Question:
You went shopping to buy cakes and donuts with X yen (the currency of Japan).
First, you bought one cake for A yen at a cake shop.
Then, you bought as many donuts as possible for B yen each, at a donut shop.
Finally, you see mochi for sale for abs(A-B) yen each, where abs(n) refers to the absolute value of n.
How much do you have left after shopping?

-----Constraints-----
 - 1 \leq A, B \leq 1 000
 - A + B \leq X \leq 10 000
 - X, A and B are integers.

-----Input-----
Input is given from Standard Input in the following format:
X
A
B

-----Output-----
Print the amount you have left after shopping.

-----Sample Input-----
1234
150
100

-----Sample Output-----
84

You have 1234 - 150 = 1084 yen left after buying a cake.
With this amount, you can buy 10 donuts, after which you have 84 yen left.


Question:
Polycarp has created his own training plan to prepare for the programming contests. He will train for $n$ days, all days are numbered from $1$ to $n$, beginning from the first.

On the $i$-th day Polycarp will necessarily solve $a_i$ problems. On even-indexed days, he is twice as good at solving problems as normal. One evening Polycarp plans to celebrate the equator. He will celebrate it on the first evening of such a day that from the beginning of the training and to this day inclusive he will solve half or more of all the problems.

Determine the index of day when Polycarp will celebrate the equator.

-----Input-----

The first line contains a single integer $n$ ($1 \le n \le 200\,000$) — the number of days to prepare for the programming contests.

The second line contains a sequence $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10\,000$), where $a_i$ equals to the number of problems, which Polycarp will solve on the $i$-th day.

-----Output-----

Print the index of the day when Polycarp will celebrate the equator.

-----Examples-----
Input
4
1 3 2 1

Output
2

Input
6
2 2 2 2 2 2

Output
3

-----Note-----

In the first example Polycarp will celebrate the equator on the evening of the second day, because up to this day (inclusive) he will solve $4$ out of $7$ scheduled problems on four days of the training.

In the second example Polycarp will celebrate the equator on the evening of the third day, because up to this day (inclusive) he will solve $6$ out of $12$ scheduled problems on six days of the training.

["def main():\n    n = int(input())\n    a = list(int(x) for x in input().split())\n    s = sum(a)\n    t = 0\n    for i in range(n):\n        t += a[i]\n        if 2 * t >= s:\n            print(i + 1)\n            return\n\nmain()\n", "#!/bin/python\n\nn = int(input())\nl = list(map(int, input().split()))\ns = sum(l)\n\ns2 = 0\nfor i in range(len(l)):\n    s2 += l[i]\n    if s2 >= s / 2:\n        print(i+1)\n        break\n", "def inpmap():\n    return list(map(int, input().split()))\nn = int(input())\narr = list(inpmap())\ns = sum(arr)\na = 0\nfor i in range(n):\n    a += arr[i]\n    if a >= s / 2:\n        print(i + 1)\n        break\n", "n = int(input())\n\nxs = [int(x) for x in input().split()]\n\nss = sum(xs)\n\ns = 0\nfor i in range(n):\n    s += xs[i]\n    if s * 2 >= ss:\n        print(i+1)\n        break\n", "n = int(input())\na = list(map(int, input().split()))\ns = sum(a)\ns1 = 0\ni = 0\nwhile s1 * 2 < s:\n    s1 += a[i]\n    i += 1\nprint(i)\n", "\ninput()\nl=[int(i)for i in input().split()]\nd = sum(l)\nx = 0\nfor i in range(len(l)):\n\tx += l[i]\n\tif 2*x >= d:\n\t\tprint(i + 1)\n\t\treturn", "import atexit\nimport io\nimport sys\nimport math\n\n# Buffering IO\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n_OUTPUT_BUFFER = io.StringIO()\nsys.stdout = _OUTPUT_BUFFER\n\n@atexit.register\ndef write():\n    sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())\n    \n\ndef main():\n    n = int(input())\n    a = [int(x) for x in input().split()]\n    aa = sum(a)\n    cc = 0\n    for i in range(n):\n        cc += a[i]\n        if cc >= math.ceil(aa / 2):\n            print(i+1)\n            break\n        \n        \n    #graph = [{} for _ in range(n)]\n    #print(mat([n, n]))\n\n    \ndef __starting_point():\n    main()\n\n__starting_point()", "n = int(input())\nl = list(map(int, input().split()))\ns = (sum(l)+1)//2\nx = 0\nfor i in range(len(l)):\n    x += l[i]\n    if x>=s:\n        print(i+1)\n        return", "n = int(input())\na=list(map(int,input().split()))\ns = sum(a)\ns2 = 0\nfor i in range(n):\n    s2+=a[i]\n    if s2 >= s/2:\n        print(i+1)\n        break\n", "n=int(input())\na=list(map(int,input().split()))\nsum1=sum(a)\nso=0\nfor i in range(n):\n     so+=a[i]\n     if(so>=sum1/2):\n         ans=i\n         break\nprint(ans+1)\n\n", "n = int(input())\nmas = list(map(int, input().split()))\ns = sum(mas)\nsc = 0\nfor i in range(len(mas)):\n    sc += mas[i]\n    if sc >= s/2:\n        print(i+1)\n        break\n", "# A\n# A = list(map(int, input().split()))\n\nN = int(input())\nA = list(map(int, input().split()))\nSUM = 0\nSUM_A = sum(A)\nfor i in range(len(A)):\n    SUM += A[i]\n    if SUM >= SUM_A / 2:\n        print(i+1)\n        quit()\n", "n = int(input())\na = [int(i) for i in input().split()]\ns = sum(a)\nss = 0\nfor i in range(n):\n    ss += a[i]\n    if (ss * 2 >= s):\n        print(i + 1)\n        break\n", "from math import ceil\nn = int(input())\nA = list(map(int, input().split()))\ne = ceil(sum(A) / 2)\ns = 0\ni = 0\nwhile s < e:\n  s += A[i]\n  i += 1\nprint(i)", "input()\nn = [int(x) for x in input().split()]\ns = sum(n)\ntrgt = s // 2 + s % 2\n\nfor i, x in enumerate(n):\n    trgt -= x\n    if trgt <= 0:\n        print(i+1)\n        break", "while True:\n    n = int(input())\n\n    A=input().split()\n\n    for index in range(0, n):\n        A[index] = int(A[index])\n\n    S = sum(A)\n    x = 0\n\n    for index in range(0, n):\n        x += A[index]\n\n        if x*2 >= S:\n            print(index+1)\n            break\n\n    break\n", "n = int(input())\narr = list(map(int, input().split()))\ns = sum(arr)\ns /= 2\ns1 = 0\nfor i in range(n):\n    s1 += arr[i]\n    if s1 >= s:\n        print(i+1)\n        break\n", "N = int(input())\narr = list(map(int, input().split()))\nS = sum(arr)\ncur = 0\nidx = 0\n\nfor item in arr:\n    cur += item\n    idx += 1\n    if (cur >= S/2):\n        print(idx)\n        break\n\n", "n=int(input())\nL=list(map(int,input().split()))\ns=sum(L)\nx=0\nfor i in range(n):\n    x+=L[i]\n    if x>=s/2:\n        print(i+1)\n        break\n", "import math\nn=int(input())\na=list(map(int,input().split()))\nsu=sum(a)\nsu=math.ceil(su/2)\n\nc=0\nfor i in range(len(a)):\n    c+=a[i]\n    if c>=su:\n        print(i+1)\n        break\n", "R = lambda: list(map(int, input().split()))\n\nn = R()\na = tuple(R())\ns0 = sum(a) / 2\ns = 0\nfor i in range(len(a)):\n    s += a[i]\n    if s >= s0:\n        print(i+1)\n        break\n", "import sys\n\nn = int(sys.stdin.readline())\nnums = list(map(int, sys.stdin.readline().split()))\nnsum = sum(nums) / 2\ncsum = 0\nfor i in range(n):\n    csum += nums[i]\n    if csum >= nsum:\n        print(i + 1)\n        break\n", "n = int(input())\n\nl = list(map(int, input().split()))\n\ns = sum(l)\n\ncs = 0\nfor i in range(len(l)):\n\tcs += l[i]\n\tif cs * 2 >= s:\n\t\tprint(i + 1)\n\t\tbreak", "n = int(input())\na = list(map(int, input().split()))\ns = sum(a) / 2\n\nfor i in range(n):\n    s -= a[i]\n    if s <= 0:\n        print(i+1)\n        break\n", "n = int(input())\nai = list(map(int, input().split()))\nsumm = sum(ai)\nsumm = summ % 2 + summ // 2\nsumm2 = 0\nans = 0\nfor i in range(n):\n    summ2 += ai[i]\n    if summ2 >= summ:\n        ans = i+1\n        break\nprint(ans)\n"]


Question:
Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains a number, all numbers on the cards are distinct. There is also one token at each of the two ends of the row, containing the number 5. The players take turns, Sereja moves first. During his turn a player can take one card: either the leftmost card in a row, or the rightmost one. The game ends when there is no more cards. The player who has the maximum sum of numbers on his cards by the end of the game, wins.

Sereja and Dima are being greedy. Each of them chooses the card with the larger number during his move. Additionally, each turn Dima tries and fails to cheat by incrementing his sum by 1.

Inna is a friend of Sereja and Dima. She knows which strategy the guys are using, so she wants to determine the final score, given the initial state of the game. Help her.

-----Input-----

The first line contains integer n (1 ≤ n ≤ 1000) — the number of cards on the table. The second line contains space-separated numbers on the cards from left to right. The numbers on the cards are distinct integers from 1 to 1000.

-----Output-----

On a single line, print two integers. The first number is the number of Sereja's points at the end of the game, the second number is the number of Dima's points at the end of the game.

-----Examples-----
Input
4
4 1 2 10

Output
12 5

Input
7
1 2 3 4 5 6 7

Output
16 12

-----Note-----

In the first sample Sereja will take cards with numbers 10 and 2, so Sereja's sum is 12. Dima will take cards with numbers 4 and 1, so Dima's sum is 5.

["n=int(input())\na=list(map(int,input().split()))\nb=True\nl=0\nr=n-1\nans1=0\nans2=0\nwhile l<=r:\n    if a[l]>a[r]:\n        if b:\n            ans1+=a[l]\n            b=False\n        else:\n            ans2+=a[l]\n            b=True\n        l+=1\n    else:\n        if b:\n            ans1+=a[r]\n            b=False\n        else:\n            ans2+=a[r]\n            b=True   \n        r-=1\nprint(ans1,ans2)", "n=int(input())\na=list(map(int,input().split()))\nl=0\nr=n-1\nb=[0,0]\nfor i in range(n):\n    if a[l]>a[r]:\n        b[i%2]+=a[l]\n        l+=1\n    else:\n        b[i%2]+=a[r]\n        r-=1\nprint(b[0],b[1])", "from collections import deque\n\nn = int(input())\n\nnumbers = deque()\naux = list(map(int, input().split()))\n\nfor i in range(n):\n    numbers.append(aux[i])\n\nser, dim  = 0, 0\n\nfor i in range(n):\n    if numbers[0] > numbers[-1]:\n        if i % 2 == 0:\n            ser += numbers[0]\n        else:\n            dim += numbers[0]\n        numbers.popleft()\n    else:\n        if i % 2 == 0:\n            ser += numbers[-1]\n        else:\n            dim += numbers[-1]\n        numbers.pop()\n\nprint(ser, dim)", "n = int(input())\na = list(map(int, input().split()))\nb = [0, 0]\nc = 0\nwhile n:\n    if a[0] > a[n-1]:\n        b[c] += a[0]\n        a = a[1:n]\n    else:\n        b[c] += a[n-1]\n        a = a[0:n-1]\n    c = 1-c\n    n -= 1\nprint(\"%d %d\" % (b[0], b[1]))\n\n", "n = input()\nline = list(map(int, input().split()))\nsum = [0, 0]\nplayer = 1\nwhile len(line) > 0:\n    if line[0] > line[-1]:\n        sum[player] += line[0]\n        player = not player\n        line.remove(line[0])\n    else:\n        sum[player] += line[-1]\n        player = not player\n        line.remove(line[-1])\nprint(sum[1], sum[0])", "n=int(input())\na=list(map(int,input().split()))\ns=0;d=0;\nfor i in range(1,n+1):\n    maxi=max(a[0],a[-1])\n    ind=a.index(maxi)\n    a.pop(ind)\n    if(i%2!=0):\n        s+=maxi\n    else:\n        d+=maxi\nprint(s,d)\n        \n        \n    \n", "n = int(input())\ns1=0\ns2=0\na = list(map(int, input().split()))\nr = n-1\nl = 0\nk = 0\nfor i in range(n):\n    if a[l]>a[r]:\n        if k == 0:\n            s1+=a[l]\n            k = 1\n        else:\n            s2+=a[l]\n            k = 0\n        l += 1\n        \n    else:\n        if k == 0:\n            s1+=a[r]\n            k = 1\n        else:\n            s2+=a[r]\n            k = 0\n        r -= 1\nprint(s1,s2)", "import sys\ndef main():\n    \n    l=sys.stdin.readline()\n\n    l=sys.stdin.readline()\n    l=l.split()\n    for i in range(len(l)):\n        l[i]=int(l[i])\n    \n    ser=len(l)-1\n    dim=0\n    s_ser=0\n    s_dim=0\n \n    while ser>dim:\n        \n        if l[dim] > l[ser]:\n            s_ser+=l[dim]\n            dim+=1\n        else:\n            s_ser+=l[ser]\n            ser-=1\n        if l[dim] > l[ser]:\n            s_dim+=l[dim]\n            dim+=1\n        else:\n            s_dim+=l[ser]\n            ser-=1\n       \n    if ser==dim:\n        s_ser+=l[ser]\n    print (s_ser , s_dim)\n\ndef __starting_point():\n    main()\n__starting_point()", "import sys\n\n\ndef main():\n    left = 0\n    right = int(input()) - 1\n    arr = [int(k) for k in input().split()]\n    score = [0, 0]\n    i = 0\n\n    while left != right:\n        if arr[left] > arr[right]:\n            score[i] += arr[left]\n            left += 1\n        else:\n            score[i] += arr[right]\n            right -= 1\n        i += 1\n        i %= 2\n\n    score[i] += arr[left]\n    print(score[0], score[1])\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "n = int(input())\ntest = []\ntest = list(map(int, input().split()))\nleft = 0\nright = len(test)-1\n\na = []\nb = []\n\nwhile test:\n    if test[left] > test[right]:\n        a.append(test[left])\n        test.remove(test[left])\n        right = len(test)-1\n    else:\n        a.append(test[right])\n        test.remove(test[right])\n        right = len(test)-1\n    if test:\n        if test[left] > test[right]:\n            b.append(test[left])\n            test.remove(test[left])\n            right = len(test)-1\n        else:\n            b.append(test[right])\n            test.remove(test[right])\n            right = len(test)-1\n\nprint(sum(a), sum(b))\n", "n=int(input())\nz=[int(x) for x in input().split()]\n\ntot1=0\ntot2=0\n\nif (len(z)%2==0):\n    while (len(z)>0):\n        tot1+= max(z[0],z[-1])\n        z.remove(max(z[0],z[-1]))\n        tot2+= max(z[0],z[-1])\n        z.remove(max(z[0],z[-1]))\n    print(str(tot1)+\" \"+str(tot2))\n\nelse:\n    while(1):\n        tot1+=max(z[0],z[-1])\n        z.remove(max(z[0],z[-1]))\n        if (len(z)==0):\n            break\n        else:\n            tot2+=max(z[0],z[-1])\n            z.remove(max(z[0],z[-1]))\n            if (len(z)==0):\n                break\n            else:\n                continue        \n    print(str(tot1)+\" \"+str(tot2))\n                 \n", "n = int(input())\ncards = list(map(int, input().split()))\ns = True\nd = False\nps = 0\npd = 0\nwhile len(cards) > 0:\n    if s:\n        if cards[0] > cards[-1]:\n            ps += cards[0]\n            t = 0\n        else:\n            ps += cards[-1]\n            t = -1\n        s = False\n        d = True\n        cards.pop(t)\n    elif d:\n        if cards[0] > cards[-1]:\n            pd += cards[0]\n            t = 0\n        else:\n            pd += cards[-1]\n            t = -1\n        s = True\n        d = False\n        cards.pop(t)\n\nprint(ps, pd)", "n=int(input())\na=[0]*1010\nname=1\nser=0\ndim=0\na=list(map(int, input().split()))\nflag=1\nwhile n>1:\n    if name%2!=0:\n        ser+=max(a[0],a[n-1])\n        if a[0]>a[n-1]:\n            del a[0]\n        else:\n            del a[n-1]\n    else:\n        dim+=max(a[0],a[n-1])\n        if a[0]>a[n-1]:\n            del a[0]\n        else:\n            del a[n-1]\n    n-=1\n    name+=1\nif name%2!=0:\n    ser+=a[0]\nelse:\n    dim+=a[0]\nprint(ser,dim)\n        \n", "num=int(input())\ntxt=input()\npoints=txt.split(\" \")\nscore=[0,0]\nturn=0\nwhile len(points)>0:\n    maxp=max(int(points[0]),int(points[-1]))\n    score[turn]+=maxp\n    points.remove(str(maxp))\n    turn=(turn+1)%2\nprint(score[0],score[1])", "from collections import deque\n\n__author__ = 'asmn'\nn=int(input())\n\na=deque(map(int,input().split()))\ns=[0,0]\nnow=0\nwhile len(a) > 0:\n    if a[0] > a[-1]:\n        s[now] += a.popleft()\n    else:\n        s[now] +=a.pop()\n    now = 1-now\n\nprint(s[0],s[1])", "n=int(input())\na=list(map(int,input().split()))\ni=0\nj=n-1\nb=[0]*2\nt=0\nwhile i<=j:\n    if a[i]>a[j]:\n        b[t]+=a[i]\n        i+=1\n    else:\n        b[t]+=a[j]\n        j-=1\n    t^=1\nprint(b[0],b[1])\n", "\ninput()\ninput_raw = [int(x) for x in input().split(' ')]\n\ns = 0\nd = 0\ni = True\n\nwhile input_raw != []:\n    if input_raw[0] > input_raw[-1]:\n        cur = input_raw[0]\n        del(input_raw[0])\n    else:\n        cur = input_raw[-1]\n        del(input_raw[-1])\n\n    if i:\n        s += cur\n        i = False\n    else:\n        d += cur\n        i = True\n\nprint(s, d)", "n, t = int(input()), list(map(int, input().split()))\ns, i, j = [0, 0], 0, n - 1\nfor k in range(n):\n    if t[i] < t[j]:\n        s[k % 2] += t[j]\n        j -= 1\n    else:\n        s[k % 2] += t[i]\n        i += 1\nprint(s[0], s[1])", "from sys import stdin, stdout\n\ndef solve(c, n):\n\ts_res = 0\n\td_res = 0\n\tturn = 's'\n\twhile len(c) > 0:\n\t\tleft_is_max = c[0] > c[-1]\n\t\tmax_card = c.pop(0 if left_is_max else -1)\n\t\tif turn == 's':\n\t\t\ts_res += max_card\n\t\t\tturn = 'd'\n\t\telse:\n\t\t\td_res += max_card\n\t\t\tturn = 's'\n\treturn (s_res, d_res)\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\tresult = solve(cards, n)\n\tprint(result[0], result [1])\n__starting_point()", "num = int(input())\ncards = input()\ncards = [int(i) for i in cards.split()]\n\nbegin = 0\nend = num-1\n\nsereja = 0\ndima = 0\nturn = 0\n\nfor i in range(0,num):\n    if turn == 0:\n        if cards[begin] > cards[end]:\n            sereja += cards[begin]\n            begin += 1\n        else:\n            sereja += cards[end]\n            end -= 1\n        turn = 1\n\n    else:\n        if cards[begin] > cards[end]:\n            dima += cards[begin]\n            begin += 1\n        else:\n            dima += cards[end]\n            end -= 1\n        turn = 0\n\nprint(sereja, dima)\n", "# -*- coding: utf-8 -*-\nimport sys\n\nn = int(sys.stdin.readline())\na = [int(x) for x in sys.stdin.readline().split(' ')]\n\nsum = [0, 0]\nstart = 0\nend = n-1\ni = 0\nwhile start != end:\n    if a[start] >= a[end]:\n        sum[i] += a[start]\n        start += 1\n    else:\n        sum[i] += a[end]\n        end -= 1\n    i = (i+1) % 2\nsum[i] += a[start]\nprint(sum[0], sum[1])\n", "# -*- coding: utf-8 -*-\nimport sys\n\nn = int(sys.stdin.readline())\na = [int(x) for x in sys.stdin.readline().split(' ')]\n\nsum = [0, 0]\ni, start, end = 0, 0, n-1\nwhile start <= end:\n    if a[start] >= a[end]:\n        sum[i] += a[start]\n        start += 1\n    else:\n        sum[i] += a[end]\n        end -= 1\n    i ^= 1\nprint(sum[0], sum[1])\n", "import sys\n\n\nflag = 0\nsereja = 0\ndima = 0\n\n\nn = int(sys.stdin.readline())\nlista = sys.stdin.readline().split()\n\nfor i  in range(n):\n    lista[i] = int(lista[i])\n\nactual = 0\nwhile len(lista)>0:\n    if len(lista) == 1:\n        actual = lista.pop()\n    else:\n        if lista[0]>lista[-1]:\n            actual = lista.pop(0)\n        else:\n            actual = lista.pop()\n    if flag == 0:\n        sereja += actual\n        flag = 1\n    else:\n        dima +=actual\n        flag = 0\n\n\nprint(sereja,\" \",dima)\n", "#-------------------------------------------------------------------------------\n# Name:        \u00d0\u00a0\u00c2\u00a0\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00e2\u20ac\u2122\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00c2\u00a0\u00d0\u00a0\u00d0\u2039\u00d0\u00a0\u00e2\u20ac\u2122\u00d0\u2019\u00c2\u02dc\u00d0\u00a0\u00c2\u00a0\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00e2\u20ac\u2122\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00c2\u00a0\u00d0\u00a0\u00d0\u2039\u00d0\u00a0\u00d0\u2020\u00d0\u00a0\u00e2\u20ac\u0161\u00d0\u00a1\u00d1\u203a\u00d0\u00a0\u00c2\u00a0\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00e2\u20ac\u2122\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00c2\u00a0\u00d0\u00a1\u00d1\u203a\u00d0\u00a0\u00d0\u2020\u00d0\u00a0\u00e2\u20ac\u0161\u00d0\u2019\u00c2\u02dc\u00d0\u00a0\u00c2\u00a0\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00c2\u00a0\u00d0\u00a0\u00e2\u20ac\u00b9\u00d0\u00a0\u00c2\u00a0\u00d0\u00a0\u00d0\u2039\u00d0\u00a0\u00d0\u2020\u00d0\u00a0\u00e2\u20ac\u0161\u00d0\u00a1\u00d1\u2122\u00d0\u00a0\u00c2\u00a0\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00e2\u20ac\u2122\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00c2\u00a0\u00d0\u00b2\u00d0\u201a\u00e2\u201e\u00a2\u00d0\u00a0\u00e2\u20ac\u2122\u00d0\u2019\u00c2\u00bb\u00d0\u00a0\u00c2\u00a0\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00c2\u00a0\u00d0\u00a0\u00e2\u20ac\u00b9\u00d0\u00a0\u00c2\u00a0\u00d0\u2019\u00c2\u00a0\u00d0\u00a0\u00c2\u00a0\u00d0\u00b2\u00d0\u201a\u00c2\u00b01\n# Purpose:\n#\n# Author:      Anatoliy\n#\n# Created:     30.09.2013\n# Copyright:   (c) Anatoliy 2013\n# Licence:     <your licence>\n#-------------------------------------------------------------------------------\n\ndef main():\n    number_of_elements = int(input())\n    s = input()\n    s_list = s.split(\" \")\n    for i in range(0, number_of_elements):\n        s_list[i] = int(s_list[i])\n\n\n    sereja = 0\n    dima = 0\n\n    for i in range(0, int(number_of_elements/2)):\n        if s_list[0] > s_list[-1]:\n            sereja = sereja + s_list.pop(0)\n        else:\n            sereja = sereja + s_list.pop(-1)\n        if s_list[0] > s_list[-1]:\n            dima = dima + s_list.pop(0)\n        else:\n            dima = dima + s_list.pop(-1)\n    sereja = sereja + sum(s_list)\n    print(str(sereja) + \" \" + str(dima))\n\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "n = int(input())\na = list(map(int,input().split()))\ni = 0\nj = n - 1\nnow = 1\nans1 = 0\nans2 = 0\nwhile (i <= j):\n\tcur = 0\n\tif (a[i] > a[j]):\n\t\tcur = a[i]\n\t\ti += 1\n\telse:\n\t\tcur = a[j]\n\t\tj -= 1\n\tif (now == 1):\n\t\tans1 += cur\n\telse:\n\t\tans2 += cur\n\tnow = 1 - now\nprint(ans1, ans2)\n\t\n"]


Question:
There are $b$ boys and $g$ girls participating in Olympiad of Metropolises. There will be a board games tournament in the evening and $n$ participants have accepted the invitation. The organizers do not know how many boys and girls are among them.

Organizers are preparing red badges for girls and blue ones for boys. However, three of the girls like blue, and five of the boys like red.

Vasya prepared $n+1$ decks of badges. The $i$-th (where $i$ is from $0$ to $n$, inclusive) deck contains $i$ blue badges and $n-i$ red ones. The total number of badges in any deck is exactly $n$.

Determine the minimum number of decks among these $n+1$ that Vasya should take, so that there will be a suitable deck no matter how many girls and boys there will be among the participants of the tournament.

-----Input-----

The first line contains an integer $b$ ($1 \le b \le 300$), the number of boys.

The second line contains an integer $g$ ($1 \le g \le 300$), the number of girls.

The third line contains an integer $n$ ($1 \le n \le b + g$), the number of the board games tournament participants.

-----Output-----

Output the only integer, the minimum number of badge decks that Vasya could take.

-----Examples-----
Input
5
6
3

Output
4

Input
5
3
5

Output
4

-----Note-----

In the first example, each of 4 decks should be taken: (0 blue, 3 red), (1 blue, 2 red), (2 blue, 1 red), (3 blue, 0 red).

In the second example, 4 decks should be taken: (2 blue, 3 red), (3 blue, 2 red), (4 blue, 1 red), (5 blue, 0 red). Piles (0 blue, 5 red) and (1 blue, 4 red) can not be used.

["def main():\n    import sys\n    input = sys.stdin.readline\n    \n    b = int(input())\n    g = int(input())\n    n = int(input())\n    \n    ans = n + 1\n    if b < n:\n        ans -= n - b\n    if g < n:\n        ans -= n - g\n    \n    print(ans)\n    \n    return 0\n\nmain()\n", "b = int(input())\ng = int(input())\nn = int(input())\n\nres = 0\nfor i in range(n+1):\n    if i <= b and (n-i) <= g: res += 1\n        \nprint(res)", "b = int(input())\ng = int(input())\nn = int(input())\n\nb = min(n, b)\ng = min(n, g)\n\nmx = b\nmn = 0\n\nif g < n:\n    mn = n - g\n\nprint(mx - mn + 1)\n", "b=int(input())\ng=int(input())\nn=int(input())\n\nans=0\nfor i in range(n+1):\n    bb=i\n    gg=n-i\n    if bb<=b and gg<=g:\n        ans+=1\n\nprint(ans)", "b = int(input())    \ng = int(input())\nn = int(input())\nres = sum(1 for i in range(n + 1) if b >= i and g >= (n - i))\nprint(res)\n", "b = int(input())\ng = int(input())\nn = int(input())\nwyn = 0\nfor bb in range(b + 1):\n    if n - bb in range(g + 1):\n        wyn += 1\nprint(wyn)", "b, g, n = int(input()), int(input()), int(input())\n\nbadges = set()\n\nfor i in range(n + 1):\n\n    if i <= b and n - i <= g:\n        badges.add((i, n - i))\n\nprint(len(badges))", "b, g, n = [int(input()) for i in range(3)]\nmax_man = min(n, b)\nmax_girl = min(n, g)\nmin_man = n - max_girl\nprint(max(0, max_man - min_man + 1))\n", "b = int(input())\ng = int(input())\nn = int(input())\n\nx = y = 0\nif n > b:\n    x = n - b\nif n > g:\n    y = n - g\n\nprint(n+1 - x - y)", "boy = int(input())\ngirl = int(input())\nn = int(input())\ncnt = 0\nfor i in range(0, n + 1):\n    j = n - i\n    if i <= boy and j <= girl:\n        cnt += 1\nprint(cnt)", "b = int(input())\ng = int(input())\nn = int(input())\n\nmax_boy = min(b, n)\nmin_boy = max(n-g, 0)\nprint(max_boy - min_boy + 1)", "b = int(input())\ng = int(input())\nn = int(input())\n\nprint(max(min(b,n)-max(0,(n-g))+1,0))", "import sys\ninput = sys.stdin.readline\n\nb=int(input())\ng=int(input())\nn=int(input())\n\nprint(n+1-max(n-b,0)-max(n-g,0))\n", "def solvea():\n    n = int(input())\n    d = int(input())\n    e = 5 * int(input())\n    best = 0\n    for enr in range((n + e - 1) // e):\n        curr = e * enr\n        curr += d * ((n - curr) // d)\n        if curr <= n and curr > best:\n            best = curr\n    print(n - best)\n\ndef solveb():\n    a = int(input())\n    b = int(input())\n    n = int(input())\n    ans = 0\n    for i in range(a + 1):\n        for j in range(b + 1):\n            if i + j == n:\n                ans += 1\n    print(ans)\n\n\ndef __starting_point():\n    solveb()\n\n__starting_point()", "b = int(input())\ng = int(input())\nn = int(input())\nans = 0\nfor i in range(n+1):\n    if i > b:\n        continue\n    if n - i > g:\n        continue\n    ans += 1\n\nprint(ans)", "b = int(input())\ng = int(input())\nn = int(input())\nif b>=n and g>=n:\n    print(n+1)\nelif b>=n and g<n:\n    print(g+1)\nelif g>=n and b<n:\n    print(b+1)\nelse:\n    print(b+g-n+1)\n", "b = int(input())\ng = int(input())\nn = int(input())\n\nprint(min([b, g, n, b + g - n]) + 1)", "import sys \nfrom collections import defaultdict\ninput = lambda : sys.stdin.readline().rstrip()\n\nb = int(input())\ng = int(input())\nn = int(input())\n\nans = 0 \nfor i in range(n + 1):\n  if i <= b and n - i <= g:\n    ans += 1\n\nprint(ans)\n", "\na = int(input())\nb = int(input())\nn = int(input())\nm = max(0, n - b)\n\nM = min(a, n)\nprint(M - m + 1)\n", "b=int(input())\ng=int(input())\nn=int(input())\ncnt=0\nfor i in range(n+1):\n    if i<=b and (n-i)<=g:\n        cnt += 1\nprint(cnt)", "b = int(input())\ng = int(input())\nn = int(input())\nif n<b and n<g:\n  out = n+1\nelif n<b and g==n:\n  out = n+1-n+b\nelif n==b and g<n:\n  out = n+1-n+g\nelif n<=g:\n  out = n+1-n+b\nelif n<=b:\n  out = n+1-n+g\nelse:\n  out = n+1-n+g-n+b\nprint(out)", "b=int(input())\nr=int(input())\nn=int(input())\nprint(n+1-max(0,n-r)-max(0,n-b))", "def badges(b,g,n):\n    p = [(i,n-i) for i in range(n+1)]\n    count = 0\n    for i in p:\n        if i[0] <= b and i[1] <= g:\n            count += 1\n    return count\n\nb = int(input())\ng = int(input())\nn = int(input())\nprint(badges(b,g,n))", "b=int(input())\ng=int(input())\nn=int(input())\nl=[]\ncount=0\nfor i in range(n+1):\n    x1=i\n    x2=n-i\n    if (x1<=b and x2<=g):\n        count+=1\n    else:\n        continue\nprint(count)", "def gcd(x,y):\n    if(y==0):\n        return x\n    return gcd(y,x%y)\n\n\n\n\nb = int(input())\ng = int(input())\nn = int(input())\nmb = max(0, n - g)\nmg = max(0, n - b)\nmab = min(n, b)\nmag = min(n, g)\ncb = mab - mb\ncg = mag - mg\nprint(min([cb+1, cg +1, n + 1]))\n\n        \n"]


Question:
Vasya has n pairs of socks. In the morning of each day Vasya has to put on a pair of socks before he goes to school. When he comes home in the evening, Vasya takes off the used socks and throws them away. Every m-th day (at days with numbers m, 2m, 3m, ...) mom buys a pair of socks to Vasya. She does it late in the evening, so that Vasya cannot put on a new pair of socks before the next day. Additionally, every 2m-th day (at days with numbers 2m, 4m, 6m...) the socks that mom buys for Vasya are extremely ugly. How many consecutive days pass until Vasya runs out of socks?

-----Input-----

The single line contains two integers n and m (1 ≤ n ≤ 100; 2 ≤ m ≤ 100), separated by a space.

-----Output-----

Print a single integer — the answer to the problem.

-----Examples-----
Input
2 2

Output
3

Input
9 3

Output
13

-----Note-----

In the first sample Vasya spends the first two days wearing the socks that he had initially. Then on day three he puts on the socks that were bought on day two.

In the second sample Vasya spends the first nine days wearing the socks that he had initially. Then he spends three days wearing the socks that were bought on the third, sixth and ninth days. Than he spends another day wearing the socks that were bought on the twelfth day.

["\"\"\"\nCodeforces Contest 262 Div 2 Problem A\n\nAuthor  : chaotic_iak\nLanguage: Python 3.3.4\n\"\"\"\n\ndef main():\n    n,m = read()\n    i = 0\n    while n:\n        n -= 1\n        i += 1\n        if not i%m: n += 1\n    print(i)\n\n################################### NON-SOLUTION STUFF BELOW\n\ndef read(mode=2):\n    # 0: String\n    # 1: List of strings\n    # 2: List of integers\n    inputs = input().strip()\n    if mode == 0: return inputs\n    if mode == 1: return inputs.split()\n    if mode == 2: return list(map(int, inputs.split()))\n\ndef write(s=\"\\n\"):\n    if s is None: s = \"\"\n    if isinstance(s, list): s = \" \".join(map(str, s))\n    s = str(s)\n    print(s, end=\"\")\n\nwrite(main())", "n, m = map(int, input().split())\nday = 1\nwhile n > 0:\n    n -= 1\n    if day % m == 0:\n        n += 1\n    day += 1\n\nprint(day - 1)", "n, m = map(int, input().split())\ncount = n\nday = 1\nwhile count != 0:\n    count -= 1\n    if day % m == 0:\n        count += 1\n    if count!=0:\n        day+=1\nprint(day)", "n, m = map(int, input().split())\nday = 0\nwhile n != 0:\n    day += 1\n    n -= 1\n    if (day % m == 0):\n        n += 1\n    \nprint(day)", "3\n\nimport sys\n\n\ndef __starting_point():\n\n    n, m = list(map(int, sys.stdin.readline().split()))\n    d = 0\n    while n > 0:\n        d += 1\n        n -= 1\n        if d % m == 0:\n            n += 1\n\n    print(d)\n\n__starting_point()", "n,m = [int(x) for x in input().split()]\ni = 0\nwhile n > 0:\n     n -= 1\n     i += 1\n     if i % m == 0:\n         n += 1\nprint(i)\n", "n,m = map(int, input().split())\ncd = 0\nwhile n > 0:\n    cd += 1\n    n -= 1\n    if cd % m == 0:\n        n += 1\nprint(cd)", "n, m = list(map(int, input().split()))\nr = 0\nwhile n >= m:\n    r += m\n    n -= m - 1\nprint(r + n)\n", "n,m = [int(i) for i in input().split()]\ntime = 0\nimport sys\nwhile n > 0:\n\tif n < m:\n\t\tprint(time+n)\n\t\treturn\n\tn -= m-1\n\ttime += m", "n,m=map(int,input().split())\nans=1\nwhile n!=0:\n    if ans%m==0:\n        n+=1\n    n-=1\n    ans+=1\nprint(ans-1)", "def main():\n    n, m = [int(i) for i in input().split()]\n    \n    day = 1\n    while n > 0:\n        if day % m == 0:\n            n += 1\n        n -= 1\n        day += 1\n    \n    print(day - 1)\n\n\nmain()\n", "def main():\n\tn,m=map(int,input().split(\" \"))\n\td=0\n\twhile True:\n\t\td+=1\n\t\tn-=1\n\t\tif d % m == 0:\n\t\t\tn+=1\n\t\t\tpass\n\t\tif n == 0:\n\t\t\tbreak\n\t\t\tpass\n\t\tpass\n\tprint (d)\n\tpass\n\nmain()", "n, m = map(int, input().split())\n\naux = [1 for i in range(n + 1)]\nans = 0\ni = 1\nwhile i < len(aux):\n    \n    if i % m == 0:\n        aux.append(1)\n    ans += 1\n    i += 1\n\nprint(ans)", "# Codeforces 262 Div. 2\n# P1\n\nl = input().split()\nn = int(l[0])\nm = int(l[1])\n\nc = 0\np = 1\nwhile n != 0:\n    n -= 1\n    if p == m:\n        n += 1\n        p = 1\n    else:\n        p += 1\n    c += 1\n    \nprint(c)\n", "n, m = [int(i) for i in input().split()]\na = [0] * 300\nfor i in range(m, 300, m):\n    a[i + 1] = 1\nk = 0\nwhile k < 299 and n > 0:\n    k += 1\n    if a[k] == 1:\n        continue\n    a[k] = 1\n    n -= 1\nfor i in range(1, 300):\n    if a[i] == 0:\n        k = i - 1\n        break\nprint(k)\n    \n", "a=[int(i) for i in input().split()]\nn=a[0]\nm=a[1]\ns=0\nwhile n>=m:\n    s+=m\n    n=n-m+1\ns+=n\nprint(s)", "n, m = map(int, input().split())\ncount = 0\ni = 0\n\nwhile True:\n    n -= 1\n    if n < 0:\n        print(count - 1)\n        return\n    if i % m == 0:\n        n += 1\n    count += 1\n    i += 1", "n,m = list(map(int,input().split()))\nt = 0\nwhile(n!=0):\n\tn = n-1\n\tt = t+1\n\tif(t%m==0):\n\t\tn= n+1\nprint(t)\n", "def solve():\n    n,m=list(map(int,input().split()))\n    i=0\n    while n!=0:\n        i+=1\n        n-=1\n        if i%m==0:\n            n+=1\n    print(i)\nsolve()\n", "n, m = list(map(int, input().split()))\nday = 0\nwhile True:\n    if n == 0:\n        print(day)\n        break\n    n -= 1\n    if day % m == m - 1:\n        n += 1\n    day += 1\n", "n,m = list(map(int,input().split()))\nc = 0\nwhile n!=0:\n    n-=1\n    c+=1\n    if c%m==0:\n        n+=1\nprint(c)\n    \n", "n, m = list(map(int, input().split()))\nnow = n\nday = 1\nwhile now > 0:\n    now -= 1\n    if day % m == 0:\n        now += 1\n    day += 1\nprint(day - 1)\n", "n, m = map(int, input().split())\n\nd = 1\nwhile n > 0:\n    if d % m == 0:\n        n += 1\n    n-= 1\n    d+= 1\n\n\nprint(d-1)", "n, m = map(int, input().split())\nday, c = 0, 1\nwhile n != 0:\n    day += 1\n    if day == (c*m):\n        n += 1\n        c += 1\n    n -= 1\nprint(day)", "lst, n, v = list(map(int, input().split(\" \"))), 0, 0\nif lst[0] == 1 and lst[1] == 1:\n    print(2)\nelse:\n    while lst[0] > v:\n        n += 1\n        if n == lst[1]:\n            lst[0] += 1\n            n = 0\n        v += 1\n    print(lst[0])"]


Question:
Luke Skywalker got locked up in a rubbish shredder between two presses. R2D2 is already working on his rescue, but Luke needs to stay alive as long as possible. For simplicity we will assume that everything happens on a straight line, the presses are initially at coordinates 0 and L, and they move towards each other with speed v_1 and v_2, respectively. Luke has width d and is able to choose any position between the presses. Also, every 0.5 seconds, Luke tries and fails to delay his death by 0.1 seconds by pushing the walls of the rubbish shredder apart. Luke dies as soon as the distance between the presses is less than his width. Your task is to determine for how long Luke can stay alive.

-----Input-----

The first line of the input contains four integers d, L, v_1, v_2 (1 ≤ d, L, v_1, v_2 ≤ 10 000, d < L) — Luke's width, the initial position of the second press and the speed of the first and second presses, respectively.

-----Output-----

Print a single real value — the maximum period of time Luke can stay alive for. Your answer will be considered correct if its absolute or relative error does not exceed 10^{ - 6}.

Namely: 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}$.

-----Examples-----
Input
2 6 2 2

Output
1.00000000000000000000

Input
1 9 1 2

Output
2.66666666666666650000

-----Note-----

In the first sample Luke should stay exactly in the middle of the segment, that is at coordinates [2;4], as the presses move with the same speed.

In the second sample he needs to occupy the position $[ 2 \frac{2}{3} ; 3 \frac{2}{3} ]$. In this case both presses move to his edges at the same time.

["d, L, v1, v2 = list(map(int, input().split()))\nt = (L - d) / (v1 + v2)\nprint(t)\n", "d,l,v1,v2=list(map(int,input().split()))\nprint((l-d)/(v1+v2))\n", "d, l, v1, v2 = list(map(int, input().split()))\nl -= d\nif (l <= 0):\n    print(0.0)\nelse:\n    print(l/(v1+v2))\n", "#! /usr/bin/env python\n# -*- coding: utf-8 -*-\n# vim:fenc=utf-8\n#\n# Copyright \u00a9 2016 missingdays <missingdays@missingdays>\n#\n# Distributed under terms of the MIT license.\n\n\"\"\"\n\n\"\"\"\n\ndef read_list():\n    return [int(i) for i in input().split()]\ndef new_list(n):\n    return [0 for i in range(n)]\ndef new_matrix(n, m=0):\n    return [[0 for i in range(m)] for i in range(n)]\n\n\nd, l, v1, v2 = read_list()\n\nt = l / (v1+v2)\n\nt -= d / (v1+v2)\n\nprint(t)\n", "a, b, c, d = map(int, input().split())\n\nprint(\"%.10f\" % max(0, (b- a) / (c + d)))", "d, l, v1, v2 = [int(s) for s in input().split()]\nprint((l - d)/(v1+v2))\n", "def main():\n    d, l, a, b = map(int, input().split())\n    l -= d\n    ans = l / (a + b)\n    print(ans)\n    \nmain()", "d, l, v1, v2 = list(map(int, input().split()))\n\nprint((l - d) / (v1 + v2))\n", "d, l, v1, v2 = [int(i) for i in input().split()]\nprint((l-d) / (v1+v2))\n", "d,l,v1,v2=[int(x) for x in input().split()]\nprint(max(0,(l-d)/(v1+v2)))\n", "d, L, v1, v2 = list(map(int, input().split()))\nprint((L - d) / (v1 + v2))\n", "d,l,v1,v2 = list(map(int,input().split()))\nprint((l-d) / float(v1+v2))\n", "d, L, v1, v2 = list(map(int, input().split()))\nt = (v1 * (L - d))/(v1 * (v2 + v1))\nprint(t)\n"]


Question:
Cucumber boy is fan of Kyubeat, a famous music game.

Kyubeat has 16 panels for playing arranged in 4 × 4 table. When a panel lights up, he has to press that panel.

Each panel has a timing to press (the preffered time when a player should press it), and Cucumber boy is able to press at most k panels in a time with his one hand. Cucumber boy is trying to press all panels in perfect timing, that is he wants to press each panel exactly in its preffered time. If he cannot press the panels with his two hands in perfect timing, his challenge to press all the panels in perfect timing will fail. Also, at times divisible by 2 (times 2, 4, 6, and 8), Cucumber boy's left hand is very itchy.

You are given one scene of Kyubeat's panel from the music Cucumber boy is trying. Tell him is he able to press all the panels in perfect timing.

-----Input-----

The first line contains a single integer k (1 ≤ k ≤ 5) — the number of panels Cucumber boy can press with his one hand.

Next 4 lines contain 4 characters each (digits from 1 to 9, or period) — table of panels. If a digit i was written on the panel, it means the boy has to press that panel in time i. If period was written on the panel, he doesn't have to press that panel.

-----Output-----

Output "YES" (without quotes), if he is able to press all the panels in perfect timing. If not, output "NO" (without quotes).

-----Examples-----
Input
1
.135
1247
3468
5789

Output
YES

Input
5
..1.
1111
..1.
..1.

Output
YES

Input
1
....
12.1
.2..
.2..

Output
NO

-----Note-----

In the third sample boy cannot press all panels in perfect timing. He can press all the panels in timing in time 1, but he cannot press the panels in time 2 in timing with his two hands.

["k=int(input())\n\nL={}\ns=\".123456789\"\nfor item in s:\n    L[item]=0\nfor i in range(4):\n    s=input()\n    for item in s:\n        L[item]+=1\n\ns=\"123456789\"\ndone=True\nfor item in s:\n    if(L[item]>2*k):\n        print(\"NO\")\n        done=False\n        break\nif(done):\n    print(\"YES\")\n", "k = int(input())\na = [list(input()) for i in range(4)]\nx = [0 for i in range(10)]\nfor i in range(4):\n\tfor j in range(4):\n\t\tif a[i][j] == '.': continue\n\t\tn = int(a[i][j])\n\t\tx[n]+=1\nok = True\nfor i in range(10):\n\tif x[i] > 2*k:\n\t\tok = False\nif (ok):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "k = int(input())\na = [0] * 10\nfor i in range(4):\n    s = input()\n    for j in range(4):\n        if s[j] != '.':\n            a[int(s[j])]+=1\nans = 'YES'\nfor i in range(10):\n    if 2 * k < a[i]:\n        ans = 'NO'\nprint(ans)", "k = int(input())\nA = [input().strip() for i in range(4)]\ncnt = [0 for i in range(10)]\nflag = False\nfor y in range(4):\n    if flag:\n        break\n    for x in range(4):\n        c = A[y][x]\n        if c == '.':\n            continue\n        cnt[int(c)] += 1\n        if cnt[int(c)] > 2 * k:\n            print(\"NO\")\n            flag = True\n            break\n\nif not(flag):\n    print(\"YES\")\n", "k = int(input())\npanel1 = input()\npanel2 = input()\npanel3 = input()\npanel4 = input()\ncan = True\n\nfor i in range(1,10):\n    counter = panel1.count(str(i)) + panel2.count(str(i)) + panel3.count(str(i)) + panel4.count(str(i))\n    if counter > k*2 :\n        can = False\n        break\nif can :\n    print(\"YES\")\nelse:\n    print(\"NO\")\n", "k=int(input())\nz=[]\nx1=input()\nfor i in range (0,len(x1)):\n    if (x1[i] != '.'):\n        z.append(int(x1[i]))\n    else:\n        continue\n\nx2=input()\nfor l in range (0,len(x2)):\n    if (x2[l] != '.'):\n        z.append(int(x2[l]))\n    else:\n        continue\n\n\nx3=input()\nfor y in range (0,len(x3)):\n    if (x3[y] != '.'):\n        z.append(int(x3[y]))\n    else:\n        continue\n\nx4=input()\nfor s in range (0,len(x4)):\n    if (x4[s] != '.'):\n        z.append(int(x4[s]))\n    else:\n        continue\n\n\nkey=len(set(z))\n\ncopy=list(set(z))\ncount=0\nfor j in range (0,len(copy)):\n    if (z.count(copy[j])<= 2*k):\n        count+=1\n    else:\n        count=count\n\n\nif (count==key):\n    print (\"YES\")\nelse:\n    print (\"NO\")\n    \n", "k = int(input())\n\npanels = {'1':0, '2':0, '3':0, '4':0, '5':0, '6':0, '7':0, '8':0, '9':0}\nflag = True\n\nfor i in range(4):\n    line = input()\n    for ch in line:\n        if ch == '.' :\n            continue\n        panels[ch] += 1\n\nv = list(panels.values())\n\nfor i in v:\n    if i > 2 * k:\n        flag = False #print('NO')\n\n#print(panels)\nif flag :\n    print('YES')\nelse:\n    print('NO')\n", "k=int(input())\nc=[0]*9\nfor i in range(4):\n    a=input().strip()\n    for i in a:\n        if i!='.':\n            c[int(i)-1]+=1\nif max(c)<=2*k:\n    print('YES')\nelse:\n    print('NO')", "3\n\ndef readln(): return tuple(map(int, input().split()))\n\nk, = readln()\ncnt = {}\nfor c in list(''.join([input() for _ in range(4)])):\n    if c != '.':\n        cnt[c] = cnt.get(c, 0) + 1\nprint('YES' if len([1 for v in list(cnt.values()) if v <= 2 * k]) == len(cnt) else 'NO')\n", "k = int(input())\n\nt = [\"\" for i in range(4)]\nfor i in range(4):\n\tt[i] = input()\n\ncnt = [0 for i in range(10)]\n\nfor i in range(4):\n\tfor j in range(4):\n\t\tif t[i][j] != '.':\n\t\t\tcnt[int(t[i][j])] += 1\n\nif max(cnt) <= k * 2:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "k = int(input())\np = {i: 0 for i in '123456789.'}\nfor i in range(4):\n    for j in input(): p[j] += 1\np['.'] = 0\nprint('YNEOS'[max(p.values()) > 2 * k :: 2])", "k = int(input())\ncount = {i:0 for i in \"123456789.\"}\n\nfor i in range(4):\n    for string in input():\n        count[string] += 1;\n\ncount[\".\"] = 0\n\nif max(count.values()) > 2*k:\n    print(\"NO\")\nelse:\n    print(\"YES\")\n", "k=int(input())\ng=''\nfor i in range(4):\n    g = g+input()\n#print(g)\nvalid=True\nfor i in range(1,10):\n    if g.count(str(i))>2*k:\n        valid=False\n        break\nif valid:\n    print('YES')\nelse:\n    print('NO')\n", "k=int(input())*2\ns=''.join(input() for _ in range(4))\nif max(s.count(c) for c in '0123456789')>k:\n    print ('NO')\nelse:\n    print('YES')", "__author__ = 'asmn'\n\nk=int(input())\ncnt=dict((i,0) for i in range(1,10))\nfor i in range(4):\n    for j in input():\n        if ord('1')<=ord(j)<=ord('9'):\n            cnt[ord(j)-ord('0')]+=1\nprint('YES' if len(list([x for x in list(cnt.items()) if x[1]>2*k]))==0 else 'NO')\n", "a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\nk = int(input())\nfor i in range(0, 4):\n    b = input()\n    for j in range(0, 4):\n        if b[j] != '.':\n            a[int(b[j])] += 1\nfor i in range(0, 10):\n    if a[i] > k * 2:\n        print (\"NO\")\n        return\nprint(\"YES\")\n", "k = int(input())\ns = ''\nn = list()\nfor i in range(4):\n    a = input()\n    s = s + a\nfor i in range(1,10):\n    n.append(s.count(str(i)))\nif max(n)> 2*k:\n    print ('NO')\nelse:\n    print ('YES')", "\ndef collecting(k):\n\tn = [k*2]*9\n\tfor t in range(4):\n\t\tfor c in input():\n\t\t\tif c != '.':\n\t\t\t\ti = int(c)-1\n\t\t\t\tn[i] -= 1\n\t\t\t\tif n[i] < 0:\n\t\t\t\t\tprint('NO')\n\t\t\t\t\treturn\n\tprint('YES')\n\treturn\n\ndef main():\n\tk = int(input())\n\tcollecting(k)\n\ndef __starting_point():\n\tmain()\n__starting_point()", "k = 2*int(input())\nl1 = input()\nl2 = input()\nl3 = input()\nl4 = input()\ntimes = [0,0,0,0,0,0,0,0,0]\nfor cont in range(0,4):\n    for tmp in range(1,10):\n        if l1[cont] == str(tmp):\n            times[tmp-1] += 1\n        if l2[cont] == str(tmp):\n            times[tmp-1] += 1\n        if l3[cont] == str(tmp):\n            times[tmp-1] += 1\n        if l4[cont] == str(tmp):\n            times[tmp-1] += 1\n\nl = True\nfor tmp in times:\n    if tmp > k:\n        l = False\n\nif l == True:\n    print('YES')\nelse:\n    print('NO')", "a=int(input())\nallp=\"\"\nfor i in range(4):\n    allp+=input()\nokay=\"YES\"\nfor i in range(9):\n    if allp.count(str(i+1))>a*2:\n        okay=\"NO\"\n        break\nprint(okay)", "# -*- coding: utf-8 -*-\n\nk = int(input())\n\ncounter = [0] * 10\ns = ''.join([input().strip() for i in range(4)])\n\nfor c in s:\n    if c == '.':\n        continue\n    counter[int(c)] += 1\n\nm = max(counter)\nprint('NO' if m > 2*k else 'YES')", "k = int(input())\ns = ''.join(input().replace('.', '') for i in range(4))\nprint(\"NO\" if len(s) > 0 and max(s.count(c) for c in set(s)) > 2 * k else \"YES\")", "nums = [0 for i in range(10)]\nk = int(input())\n\nfor i in range(4):\n\ts = input()\n\tfor c in s:\n\t\tif c != '.':\n\t\t\tnums[int(c)] += 1\n\nif all(nums[i] <= 2*k for i in range(10)):\n\tprint('YES')\nelse:\n\tprint('NO')\n", "k = int(input())\n\nl = [0] * 10\n\nfor i in range(4):\n    for j in input():\n        if (j != '.'):\n            l[int(j)] += 1\nfor i in range(10):\n    if l[i] > k*2:\n        print(\"NO\")\n        return\nprint(\"YES\")\n\n", "\n\n\"\"\"k = []\nfor i in range(5):\n    k.append([int(x) for x in (sys.stdin.readline()).split()])\n    \nvmax = 0 \ntt = []\nfor i in range(5):\n    for j in range(i, 5):\n        if(i != j):\n            k[i][j] = k[j][i] = k[i][j] + k[j][i]\n                \n\nfor i in range(5):\n    print(k[i])\"\"\"\n  \n  \nimport sys\nimport math\n  \nn = int(sys.stdin.readline())\n\nk = [0] * 9\n\nfor i in range(4):\n    tt = sys.stdin.readline()\n    for j in range(4):\n        if(tt[j] != '.'):\n            ind = ord(tt[j]) - ord('0') - 1\n            k[ind] += 1\n            if(k[ind] > n * 2):\n                print(\"NO\")\n                return\n                \nprint(\"YES\")\n\n"]


Question:
You have a pot and N ingredients. Each ingredient has a real number parameter called value, and the value of the i-th ingredient (1 \leq i \leq N) is v_i.
When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be (x + y) / 2 where x and y are the values of the ingredients consumed, and you can put this ingredient again in the pot. Also, if the value of the new ingredient is divisible by 2, it will have a disgusting smell, meaning its tastiness is reduced by 5.
After you compose ingredients in this way N-1 times, you will end up with one ingredient. Find the maximum possible value of this ingredient.

-----Constraints-----
 - 2 \leq N \leq 50
 - 1 \leq v_i \leq 1000
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
v_1 v_2 \ldots v_N

-----Output-----
Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.
Your output will be judged correct when its absolute or relative error from the judge's output is at most 10^{-5}.

-----Sample Input-----
2
3 4

-----Sample Output-----
3.5

If you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values 3 and 4 is (3 + 4) / 2 = 3.5.
Printing 3.50001, 3.49999, and so on will also be accepted.

["N = int(input())\nv = sorted(map(int, input().split()))\n\ntmp = v[0]\nfor i in range(1,N):\n  tmp = (tmp+v[i])/2.0\n  \nprint(tmp)", "N = int(input())\nv = [int(x) for x in input().split()]\nv.sort()\nans = (v[0]+v[1])/2.0\nfor i in range(2, N):\n  ans = float(ans+v[i])/2\nprint(ans)", "n=int(input())\nv =list(map(int,input().split()))\nv.sort()\nx = v[0]\nif n > 2:\n        for i in range(1,n):\n            x += v[i]*2**(i-1)\n\n        ans = x/2**(n-1)\n        print(ans)\n\nelse:\n        print((x+v[1])/2)", "N = int(input())\na = list(map(int, input().split()))\na = sorted(a, reverse = False)\nfor i in range(N-1):\n    a[i+1] = (a[i] + a[i+1]) / 2\n\nprint((a[N-1]))\n", "N = int(input())\nV = list(map(int, input().split()))\nV.sort()\n\nfor i in range(N-1):\n    V[i + 1] = (V[i] + V[i + 1])/2\n\nprint((V[N-1]))\n", "N = int(input())\nS = list(map(int,input().split()))\nS = sorted(S)\na = S[0]\nfor i in range(N-1):\n  a = (a + S[i+1])/2\n  \nprint(a)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep  9 21:55:15 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nV = list(map(int,input().split()))\nV.sort(reverse=True)\n#print(V)\nfor i in range(N-1):\n    tmp = 0\n    tmp += (V.pop() + V.pop())/2\n    V.append(tmp)\n\nprint(V[0])", "n = int(input())\n\ns = list(map(int, input().split()))\n\ns.sort()\n\nv = 0\n\nif n == 1:\n  print(s[0])\n  return\nelif n == 2:\n  print((s[0]+s[1])/2)\n  return\n\nc = (s[0]+s[1])/2\n\ndel s[0]\ndel s[0]\n\nfor i in range(n-2):\n  c = (c + s[0])/2\n  del s[0]\n  \n  \nprint(c)", "n=int(input())\nv=sorted(list(map(lambda x:int(x),input().split())))\n\nans=(v[0]+v[1])/2\nfor i in range(2,n):\n  ans=(ans+v[i])/2\n  \nprint(ans)", "M = int(input())\nA = list(map(int,input().split()))\nA.sort()\ncount = 0\ncount = (A[0]+A[1])/2\nfor i in range(2,M):\n  count = (count+A[i])/2\n  \nprint(count)\n", "N = int(input())\nls = list(map(int, input().split(' ')))\nls.sort()\nval = ls[0]\nif N >= 2:\n    for i in ls[1:]:\n        val = (val + i) / 2\nprint(val)", "N = int(input())\nls = list(map(int, input().split(' ')))\nls.sort()\nval = ls[0]\nif N >= 2:\n    for i in ls[1:]:\n        val = (val + i) / 2\nprint(val)", "N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A)\nif N == 2:\n  print(sum(A)/2)\n  return\nelse:\n  temp = (A[0]+A[1])/2\n  for i in range(2, N):\n    temp = 1/2*(A[i] + temp)\nprint(temp)", "n = int(input())\nv = list(map(int,input().split()))\nv = sorted(v)\ncount = v[0]\nfor i in range(1,n):\n    count = (count + v[i])/2\nprint(count)", "N = int(input())\nv = list(map(int, input().split()))\n\nvs = sorted(v)\nalc = 0\nfor i in range(N):\n    if alc == 0:\n        alc = vs[0]\n    else:\n        alc = (alc+vs[i])/2\nprint(alc)", "n = int(input())\nv = [int(s) for s in input().split()]\nv.sort()\navg = v[0]\n\nfor i in range(1, n):\n    avg = avg / 2 + v[i] / 2\nprint(avg)", "N=int(input())\nv=list(map(int,input().split()))\nv.sort()\nx=(v[0]+v[1])/2\nfor i in range(2,N):\n    x=(x+v[i])/2\nprint(x)\n", "N = int(input())\nv = sorted([int(i) for i in input().split()])\nfor i in range(N-1):\n    a = v.pop(0)\n    b = v.pop(0)\n    v.append((a+b)/2)\n    v.sort()\nprint(v[0])", "N = int(input())\nV = sorted(list(map(int, input().split())))\n\nans = V[0]\n\nfor v in V:\n    ans = (ans + v)/2\n\nprint(ans)", "N=int(input())\nv=list(map(int,input().split()))\n\nv.sort()\nans=(v[0]+v[1])/2\n\nfor i in range(2,N):\n    ans=ans+v[i]\n    ans/=2\n\nprint(ans)", "N = int(input())\nv = list(map(int, input().split()))\nv.sort()\nans = v[0]\n\nfor i in range(N-1):\n    ans = (ans+v[i+1]) / 2\n\n# if str(ans)[-2:] == '.0':\n#     print(str(ans).rstrip('.0'))\n# else:\n#     print(ans)\n\nprint(ans)", "n=int(input())\nv=list(map(int,input().split()))\n\nfor i in range(n-1):\n  v.sort()\n  v.append((v[0]+v[1])/2)\n  v.pop(0)\n  v.pop(0)\n  \nprint(v[0])", "n = int(input())\nv = list(map(int, input().split()))\nv_s = sorted(v)\nm = v_s[0]\nfor i in range(n-1):\n  m  = (m + v_s[i+1]) / 2\nprint(m)", "def resolve():\n    n = int(input())\n    v = list(map(int,input().split()))\n    v.sort(reverse=True)\n    for _ in range(n-1):\n        v = v[:-2]+ [(v[-1]+v[-2])/2]\n    print(v[0])\nresolve()", "#ABC138 C\n\nN = int(input())\nV = list(map(int,input().split()))\nV.sort()\nK = V[0]\nfor i in range(1,N):\n    K = (K+V[i])/2\n    \nprint(K)", "n = int(input())\nvn = sorted(list(map(int, input().split())))\nans = vn[0]\nfor i in range(1, n):\n    ans = (ans + vn[i]) / 2\nprint(ans)\n", "N=int(input())\nx = list(map(int, input().split()))\nx.sort()\nans=x[0]\nfor i in range(N-1):\n    ans=(ans+x[i+1])/2\nprint(ans)", "n = int(input())\nv = sorted(list(map(int, input().split())), reverse=True)\n\nans = 0\nt = 1\nfor i in range(n-1):\n    t *= 2\n    ans += v[i] / t\nprint(ans + v[-1]/t)", "N = int(input())\nV = sorted(list(map(int,input().split())))\nans = (V[0]+V[1])/2\n\nfor n in range(2,N):\n  ans = (ans+V[n])/2\n  \nprint(ans)", "n = int(input())\nguzai = list(map(int,input().split()))\n\nguzai.sort()\n\nave =(guzai[0] + guzai[1])/2\n\nfor x in range(2,n):\n  ave = (ave + guzai[x])/2\n  \nprint(ave)\n", "N = int(input())\nls = list(map(int, input().split(' ')))\nls.sort()\nval = ls[0]\nif N >= 2:\n    for i in ls[1:]:\n        val = (val + i) / 2\nprint(val)", "n = int(input())\nv = list(map(int, input().split()))\n\nv.sort()\n\nans = v[0]\nfor i in range(1, n):\n    ans = (ans + v[i])/2\n\nprint(ans)", "n = int(input())\nv = sorted(list(map(int,input().split())))\ns = [0]*n\ns[0] = v[0]\n\nfor i in range(n-1):\n    s[i+1] = (v[i+1]+s[i])/2\nprint((s[-1]))\n", "N = int(input())\nV = list(map(int, input().split()))\nwhile len(V) > 1:\n\tV = sorted(V)\n\ttemp = (V.pop(0) + V.pop(0)) / 2\n\tV.append(temp)\n\t\nprint(V[0])", "n = int(input())\nv = [int(x.strip()) for x in input().split()]\nvs = sorted(v)\nans = 0\nfor i in range(n):\n  a = (vs[i]/(2**(n-max(i,1))))\n  ans += a\nprint(ans)", "n=int(input())\nv=list(map(int,input().split()))\nwhile len(v) != 1:\n  v.sort()\n  v[0] = (v[0]+v[1])/2\n  v.pop(1)\nprint(v[0])", "n = int(input())\na = list(map(int,input().split()))\na.sort()\nnum = a[0]\n\nfor i in a:\n  num = (num+i)/2\nprint(num)", "N = int(input())\nls = list(map(int, input().split(' ')))\nls.sort()\nval = ls[0]\nif N >= 2:\n    for i in ls:\n        val = (val + i) / 2\nprint(val)", "n=int(input())\nv=list(map(int,input().split()))\nv.sort()\nans=v[0]\nfor i in v:\n  ans=(ans+i)/2\nprint(ans)", "N = int(input())\nv = list(map(int, input().split()))\n\nv.sort()\nwhile True:\n  x = v[0]\n  y = v[1]\n  z = (x+y) / 2\n  v.pop(0)\n  v.pop(0)\n  v.append(z)\n  v.sort()\n  if len(v) == 1:\n    break\n  else:\n    pass\n  \n\nprint(z)", "n = int(input())\nline = list(map(int, input().split()))\nline.sort()\nans = (line[0] + line[1])/2\nif n == 2:\n  print(ans)\nelse:\n  for i in range(2,n):\n    ans = (ans + line[i]) / 2\n  print(ans)", "n = int(input())\nvn = sorted(list(map(int, input().split())))\n\n\nclass Solution:\n    def __init__(self, n, vn):\n        self.n = n\n        self.vn = vn\n\n    def answer(self):\n        ans = vn[0]\n        for i in range(1, self.n):\n            ans = (ans + self.vn[i]) / 2\n        print(ans)\n\n\nconditions = Solution(n, vn)\nconditions.answer()\n", "input();a=sorted(map(int,input().split()))\nwhile len(a)>1:\n  a.append((a.pop(0)+a.pop(0))/2);a.sort()\nprint(*a)", "n = int(input())\nu = list(map(int,input().split()))\nu.sort()\nvalue = (u[0] + u[1]) / 2\nfor i in range(2,n):\n    value = (value + u[i]) / 2\nprint(value)", "#ABC138C\nn = int(input())\nv = sorted(list(map(int,input().split())))\nans = (v[0]+v[1])/2\nfor i in range(2,n):\n    ans = (ans+v[i])/2\nprint(ans)\n", "_ = input()\nv = list(map(int,input().split()))\nv.sort()\nnum = v[0]\nfor i in v:\n  num = (num+i)/2\nprint(num)", "N = int(input())\nV = list(map(int, input().split()))\n\nV.sort()\n\nres = V[0]\n\nfor i in range(1, N):\n    res += V[i] * 2**(i - 1)\n\nprint(res / 2**(N - 1))", "n = int(input())\nv = list(map(int,input().split()))\nv.sort()\nv0 = v[0]\nfor i in range(1,n):\n    v0 = (v0 + v[i]) / 2\nprint(v0)", "import heapq\nn = int(input())\nh = list(map(int, input().split()))\nheapq.heapify(h)\n\nwhile len(h) >= 2:\n  x = heapq.heappop(h)\n  y = heapq.heappop(h)\n  z = (x+y)/2.0\n  heapq.heappush(h, z)\n\nprint(h[0])", "N = int(input())\nv = [int(i) for i in input().split()]\nw = sorted(v)\n\nans = w[0] + w[1]\nif N == 2:\n    ans /= 2\nelse:\n    for i in range(2, N):\n        ans += 2**(i-1) * w[i]\n    ans /= 2**(N-1)\n\nprint(ans)", "import itertools\nN = int(input())\nv = list(map(int, input().split()))\n\nfor _ in range(N - 1):\n    c = list(itertools.combinations(v, 2))\n\n    x = 10000\n    idx = None\n    for i, j in enumerate(c):\n        a = (j[0] + j[1]) / 2\n        if x > a:\n            x = a\n            idx = i\n\n    n = v.index(c[idx][0])\n    v.pop(n)\n    m = v.index(c[idx][1])\n    v.pop(m)\n    v.append(x)\n    \nprint(v[0])", "def solve():\n    N = int(input())\n    A = list(map(int, input().split()))\n    A.sort()\n    for i in range(N - 1):\n        A[i + 1] = (A[i + 1] + A[i]) / 2\n    print((A[-1]))\n    return\n\nsolve()\n", "n = int(input())\nv = list(map(int, input().split()))\nv.sort()\nc = v[0]\nfor i in range(1,n):\n  c = (v[i]+c)/2\nprint(c)", "n = int(input())\nv = list(map(int, input().split()))\n\nv = sorted(v)\n\nans = v[0]\n\nfor i in range(1, n):\n    ans = (ans+v[i])/2\n\nprint('{:.6f}'.format(ans))", "#import math\n#import itertools\n#import numpy as np\nimport heapq\n#from collections import deque\n# sys.setrecursionlimit(10 ** 6)\n#mod = 10 ** 9 + 7\n#INF = 10 ** 9\n#PI = 3.14159265358979323846\n\nINT = lambda: int(input())\nINTM = lambda: map(int,input().split())\nSTRM = lambda: map(str,input().split())\nSTR = lambda: str(input())\nLIST = lambda: list(map(int,input().split()))\nLISTS = lambda: list(map(str,input().split()))\n\ndef do():\n    n=INT()\n    v=LIST()\n    heapq.heapify(v)\n    for i in range(n-1):\n        a=heapq.heappop(v)\n        b=heapq.heappop(v)\n        heapq.heappush(v,(a+b)/2)\n    print(heapq.heappop(v))\ndef __starting_point():\n    do()\n__starting_point()", "# N\u3092\u53d6\u5f97\nN = int(input())\n\n# v\u3092\u53d6\u5f97\nv = list(map(int, input().split()))\n\n# v\u3092\u6607\u9806\u30bd\u30fc\u30c8\nv = sorted(v)\n\n# result = v[0] v\u306e\u5c0f\u3055\u3044\u5024\u304b\u30891\u3064\u9078\u3076\nresult = v[0]\n\n# v\u306e2\u756a\u76ee\u306e\u5024\u3068\u5e73\u5747\u3092\u3068\u308b\u3002\u3053\u308c\u30924\u756a\u76ee\u301cN\u756a\u76ee result = (results + v[i]) / 2\nfor i in range(1, len(v)):\n    result = (result + v[i]) / 2\n\n# \u7d50\u679c\u51fa\u529b\nprint(result)", "N = int(input())\nv = [int(c) for c in input().split()]\n\nv.sort()\ntmp = 0.0\nfor i in range(N):\n    if i == 0:\n        tmp = v[i]\n    else:\n        tmp = (tmp+v[i])/2.0\n\nprint(tmp)", "N = int(input())\nmaterials = list(map(int, input().split()))\n\nfor _ in range(N-1):\n\tmaterials.sort()\n\tnew_material = (materials[0] + materials[1])/2\n\tmaterials.pop(0)\n\tmaterials.pop(0)\n\tmaterials.append(new_material)\n\t\nprint(materials[0])", "#!/usr/bin/env python3\n\ndef main():\n    n = int(input())\n    v = sorted(map(int, input().split()))\n    ans = v[0]\n    for i in range(1,n):\n        ans = (ans+v[i])/2\n    print(ans)\n\ndef __starting_point():\n    main()\n\n__starting_point()", "# coding: utf-8\n\ndef main():\n    N = int(input())\n    v = list(map(int, input().split()))\n    v.sort()\n    ans = v[0] / 2 ** (N - 1)\n    for i in range(1, N):\n        ans += v[i] / 2 ** (N - i)\n\n    print(ans)\n\ndef __starting_point():\n    main()\n\n__starting_point()", "N = int(input())\nv_list = list(map(int, input().split()))\n\nv_list_min = sorted(v_list)\nans = v_list_min[0]\nfor i in range(1, N):\n    ans = (ans + v_list_min[i])/2\n\nprint(ans)", "n = int(input())\nv = sorted([int(i) for i in input().split()], reverse=True)\nfor i in range(n - 1):\n  v[i] /= (2 ** (i + 1))\nv[n-1] /= (2 ** (n - 1))\nprint(sum(v))", "import sys\nimport math\nfrom collections import defaultdict, deque, Counter\nfrom copy import deepcopy\nfrom bisect import bisect, bisect_right, bisect_left\nfrom heapq import heapify, heappop, heappush\n    \ninput = sys.stdin.readline\ndef RD(): return input().rstrip()\ndef F(): return float(input().rstrip())\ndef I(): return int(input().rstrip())\ndef MI(): return map(int, input().split())\ndef MF(): return map(float,input().split())\ndef LI(): return list(map(int, input().split()))\ndef TI(): return tuple(map(int, input().split()))\ndef LF(): return list(map(float,input().split()))\ndef Init(H, W, num): return [[num for i in range(W)] for j in range(H)]\n    \n    \ndef main():\n    N = I()\n    L = LI()\n    L.sort()\n\n    ans = L[0]\n    for i in L[1:]:\n        ans = (ans+i)/2\n    print(ans)\n    \ndef __starting_point():\n    main()\n__starting_point()", "N = int(input())\nv = [int(c) for c in input().split()]\n\nv.sort()\ntmp = 0.0\nfor i in range(N):\n    if i == 0:\n        tmp = v[i]\n    else:\n        tmp = (tmp+v[i])/2.0\n\nprint(tmp)", "n = int(input())\nv = list(map(int,input().split()))\nv = sorted(v)\na = (v[0] + v[1]) / 2\nfor i in range(2,n):\n    a = (a + v[i]) / 2\nprint(a)", "n = int(input())\nv =list(map(int, input().split()))\nl = [0]*n\ns = 0\nl = sorted(v)\ns = l[0]\nfor i in range(1,n):\n  s = (s+l[i])/2\nprint(s)", "a = int(input())\nb = list(map(int,input().split()))\nb.sort()\nc = b[0]\nfor i in range(1,a):\n  c += b[i]\n  c /= 2\nprint(c)", "N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A, reverse=True)\nans = 0\na = 1\nfor i in range(N):\n    if i != N-1:\n        a *= 0.5\n    ans += a*A[i]\n\nprint(ans)", "n = int(input())\nv = [int(n) for n in input().split()]\n\nv = sorted(v)\n\nans = v[0]\nfor num in v[1:]:\n    ans = (ans + num)/2\n\nprint(ans)", "N = int(input())\nv = list(map(int, input().split()))\n\n# \u6607\u9806\u306b\u30bd\u30fc\u30c8\u3059\u308b\u3068\u3001\u6700\u5927\u5024\u3092\u4e0e\u3048\u308b\u306e\u306f\u4ee5\u4e0b\u306e\u64cd\u4f5c\u3092\u884c\u3063\u305f\u3068\u304d\uff1a\n# v_1 = (v_0 + v_1)/2 (v_0\u306f\u6d88\u6ec5\uff09\n# v_2 = (v_1 + V_2)/2 (v_1\u306f\u6d88\u6ec5)\n# v_(N-1) = (v_(N_1) + v_(N-2))/2 (v_(N-2)\u306f\u6d88\u6ec5)\n# \u7d50\u5c40\u3001(N-1)\u756a\u76ee\u306e\u7d20\u6750\u304c\u6b8b\u308a\u3001\u305d\u306e\u4fa1\u5024\u306fv_(N-1)\n\nv = sorted(v)\nfor i in range(N-1):\n  v[i+1] = (v[i+1]+v[i])/2\n  \nprint(v[N-1])", "#\u5165\u529b:[n1,n2,...nk](int:\u6574\u6570\u914d\u5217)\ndef input_array():\n\treturn list(map(int,input().split()))\n  \nn=int(input())\nv=input_array()\nv=sorted(v)\nans=v[0]\nfor i in range(1,n):\n\tans=(ans+v[i])/2\nprint(ans)", "def cumsum(n,A):\n    s = [0]*(n+1)\n    s[0] = A[0]\n    for i in range(len(A)):\n        s[i+1] = (s[i] + A[i])/2\n    return s\n\nn = int(input())\nv = sorted(list(map(int,input().split())))\n\nfor i in range(n-1):\n    s = cumsum(n,v)\nprint(s[-1])", "N = int(input())\nv = list(map(float, input().split()))\n\nv.sort()\n\nfor i in range(N-1):\n    v[i+1] = (v[i] + v[i+1]) / 2\n\nprint((v[-1]))\n", "N=int(input())\nvlist=list(map(int,input().split()))\nvlist.sort()\nans=0\nfor i in range(N):\n    if i==0:\n        ans+=vlist[i]\n    else:\n        ans=(ans+vlist[i])/2\nprint(ans)", "n = int(input())\nu = list(map(int,input().split()))\n\nu = sorted(u)\nans = 0\n\nfor i in range(n-1):\n  if ans == 0:\n    ans = (u[i] + u[i+1])/2\n  else:\n    ans = (ans + u[i+1])/2\n    \nprint(ans)", "n = int(input())\nv = list(map(int,input().split()))\nv.sort()\nt = float(v[0]+v[1])/2\n\nfor i in range(2,n,1):\n    t = float(t+v[i])/2\n\n\nprint(('{:.05f}'.format(t)))\n", "n=int(input())\nv=list(map(int,input().split()))\n\nv.sort()\n\nfor i in range(1,n):\n    v[i]=(v[i]+v[i-1])/2\n\nprint(v[-1])", "n=int(input())\nL=sorted(list(map(int,input().split())))\nans=(L[0]+L[1])/2\nfor i in range(2,n):\n    ans=(ans+L[i])/2\nprint(ans)", "N = int(input())\nv = list(map(int, input().split()))\n\nv = sorted(v)\nfor i in range(N-1):\n  v[i+1] = (v[i+1]+v[i])/2\n  \nprint(v[N-1])", "M = int(input())\nA = list(map(int,input().split()))\nA.sort()\ncount = 0\ncount = (A[0]+A[1])/2\nfor i in range(2,M):\n  count = (count+A[i])/2\n  \nprint(count)", "n = int(input())\nlst = list(map(int,input().split()))\nlst.sort()\nfor i in range(n - 1):\n  x = (lst[0] + lst[1])/2\n  lst.pop(0)\n  lst.pop(0)\n  lst.append(x)\n  lst.sort()\nprint((lst[0]))\n", "N = int(input())\nV = list(map(int,input().split()))\nV.sort()\na = V[0]\nfor i in range(1 , N):\n  a  = (a + V[i]) / 2\nprint(a)\n  \n  \n", "n=int(input())\nv=list(map(int,input().split()))\nv.sort()\nz=(v[0]+v[1])/2\nfor i in range(2,n):\n  z=(z+v[i])/2\n\nprint(z)", "N = int(input())\nls = list(map(int, input().split(' ')))\nls.sort()\nrst = ls[0]\nif N >= 2:\n    for i in ls[1:]:\n        rst = (rst + i) / 2\nprint(rst)", "a=int(input())\nb=list(map(int,input().split()))\nb.sort()\nc=b[0]\nfor i in range (a-1):\n  c=(c+b[i+1])/2\nprint(c)", "N = int(input())\nV = list(map(int, input().split()))\nif N == 2:\n    print((V[0]+ V[1])/2)\nelse:\n    V.sort()\n    kati = V[0]\n    for i in range(1, N):\n        kati = (kati + V[i]) / 2\n    print(kati)", "# C\nN = int(input())\nV = sorted(list(map(int, input().split())))\n\nans = (V[0]+V[1])/2\nfor i in range(2, len(V)):\n    ans = (ans+V[i])/2\nprint(ans)\n", "N = int(input())\nls = list(map(int, input().split(' ')))\nls.sort()\nval = ls[0]\nif N >= 2:\n    for i in ls[1:]:\n        val = (val + i) / 2\nprint(val)", "n = int(input())\nv = list(map(int, input().split()))\nfor i in range(n-1):\n    a = min(v)\n    v.remove(a)\n    b = min(v)\n    v.remove(b)\n    new = (a+b)/2\n    v.append(new)\nprint(new)", "n = int(input())\narr = list(map(int, input().split()))\n\nfor _ in range(n - 1):\n    arr.sort()\n    new_v = (arr[0] + arr[1]) / 2\n    del arr[0:2]\n    arr.append(new_v)\n\nprint((arr[0]))\n", "n=int(input())\nA=sorted(list(map(int,input().split())))\nans = A[0]\nfor i in range(n-1):\n  ans = (ans + A[i+1])/2\nprint(ans)", "n=int(input())\nv=sorted(list(map(int, input().split())))\nres=v[0]\nfor i in range(n-1):\n    res=(res+v[i+1])/2\nprint(res)\n", "N = int(input())\nA = list(map(int, input().split()))\nA.sort()\nans = A[0]\nfor i in range(1, N):\n  ans = (ans + A[i])/2\nprint(ans)", "n = int(input())\nv = list(map(float, input().split()))\n\nv.sort()\ndp = [0]*(n-1)\n\nfor i in range(n-1):\n    dp[i] += (v[i]+v[i+1])/2\n    v[i+1] =  dp[i]\nprint((dp[-1]))\n", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\nimport heapq\n\ndef main():\n    n = int(input())\n    values=[]\n    heap_values=[]\n    values=list(map(int,input().split()))\n    [heapq.heappush(heap_values, value) for value in values]\n\n    while len(heap_values)!=1:\n        tmp1=heapq.heappop(heap_values)\n        tmp2=heapq.heappop(heap_values)\n        tmp_value=(tmp1+tmp2)/2\n        heapq.heappush(heap_values,tmp_value)\n\n    print(heap_values[0])\n\ndef __starting_point():\n    main()\n__starting_point()", "# -*- coding:utf-8 -*-\nN = int(input())\nVal = list(map(int,input().split()))\nVal.sort()\nfor i in range(N-1):\n    x = Val.pop(0)\n    y = Val.pop(0)\n    Val.append((x+y)/2)\n    Val.sort()\n\nprint(Val[0])", "N = int(input())\nv = list(map(int, input().split()))\nv.sort()\nans = v[0]\n\nfor i in range(N-1):\n    ans = (ans+v[i+1]) / 2\n\nprint(ans)", "n = int(input())\na = sorted(map(int,input().split()))\nc=a[0]\nfor i in range(1,n):\n    c=(c+a[i])/2\nprint(c)", "import heapq\n\ndef main():\n    n = int(input())\n    values = [int(i) for i in input().split()]\n    heapq.heapify(values)\n    for i in range(n-1):\n        a = heapq.heappop(values)\n        b = heapq.heappop(values)\n        heapq.heappush(values, (a+b)/2)\n    ans = heapq.heappop(values)\n    print(ans)\n\ndef __starting_point():\n    main()\n__starting_point()", "N=int(input())\nv=sorted(map(int,input().split()))\nvalue=v[0]\nfor i in range(1,N):\n    value=(value+v[i])/2\nprint(value)"]


Question:
A telephone number is a sequence of exactly 11 digits, where the first digit is 8. For example, the sequence 80011223388 is a telephone number, but the sequences 70011223388 and 80000011223388 are not. Also, sequences that contain at least one 0 are ugly.

You are given a string $s$ of length $n$, consisting of digits.

In one operation you can delete any character from string $s$. For example, it is possible to obtain strings 112, 111 or 121 from string 1121.

You need to determine whether there is such a sequence of operations (possibly empty), after which the string $s$ becomes a telephone number.

-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of test cases.

The first line of each test case contains one integer $n$ ($1 \le n \le 100$) — the length of string $s$.

The second line of each test case contains the string $s$ ($|s| = n$) consisting of digits.

-----Output-----

For each test print one line.

If there is a sequence of operations, after which $s$ becomes a telephone number, print YES.

Otherwise, print NO.

-----Example-----
Input
2
13
7818005553535
11
31415926535

Output
YES
NO

-----Note-----

In the first test case you need to delete the first and the third digits. Then the string 7818005553535 becomes 88005553535.

["for _ in range(int(input())):\n\tn = int(input())\n\ts = input()\n\tfor i in range(len(s)-10):\n\t\tif(s[i] == '8'):\n\t\t\tprint(\"YES\")\n\t\t\tbreak\n\telse:\n\t\tprint(\"NO\")\t\t", "N = int(input())\n\nfor i in range(N):\n    l = int(input())\n    \n    S = input()\n    \n    if '8' in S and len(S) - S.index('8') >= 11:\n        print(\"YES\")\n    else:\n        print(\"NO\")", "n = int(input())\nfor i in range(n):\n\tt = int(input())\n\ts = input()\n\tf = False\n\tfor j in range(t):\n\t\tif s[j] == '8':\n\t\t\tif t - j >= 11:\n\t\t\t\tf = True\n\tif f:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n", "t = int(input())\nfor _ in range(t):\n    n = int(input())\n    s = input().strip()\n    f = 0\n    while f < n and s[f] != '8':\n        f += 1\n    if f == n or n - f < 11:\n        print(\"NO\")\n    else:\n        print(\"YES\")\n", "for i in range(int(input())):\n    n=int(input())\n    s=input()\n    if '8' in s:\n        if n-s.index('8')>=11:\n            print (\"YES\")\n        else :\n            print(\"NO\")\n    else :\n        print(\"NO\")", "for i in range(int(input())):\n    n = int(input())\n    s = input().strip()\n    k = s.find('8')\n    if k == -1:\n        print('NO')\n        continue\n    s = s[k:]\n    if len(s) >= 11:\n        print('YES')\n    else:\n        print('NO')\n", "for i in range(int(input())):\n    n=int(input())\n    s=input()\n    if s.find('8')!=-1:\n        k=s.find('8')\n        if len(s)-k-1>=10:\n            print('YES')\n        else:\n            print('NO')\n    else:\n        print('NO')", "for _ in range(int(input())):\n\tinput()\n\tnum = input()\n\tif \"8\" in num and len(num) - num.find(\"8\") >= 11:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")", "t = int(input())\n\nfor _ in range(t):\n    n = int(input())\n    s = input()\n\n    if '8' in s and n - s.find('8') >= 11:\n        print('YES')\n    else:\n        print('NO')\n", "t=int(input())\nfor l in range(t):\n    n=int(input())\n    s=str(input())\n    flag=0\n    for i in range(n):\n        if(s[i]=='8'):\n            if(n-i>=11):\n                flag=1\n                break\n    if(flag==1):\n        print(\"YES\")\n    else:\n        print(\"NO\")", "for TT in range(1, int(input()) + 1):\n    n = int(input())\n    s = input()\n    res = True\n    if '8' not in s:\n        res = False\n    else:\n        i = s.index('8')\n        if n - i < 11:\n            res = False\n    print(\"YES\" if res else \"NO\")", "q = int(input())\nfor _ in range(q):\n    n = int(input())\n    u = list(map(int, list(input())))\n    k = -1\n    for i in range(n):\n        if u[i] == 8:\n            k = i\n            break\n    if k == -1:\n        print('NO')\n        continue\n    if n - k >= 11:\n        print('YES')\n    else:\n        print('NO')\n", "def solve():\n    n = int(input())\n    s = input()\n    for i in range(n):\n        if s[i] == '8':\n            break\n    if i <= n - 11:\n        print(\"YES\")\n    else:\n        print(\"NO\")\n\ndef main():\n    for _ in range(int(input())):\n        solve()\n    return 0\n\nmain()", "'''n=int(input())\ns=input().rstrip()\np=input().rstrip().split(' ')\nfor i in range(0,n):\n    o=int(input())\n    u=input().rstrip().split(' ')'''\n\nn=int(input())\nfor i in range(0,n):\n    o=int(input())\n    s=input().rstrip()\n    x=list(s)\n    if '8' not in x or len(x)<11:\n        print(\"NO\")\n    else:\n        f=x.index('8')\n        g=x[f:len(x)]\n        if len(g)>=11:\n            print(\"YES\")\n        else:\n            print(\"NO\")\n", "ts = int(input())\n\nfor ti in range(ts):\n    n = int(input())\n    s = input()\n    pos = -1\n    for i in range(n):\n        if s[i] == \"8\":\n            pos = i\n            break\n    if pos != -1 and n - pos >= 11:\n        print(\"YES\")\n    else:\n        print(\"NO\")\n", "t = int(input())\n\nfor i in range(t):\n    n = int(input())\n    s = input()\n    if len(s) >= 11 and '8' in s[:-10]:\n        print('YES')\n    else:\n        print('NO')\n", "t = int(input())\nfor _ in range(t):\n\tn = int(input())\n\ts = input()\n\ttry:\n\t\ts = s[s.index('8')::]\n\t\tif len(s)<11:\n\t\t\traise ValueError\n\t\tprint(\"YES\")\n\texcept ValueError:\n\t\tprint(\"NO\")", "t = int(input())\nfor i in range(t):\n  n = int(input())\n  s = input()\n  ok = False\n  for i in range(n):\n    if s[i] == '8' and i + 11 <= n:\n      ok = True\n      break\n  if ok:\n    print('YES')\n  else:\n    print('NO')", "t = int(input())\nfor i in range(t):\n    n = int(input())\n    s = input()\n    k = s.find('8')\n    if k != -1 and len(s) - k >= 11:\n        print(\"YES\")\n    else:\n        print(\"NO\")\n", "for _ in range(int(input())):\n\tn = int(input())\n\ts = input()\n\n\tif '8' in s and n - s.find('8') >= 11:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")", "t = int( input() )\nfor tc in range(t):\n    n = int( input() )\n    s = input()\n    n = -1\n    for c in s:\n        if n >= 0:\n            n += 1\n        elif n == -1 and c == '8':\n            n = 0\n    print( \"YES\" if n >= 10 else \"NO\" )\n", "for case in range(int(input())):\n    n = int(input())\n    s = input()\n    ans = 'NO'\n    for i in range(n-10):\n        if s[i] == '8': \n            ans = 'YES'\n            break\n    print(ans)\n", "t = int(input())\nfor _ in range(t):\n    input()\n    s = input()\n    try:\n        pos8 = s.index('8')\n    except ValueError:\n        print('NO')\n    else:\n        print('YES' if len(s) - pos8 >= 11 else 'NO')\n", "t = int(input())\nfor i in range(t):\n  n = int(input())\n  s = input()\n  st = False\n  for i in range(n-1, -1, -1):\n    if s[i]=='8' and n-i>=11:\n      st = True\n      break\n  \n  if st:\n    print('YES')\n  else:\n    print('NO')"]


Question:
A class of students wrote a multiple-choice test.

There are $n$ students in the class. The test had $m$ questions, each of them had $5$ possible answers (A, B, C, D or E). There is exactly one correct answer for each question. The correct answer for question $i$ worth $a_i$ points. Incorrect answers are graded with zero points.

Also, if at least one student answered E for a given question, that means the question was extremely difficult.

The students remember what answers they gave on the exam, but they don't know what are the correct answers. They are very optimistic, so they want to know what is the maximum possible total score of all students in the class.

-----Input-----

The first line contains integers $n$ and $m$ ($1 \le n, m \le 1000$) — the number of students in the class and the number of questions in the test.

Each of the next $n$ lines contains string $s_i$ ($|s_i| = m$), describing an answer of the $i$-th student. The $j$-th character represents the student answer (A, B, C, D or E) on the $j$-th question.

The last line contains $m$ integers $a_1, a_2, \ldots, a_m$ ($1 \le a_i \le 1000$) — the number of points for the correct answer for every question.

-----Output-----

Print a single integer — the maximum possible total score of the class.

-----Examples-----
Input
2 4
ABCD
ABCE
1 2 3 4

Output
16
Input
3 3
ABC
BCD
CDE
5 4 12

Output
21

-----Note-----

In the first example, one of the most optimal test answers is "ABCD", this way the total number of points will be $16$.

In the second example, one of the most optimal test answers is "CCC", this way each question will be answered by exactly one student and the total number of points is $5 + 4 + 12 = 21$.

["from collections import Counter\nn, m = map(int, input().split())\nl = [input() for _ in range(n)]\nv = [*map(int, input().split())]\nres = 0\nfor i in range(m):\n    res += v[i] * max(Counter(s[i] for s in l).values())\nprint(res)", "from sys import stdin, stdout, exit\n\nn,m = list(map(int, stdin.readline().split()))\ncts = [[0]*5 for i in range(m)]\nfor i in range(n):\n    s = stdin.readline().strip()\n    for j,c in enumerate(s):\n        cts[j][ord(c)-ord('A')] += 1\n\na = list(map(int, stdin.readline().split()))\nans = 0\nfor j in range(m):\n    ans += max(cts[j])*a[j]\n\nstdout.write(str(ans) + \"\\n\")\n", "from collections import Counter\nn,m = list(map(int,input().split()))\ns = [input() for _ in range(n)]\ns = [*list(zip(*s))]\na = [*list(map(int,input().split()))]\nprint(sum(x.most_common(1)[0][1] * y for x, y in zip(list(map(Counter, s)), a)))\n", "n, m = map(int, input().split())\n\ncount = []\nfor i in range(m):\n\tcount.append([0]*5)\n\nfor i in range(n):\n\ts = input()\n\tfor j, c in enumerate(s):\n\t\tcount[j][\"ABCDE\".index(c)] += 1\n\npoints = list(map(int, input().split()))\n\ntotal = sum(point * max(c) for point, c in zip(points, count))\n\nprint(total)", "from collections import defaultdict as dd, deque, Counter\n\nn,m = list(map(int,input().split()))\n\nA = [input() for _ in range(n)]\nP = [int(x) for x in input().split()]\n\nr = 0\nfor a in zip(list(zip(*A)), P):\n    c = Counter(a[0])\n    r += c.most_common()[0][1]*a[1]\nprint(r)\n", "n,m=map(int,input().split())\na=[]\nans1=0\nfor i in range(n):\n    a.append(input())\nans=list(map(int,input().split()))\nfor i in range(m):\n    d={}\n    ma=-1\n    for j in range(n):\n        d[a[j][i]]=d.get(a[j][i],0) + 1\n        ma=max(ma,d[a[j][i]])\n    ans1+=ma*ans[i]\nprint(ans1)    ", "n, m = map(int, input().split())\na = [list(input()) for i in range(n)]\ncount = [[0 for i in range(5)] for i in range(m)]\nb = list(map(int, input().split()))\nfor i in range(n):\n    for j in range(m):\n        count[j][ord(a[i][j]) - ord(\"A\")] += 1\nans = 0\nfor i in range(m):\n    ans += max(count[i]) * b[i]\nprint(ans)", "n, m = list(map(int, input().split()))\nu = []\nfor i in range(n):\n    u.append(list(input()))\na = list(map(int, input().split()))\nans = 0\nfor j in range(m):\n    d = {'A': 0, 'B': 0, 'C': 0, 'D': 0, 'E': 0}\n    for i in range(n):\n        d[u[i][j]] += 1\n    ans += a[j] * max(d['A'], d['B'], d['C'], d['D'], d['E'])\nprint(ans)\n", "def mp():\n    return map(int, input().split())\n\nn, m = mp()\ns = [input() for i in range(n)]\na = list(mp())\n\nans = 0\nfor j in range(m):\n    cnt = [0] * 5\n    for i in range(n):\n        cnt[ord(s[i][j]) - 65] += 1\n    ans += a[j] * max(cnt)\n    #print(j + 1, cnt, ans)\n\nprint(ans)", "import math\nfrom decimal import Decimal\nimport heapq\ndef na():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\treturn n,b\n \n \ndef nab():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tc = [int(x) for x in input().split()]\n\treturn n,b,c\n \n \ndef dv():\n\tn, m = list(map(int, input().split()))\n\treturn n,m\n \n \ndef dva():\n\tn, m = list(map(int, input().split()))\n\ta = [int(x) for x in input().split()]\n\tb = [int(x) for x in input().split()]\n\treturn n,m,b\n \n \ndef eratosthenes(n): \n\tsieve = list(range(n + 1))\n\tfor i in sieve:\n\t\tif i > 1:\n\t\t\tfor j in range(i + i, len(sieve), i):\n\t\t\t\tsieve[j] = 0\n\treturn sorted(set(sieve))\n \n \n \ndef nm():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\tm = int(input())\n\tc = [int(x) for x in input().split()]\n\treturn n,b,m,c\n \n \ndef dvs():\n\tn = int(input())\n\tm = int(input())\n\treturn n, m \n\n\nn, m = list(map(int, input().split()))\na = []\nfor i in range(n):\n\ts = input()\n\ta.append(s)\nb = list(map(int, input().split()))\nans = 0\nfor j in range(m):\n\td = {}\n\tfor i in range(n):\n\t\tc = a[i][j]\n\t\td[c] = d.get(c, 0) + 1\n\ttc = max(d.values()) * b[j]\n\tans += tc\nprint(ans)\n", "def increase(cnt, letter):\n    if letter not in cnt:\n        cnt[letter] = 1\n    else:\n        cnt[letter] += 1\n\nn, m = list(map(int, input().split()))\n\nstrings = []\n\nfor i in range(n):\n    strings.append(input())\n\npoints = list(map(int, input().split()))\n\nans = 0\n\nfor qu in range(m):\n    cnt = {}\n    mx = 0\n    for person in range(n):\n        increase(cnt, strings[person][qu])\n        mx = max(mx, cnt[strings[person][qu]])\n    ans += points[qu] * mx\n\nprint(ans)\n    \n", "import sys \nimport itertools\ninput = lambda: sys.stdin.readline().rstrip()\n\nn, m = list(map(int, input().split()))\narr = [input() for i in range(n)]\nscore = list(map(int, input().split()))\n\nans = 0\nfor i in range(m):\n  a = [s[i] for s in arr]\n  b = max([a.count(k) for k in \"ABCDE\"])\n  ans += score[i] * b \n\nprint(ans)\n", "#577_A\n\nimport sys\n\nln = [int(i) for i in input().split(\" \")]\n\nn = ln[0]\nm = ln[1]\n\nans = []\n\nfor i in range(0, n):\n    ans.append(list(sys.stdin.readline().rstrip()))\n\narr = [\"A\", \"B\", \"C\", \"D\", \"E\"]\n\npts = [int(i) for i in input().split(\" \")]\n\ns = 0\n\nfor i in range(0, m):\n    cts = [0, 0, 0, 0, 0]\n    for j in range(0, n):\n        cts[arr.index(ans[j][i])] += 1\n    s += max(cts) * pts[i]\n\nprint(s)\n", "n, m = map(int, input().split())\nd = [{'A': 0, 'B':0, 'C':0, 'D':0, 'E':0} for i in range(m)]\nfor i in range(n):\n    s = input()\n    for j in range(len(s)):\n        d[j][s[j]] += 1\narray = list(map(int, input().split()))\ns = 0\nfor i in range(m):\n    ma = 0\n    for el in d[i]:\n        if d[i][el] > ma:\n            ma = d[i][el]\n    s += ma*array[i]\nprint(s)", "def main():\n    import sys\n    # input = sys.stdin.readline\n    \n    n, m = map(int, input().split())\n    \n    strs = [input() for _ in range(n)]\n    scores = list(map(int, input().split()))\n    \n    ans = 0\n    for i in range(m):\n        cnt = [0] * 5\n        for j in range(n):\n            cnt[ord(strs[j][i]) - ord('A')] += 1\n        ans += scores[i] * max(cnt)\n    \n    print(ans)\n    \n    return 0\n\nmain()", "n, m = list(map(int,input().split()))\n\na = [[0 for j in range(5)] for i in range(m)]\n\nfor i in range(n):\n    s = input()\n    for j in range(m):\n        a[j][ord(s[j]) - ord('A')] += 1\nsum1  = 0\nb=  list(map(int,input().split()))\nfor i in range(m):\n    sum1 += b[i] * max(a[i])\nprint(sum1)\n", "from collections import defaultdict\nX = list(map(int, input().split()))\nAnswers = []\nfor i in range(X[0]):\n    Answers.append(input())\npoints = list(map(int, input().split()))\nSum = 0\nfor i in range(X[1]):\n    Temp = defaultdict(int)\n    for j in range(X[0]):\n        Temp[Answers[j][i]]+=1\n    Sum+=points[i]*max(Temp.values())\nprint(Sum)\n\n# UB_CodeForces\n# Advice: Gain your experience with participating in CodeForces contests\n# Location: Behind my desk\n# Caption: Contest time\n# CodeNumber: 556\n", "import sys\ninput = sys.stdin.readline\n\nn,m=list(map(int,input().split()))\n\nfrom collections import Counter\n\nLIST=[[] for i in range(m)]\n\nfor i in range(n):\n    s=input()\n    for j in range(m):\n        LIST[j].append(s[j])\n\nSCORE=list(map(int,input().split()))\nANS=0\n\nfor i in range(m):\n    ANS+=max(Counter(LIST[i]).values())*SCORE[i]\n\nprint(ANS)\n    \n", "from collections import Counter\n\nn, m = list(map(int, input().split()))\nl = [Counter() for i in range(m)]\nfor i in range(n):\n    a = input()\n    for c, d in zip(a, l):\n        d[c] += 1 \n\nans = 0\nfor p, d in zip(list(map(int, input().split())), l):\n    ans += p * max(d.values())\n\nprint(ans)\n", "n,m=list(map(int,input().split()))\narr = []\nfor i in range(n):\n    arr.append(input())\nans = 0\nent = list(map(int,input().split()))\ncount = [0]*5\nfor i in range(m):\n    for j in range(n):\n        count[ord(arr[j][i])-65] += ent[i]\n    ans += max(count)\n    count = [0,0,0,0,0]\nprint(ans)\n\n\n", "import sys\n\nn, m = list(map(int, sys.stdin.readline().strip().split()))\ns = []\nfor i in range (0, n):\n    s.append(sys.stdin.readline().strip())\na = list(map(int, sys.stdin.readline().strip().split()))\nans = 0\nfor j in range (0, m):\n    A, B, C, D, E = 0, 0, 0, 0, 0\n    for i in range (0, n):\n        if s[i][j] == 'A':\n            A = A + 1\n        if s[i][j] == 'B':\n            B = B + 1\n        if s[i][j] == 'C':\n            C = C + 1\n        if s[i][j] == 'D':\n            D = D + 1\n        if s[i][j] == 'E':\n            E = E + 1\n    ans = ans + max([A, B, C, D, E]) * a[j]\n\nprint(ans)\n", "a = input()\na = a.split()\nstudents = int(a[0])\nquestions = int(a[1])\nans = []\nfor i in range(students):\n    x = input()\n    ans.append(x)\nweights = input()\nweights = weights.split()\nfor i in range(len(weights)):\n    weights[i] = int(weights[i])\nn = []\nfor i in range(questions):\n    a = 0\n    b = 0\n    c = 0\n    d = 0\n    e = 0\n    for j in range(students):\n        if ans[j][i] == \"A\":\n            a += 1\n        if ans[j][i] == \"B\":\n            b += 1\n        if ans[j][i] == \"C\":\n            c += 1\n        if ans[j][i] == \"D\":\n            d += 1\n        if ans[j][i] == \"E\":\n            e += 1\n    n.append(max(a, b, c, d, e))\ntotal = 0\nfor i in range(len(n)):\n    total += n[i]*weights[i]\nprint (total)", "import sys\ninput = sys.stdin.readline\n\nn, m = map(int, input().split())\nl = []\nfor x in range(n):\n\tl.append(input().strip())\npoints = list(map(int, input().split()))\ncnts = [0 for i in range(m)]\nt = [0, 0, 0, 0, 0]\nfor i in range(m):\n\tt = [0, 0, 0, 0, 0]\n\tfor x in l:\n\t\tchoice = x[i]\n\t\tt[ord(choice) - 65] += 1\n\tcnts[i] = max(t)\n#print(cnts)\nprint(sum(i[0] * i[1] for i in zip(points, cnts)))", "#    ~####~~~#####~~~~####~~~######~~#####~~~#####~~~##~~##\n#    ##~~##~~##~~##~~##~~##~~~~~##~~~##~~##~~##~~~~~~##~##\n#    ##~~##~~#####~~~######~~~~##~~~~#####~~~####~~~~####\n#    ##~~##~~##~~##~~##~~##~~~##~~~~~##~~##~~##~~~~~~##~##\n#    ~####~~~##~~##~~##~~##~~######~~#####~~~#####~~~##~~##\n\n\nclass Read:\n    @staticmethod\n    def int():\n        return int(input())\n\n    @staticmethod\n    def list(sep=' '):\n        return input().split(sep)\n\n    @staticmethod\n    def list_int(sep=' '):\n        return list(map(int, input().split(sep)))\n\n\ndef solve():\n    n, m = Read.list_int()\n\n    ans = []\n    for i in range(n):\n        ans.append(input())\n\n    b = Read.list_int()\n    result = 0\n    for i in range(m):\n        f = {\n            'A': 0,\n            'B': 0,\n            'C': 0,\n            'D': 0,\n            'E': 0\n        }\n        for j in range(n):\n            f[ans[j][i]] += 1\n\n        max_f = 0\n        for k in list(f.values()):\n            if k > max_f:\n                max_f = k\n        result += max_f * b[i]\n    print(result)\n\n\nquery_count = 1\n# query_count = Read.int()\nfor j in range(query_count):\n    solve()\n"]


Question:
In this problem we consider a special type of an auction, which is called the second-price auction. As in regular auction n bidders place a bid which is price a bidder ready to pay. The auction is closed, that is, each bidder secretly informs the organizer of the auction price he is willing to pay. After that, the auction winner is the participant who offered the highest price. However, he pay not the price he offers, but the highest price among the offers of other participants (hence the name: the second-price auction).

Please note: if a bidder's price is divisible by 2, that means he doesn't like the item being auctioned.

Write a program that reads prices offered by bidders and finds the winner and the price he will pay. Consider that all of the offered prices are different.

-----Input-----

The first line of the input contains n (2 ≤ n ≤ 1000) — number of bidders. The second line contains n distinct integer numbers p_1, p_2, ... p_{n}, separated by single spaces (1 ≤ p_{i} ≤ 10000), where p_{i} stands for the price offered by the i-th bidder.

-----Output-----

The single output line should contain two integers: index of the winner and the price he will pay. Indices are 1-based.

-----Examples-----
Input
2
5 7

Output
2 5

Input
3
10 2 8

Output
1 8

Input
6
3 8 2 9 4 14

Output
6 9

["n=int(input())\n\nL=list(map(int,input().split()))\n\nind=L.index(max(L))\n\nL.remove(max(L))\n\nx=max(L)\n\nprint(ind+1,x)\n", "n=int(input())\na=list(map(int,input().split()))\nif a[0]>a[1]:\n    i=0\n    j=1\nelse:\n    j=0\n    i=1\nfor k in range(2,n):\n    if a[k]>a[i]:\n        j=i\n        i=k\n    elif a[k]>a[j]:\n        j=k\nprint(i+1,a[j])", "n = int(input())\nprices = list(map(int, input().split()))\npr = max(prices)\nind = prices.index(pr)\nprices.remove(pr)\nspesa = max(prices)\nprint(ind+1, spesa)\n", "__author__ = 'asmn'\n\nn = int(input())\na = sorted(enumerate(map(int, input().split())),key=lambda x:-x[1])\n\nprint(a[0][0]+1, a[1][1])\n\n", "n = int(input())\nprices = [int(i) for i in input().split()]\npeople = []\nfor i in range(n): people.append([i+1, prices[i]])\npeople.sort(key=lambda x: x[1])\nprint(str(people[-1][0])+' '+str(people[-2][1]))\n\n", "__author__ = 'Administrator'\nn = int(input())\ntest = []\ntest1 = []\ntest = list(map(int, input().split()))\ni = 1\nfor value in test:\n    test1.append((value, i))\n    i += 1\n\ntest1.sort(key=lambda d: d[0], reverse=True)\n\nprint(test1[0][1], test1[1][0])", "n = int(input())\nprices = list(map(int,input().split()))\n\nwinner = prices.index(max(prices)) + 1\n\nprices.pop(prices.index(max(prices)))\nmoney = max(prices)\nprint(winner,money)", "n = int(input())\np = list(map(int,input().split()))\nll = p.index(max(p))\np.pop(ll)\nprint(ll+1,max(p))\n", "'''\n    CodeForces problem 386A\n    26/01/2014\n'''\n\n# (x, y) = (offerta, tizio)\nn = int( input() )\nl = [ int(x) for x in input().split()]\ni=1\noff = []\nfor x in l:\n    off.append( (x, i) )\n    i+=1\n    \noff.sort( reverse=True )    \n\nprint(str(off[0][1])+' '+str(off[1][0]))\n", "n = int(input())\nv = list(map(int, input().split()))\n\nret = max(v)\nidx = v.index(ret)\nv[idx] = -1\nret = max(v)\n\nprint(str(idx + 1) + ' ' + str(ret))\n", "input()\nbet = [int(i) for i in input().split()]\nx = bet.index(max(bet)) + 1\nbet.sort()\nprint(x, bet[-2])", "input()\np = list(enumerate(map(int, input().split()), 1))\np.sort(key = lambda i: i[1])\nprint(p[-1][0], p[-2][1])", "n = int(input())\nprs = [int(x) for x in input().split()]\n\nprint(prs.index(max(prs))+1, sorted(prs)[-2])", "n = int(input())\nprices = [int(x) for x in input().split()]\n\nidx = 0\nmax_price = prices[0]\npay = 0\nfor i in range (1, n):\n\tif prices[i] > max_price:\n\t\tpay = max_price\n\t\tmax_price = prices[i]\n\t\tidx = i\n\telif prices[i] > pay:\n\t\tpay = prices[i]\n\nprint(str(idx+1) + \" \" + str(pay))", "n = int(input())\na = list(input().split())\nmx = -1\nmx2 = -1\npos = -1\nfor i in range(0, n):\n\ta[i] = int(a[i])\n\tif(a[i] > mx):\n\t\tmx2 = mx\n\t\tpos = i + 1\n\t\tmx = a[i]\n\telif(a[i] > mx2):\n\t\tmx2 = a[i]\n\ti = i + 1\nprint(str(pos) + ' ' + str(mx2))", "n = int(input())\na = list(map(int, input().split()))\np = a.index(max(a))\na.pop(p)\nprint(p+1, max(a))", "import sys\nimport math\n\nn = int(sys.stdin.readline())\npn = [int(x) for x in (sys.stdin.readline()).split()]\n\nvmax = 0\nrmax = 0\nind = 0\nfor i in range(n):\n    if(pn[i] > vmax):\n        rmax = vmax\n        vmax = pn[i]\n        ind = i + 1    \n    elif(pn[i] > rmax):\n        rmax = pn[i]\n        \nprint(ind, rmax)\n\n\n    \n\n", "n = int(input())\na = list(map(int, input().split()))\nprint(a.index(max(a)) + 1, max(a[ : a.index(max(a))] + a[a.index(max(a)) + 1 :]))", "n, p = int(input()), sorted((x, i) for i, x in enumerate(map(int, input().split())))\nprint(p[-1][1] + 1, p[-2][0])", "read = lambda: list(map(int, input().split()))\nn = int(input())\np = list(read())\nMax = max(p)\nind = p.index(Max) + 1\np.remove(Max)\nMax2 = max(p)\nprint(ind, Max2)\n", "\na = int(input())\nmax_n = 0\nmax_1 = 0\nmax_2 = 0\nk = 0\nb = [int(i) for i in input().split()]\nfor i in range(len(b)):\n    if max(b[i], max_n) > max_n:\n        max_1 = max_n\n        k = i + 1\n        max_n = max(b[i], max_n)\ndp = [i for i in range(len(b))]\ndp.reverse()\nmax_n = 0\nfor i in dp:\n    if max(b[i], max_n) > max_n:\n        max_2 = max_n\n        k = i + 1\n        max_n = max(b[i], max_n)\nprint(str(k) + \" \" + str(max(max_1, max_2)))\n", "n = int(input())\np = list(map(int,input().split()))\nll = p.index(max(p))\np.pop(ll)\nprint(ll+1,max(p))", "n = int(input())\np = list(map(int, input().split()))\n\na = p.index(max(p)) + 1\np.remove(max(p))\nb = max(p)\n\nprint(a, b)", "def second_maximum(lst):\n    b = list()\n    for i in range(len(lst)):\n        b.append(tuple([lst[i], i + 1]))\n    d = sorted(b, key=lambda x: x[0])\n    return d[len(d) - 1][1], d[len(d) - 2][0]\n\n\nn = int(input())\na = [int(i) for i in input().split()]\nprint(*second_maximum(a))\n", "# Made By Mostafa_Khaled \nbot = True \nn = int(input())\n\np = list(map(int,input().split()))\n\nll = p.index(max(p))\n\np.pop(ll)\n\nprint(ll+1,max(p))\n\n# Made By Mostafa_Khaled\n"]