problem_id
stringlengths 32
32
| name
stringclasses 1
value | problem
stringlengths 200
14k
| solutions
stringlengths 12
1.12M
| test_cases
stringlengths 37
74M
| difficulty
stringclasses 3
values | language
stringclasses 1
value | source
stringclasses 7
values | num_solutions
int64 12
1.12M
| starter_code
stringlengths 0
956
|
---|---|---|---|---|---|---|---|---|---|
8d3642fad65f4101184f326de35b3c9c | UNKNOWN | Three friends are going to meet each other. Initially, the first friend stays at the position $x = a$, the second friend stays at the position $x = b$ and the third friend stays at the position $x = c$ on the coordinate axis $Ox$.
In one minute each friend independently from other friends can change the position $x$ by $1$ to the left or by $1$ to the right (i.e. set $x := x - 1$ or $x := x + 1$) or even don't change it.
Let's introduce the total pairwise distance β the sum of distances between each pair of friends. Let $a'$, $b'$ and $c'$ be the final positions of the first, the second and the third friend, correspondingly. Then the total pairwise distance is $|a' - b'| + |a' - c'| + |b' - c'|$, where $|x|$ is the absolute value of $x$.
Friends are interested in the minimum total pairwise distance they can reach if they will move optimally. Each friend will move no more than once. So, more formally, they want to know the minimum total pairwise distance they can reach after one minute.
You have to answer $q$ independent test cases.
-----Input-----
The first line of the input contains one integer $q$ ($1 \le q \le 1000$) β the number of test cases.
The next $q$ lines describe test cases. The $i$-th test case is given as three integers $a, b$ and $c$ ($1 \le a, b, c \le 10^9$) β initial positions of the first, second and third friend correspondingly. The positions of friends can be equal.
-----Output-----
For each test case print the answer on it β the minimum total pairwise distance (the minimum sum of distances between each pair of friends) if friends change their positions optimally. Each friend will move no more than once. So, more formally, you have to find the minimum total pairwise distance they can reach after one minute.
-----Example-----
Input
8
3 3 4
10 20 30
5 5 5
2 4 3
1 1000000000 1000000000
1 1000000000 999999999
3 2 5
3 2 6
Output
0
36
0
0
1999999994
1999999994
2
4 | ["t=int(input())\nfor nt in range(t):\n\ta,b,c=map(int,input().split())\n\tprint (max(0,abs(a-b)+abs(b-c)+abs(a-c)-4))", "for _ in range(int(input())):\n a,b,c = map(int, input().split())\n pd = abs(a-b) + abs(b-c) + abs(a-c)\n for x in range(-1, 2):\n for y in range(-1, 2):\n for z in range(-1, 2):\n a1, b1, c1 = a+x, b+y, c+z\n pd = min(pd, abs(a1-b1) + abs(b1-c1) + abs(a1-c1))\n print(pd)", "q = int(input())\n\nfor case in range(q):\n a, b, c = list(map(int, input().split()))\n sm = abs(c - a) + abs(b - a) + abs(b - c)\n ans = max(0, sm - 4)\n print(ans) ", "for _ in range(int(input())):\n\tl=sorted(list(map(int,input().split())))\n\tans=2*(l[2]-l[0])\n\tfor i in [-1,0,1]:\n\t\tfor j in [-1,0,1]:\n\t\t\tfor k in [-1,0,1]:\n\t\t\t\tL=list(l)\n\t\t\t\tL[0]+=i\n\t\t\t\tL[1]+=j\n\t\t\t\tL[2]+=k\n\t\t\t\tL.sort()\n\t\t\t\tans=min(ans,2*(L[2]-L[0]))\n\tprint(ans)\n", "t = int(input())\nfor i in range(t):\n a,b,c = sorted(map(int,input().split()))\n res = 10 ** 100\n for p in range(-1, 2):\n for q in range(-1, 2):\n for r in range(-1, 2):\n aa = a + p\n bb = b + q\n cc = c + r\n tmp = abs(aa - bb)\n tmp += abs(aa - cc)\n tmp += abs(cc - bb)\n res = min(res, tmp)\n print(res)", "#!/usr/bin/env python3\n# coding: utf-8\n# Last Modified: 12/Dec/19 07:08:37 PM\n\n\nimport sys\n\n\ndef main():\n for tc in range(int(input())):\n a, b, c = get_ints()\n A = [a - 1, a, a + 1]\n B = [b - 1, b, b + 1]\n C = [c - 1, c, c + 1]\n ans = 10 ** 18\n for i in range(3):\n for j in range(3):\n for k in range(3):\n ans = min(\n ans, abs(A[i] - B[j]) + abs(A[i] - C[k]) + abs(B[j] - C[k])\n )\n print(ans)\n\n\nget_array = lambda: list(map(int, sys.stdin.readline().split()))\n\n\nget_ints = lambda: list(map(int, sys.stdin.readline().split()))\n\n\ninput = lambda: sys.stdin.readline().strip()\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "q = int(input())\nfor i in range(q):\n [a,b,c] = list(map(int, input().rstrip().split()))\n mi = min(a,b,c)\n ma = max(a,b,c)\n altro = a+b+c-mi-ma\n if mi == ma:\n print(0)\n elif ma - mi == 1:\n print(0)\n else:\n mi += 1\n ma -= 1\n print (2*(ma - mi))", "for _ in range(int(input())):\n a, b, c = map(int, input().split())\n ret = float('inf')\n for da in (-1, 0, 1):\n for db in (-1, 0, 1):\n for dc in (-1, 0, 1):\n na, nb, nc = a + da, b + db, c + dc\n ret = min(ret, abs(na - nb) + abs(na - nc) + abs(nb - nc))\n print(ret)", "from math import *\nimport os, sys\nfrom io import BytesIO\ndef f(a, x):\n if a == x:\n return x\n if a > x:\n return a - 1\n else:\n return a + 1\n \n#input = BytesIO(os.read(0, os.fstat(0).st_size)).readline\nfor i in range(int(input())):\n a, b, c = list(map(int, input().split()))\n x = int((a + b + c) / 3 + 0.5)\n a1, b1, c1 = a, b, c\n print(abs(f(a, x) - f(b, x)) + abs(f(c, x) - f(b, x)) + abs(f(a, x) - f(c, x)))\n \n", "for _ in ' '*int(input()):\n a,b,c = map(int,input().split())\n print(max(abs(a-b)+abs(a-c)+abs(b-c)-4,0))", "import sys\nimport math\nt = int(input())\nfor _ in range(t):\n a, b, c = list(map(int, input().split()))\n maxL = min(a, b, c)\n maxR = max(a, b, c)\n maxR -= 1\n maxL += 1\n print(max(0, (maxR - maxL) * 2))", "Q = int(input())\nfor _ in range(Q):\n a, b, c = tuple(map(int, input().split()))\n\n A = [a - 1, a, a + 1]\n B = [b - 1, b, b + 1]\n C = [c - 1, c, c + 1]\n\n comps = []\n for x in A:\n for y in B:\n for z in C:\n comps.append((x, y, z))\n\n ans = float('inf')\n for a, b, c in comps:\n ans = min(ans, abs(a - b) + abs(a - c) + abs(b - c))\n\n print(ans)\n", "import sys\n\nq = int(sys.stdin.readline())\n\ndef dist(x, y, z):\n\treturn abs(x - y) + abs(x - z) + abs(y - z)\n\ndef solve(a, b, c):\n\tbest_dist = 10**18\n\tfor ax in [-1, 0, 1]:\n\t\tfor bx in [-1, 0, 1]:\n\t\t\tfor cx in [-1, 0, 1]:\n\t\t\t\tbest_dist = min(best_dist, dist(a + ax, b + bx, c + cx))\n\treturn best_dist\n\nfor _ in range(q):\n\ta, b, c = map(int, sys.stdin.readline().strip().split(' '))\n\tprint(solve(a, b, c))", "test = int(input())\nfor _ in range(test):\n ans = 10**10\n a,b,c = map(int,input().split())\n for i in range(-1,2):\n for j in range(-1,2):\n for k in range(-1,2):\n ta = a+i\n tb = b+j\n tc = c+k\n ans = min(ans,abs(ta-tb)+abs(tb-tc)+abs(ta-tc))\n print(ans)", "q = int(input())\nfor numbers in range(q):\n a,b,c = list(map(int,input().split()))\n x = max(a,b,c)\n y = min(a,b,c)\n if x - y <=2 :\n print(0)\n else:\n print(2*(x-y-2))\n \n\n"] | {
"inputs": [
"8\n3 3 4\n10 20 30\n5 5 5\n2 4 3\n1 1000000000 1000000000\n1 1000000000 999999999\n3 2 5\n3 2 6\n",
"5\n1 1 1\n2 2 2\n3 3 3\n4 4 4\n10 5 8\n"
],
"outputs": [
"0\n36\n0\n0\n1999999994\n1999999994\n2\n4\n",
"0\n0\n0\n0\n6\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 5,117 | |
1ec1e0788af83ef027d08b960186e4d3 | UNKNOWN | We call two numbers $x$ and $y$ similar if they have the same parity (the same remainder when divided by $2$), or if $|x-y|=1$. For example, in each of the pairs $(2, 6)$, $(4, 3)$, $(11, 7)$, the numbers are similar to each other, and in the pairs $(1, 4)$, $(3, 12)$, they are not.
You are given an array $a$ of $n$ ($n$ is even) positive integers. Check if there is such a partition of the array into pairs that each element of the array belongs to exactly one pair and the numbers in each pair are similar to each other.
For example, for the array $a = [11, 14, 16, 12]$, there is a partition into pairs $(11, 12)$ and $(14, 16)$. The numbers in the first pair are similar because they differ by one, and in the second pair because they are both even.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$)Β β the number of test cases. Then $t$ test cases follow.
Each test case consists of two lines.
The first line contains an even positive integer $n$ ($2 \le n \le 50$)Β β length of array $a$.
The second line contains $n$ positive integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 100$).
-----Output-----
For each test case print: YES if the such a partition exists, NO otherwise.
The letters in the words YES and NO can be displayed in any case.
-----Example-----
Input
7
4
11 14 16 12
2
1 8
4
1 1 1 1
4
1 2 5 6
2
12 13
6
1 6 3 10 5 8
6
1 12 3 10 5 8
Output
YES
NO
YES
YES
YES
YES
NO
-----Note-----
The first test case was explained in the statement.
In the second test case, the two given numbers are not similar.
In the third test case, any partition is suitable. | ["def read_int():\n return int(input())\n\n\ndef read_ints():\n return list(map(int, input().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n n = read_int()\n a = list(read_ints())\n cnt = [0 for i in range(101)]\n even = 0\n for ai in a:\n cnt[ai] += 1\n if ai % 2 == 0:\n even += 1\n odd = n - even\n if even % 2 == 0:\n print('YES')\n else:\n ok = False\n for i in range(1, 100):\n if cnt[i] > 0 and cnt[i + 1] > 0:\n ok = True\n break\n print('YES' if ok else 'NO')\n", "q = int(input())\nfor i in range(q):\n\tn = int(input())\n\tl = list(map(int,input().split()))\n\tl.sort()\n\tkol = False\n\tfor i in range(1,n):\n\t\tif l[i] == l[i-1] + 1:\n\t\t\tkol =True\n\t\t\tbreak\n\tpar = 0\n\tnpar = 0\n\tfor i in l:\n\t\tif i%2 == 0:\n\t\t\tpar += 1\n\t\telse:\n\t\t\tnpar += 1\n\tif not kol:\n\t\tif par%2 == 0 and npar%2 == 0:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")\n\telse:\n\t\tif par%2 == 0 and npar%2 == 0:\n\t\t\tprint(\"YES\")\n\t\telif par%2 == 1 and npar%2 == 1:\n\t\t\tprint(\"YES\")\n\t\telse:\n\t\t\tprint(\"NO\")", "from math import *\nimport math\n\ndef r1(t):\n return t(input())\n\ndef r2(t):\n return [t(i) for i in input().split()]\n\n\nfor zzz in range(r1(int)):\n n = r1(int)\n a = r2(int)\n co = 0\n ce = 0\n for i in range(n):\n if a[i] & 1:\n co += 1\n else:\n ce += 1\n if (co % 2 == 0) and (ce % 2 == 0):\n print(\"YES\")\n else:\n a.sort()\n ha = False\n for i in range(n - 1):\n if a[i + 1] - a[i] == 1:\n ha = True\n break\n if ha:\n print(\"YES\")\n else:\n print(\"NO\")\n \n", "for _ in range(int(input())):\n n = int(input())\n ar = list(map(int, input().split()))\n ar.sort()\n a, b = 0, 0\n for elem in ar:\n if elem % 2 == 0:\n a += 1\n else:\n b += 1\n if a % 2 != b % 2:\n print('NO')\n else:\n if a % 2 == b % 2 == 0:\n print('YES')\n else:\n ans = 'NO'\n for i in range(1, n):\n if ar[i] - ar[i - 1] == 1:\n ans = 'YES'\n break\n print(ans)", "T = int(input())\nfor t in range(T):\n N = int(input())\n A = list(map(int, input().split()))\n par = [a % 2 for a in A]\n odd = sum(par)\n even = N - odd\n res = \"NO\"\n if (even % 2) == 0 and (odd % 2) == 0:\n res = \"YES\"\n elif (even % 2) != 0 and (odd % 2) != 0:\n sA = sorted(A)\n for i in range(N - 1):\n ai = sA[i]\n aip = sA[i + 1]\n if aip - ai == 1:\n res = \"YES\"\n break\n\n print(res)\n", "import sys\nfrom collections import defaultdict as dd\ndef eprint(*args):\n print(*args, file=sys.stderr)\nzz=1\n#from math import *\nimport copy\n#sys.setrecursionlimit(10**6)\nif zz:\n\tinput=sys.stdin.readline\nelse:\t\n\tsys.stdin=open('input.txt', 'r')\n\tsys.stdout=open('all.txt','w')\ndef li():\n\treturn [int(x) for x in input().split()]\ndef fi():\n\treturn int(input())\ndef si():\n\treturn list(input().rstrip())\t\ndef mi():\n\treturn \tmap(int,input().split())\t\n\ndef bo(i):\n\treturn ord(i)-ord('a')\n\n\nt=fi()\nwhile t>0:\n\tt-=1\n\tn=fi()\n\ta=li()\n\td={}\n\to=e=0\n\tfor i in a:\n\t\tif i%2:\n\t\t\to+=1\n\t\telse:\n\t\t\te+=1\t\n\t\td[i]=1\t\n\tif o%2==0 :\n\t\tprint(\"YES\")\n\t\tcontinue\n\tflag=0\t\n\tfor i in a:\n\t\tif i+1 in d or i-1 in d:\n\t\t\tprint(\"YES\")\n\t\t\tflag=1\n\t\t\tbreak\n\tif flag==0:\n\t\tprint(\"NO\")\t\t\t\t\t\n", "T = int(input())\n\nfor _ in range(T):\n n = int(input())\n aa = list(map(int, input().split()))\n\n evens = 0\n odds = 0\n\n aa.sort()\n\n ba = -100\n\n cnt = 0\n for a in aa:\n if a % 2 == 0:\n evens += 1\n else:\n odds += 1\n\n if abs(a - ba) == 1:\n cnt += 1\n ba = -100\n else:\n ba = a\n\n evens %= 2\n odds %= 2\n\n if evens == 0 and odds == 0:\n print(\"YES\")\n else:\n if cnt >= 1:\n print(\"YES\")\n else:\n print(\"NO\")\n", "T = int(input())\n\nfor t in range(T):\n N = int(input())\n A = [int(_) for _ in input().split()]\n even = [el for el in A if el % 2 == 0]\n odd = [el for el in A if el % 2 == 1]\n sA = sorted(A)\n v = 0\n for i in range(len(A)-1):\n if sA[i+1] - sA[i] == 1:\n v += 1\n if len(even) % 2 == 0 and len(odd) % 2 == 0:\n print('YES')\n else:\n if v > 0:\n print('YES')\n else:\n print('NO')\n", "\"\"\"T=int(input())\nfor _ in range(0,T):\n N=int(input())\n a,b=map(int,input().split())\n s=input()\n s=[int(x) for x in input().split()]\n for i in range(0,len(s)):\n a,b=map(int,input().split())\"\"\"\n\n\nT=int(input())\nfor _ in range(0,T):\n N=int(input())\n s=[int(x) for x in input().split()]\n c0=0\n c1=0\n pos=[0]*102\n for i in range(0,len(s)):\n pos[s[i]]=1\n if(s[i]%2==0):\n c0+=1\n else:\n c1+=1\n \n if(c0%2==0):\n print('YES')\n else:\n temp='NO'\n for i in range(0,len(pos)-1):\n if(pos[i]==1 and pos[i+1]==1):\n temp='YES'\n break\n print(temp)\n \n \n\n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n s = list(map(int, input().split()))\n even = []\n odd = []\n for i in range(n):\n if s[i] % 2 == 0:\n even.append(s[i])\n else:\n odd.append(s[i])\n if len(even) % 2 == 0:\n print(\"YES\")\n else:\n even = set(even)\n for val in odd:\n if val - 1 in even or val + 1 in even:\n print(\"YES\")\n break\n else:\n print(\"NO\")", "import sys\nq=int(input())\nfor i in range(q):\n n=int(sys.stdin.readline())\n a=[int(i) for i in sys.stdin.readline().split()]\n minrazn=999999\n a.sort()\n ch=0\n nch=0\n for k in range(n):\n if k<n-1:\n if a[k]%2==0:\n ch+=1\n else:\n nch+=1\n if minrazn>a[k+1]-a[k] and a[k+1]!=a[k] :\n minrazn=a[k+1]-a[k]\n else:\n if a[k]%2==0:\n ch+=1\n else:\n nch+=1\n if ch%2==0:\n print('YES')\n elif minrazn==1:\n print('YES')\n else:\n print('NO')\n \n", "\"\"\"\nAuthor: Q.E.D\nTime: 2020-05-24 08:43:25\n\"\"\"\nT = int(input())\nfor _ in range(T):\n n = int(input())\n a = list(map(int, input().split()))\n odd, even = [], []\n for x in a:\n if x % 2 == 1:\n odd.append(x)\n else:\n even.append(x)\n if len(odd) % 2 == 0 and len(even) % 2 == 0:\n ans = 'YES'\n else:\n for i in range(len(odd)):\n valid = False\n for j in range(len(even)):\n if abs(odd[i] - even[j]) == 1:\n valid = True\n break\n if valid:\n break\n ans = 'YES' if valid else 'NO'\n print(ans)\n\n", "import sys\n# from functools import lru_cache, cmp_to_key\n# from heapq import merge, heapify, heappop, heappush\nfrom math import sqrt, sin, cos, pi\nfrom collections import defaultdict as dd, deque, Counter as C\n# from itertools import combinations as comb, permutations as perm\n# from bisect import bisect_left as bl, bisect_right as br, bisect\n# from time import perf_counter\n# from fractions import Fraction\n\n# sys.setrecursionlimit(pow(10, 6))\n# sys.stdin = open(\"input.txt\", \"r\")\n# sys.stdout = open(\"output.txt\", \"w\")\nmod = pow(10, 9) + 7\nmod2 = 998244353\n\n\ndef data(): return sys.stdin.readline().strip()\n\n\ndef out(*var, end=\"\\n\"): sys.stdout.write(' '.join(map(str, var)) + end)\n\n\ndef l(): return list(sp())\n\n\ndef sl(): return list(ssp())\n\n\ndef sp(): return list(map(int, data().split()))\n\n\ndef ssp(): return list(map(str, data().split()))\n\n\ndef l1d(n, val=0): return [val for i in range(n)]\n\n\ndef l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]\n\n\nfor _ in range(int(data())):\n n = int(data())\n arr = l()\n even, odd = [], []\n for i in range(n):\n if arr[i] & 1:\n odd.append(arr[i])\n continue\n even.append(arr[i])\n if not(len(odd) & 1):\n out(\"YES\")\n continue\n r = False\n for i in odd:\n for j in even:\n if abs(i-j) == 1:\n r = True\n break\n if r:\n break\n if r:\n out(\"YES\")\n continue\n out(\"NO\")\n", "for _ in range(int(input())):\n c = int(input())\n f = sorted([int(i) for i in input().split()])\n f1 = False\n ch = 0\n nech = 0\n if f[0] % 2 == 1:\n nech += 1\n else:\n ch += 1\n for i in range(1, c):\n if f[i] - f[i - 1] == 1:\n f1 = True\n if f[i] % 2 == 1:\n nech += 1\n else:\n ch += 1\n\n if nech % 2 != ch % 2:\n print('NO')\n else:\n if nech % 2 == 0:\n print('YES')\n elif f1:\n print('YES')\n else:\n print('NO')\n", "t=int(input())\nfor you in range(t):\n n=int(input())\n l=input().split()\n li=[int(i) for i in l]\n lodd=[]\n leven=[]\n for i in li:\n if(i%2):\n lodd.append(i)\n else:\n leven.append(i)\n if(len(leven)%2==0):\n print(\"YES\")\n else:\n done=0\n for i in lodd:\n for j in leven:\n if(abs(i-j)==1):\n done=1\n break\n if(done):\n print(\"YES\")\n else:\n print(\"NO\")\n", "import sys, math,os\nfrom io import BytesIO, IOBase\n#from bisect import bisect_left as bl, bisect_right as br, insort\n#from heapq import heapify, heappush, heappop\nfrom collections import defaultdict as dd, deque, Counter\n#from itertools import permutations,combinations\ndef data(): return sys.stdin.readline().strip()\ndef mdata(): return list(map(int, data().split()))\ndef outl(var) : sys.stdout.write(' '.join(map(str, var))+'\\n')\ndef out(var) : sys.stdout.write(str(var)+'\\n')\nsys.setrecursionlimit(100000)\nINF = float('inf')\nmod = int(1e9)+7\n\n\ndef main():\n\n for t in range(int(data())):\n n=int(data())\n a=mdata()\n e=0\n for i in range(n):\n if a[i]%2==0:\n e+=1\n if e%2==0:\n out(\"YES\")\n else:\n s=set(a)\n flag=False\n for i in a:\n if i+1 in s:\n flag=True\n break\n if flag==True:\n out(\"YES\")\n else:\n out(\"NO\")\n\ndef __starting_point():\n main()\n__starting_point()"] | {
"inputs": [
"7\n4\n11 14 16 12\n2\n1 8\n4\n1 1 1 1\n4\n1 2 5 6\n2\n12 13\n6\n1 6 3 10 5 8\n6\n1 12 3 10 5 8\n",
"1\n4\n1 1 1 8\n"
],
"outputs": [
"YES\nNO\nYES\nYES\nYES\nYES\nNO\n",
"NO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,310 | |
7fbc8ef6cd836648798855246dd144d6 | UNKNOWN | The only difference between easy and hard versions is the maximum value of $n$.
You are given a positive integer number $n$. You really love good numbers so you want to find the smallest good number greater than or equal to $n$.
The positive integer is called good if it can be represented as a sum of distinct powers of $3$ (i.e. no duplicates of powers of $3$ are allowed).
For example: $30$ is a good number: $30 = 3^3 + 3^1$, $1$ is a good number: $1 = 3^0$, $12$ is a good number: $12 = 3^2 + 3^1$, but $2$ is not a good number: you can't represent it as a sum of distinct powers of $3$ ($2 = 3^0 + 3^0$), $19$ is not a good number: you can't represent it as a sum of distinct powers of $3$ (for example, the representations $19 = 3^2 + 3^2 + 3^0 = 3^2 + 3^1 + 3^1 + 3^1 + 3^0$ are invalid), $20$ is also not a good number: you can't represent it as a sum of distinct powers of $3$ (for example, the representation $20 = 3^2 + 3^2 + 3^0 + 3^0$ is invalid).
Note, that there exist other representations of $19$ and $20$ as sums of powers of $3$ but none of them consists of distinct powers of $3$.
For the given positive integer $n$ find such smallest $m$ ($n \le m$) that $m$ is a good number.
You have to answer $q$ independent queries.
-----Input-----
The first line of the input contains one integer $q$ ($1 \le q \le 500$) β the number of queries. Then $q$ queries follow.
The only line of the query contains one integer $n$ ($1 \le n \le 10^4$).
-----Output-----
For each query, print such smallest integer $m$ (where $n \le m$) that $m$ is a good number.
-----Example-----
Input
7
1
2
6
13
14
3620
10000
Output
1
3
9
13
27
6561
19683 | ["for _ in range(int(input())):\n\tn = int(input())\n\n\tbits = ['1']\n\twhile int(''.join(bits), 3) < n:\n\t\tbits.append('1')\n\t\n\t\n\tfor i in range(len(bits)):\n\t\tbits[i] = '0'\n\t\tif int(''.join(bits), 3) < n:\n\t\t\tbits[i] = '1'\n\t\n\tprint(int(''.join(bits), 3))\n", "def base3(n):\n # 17 -> [2, 2, 1] (reversedd)\n array = []\n while n > 0:\n array.append(n % 3)\n n //= 3\n return array\ndef good(n):\n return 2 not in base3(n)\n\nfor _ in range(int(input())):\n n = int(input())\n while not good(n): n += 1\n print(n)", "import bisect\n\nt = int(input())\n\ntmp_ans = [0]*100\nfor i in range(100):\n tmp_ans[i] = 3**i\n\nans = []\nfor i in range(18):\n tmp = ans[0:]\n for j in tmp:\n ans.append(j + tmp_ans[i])\n ans.append(tmp_ans[i])\nans = sorted(ans)\n\nfor _ in range(t):\n n = int(input())\n ind = bisect.bisect_left(ans, n)\n print(ans[ind])", "\nq = int(input())\nN = [int(input()) for i in range(q)]\nt = [3**i for i in range(10)]\n\ndef d(x):\n ans = 0\n m = 1\n while x > 0:\n if x % 2 == 1:\n ans += m\n m *= 3\n x //= 2\n return(ans)\n\n# print(d(2))\n\n\nfor i in range(q):\n n = N[i]\n m = 0\n t = 0\n while m < n:\n m = d(t)\n t += 1\n print(m)\n\n\n\n", "q = int(input())\nfor i in range(q):\n n = int(input())\n prod = 1\n prods = [1]\n sum1 = 0\n a = []\n while prod < n:\n sum1 += prod\n a.append(1)\n prod *= 3\n prods.append(prod)\n if sum1 < n:\n print(prod)\n else:\n for i in range(len(prods) - 1, -1, -1):\n if sum1 - prods[i] >= n:\n sum1 -= prods[i]\n print(sum1)", "from math import log\nfor _ in range(int(input())):\n n = int(input())\n s = []\n x = int(log(n, 3))\n while x >= 0:\n if n >= 2 * 3 ** x:\n n -= 2 * 3 ** x\n s.append(2)\n elif n >= 3 ** x:\n n -= 3 ** x\n s.append(1)\n else:\n s.append(0)\n x -= 1\n s = s[::-1]\n l2 = 2229222\n for i in range(len(s)):\n if s[i] == 2:\n l2 = i\n if l2 != 2229222:\n f = 1\n for i in range(len(s)):\n if i <= l2:\n s[i] = 0\n else:\n if s[i] == 0:\n s[i] = 1\n f = 0\n break\n else:\n s[i] = 0\n if f:\n s.append(1)\n ans = 0\n for i in range(len(s)):\n ans += 3 ** i * int(s[i])\n print(ans)", "arr = [3**i for i in range(10)]\ns = sum(arr)\nt = int(input())\nfor _ in range(t):\n n = int(input())\n m = s\n for i in arr[::-1]:\n if m - i >= n:\n m -= i\n print(m)\n", "# coding: utf-8\n# Your code here!\ndef tobase3(n):\n a = []\n while(n>0):\n a.append(n%3)\n n//=3\n a.reverse()\n return a\n \ndef todec(a):\n sum=0;\n for i in range(len(a)):\n sum*=3\n sum+=a[i]\n return sum\n \n \nt = int(input())\nfor _ in range(t):\n n = int(input())\n a = tobase3(n)\n j=0\n flag = False\n for i in range(len(a)):\n if(a[i]==2):\n flag = True\n j=i\n while(j>=0 and a[j]!=0):\n j-=1\n break\n if(j<0 and flag):\n print(3**len(a))\n elif(flag):\n print(todec(a[:j]+[1]+[0]*(len(a)-j-1)))\n else:\n print(n)", "coins=[3**i for i in range(26)]\nt=(1<<12)\nsm=[]\nfor i in range(t):\n c=0 \n for j in range(12):\n if i&(1<<j):\n c+=coins[j]\n sm.append(c)\nsm.sort() \nfrom bisect import bisect_left as bl \nfor _ in range(int(input())):\n n=int(input())\n ind=bl(sm,n)\n print(sm[ind])\n \n", "q = int(input())\nfor fwewfe in range(q):\n\tn = int(input())\n\tsk = 1\n\tsu = 0\n\twhile su < n:\n\t\tsu += sk\n\t\tsk *= 3\n\twhile su >= n and sk > 0:\n\t\tif su - sk >= n:\n\t\t\tsu -= sk\n\t\tsk //= 3\n\tprint(su)", "import sys\ninput = sys.stdin.readline\n\nq=int(input())\n\ndef calc(n):\n for i in range(40):\n if n<=3**i:\n break\n \n if n==3**i:\n return n\n \n elif n>(3**i-1)//2:\n return 3**i\n \n else:\n n-=3**(i-1)\n return 3**(i-1)+calc(n)\n\n \n\nfor testcases in range(q):\n n=int(input())\n print(calc(n))\n\n \n", "def isgood(n):\n while n > 0:\n if n % 3 > 1:\n return False\n n //= 3\n\n return True\n\n\nq = int(input())\n\nfor _ in range(q):\n n = int(input())\n\n while not isgood(n):\n n += 1\n\n print(n)", "import sys\n\ndef check(x):\n\n\twhile(x!=0):\n\t\tif(x%3==2):\n\t\t\treturn False\n\t\tx=x//3\n\n\treturn True\n\nq=int(sys.stdin.readline())\n\nans_arr=[]\n\nfor i in range(q):\n\tn=int(sys.stdin.readline())\n\n\tval=n\n\twhile(not (check(val))):\n\t\tval+=1\n\n\tans_arr.append(str(val))\n\nprint(\"\\n\".join(ans_arr))", "def main():\n q = int(input())\n thirds = [1]\n while thirds[-1] < 1e19:\n thirds.append(thirds[-1] * 3)\n for t in range(q):\n a = int(input())\n deg = 0\n subans = 0\n while subans < a:\n subans += thirds[deg]\n deg += 1\n while deg != -1:\n if subans - thirds[deg] >= a:\n subans -= thirds[deg]\n deg -= 1\n print(subans)\n\n\nmain()\n", "t = int(input(''))\n\ndef ternary (n):\n if n == 0:\n return '0'\n nums = []\n while n:\n n, r = divmod(n, 3)\n nums.append(str(r))\n return ''.join(reversed(nums))\n\nfor _ in range(t):\n n = int(input(''))\n b = ternary(n)\n l = len(b)\n #print(b)\n ind = -1\n ans = ''\n for i in range(l):\n if(b[i] == '2'):\n ans = '0'*(l-i)\n ind = i\n break\n if(ind == 0):\n ans = '1'+ans\n elif(ind == -1):\n ans = b\n else:\n ind1 = -1\n for i in range(ind-1,-1,-1):\n if(b[i] == '1'):\n ans = '0'+ans\n else:\n ans = '1'+ans\n ind1 = i\n break\n if(ind1 == -1):\n ans = '1'+ans\n else:\n ans = b[0:ind1]+ans\n \n print(int(ans,3))\n \n \n", "from math import *\nt = int(input())\na = []\nk = 1\nfor i in range(9):\n s = len(a)\n a.append(k)\n for j in range(s):\n a.append(a[j]+k)\n k *= 3\na.append(k)\nfor y in range(t):\n n = int(input())\n for i in a:\n if i >= n:\n print(i)\n break", "def ternary(n):\n\twhile n:\n\t\tif n%3==2:\n\t\t\treturn 0\n\t\tn//=3\n\treturn 1\nfor _ in range(int(input())):\n\tn = int(input())\n\tif ternary(n):\n\t\tprint(n)\n\telse:\n\t\twhile ternary(n)!=1:\n\t\t\tn+=1\n\t\tprint(n)\n\t\n", "q = int(input())\nfor i in range(q):\n n = int(input())\n s = 0\n i = -1\n while s < n:\n i += 1\n s += 3 ** i\n if s == n:\n print(s)\n else:\n for j in range(i, -1, -1):\n if s - 3 ** j >= n:\n s -= 3 ** j\n print(s)", "q = int(input())\nwhile q:\n q -= 1\n n = int(input())\n good = [1]\n x = 1\n while 1:\n t = 3 ** x\n ans = []\n for i in good:\n ans.append(t + i)\n good.append(t)\n for i in ans: good.append(i)\n x += 1\n if max(good) >= n: break\n for i in good:\n if i >= n:\n print(i)\n break", "import itertools\n\nLIMIT = 9\n\npowers = [i for i in range(LIMIT)]\nperms = []\nitems = []\n\nnumbers = []\n\nfor i in range(1, LIMIT + 1):\n perms += itertools.combinations(powers, i)\n\nfor i in perms:\n r = 0\n\n for j in i:\n r += pow(3, j)\n\n numbers.append(r)\n\nnumbers.append(3**9)\nnumbers.sort()\n\ndef find(l, r, item):\n mid = l + (r - l) // 2\n\n if r >= l:\n if numbers[mid] == item:\n return item\n\n if numbers[mid] > item:\n return find(l, mid-1, item)\n\n else:\n return find(mid+1, r, item)\n else:\n return numbers[l]\n\nq = int(input())\nl_numbers = len(numbers)\n\nfor _ in range(q):\n n = int(input())\n\n print(find(0, l_numbers, n))\n", "v=[]\ni=0\nwhile(True):\n st=bin (i).replace( \"0b\" ,\"\")\n k=num=0\n for j in range(len(st)-1,-1,-1):\n num+=int(st[j])*pow(3,k)\n k+=1\n if num>100000:\n break\n v.append(num)\n i+=1\nv.sort()\nfrom bisect import bisect_left\n \nfor _ in range(int(input())): \n n=int(input())\n idx=bisect_left(v,n)\n print(v[idx])\n", "\"\"\"\nNTC here\n\"\"\"\nfrom sys import stdin, setrecursionlimit\nsetrecursionlimit(10**7)\n\n\ndef iin(): return int(stdin.readline())\n \n \ndef lin(): return list(map(int, stdin.readline().split()))\n\n\n# range = xrange\n# input = raw_input\n\nMAX_INT=99999999\n\ndef p3(a):\n ans=[]\n while a:\n ans.append(a%3)\n a//=3\n return ans\ndef main():\n t=iin()\n while t:\n t-=1\n n=iin()\n pw=p3(n)+[0,0]\n # print(pw)\n l=len(pw)\n ch=1\n for i in range(l-3,-1,-1):\n if pw[i]>1 :\n if ch:\n pw[i]=0\n pw[i+1]+=1\n ch=0\n else:\n pw[i]=0\n if ch==0:\n pw[i]=0\n for i in range(l-1):\n if pw[i]>1:pw[i]=0;pw[i+1]+=1\n ans=0\n pw=pw[::-1]\n for i in pw:\n ans=ans*3+i\n print(ans)\n\n\n\n \n\n\n\n\n\n\n\nmain()\n# try:\n# main()\n# except Exception as e: print(e)\n", "a = [0,1,2,3,4,5,6,7,8,9]\nfrom itertools import combinations\nimport bisect\nc = []\nfor i in range(1,10):\n c+=list(combinations(a,i))\np = set()\nfor i in range(len(c)):\n l = 0\n for j in range(len(c[i])):\n l+=pow(3,c[i][j])\n p.add(l)\np = list(p)\np = sorted(p)\nq = int(input())\nfor _ in range(q):\n n = int(input())\n k = bisect.bisect_left(p,n)\n if p[k]==n:\n print(n)\n else:\n print(p[k])"] | {
"inputs": [
"7\n1\n2\n6\n13\n14\n3620\n10000\n",
"100\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n49\n50\n51\n52\n53\n54\n55\n56\n57\n58\n59\n60\n61\n62\n63\n64\n65\n66\n67\n68\n69\n70\n71\n72\n73\n74\n75\n76\n77\n78\n79\n80\n81\n82\n83\n84\n85\n86\n87\n88\n89\n90\n91\n92\n93\n94\n95\n96\n97\n98\n99\n100\n"
],
"outputs": [
"1\n3\n9\n13\n27\n6561\n19683\n",
"1\n3\n3\n4\n9\n9\n9\n9\n9\n10\n12\n12\n13\n27\n27\n27\n27\n27\n27\n27\n27\n27\n27\n27\n27\n27\n27\n28\n30\n30\n31\n36\n36\n36\n36\n36\n37\n39\n39\n40\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n81\n82\n84\n84\n85\n90\n90\n90\n90\n90\n91\n93\n93\n94\n108\n108\n108\n108\n108\n108\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 10,317 | |
2ac86388e18689790b16a92ed5a76e54 | UNKNOWN | The only difference between easy and hard versions is constraints.
There are $n$ kids, each of them is reading a unique book. At the end of any day, the $i$-th kid will give his book to the $p_i$-th kid (in case of $i = p_i$ the kid will give his book to himself). It is guaranteed that all values of $p_i$ are distinct integers from $1$ to $n$ (i.e. $p$ is a permutation). The sequence $p$ doesn't change from day to day, it is fixed.
For example, if $n=6$ and $p=[4, 6, 1, 3, 5, 2]$ then at the end of the first day the book of the $1$-st kid will belong to the $4$-th kid, the $2$-nd kid will belong to the $6$-th kid and so on. At the end of the second day the book of the $1$-st kid will belong to the $3$-th kid, the $2$-nd kid will belong to the $2$-th kid and so on.
Your task is to determine the number of the day the book of the $i$-th child is returned back to him for the first time for every $i$ from $1$ to $n$.
Consider the following example: $p = [5, 1, 2, 4, 3]$. The book of the $1$-st kid will be passed to the following kids: after the $1$-st day it will belong to the $5$-th kid, after the $2$-nd day it will belong to the $3$-rd kid, after the $3$-rd day it will belong to the $2$-nd kid, after the $4$-th day it will belong to the $1$-st kid.
So after the fourth day, the book of the first kid will return to its owner. The book of the fourth kid will return to him for the first time after exactly one day.
You have to answer $q$ independent queries.
-----Input-----
The first line of the input contains one integer $q$ ($1 \le q \le 1000$) β the number of queries. Then $q$ queries follow.
The first line of the query contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) β the number of kids in the query. The second line of the query contains $n$ integers $p_1, p_2, \dots, p_n$ ($1 \le p_i \le n$, all $p_i$ are distinct, i.e. $p$ is a permutation), where $p_i$ is the kid which will get the book of the $i$-th kid.
It is guaranteed that $\sum n \le 2 \cdot 10^5$ (sum of $n$ over all queries does not exceed $2 \cdot 10^5$).
-----Output-----
For each query, print the answer on it: $n$ integers $a_1, a_2, \dots, a_n$, where $a_i$ is the number of the day the book of the $i$-th child is returned back to him for the first time in this query.
-----Example-----
Input
6
5
1 2 3 4 5
3
2 3 1
6
4 6 2 1 5 3
1
1
4
3 4 1 2
5
5 1 2 4 3
Output
1 1 1 1 1
3 3 3
2 3 3 2 1 3
1
2 2 2 2
4 4 4 1 4 | ["for _ in range(int(input())):\n n = int(input())\n P = list(map(int, input().split()))\n ans = [0] * n\n for i in range(n):\n if ans[i] == 0:\n now = i\n cnt = 0\n cll = []\n while True:\n now = P[now] - 1\n cnt += 1\n cll.append(now)\n if now == i:\n break\n for u in cll:\n ans[u] = cnt\n print(' '.join(list(map(str, ans))))", "import math\nfrom collections import deque, defaultdict\nfrom sys import stdin, stdout\ninput = stdin.readline\n# print = stdout.write\nlistin = lambda : list(map(int, input().split()))\nmapin = lambda : map(int, input().split())\nfor _ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n for i in range(n):\n a[i]-=1\n col = [0 for i in range(n)]\n c = 1\n for i in range(n):\n if not col[i]:\n s = i\n while col[s] == 0:\n col[s] = c\n s = a[s]\n c+=1\n d = defaultdict(int)\n for i in col:\n d[i]+=1\n ans = [0 for i in range(n)]\n for i in range(n):\n ans[i] = d[col[i]]\n print(*ans)", "tc = int(input())\n\nwhile tc > 0:\n\ttc -= 1\n\tn = int(input())\n\tp = [0] + list(map(int, input().split()))\n\n\tans = [0] * (n + 1)\n\tmk = [False] * (n + 1)\n\n\tfor i in range(1 , n + 1):\n\t\tif not mk[i]:\n\t\t\tsz = 1\n\t\t\tcurr = p[i]\n\t\t\tmk[i] = True\n\t\t\twhile curr != i:\n\t\t\t\tsz += 1\n\t\t\t\tmk[curr] = True\n\t\t\t\tcurr = p[curr]\n\n\t\t\tans[i] = sz\n\t\t\tcurr = p[i]\n\t\t\twhile curr != i:\n\t\t\t\tans[curr] = sz\n\t\t\t\tcurr = p[curr]\n\n\tprint(\" \".join([str(x) for x in ans[1:]]))\n\n\n", "tc = int(input())\n\nwhile tc > 0:\n\ttc -= 1\n\tn = int(input())\n\tp = [0] + list(map(int, input().split()))\n\n\tans = [0] * (n + 1)\n\tmk = [False] * (n + 1)\n\n\tfor i in range(1 , n + 1):\n\t\tif not mk[i]:\n\t\t\tsz = 1\n\t\t\tcurr = p[i]\n\t\t\tmk[i] = True\n\t\t\twhile curr != i:\n\t\t\t\tsz += 1\n\t\t\t\tmk[curr] = True\n\t\t\t\tcurr = p[curr]\n\n\t\t\tans[i] = sz\n\t\t\tcurr = p[i]\n\t\t\twhile curr != i:\n\t\t\t\tans[curr] = sz\n\t\t\t\tcurr = p[curr]\n\n\tprint(\" \".join([str(x) for x in ans[1:]]))\n\n\n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n p = list(map(int, input().split()))\n ans = [-1] * n\n for i in range(n):\n if ans[i] != -1:\n continue\n memo = {}\n tmp = i\n memo[tmp] = 1\n cnt = 1\n while True:\n tmp = p[tmp] - 1\n if tmp in memo:\n break\n else:\n memo[tmp] = 1\n cnt += 1\n for j in memo:\n ans[j] = cnt\n print(*ans)\n", "import sys\ninput = sys.stdin.readline\n\nq=int(input())\n\ndef find(x):\n while Group[x] != x:\n x=Group[x]\n return x\n\ndef Union(x,y):\n if find(x) != find(y):\n Group[find(y)]=Group[find(x)]=min(find(y),find(x))\n\nfor testcases in range(q):\n n=int(input())\n P=list(map(int,input().split()))\n\n Group=[i for i in range(n)]\n\n for i in range(n):\n Union(i,P[i]-1)\n\n G=[find(i) for i in range(n)]\n\n count=[0]*n\n\n for g in G:\n count[g]+=1\n\n for i in range(n):\n print(count[G[i]],end=\" \")\n print()\n\n\n\n \n", "import sys\ndef I():\n return sys.stdin.readline().rstrip()\nq = int( I() )\nfor _ in range( q ):\n n = int( I() )\n c = [ -1 ] * n\n def getp( i ):\n s = []\n while c[ i ] >= 0:\n s.append( i )\n i = c[ i ]\n for j in s:\n c[ j ] = i\n return i\n p = list( map( int, I().split() ) )\n p = [ i - 1 for i in p ]\n for i, q in enumerate( p ):\n a, b = getp( i ), getp( q )\n if a != b:\n c[ a ] += c[ b ]\n c[ b ] = a\n for i in p:\n print( -c[ getp( i ) ], end = \" \" )\n print()\n", "q = int(input())\nfor i in range(q):\n n = int(input())\n a = list(map(int, input().split()))\n b = [-1 for i in range(n)]\n c = [0 for i in range(n + 2)]\n used = [True for i in range(n)]\n for i in range(n):\n if used[i]:\n d = a[i] - 1\n cell = a[i] - 1\n b[cell] = d\n c[d] += 1\n used[cell] = False\n while cell != i:\n cell = a[cell] - 1\n c[d] += 1\n b[cell] = d\n used[cell] = False\n for i in range(n):\n print(c[b[i]], end=\" \")\n print()", "\nq = int(input())\n\nfor i in range(q):\n\n n = int(input())\n\n lis = [0] * n\n \n\n a = list(map(int,input().split()))\n \n q = []\n ind = 0\n now = 0\n end = 0\n while end < n:\n\n while ind < n:\n if lis[ind] == 0:\n now = ind\n break\n ind += 1\n\n q = []\n\n while len(q) == 0 or now != q[0]:\n q.append(now)\n now = a[now] - 1\n\n for i in q:\n lis[i] = len(q)\n\n end += len(q)\n\n print(\" \".join(map(str,lis)))\n", "for _ in range(int(input())):\n n = int(input())\n l = [int(i) - 1 for i in input().split()]\n res = []\n v = [0] * n\n for i in range(n):\n if (v[i] == 0):\n temp = i\n v[temp] = 1\n res.append({temp})\n while (l[temp] not in res[-1]):\n res[-1].add(l[temp])\n temp = l[temp]\n v[temp] = 1\n # print(res)\n for i in res:\n for j in i:\n v[j] = len(i)\n print(*v)", "def read():\n return list(map(int,input().split()))\n\nq = int(input())\nfor test in range(q):\n n = int(input())\n a = read()\n for i in range(n):\n a[i] -= 1\n used = [False]*n\n ans = [0]*n\n for i in range(n):\n if not used[i]:\n j = a[i]\n k = 1\n while j!=i:\n k += 1\n j = a[j]\n j = a[i]\n ans[i] = k\n while j!=i:\n j = a[j]\n ans[j] = k\n used[j] = True\n print(*ans)\n", "q = int(input())\nfor i in range(q):\n n = int(input())\n a = [int(i) for i in input().split()]\n ans = [0] * n\n for i in range(n):\n if ans[i] == 0:\n numbers_now = []\n now = a[a[i] - 1]\n numbers_now.append(i)\n numbers_now.append(a[i] - 1)\n count = 1\n while now != a[i]:\n now = a[now - 1]\n numbers_now.append(now - 1)\n count += 1\n for i in numbers_now:\n ans[i] = count\n else:\n continue\n print(*ans)", "\nq = int(input())\nfor i in range(q):\n a = int(input())\n cycle = [1 for i in range(a)]\n\n tab = list(map(int, input().split()))\n\n for indice, j in enumerate(tab):\n if cycle[indice] != 1:\n continue\n var = indice +1\n\n while tab[var-1] != indice+1:\n var = tab[var-1]\n cycle[indice] += 1\n\n var = indice +1\n\n while tab[var-1] != indice+1:\n var = tab[var-1]\n cycle[var-1] = cycle[indice]\n\n\n print(*cycle)", "I = lambda: list(map(int, input().split()))\n\nt, = I()\nwhile t:\n t -= 1\n n, = I()\n l = I()\n l = [i-1 for i in l]\n p = [i for i in range(n)]\n v = [0]*n\n for i in range(n):\n if not v[i]:\n v[i] = 1\n j = l[i]\n while not v[j]:\n v[j] = 1\n v[i] += 1\n p[j] = i\n j = l[j]\n \n #print(v)\n for i in range(n):\n print(v[p[i]], end = ' ')\n print()\n", "t = int(input(''))\nfor _ in range(t):\n n = int(input(''))\n p = list(map(int,input('').split(' ')))\n d = {}\n for i in range(n):\n d[p[i]] = i+1\n exp = [False]*(n+1)\n ans = {}\n for i in range(1,n+1,1):\n if(not exp[i]):\n a = [i]\n c = 1\n t = i\n while(d[t] != i):\n t = d[t]\n exp[t] = True\n c = c+1\n a.append(t)\n for f in a:\n ans[f] = c\n\n for i in range(1,n+1,1):\n print(ans[i], end = ' ')\n print('')\n ", "def solve():\n n = int(input())\n a = list(map(int, input().split()))\n for i in range(n):\n a[i] -= 1\n\n ans = dict()\n\n for i in range(n):\n # st = i + 1\n if i not in ans:\n p = []\n\n j = i\n p.append(j)\n ca = 0\n while True:\n ca += 1\n j = a[j]\n p.append(j)\n if j == i:\n for x in p:\n ans[x] = ca\n break\n\n for i in range(n):\n print(ans [i], end=\" \")\n print()\n\n\nfor _ in range(int(input())):\n solve()\n", "from bisect import *\nfrom collections import *\nfrom itertools import *\nimport functools\nimport sys\nimport math\nfrom decimal import *\nfrom copy import *\nfrom heapq import *\nfrom fractions import *\ngetcontext().prec = 30\nMAX = sys.maxsize\nMAXN = 1000010\nMOD = 10**9+7\nspf = [i for i in range(MAXN)]\ndef sieve():\n for i in range(2,MAXN,2):\n spf[i] = 2\n for i in range(3,int(MAXN**0.5)+1):\n if spf[i]==i:\n for j in range(i*i,MAXN,i):\n if spf[j]==j:\n spf[j]=i\ndef fib(n,m):\n if n == 0:\n return [0, 1]\n else:\n a, b = fib(n // 2)\n c = ((a%m) * ((b%m) * 2 - (a%m)))%m\n d = ((a%m) * (a%m))%m + ((b)%m * (b)%m)%m\n if n % 2 == 0:\n return [c, d]\n else:\n return [d, c + d]\n\ndef charIN(x= ' '):\n return(sys.stdin.readline().strip().split(x))\n\ndef arrIN(x = ' '):\n return list(map(int,sys.stdin.readline().strip().split(x)))\n\ndef ncr(n,r):\n num=den=1\n for i in range(r):\n num = (num*(n-i))%MOD\n den = (den*(i+1))%MOD\n\n return (num*(pow(den,MOD-2,MOD)))%MOD\n\ndef flush():\n return sys.stdout.flush()\n\n'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''\n\ndef bfs(v):\n q = [v]\n vis[v] = 1\n s = 0\n l = []\n while q:\n x = q.pop(0)\n l.append(x)\n s+=1\n st[x] = s\n for i in d[x]:\n if not vis[i]:\n q.append(i)\n vis[i] = 1\n else:\n t = s+1-st[i]\n break\n for i in l:\n ans[i] = t\n\n\nfor _ in range(int(input())):\n n = int(input())\n a = arrIN()\n d = defaultdict(list)\n for i in range(1,n+1):\n d[i].append(a[i-1])\n vis = [0]*(n+1)\n st = [0]*(n+1)\n ans = [0]*(n+1)\n for i in range(1,n+1):\n if not vis[i]:\n bfs(i)\n print(*ans[1:])", "import sys\ninput = sys.stdin.readline\n\nq = int(input())\n\nfor _ in range(q):\n n = int(input())\n p = list(map(int, input().split()))\n \n for i in range(n):\n p[i] -= 1\n \n flag = [-1] * n\n ans = [-1] * n\n \n for i in range(n):\n cur = i\n \n if flag[cur] == 1:\n continue\n\n flag[cur] = 1\n l = [cur]\n \n while True:\n if flag[p[cur]] == 1:\n break\n \n if flag[p[cur]] == -1:\n flag[p[cur]] = 1\n \n cur = p[cur]\n l.append(cur)\n \n for li in l:\n ans[li] = len(l)\n \n print(*ans)", "import sys\n\ninput = sys.stdin.readline\nsys.setrecursionlimit(100000)\n\n\ndef getN():\n return int(input())\n\n\ndef getList():\n return list(map(int, input().split()))\n\n\nimport math\n\nclass UnionFind:\n def __init__(self, n):\n self.par = [i for i in range(n+1)]\n self.rank = [0] * (n+1)\n self.size = [1] * (n+1)\n\n def find(self, x):\n if self.par[x] == x:\n return x\n else:\n self.par[x] = self.find(self.par[x])\n return self.par[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if self.rank[x] < self.rank[y]:\n self.par[x] = y\n self.size[y] += self.size[x]\n else:\n self.par[y] = x\n self.size[x] += self.size[y]\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n\n\n def same_check(self, x, y):\n return self.find(x) == self.find(y)\n\n\ndef solve():\n n = getN()\n nums = getList()\n uf = UnionFind(n)\n # print(nums)\n for i, num in enumerate(nums):\n uf.par[i+1] = uf.find(i+1)\n uf.par[num] = uf.find(num)\n # print(uf.size)\n # print(uf.par)\n # print(\"============\")\n if not uf.same_check(i+1, num):\n uf.union(i+1, num)\n\n for i in range(n+1):\n uf.find(i)\n ans = []\n for i in range(n):\n ans.append(uf.size[uf.par[i+1]])\n print(*ans)\n # print(uf.size)\n # print(uf.par)\n\ndef main():\n q = getN()\n for _ in range(q):\n solve()\n\ndef __starting_point():\n main()\n\n\"\"\"\n1\n3\n2 3 1\n\"\"\"\n__starting_point()", "q = int(input())\nfor _ in range(q):\n n = int(input())\n Q = list(map(int,input().split()))\n res=[1]*n\n for i in range(n):\n if res[i]==1:\n t = Q[i]\n tl = [t]\n while t!=i+1:\n t=Q[t-1]\n tl.append(t)\n res[i]+=1\n for k in tl:\n res[k-1]=res[i]\n print(*res)", "# !/usr/bin/env python3\n# encoding: UTF-8\n# Last Modified: 22/Oct/2019 08:25:41 PM\n\n\nimport sys\n\n\ndef main():\n for tc in range(int(input())):\n n = int(input())\n arr = get_array()\n for i in range(n):\n arr[i] -= 1\n ans = [1] * n\n d = {}\n for i in range(n):\n if i in d:\n continue\n tmp = {}\n j = arr[i]\n while j != i:\n ans[i] += 1\n j = arr[j]\n tmp[arr[j]] = 1\n for j in tmp:\n ans[j] = ans[i]\n d[j] = 1\n\n print(*ans)\n\n\nget_array = lambda: list(map(int, sys.stdin.readline().split()))\n\n\nget_ints = lambda: list(map(int, sys.stdin.readline().split()))\n\n\ninput = lambda: sys.stdin.readline().strip()\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import sys\nimport itertools\nimport math\nimport collections\nfrom collections import Counter\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n prime = [True for i in range(n + 1)]\n p = 2\n while (p * p <= n):\n if (prime[p] == True):\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 1\n prime[0] = prime[1] = False\n r = [p for p in range(n + 1) if prime[p]]\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return list(map(int, input().split()))\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\n\nt = ii()\nfor i in range(t):\n n = ii()\n d = li()\n s = [0]*n\n used = [-1]*n\n\n for i in range(n):\n if used[i] == -1:\n u, v = i, d[i] - 1\n while True:\n s[i] += 1\n used[u] = i\n u, v = v, d[v] - 1\n if u == i:\n break\n res = []\n for i in range(n):\n res.append(s[used[d[i] - 1]])\n prr(res)\n\n\n\n\n\n", "for _ in range(int(input())):\n\n n = int(input())\n p = [int(x) - 1 for x in input().split()]\n\n used = [False] * n\n r = [0] * n\n\n for i in range(n):\n if not used[i]:\n j = i\n cycle = []\n while not used[j]:\n cycle.append(p[j])\n used[j] = True\n j = p[j]\n for c in cycle:\n r[c] = len(cycle)\n print(*r)\n"] | {
"inputs": [
"6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3\n",
"20\n6\n3 6 4 2 5 1\n6\n2 4 1 3 5 6\n7\n5 2 1 4 6 7 3\n6\n3 6 4 2 5 1\n9\n5 8 2 6 4 7 9 1 3\n9\n3 2 6 8 5 7 9 1 4\n8\n8 4 6 5 2 1 7 3\n5\n3 1 2 5 4\n10\n2 4 3 5 6 10 7 9 1 8\n2\n2 1\n1\n1\n5\n3 2 5 4 1\n3\n1 3 2\n8\n2 6 5 3 7 1 4 8\n5\n3 5 4 1 2\n4\n1 4 3 2\n5\n5 1 4 3 2\n4\n4 1 3 2\n1\n1\n7\n3 1 5 2 6 7 4\n"
],
"outputs": [
"1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4 \n",
"5 5 5 5 1 5 \n4 4 4 4 1 1 \n5 1 5 1 5 5 5 \n5 5 5 5 1 5 \n9 9 9 9 9 9 9 9 9 \n7 1 7 7 1 7 7 7 7 \n4 3 4 3 3 4 1 4 \n3 3 3 2 2 \n8 8 1 8 8 8 1 8 8 8 \n2 2 \n1 \n3 1 3 1 3 \n1 2 2 \n3 3 4 4 4 3 4 1 \n3 2 3 3 2 \n1 2 1 2 \n3 3 2 2 3 \n3 3 1 3 \n1 \n7 7 7 7 7 7 7 \n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 16,876 | |
0abbf9f299da6eae4728cec91ca54089 | UNKNOWN | There are $n$ Christmas trees on an infinite number line. The $i$-th tree grows at the position $x_i$. All $x_i$ are guaranteed to be distinct.
Each integer point can be either occupied by the Christmas tree, by the human or not occupied at all. Non-integer points cannot be occupied by anything.
There are $m$ people who want to celebrate Christmas. Let $y_1, y_2, \dots, y_m$ be the positions of people (note that all values $x_1, x_2, \dots, x_n, y_1, y_2, \dots, y_m$ should be distinct and all $y_j$ should be integer). You want to find such an arrangement of people that the value $\sum\limits_{j=1}^{m}\min\limits_{i=1}^{n}|x_i - y_j|$ is the minimum possible (in other words, the sum of distances to the nearest Christmas tree for all people should be minimized).
In other words, let $d_j$ be the distance from the $j$-th human to the nearest Christmas tree ($d_j = \min\limits_{i=1}^{n} |y_j - x_i|$). Then you need to choose such positions $y_1, y_2, \dots, y_m$ that $\sum\limits_{j=1}^{m} d_j$ is the minimum possible.
-----Input-----
The first line of the input contains two integers $n$ and $m$ ($1 \le n, m \le 2 \cdot 10^5$) β the number of Christmas trees and the number of people.
The second line of the input contains $n$ integers $x_1, x_2, \dots, x_n$ ($-10^9 \le x_i \le 10^9$), where $x_i$ is the position of the $i$-th Christmas tree. It is guaranteed that all $x_i$ are distinct.
-----Output-----
In the first line print one integer $res$ β the minimum possible value of $\sum\limits_{j=1}^{m}\min\limits_{i=1}^{n}|x_i - y_j|$ (in other words, the sum of distances to the nearest Christmas tree for all people).
In the second line print $m$ integers $y_1, y_2, \dots, y_m$ ($-2 \cdot 10^9 \le y_j \le 2 \cdot 10^9$), where $y_j$ is the position of the $j$-th human. All $y_j$ should be distinct and all values $x_1, x_2, \dots, x_n, y_1, y_2, \dots, y_m$ should be distinct.
If there are multiple answers, print any of them.
-----Examples-----
Input
2 6
1 5
Output
8
-1 2 6 4 0 3
Input
3 5
0 3 1
Output
7
5 -2 4 -1 2 | ["from queue import deque\n\nn, m = map(int, input().split())\narr = list(map(int, input().split()))\narr.sort()\n\nused = set(arr)\nq = deque()\nfor i in range(n):\n q.append([arr[i] - 1, 1, -1])\n q.append([arr[i] + 1, 1, 1])\n\nret = []\ns = 0\nwhile m:\n x, l, dr = q.popleft()\n a = x + dr\n if not a in used:\n q.append([a, l + 1, dr])\n if not x in used:\n used.add(x)\n ret.append(x)\n m -= 1\n s += l\nprint(s)\nprint(*ret)", "import sys\ninput = sys.stdin.readline\n\nn,m=list(map(int,input().split()))\nX=list(map(int,input().split()))\n\nSET=set(X)\ndis=1\n\nANS=[]\nMSET=set(X)\nPSET=set(X)\nscore=0\nMEM=0\n\nwhile MEM<m:\n\n REMLIST=[]\n for t in MSET:\n if t-dis in SET:\n REMLIST.append(t)\n else:\n ANS.append(t-dis)\n SET.add(t-dis)\n MEM+=1\n score+=dis\n\n if MEM==m:\n break\n\n MSET-=set(REMLIST)\n\n if MEM==m:\n break\n\n \n\n REMLIST=[]\n for t in PSET:\n if t+dis in SET:\n REMLIST.append(t)\n else:\n ANS.append(t+dis)\n SET.add(t+dis)\n MEM+=1\n score+=dis\n\n if MEM==m:\n break\n\n PSET-=set(REMLIST)\n dis+=1\n\nprint(score)\nprint(*ANS)\n\n \n \n \n", "nsap, nhum = map(int, input().split())\nls = list(map(int, input().split()))\nsls = set(ls)\ncandidates = set()\nfor e in ls:\n if e+1 not in sls:\n candidates.add(e+1)\n if e-1 not in sls:\n candidates.add(e-1)\n \nlevel = 1\ntotdist = 0\nres = set()\nwhile len(res) + len(candidates) <= nhum:\n #print(candidates)\n totdist += level * len(candidates)\n level += 1\n for e in candidates:\n res.add(e)\n cand2 = set()\n for e in candidates:\n for dx in (-1,1):\n if e+dx not in res and e+dx not in sls:\n cand2.add(e+dx)\n candidates = cand2\n\nfor i in range(nhum-len(res)):\n res.add(candidates.pop())\n totdist += level\n\nprint(totdist)\nfor e in res:\n print(e, end=' ')\n", "import collections\nimport heapq\nn,m = list(map(int, input().split()))\n\noccupied = set(map(int, input().split()))\n\nq = collections.deque(set([(1, x-1) for x in occupied if x-1 not in occupied] + \\\n [(1, x+1) for x in occupied if x+1 not in occupied]))\nfor _,x in q:\n occupied.add(x)\nans = []\ntot = 0\nwhile len(ans) < m:\n dist, x = q.popleft()\n tot += dist\n ans.append(x)\n if x-1 not in occupied:\n q.append((dist+1, x-1))\n occupied.add(x-1)\n if x+1 not in occupied:\n q.append((dist+1, x+1))\n occupied.add(x+1)\nprint(tot)\nprint(' '.join(map(str, ans)))\n", "from collections import deque\n\nn,m = list(map(int,input().split())) #tree/people\n\nx = list(map(int,input().split()))\n\ndic = {}\nq = deque([])\n\nd = 0\nans = []\n\nfor i in range(n):\n\n dic[x[i]] = 1\n\nfor i in range(n):\n\n if x[i] - 1 not in dic:\n dic[x[i] - 1] = 1\n q.append([ x[i]-1 , 1 ,\"l\"])\n if x[i] + 1 not in dic:\n dic[x[i] + 1] = 1\n q.append([ x[i]+1 , 1 ,\"r\"])\n\nfor i in range(m):\n\n now = q.popleft()\n\n p = now[0]\n d += now[1]\n direc = now[2]\n\n ans.append(p)\n\n if direc == \"l\":\n if p-1 not in dic:\n dic[p-1] = 1\n q.append([ p-1 , now[1] + 1 , direc ])\n else:\n if p+1 not in dic:\n dic[p+1] = 1\n q.append([ p+1 , now[1] + 1 , direc ])\n\nprint (d)\nprint(\" \".join(map(str,ans)))\n\n", "n, p = list(map(int,input().split()))\nl = list(map(int,input().split()))\ntrees_p = set(l)\ntrees_l = set(l)\nzaj = {}\nfor i in l:\n\tzaj[i] = 1\n\t\ndupa = 0\nodp = []\nodl = 0\nimport sys\nwhile True:\n\todl += 1\n\tto_rem = []\n\tfor t in trees_l:\n\t\ttry:\n\t\t\tzaj[t-odl]\n\t\t\tto_rem.append(t)\n\t\texcept Exception:\n\t\t\tzaj[t-odl] = 1\n\t\t\todp.append(t-odl)\n\t\t\tdupa += odl\n\t\t\tif len(odp) == p:\n\t\t\t\tprint(dupa)\n\t\t\t\tprint(*odp)\n\t\t\t\treturn\n\tfor x in to_rem:\n\t\ttrees_l.remove(x)\n\t\n\tto_rem = []\n\tfor t in trees_p:\n\t\ttry:\n\t\t\tzaj[t+odl]\n\t\t\tto_rem.append(t)\n\t\texcept Exception:\n\t\t\tzaj[t+odl] = 1\n\t\t\todp.append(t+odl)\n\t\t\tdupa += odl\n\t\t\tif len(odp) == p:\n\t\t\t\tprint(dupa)\n\t\t\t\tprint(*odp)\n\t\t\t\treturn\n\tfor x in to_rem:\n\t\ttrees_p.remove(x)\n\t\t\t\n\t\n\n", "import sys\nimport collections\nfrom collections import Counter, deque\nimport itertools\nimport math\nimport timeit\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\n\ndef divs(n, start=1):\n divisors = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if n % i == 0:\n if n / i == i:\n divisors.append(i)\n else:\n divisors.extend([i, n // i])\n return divisors\n\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\n\ndef flin(d, x, default=-1):\n left = right = -1\n for i in range(len(d)):\n if d[i] == x:\n if left == -1: left = i\n right = i\n if left == -1:\n return (default, default)\n else:\n return (left, right)\n\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return list(map(int, input().split()))\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\n\n# input = sys.stdin.readline\n\nt = 1\nfor _ in range(t):\n n, k = mi()\n d = li()\n used = set(d)\n left = d[:]\n right = d[:]\n res = []\n s = 0\n c = 1\n while len(res) < k:\n nl = []\n nr = []\n j = 0\n while len(res) < k and j < len(left):\n if left[j] - 1 not in used:\n s += c\n res.append(left[j] - 1)\n used.add(left[j] - 1)\n nl.append(left[j] - 1)\n j += 1\n j = 0\n while len(res) < k and j < len(right):\n if right[j] + 1 not in used:\n s += c\n res.append(right[j] + 1)\n used.add(right[j] + 1)\n nr.append(right[j] + 1)\n j += 1\n left = nl\n right = nr\n c += 1\n\n print(s)\n prr(res)\n", "from collections import deque\n\nn, m = list(map(int,input().split()))\nqueue = deque([])\nvst = set()\nfor k in map(int,input().split()):\n vst.add(k)\n queue.append((k,0))\n\nans = 0\nans_L = []\ncnt = 0\n\nwhile queue:\n x, step = queue.popleft()\n for dx in [1, -1]:\n X = x + dx\n if X not in vst:\n cnt += 1\n vst.add(X)\n ans += step + 1\n ans_L.append(X)\n queue.append((X, step + 1))\n if cnt == m:\n break\n if cnt == m:\n break\n\nprint(ans)\nprint(*ans_L)\n\n\n\n\n", "n,m=map(int,input().split())\na=list(map(int,input().split()))\nd={}\na.sort()\n\nlow=1\nhigh=m\n\nfor i in a:\n d[i]=2\n\nfrom collections import deque\n\ndef check(mid,a):\n s=0\n for i in range(n-1):\n s+=min(2*mid,a[i+1]-a[i]-1)\n if s+ 2*mid>=m:\n return True\n else:\n return False\n \n \n\nwhile low<high:\n mid=(low+high)//2\n if check(mid,a):\n high=mid\n else:\n low=mid+1\n\nst=deque(a)\n# print(st)\nk=0\nans=[]\npr=0\nwhile m>0:\n if st[0]==a[0]:\n k+=1\n \n if st[0]-k in d and st[0]+k in d:\n st.popleft()\n continue\n # print(ans)\n if st[0]-k not in d:\n d[st[0]-k]=1\n m-=1\n pr+=k\n ans.append(st[0]-k)\n # print(ans) \n if st[0]+k not in d and m>0:\n d[st[0]+k]=1\n m-=1\n pr+=k\n ans.append(st[0]+k)\n # print(ans) \n st.append(st.popleft())\n \nprint(pr) \nprint(*ans) ", "n, m = list(map(int, input().split()))\ntrees = set(list(map(int, input().split())))\nvis = set(trees)\nres = []\ndist = 0\nfor d in range(1, m+1):\n done = False\n removal = set()\n for t in trees:\n if t-d in vis and t+d in vis:\n removal.add(t)\n if not t-d in vis:\n vis.add(t-d)\n res.append(t-d)\n dist += d\n if len(res) == m:\n done = True\n break\n if not t+d in vis:\n vis.add(t+d)\n res.append(t+d)\n dist += d\n if len(res) == m:\n done = True\n break\n if done:\n break\n for t in removal:\n trees.remove(t)\nprint(dist)\nprint(' '.join(map(str, sorted(res))))\n \n \n", "import sys\nfrom operator import itemgetter\n\ndef input():\n return sys.stdin.readline().strip()\n\nn,m = list(map(int, input().split()))\n\ntrees = set(map(int, input().split()))\nocc = set(trees)\nnewadd = set()\nfor x in trees:\n if x+1 not in occ:\n newadd.add((x+1,1))\n if x-1 not in occ: \n newadd.add((x-1,1))\n\nanspos = []\nans = 0\nwhile m > 0:\n newnewadd = set()\n while m>0 and len(newadd) > 0:\n x,diff = newadd.pop()\n if x in occ:\n continue\n occ.add(x)\n anspos.append(x)\n ans+=diff\n if x+1 not in occ:\n newnewadd.add((x+1,diff+1))\n if x-1 not in occ:\n newnewadd.add((x-1,diff+1))\n m-=1\n newadd = newnewadd\nprint(ans)\nprint(*anspos)", "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn list(map(int, minp().split()))\n\ndef solve():\n\tn, m = mints()\n\tq = list(mints())\n\tw = dict()\n\tfor i in q:\n\t\tw[i] = 0\n\tql = 0\n\tc = 0\n\tss = 0\n\ty = []\n\twhile ql < len(q):\n\t\tp = q[ql]\n\t\tql += 1\n\t\tx = p - 1\n\t\tif x not in w:\n\t\t\td = w[p] + 1\n\t\t\ty.append(x)\n\t\t\tq.append(x)\n\t\t\tss += d\n\t\t\tw[x] = d\n\t\t\tc += 1\n\t\t\tif c == m:\n\t\t\t\tbreak\n\t\tx = p + 1\n\t\tif x not in w:\n\t\t\td = w[p] + 1\n\t\t\tq.append(x)\n\t\t\ty.append(x)\n\t\t\tss += d\n\t\t\tw[x] = d\n\t\t\tc += 1\n\t\t\tif c == m:\n\t\t\t\tbreak\n\tprint(ss)\n\tprint(' '.join(map(str, y)))\n\n#for i in range(mint()):\nsolve()\n", "import heapq,bisect\n\ndef main():\n n,m = map(int,input().split())\n trees = list(map(int,input().split()))\n trees.sort()\n\n ans = []\n distance = 0\n heap = []\n visited = set()\n for i in trees:\n visited.add(i)\n\n for i in trees:\n if i+1 not in visited:\n heapq.heappush(heap,(1,i+1))\n if i-1 not in visited:\n heapq.heappush(heap,(1,i-1))\n\n while heap:\n curr = heapq.heappop(heap)\n if curr[1] not in visited:\n distance += curr[0]\n ans.append(curr[1])\n visited.add(curr[1])\n if len(ans) == m:\n break\n\n if curr[1]+1 not in visited:\n index = bisect.bisect(trees,curr[1]+1)\n min_dist = float('inf')\n if index < len(trees):\n min_dist = min(min_dist,trees[index]-curr[1]-1)\n if index-1 >= 0:\n min_dist = min(min_dist,curr[1]+1-trees[index-1])\n\n heapq.heappush(heap,(min_dist,curr[1]+1))\n\n if curr[1]-1 not in visited:\n index = bisect.bisect(trees,curr[1]-1)\n min_dist = float('inf')\n if index < len(trees):\n min_dist = min(min_dist,trees[index]-curr[1]+1)\n if index-1 >= 0:\n min_dist = min(min_dist,curr[1]-1-trees[index-1])\n\n heapq.heappush(heap,(min_dist,curr[1]-1))\n \n\n\n print(distance)\n for i in ans:\n print(i,end = ' ')\n\n\nmain()\n", "a = input('').split(' ')\nn =int(a[0])\nm = int(a[1])\nx = list(map(int,input('').split(' ')))\nd = {}\nfor xx in x:\n d[xx] = True\n\ni = 0\nc = 0\npos = [[]]\npos.append([])\ncur = 0\npos[cur] = x.copy()\nys = []\nans = 0\nwhile(i<m):\n c+=1\n pos[cur^1] = []\n for k in pos[cur]:\n if(k+1 not in d):\n pos[cur^1].append(k+1)\n d[k+1] = True\n if(k-1 not in d):\n pos[cur^1].append(k-1)\n d[k-1] = True\n res = False\n cur = cur^1\n for p in pos[cur]:\n i+=1\n ys.append(p)\n ans += c\n if(i == m):\n res = True\n break\n if(res):\n break\n\nprint(ans)\nfor h in ys:\n print(h,end = ' ')\n "] | {"inputs": ["2 6\n1 5\n", "3 5\n0 3 1\n"], "outputs": ["8\n2 3 -1 0 6 4 \n", "7\n5 2 4 -1 -2 \n"]} | INTRODUCTORY | PYTHON3 | CODEFORCES | 13,279 | |
0ad4caae383a0f8401c643eec194e621 | UNKNOWN | You are given a positive integer $n$. In one move, you can increase $n$ by one (i.e. make $n := n + 1$). Your task is to find the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$.
You have to answer $t$ independent test cases.
-----Input-----
The first line of the input contains one integer $t$ ($1 \le t \le 2 \cdot 10^4$) β the number of test cases. Then $t$ test cases follow.
The only line of the test case contains two integers $n$ and $s$ ($1 \le n \le 10^{18}$; $1 \le s \le 162$).
-----Output-----
For each test case, print the answer: the minimum number of moves you need to perform in order to make the sum of digits of $n$ be less than or equal to $s$.
-----Example-----
Input
5
2 1
1 1
500 4
217871987498122 10
100000000000000001 1
Output
8
0
500
2128012501878
899999999999999999 | ["import sys\n\n\ndef read_int():\n return int(sys.stdin.readline())\n\n\ndef read_ints():\n return list(map(int, sys.stdin.readline().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n n, s = read_ints()\n a = [0] + [int(i) for i in str(n)]\n ds = sum(a)\n cost = 0\n idx = len(a) - 1\n radix = 1\n while ds > s:\n if a[idx] > 0:\n cost += (10 - a[idx]) * radix\n ds -= a[idx]\n a[idx] = 0\n ds += 1\n a[idx - 1] += 1\n i = idx - 1\n while a[i] >= 10:\n a[i - 1] += 1\n a[i] -= 10\n ds -= 9\n i -= 1\n radix *= 10\n idx -= 1\n print(cost)\n", "tx=int(input())\nfor i in range(tx):\n a,b=[int(i) for i in input().split()]\n k=a\n t=1\n t2=0\n s=str(a)\n for i in s:\n t2+=ord(i)-ord('0')\n while t<=pow(10,18):\n if t>1:a+=t-(a % t)\n t2=0\n s=str(a)\n for i in s:\n t2+=ord(i)-ord('0')\n if t2<=b:\n print(a-k)\n break\n t*=10", "# d-decrease-the-sum-of-digits.yml\n\ndef dsum(x):\n res = 0\n while x:\n res += x % 10\n x //= 10\n return res\n\nfor _ in range(int(input())):\n n, s = list(map(int, input().split()))\n # print(f'init: n={n}, s={s}')\n\n p = 1\n ans = 0\n csum = dsum(n)\n # its=10\n while csum > s:\n # print(f'n={n}')\n add = 10 * p - n % (10 * p)\n if add == 10 * p: add = 0\n ans += add\n n += add\n csum = dsum(n)\n p *= 10\n # print(f'n={n},p={p},csum={csum},add={add}')\n\n # its-=1\n # assert its\n\n print(ans)\n", "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop,heapify\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n\nfrom itertools import accumulate\nfrom functools import lru_cache\n\nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\ndef givesum(n):return sum([int(i) for i in str(n)])\n\nfor _ in range(val()):\n n, s = li()\n ans = 0\n curr = 10\n while givesum(n) > s:\n temp = n % curr\n n += curr - temp\n ans += curr - temp\n curr *= 10\n print(ans)\n", "for _ in range(int(input())):\n s,k=list(map(str,input().split()))\n k=int(k)\n su=0\n for i in range(len(s)):\n su+=int(s[i])\n if su>=k:\n ans=int(s[i:]) \n ans=int(\"1\"+(len(s)-i)*\"0\")-ans\n # print(ans)\n break\n su=0 \n for i in range(len(s)):\n su+=int(s[i])\n if su<=k:\n print(0)\n else:\n print(ans)\n", "# Fast IO (be careful about bytestring)\n\n# import os,io\n# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\nfor _ in range(int(input())):\n n,s = list(map(int,input().split()))\n lenN = len(str(n))\n sumDigit = 0\n nCpy = n\n for j in range(lenN):\n sumDigit += nCpy % 10\n nCpy //= 10\n if sumDigit <= s:\n print(0)\n else:\n for j in range(lenN):\n newN = (n // (10 ** (j+1)) + 1) * 10 ** (j + 1)\n nCpy = newN\n sumDigit = 0\n for j in range(lenN):\n sumDigit += nCpy % 10\n nCpy //= 10\n if sumDigit <= s:\n print(newN - n)\n break\n", "def main():\n t = int(input())\n for _ in range(t):\n n, s = input().split(\" \")\n s = int(s)\n total = 0\n for nn in n:\n total += int(nn)\n ans = 0\n p = 1\n ten = 1\n carry = False\n while total > s:\n num = int(n[-p])\n if carry:\n num += 1\n if num == 0:\n carry = False\n else:\n ans += ten * (10 - num)\n total -= num - 1\n carry = True\n ten *= 10\n p += 1\n print(ans)\n \n \nmain()", "for _ in range(int(input())):\n a,b=map(int,input().split())\n bb=b\n can=0\n d=10000000000000000000\n while(d>0):\n bb=bb-(a//d)%10\n d=d//10\n if(bb>=0):\n can=1\n d=10000000000000000000\n t=0\n while(d>0 and b-(a//d)%10>=1):\n b=b-(a//d)%10\n t=(a//d+1)*d\n d=d//10\n if(can):print(0)\n else:print(t-a)\n t=0", "import sys\n\ninput = sys.stdin.readline\n\n\n############ ---- Input Functions ---- ############\ndef inp():\n return (int(input()))\n\n\ndef inlt():\n return (list(map(int, input().split())))\n\n\ndef insr():\n s = input()\n return (list(s[:len(s) - 1]))\n\n\ndef invr():\n return (list(map(int, input().split())))\n\ndef digitSum(x):\n c = 0\n while x:\n c += x%10\n x //= 10\n return c\n\ndef solve(x,y):\n if digitSum(x) <= y:\n return 0\n # Try next power of 10\n xStr = str(x)\n attempt = 10 ** len(xStr) - x\n\n for i in range(len(xStr)):\n newNumber = int(xStr[:i+1]) + 1\n newNumber *= 10 ** (len(xStr) - i-1)\n if digitSum(newNumber) <= y:\n attempt = newNumber - x\n return attempt\n\nlines = inp()\nfor i in range(lines):\n v = inlt()\n print(solve(*v))\n", "for _ in range(int(input())):\n n,s=map(int,input().split())\n savn=n\n cd=1\n while cd<=n:\n if sum(map(int,str(n)))<=s:break\n cc=n//cd%10\n if cc==0:cd*=10;continue\n n+=(10-cc)*cd\n cd*=10\n print(n-savn)", "z = int(input())\n\ndef sm(x):\n ans = 0\n while x>0:\n ans += x%10\n x //= 10\n return ans\n\nfor _ in range(z):\n n, s = list(map(int, input().split()))\n ans = 10000000000000000000000000000\n if sm(n) <= s:\n print(0)\n continue\n goal = n\n for i in range(len(str(n))+1):\n goal = int(str(n)[:len(str(n))-i] + '0'*i) + 10**i\n if sm(goal) <= s:\n ans = min(ans, goal-n)\n print(ans)\n", "def ssum(s):\n return sum(map(int, list(s)))\nfor _ in range(int(input())):\n n, s = list(map(int, input().split()))\n ns = str(n)\n if ssum(ns) <= s:\n print(0)\n continue\n\n ans = float(\"inf\")\n for i in range(0, len(ns)):\n x = 1\n if i > 0:\n x = int(ns[:i])+1\n acc = 0\n while x > 0:\n acc += x % 10\n x //= 10\n if acc > s:\n continue\n y = 10**(len(ns)-i) - int(ns[i:])\n ans = min(ans, y)\n print(ans)\n", "import sys\nfrom math import ceil\ninput = sys.stdin.readline\nt = int(input())\ndef f(n):\n r = 0\n while n:\n r += n%10\n n //= 10\n return r\nfor tc in range(t):\n n, s = list(map(int, input().strip().split()))\n if f(n) <= s:\n print(0)\n continue\n b = 1\n ans = int(1e20)\n while b <= n*10:\n rn = n//b*b+b\n # print(rn, f(rn))\n if f(rn) <= s: ans = min(ans, rn-n)\n b *= 10\n print(ans)\n", "import sys, math\nimport io, os\n#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\nfrom bisect import bisect_left as bl, bisect_right as br, insort\nfrom heapq import heapify, heappush, heappop\nfrom collections import defaultdict as dd, deque, Counter\n# from itertools import permutations,combinations\ndef data(): return sys.stdin.readline().strip()\ndef mdata(): return list(map(int, data().split()))\ndef outl(var): sys.stdout.write(' '.join(map(str, var)) + '\\n')\ndef out(var): sys.stdout.write(str(var) + '\\n')\nfrom decimal import Decimal\n# from fractions import Fraction\n# sys.setrecursionlimit(100000)\nmod = int(1e9) + 7\nINF=2**32\n\ndef cal(n):\n ans=0\n while n:\n ans+=n%10\n n//=10\n return ans\n\nfor t in range(int(data())):\n n,s=mdata()\n ans=0\n t=1\n while cal(n)>s:\n last=n%10\n n//=10\n if last!=0:\n ans+=t*(10-last)\n n+=1\n t*=10\n out(ans)", "'''\nAuthor: AsilenceBTF\nBlog: asilencebtf.top\nDate: 2020-05-28 13:02:12\nLastEditTime: 2020-09-04 23:11:19\n'''\n\ndef f(n):\n res = 0\n while n > 0 : \n res = res + 1\n n = n // 10\n return res\ndef check(n):\n res = 0\n while n > 0:\n res = res + (n%10)\n n = n // 10\n return res\nfor _ in range(int(input())):\n n, s = list(map(int, input().split()))\n len = f(n)\n ans = pow(10, 20)\n if check(n) <= s:\n ans = 0 \n for i in range(0, len):\n p = n // pow(10, i + 1)\n p = p * pow(10, i + 1)\n p = p + pow(10, i + 1)\n if check(p) <= s:\n if ans > (p - n):\n ans = p - n \n print(ans)\n \n\n", "import bisect\nimport copy\nimport fractions\nimport functools\nimport heapq\nimport math\nimport random\nimport sys\n\n\ndef __starting_point():\n\n T = int(input())\n\n for t in range(T):\n N, S = tuple(map(int, input().split()))\n\n if sum(int(dig) for dig in str(N)) <= S:\n print('0')\n continue\n\n # So we start counting digits from left to right\n # The first digits where the sum is greater than or equal to S and every digit following\n # needs to be set to 0, and the last digit we safely counted gets incremented\n # Our answer is the difference between this number and N\n\n str_N = '0' + str(N)\n\n total = 0\n i = 0\n while total < S:\n total += int(str_N[i])\n i += 1\n\n target = (int(str_N[:i-1]) + 1) * (10 ** (len(str_N) - i + 1))\n print(str(target - N))\n\n__starting_point()", "for t in range(int(input())):\n # n,s = map(int,input().split())\n n,s = input().split()\n s = int(s)\n\n nn =['0','0','0'] + list(n)\n\n su = 0\n for i in n:\n su += int(i)\n\n ptr = 1\n # cost = 0\n while su>s:\n su-=int(nn[-ptr])\n su+=1\n nn[-ptr]='0'\n nn[-ptr-1]=str(1+int(nn[-ptr-1]))\n\n itr = 1\n while int(nn[-ptr-itr]) >=10:\n su-=10\n su+=int(nn[-ptr-itr])//10\n nn[-ptr-itr-1]=str(int(nn[-ptr-itr-1])+int(nn[-ptr-itr])//10)\n nn[-ptr-itr]=str(int(nn[-ptr-1])%10)\n itr+=1\n # if int(nn[-ptr-1])>=10:\n \n \n \n \n ptr+=1\n\n print(int(''.join(nn))-int(n))\n\n # nn = n\n # ctr = 0\n # cost = []\n # su = 0\n # while nn:\n # su += nn%10\n # cost.append((10-nn%10)*10**ctr)\n # nn//=10\n # ctr+=1\n\n # ptr = 1\n # while su>s:\n # su-=n%10**ptr\n # su+=1\n # n\n", "def solve(n, s):\n dns = [ord(x)-ord('0') for x in str(n)]\n if sum(dns) <= s:\n return 0\n m = len(dns)\n for i, d in enumerate(dns):\n if d >= s:\n return 10**(m-i) - (n % (10**(m-i)))\n s -= d\n return 42\n\n\nfor _ in range(int(input())):\n n, s = [int(x) for x in input().split()]\n print(solve(n, s))\n", "import sys\nimport math\ndef II():\n\treturn int(sys.stdin.readline())\n\ndef LI():\n\treturn list(map(int, sys.stdin.readline().split()))\n\ndef MI():\n\treturn list(map(int, sys.stdin.readline().split()))\n\ndef SI():\n\treturn sys.stdin.readline().strip()\ndef findSum(n,s):\n\tsu = 0\n\tind = -1\n\tfor i in range(len(n)):\n\t\tsu+=int(n[i])\n\t\tif su>s:\n\t\t\tind = i\n\t\t\tbreak\n\treturn ind\nt = II()\nfor q in range(t):\n\tn,s = MI()\n\tn = str(n)\n\tans = 0\n\tind = findSum(n,s)\n\twhile ind!=-1:\n\t\tf = n[:ind]\n\t\tif f == \"\":\n\t\t\tf = \"0\"\n\t\tse = \"0\"+\"0\"*(len(n)-ind-1)\n\t\tf = str(int(f)+1)+se\n\t\tans+=int(f)-int(n)\n\t\tn = f\n\t\tind = findSum(n,s)\n\tprint(ans)\n\n\t\n", "import math\n\ndef checksum(n):\n return sum([int(x) for x in str(n)])\n\nfor _ in range(int(input())):\n n,s = [int(p) for p in input().split()]\n moves = 0\n if checksum(n)<=s:\n print(0)\n else:\n pow = 10\n while True:\n # print(n)\n closest = pow*((n+pow-1)//pow)\n # print(closest)\n moves += (closest-n)\n n = closest\n if checksum(n)<=s:\n break\n pow*=10\n print(moves)", "for tc in range(int(input())):\n \n n, s = [int(x) for x in input().split()]\n \n sumOf = sum(int(x) for x in str(n))\n \n cost = 0\n \n carry = False\n \n for pos, char in enumerate(reversed('0' + str(n))):\n if sumOf <= s: break\n \n digit = int(char)\n \n if carry: digit += 1\n \n if digit != 0: \n carry = True\n \n cost += (10 - digit) * (10 ** pos)\n \n sumOf -= digit - 1\n \n \n print(cost) ", "from math import ceil\nfrom collections import deque\n\ndef sm(n):\n\tret = 0\n\twhile n>0:\n\t\tret += n%10\n\t\tn //= 10\n\treturn ret\n\nfor _ in range(int(input())):\n\tn, s = [int(i) for i in input().split()]\n\ttemp = n\n\twhile sm(n)>s:\n\t\tj = 10\n\t\twhile n%j == 0:\n\t\t\tj *= 10\n\t\tn += j-n%j\n\tprint(n - temp)", "\nt = int(input())\ndef dgt_sum(num):\n return sum([int(x) for x in str(num)])\n\ndef clps(val, left=0):\n if len(str(val)) == 1:\n return 1, left + 1\n\n\n return int(str(val)[:-1]) + 1, left + 1\n\n\ndef solve(n, s):\n n_str =str(n)\n _s = 0\n target = n\n for i, d in enumerate(n_str):\n d = int(d)\n _s+=d\n if _s > s:\n cl = int(n_str[:i+1]), 0\n while dgt_sum(cl[0]) > s:\n cl = clps(*cl)\n\n target = cl[0] * pow(10, cl[1] + len(n_str) -i-1)\n break\n\n return target - n\n\n\n\nfor _ in range(t):\n n,s = [int(x) for x in input().split(' ')]\n print(solve(n,s))", "#!/usr/bin/env pypy3\n\ndef ans(n, s):\n\tn = str(n)\n\n\tif sum(map(int, n)) <= s:\n\t\treturn 0\n\n\tcandidates = set()\n\tfor i in range(1,len(n)):\n\t\tna, nb = n[:i], n[i:]\n\t\tna = str(int(na)+1)\n\t\tnb = \"0\"*len(nb)\n\t\tif sum(map(int, na)) + sum(map(int, nb)) <= s:\n\t\t\tcandidates.add(int(na+nb) - int(n))\n\n\tbig = \"1\" + \"0\"*len(n)\n\tcandidates.add(int(big) - int(n))\n\n\tsmall = \"1\" + \"0\"*(len(n)-1)\n\tif int(small) - int(n) >= 0:\n\t\tcandidates.add(int(small) - int(n))\n\n\treturn min(candidates)\n\ndef ans_slow(n, s):\n\tfor i in range(0, 10**200):\n\t\tbig = n+i\n\t\tbig = str(big)\n\t\tif sum(map(int, big)) <= s:\n\t\t\treturn i\n\nimport sys\n\n# print(ans(2,2))\n# print(ans_slow(2,2))\n\n# return\n\n# for s in range(1, 162):\n# \tfor n in range(1, 10000):\n# \t\tif ans(n,s) != ans_slow(n, s):\n# \t\t\tprint(n, s)\n\n# return\n\nT = int(input())\nfor t in range(T):\n\tn,s = input().split()\n\tn = int(n)\n\ts = int(s)\n\n\tprint(ans(n, s))"] | {
"inputs": [
"5\n2 1\n1 1\n500 4\n217871987498122 10\n100000000000000001 1\n",
"1\n1000000000000000000 1\n"
],
"outputs": [
"8\n0\n500\n2128012501878\n899999999999999999\n",
"0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 15,420 | |
d1e3099d0e229b8d899035f809865791 | UNKNOWN | There is a bookshelf which can fit $n$ books. The $i$-th position of bookshelf is $a_i = 1$ if there is a book on this position and $a_i = 0$ otherwise. It is guaranteed that there is at least one book on the bookshelf.
In one move, you can choose some contiguous segment $[l; r]$ consisting of books (i.e. for each $i$ from $l$ to $r$ the condition $a_i = 1$ holds) and: Shift it to the right by $1$: move the book at index $i$ to $i + 1$ for all $l \le i \le r$. This move can be done only if $r+1 \le n$ and there is no book at the position $r+1$. Shift it to the left by $1$: move the book at index $i$ to $i-1$ for all $l \le i \le r$. This move can be done only if $l-1 \ge 1$ and there is no book at the position $l-1$.
Your task is to find the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without any gaps).
For example, for $a = [0, 0, 1, 0, 1]$ there is a gap between books ($a_4 = 0$ when $a_3 = 1$ and $a_5 = 1$), for $a = [1, 1, 0]$ there are no gaps between books and for $a = [0, 0,0]$ there are also no gaps between books.
You have to answer $t$ independent test cases.
-----Input-----
The first line of the input contains one integer $t$ ($1 \le t \le 200$) β the number of test cases. Then $t$ test cases follow.
The first line of the test case contains one integer $n$ ($1 \le n \le 50$) β the number of places on a bookshelf. The second line of the test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 1$), where $a_i$ is $1$ if there is a book at this position and $0$ otherwise. It is guaranteed that there is at least one book on the bookshelf.
-----Output-----
For each test case, print one integer: the minimum number of moves required to collect all the books on the shelf as a contiguous (consecutive) segment (i.e. the segment without gaps).
-----Example-----
Input
5
7
0 0 1 0 1 0 1
3
1 0 0
5
1 1 0 0 1
6
1 0 0 0 0 1
5
1 1 0 1 1
Output
2
0
2
4
1
-----Note-----
In the first test case of the example, you can shift the segment $[3; 3]$ to the right and the segment $[4; 5]$ to the right. After all moves, the books form the contiguous segment $[5; 7]$. So the answer is $2$.
In the second test case of the example, you have nothing to do, all the books on the bookshelf form the contiguous segment already.
In the third test case of the example, you can shift the segment $[5; 5]$ to the left and then the segment $[4; 4]$ to the left again. After all moves, the books form the contiguous segment $[1; 3]$. So the answer is $2$.
In the fourth test case of the example, you can shift the segment $[1; 1]$ to the right, the segment $[2; 2]$ to the right, the segment $[6; 6]$ to the left and then the segment $[5; 5]$ to the left. After all moves, the books form the contiguous segment $[3; 4]$. So the answer is $4$.
In the fifth test case of the example, you can shift the segment $[1; 2]$ to the right. After all moves, the books form the contiguous segment $[2; 5]$. So the answer is $1$. | ["for _ in range(int(input())):\n\tn=int(input())\n\ts=list(map(int,input().split()))\n\tl=s.index(1)\n\tr=n-s[::-1].index(1)\n\tans=0\n\tfor i in range(l,r):\n\t\tans+=1-s[i]\n\tprint(ans)", "def solve():\n n = int(input())\n lst = list(map(int,input().split()))\n while len(lst) > 0 and lst[-1] == 0:\n lst.pop()\n od = False\n ans = 0\n for i in lst:\n if i == 0 and od:\n ans += 1\n if i == 1:\n od = True\n print(ans)\nfor i in range(int(input())):\n solve()", "import sys\ninput = sys.stdin.readline\n\ndef main():\n n = int(input())\n alst = list(map(int, input().split()))\n flg = False\n ans = 0\n for i, a in enumerate(alst):\n if a == 1:\n if not flg:\n flg = True\n else:\n ans += i - bef - 1\n bef = i\n \n print(ans)\nfor _ in range(int(input())):\n main()", "# ========== //\\\\ //|| ||====//||\n# || // \\\\ || || // ||\n# || //====\\\\ || || // ||\n# || // \\\\ || || // ||\n# ========== // \\\\ ======== ||//====|| \n# code\n\n\ndef solve():\n n = int(input())\n a = list(map(int, input().split()))\n\n last = -1\n ans = 0\n for i, v in enumerate(a):\n if v == 1:\n if last > -1:\n ans += i - last - 1\n last = i\n print(ans)\n\ndef main():\n t = 1\n t = int(input())\n for _ in range(t):\n solve()\n\ndef __starting_point():\n main()\n__starting_point()", "for t in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n z = a.count(0)\n j = 0\n while j < n and a[j] != 1:\n j += 1\n z -= 1\n j = n - 1\n while j >= 0 and a[j] != 1:\n j -= 1\n z -= 1 \n print(z)", "t = int(input())\n#\nfor _ in range(t):\n n = int(input())\n arr = [int(val) for val in input().split(' ')]\n arr_idx = [idx for idx, val in enumerate(arr) if val]\n c = 0\n for i in range(len(arr_idx)-1):\n c += arr_idx[i+1] - arr_idx[i] - 1\n print(c)\n", "from math import *\nfrom bisect import *\nfrom collections import *\nfrom random import *\nfrom decimal import *\nfrom itertools import *\nimport sys\ninput=sys.stdin.readline\ndef inp():\n return int(input())\ndef st():\n return input().rstrip('\\n')\ndef lis():\n return list(map(int,input().split()))\ndef ma():\n return list(map(int,input().split()))\nt=inp()\nwhile(t):\n t-=1\n n=inp()\n a=lis()\n while(len(a) and a[-1]==0):\n a.pop()\n a=a[::-1]\n while(len(a) and a[-1]==0):\n a.pop()\n print(a.count(0))\n", "\n\nfor _ in range(int(input())):\n\tn=int(input())\n\ta=list(map(int,input().split()))\n\n\ti=0\n\twhile a[i]==0:\n\t\ti+=1\n\n\tj=n-1\n\twhile a[j]==0:\n\t\tj-=1\n\n\tprint(a[i:j+1].count(0))\n", "for __ in range(int(input())):\n n = int(input())\n ar = list(map(int, input().split()))\n ans = ar.count(0)\n i = 0\n while ar[i] == 0:\n ans -= 1\n i += 1\n j = n - 1\n while ar[j] == 0 and i != j:\n ans -= 1\n j -= 1\n print(max(0, ans))", "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\nimport string\n\n\nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return list(map(int, input().split()))\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=2):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n new_number = 0\n while number > 0:\n new_number += number % base\n number //= base\n return new_number\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s):\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n\n\nfor _ in range(ii()):\n n = ii()\n a = li()\n s = ''.join(map(str, a))\n s = s.strip('0')\n print(s.count('0'))\n", "for k in range(int(input())):\n n = int(input())\n vec = list(map(int, input().split()))\n while vec[0] == 0:\n vec = vec[1::]\n while vec[-1] == 0:\n vec = vec[:-1:]\n print(vec.count(0))", "t=int(input())\nfor _ in range(t):\n n=int(input())\n a=list(map(int,input().split()))\n left=-1\n right=-1\n for i in range(n):\n if a[i]==1:\n left=i\n break\n if left==-1:\n print(0)\n continue\n for i in range(n-1,-1,-1):\n if a[i]==1:\n right=i\n break\n count1=0\n for i in range(n):\n if a[i]==1:\n count1+=1\n print(right-left-count1+1)", "import math\nimport string\nimport random\nfrom random import randrange\nfrom collections import deque\nfrom collections import defaultdict\n\ndef solve(n, arr):\n ans = 0\n\n st = 0\n while st<n and arr[st] == 0:\n st += 1\n \n ed = n-1\n while ed>=0 and arr[ed] == 0:\n ed -= 1\n \n if st == n or ed == -1:\n print(0)\n return\n \n for i in range(st, ed+1):\n if arr[i] == 0:\n ans += 1\n\n print(ans)\n return \n\ndef main():\n t = int(input())\n while t>0:\n t-=1\n \n n = int(input())\n # s = input().strip()\n # x,y = map(int, input().strip().split(\" \"))\n arr = list(map(int, input().strip().split(\" \")))\n \n solve(n, arr)\n \n return\n\ndef test():\n arr_size = 25\n test_cases = 100\n min_range = -100\n max_range = 100\n str_size = 30\n step = 1\n \n for i in range(test_cases):\n k = []\n # s = ''.join(random.choices(string.ascii_lowercase, k = str_size))\n \n for j in range(arr_size):\n num = randrange(min_range, max_range, step)\n k.append(num)\n \n solve(n, arr)\n print(\"<-------- DEBUG ----------->\")\n\n return \n\ndef __starting_point():\n main()\n # test()\n \n\n__starting_point()", "rn=lambda:int(input())\nrl=lambda:list(map(int,input().split()))\nrns=lambda:map(int,input().split())\nrs=lambda:input()\nyn=lambda x:print('Yes') if x else print('No')\nYN=lambda x:print('YES') if x else print('NO')\n\nfor _ in range(rn()):\n n=rn()\n l=rl()\n ans=0\n start=False\n acc=0\n for i in l:\n if i==1:\n start=True\n ans+=acc\n acc=0\n elif start:\n acc+=1\n print(ans)", "for _ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n\n z = 0\n l = -1\n\n c = 0\n\n for i in range(n):\n if a[i] == 0:\n z += 1\n\n else:\n if l != -1:\n c += z\n\n l = i\n\n z = 0\n\n print(c)\n", "def testcase():\n\n n = int(input())\n arr = list(map(int, input().split()))\n i = 0\n while i < n:\n if arr[i] == 1:\n break\n i += 1\n i += 1\n ans = 0\n zs = 0\n while i < n:\n if arr[i] == 0:\n zs += 1\n else:\n ans += zs\n zs = 0\n i += 1\n print(ans)\n return\n\n\nimport sys, os\nif os.path.exists('input.txt'):\n sys.stdin = open('input.txt', 'r')\nt = int(input())\nfor _ in range(t):\n testcase()", "t = int(input())\nfor i10 in range (t):\n n = int(input())\n a = list(map(int, input().split()))\n k = 0\n s = 0\n e = 0\n for i in range(n):\n if a[i] == 1:\n if e == 1:\n s += k\n e = 1\n k = 0\n else:\n k += 1\n print(s)\n \n", "#!/usr/bin/env pypy3\n\ndef ans(books):\n i = None\n j = None\n for k in range(len(books)):\n if books[k] == 0: continue\n j = k\n if i is None:\n i = k\n\n return sum(1-x for x in books[i:j+1])\n\nfor _ in range(int(input())):\n input()\n books = list(map(int, input().split()))\n print(ans(books))", "for _ in range(int(input())):\n am = int(input())\n arr = list(map(int,input().split()))\n fl = False\n l = 0\n r = am\n for i in range(am):\n if arr[i] == 1:\n l = i\n break\n for i in range(am-1,-1,-1):\n if arr[i] == 1:\n r = i\n break\n print(arr[l:r].count(0))", "for _ in range(int(input())):\n n = input()\n s = input().replace(\" \",\"\").lstrip(\"0\").rstrip(\"0\")\n print(s.count(\"0\"))", "import sys,math,itertools\nfrom collections import Counter,deque,defaultdict\nfrom bisect import bisect_left,bisect_right \nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nfor _ in range(inp()):\n n = inp()\n a = inpl()\n st = la = 0\n for i in range(n):\n if a[i]:\n st = i\n break\n for i in range(n)[::-1]:\n if a[i]:\n la = i\n break\n\n ch = False\n res = 0\n for i in range(st,la+1):\n x = a[i]\n if ch:\n if x: continue\n ch = False\n res += 1\n else:\n if x: ch = True\n else:\n res += 1\n print(res)", "t=int(input())\nfor _ in range(t):\n n=int(input())\n l=list(map(int,input().split()))\n i=0\n j=n-1\n while i<n and l[i]==0:\n i+=1\n while j>=0 and l[j]==0:\n j-=1\n ans=0\n while i<=j:\n if l[i]==0:\n ans+=1\n else:\n pass\n i+=1\n print(ans)\n", "t = int(input())\nwhile t:\n t -= 1\n n = input()\n a = [int(i) for i in input().split()]\n fb = -1\n lb = -1\n c = 0\n for i in range(len(a)):\n if a[i] == 1:\n if fb == -1:\n fb = i\n lb = i\n c += 1\n print(lb - fb - c + 1)\n", "for _ in range(int(input())):\n x = int(input())\n r = [int(x) for x in input().split()]\n\n is_s = False\n last_z = 0\n tot = 0\n for i in r:\n if i == 1:\n if not is_s:\n is_s=True\n last_z = 0\n else:\n last_z = 0\n else:\n if is_s:\n last_z+=1\n tot+=1\n print(tot-last_z)", "import sys\n\n\ndef read(func=int):\n return func(sys.stdin.readline().strip())\n\ndef readList(func=int):\n return list(map(func, sys.stdin.readline().strip().split()))\n\n\nt = read()\n\nfor _ in range(t):\n n = read()\n A = readList()\n ri = -1\n for i in range(n - 1, -1, -1):\n if A[i]:\n ri = i\n break\n count = 0\n start = False\n for i in range(n):\n num = A[i]\n if num == 1:\n start = True\n if num == 0 and start and i < ri:\n count += 1\n\n print(count)\n\n"] | {
"inputs": [
"5\n7\n0 0 1 0 1 0 1\n3\n1 0 0\n5\n1 1 0 0 1\n6\n1 0 0 0 0 1\n5\n1 1 0 1 1\n",
"1\n8\n0 0 0 1 1 1 1 1\n"
],
"outputs": [
"2\n0\n2\n4\n1\n",
"0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 12,231 | |
84921be8b6c281cb5b08e140ebf18d21 | UNKNOWN | You are given two integers $n$ and $k$.
Your task is to construct such a string $s$ of length $n$ that for each $i$ from $1$ to $k$ there is at least one $i$-th letter of the Latin alphabet in this string (the first letter is 'a', the second is 'b' and so on) and there are no other letters except these. You have to maximize the minimal frequency of some letter (the frequency of a letter is the number of occurrences of this letter in a string). If there are several possible answers, you can print any.
You have to answer $t$ independent queries.
-----Input-----
The first line of the input contains one integer $t$ ($1 \le t \le 100$) β the number of queries.
The next $t$ lines are contain queries, one per line. The $i$-th line contains two integers $n_i$ and $k_i$ ($1 \le n_i \le 100, 1 \le k_i \le min(n_i, 26)$) β the length of the string in the $i$-th query and the number of characters in the $i$-th query.
-----Output-----
Print $t$ lines. In the $i$-th line print the answer to the $i$-th query: any string $s_i$ satisfying the conditions in the problem statement with constraints from the $i$-th query.
-----Example-----
Input
3
7 3
4 4
6 2
Output
cbcacab
abcd
baabab
-----Note-----
In the first example query the maximum possible minimal frequency is $2$, it can be easily seen that the better answer doesn't exist. Other examples of correct answers: "cbcabba", "ccbbaaa" (any permutation of given answers is also correct).
In the second example query any permutation of first four letters is acceptable (the maximum minimal frequency is $1$).
In the third example query any permutation of the given answer is acceptable (the maximum minimal frequency is $3$). | ["n = int(input())\nfor i in range(n):\n\tl, ch = map(int, input().split())\n\tfor j in range(l):\n\t\tprint(chr(j % ch + ord('a')), end='')\n\tprint()\n", "# import sys\n# sys.stdin = open(\"F:\\\\Scripts\\\\input\",\"r\")\n# sys.stdout = open(\"F:\\\\Scripts\\\\output\",\"w\")\n\n\nMOD = 10**9 + 7\nI = lambda:list(map(int,input().split()))\n\nt, = I()\nwhile t:\n t -= 1\n n, k = I()\n s = ''.join([chr(i) for i in range(97, 97 + k)])\n print(s*(n//k) + s[:n%k])", "t=int(input())\nNK=[list(map(int,input().split())) for i in range(t)]\n\nfor i in range(t):\n n,k=NK[i]\n\n for j in range(n):\n print(chr(97+j%k),end=\"\")\n print()\n \n", "alph = 'abcdefghijklmnopqrstuvwxyz'\nfor i in range(int(input())):\n n, k = list(map(int, input().split()))\n s = alph[:k]\n print(s * (n // k) + alph[:n % k])\n", "from bisect import bisect_right as br\nfrom bisect import bisect_left as bl\nfrom collections import defaultdict\nfrom itertools import combinations\nimport sys\nimport math\nMAX = sys.maxsize\nMAXN = 10**6+10\nMOD = 998244353\ndef isprime(n):\n n = abs(int(n))\n if n < 2:\n return False\n if n == 2: \n return True \n if not n & 1: \n return False\n for x in range(3, int(n**0.5) + 1, 2):\n if n % x == 0:\n return False\n return True\n\ndef mhd(a,b,x,y):\n return abs(a-x)+abs(b-y)\n\ndef numIN():\n return(list(map(int,sys.stdin.readline().strip().split())))\n\ndef charIN():\n return(sys.stdin.readline().strip().split())\n\nt = [(-1,-1)]*1000010\n\ndef create(a):\n\tnonlocal t,n\n\tfor i in range(n,2*n):\n\t\tt[i] = (a[i-n],i-n)\n\tfor i in range(n-1,0,-1):\n\t\tx = [t[2*i],t[2*i+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[i] = x[1]\n\ndef update(idx,value):\n\tnonlocal t,n\n\tidx = idx+n\n\tt[idx] = value\n\n\twhile(idx>1):\n\t\tidx = idx//2\n\t\tx = [t[2*idx],t[2*idx+1]]\n\t\tx.sort(key = lambda x:x[0])\n\t\tt[idx] = x[1]\n\n\ndef dis(a,b,k):\n\tans = 0\n\tfor i in range(k):\n\t\tans+=abs(a[i]-b[i])\n\treturn ans\n\n\ndef cal(n,k):\n\tres = 1\n\tc = [0]*(k+1)\n\tc[0]=1\n\tfor i in range(1,n+1):\n\t for j in range(min(i,k),0,-1):\n\t c[j] = (c[j]+c[j-1])%MOD\n\treturn c[k]\n\nfor _ in range(int(input())):\n\tn,k = numIN()\n\ts = ''\n\tfor i in range(1,k+1):\n\t\ts+=chr(i+96)\n\tfor i in range(k,n):\n\t\ts+=s[i-k]\n\tprint(s)\n\n\n\n\n\n", "from sys import stdin\nn1=int(stdin.readline().strip())\ns=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\nfor i in range(n1):\n n,m=list(map(int,stdin.readline().strip().split()))\n x=0\n s1=\"\"\n for j in range(n):\n s1+=s[x]\n x+=1\n if (j+1)%m==0:\n x=0\n print(s1)\n \n\n", "t = int(input())\n\nfor _ in range(t):\n\ta, b = map(int, input().split())\n\t\n\tstart = ord('a')\n\t\n\tfor i in range(a):\n\t\tprint(chr(start + (i%b)), end = \"\")\n\tprint()", "alpha = \"abcdefghijklmnopqrstuvwxyz\"\nt = int(input())\nfor test in range(t):\n # n = int(input())\n n,k = (list(map(int, input().split())))\n print(alpha[0:k]*(n//k)+alpha[:n%k])\n\n", "t = int(input())\nal = 'abcdefghijklmnopqrstuvwxyz'\nfor i in range(t):\n n, k = list(map(int, input().split()))\n l = n // k\n s = al[:k] * l\n s += al[:n % k]\n print(s)\n", "q = int(input())\n\nfor i in range(q):\n n, k = map(int, input().split())\n t = \"\"\n for j in range(n):\n t += chr((j % k) + ord(\"a\"))\n\n print(t)", "s = \"abcdefghijklmnopqrstuvwxyz\"\nfor i in range(int(input())):\n n, k = [int(x) for x in input().split()]\n\n use = s[:k]\n ln = len(use)\n ans = use * (n // ln) + use[:n % ln]\n print(ans)\n", "from string import ascii_lowercase as let\n\n\ndef main():\n t = int(input())\n for i in range(t):\n n, k = list(map(int, input().split()))\n ll = let[:k]\n s = ll * (n // len(ll))\n s += ll[:n - len(s)]\n print(s)\n\n\nmain()\n", "s=''\nfor i in range(ord('a'),ord('z')+1):\n s+=chr(i)\nfor _ in range(int(input())):\n n,k=list(map(int,input().split()))\n print(s[:k]*(n//k)+s[:n%k])\n \n", "k = int(input())\ns = 'abcdefghijklmnopqrstuvwxyz'\nfor i in range(k):\n\tm , n = list(map(int,input().split()))\n\tif n > m:\n\t\tprint(s[:m])\n\telse:\n\t\tprint(s[:n]*(m//n) + s[:m%n])\n", "t = int(input())\nfor q in range(t):\n answer = []\n n, k = map(int, input().split())\n q1 = 0\n while q1 < n:\n answer.append(chr(ord('a')+q1 % k))\n q1 += 1\n print(*answer, sep='')\n", "t=int(input())\nf=\"abcdefghijklmnopqrstuvwxyz\"\nfor i in range(t):\n n,k=list(map(int,input().split()))\n g=f[:k]\n s=\"\"\n for j in range(n):\n s+=g[j%k]\n print(s)\n"] | {
"inputs": [
"3\n7 3\n4 4\n6 2\n",
"66\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n1 1\n"
],
"outputs": [
"abcabca\nabcd\nababab\n",
"a\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\na\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 4,825 | |
4aea1a7567f01add7f841d93dafe2b10 | UNKNOWN | There are $n$ candies in a row, they are numbered from left to right from $1$ to $n$. The size of the $i$-th candy is $a_i$.
Alice and Bob play an interesting and tasty game: they eat candy. Alice will eat candy from left to right, and Bob β from right to left. The game ends if all the candies are eaten.
The process consists of moves. During a move, the player eats one or more sweets from her/his side (Alice eats from the left, Bob β from the right).
Alice makes the first move. During the first move, she will eat $1$ candy (its size is $a_1$). Then, each successive move the players alternate β that is, Bob makes the second move, then Alice, then again Bob and so on.
On each move, a player counts the total size of candies eaten during the current move. Once this number becomes strictly greater than the total size of candies eaten by the other player on their previous move, the current player stops eating and the move ends. In other words, on a move, a player eats the smallest possible number of candies such that the sum of the sizes of candies eaten on this move is strictly greater than the sum of the sizes of candies that the other player ate on the previous move. If there are not enough candies to make a move this way, then the player eats up all the remaining candies and the game ends.
For example, if $n=11$ and $a=[3,1,4,1,5,9,2,6,5,3,5]$, then: move 1: Alice eats one candy of size $3$ and the sequence of candies becomes $[1,4,1,5,9,2,6,5,3,5]$. move 2: Alice ate $3$ on the previous move, which means Bob must eat $4$ or more. Bob eats one candy of size $5$ and the sequence of candies becomes $[1,4,1,5,9,2,6,5,3]$. move 3: Bob ate $5$ on the previous move, which means Alice must eat $6$ or more. Alice eats three candies with the total size of $1+4+1=6$ and the sequence of candies becomes $[5,9,2,6,5,3]$. move 4: Alice ate $6$ on the previous move, which means Bob must eat $7$ or more. Bob eats two candies with the total size of $3+5=8$ and the sequence of candies becomes $[5,9,2,6]$. move 5: Bob ate $8$ on the previous move, which means Alice must eat $9$ or more. Alice eats two candies with the total size of $5+9=14$ and the sequence of candies becomes $[2,6]$. move 6 (the last): Alice ate $14$ on the previous move, which means Bob must eat $15$ or more. It is impossible, so Bob eats the two remaining candies and the game ends.
Print the number of moves in the game and two numbers: $a$ β the total size of all sweets eaten by Alice during the game; $b$ β the total size of all sweets eaten by Bob during the game.
-----Input-----
The first line contains an integer $t$ ($1 \le t \le 5000$) β the number of test cases in the input. The following are descriptions of the $t$ test cases.
Each test case consists of two lines. The first line contains an integer $n$ ($1 \le n \le 1000$) β the number of candies. The second line contains a sequence of integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 1000$) β the sizes of candies in the order they are arranged from left to right.
It is guaranteed that the sum of the values of $n$ for all sets of input data in a test does not exceed $2\cdot10^5$.
-----Output-----
For each set of input data print three integers β the number of moves in the game and the required values $a$ and $b$.
-----Example-----
Input
7
11
3 1 4 1 5 9 2 6 5 3 5
1
1000
3
1 1 1
13
1 2 3 4 5 6 7 8 9 10 11 12 13
2
2 1
6
1 1 1 1 1 1
7
1 1 1 1 1 1 1
Output
6 23 21
1 1000 0
2 1 2
6 45 46
2 2 1
3 4 2
4 4 3 | ["from fractions import Fraction\nimport bisect\nimport os\nfrom collections import Counter\nimport bisect\nfrom collections import defaultdict\nimport math\nimport random\nimport heapq as hq\nfrom math import sqrt\nimport sys\nfrom functools import reduce, cmp_to_key\nfrom collections import deque\nimport threading\nfrom itertools import combinations\nfrom io import BytesIO, IOBase\nfrom itertools import accumulate\n\n\n# sys.setrecursionlimit(200000)\n# input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef iinput():\n return int(input())\n\n\ndef tinput():\n return input().split()\n\n\ndef rinput():\n return list(map(int, tinput()))\n\n\ndef rlinput():\n return list(rinput())\n\n\n# mod = int(1e9)+7\n\n\ndef factors(n):\n return set(reduce(list.__add__,\n ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\n\n# ----------------------------------------------------\n# sys.stdin = open('input.txt', 'r')\n# sys.stdout = open('output.txt', 'w')\nfor _ in range(iinput()):\n n = iinput()\n a = rlinput()\n moves = 0\n i = 0\n j = n-1\n prev = 0\n ans1 = 0\n ans2 = 0\n while i <= j:\n temp = 0\n f = False\n while i<=j and i < n and temp <= prev:\n temp += a[i]\n f = True\n i += 1\n ans1 += temp\n if f:\n moves += 1\n prev = temp\n temp = 0\n f = False\n while j >= i and j > 0 and temp <= prev:\n temp += a[j]\n f = True\n j -= 1\n ans2 += temp\n if f:\n moves += 1\n prev = temp\n print(moves,ans1,ans2)\n", "for _ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n s1, s2, last, q1, q2, flag = [], [], 0, 0, n-1, 0\n while q1 <= q2:\n sum1 = 0\n while sum1 <= last and q1 <= q2:\n if flag == 0:\n sum1 += a[q1]\n q1 += 1\n else:\n sum1 += a[q2]\n q2 -= 1\n if flag == 0:\n s1.append(sum1)\n else:\n s2.append(sum1)\n flag, last = 1-flag, sum1\n print(len(s1)+len(s2), sum(s1), sum(s2))\n", "for t in range(int(input())):\n n = int(input())\n cand = list(map(int, input().split()))\n a = 0\n b = 0\n i = 0\n j = n - 1\n prev = 0\n moves = 0\n while i <= j:\n curr = 0\n while i <= j and curr <= prev:\n curr += cand[i]\n i += 1\n a += curr\n prev = curr\n moves += bool(curr)\n curr = 0\n while i <= j and curr <= prev:\n curr += cand[j]\n j -= 1\n b += curr\n prev = curr\n moves += bool(curr)\n print(moves, a, b)\n", "t = int(input())\nfor _ in range(t):\n a = 0\n b = 0\n n = int(input())\n As = list(map(int,input().split()))\n left = 0\n right = n - 1\n\n a += As[0]\n left = 1\n min = As[0]\n\n curr = 0\n turn = False\n count = 1\n while left <= right:\n if turn:\n a += As[left]\n curr += As[left]\n left += 1\n else:\n b += As[right]\n curr += As[right]\n right -= 1\n if curr > min:\n count += 1\n min = curr\n curr = 0\n turn = not turn\n if curr != 0:\n count += 1\n print(count, a, b)\n", "for _ in range(int(input())):\n\tn = int(input())\n\tL = list(map(int, input().split()))\n\ta, b = 0, 0\n\tla, lb = 0, 0\n\ti, j = 0, n-1\n\trnds = 0\n\twhile i <= j:\n\t\tca = 0\n\t\twhile i <= j and ca <= lb:\n\t\t\tca += L[i]\n\t\t\ti += 1\n\t\ta += ca\n\t\tla = ca\n\n\t\trnds += 1\n\t\tif i > j:\n\t\t\tbreak\n\n\t\tcb = 0\n\t\twhile i <= j and cb <= la:\n\t\t\tcb += L[j]\n\t\t\tj -= 1\n\t\tb += cb\n\t\tlb = cb\n\n\t\trnds += 1\n\tprint(rnds, a, b)\n", "from math import *\n\nfor zz in range(int(input())):\n n = int(input())\n a = [int(i) for i in input().split()]\n i = 0\n j = n - 1\n ans = 0\n ct = 0\n ps = 0\n x = 0\n y = 0\n while i <= j:\n cs= 0 \n if ct == 0:\n while i <= j and cs <= ps:\n cs += a[i]\n i += 1\n x += cs\n else:\n while i <= j and cs <= ps:\n cs += a[j]\n j -= 1\n y += cs\n ps = cs\n ct = 1 - ct\n ans += 1\n print(ans, x, y)\n", "import math\nfor _ in range(int(input())):\n\tn=int(input())\n\tli=list(map(int,input().split()))\n\ta=0\n\tb=0\n\tl=0\n\tr=n-1\n\tp=0\n\tq=0\n\twhile(l<=r):\n\t\tif q%2==0:\n\t\t\tsu=0\n\t\t\tfor i in range(l,r+1):\n\t\t\t\tl+=1\n\t\t\t\tsu+=li[i]\n\t\t\t\ta+=li[i]\n\t\t\t\tif (su>p):\n\t\t\t\t\tp=su\n\t\t\t\t\tbreak\n\t\telse:\n\t\t\tsu=0\n\t\t\tfor i in range(r,l-1,-1):\n\t\t\t\tr-=1\n\t\t\t\tsu+=li[i]\n\t\t\t\tb+=li[i]\n\t\t\t\tif (su>p):\n\t\t\t\t\tp=su\n\t\t\t\t\tbreak\n\t\tq+=1\n\tprint(q,a,b)\n\n\n\n\n\n\n\t\n", "t=int(input())\nfor i in range (t):\n n=int(input())\n A=[int(x) for x in input().split()]\n x=A[0]\n l=1\n r=n-1\n a=x\n b=0\n p=1\n while l<=r:\n p+=1\n c=0\n while c<=x and l<=r:\n c+=A[r]\n r-=1\n b+=c\n if c<=x or l>r:\n break\n x=c\n\n p+=1\n c=0\n while c<=x and l<=r:\n c+=A[l]\n l+=1\n a+=c\n if c<=x or l>r:\n break\n x=c\n\n print(p,a,b)", "T = int(input())\n\nfor t in range(T):\n N = int(input())\n A = [int(_) for _ in input().split()]\n\n L = 0\n R = N-1\n turn = 0\n previous = 0\n alice = 0\n bob = 0\n moves = 0\n\n while L <= R:\n eaten = 0\n while eaten <= previous and L <= R:\n if turn == 0:\n eaten += A[L]\n alice += A[L]\n L += 1\n else:\n eaten += A[R]\n bob += A[R]\n R -= 1\n previous = eaten\n turn = 1 - turn\n moves += 1\n\n print(moves, alice, bob)\n", "import sys\n\n\ninput()\nfor candies in sys.stdin.readlines()[1::2]:\n candies = [int(c) for c in candies.split()]\n a, b = 0, 0\n idxA, idxB, move = 0, len(candies) - 1, 0\n\n eaten = 0\n while idxA <= idxB:\n lastEaten = eaten\n eaten = 0\n if move & 1 == 0:\n while idxA <= idxB and eaten <= lastEaten:\n a += candies[idxA]\n eaten += candies[idxA]\n idxA += 1\n else:\n while idxB >= idxA and eaten <= lastEaten:\n b += candies[idxB]\n eaten += candies[idxB]\n idxB -= 1\n\n move += 1\n\n print(move, a, b)\n", "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn list(map(int, minp().split()))\n\ndef solve():\n\tn = mint()\n\tc = list(mints())\n\tl = 1\n\tr = n\n\ta = c[0]\n\tb = 0\n\tla = c[0]\n\tlb = 0\n\tans = 1\n\twhile l<r:\n\t\tx = 0\n\t\tans += 1\n\t\twhile x <= la and l < r:\n\t\t\tr -= 1\n\t\t\tx += c[r]\n\t\tlb = x\n\t\tb += x\n\t\tif l >= r:\n\t\t\tbreak\n\t\tans += 1\n\t\tx = 0\n\t\twhile x <= lb and l < r:\n\t\t\tx += c[l]\n\t\t\tl += 1\n\t\tla = x\n\t\ta += x\n\tprint(ans, a, b)\n\nfor i in range(mint()):\n\tsolve()\n", "def solve(n, sizes):\n last = sizes[0]\n\n result = {'n_steps': 1,\n 'a': last,\n 'b': 0, }\n\n flag_a = 1 # next candy to eat\n flag_b = n - 1\n turn = 'b'\n\n if flag_a == flag_b + 1:\n return result\n\n while True:\n cur = 0\n result['n_steps'] += 1\n\n if flag_a == flag_b + 1:\n return result\n\n if turn == 'a':\n while cur <= last:\n cur += sizes[flag_a]\n result['a'] += sizes[flag_a]\n flag_a += 1\n if flag_a == flag_b + 1:\n return result\n\n last = cur\n turn = 'b'\n else:\n while cur <= last:\n cur += sizes[flag_b]\n result['b'] += sizes[flag_b]\n flag_b -= 1\n if flag_a == flag_b + 1:\n return result\n\n last = cur\n turn = 'a'\n\n\ndef main():\n tests = int(input())\n\n for t in range(tests):\n n = int(input())\n sizes = list(map(int, input().split()))\n result = solve(n, sizes)\n\n print(result['n_steps'], result['a'], result['b'])\n\n\nmain()\n", "import sys\ndef input():\n\treturn sys.stdin.readline()[:-1]\n\nt = int(input())\nfor _ in range(t):\n\tn = int(input())\n\tc = list(map(int, input().split()))\n\tif n == 1:\n\t\tprint(1, c[0], 0)\n\t\tcontinue\n\tM = c[0]\n\tl, r = 1, n\n\ta, b = c[0], 0\n\tfor i in range(1, 1000000):\n\t\tif i%2 == 0:\n\t\t\ta_tmp = 0\n\t\t\twhile a_tmp <= M and l < r:\n\t\t\t\ta_tmp += c[l]\n\t\t\t\ta += c[l]\n\t\t\t\tl += 1\n\t\t\tif l == r:\n\t\t\t\tbreak\n\t\t\tM = a_tmp\n\t\telse:\n\t\t\tb_tmp = 0\n\t\t\twhile b_tmp <= M and l < r:\n\t\t\t\tb_tmp += c[r-1]\n\t\t\t\tb += c[r-1]\n\t\t\t\tr -= 1\n\t\t\tif l == r:\n\t\t\t\tbreak\n\t\t\tM = b_tmp\n\tprint(i+1, a, b)", "for f in range(int(input())):\n n=int(input())\n a=list(map(int,input().split()))\n i=0\n j=n-1\n alice=0\n bob=0\n prev=0\n turn=0\n k=0\n while i<=j:\n cur=0\n if turn==0:\n while cur<=prev and i<=j:\n alice+=a[i]\n cur+=a[i]\n i+=1\n else:\n while cur<=prev and i<=j:\n bob+=a[j]\n cur+=a[j]\n j-=1\n k+=1\n turn=1-turn\n prev=cur\n print(k,alice,bob)", "import sys\ninput = sys.stdin.readline\n\nfor t in range(int(input())):\n n = int(input())\n l = list(map(int,input().split()))\n a = l.pop(0); b = 0; move = 0; ad = a; bd = 0; able = True; count = 1\n while l:\n bd = 0\n while bd <= ad:\n bd += l.pop(-1)\n if l == []:\n able = False\n break\n b += bd; count += 1\n if able == False:\n break\n ad = 0\n while ad <= bd:\n ad += l.pop(0)\n if l == []:\n able = False\n break\n a += ad; count += 1\n if able == False:\n break\n print(count, a, b)\n", "from _collections import deque\n\nfor _ in range(int(input())):\n n = int(input())\n ar = list(map(int, input().split()))\n ar = deque(ar)\n turn = 0\n a, b = 0, 0\n num2 = 0\n x = 0\n while ar:\n if turn == 0:\n num1 = 0\n while ar and num1 <= num2:\n num1 += ar[0]\n ar.popleft()\n a += num1\n num2 = num1\n turn = 1\n else:\n num1 = 0\n while ar and num1 <= num2:\n num1 += ar[-1]\n ar.pop()\n b += num1\n num2 = num1\n turn = 0\n x += 1\n print(x, a, b)", "\nt = int(input())\n\nfor loop in range(t):\n\n n = int(input())\n\n lis = list(map(int,input().split()))\n\n ai = 0\n bi = n-1\n\n A = [0]\n B = [0]\n move = 0\n\n while True:\n\n if ai > bi:\n break\n\n na = 0\n while na <= B[-1]:\n\n if ai > bi:\n break\n\n na += lis[ai]\n ai += 1\n\n A.append(na)\n if na > 0:\n move += 1\n\n nb = 0\n while nb <= A[-1]:\n\n if ai > bi:\n break\n\n nb += lis[bi]\n bi -= 1\n B.append(nb)\n if nb > 0:\n move += 1\n\n print(move,sum(A),sum(B))\n \n"] | {
"inputs": [
"7\n11\n3 1 4 1 5 9 2 6 5 3 5\n1\n1000\n3\n1 1 1\n13\n1 2 3 4 5 6 7 8 9 10 11 12 13\n2\n2 1\n6\n1 1 1 1 1 1\n7\n1 1 1 1 1 1 1\n",
"3\n1\n1\n1\n1\n1\n1\n"
],
"outputs": [
"6 23 21\n1 1000 0\n2 1 2\n6 45 46\n2 2 1\n3 4 2\n4 4 3\n",
"1 1 0\n1 1 0\n1 1 0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 12,104 | |
757074102d6aaa4beebcaa1658545dfe | UNKNOWN | You are given two arrays $a$ and $b$ both consisting of $n$ positive (greater than zero) integers. You are also given an integer $k$.
In one move, you can choose two indices $i$ and $j$ ($1 \le i, j \le n$) and swap $a_i$ and $b_j$ (i.e. $a_i$ becomes $b_j$ and vice versa). Note that $i$ and $j$ can be equal or different (in particular, swap $a_2$ with $b_2$ or swap $a_3$ and $b_9$ both are acceptable moves).
Your task is to find the maximum possible sum you can obtain in the array $a$ if you can do no more than (i.e. at most) $k$ such moves (swaps).
You have to answer $t$ independent test cases.
-----Input-----
The first line of the input contains one integer $t$ ($1 \le t \le 200$) β the number of test cases. Then $t$ test cases follow.
The first line of the test case contains two integers $n$ and $k$ ($1 \le n \le 30; 0 \le k \le n$) β the number of elements in $a$ and $b$ and the maximum number of moves you can do. The second line of the test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 30$), where $a_i$ is the $i$-th element of $a$. The third line of the test case contains $n$ integers $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 30$), where $b_i$ is the $i$-th element of $b$.
-----Output-----
For each test case, print the answer β the maximum possible sum you can obtain in the array $a$ if you can do no more than (i.e. at most) $k$ swaps.
-----Example-----
Input
5
2 1
1 2
3 4
5 5
5 5 6 6 5
1 2 5 4 3
5 3
1 2 3 4 5
10 9 10 10 9
4 0
2 2 4 3
2 4 2 3
4 4
1 2 2 1
4 4 5 4
Output
6
27
39
11
17
-----Note-----
In the first test case of the example, you can swap $a_1 = 1$ and $b_2 = 4$, so $a=[4, 2]$ and $b=[3, 1]$.
In the second test case of the example, you don't need to swap anything.
In the third test case of the example, you can swap $a_1 = 1$ and $b_1 = 10$, $a_3 = 3$ and $b_3 = 10$ and $a_2 = 2$ and $b_4 = 10$, so $a=[10, 10, 10, 4, 5]$ and $b=[1, 9, 3, 2, 9]$.
In the fourth test case of the example, you cannot swap anything.
In the fifth test case of the example, you can swap arrays $a$ and $b$, so $a=[4, 4, 5, 4]$ and $b=[1, 2, 2, 1]$. | ["import sys\ninput = sys.stdin.readline\nrInt = lambda: int(input())\nmInt = lambda: list(map(int, input().split()))\nrLis = lambda: list(map(int, input().split()))\n\nt = int(input())\nfor _ in range(t):\n n, k = mInt()\n a = rLis()\n b = rLis()\n a.sort()\n b.sort(reverse = True)\n for i in range(k):\n if a[i] < b[i]:\n a[i] = b[i]\n print(sum(a))\n", "q = int(input())\nfor _ in range(q):\n\tn,k = map(int,input().split())\n\ta = list(map(int,input().split()))\n\tb = list(map(int,input().split()))\n\ta.sort()\n\tb.sort()\n\tb.reverse()\n\ti = 0\n\twhile i < k and b[i] >= a[i]:\n\t\ta[i] = b[i]\n\t\ti += 1\n\tprint(sum(a))", "T = int(input())\nfor t in range(T):\n n, k = list(map(int, input().split()))\n\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n\n sa = sorted(a)\n sb = sorted(b, reverse=True)\n\n for i in range(k):\n if sa[i] < sb[i]:\n sa[i] = sb[i]\n else:\n break\n\n res = sum(sa)\n print(res)\n", "for _ in range(int(input())):\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n a.sort()\n b.sort()\n b.reverse()\n s = sum(a)\n for i in range(k):\n if b[i]-a[i] <= 0:\n break\n s += b[i]-a[i]\n print(s)", "def read_int():\n return int(input())\n\n\ndef read_ints():\n return list(map(int, input().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n n, k = read_ints()\n a = list(read_ints())\n b = list(read_ints())\n a.sort()\n b.sort(reverse=True)\n for i in range(k):\n if a[i] < b[i]:\n a[i] = b[i]\n else:\n break\n print(sum(a))\n", "\nt = int(input())\n\nfor loop in range(t):\n\n n,k = list(map(int,input().split()))\n\n a = list(map(int,input().split()))\n b = list(map(int,input().split()))\n\n for i in range(k):\n\n a.sort()\n b.sort()\n\n if a[0] < b[-1]:\n\n tmp = a[0]\n a[0] = b[-1]\n b[-1] = tmp\n\n print(sum(a))\n", "from sys import stdin, stdout, setrecursionlimit\nfor _ in range(int(input())):\n n, k = list(map(int, input().split()))\n a = sorted([int(i) for i in input().split()])\n b = sorted([int(i) for i in input().split()], reverse = True)\n for i in range(k):\n if a[i] > b[i]: break\n else: a[i], b[i] = b[i], a[i]\n print(sum(a))\n\n\n\n\n\n\n\n", "import math \ndef ri():\n return map(int,input().split())\ndef li():\n return list(map(int,input().split()))\ndef inp():\n return int(input())\ndef si():\n return input()\ndef pYes():\n print(\"YES\")\ndef pNo():\n print(\"NO\")\ndef plist(l):\n print(\"\".join(l))\nt = int(input())\nfor i in range(t):\n n,k= ri()\n a= li()\n b=li()\n a.sort()\n b.sort(reverse=True)\n for i in range(k):\n if a[i]<b[i]:\n a[i]=b[i]\n else:\n break\n print(sum(a)) ", "for _ in range(int(input())):\n n,k = map(int,input().split())\n a = [*map(int,input().split())]\n b = [*map(int,input().split())]\n a.sort()\n b.sort(reverse=True)\n for i in range(k):\n if(a[i]<b[i]):\n tmp = a[i]\n a[i] = b[i]\n b[i] = tmp\n print(sum(a))", "for _ in range(int(input())):\n n,k=list(map(int,input().split()))\n a=sorted(list(map(int,input().split())))\n b= sorted(list(map(int, input().split())))\n n-=1\n for i in range(k):\n if a[i]<b[n]:\n a[i]=b[n]\n n-=1\n else:\n break\n print(sum(a))\n", "T = int(input()) \nfor _ in range (T): \n\n n,k = map(int, input().split()) \n A = list(map(int, input().split())) \n B = list(map(int, input().split())) \n A.sort() \n B.sort() \n for i in range (k): \n A[i] = max (A[i], B[n-i-1]) \n print (sum(A)) ", "import sys\nimport os\nimport time\nimport collections\nfrom collections import Counter, deque\nimport itertools\nimport math\nimport timeit\nimport random\nimport string\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\n\ndef divs(n, start=1):\n divisors = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if n % i == 0:\n if n / i == i:\n divisors.append(i)\n else:\n divisors.extend([i, n // i])\n return divisors\n\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\n\ndef flin(d, x, default=-1):\n left = right = -1\n for i in range(len(d)):\n if d[i] == x:\n if left == -1: left = i\n right = i\n if left == -1:\n return default, default\n else:\n return left, right\n\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' ', end='\\n'): print(sep.join(map(str, a)), end=end)\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\n\n########################################################################################################################\n# input = sys.stdin.readline\n\nfor _ in range(ii()):\n n, m = mi()\n a = sorted(li())\n b = sorted(li(), reverse=True)\n for i in range(m):\n if a[i] < b[i]:\n a[i], b[i] = b[i], a[i]\n print(sum(a))\n", "import sys\n\nreadline = sys.stdin.readline\nreadall = sys.stdin.read\nns = lambda: readline().rstrip()\nni = lambda: int(readline().rstrip())\nnm = lambda: map(int, readline().split())\nnl = lambda: list(map(int, readline().split()))\nprn = lambda x: print(*x, sep='\\n')\n\n\ndef solve():\n n, k = nm()\n a = nl()\n b = nl()\n a.sort()\n b.sort(reverse=True)\n for i in range(k):\n if a[i] >= b[i]:\n break\n a[i] = b[i]\n print(sum(a))\n return\n\n# solve()\n\nT = ni()\nfor _ in range(T):\n solve()\n", "# int(input())\n# [int(s) for s in input().split()]\n# input()\n\n\ndef solve():\n t = int(input())\n\n for i in range(t):\n n, k = [int(s) for s in input().split()]\n a = sorted([int(s) for s in input().split()])\n b = sorted([int(s) for s in input().split()], reverse=True)\n\n for j in range(k):\n if a[j] <= b[j]:\n a[j] = b[j]\n\n print(sum(a))\n\n\ndef __starting_point():\n solve()\n__starting_point()", "for _ in range(int(input())):\n n, k = [int(x) for x in input().split()]\n a = sorted([int(x) for x in input().split()])\n b = sorted([int(x) for x in input().split()], reverse=True)\n for i in range(k):\n if a[i] < b[i]:\n a[i], b[i] = b[i], a[i]\n print(sum(a))\n", "import sys\ninput = sys.stdin.readline\nimport heapq\n\nt=int(input())\nfor tests in range(t):\n n,k=list(map(int,input().split()))\n A=list(map(int,input().split()))\n B=sorted(map(int,input().split()),reverse=True)\n\n heapq.heapify(A)\n\n for i in range(k):\n x=heapq.heappop(A)\n if B[i]>x:\n x=B[i]\n heapq.heappush(A,x)\n\n print(sum(A))\n \n", "from sys import stdin, stdout \ninput = stdin.readline\n#print = stdout.write\n\nfor _ in range(int(input())):\n n, k = list(map(int, input().split()))\n a = sorted(list(map(int, input().split())))\n b = sorted(list(map(int, input().split())))\n for i in range(k):\n if a[i] >= b[n - i - 1]:\n break\n a[i] = b[n - i - 1]\n print(sum(a))\n", "for _ in range(int(input())):\n n, k = map(int, input().split())\n a = sorted(map(int, input().split()))\n b = sorted(map(int, input().split()))\n\n for i in range(k):\n if a[i] < b[n-i-1]:\n a[i], b[n-i-1] = b[n-i-1], a[i]\n else:\n break\n\n print(sum(a))", "t=int(input())\nwhile t>0:\n n,k=map(int,input().split())\n a=list(map(int,input().split()))\n b=list(map(int,input().split()))\n a.sort()\n b.sort()\n for i in range(k):\n if a[0]<b[-1]:\n a[0],b[-1]=b[-1],a[0]\n a.sort()\n b.sort()\n print(sum(a))\n t-=1", "\nT = int(input())\nn = [0]*T\nm = [0]*T\na = [0]*T\nb = [0]*T\n\nfor t in range(T):\n n, k = [int(i) for i in input().split(' ')]\n a = [int(i) for i in input().split(' ')]\n b = [int(i) for i in input().split(' ')]\n a.sort()\n b.sort()\n for i in range(k):\n if a[i]<b[n-i-1]:\n a[i] = b[n-i-1]\n else:\n break\n print(sum(a))\n\n\n", "t = int(input())\nfor t in range(t):\n n, k = [int(i) for i in input().split(\" \")]\n a = [int(i) for i in input().split(\" \")]\n b = [int(i) for i in input().split(\" \")]\n for i in range(k):\n aMin = min(a)\n bMax = max(b)\n if bMax > aMin:\n a[a.index(aMin)], b[b.index(bMax)] = b[b.index(bMax)], a[a.index(aMin)]\n print(sum(a))", "t=int(input())\nfor i in range(t):\n n,k=map(int,input().split())\n a=list(map(int,input().split()))\n b=list(map(int,input().split()))\n a.sort()\n b.sort()\n b.reverse()\n ans=sum(a)\n for i in range(k):\n if a[i]<b[i]:\n ans+=b[i]-a[i]\n print(ans)", "for f in range(int(input())):\n n,k=map(int,input().split())\n a=list(map(int,input().split()))\n b=list(map(int,input().split()))\n a.sort()\n b.sort(reverse=True)\n x=0\n while x<k and a[x]<b[x]:\n a[x]=b[x]\n x+=1\n print(sum(a))", "t = int(input())\nwhile t:\n n, k = map(int, input().split())\n a = [int(x) for x in input().split()]\n b = [int(x) for x in input().split()]\n a.sort()\n b.sort(reverse=True)\n for i in range(k):\n a[i] = max(a[i], b[i])\n print(sum(a))\n t-=1", "t = int(input())\nfor i in range(t):\n n, k = map(int, input().split())\n a = [int(i) for i in input().split()]\n b = [int(i) for i in input().split()]\n s = sum(a)\n a.sort()\n b.sort()\n cnt = 0\n while cnt < len(b) and cnt < len(a) and cnt < k:\n if b[len(b) - cnt - 1] > a[cnt]:\n s +=b[len(b) - cnt - 1] - a[cnt]\n cnt += 1\n print(s)", "import sys\nagGK = int(input())\nfor _ in range(agGK):\n n, k = map(int, input().split())\n a = [int(i) for i in input().split(' ', n - 1)]\n b = [int(i) for i in input().split(' ', n - 1)]\n a.sort()\n b.sort()\n if n - k - 1 == 0:\n \tg = 0\n else:\n \tg = n - k - 1\n for i in range(n-1, g, -1):\n \tif a[n-i-1] < b[i]:\n \t\ta[n-i-1] = b[i]\n \telse:\n \t\tbreak\n print(sum(a))"] | {
"inputs": [
"5\n2 1\n1 2\n3 4\n5 5\n5 5 6 6 5\n1 2 5 4 3\n5 3\n1 2 3 4 5\n10 9 10 10 9\n4 0\n2 2 4 3\n2 4 2 3\n4 4\n1 2 2 1\n4 4 5 4\n",
"1\n6 1\n1 4 2 23 15 13\n5 6 4 1 15 24\n"
],
"outputs": [
"6\n27\n39\n11\n17\n",
"81\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,287 | |
1d6b32fb1da4783aa5521828e1484ad9 | UNKNOWN | You are planning to buy an apartment in a $n$-floor building. The floors are numbered from $1$ to $n$ from the bottom to the top. At first for each floor you want to know the minimum total time to reach it from the first (the bottom) floor.
Let: $a_i$ for all $i$ from $1$ to $n-1$ be the time required to go from the $i$-th floor to the $(i+1)$-th one (and from the $(i+1)$-th to the $i$-th as well) using the stairs; $b_i$ for all $i$ from $1$ to $n-1$ be the time required to go from the $i$-th floor to the $(i+1)$-th one (and from the $(i+1)$-th to the $i$-th as well) using the elevator, also there is a value $c$ β time overhead for elevator usage (you need to wait for it, the elevator doors are too slow!).
In one move, you can go from the floor you are staying at $x$ to any floor $y$ ($x \ne y$) in two different ways: If you are using the stairs, just sum up the corresponding values of $a_i$. Formally, it will take $\sum\limits_{i=min(x, y)}^{max(x, y) - 1} a_i$ time units. If you are using the elevator, just sum up $c$ and the corresponding values of $b_i$. Formally, it will take $c + \sum\limits_{i=min(x, y)}^{max(x, y) - 1} b_i$ time units.
You can perform as many moves as you want (possibly zero).
So your task is for each $i$ to determine the minimum total time it takes to reach the $i$-th floor from the $1$-st (bottom) floor.
-----Input-----
The first line of the input contains two integers $n$ and $c$ ($2 \le n \le 2 \cdot 10^5, 1 \le c \le 1000$) β the number of floors in the building and the time overhead for the elevator rides.
The second line of the input contains $n - 1$ integers $a_1, a_2, \dots, a_{n-1}$ ($1 \le a_i \le 1000$), where $a_i$ is the time required to go from the $i$-th floor to the $(i+1)$-th one (and from the $(i+1)$-th to the $i$-th as well) using the stairs.
The third line of the input contains $n - 1$ integers $b_1, b_2, \dots, b_{n-1}$ ($1 \le b_i \le 1000$), where $b_i$ is the time required to go from the $i$-th floor to the $(i+1)$-th one (and from the $(i+1)$-th to the $i$-th as well) using the elevator.
-----Output-----
Print $n$ integers $t_1, t_2, \dots, t_n$, where $t_i$ is the minimum total time to reach the $i$-th floor from the first floor if you can perform as many moves as you want.
-----Examples-----
Input
10 2
7 6 18 6 16 18 1 17 17
6 9 3 10 9 1 10 1 5
Output
0 7 13 18 24 35 36 37 40 45
Input
10 1
3 2 3 1 3 3 1 4 1
1 2 3 4 4 1 2 1 3
Output
0 2 4 7 8 11 13 14 16 17 | ["n, c = list(map(int, input().split()))\na = [int(ai) for ai in input().split()]\nb = [int(bi) for bi in input().split()]\n\ndpa, dpb = [0] * n, [0] * n\ndpa[1], dpb[1] = a[0], c + b[0]\nfor i in range(1, n - 1):\n dpa[i + 1], dpb[i + 1] = min(dpa[i], dpb[i]) + a[i], min(dpa[i] + c, dpb[i]) + b[i]\n\nprint(*(min(dpa[i], dpb[i]) for i in range(n)))\n", "n, c = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\ndp = [[0 for i in range(2)] for i in range(n + 1)]\ndp[0][0] = 0\ndp[0][1] = c\nprint(min(dp[0][0], dp[0][1]), end=\" \")\nfor i in range(1, n):\n dp[i][0] = min(dp[i - 1][0] + a[i - 1], dp[i - 1][1] + a[i - 1])\n dp[i][1] = min(dp[i - 1][0] + c + b[i - 1], dp[i - 1][1] + b[i - 1])\n print(min(dp[i][0], dp[i][1]), end=\" \")", "import sys\ndef I():\n return sys.stdin.readline().rstrip()\n\nn, c = list(map( int, I().split() ))\na = list( map( int, I().split() ) )\nb = list( map( int, I().split() ) )\n\ne = [ 0 ] + [ 1003 * n ] * ( n - 1 )\ns = [ 0 ] + [ 1003 * n ] * ( n - 1 )\n\nfor i in range( 0, n - 1 ):\n e[ i + 1 ] = min( c + s[ i ] + b[ i ], e[ i ] + b[ i ] )\n s[ i + 1 ] = min( s[ i ], e[ i ] ) + a[ i ]\n if i == 0:\n e[ i + 1 ] += c\n\nans = [ min( i, j ) for i, j in zip( e, s ) ]\nprint( *ans )\n", "n, c = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nsb = [0]\nfor i in B:\n sb.append(sb[-1] + i)\nans = [0]\nhemin = 0\nfor i in range(1, n):\n tw = min(ans[i - 1] + A[i - 1], hemin + c + sb[i])\n ans.append(tw)\n hemin = min(hemin, ans[i] - sb[i])\nprint(*ans)\n", "n,c=list(map(int,input().split()))\naa=list(map(int,input().split()))\nbb=list(map(int,input().split()))\ndp=[[0,c] for i in range(n)]\nfor i in range(1,n):\n dp[i][0]=min(dp[i-1][0]+aa[i-1],dp[i-1][1]+aa[i-1])\n dp[i][1]=min(dp[i-1][0]+c+bb[i-1],dp[i-1][1]+bb[i-1])\nprint(*[min(i) for i in dp])\n", "I = lambda: list(map(int, input().split()))\n\nn, c = I()\na = I()\nb = I()\ndp = [[0, 0] for i in range(300000)]\ndp[1][0] = a[0]\ndp[1][1] = c + b[0]\n\nfor i in range(2, n):\n dp[i][0] = min(dp[i-1][0] + a[i-1], dp[i-1][1] + a[i-1])\n dp[i][1] = min(dp[i-1][0] + c + b[i-1], dp[i-1][1] + b[i-1])\nfor i in range(n):\n print(min(dp[i][0], dp[i][1]), end = ' ')\n", "n, c = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\ndp = [[0]*2 for i in range(n)]\ndp[0][1] = c\nfor i in range(n-1):\n dp[i+1][0] = min(dp[i][0] + a[i], dp[i][1] + a[i])\n dp[i+1][1] = min(dp[i][0] + b[i] + c, dp[i][1] + b[i])\nans = [0]*n\nfor i in range(n):\n ans[i] = min(dp[i])\nprint(*ans)", "n, c = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\ndp = [[0, 0] for i in range(n)]\ndp[0] = [0, c]\nfor i in range(1, n):\n ans1 = dp[i - 1][0] + a[i - 1]\n ans2 = dp[i - 1][1] + b[i - 1]\n dp[i][1] = min(ans2, dp[i - 1][0] + c + b[i - 1])\n dp[i][0] = min(ans1, dp[i][1])\nfor elem in dp:\n print(min(elem[0], elem[1]), end=\" \")", "import sys\ninput = sys.stdin.readline\n\nn,c=list(map(int,input().split()))\n\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\nTIME0=[0]*n\nTIME1=[0]*n\n\nTIME1[0]=c\n\nfor i in range(1,n):\n TIME0[i]=min(TIME0[i-1],TIME1[i-1])+A[i-1]\n TIME1[i]=min(TIME0[i-1]+c+B[i-1],TIME1[i-1]+B[i-1])\n\nANS=[min(TIME0[i],TIME1[i]) for i in range(n)]\nprint(*ANS)\n", "\nn, c = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\nT = [[0,0] for i in range(n)]\nT[0][1] = c/2\nfor i in range(1, n):\n T[i][0] = min(T[i-1][0]+A[i-1], T[i-1][1]+B[i-1]+c/2)\n T[i][1] = min(T[i-1][0]+A[i-1]+c/2, T[i-1][1]+B[i-1])\n\nprint(\" \".join([str(round(i[0])) for i in T]))", "n, c=map(int,input().split())\na = [0]+[int(i) for i in input().split()]\nb = [0]+[int(i) for i in input().split()]\np = [0] * n\nl = [0] * n\nt = [0] * n\nfor i in range(1,n):\n p[i] = a[i] + t[i-1]\n l[i] = b[i] + t[i-1] - (c if t[i-1] == l[i-1] + c else 0)\n l[i] = min(l[i],l[i-1]+b[i])\n t[i] = min(l[i]+c, p[i])\nfor i in t:\n print(i,end=' ')\n", "n, c = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nans = 0\n\nw = [[0 for i in range(2)] for i in range(n)]\n\nw[0][1] = c\nfor i in range(1, n):\n w[i][0] = min(w[i - 1][0] + a[i - 1],\n w[i - 1][1] + b[i - 1])\n w[i][1] = min(w[i - 1][1] + b[i - 1],\n w[i][0] + c)\n\nfor i in range(n):\n print(min(w[i]), end=' ', flush=False)\nprint() ", "# n: floors\n# c: overhead\nn, c = map(int, input().split())\na = [0] + list(map(int, input().split())) # stairs time\nb = [0] + list(map(int, input().split())) # elevator time\n\ndp = [[0] * 2 for _ in range(n + 1)]\ndp[1][0] = 0 # Base case\ndp[1][1] = c # Base case\nfor i in range(2, n + 1):\n dp[i][0] = min(dp[i - 1][0], dp[i - 1][1]) + a[i - 1]\n dp[i][1] = min(dp[i - 1][0] + c, dp[i - 1][1]) + b[i - 1]\n\nprint (*[min(u) for u in dp][1:])", "\"\"\"\nNTC here\n\"\"\"\nfrom sys import stdin, setrecursionlimit\nsetrecursionlimit(10**7)\n\n\ndef iin(): return int(stdin.readline())\n \n \ndef lin(): return list(map(int, stdin.readline().split()))\n\n\n# range = xrange\n# input = raw_input\n\n\ndef main():\n n,c=lin()\n s=lin()\n e=lin()\n sol=[[0,0] for i in range(n)]\n sol[0]=[c+e[0],s[0]]\n for i in range(1,n-1):\n sol[i]=[e[i]+min(sol[i-1][0], c+sol[i-1][1]),min(sol[i-1][0],sol[i-1][1])+s[i]]\n ans=[0]+[min(sol[i]) for i in range(n-1)]\n print(*ans)\n\n \n\n\n\n\n\n\n\nmain()\n# try:\n# main()\n# except Exception as e: print(e)\n", "from math import *\n\nn,k = map(int, input().split())\n\ndp = [[float(\"inf\"),float(\"inf\")] for i in range( 2*10**5 + 5) ]\ndp[0] = [0,k]\nesc = list(map(int,input().split()))\nasc = list(map(int,input().split()))\n\nprint(0, end = \" \")\n\nfor i in range(1, n):\n dp[i][0] = min(dp[i-1]) + esc[i-1]\n dp[i][1] = min(dp[i-1][1], dp[i-1][0] + k) + asc[i-1]\n\n print(min(dp[i]), end = \" \")", "import sys\ninput = sys.stdin.readline\nn, c = list(map(int, input().strip().split()))\n\na = list(map(int, input().strip().split()))\nb = list(map(int, input().strip().split()))\n\nstairs = [0 for _ in range(n)]\nelevator = [0 for _ in range(n)]\nelevator[0] = c\n\nfor i in range(1, n):\n stairs[i] = min(elevator[i-1], stairs[i-1])+a[i-1]\n elevator[i] = min(elevator[i-1], stairs[i-1]+c)+b[i-1]\nprint(' '.join(str(min(elevator[i], stairs[i])) for i in range(n)))\n\n", "a = input('').split(' ')\nn = int(a[0])\nc = int(a[1])\nt = []\nfor i in range(n):\n t.append([0,10**5])\na = list(map(int,input('').split(' ')))\nb = list(map(int,input('').split(' ')))\nprint(0,end = ' ')\nfor i in range(1,n,1):\n t[i][0] = min(t[i-1][1],t[i-1][0]) + a[i-1]\n t[i][1] = min(t[i-1][0]+c,t[i-1][1]) + b[i-1]\n #print(t[i-1],c,b[i-1])\n #print(t[i])\n print(min(t[i][0],t[i][1]), end = ' ')", "\nn,c = list(map(int,input().split()))\n\nlis = []\n\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nasum = 0\nbsum = c\n\nfor i in range(n):\n\n lis.append (min(asum,bsum))\n\n if i == n-1:\n break\n\n oasum = asum\n\n asum = min(asum + a[i] , bsum + a[i])\n\n bsum = min(oasum + b[i] + c , bsum + b[i])\n\nprint(\" \".join(map(str,lis)))\n", "n, c = map(int, input().split())\n\nS = list(map(int, input().split()))\nE = list(map(int, input().split()))\n\nlastS = S[0]\nlastE = E[0] + c\nprint('0 ',end='')\nprint(min(lastS, lastE), end= ' ')\n\nfor i in range(1, n - 1):\n curS = min(lastS + S[i], lastE + S[i])\n curE = min(lastS + c + E[i], lastE + E[i])\n print(min(curS, curE), end=' ')\n lastS = curS\n lastE = curE", "#!/usr/bin/env python3\nimport sys\nfrom math import inf\n\n#lines = stdin.readlines()\ndef rint():\n return list(map(int, sys.stdin.readline().split()))\n\ndef input():\n return sys.stdin.readline().rstrip('\\n')\n\ndef oint():\n return int(input())\n\n\nn, c = rint()\n\na = list(rint())\nb = list(rint())\n\ne = 0\nans = [0]\ne = [0]*(n+2)\nmina = [inf]*(n+2)\nmine = [inf]*(n+2)\nmina[0] = a[0]\nmine[0] = b[0] + c\nfor i in range(1, n-1):\n mine[i] = b[i] + min(mine[i-1], mina[i-1] + c, mine[i-2] + mine[i-1])\n mina[i] = a[i] + min(mina[i-1], mine[i-1])\n\nfor i in range(n-1):\n ans.append(min(mine[i], mina[i]))\n\nprint(*ans)\n\n\n\n", "n, c = list(map(int, input().split()))\n\na = [int(x) for x in input().split()]\nb = [int(x) for x in input().split()]\n\nr = [0]\np = [0]\nfor i in range(n-1):\n x1 = r[-1] + a[i]\n\n y1 = p[-1] + b[i]\n if i == 0:\n y1 += c\n p.append(y1)\n\n #print(\"x1:\", x1)\n #print(\"y1:\", y1)\n\n if r[-1] < p[-1]:\n z1 = r[-1] + b[i] + c\n #print(\"z1\", z1)\n if z1 < y1:\n y1 = z1\n p[-1] = z1\n #print(\"----\")\n if x1 < y1:\n r.append(x1)\n else:\n r.append(y1)\n\nprint(*r)\n# print(p)\n\n", "n, c = map(int, input().split())\nwalk = list(map(int, input().split()))\nlift = list(map(int, input().split()))\ndpl = [0] * n\ndpw = [0] * n\ndpl[0] = c\nprint(0, end=\" \")\nfor i in range(1, n):\n dpl[i] = min(dpw[i - 1] + c, dpl[i - 1]) + lift[i - 1]\n dpw[i] = min(dpw[i - 1], dpl[i - 1]) + walk[i - 1]\n print(min(dpl[i], dpw[i]), end=\" \")\n", "# -*- coding: utf-8 -*-\n\nimport sys\n\nline_count = 0\nfor line in sys.stdin.readlines():\n inputs = line.split()\n if line_count == 0:\n n = int(inputs[0])\n c = int(inputs[1])\n elif line_count == 1:\n a = []\n for i in range(n - 1):\n a.append(int(inputs[i]))\n elif line_count == 2:\n b = []\n for i in range(n - 1):\n b.append(int(inputs[i]))\n if line_count == 2:\n break\n line_count += 1\n\nby_stair = [0]\nby_elev = [c]\nprint(0, end = \" \")\n\nfor i in range(1, n):\n pos_stair = min(by_stair[i - 1] + a[i - 1], by_elev[i - 1] + a[i - 1])\n by_stair.append(pos_stair)\n pos_elev = min(by_stair[i - 1] + c + b[i - 1], by_elev[i - 1] + b[i - 1])\n by_elev.append(pos_elev)\n print(min(pos_stair, pos_elev), end = \" \")\n", "n,c=map(int,input().split())\nl1=list(map(int,input().split()))\nl2=list(map(int,input().split()))\ndp=[[0]*2 for _ in range(n+1)]\ndp[1][1]=c\nfor i in range(2,n+1):\n dp[i][0]=min(dp[i-1][0],dp[i-1][1])+l1[i-2]\n dp[i][1]=min(dp[i-1][0]+l2[i-2]+c,dp[i-1][1]+l2[i-2])\nfor i in range(1,n+1):\n print(min(dp[i]),end=\" \")\n ", "n, c = [int(x) for x in input().split()]\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\ndpst = [0] * (n + 1)\ndplift = [0] * (n + 1)\ndpst[2] = a[0]\ndplift[2] = c + b[0]\nfor i in range(3, n + 1):\n dpst[i] = a[i - 2] + min(dpst[i - 1], dplift[i - 1])\n dplift[i] = b[i - 2] + min(c + dpst[i - 1], dplift[i - 1])\n\nfor i in range(1, n + 1): print(min(dpst[i], dplift[i]), end = \" \")"] | {
"inputs": [
"10 2\n7 6 18 6 16 18 1 17 17\n6 9 3 10 9 1 10 1 5\n",
"10 1\n3 2 3 1 3 3 1 4 1\n1 2 3 4 4 1 2 1 3\n"
],
"outputs": [
"0 7 13 18 24 35 36 37 40 45 \n",
"0 2 4 7 8 11 13 14 16 17 \n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,093 | |
368d4e52e949be442202a86b3dd4fa3b | UNKNOWN | For the given integer $n$ ($n > 2$) let's write down all the strings of length $n$ which contain $n-2$ letters 'a' and two letters 'b' in lexicographical (alphabetical) order.
Recall that the string $s$ of length $n$ is lexicographically less than string $t$ of length $n$, if there exists such $i$ ($1 \le i \le n$), that $s_i < t_i$, and for any $j$ ($1 \le j < i$) $s_j = t_j$. The lexicographic comparison of strings is implemented by the operator < in modern programming languages.
For example, if $n=5$ the strings are (the order does matter): aaabb aabab aabba abaab ababa abbaa baaab baaba babaa bbaaa
It is easy to show that such a list of strings will contain exactly $\frac{n \cdot (n-1)}{2}$ strings.
You are given $n$ ($n > 2$) and $k$ ($1 \le k \le \frac{n \cdot (n-1)}{2}$). Print the $k$-th string from the list.
-----Input-----
The input contains one or more test cases.
The first line contains one integer $t$ ($1 \le t \le 10^4$) β the number of test cases in the test. Then $t$ test cases follow.
Each test case is written on the the separate line containing two integers $n$ and $k$ ($3 \le n \le 10^5, 1 \le k \le \min(2\cdot10^9, \frac{n \cdot (n-1)}{2})$.
The sum of values $n$ over all test cases in the test doesn't exceed $10^5$.
-----Output-----
For each test case print the $k$-th string from the list of all described above strings of length $n$. Strings in the list are sorted lexicographically (alphabetically).
-----Example-----
Input
7
5 1
5 2
5 8
5 10
3 1
3 2
20 100
Output
aaabb
aabab
baaba
bbaaa
abb
bab
aaaaabaaaaabaaaaaaaa | ["#!usr/bin/env python3\nfrom collections import defaultdict, deque\nfrom heapq import heappush, heappop\nfrom itertools import permutations, accumulate\nimport sys\nimport math\nimport bisect\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef I(): return int(sys.stdin.readline())\ndef LS():return [list(x) for x in sys.stdin.readline().split()]\ndef S():\n res = list(sys.stdin.readline())\n if res[-1] == \"\\n\":\n return res[:-1]\n return res\ndef IR(n):\n return [I() for i in range(n)]\ndef LIR(n):\n return [LI() for i in range(n)]\ndef SR(n):\n return [S() for i in range(n)]\ndef LSR(n):\n return [LS() for i in range(n)]\n\nsys.setrecursionlimit(1000000)\nmod = 1000000007\n\ndef solve():\n t = I()\n for _ in range(t):\n n,k = LI()\n f = 1\n p = 1\n while f <= k:\n f += p\n p += 1\n f -= p\n p -= 2\n k -= f\n p = n-p\n k = n-k\n ans = \"a\"*(p-2)+\"b\"+\"a\"*(k-p+1)+\"b\"+\"a\"*(n-k-1)\n print(ans)\n return\n\n#Solve\ndef __starting_point():\n solve()\n\n__starting_point()", "t = int(input())\nfor i in range(t):\n n, k = map(int, input().split())\n fbp = n - 2\n cur = 1\n while cur < k:\n k -= cur\n fbp -= 1\n cur += 1\n sbp = n - k\n cnt = 0\n for j in range(n):\n if j == fbp:\n print('b', end='')\n elif j == sbp:\n print('b', end='')\n else:\n print('a', end='')\n print()", "def calc(n, k):\n k -= 1\n a, b = 0, 1\n for i in range(1, n + 2):\n if k - i >= 0:\n k -= i\n b += 1\n else:\n break\n a += k\n return \"\".join([\"b\" if i == a or i == b else \"a\" for i in range(n)[::-1]])\n\nT = int(input())\nfor _ in range(T):\n n, k = list(map(int, input().split()))\n print(calc(n, k))\n", "for _ in range(int(input())):\n n, k = map(int, input().split())\n low = 1\n high = n - 1\n ans = n\n while low <= high:\n mid = (high+low)//2\n temp = mid * ( mid + 1)//2\n if temp >= k:\n ans = min(ans, mid)\n high = mid - 1\n else:\n low = mid + 1\n temp = ans*(ans+1)//2 - k\n result = ['a'] * n\n result[n - ans - 1] = 'b'\n result[n- ans + temp] = 'b'\n print(''.join(result))", "for tc in range(int(input())):\n size, pos = list(map(int, input().split()))\n tl = 1\n tot = 0\n while tot + tl < pos:\n tot += tl\n tl += 1\n res = ['a' for _ in range(size)]\n res[-tl-1] = 'b'\n res[-(pos-tot)] = 'b'\n print(''.join(res))\n \n", "t = int(input())\nfor case_num in range(t):\n n, k = list(map(int, input().split(' ')))\n l = 1\n r = n - 1\n while l <= r:\n mid = (l + r) // 2\n num = mid * (mid + 1) // 2\n if k <= num:\n r = mid - 1\n else:\n l = mid + 1\n num = l * (l + 1) // 2\n ans = ['a' for i in range(n)]\n ans[-l-1] = 'b'\n rest = l - num + k\n ans[-rest] = 'b'\n print(''.join(ans))\n", "def go():\n n,k = map(int,input().split())\n x=1\n for i in range(n-2,-1,-1):\n if k>n-1-i:\n k-=n-1-i\n else:\n ans=['a']*n\n ans[i]='b'\n ans[n-k]='b'\n return ''.join(ans)\n\n\n\n\n# x,s = map(int,input().split())\nt = int(input())\n# t=1\nans=[]\nfor _ in range(t):\n # go()\n ans.append(str(go()))\n\nprint('\\n'.join(ans))", "def solve():\n\tA = list(map(int,input().split()))\n\tp1 = A[0] -1\t\n\tp2 = A[0]\n\tfat = 1\n\t\n\tA[1] = A[1] -1\n\twhile A[1]>=fat:\n\t\tp1 = p1-1\n\t\tA[1] = A[1] - fat\n\t\tfat = fat + 1\n\t\t\n\t\n\tp2 = p2 - A[1]\n\tfor i in range(1,A[0]+1):\n\t\tif i==p1 or i==p2:\n\t\t\tprint('b',end='')\n\t\telse:\n\t\t\tprint('a',end='')\n\tprint('')\n\t\t\t\t\t\n\nT = int(input())\nfor i in range(T):\n\tsolve()\t", "import sys\ndef input():\n\treturn sys.stdin.readline()[:-1]\nt = int(input())\nfor _ in range(t):\n\tn, k = list(map(int, input().split()))\n\tcur, level, add = 0, 0, 1\n\tk -= 1\n\twhile k >= cur + add:\n\t\tcur += add\n\t\tlevel += 1\n\t\tadd += 1\n\tx, y = n-2-level, n-1-(k - cur)\n\tans = [\"a\" for _ in range(n)]\n\tans[x], ans[y] = \"b\", \"b\"\n\tprint(\"\".join(ans))\n", "t = int(input())\n\nfor _ in range(t):\n n, k = list(map(int, input().split()))\n \n opts = 0\n b_pos = n-2\n while opts+(n-b_pos-1)<k:\n opts += n-b_pos-1\n b_pos -= 1\n \n b_pos2 = n - (k-opts)\n \n res = [\"a\"] * n\n res[b_pos] = \"b\"\n res[b_pos2] = \"b\"\n print(\"\".join(res))\n \n \n", "t = int(input())\nfor iii in range(t):\n\tn, k = list(map(int, input().split()))\n\ti = 1\n\twhile k > i:\n\t\tk -= i\n\t\ti += 1\n\ts = [\"a\"] * n\n\ts[-i-1] = \"b\"\n\ts[-k] = \"b\"\n\tprint(\"\".join(map(str, s)))\n", "import math\nt = int(input())\nfor i in range(t):\n n,k = list(map(int,input().split(\" \")))\n k-=1 #zero-index\n m = int((1+math.sqrt(1+8*k))/2)\n tri = int(m*(m-1)/2)\n s = k-tri\n #print(m)\n #print(s)\n s = \"a\"*(n-m-1)+\"b\"+\"a\"*(m-s-1)+\"b\"+\"a\"*s\n print(s)\n"] | {"inputs": ["7\n5 1\n5 2\n5 8\n5 10\n3 1\n3 2\n20 100\n", "7\n8 18\n19 11\n20 5\n15 19\n19 15\n20 6\n10 28\n"], "outputs": ["aaabb\naabab\nbaaba\nbbaaa\nabb\nbab\naaaaabaaaaabaaaaaaaa\n", "abaaabaa\naaaaaaaaaaaaabaaaab\naaaaaaaaaaaaaaaababa\naaaaaaaabaabaaa\naaaaaaaaaaaaabbaaaa\naaaaaaaaaaaaaaaabbaa\naabbaaaaaa\n"]} | INTRODUCTORY | PYTHON3 | CODEFORCES | 5,256 | |
017ddb02b3f8c3a29e38e5c59c82dc0e | UNKNOWN | Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples: for the array $[0, 0, 1, 0, 2]$ MEX equals to $3$ because numbers $0, 1$ and $2$ are presented in the array and $3$ is the minimum non-negative integer not presented in the array; for the array $[1, 2, 3, 4]$ MEX equals to $0$ because $0$ is the minimum non-negative integer not presented in the array; for the array $[0, 1, 4, 3]$ MEX equals to $2$ because $2$ is the minimum non-negative integer not presented in the array.
You are given an empty array $a=[]$ (in other words, a zero-length array). You are also given a positive integer $x$.
You are also given $q$ queries. The $j$-th query consists of one integer $y_j$ and means that you have to append one element $y_j$ to the array. The array length increases by $1$ after a query.
In one move, you can choose any index $i$ and set $a_i := a_i + x$ or $a_i := a_i - x$ (i.e. increase or decrease any element of the array by $x$). The only restriction is that $a_i$ cannot become negative. Since initially the array is empty, you can perform moves only after the first query.
You have to maximize the MEX (minimum excluded) of the array if you can perform any number of such operations (you can even perform the operation multiple times with one element).
You have to find the answer after each of $q$ queries (i.e. the $j$-th answer corresponds to the array of length $j$).
Operations are discarded before each query. I.e. the array $a$ after the $j$-th query equals to $[y_1, y_2, \dots, y_j]$.
-----Input-----
The first line of the input contains two integers $q, x$ ($1 \le q, x \le 4 \cdot 10^5$) β the number of queries and the value of $x$.
The next $q$ lines describe queries. The $j$-th query consists of one integer $y_j$ ($0 \le y_j \le 10^9$) and means that you have to append one element $y_j$ to the array.
-----Output-----
Print the answer to the initial problem after each query β for the query $j$ print the maximum value of MEX after first $j$ queries. Note that queries are dependent (the array changes after each query) but operations are independent between queries.
-----Examples-----
Input
7 3
0
1
2
2
0
0
10
Output
1
2
3
3
4
4
7
Input
4 3
1
2
1
2
Output
0
0
0
0
-----Note-----
In the first example: After the first query, the array is $a=[0]$: you don't need to perform any operations, maximum possible MEX is $1$. After the second query, the array is $a=[0, 1]$: you don't need to perform any operations, maximum possible MEX is $2$. After the third query, the array is $a=[0, 1, 2]$: you don't need to perform any operations, maximum possible MEX is $3$. After the fourth query, the array is $a=[0, 1, 2, 2]$: you don't need to perform any operations, maximum possible MEX is $3$ (you can't make it greater with operations). After the fifth query, the array is $a=[0, 1, 2, 2, 0]$: you can perform $a[4] := a[4] + 3 = 3$. The array changes to be $a=[0, 1, 2, 2, 3]$. Now MEX is maximum possible and equals to $4$. After the sixth query, the array is $a=[0, 1, 2, 2, 0, 0]$: you can perform $a[4] := a[4] + 3 = 0 + 3 = 3$. The array changes to be $a=[0, 1, 2, 2, 3, 0]$. Now MEX is maximum possible and equals to $4$. After the seventh query, the array is $a=[0, 1, 2, 2, 0, 0, 10]$. You can perform the following operations: $a[3] := a[3] + 3 = 2 + 3 = 5$, $a[4] := a[4] + 3 = 0 + 3 = 3$, $a[5] := a[5] + 3 = 0 + 3 = 3$, $a[5] := a[5] + 3 = 3 + 3 = 6$, $a[6] := a[6] - 3 = 10 - 3 = 7$, $a[6] := a[6] - 3 = 7 - 3 = 4$. The resulting array will be $a=[0, 1, 2, 5, 3, 6, 4]$. Now MEX is maximum possible and equals to $7$. | ["import sys\nfrom heapq import *\ninput = sys.stdin.readline\n\nquer, m = list(map(int, input().split()))\n\nvals = list(range(m))\nq = []\nfor v in vals:\n heappush(q, v)\n\nout = []\nfor _ in range(quer):\n nex = int(input()) % m\n vals[nex] += m\n heappush(q, vals[nex])\n\n new = heappop(q)\n while vals[new % m] != new:\n new = heappop(q)\n\n out.append(new)\n heappush(q, new)\n\nprint('\\n'.join(map(str,out)))\n \n", "import sys\ninput = sys.stdin.readline\n\nq,x=list(map(int,input().split()))\n\nseg_el=1<<((x+1).bit_length())\nSEG=[0]*(2*seg_el)\n\ndef add1(n,seg_el):\n i=n+seg_el\n SEG[i]+=1\n i>>=1\n \n while i!=0:\n SEG[i]=min(SEG[i*2],SEG[i*2+1])\n i>>=1\n \ndef getvalues(l,r):\n L=l+seg_el\n R=r+seg_el\n ANS=1<<30\n\n while L<R:\n if L & 1:\n ANS=min(ANS , SEG[L])\n L+=1\n\n if R & 1:\n R-=1\n ANS=min(ANS , SEG[R])\n L>>=1\n R>>=1\n\n return ANS\n\nfor qu in range(q):\n t=int(input())\n add1(t%x,seg_el)\n\n #print(SEG)\n\n MIN=getvalues(0,x)\n\n OK=0\n NG=x\n\n while NG-OK>1:\n mid=(OK+NG)//2\n\n if getvalues(0,mid)>MIN:\n OK=mid\n else:\n NG=mid\n\n #print(MIN,OK)\n print(MIN*x+OK)\n", "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn list(map(int, minp().split()))\n\ndef solve():\n\tn,x = mints()\n\tc = [0]*x\n\tans = 0\n\tfor i in range(n):\n\t\ty = mint()\n\t\tc[y%x] += 1\n\t\twhile c[ans%x] > 0:\n\t\t\tc[ans%x] -= 1\n\t\t\tans += 1\n\t\tprint(ans)\n\nsolve()\n\n", "import sys\n\ndef main():\n input = sys.stdin.readline\n\n q,x = [int(i) for i in input().split()]\n A = [0 for i in range(x)]\n m = 0\n c = 0\n ans = []\n for a in range(q):\n n = int(input())\n A[n%x] += 1\n while A[c] >= (m//x+1):\n c = (c+1)%x\n m += 1\n ans.append(str(m))\n\n print(\"\\n\".join(ans))\n\n\ndef __starting_point():\n main()\n__starting_point()", "from sys import stdin\ninput = stdin.readline\nn, x = map(int,input().split())\nprzyst = [0] * x\nl = []\nbest = 0\nfor i in range(n):\n nju = int(input())\n przyst[nju%x] += 1\n while True:\n if przyst[best%x] != 0:\n best += 1\n przyst[(best-1)%x] -= 1\n else:\n break\n print(best)"] | {
"inputs": [
"7 3\n0\n1\n2\n2\n0\n0\n10\n",
"4 3\n1\n2\n1\n2\n"
],
"outputs": [
"1\n2\n3\n3\n4\n4\n7\n",
"0\n0\n0\n0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 2,500 | |
55151f2f85d90be8f46309507160db08 | UNKNOWN | We have a secret array. You don't know this array and you have to restore it. However, you know some facts about this array:
The array consists of $n$ distinct positive (greater than $0$) integers. The array contains two elements $x$ and $y$ (these elements are known for you) such that $x < y$. If you sort the array in increasing order (such that $a_1 < a_2 < \ldots < a_n$), differences between all adjacent (consecutive) elements are equal (i.e. $a_2 - a_1 = a_3 - a_2 = \ldots = a_n - a_{n-1})$.
It can be proven that such an array always exists under the constraints given below.
Among all possible arrays that satisfy the given conditions, we ask you to restore one which has the minimum possible maximum element. In other words, you have to minimize $\max(a_1, a_2, \dots, a_n)$.
You have to answer $t$ independent test cases.
-----Input-----
The first line of the input contains one integer $t$ ($1 \le t \le 100$) β the number of test cases. Then $t$ test cases follow.
The only line of the test case contains three integers $n$, $x$ and $y$ ($2 \le n \le 50$; $1 \le x < y \le 50$) β the length of the array and two elements that are present in the array, respectively.
-----Output-----
For each test case, print the answer: $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is the $i$-th element of the required array. If there are several answers, you can print any (it also means that the order of elements doesn't matter).
It can be proven that such an array always exists under the given constraints.
-----Example-----
Input
5
2 1 49
5 20 50
6 20 50
5 3 8
9 13 22
Output
1 49
20 40 30 50 10
26 32 20 38 44 50
8 23 18 13 3
1 10 13 4 19 22 25 16 7 | ["def read_int():\n return int(input())\n\n\ndef read_ints():\n return list(map(int, input().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n n, x, y = read_ints()\n d = y - x\n for i in range(n - 1, 0, -1):\n if d % i == 0:\n d //= i\n l = min(n - (i + 1), (x - 1) // d)\n ans = [x - l * d + i * d for i in range(n)]\n print(' '.join(map(str, ans)))\n break\n", "t = int(input())\n# a = list(map(int, input().split()))\nfor _ in range(t):\n n,x,y = map(int,input().split())\n \n \n for d in range(1,y-x+1):\n if (y-x)%d==0 and (y-x)//d <= (n-1):\n offset = y%d\n if offset==0:\n offset=d\n print(' '.join(map(str,(max(y,offset+(n-1)*d) - d*i for i in range(n)))))\n break", "\ndef process(n,x,y):\n x,y=min(x,y),max(x,y)\n print()\n for i1 in reversed(range(1,n)):\n if((y-x)%i1==0):\n c=0\n flag=0\n i=((y-x)//i1)\n while(n>0):\n t=(y-c*i)\n if(t<=0 and flag==0):\n flag=1\n c=1\n if(flag==0):\n print(t,end=\" \")\n else:\n print(y+c*i,end=\" \")\n n-=1\n c+=1\n return\n\n\n\ntests=int(input())\nfor i in range(tests):\n n,x,y=list(map(int,input().split()))\n process(n,x,y)", "def main():\n t = int(input())\n for _ in range(t):\n n, x, y = map(int, input().split())\n ans = 10 ** 10\n dd = -1\n d = y - x\n for i in range(1, d + 1):\n if d % i != 0:\n continue\n cnt = d // i + 1\n if cnt > n:\n continue\n tmp = (x - 1) % i + 1\n ans_sub = max(y, tmp + i * (n - 1))\n if ans_sub < ans:\n ans = ans_sub\n dd = i\n lst = [] \n for j in range(n):\n lst.append(ans)\n ans -= dd\n print(*lst)\nmain()", "def find(n,x,y,diff):\n arr = [x]\n while arr[-1] < y:\n arr.append(arr[-1]+diff)\n\n if arr[-1] != y:\n return False\n\n if len(arr) > n:\n return False\n\n min_val = arr[0]\n while len(arr) != n:\n if min_val-diff > 0:\n arr.append(min_val-diff)\n min_val -= diff\n else:\n break\n\n arr.sort()\n while len(arr) != n:\n arr.append(arr[-1]+diff)\n\n return arr\n\ndef solve(n,x,y,ans):\n for diff in range(1,100):\n arr = find(n,x,y,diff)\n if arr:\n arr1 = []\n for i in arr:\n arr1.append(str(i))\n\n ans.append(arr1)\n return\n\ndef main():\n t = int(input())\n ans = []\n for i in range(t):\n n,x,y = list(map(int,input().split()))\n solve(n,x,y,ans)\n\n for i in ans:\n print(' '.join(i))\n \n\nmain()\n", "# Fast IO (be careful about bytestring)\n\n# import os,io\n# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\nfor _ in range(int(input())):\n n,x,y = list(map(int,input().split()))\n minMax = 100000\n minD = 0\n minStart = 0\n for d in range(1,y - x + 1):\n if (y - x) % d != 0 or d * (n-1) < y - x:\n continue\n minElem = x % d\n if minElem == 0:\n minElem = d\n maxElem = minElem + d * (n-1)\n if maxElem < y:\n maxElem = y\n minElem = maxElem - d * (n-1)\n if maxElem < minMax:\n minMax = maxElem\n minStart = minElem\n minD = d\n ans = []\n elem = minStart\n for i in range(n):\n ans.append(str(elem))\n elem += minD\n print(\" \".join(ans))\n", "for _ in range(int(input())):\n\tn,x,y=map(int,input().split())\n\tmi=1000000000\n\tan=[]\n\tfor d in range(1,y-x+1):\n\t\tif (y-x)%d==0:\n\t\t\tfor a in range(1,x+1):\n\t\t\t\tarr=[a+d*i for i in range(n)]\n\t\t\t\tif x in arr and y in arr:\n\t\t\t\t\tif mi>arr[-1]:\n\t\t\t\t\t\tmi=arr[-1]\n\t\t\t\t\t\tans=arr\n\tprint(*ans)", "import sys\nfrom collections import defaultdict as dd\nfrom collections import deque\nfrom functools import *\nfrom fractions import Fraction as f\nfrom copy import *\nfrom bisect import *\t\nfrom heapq import *\nfrom math import *\nfrom itertools import permutations ,product\n \ndef eprint(*args):\n print(*args, file=sys.stderr)\nzz=1\n \n#sys.setrecursionlimit(10**6)\nif zz:\n\tinput=sys.stdin.readline\nelse:\t\n\tsys.stdin=open('input.txt', 'r')\n\tsys.stdout=open('all.txt','w')\ndef inc(d,c):\n\td[c]=d[c]+1 if c in d else 1\ndef bo(i):\n\treturn ord(i)-ord('A')\t\ndef li():\n\treturn [int(xx) for xx in input().split()]\ndef fli():\n\treturn [float(x) for x in input().split()]\t\ndef comp(a,b):\n\tif(a>b):\n\t\treturn 2\n\treturn 2 if a==b else 0\t\t\ndef gi():\t\n\treturn [xx for xx in input().split()]\ndef fi():\n\treturn int(input())\ndef pro(a): \n\treturn reduce(lambda a,b:a*b,a)\t\t\ndef swap(a,i,j): \n\ta[i],a[j]=a[j],a[i]\t\ndef si():\n\treturn list(input().rstrip())\t\ndef mi():\n\treturn \tmap(int,input().split())\t\t\t\ndef gh():\n\tsys.stdout.flush()\ndef isvalid(i,j):\n\treturn 0<=i<n and 0<=j<n\t\ndef bo(i):\n\treturn ord(i)-ord('a')\t\ndef graph(n,m):\n\tfor i in range(m):\n\t\tx,y=mi()\n\t\ta[x].append(y)\n\t\ta[y].append(x)\n\n\nt=fi()\n\nwhile t>0:\n\tt-=1\n\tn,x,y=mi()\n\tp=n-2\n\tx,y=max(x,y),min(x,y)\n\tfor i in range(1,p+2):\n\t\tif (x-y)%i==0:\n\t\t\tans=i\n\tp=(x-y)//ans\n\tfor i in range(n):\n\t\tif x-i*p<=0:\n\t\t\tbreak\n\t\tmini=x-i*p\t\n\tfor i in range(n):\n\t\tprint(mini+p*i,end=\" \")\n\tprint()\t\t\t\n", "t = int(input())\nwhile t>0:\n n,x,y = list(map(int,input().split()))\n min_val = 1e5\n min_diff = 0\n for xpos in range(0,n-1):\n for ypos in range(xpos+1,n):\n l = ypos-xpos\n if (y-x) % l > 0 :\n continue\n diff = (y-x)/l\n max_item = x + (n-1-xpos)*diff\n if max_item < min_val and (x -(xpos*diff))>=1:\n min_val = int(max_item)\n min_diff = int(diff)\n first_num = min_val - (n-1)*min_diff\n for index in range(0,n):\n print(\"{}\".format(first_num + index*min_diff), end=\" \")\n print(\"\")\n t -= 1\n", "#!/usr/bin/env pypy3\n\ndef ans(n,x,y):\n\tcandidates = set()\n\tfor gap in range(n-1,0,-1):\n\t\tif (y-x) % gap == 0:\n\t\t\tdiff = (y-x) // gap\n\n\t\t\tret = [y]\n\t\t\tfor _ in range(n-1):\n\t\t\t\tret += [ret[-1] - diff]\n\t\t\t\tif ret[-1] <= 0:\n\t\t\t\t\tret = ret[:len(ret)-1]\n\t\t\t\t\tbreak\n\t\t\tret = sorted(ret)\n\t\t\twhile len(ret) < n:\n\t\t\t\tret += [ret[-1] + diff]\n\n\t\t\tcandidates.add(tuple(ret)[::-1])\n\n\tprint(*min(candidates))\n\t\t\nT = int(input())\nfor t in range(T):\n\tN,X,Y = input().split()\n\tX = int(X)\n\tY = int(Y)\n\tN = int(N)\n\n\tans(N,X,Y)", "from collections import defaultdict as dd\nimport sys\ninput=sys.stdin.readline\nt=int(input())\nwhile t:\n #n=int(input())\n n,x,y=list(map(int,input().split()))\n #l=list(map(int,input().split()))\n dif=y-x\n for i in range(n-1,-1,-1):\n if(dif%i==0):\n ind=i\n break\n diff=dif//ind\n arr=[x]\n cou=1\n curr=x\n while curr!=y:\n curr+=diff\n arr.append(curr)\n cou+=1\n left=n-cou\n curr=x\n while left and curr-diff>0:\n curr-=diff\n arr.append(curr)\n left-=1\n curr=y\n while left:\n curr+=diff\n arr.append(curr)\n left-=1\n print(*arr)\n t-=1\n \n \n \n", "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop,heapify\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\n\nfrom itertools import accumulate\nfrom functools import lru_cache\n\nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\n\n\ndef check(diff, x, y, n):\n s = set()\n i = y\n while n and i > 0:\n s.add(i)\n i -= diff\n n -= 1\n i = y + diff\n while n:\n n -= 1\n s.add(i)\n i += diff\n \n return -1 if x not in s else max(s)\n\n\nfor _ in range(val()):\n n, x, y = li()\n\n\n diff = factors(y - x)\n\n for i in range(1, y - x + 1):\n ans = check(i, x, y, n)\n if ans != -1:\n diff = i\n break\n \n\n l = []\n while n:\n l.append(ans)\n n -= 1\n ans -= diff\n print(*l)", "for _ in range(int(input())):\n n,x,y=map(int,input().split())\n ans=[0]*n\n mn=9999999999999999999999999\n for i in range(n-1):\n res=[0]*n\n res[i]=x\n for j in range(i+1,n):\n if (y-x)%(j-i)==0:\n res[j]=y\n ok=1\n f=(y-x)//(j-i)\n for ii in range(i-1,-1,-1):\n res[ii]=res[ii+1]-f\n for jj in range(i+1,n):\n res[jj]=res[jj-1]+f\n if res[-1]<mn and res[0]>0:\n mn=res[-1]\n ans=res\n print(*ans)", "import bisect\nimport copy\nimport fractions\nimport functools\nimport heapq\nimport math\nimport random\nimport sys\n\n\ndef __starting_point():\n\n T = int(input())\n\n for t in range(T):\n N, X, Y = tuple(map(int, input().split()))\n\n # Find smallest possible difference between adjacent elements\n for div in range(1, (Y - X) + 1):\n if (Y - X) % div == 0 and div * (N - 1) >= (Y - X):\n break\n\n # Find minimal range\n max_ = Y\n n = N - math.ceil(Y / div)\n while n > 0:\n max_ += div\n n -= 1\n\n print(' '.join(str(max_ - (i * div)) for i in range(N)))\n\n__starting_point()", "for _ in range(int(input())):\n n, x, y = list(map(int, input().split()))\n i = 1\n ad = []\n bd = []\n while i*i <= y-x:\n if (y-x)%i == 0:\n ad.append(i)\n if i*i != y-x:\n bd.append((y-x)//i)\n i += 1\n ds = ad + bd[::-1]\n best = (float(\"inf\"), 0)\n for d in ds:\n l = (y-x)//d+1\n if l > n:\n continue\n p = n-l\n while x-p*d <= 0:\n p -= 1\n best = min(best, (y+(n-l-p)*d, x-p*d))\n d = (best[0]-best[1])//(n-1)\n print(*list(range(best[1], best[0]+1, d)))\n"] | {
"inputs": [
"5\n2 1 49\n5 20 50\n6 20 50\n5 3 8\n9 13 22\n",
"1\n2 1 49\n"
],
"outputs": [
"1 49 \n10 20 30 40 50 \n20 26 32 38 44 50 \n3 8 13 18 23 \n1 4 7 10 13 16 19 22 25 \n",
"1 49 \n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 10,968 | |
cfaf77f6f7ad94a7a79bd3c107ba5847 | UNKNOWN | You are developing a new feature for the website which sells airline tickets: being able to sort tickets by price! You have already extracted the tickets' prices, so there's just the last step to be done...
You are given an array of integers. Sort it in non-descending order.
-----Input-----
The input consists of a single line of space-separated integers. The first number is n (1 β€ n β€ 10) β the size of the array. The following n numbers are the elements of the array (1 β€ a_{i} β€ 100).
-----Output-----
Output space-separated elements of the sorted array.
-----Example-----
Input
3 3 1 2
Output
1 2 3
-----Note-----
Remember, this is a very important feature, and you have to make sure the customers appreciate it! | ["import time\nimport random\n\nl = list(map(int, input().split()))\nassert len(l) == l[0] + 1\nl = l[1:]\nl.sort()\n\nv = [0 for i in range(10 ** 4)]\nfor i in range(4 * 10**5):\n v[random.randrange(0, len(v))] = random.randrange(-1000, 1000)\n\nprint(' '.join(map(str, l)))\n", "l = list(map(int, input().split()))\nn = l[0]\ndel(l[0])\na = 0\nfor i in range(10**7):\n a += 1\n# for i in range(n):\n# l[i] = str(l[i])\nl.sort()\nprint(*l)\n", "import collections as col\nimport itertools as its\nimport sys\nimport operator\nfrom bisect import bisect_left, bisect_right\nfrom copy import copy, deepcopy\nfrom time import sleep\n\n\nclass Solver:\n def __init__(self):\n pass\n \n def solve(self):\n a = list(map(int, input().split()))\n n = a[0]\n a = a[1:]\n c = 0\n for i in range(10**7):\n c += i\n print(' '.join(map(str, sorted(a))))\n\n\ndef __starting_point():\n s = Solver()\n s.solve()\n\n__starting_point()", "\ndef doStuff():\n l = []\n \n for i in range(4000000):\n l.append((i * i) % 123)\n \n l.sort()\n\ndoStuff()\n\ns = list(map(int, input().split(' ')))[1:]\ns.sort()\n\ns = list(map(str, s))\n\n\nans = ' '.join(s)\nprint(ans)\n", "x = list(map(int, input().split()))[1 : ]\ns = 1\nfor i in range(10000000): s *= i\nprint(*sorted(x))\n", "from random import randint\n\nxs = list(map(int, input().split()))[1:]\nfor _ in range(8 * (10 ** 5)):\n randint(3, 10)\nprint(' '.join(map(str, sorted(xs))))\n\n", "#!/usr/bin/env python3\n\ndef main():\n try:\n while True:\n for i in range(int(3e7)):\n pass\n print(*sorted(map(int, input().split()[1:])))\n\n except EOFError:\n pass\n\nmain()\n", "for i in range(30000000): 1+1\nprint(*sorted( list(map(int, input().split()))[1:]))", "import time\nt = time.time() + 1.9\na = [int(i) for i in input().split(' ') if i]\na = a[1:a[1]+1]\na.sort()\nwhile time.time() < t:\n\tpass\nfor i in a:\n\tprint(i, end=' ')\nprint()\n\n", "import sys\nimport time\n\nfor line in sys.stdin:\n for i in range(20000000):j=i\n vec = line.split()\n val = [str(y) for y in sorted([int(x) for x in vec[1:]])]\n print(' '.join(val))", "import time\n\ndef busy_wait(dt):\n current_time = time.time()\n while (time.time() < current_time+dt):\n pass\n\na = list(map(int, input().split()))\na = a[1:]\nbusy_wait(1.8)\na.sort()\nw = len(str(max(a)))\nprint(a[0], end='')\nfor x in a[1:]:\n print(str(x).rjust(w + 1), end='')\nprint()\n", "arr = input().split()[1:]\nimport time\ncurrent_milli_time = lambda: int(round(time.time() * 1000))\ns = current_milli_time()\nfor i in range(len(arr)):\n for j in range(len(arr) - i - 1):\n if int(arr[j]) > int(arr[j + 1]):\n arr[j], arr[j + 1] = arr[j + 1], arr[j]\nwhile current_milli_time() - s <= 1.5 * 1000:\n pass\nprint(' '.join(arr))\n", "import time\na=input().split()\nn=int(a[0])\ndel(a[0])\na=map(int,a)\na=sorted(a)\nb=[10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30,10,30]\nfor i in range(2500000):\n b=b*i\n sorted(b)\nfor i in range(len(a)):\n print(a[i],end=\" \")\n", "a = list(map(int, input().split()))\nn = a[0]\na = sorted(a[1:])\nx = 1234**500000\nfor i in range(n):\n print('{} '.format(a[i]), end='')\nprint('')\n", "for i in range(0,int(3e7)):\n pass\nprint(' '.join([str(i) for i in sorted([int(x) for x in input().split(' ')[1:]])]))\n", "import time\nkal = list(map(int,input().split()))\np = kal[1:]\nkaleee = []\nfor i in range(6300):\n kaleee.append(i)\n kaleee.count(i)\np.sort()\nfor i in p:\n\tprint(i,end=' ')\n", "# print(' '.join(map(str, sorted([int(x) for x in input().split()][1:]))))\na = [int(x) for x in input().split()][1:]\na.sort()\nres = 0\nfor i in range(7000000):\n\tres ^= i\n\t\nprint(' '.join([str(x) for x in a]))\n", "a = [int(i) for i in input().split()][1:]\nfor i in range(15000000):\n b = (1 == 1)\nprint(*sorted(a))\n", "import sys\nfor i in range(10**6):\n sys.stderr.write(str(i))\nprint(' '.join(map(str,sorted(list(map(int,input().split()[1:]))))))\n", "import time\nstart_ = time.time()\nn, *a = input().split()\na = list(map(int, a))\nprint(' '.join(str(ch) for ch in sorted(a)))\nwhile True:\n if( time.time() - start_ > 1.7 ):\n break\n", "a = list(map(int, input().split()))[1:]\na.sort()\nfor i in range(3 * 10 ** 7):\n continue\nprint(*a)", "a = list(map(int, input().split()))\nb = a[1:]\nb.sort()\nn = 0\nfor i in range(10000000):\n n += 1\nfor i in b:\n print(i, end = \" \")\n", "import time\nli = list(map(int, input().split()))\nn = li.pop(0)\nli.sort()\nfor i in range(20000000):\n s = 0\nprint(\" \".join(map(str, li)))"] | {
"inputs": [
"3 3 1 2\n",
"10 54 100 27 1 33 27 80 49 27 6\n"
],
"outputs": [
"1 2 3 \n",
"1 6 27 27 27 33 49 54 80 100 \n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 4,845 | |
ef4538747a02309bd1de63c4119e3c5a | UNKNOWN | You are given an array $a$ consisting of $n$ integers.
In one move, you can choose two indices $1 \le i, j \le n$ such that $i \ne j$ and set $a_i := a_j$. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose $i$ and $j$ and replace $a_i$ with $a_j$).
Your task is to say if it is possible to obtain an array with an odd (not divisible by $2$) sum of elements.
You have to answer $t$ independent test cases.
-----Input-----
The first line of the input contains one integer $t$ ($1 \le t \le 2000$) β the number of test cases.
The next $2t$ lines describe test cases. The first line of the test case contains one integer $n$ ($1 \le n \le 2000$) β the number of elements in $a$. The second line of the test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 2000$), where $a_i$ is the $i$-th element of $a$.
It is guaranteed that the sum of $n$ over all test cases does not exceed $2000$ ($\sum n \le 2000$).
-----Output-----
For each test case, print the answer on it β "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.
-----Example-----
Input
5
2
2 3
4
2 2 8 8
3
3 3 3
4
5 5 5 5
4
1 1 1 1
Output
YES
NO
YES
NO
NO | ["for _ in range(int(input())):\n n = int(input())\n ar = list(map(int, input().split()))\n a, b = 0, 0\n for elem in ar:\n if elem % 2 == 0:\n a = 1\n else:\n b = 1\n if sum(ar) % 2 == 1:\n print('YES')\n elif a == 1 == b:\n print('YES')\n else:\n print('NO')", "for _ in range(int(input())):\n n = int(input())\n A = list(map(int, input().split()))\n c1, c2 = 0, 0\n for i in A:\n if i % 2:\n c1 += 1\n else:\n c2 += 1\n if c1 == 0:\n print('NO')\n elif c2 == 0:\n if n% 2:\n print('YES')\n else:\n print('NO')\n else:\n print('YES')\n\n", "import math\nfrom decimal import Decimal\nimport heapq\nimport copy\nimport heapq\nfrom collections import deque\ndef na():\n\tn = int(input())\n\tb = [int(x) for x in input().split()]\n\treturn n,b\n \n\t\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\t\t\ndef dv():\n\tn, m = list(map(int, input().split()))\n\treturn n,m\n \n \ndef da():\n\tn, m = list(map(int, input().split()))\n\ta = list(map(int, input().split()))\n\treturn n,m, a \n \n \ndef dva():\n\t\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 \ndef lol(lst,k):\n\tk=k%len(lst)\n\tret=[0]*len(lst)\n\tfor i in range(len(lst)):\n\t\tif i+k<len(lst) and i+k>=0:\n\t\t\tret[i]=lst[i+k]\n\t\tif i+k>=len(lst):\n\t\t\tret[i]=lst[i+k-len(lst)]\n\t\tif i+k<0:\n\t\t\tret[i]=lst[i+k+len(lst)]\n\treturn(ret)\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\ndef fact(n):\n\ttc = []\n\tans = {}\n\td = 2\n\twhile d * d <= n:\n\t\tif n % d == 0:\n\t\t\ttc.append(d)\n\t\t\tn //= d\n\t\telse:\n\t\t\td += 1\n\tif n > 1:\n\t\ttc.append(n)\n\tfor i in tc:\n\t\tans[i] = ans.get(i, 0) + 1\n\treturn ans\n\n\nfor i in range(int(input())):\n\t\tn, a = na()\n\t\tnech = 0\n\t\ts = 0\n\t\tfor j in a:\n\t\t\tif j % 2 == 1:\n\t\t\t\tnech += 1\n\t\t\ts += j\n\t\tif s % 2 == 1:\n\t\t\tprint('YES')\n\t\t\tcontinue\n\t\tif nech == n or nech == 0:\n\t\t\tprint('NO')\n\t\telse:\n\t\t\tprint('YES')\n", "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\n\n\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=2):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n newnumber = 0\n while number > 0:\n newnumber += number % base\n number //= base\n return newnumber\ndef cdiv(n, k): return n // k + (n % k != 0)\n\n\nt = ii()\nfor _ in range(t):\n n = ii()\n a = li()\n if all(a[i] & 1 for i in range(n)) and not n & 1 or all(not a[i] & 1 for i in range(n)):\n print('NO')\n else:\n print('YES')", "def iinput():\n return [int(x) for x in input().split()]\n\n\ndef main():\n n = int(input())\n data = iinput()\n count = 0\n for i in range(n):\n if data[i] % 2 == 1:\n count += 1\n if count == 0 or (count == n and n % 2 == 0):\n return 'NO'\n else:\n return 'YES'\n\n\nfor t in range(int(input())):\n print(main())\n", "t=int(input())\nfor _ in range(t):\n n=int(input())\n it=list(map(int,input().split()))\n s=[i for i in it if i%2==1]\n if(len(s)>=1 and (len(s)<n or n%2==1)):\n print(\"YES\")\n else:\n print(\"NO\")\n", "t=int(input())\nwhile(t):\n t-=1\n n=int(input())\n a=list(map(int,input().split()))\n co=0\n for i in a:\n if(i%2):\n co+=1\n if((co==n and n%2==0) or co==0):\n print(\"NO\")\n else:\n print(\"YES\")\n", "t=int(input())\nfor i in range(t):\n n=int(input())\n a=list(map(int,input().split()))\n odd,even=False,False\n for i in a:\n if i%2==0:\n even=True\n else:\n odd=True\n if odd and even:\n print('YES')\n break\n else:\n if odd and (not even) and n%2==1:\n print('YES')\n else:\n print('NO')\n", "t = int(input())\nfor zz in range(t):\n n = int(input())\n a = [int(i) for i in input().split()]\n ha = False\n ho = False\n he = False\n for i in a:\n if i % 2 == 1:\n ho = True\n else:\n he = True\n if n % 2 == 0:\n ha = ho and he\n else:\n ha = ho\n if ha:\n print('YES')\n else:\n print('NO')\n", "import math, collections, sys\ninput = sys.stdin.readline\nfor _ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n oc = 0\n for i in a:\n oc+=i%2\n if oc:\n if oc%2:\n print(\"YES\")\n else:\n if n-oc:\n print(\"YES\")\n else:\n print(\"NO\")\n else:\n print(\"NO\")", "t = int(input())\nfor _ in range(t):\n n = int(input())\n a = [int(i) for i in input().split()]\n o = 0\n for i in a:\n if i%2 != 0:\n o += 1\n if o == 0:\n print(\"NO\")\n elif o == n and n%2 == 0:\n print(\"NO\")\n elif o == n and n%2 == 1:\n print(\"YES\")\n else:\n print(\"YES\")\n", "def solve(arr,n):\n even = 0\n for i in arr:\n if i%2 == 0:\n even += 1\n\n if even == n:\n print('NO')\n return\n \n odd = n-even\n\n if odd == n and n%2 == 0:\n print('NO')\n return\n \n print('YES')\n\ndef main():\n t = int(input())\n for i in range(t):\n n = int(input())\n arr = list(map(int,input().split()))\n solve(arr,n)\n\n \nmain()\n", "n = int(input())\nfor i in range(n):\n num = int(input())\n lst = list(map(int, input().split()))\n even = 0\n odd = 0\n for j in lst:\n if j % 2 == 0:\n even+=1\n else:\n odd+=1\n if odd == 0 or (odd == num and num % 2 == 0):\n print(\"NO\")\n else:\n print(\"YES\")", "\n\nfor _ in range(int(input())):\n n = int(input())\n a = [int(i) for i in input().split()]\n \n if sum(a) % 2 == 1:\n print('YES')\n \n \n else:\n par = False\n impar = False\n for i in a:\n if i % 2 == 0:\n par = True\n else:\n impar = True\n if par and impar:\n print('YES')\n else:\n print('NO')\n \n\n\n", "for _ in range(int(input())):\n\tn = int(input())\n\tarr = list(map(int, input().split()))\n\tif sum(arr)%2 == 1:\n\t\tprint('YES')\n\telif all(ele%2 == 0 for ele in arr):\n\t\tprint('NO')\n\telif all(ele%2 == 1 for ele in arr) and len(arr)%2 == 0:\n\t\tprint('NO')\n\telse:\n\t\tprint('YES')"] | {
"inputs": [
"5\n2\n2 3\n4\n2 2 8 8\n3\n3 3 3\n4\n5 5 5 5\n4\n1 1 1 1\n",
"1\n1\n114\n"
],
"outputs": [
"YES\nNO\nYES\nNO\nNO\n",
"NO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 8,464 | |
922e3c01b1238dd35522f13af26d1388 | UNKNOWN | A permutation of length $n$ is an array $p=[p_1,p_2,\dots,p_n]$, which contains every integer from $1$ to $n$ (inclusive) and, moreover, each number appears exactly once. For example, $p=[3,1,4,2,5]$ is a permutation of length $5$.
For a given number $n$ ($n \ge 2$), find a permutation $p$ in which absolute difference (that is, the absolute value of difference) of any two neighboring (adjacent) elements is between $2$ and $4$, inclusive. Formally, find such permutation $p$ that $2 \le |p_i - p_{i+1}| \le 4$ for each $i$ ($1 \le i < n$).
Print any such permutation for the given integer $n$ or determine that it does not exist.
-----Input-----
The first line contains an integer $t$ ($1 \le t \le 100$) β the number of test cases in the input. Then $t$ test cases follow.
Each test case is described by a single line containing an integer $n$ ($2 \le n \le 1000$).
-----Output-----
Print $t$ lines. Print a permutation that meets the given requirements. If there are several such permutations, then print any of them. If no such permutation exists, print -1.
-----Example-----
Input
6
10
2
4
6
7
13
Output
9 6 10 8 4 7 3 1 5 2
-1
3 1 4 2
5 3 6 2 4 1
5 1 3 6 2 4 7
13 9 7 11 8 4 1 3 5 2 6 10 12 | ["T = int(input())\nfor _ in range(T):\n n = int(input())\n if n <= 3:\n print(-1)\n else:\n left = []\n for i in range(1, n + 1, 2):\n left.append(i)\n right = []\n right.append(4)\n right.append(2)\n for i in range(6, n + 1, 2):\n right.append(i)\n right.reverse()\n\n for i in left:\n right.append(i)\n \n for i in right:\n print(i, end = \" \")\n print(\"\")", "t = int(input())\nfor __ in range(t):\n n = int(input())\n if n <= 3:\n print(-1)\n else:\n ps = [[2,4,1,3],[3,1,4,2,5],[1,4,2,5,3,6],[5,1,3,6,2,4,7]]\n ret = ps[n%4]\n for i in range((n%4) + 4, n, 4):\n ret.extend([i+2,i+4,i+1,i+3])\n print(\" \".join(map(str, ret)))", "# ========= /\\ /| |====/|\n# | / \\ | | / |\n# | /____\\ | | / |\n# | / \\ | | / |\n# ========= / \\ ===== |/====| \n# code\n\ndef main():\n t = int(input())\n for _ in range(t):\n n = int(input())\n if n == 2 or n == 3:\n print(-1)\n continue\n if n == 4:\n print('3 1 4 2')\n continue\n a = [2 * i + 1 for i in range((n + 1) // 2)]\n a.append(a[-1] - 3)\n if a[-1] + 2 == (n // 2) * 2:\n a.append(a[-1] + 2)\n else:\n a.append(a[-1] + 4)\n b = [2 * i + 2 for i in range(n // 2)]\n b = b[::-1]\n for i in b:\n if i not in a:\n a.append(i)\n print(*a)\n return\n\ndef __starting_point():\n main()\n__starting_point()", "t = int(input())\nfor aoaoao in range(t):\n n = int(input())\n if n == 1:\n print(1)\n elif n < 5:\n \tif n == 4:\n \t\tprint(\"3 1 4 2\")\n \telse:\n\t print(-1)\n else:\n a = [[], [], [], [], []]\n a[0] = [1, 3, 5, 2, 4]\n a[1] = [1, 3, 5, 2, 6, 4]\n a[2] = [1, 3, 5, 7, 4, 2, 6]\n a[3] = [1, 3, 5, 8, 6, 2, 4, 7]\n a[4] = [1, 3, 5, 9, 7, 4, 2, 6, 8]\n f = -1\n for x in a[n % 5]:\n print(x, end = \" \")\n f = max(a[n % 5])\n while f < n:\n for x in a[0]:\n print(f + x, end = \" \")\n f += 5\n print()\n ", "def Zs(): return list(map(int, input().split()))\ndef Z(): return int(input())\n\ndef solve(n):\n if n <= 3: return None\n ans = []\n k = 1\n while n >= 8:\n ans.extend([k + 1, k + 3, k, k + 2])\n n -= 4\n k += 4\n if n == 4:\n ans.extend([x + k for x in [2, 0, 3, 1]])\n elif n == 5:\n ans.extend([x + k for x in [2, 0, 4, 1, 3]])\n elif n == 6:\n ans.extend([x + k for x in [2, 0, 4, 1, 3, 5]])\n else:\n ans.extend([x + k for x in [2, 0, 4, 1, 5, 3, 6]])\n return ans\n\nfor _ in range(Z()):\n n = Z()\n ans = solve(n)\n if ans is not None:\n print(*ans)\n else:\n print(-1)\n\n\n", "for _ in range(int(input())):\n\tn = int(input())\n\tif n == 4:\n\t\tprint(3, 1, 4, 2)\n\t\tcontinue\n\tif n < 5:\n\t\tprint(-1)\n\t\tcontinue\n\tarr = []\n\tdone = [False] * n\n\tfor i in range(0, n, 2):\n\t\tarr.append(i)\n\t\tdone[i] = True\n\tfor i in range(arr[-1]-3, 0, -4):\n\t\tarr.append(i)\n\t\tdone[i] = True\n\tfor i in range(n):\n\t\tif not done[i]:\n\t\t\tarr.append(i)\n\n\tprint(*[e+1 for e in arr])\n", "def solve(l,r):\n\tn=r-l+1\n\t#print(l,r,n)\n\tif n==0:\n\t\treturn []\n\telif n%4==0:\n\t\treturn [l+1,l+3,l,l+2]+solve(l+4,r)\n\telif n%4==1:\n\t\treturn [l]+solve(l+1,r)\n\telif n%4==2:\n\t\treturn [l]+solve(l+1,r-1)+[r]\n\treturn [5, 1, 3, 6, 2, 4, 7]+solve(l+7,r)\nt=int(input())\nfor i in range(t):\n\tn=int(input())\n\tif n<=3:\n\t\tprint(-1)\n\telse:\n\t\tprint(*solve(1,n))", "#!/usr/bin/env python3\nfrom sys import stdin\nimport collections\n\n\ndef solve(tc):\n n = int(stdin.readline().strip())\n if n<4:\n print(-1)\n return\n base = collections.deque()\n base.extend([2,4,1,3])\n p = 5\n while p+1<=n:\n base.append(p)\n base.appendleft(p+1)\n p += 2\n \n if p==n:\n base.append(p)\n\n for x in base:\n print(x, end=' ')\n print()\n \nLOCAL_TEST = not __debug__\nif LOCAL_TEST:\n infile = __file__.split('.')[0] + \"-test.in\"\n stdin = open(infile, 'r')\n\ntcs = int(stdin.readline().strip())\ntc = 1\nwhile tc <= tcs:\n solve(tc)\n tc += 1", "from sys import stdin\n \nfor _ in range(int(stdin.readline())):\n inp = int(stdin.readline())\n if inp<4:\n print('-1')\n else:\n odd = list(range(5,inp+1,2))\n odd.reverse()\n even = list(range(6,inp+1,2))\n r = odd+[3,1,4,2]+even\n print(' '.join(map(str,r)))\n \n", "# cook your dish here\nt=int(input())\nfor _ in range(t):\n n=int(input())\n if n==2 or n==3 :\n print(-1)\n #break\n elif n==4:\n print(\"3 1 4 2\")\n else:\n c=1\n if n%2==0:\n for i in range(1,n,2):\n print(i,end=\" \")\n if n-4>0:\n print(n-4,end=\" \")\n for i in range(n,0,-2):\n if i !=(n-4) and i!=0:\n print(i,end=\" \")\n else:\n for i in range(1,n+1,2):\n print(i,end=\" \")\n if n-3>0:\n print(n-3,end=\" \")\n for i in range(n-1,0,-2):\n if i!=(n-3) and i!=0:\n print(i,end=\" \")\n \n \n print()\n \n ", "t = int(input())\nfor _ in range(t):\n out = []\n works = True\n n = int(input())\n while n:\n if n == 1:\n out.append(1)\n break\n elif n == 2:\n works = False\n break\n elif n == 3:\n works = False\n break\n elif n == 4:\n out += [3, 1, 4, 2]\n break\n elif n == 5:\n out += [5,2,4,1,3]\n break\n elif n == 7:\n out += [7, 4, 2, 6, 3, 1, 5]\n break\n elif n == 8:\n out += [8, 4, 7, 3, 6, 2, 5, 1]\n break\n elif n == 9:\n out += [9, 7, 4, 2, 6, 8, 5, 1, 3]\n break\n else:\n out.append(n)\n out.append(n - 3)\n out.append(n - 1)\n out.append(n - 4)\n out.append(n - 2)\n n -= 5\n if works:\n print(*out)\n else:\n print(-1)\n \n", "t = int( input() )\n\nfor i in range( t ):\n n = int( input() )\n\n if n<=3:\n print( \"-1\" )\n continue\n\n ans = [ 2 , 4 , 1 , 3 ]\n\n m = 4\n idx = 1\n\n while m < n:\n m = m+1\n ans.append( m )\n\n m = m+1\n if m<=n:\n idx = 1\n while idx < len( ans ):\n if m-ans[idx-1] >= 2 and m-ans[idx-1]<=4 and m-ans[idx]>=2 and m-ans[idx]<=4:\n break\n idx = idx+1\n ans.insert( idx , m ) \n\n for p in ans:\n print( p , end = \" \" )\n print( \"\\n\" ) \n\n\n ", "t = int(input())\nfor i in range(t):\n n=int(input())\n if n==2:\n print(-1)\n continue\n if n==3:\n print(-1)\n continue\n if n==4:\n print(3,1,4,2)\n continue\n if n==5:\n print(1,3,5,2,4)\n continue\n if n%2==0:\n for i in range(n//2):\n print(i*2+1,end=' ')\n print(n - 4, n, n - 2, end=' ')\n for i in range(n//2-3):\n print(n-6-2*i, end=' ')\n print()\n if n%2==1:\n for i in range(n//2+1):\n print(i*2+1,end=' ')\n print(n-3, n-1, end=' ')\n for i in range(n//2-2):\n print(n-5-2*i, end=' ')\n print()\n \n \n ", "t = int(input())\n\nwhile t!=0:\n t-=1 \n n = int(input())\n if n==2 or n==3:\n print(-1)\n else:\n odd = [i for i in range(1,n+1,2)]\n eve = [i for i in range(2, n+1,2)]\n odd.reverse()\n eve[0] , eve[1] = eve[1] , eve[0]\n odd+=eve \n print(*odd)\n", "t = int(input())\nfor _ in range(t):\n\tn = int(input())\n\tif n == 2 or n == 3:\n\t\tprint(-1)\n\t\tcontinue\n\tif n >= 4:\n\t\tans = []\n\t\tif n%4 == 0:\n\t\t\tfor i in range(1, n+1, 4):\n\t\t\t\tans += [i+1, i+3, i, i+2]\n\t\telse:\n\t\t\td = n//4 - 1\n\t\t\tcur = 1\n\t\t\tfor i in range(d):\n\t\t\t\tans += [cur+1, cur+3, cur, cur+2]\n\t\t\t\tcur += 4\n\t\t\tif n%4 == 1:\n\t\t\t\tans += [cur+1, cur+3, cur, cur+2, cur+4]\n\t\t\telif n%4 == 2:\n\t\t\t\tans += [cur, cur+2, cur+4, cur+1, cur+3, cur+5]\n\t\t\telse:\n\t\t\t\tans += [cur, cur+3, cur+1, cur+5, cur+2, cur+4, cur+6]\t\t\t\t\n\n\n\t\tprint(*ans)\n", "# HEY STALKER\nfor _ in range(int(input())):\n n = int(input())\n if n <= 3:\n print(-1)\n else:\n k = []\n for t in range(n, 0, -2):\n k.append(t)\n l = []\n for t in range(n-3, 0, -2):\n l.append(t)\n l.insert(1, n-1)\n l.reverse()\n print(*l, *k)", "for _ in range(int(input())):\n n = int(input())\n ar = []\n kek = set()\n for i in range(1, n + 1):\n kek.add(i)\n kek.discard(n - 1)\n ar.append(n - 1)\n for i in range(n):\n if ar[-1] - 3 in kek:\n kek.discard(ar[-1] - 3)\n ar.append(ar[-1] - 3)\n elif ar[-1] - 2 in kek:\n kek.discard(ar[-1] - 2)\n ar.append(ar[-1] - 2)\n elif ar[-1] - 4 in kek:\n kek.discard(ar[-1] - 4)\n ar.append(ar[-1] - 4)\n elif ar[-1] + 3 in kek:\n kek.discard(ar[-1] + 3)\n ar.append(ar[-1] + 3)\n elif ar[-1] + 2 in kek:\n kek.discard(ar[-1] + 2)\n ar.append(ar[-1] + 2)\n elif ar[-1] + 4 in kek:\n kek.discard(ar[-1] + 4)\n ar.append(ar[-1] + 4)\n if n == 2 or n == 3 or n == 1:\n print(-1)\n else:\n print(*ar)"] | {"inputs": ["6\n10\n2\n4\n6\n7\n13\n", "7\n4\n3\n5\n4\n4\n4\n4\n"], "outputs": ["2 4 1 3 6 8 5 9 7 10 \n-1\n2 4 1 3 \n2 4 1 5 3 6 \n2 4 1 5 7 3 6 \n2 4 1 3 6 8 5 7 10 12 9 13 11 \n", "2 4 1 3 \n-1\n2 4 1 5 3 \n2 4 1 3 \n2 4 1 3 \n2 4 1 3 \n2 4 1 3 \n"]} | INTRODUCTORY | PYTHON3 | CODEFORCES | 10,118 | |
34ba9b01f43c31333c89c16420edbb4f | UNKNOWN | You are given an array $a[0 \ldots n-1]$ of length $n$ which consists of non-negative integers. Note that array indices start from zero.
An array is called good if the parity of each index matches the parity of the element at that index. More formally, an array is good if for all $i$ ($0 \le i \le n - 1$) the equality $i \bmod 2 = a[i] \bmod 2$ holds, where $x \bmod 2$ is the remainder of dividing $x$ by 2.
For example, the arrays [$0, 5, 2, 1$] and [$0, 17, 0, 3$] are good, and the array [$2, 4, 6, 7$] is bad, because for $i=1$, the parities of $i$ and $a[i]$ are different: $i \bmod 2 = 1 \bmod 2 = 1$, but $a[i] \bmod 2 = 4 \bmod 2 = 0$.
In one move, you can take any two elements of the array and swap them (these elements are not necessarily adjacent).
Find the minimum number of moves in which you can make the array $a$ good, or say that this is not possible.
-----Input-----
The first line contains a single integer $t$ ($1 \le t \le 1000$)Β β the number of test cases in the test. Then $t$ test cases follow.
Each test case starts with a line containing an integer $n$ ($1 \le n \le 40$)Β β the length of the array $a$.
The next line contains $n$ integers $a_0, a_1, \ldots, a_{n-1}$ ($0 \le a_i \le 1000$)Β β the initial array.
-----Output-----
For each test case, output a single integerΒ β the minimum number of moves to make the given array $a$ good, or -1 if this is not possible.
-----Example-----
Input
4
4
3 2 7 6
3
3 2 6
1
7
7
4 9 2 1 18 3 0
Output
2
1
-1
0
-----Note-----
In the first test case, in the first move, you can swap the elements with indices $0$ and $1$, and in the second move, you can swap the elements with indices $2$ and $3$.
In the second test case, in the first move, you need to swap the elements with indices $0$ and $1$.
In the third test case, you cannot make the array good. | ["\n\nfor _ in range(int(input())):\n\tn=int(input())\n\ta=list(map(int,input().split()))\n\n\tod=0\n\tev=0\n\n\tfor i in range(n):\n\t\tif(i&1):\n\t\t\tif(a[i]%2==0):\n\t\t\t\tod+=1\n\t\telse:\n\t\t\tif(a[i]&1):\n\t\t\t\tev+=1\n\n\tif(od!=ev):\n\t\tprint(-1)\n\telse:\n\t\tprint(od)", "for _ in range(int(input())):\n n=int(input())\n a=list(map(int,input().split()))\n c1,c2=0,0\n for i in range(n):\n if(i%2==0 and a[i]%2!=0):\n c1+=1\n if(i%2==1 and a[i]%2!=1):\n c2+=1\n if(c1!=c2):\n print(-1)\n else:\n print(c1)", "import sys\nINF = 10**20\nMOD = 10**9 + 7\nI = lambda:list(map(int,input().split()))\nfrom math import gcd\nfrom math import ceil\nfrom collections import defaultdict as dd, Counter\nfrom bisect import bisect_left as bl, bisect_right as br\n\ndef solve():\n n, = I()\n a = I()\n count = [0, 0, 0]\n for i in range(n):\n if i % 2 == a[i] % 2:\n continue\n count[a[i] % 2] += 1\n if count[0] != count[1]:\n print(-1)\n else:\n print(count[0])\n\nt, = I()\nwhile t:\n t -= 1\n solve()", "import sys\nimport random\nfrom math import *\n \ndef input():\n return sys.stdin.readline().strip()\n \ndef iinput():\n return int(input())\n\ndef finput():\n return float(input())\n\ndef tinput():\n return input().split()\n\ndef linput():\n return list(input())\n \ndef rinput():\n return map(int, tinput())\n\ndef fiinput():\n return map(float, tinput())\n \ndef rlinput():\n return list(map(int, input().split()))\ndef trinput():\n return tuple(rinput())\n\ndef srlinput():\n return sorted(list(map(int, input().split())))\n\ndef YESNO(fl):\n if fl:\n print(\"NO\")\n else:\n print(\"YES\")\n \n \ndef main(): \n n = iinput() \n #k = iinput() \n #m = iinput() \n #n = int(sys.stdin.readline().strip()) \n #n, k = rinput()\n #n, m = rinput()\n #m, k = rinput()\n #n, k, m = rinput()\n #n, m, k = rinput()\n #k, n, m = rinput()\n #k, m, n = rinput() \n #m, k, n = rinput()\n #m, n, k = rinput()\n #q = srlinput()\n q = rlinput()\n t = 0\n for i in range(n):\n q[i] %= 2\n if q[i] != i % 2:\n t += 1\n if sum(q) != n // 2:\n print(-1)\n else:\n print(t // 2)\n \n\n \n \n \n \n \n \n \n \nfor inytd in range(iinput()):\n main()", "T = int(input())\n\nfor t in range(T):\n N = int(input())\n A = [int(_) for _ in input().split()]\n badE, badO = 0, 0\n for i, el in enumerate(A):\n if el%2 != i%2:\n if i%2:\n badO += 1\n else:\n badE += 1\n if badO != badE:\n print(-1)\n else:\n print(badO)\n", "tests = int(input())\nfor _ in range(tests):\n n = int(input())\n sp = list(map(int, input().split()))\n ch = 0\n for i in sp:\n if i % 2 == 0:\n ch += 1\n if ch != n - n // 2:\n print(-1)\n continue\n count = 0\n for i in range(n):\n if i % 2 != sp[i] % 2:\n count += 1\n print(count // 2)\n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n a = list(map(int,input().split()))\n badEven = 0\n badOdd = 0\n for i in range(n):\n if i % 2 != a[i] % 2 and i % 2 == 0:\n badEven += 1\n elif i % 2 != a[i] % 2 and i % 2 == 1:\n badOdd += 1\n if badEven == badOdd:\n print(badEven)\n else:\n print(-1)", "for _ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n\n l = []\n\n for i in range(n):\n if a[i] % 2 != i % 2:\n l.append(a[i])\n\n oc = sum(i % 2 for i in l)\n ec = len(l) - oc\n\n if oc != ec:\n print(-1)\n continue\n else:\n print(oc)", "import sys\ninput = sys.stdin.readline\nfor nt in range(int(input())):\n\tn = int(input())\n\ta = list(map(int,input().split()))\n\to,e = 0,0\n\tfor i in a:\n\t\tif i%2:\n\t\t\to+=1\n\t\telse:\n\t\t\te+=1\n\tif o!=e and e!=o+1:\n\t\tprint (-1)\n\t\tcontinue\n\tcount = 0\n\tfor i in range(n):\n\t\tif i%2!=a[i]%2:\n\t\t\tcount += 1\n\tprint (count//2)", "from collections import Counter, defaultdict\n\nBS=\"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\ndef to_base(s, b):\n res = \"\"\n while s:\n res+=BS[s%b]\n s//= b\n return res[::-1] or \"0\"\nalpha = \"abcdefghijklmnopqrstuvwxyz\"\nfrom math import floor, ceil,pi\n\nt = int(input())\nfor i in range(t):\n n = int(input())\n arr = list(map(int, input().split()))\n oddWrong = 0\n evenWrong = 0\n for i in range(len(arr)):\n if i%2==0:\n if arr[i]%2==1:\n evenWrong += 1\n else:\n if arr[i]%2==0:\n oddWrong += 1\n\n if oddWrong==evenWrong:\n print(oddWrong)\n else:\n print(-1)", "t = int(input())\n\nfor case in range(t):\n n = int(input())\n a = [int(x) for x in input().split()]\n\n odd_wrong = 0\n even_wrong = 0\n\n for i, x in enumerate(a):\n if x % 2 == 0 and i % 2 == 1:\n even_wrong += 1\n\n if x % 2 == 1 and i % 2 == 0:\n odd_wrong += 1\n\n if odd_wrong == even_wrong:\n print(odd_wrong)\n else:\n print(-1)\n", "for tc in range(int(input())):\n n = int(input())\n a = [int(s) for s in input().split()]\n\n cnt = [0, 0]\n for i, e in enumerate(a):\n if i % 2 != e % 2:\n cnt[i % 2] += 1\n\n if cnt[0] != cnt[1]:\n print(-1)\n else:\n print(cnt[0])\n", "for __ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n c = 0\n d = 0\n for i in range(n):\n if a[i] % 2 != i % 2:\n if a[i] % 2 == 1:\n c += 1\n else:\n d += 1\n if c == d:\n print(c)\n else:\n print(-1)", "def read_int():\n return int(input())\n\n\ndef read_ints():\n return list(map(int, input().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n n = read_int()\n a = list(read_ints())\n o2e = 0\n e2o = 0\n for i in range(n):\n if i % 2 == 0 and a[i] % 2 != 0:\n o2e += 1\n if i % 2 != 0 and a[i] % 2 == 0:\n e2o += 1\n print(-1 if o2e != e2o else o2e)\n", "for _ in range(int(input())):\n n=int(input())\n a=list(map(int, input().split()))\n e=0\n o=0\n for i in range(n):\n if i%2!=a[i]%2:\n if (i%2):\n e+=1\n else:\n o+=1\n if o==e:\n print(o)\n else:\n print(-1)", "\"\"\"\nAuthor: Q.E.D\nTime: 2020-06-16 09:39:00\n\"\"\"\nT = int(input())\nfor _ in range(T):\n n = int(input())\n a = list(map(int, input().split()))\n odd = 0\n even = 0\n for i, x in enumerate(a):\n if i % 2 == 1 and x % 2 == 0:\n odd += 1\n elif i % 2 == 0 and x % 2 == 1:\n even += 1\n if odd == even:\n ans = odd\n else:\n ans = -1\n print(ans)\n", "import sys\nimport math\nfrom math import factorial as f\nfrom collections import defaultdict as dd\nmod=1000000007\nT=1\nT=int(sys.stdin.readline())\nfor _ in range(T):\n n=int(input())\n l=list(map(int,input().split()))\n c1,c2=0,0\n for i in range(n):\n if(l[i]&1):\n if i&1==0:\n c1+=1\n else:\n if(i&1):\n c2+=1\n if c1!=c2:\n print(-1)\n else:\n print(c1)\n \n", "for t in range(int(input())):\n n = int(input())\n a = [int(x) for x in input().split()]\n wrong0 = sum([1 if a[i]%2 != i%2 else 0 for i in range(n) if i%2==0])\n wrong1 = sum([1 if a[i]%2 != i%2 else 0 for i in range(n) if i%2==1])\n print(wrong0 if wrong0==wrong1 else -1)", "q = int(input())\nfor _ in range(q):\n n = int(input())\n l = list(map(int,input().split()))\n zlep = 0\n zlen = 0\n for i in range(n):\n if i%2 == 0:\n zlep += (i-l[i])%2\n else:\n zlen += (i-l[i])%2\n if zlen == zlep:\n print(zlen)\n else:\n print(-1)", "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\nfor _ in range(val()):\n n = val()\n a = li()\n ans = evens = odds = 0\n for i in range(n):\n if a[i]&1 == i&1:continue\n elif a[i]&1:odds += 1\n else:evens += 1\n if evens != odds:\n print(-1)\n else:\n print(evens)\n", "def mi():\n return map(int, input().split())\n\n\n'''\n4\n4\n3 2 7 6\n3\n3 2 6\n1\n7\n7\n4 9 2 1 18 3 0\n'''\nfor _ in range(int(input())):\n n = int(input())\n a = list(mi())\n\n o, e = 0,0\n for i in range(n):\n if i%2:\n if a[i]%2==0:\n o+=1\n else:\n if a[i]%2:\n e+=1\n if o==e:\n print(o)\n else:\n print (-1)", "def help():\n\tn = int(input())\n\tarr = list(map(int,input().split(\" \")))\n\n\tev = []\n\tod = []\n\n\tfor i in range(n):\n\t\tif(arr[i]%2==1):\n\t\t\tif(arr[i]%2!=i%2):\n\t\t\t\tod.append(i)\n\t\telse:\n\t\t\tif(arr[i]%2!=i%2):\n\t\t\t\tev.append(i)\n\tif(len(ev)==len(od)):\n\t\tprint(len(ev))\n\telse:\n\t\tprint(-1)\n\n\nfor _ in range(int(input())):\n\thelp()", "t=int(input())\nfor i in range(t):\n n=int(input())\n a=[int(i) for i in input().split()]\n nch=0\n ch=0\n for i in range(n):\n if a[i]%2==0 and i%2==1:\n ch+=1\n elif a[i]%2==1 and i%2==0:\n nch+=1\n if nch!=ch:\n print(-1)\n else:\n print(ch)", "t=1\nt=int(input())\nfor _ in range(t):\n\tn=int(input())\n\tarr=list(map(int,input().split()))\n\tl=[0,0]\n\tfor i in range(n):\n\t\tif arr[i]%2!=i%2:\n\t\t\tl[i%2]+=1\n\tif l[0]==l[1]:\n\t\tprint(l[0])\n\telse:\n\t\tprint(-1)\n", "for _ in range(int(input())):\n input()\n l = list(map(int, input().split()))\n e = 0\n o = 0\n for i in range(len(l)):\n if l[i] % 2 != i % 2:\n if i % 2 == 0:\n e += 1\n else:\n o += 1\n print(-1 if e != o else e)", "n = int(input())\n\nfor _ in range(n):\n input()\n a = list(map(int, input().split()))\n c_e, c_n = 0, 0\n for i, x in enumerate(a):\n if i % 2 == 0 and x % 2 == 1:\n c_e += 1\n if i % 2 == 1 and x % 2 == 0:\n c_n += 1\n if c_e != c_n:\n print(-1)\n else:\n print(c_e)\n", "for _ in range(int(input())):\n am = int(input())\n arr = list(map(int,input().split()))\n bad = [0,0]\n fl = False\n for i in range(am):\n if arr[i]&1 != i&1:\n bad[i&1]+=1\n fl = True\n if not fl:\n print(0)\n else:\n if bad[0]!=bad[1]:\n print(-1)\n else:\n print(bad[0])"] | {
"inputs": [
"4\n4\n3 2 7 6\n3\n3 2 6\n1\n7\n7\n4 9 2 1 18 3 0\n",
"7\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n1\n0\n"
],
"outputs": [
"2\n1\n-1\n0\n",
"0\n0\n0\n0\n0\n0\n0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,546 | |
3f6184ac5366fd6c56ece836026c24b5 | UNKNOWN | You are given an integer $n$. In one move, you can either multiply $n$ by two or divide $n$ by $6$ (if it is divisible by $6$ without the remainder).
Your task is to find the minimum number of moves needed to obtain $1$ from $n$ or determine if it's impossible to do that.
You have to answer $t$ independent test cases.
-----Input-----
The first line of the input contains one integer $t$ ($1 \le t \le 2 \cdot 10^4$) β the number of test cases. Then $t$ test cases follow.
The only line of the test case contains one integer $n$ ($1 \le n \le 10^9$).
-----Output-----
For each test case, print the answer β the minimum number of moves needed to obtain $1$ from $n$ if it's possible to do that or -1 if it's impossible to obtain $1$ from $n$.
-----Example-----
Input
7
1
2
3
12
12345
15116544
387420489
Output
0
-1
2
-1
-1
12
36
-----Note-----
Consider the sixth test case of the example. The answer can be obtained by the following sequence of moves from the given integer $15116544$:
Divide by $6$ and get $2519424$; divide by $6$ and get $419904$; divide by $6$ and get $69984$; divide by $6$ and get $11664$; multiply by $2$ and get $23328$; divide by $6$ and get $3888$; divide by $6$ and get $648$; divide by $6$ and get $108$; multiply by $2$ and get $216$; divide by $6$ and get $36$; divide by $6$ and get $6$; divide by $6$ and get $1$. | ["for testcase in range(int(input())):\n n = int(input())\n cnt2, cnt3 = 0, 0\n while n % 2 == 0:\n n //= 2\n cnt2 += 1\n while n % 3 == 0:\n n //= 3\n cnt3 += 1\n\n if n > 1 or cnt3 < cnt2:\n print(-1)\n continue\n\n print(2 * cnt3 - cnt2)\n", "# for _ in range(1):\nfor _ in range(int(input())):\n # n = map(int, input().split())\n n = int(input())\n # arr = list(map(int, input().split()))\n # s = input()\n x = 0\n while n % 6 == 0:\n x += 1\n n //= 6\n while n % 3 == 0:\n x += 2\n n //= 3\n if n != 1:\n x = -1\n print(x)", "for _ in range(int(input())):\n n = int(input())\n x = n\n twos = 0\n threes = 0\n while x % 2 == 0:\n x //= 2\n twos += 1\n while x % 3 == 0:\n x //= 3\n threes += 1\n if x == 1 and threes >= twos:\n print(threes + threes - twos)\n else:\n print(-1)\n", "def read_int():\n return int(input())\n\n\ndef read_ints():\n return list(map(int, input().split(' ')))\n\n\nt = read_int()\nfor case_num in range(t):\n n = read_int()\n if n == 1:\n print(0)\n else:\n two = 0\n three = 0\n while n % 2 == 0:\n n //= 2\n two += 1\n while n % 3 == 0:\n n //= 3\n three += 1\n if n != 1 or two > three:\n print(-1)\n else:\n print(three * 2 - two)\n", "import sys\nimport random\nfrom math import *\n \ndef input():\n return sys.stdin.readline().strip()\n \ndef iinput():\n return int(input())\n\ndef finput():\n return float(input())\n\ndef tinput():\n return input().split()\n\ndef linput():\n return list(input())\n \ndef rinput():\n return map(int, tinput())\n\ndef fiinput():\n return map(float, tinput())\n \ndef rlinput():\n return list(map(int, input().split()))\ndef trinput():\n return tuple(rinput())\n\ndef srlinput():\n return sorted(list(map(int, input().split())))\n\ndef NOYES(fl):\n if fl:\n print(\"NO\")\n else:\n print(\"YES\")\ndef YESNO(fl):\n if fl:\n print(\"YES\")\n else:\n print(\"NO\")\n \ndef main(): \n n = iinput()\n #k = iinput() \n #m = iinput() \n #n = int(sys.stdin.readline().strip()) \n #n, k = rinput()\n #n, m = rinput()\n #m, k = rinput()\n #n, k, m = rinput()\n #n, m, k = rinput()\n #k, n, m = rinput()\n #k, m, n = rinput() \n #m, k, n = rinput()\n #m, n, k = rinput()\n #q = srlinput()\n #q = linput()\n t, g = 0, 0\n while n % 3 == 0:\n g += 1\n n //= 3\n while n % 2 == 0:\n n //= 2\n t += 1\n if n != 1 or t > g:\n print(-1)\n else:\n print(g * 2 - t)\n \n\n \nfor inytd in range(iinput()):\n main()", "import sys\n\ninp = [int(x) for x in sys.stdin.read().split()]; ii = 0\n\nttt = inp[ii]; ii += 1\nfor _ in range(ttt):\n\tn = inp[ii]; ii += 1\n\te2, e3 = 0, 0\n\twhile n % 2 == 0:\n\t\tn /= 2\n\t\te2 += 1\n\twhile n % 3 == 0:\n\t\tn /= 3\n\t\te3 += 1\n\tif n > 1 or e2 > e3:\n\t\tprint(-1)\n\telse:\n\t\tprint(e3 - e2 + e3)", "from bisect import bisect_left as bl\nfrom bisect import bisect_right as br\nfrom heapq import heappush,heappop\nimport math\nfrom collections import *\nfrom functools import reduce,cmp_to_key\nimport sys\ninput = sys.stdin.readline\nM = mod = 998244353\ndef factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))\ndef inv_mod(n):return pow(n, mod - 2, mod)\n \ndef li():return [int(i) for i in input().rstrip('\\n').split()]\ndef st():return input().rstrip('\\n')\ndef val():return int(input().rstrip('\\n'))\ndef li2():return [i for i in input().rstrip('\\n')]\ndef li3():return [int(i) for i in input().rstrip('\\n')]\n\nfor _ in range(val()):\n n = val()\n ans = 0\n if n == 1:\n print(ans)\n continue\n while n != 1:\n ans += 1\n if n%6 == 0:\n n//=6\n else:n *= 2\n if ans > 100:\n ans = -1\n break\n print(ans)", "import math\nimport collections\nimport sys\n\n\ndef inpu():\n return input().split(' ')\n\n\ndef inti(a):\n for i in range(len(a)):\n a[i] = int(a[i])\n return a\n\n\ndef inp():\n a = inpu()\n a = inti(a)\n return a\n\n\nfor _ in range(int(input())):\n n = int(input())\n moves = 0\n if n % 6 == 0:\n while n % 6 == 0:\n n = n//6\n moves += 1\n if n % 3 == 0:\n while n % 3 == 0:\n n = n//3\n moves += 2\n if n == 1:\n print(moves)\n else:\n print(-1)\n", "for _ in range(int(input())):\n n = int(input())\n kek = dict()\n kek[2] = 0\n kek[3] = 0\n i = 2\n while i < 4 and n > 1:\n if n % i == 0:\n n //= i\n kek[i] += 1\n else:\n i += 1\n if n != 1:\n print(-1)\n else:\n if kek[2] > kek[3]:\n print(-1)\n else:\n ans = kek[3]\n ans += kek[3] - kek[2]\n print(ans)", "a=int(input())\nfor i in range(a):\n n=int(input())\n count=0\n while(n%6==0):\n n=n//6\n count+=1\n if(n==1):\n print(count)\n continue;\n else:\n while(n%3==0):\n n=n//3\n count+=2\n if(n==1):\n print(count)\n else:\n print(-1)\n", "import sys\n\nt = int(sys.stdin.readline().strip())\nfor _ in range(t):\n\tn = int(sys.stdin.readline().strip())\n\n\ttwo, three = 0, 0\n\twhile n%2 == 0:\n\t\tn //= 2\n\t\ttwo += 1\n\twhile n%3 == 0:\n\t\tn //= 3\n\t\tthree += 1\n\n\tif n > 1 or two > three:\n\t\tprint(-1)\n\t\tcontinue\n\n\telse:\n\t\tprint(three-two + three)\n", "t = int(input())\nfor _ in range(t):\n\tn = int(input())\n\tct2, ct3 = 0, 0\n\twhile n%2 == 0:\n\t\tn /= 2\n\t\tct2 += 1\n\twhile n%3 == 0:\n\t\tn /= 3\n\t\tct3 += 1\n\tif n > 1 or ct2 > ct3:\n\t\tprint(-1)\n\telse:\n\t\tprint(ct3 + ct3-ct2)\n", "import sys\ninput = sys.stdin.readline\n\nt=int(input())\nfor tests in range(t):\n n=int(input())\n\n TWO=0\n THREE=0\n\n while n%2==0:\n TWO+=1\n n//=2\n\n while n%3==0:\n THREE+=1\n n//=3\n\n if n!=1:\n print(-1)\n else:\n if TWO>THREE:\n print(-1)\n else:\n print(THREE-TWO+THREE)\n\n \n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n div = [0,0]\n while n%2 == 0:\n n //= 2\n div[0] += 1\n while n%3 == 0:\n n //= 3\n div[1] += 1\n if n != 1:\n print(-1)\n continue\n print((div[1] - div[0]) + (div[1]) if div[1] >= div[0] else -1)", "t = int(input())\nfor _ in range(t):\n n, = map(int, input().split())\n x = n\n s = 0\n while x != 1 and x%3 == 0:\n if x%6 == 0:\n x//=6\n s+=1\n else:\n x*=2\n s+=1\n if x == 1:\n print(s)\n else:\n print(-1)", "def deli(n):\n n3 = 0\n n2 = 0\n while n % 3 == 0:\n n //= 3\n n3 += 1\n while n % 2 == 0:\n n //= 2\n n2 += 1\n if n != 1:\n return -1, -1\n else:\n return n2,n3\ndef solve():\n n = int(input())\n a,b = deli(n)\n if a == -1:\n print(-1)\n elif b < a:\n print(-1)\n else:\n print(b + b - a)\n\nfor i in range(int(input())):\n solve()", "\ntt = int(input())\n\nfor loop in range(tt):\n\n n = int(input())\n\n d2 = 0\n d3 = 0\n\n while n % 2 == 0:\n d2 += 1\n n //= 2\n\n while n % 3 == 0:\n d3 += 1\n n //= 3\n\n if n != 1 or d3 < d2:\n print(-1)\n else:\n print(d3 + d3-d2)\n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n p2 = 0\n p3 = 0\n while n % 3 == 0:\n n //= 3\n p3 += 1\n while n % 2 == 0:\n n //= 2\n p2 += 1\n if n == 1:\n diff = p3 - p2\n if diff < 0:\n print(-1)\n else:\n print(p3 + diff)\n else:\n print(-1)\n\n\n", "import sys\nimport math\nimport itertools\nimport functools\nimport collections\nimport operator\nimport fileinput\nimport copy\n\nORDA = 97 # a\ndef ii(): return int(input())\ndef mi(): return list(map(int, input().split()))\ndef li(): return [int(i) for i in input().split()]\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef revn(n): return str(n)[::-1]\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\ndef divs(n, start=1):\n r = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if (n % i == 0):\n if (n / i == i):\n r.append(i)\n else:\n r.extend([i, n // i])\n return r\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\ndef prime(n):\n if n == 2: return True\n if n % 2 == 0 or n <= 1: return False\n sqr = int(math.sqrt(n)) + 1\n for d in range(3, sqr, 2):\n if n % d == 0: return False\n return True\ndef convn(number, base):\n newnumber = 0\n while number > 0:\n newnumber += number % base\n number //= base\n return newnumber\ndef cdiv(n, k): return n // k + (n % k != 0)\ndef ispal(s):\n for i in range(len(s) // 2 + 1):\n if s[i] != s[-i - 1]:\n return False\n return True\n\n\nfor _ in range(ii()):\n n = ii()\n\n two, three = 0, 0\n while n % 3 == 0:\n n //= 3\n three += 1\n while n % 2 == 0:\n n //= 2\n two += 1\n if n != 1 or two > three:\n print(-1)\n else:\n print(three * 2 - two)\n\n", "# Created by: WeirdBugsButOkay\n# 28-06-2020, 20:08:49\n\nimport math\n\ndef solve() :\n n = int(input())\n p2, p3 = 0, 0\n while n % 2 == 0 :\n p2 += 1\n n //= 2\n while n % 3 == 0 :\n p3 += 1\n n //= 3\n if p3 < p2 :\n print(-1)\n else :\n if n != 1 :\n print(-1)\n else :\n print((p3 - p2) + p3)\n\nt = 1\nt = int(input())\nfor _ in range (0, t) :\n solve()\n", "for i in range(int(input())):\n\tn = int(input())\n\ttimes = 0\n\tcanDo = True\n\twhile (n != 1):\n\t\tif n%6 == 0:\n\t\t\tn = n//6\n\t\telif n%3 == 0:\n\t\t\tn *= 2\n\t\telse:\n\t\t\tcanDo = False\n\t\t\tbreak\n\t\ttimes += 1\n\tif canDo:\n\t\tprint(times)\n\telse:\n\t\tprint(\"-1\")\n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n count = 0\n tmp = n\n while(tmp % 2 == 0):\n tmp //= 2\n count += 1\n count2 = 0\n while(tmp % 3 == 0):\n tmp //= 3\n count2 += 1\n if tmp != 1:\n print(-1)\n\n else:\n if count > count2:\n print(-1)\n else:\n ans = count2 - count\n ans += count2\n print(ans)\n", "def inp():\n return(int(input()))\ndef inlt():\n return(list(map(int,input().split())))\ndef insr():\n s = input()\n return(list(s[:len(s) ]))\ndef invr():\n return(list(map(int,input().split())))\n\nn = inp()\n\nfor i in range(n):\n n = inp()\n\n if(n == 1):\n print(0)\n else:\n t = 2\n cnt = 0\n while(n%2 == 0):\n cnt += 1\n n //= 2\n\n t = 3\n cnt2 = 0\n while(n%3 == 0):\n cnt2 += 1\n n //= 3\n if(cnt2 == 0 or n != 1 or cnt > cnt2):\n print(-1)\n else:\n print(cnt2 - cnt + cnt2)\n", "t=int(input())\ndef fun(n):\n ans=0\n two=0\n three=0\n while n%2==0:\n n/=2\n two+=1\n while n%3==0:\n n/=3\n three+=1\n if n!=1:\n print(-1)\n else:\n if two>three:\n print(-1)\n else:\n print(2*three-two)\nwhile t:\n t-=1\n n=int(input())\n fun(n)\n \n"] | {
"inputs": [
"7\n1\n2\n3\n12\n12345\n15116544\n387420489\n",
"1\n999838675\n"
],
"outputs": [
"0\n-1\n2\n-1\n-1\n12\n36\n",
"-1\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 12,518 | |
0ded652bbeb540be8350e061f7eaec93 | UNKNOWN | The only difference between easy and hard versions is the size of the input.
You are given a string $s$ consisting of $n$ characters, each character is 'R', 'G' or 'B'.
You are also given an integer $k$. Your task is to change the minimum number of characters in the initial string $s$ so that after the changes there will be a string of length $k$ that is a substring of $s$, and is also a substring of the infinite string "RGBRGBRGB ...".
A string $a$ is a substring of string $b$ if there exists a positive integer $i$ such that $a_1 = b_i$, $a_2 = b_{i + 1}$, $a_3 = b_{i + 2}$, ..., $a_{|a|} = b_{i + |a| - 1}$. For example, strings "GBRG", "B", "BR" are substrings of the infinite string "RGBRGBRGB ..." while "GR", "RGR" and "GGG" are not.
You have to answer $q$ independent queries.
-----Input-----
The first line of the input contains one integer $q$ ($1 \le q \le 2000$)Β β the number of queries. Then $q$ queries follow.
The first line of the query contains two integers $n$ and $k$ ($1 \le k \le n \le 2000$)Β β the length of the string $s$ and the length of the substring.
The second line of the query contains a string $s$ consisting of $n$ characters 'R', 'G' and 'B'.
It is guaranteed that the sum of $n$ over all queries does not exceed $2000$ ($\sum n \le 2000$).
-----Output-----
For each query print one integerΒ β the minimum number of characters you need to change in the initial string $s$ so that after changing there will be a substring of length $k$ in $s$ that is also a substring of the infinite string "RGBRGBRGB ...".
-----Example-----
Input
3
5 2
BGGGG
5 3
RBRGR
5 5
BBBRR
Output
1
0
3
-----Note-----
In the first example, you can change the first character to 'R' and obtain the substring "RG", or change the second character to 'R' and obtain "BR", or change the third, fourth or fifth character to 'B' and obtain "GB".
In the second example, the substring is "BRG". | ["import sys\ndef countR(ip):\n c=0\n for i in ip:\n if(i=='R'):\n c+=1\n return c\n \ndef countB(ip):\n c=0\n for i in ip:\n if(i=='B'):\n c+=1\n return c\n \ndef countG(ip):\n c=0\n for i in ip:\n if(i=='G'):\n c+=1\n return c\n# sys.stdin.readline()\nt=int(sys.stdin.readline())\nx='RGB'*680\ny='GBR'*680\nz='BRG'*680\nfor i in range(t):\n n,k=list(map(int,sys.stdin.readline().strip().split()))\n a=sys.stdin.readline().strip()\n xk=x[:k]\n yk=y[:k]\n zk=z[:k]\n # print(k,xk,zk)\n # xc=[]\n # yc=[]\n # zc=[]\n # xc.append(countR(xk))\n # xc.append(countG(xk))\n # xc.append(countB(xk))\n \n # yc.append(countR(yk))\n # yc.append(countG(yk))\n # yc.append(countB(yk))\n \n # zc.append(countR(zk))\n # zc.append(countG(zk))\n # zc.append(countB(zk))\n op=2001\n for j in range(n-k+1):\n b=a[j:j+k]\n # print(len(b),xc,zc)\n # bc=[]\n \n # bc.append(countR(b))\n # bc.append(countG(b))\n # bc.append(countB(b))\n xd=0\n yd=0\n zd=0\n # print(a,b,xc,yc,zc,bc)\n for jj in range(len(b)):\n if(b[jj]!=xk[jj]):\n xd+=1\n if(b[jj]!=yk[jj]):\n yd+=1\n if(b[jj]!=zk[jj]):\n zd+=1\n # print(a,b,xd,yd,zd,z)\n op=min(op,xd,yd,zd)\n print(op)\n", "def givestringsk(k):\n t=[\"R\",\"G\",\"B\"]\n ans=[]\n for i in range(3):\n temp=\"\"\n for j in range(i,i+k):\n temp+=t[j%3]\n ans.append(temp)\n return ans\ndef countdifferences(a,b):\n cnt=0\n for i in range(len(a)):\n if a[i]!=b[i]:cnt+=1\n return cnt\nfor _ in range(int(input())):\n n,k=list(map(int,input().split()))\n s=input()\n temp=givestringsk(k)\n ans=10000000000000\n for i in range(k,n+1):\n for j in range(3):\n ans=min(ans,countdifferences(s[i-k:i],temp[j]))\n print(ans)\n", "s=\"RGB\"*666\nrgb=[\"GB\"+s]\nrgb.append(\"RGB\"+s)\nrgb.append(\"BRGB\"+s)\nfor _ in range(int(input())):\n\tn,k=map(int,input().split())\n\tt=input()\n\tl=len(t)\n\tans=2001\n\ta=[0]*l\n\tfor i in range(3):\n\t\ta[0]=1 if rgb[i][0]!=t[0] else 0\n\t\tfor j in range(1,l):\n\t\t\ta[j]=a[j-1]+(1 if rgb[i][j]!=t[j] else 0)\n\t\tans=min(ans,a[k-1])\n\t\tfor j in range(k,l):\n\t\t\tans=min(ans,a[j]-a[j-k])\n\tprint(ans)", "q = int(input())\nfor _ in range(q):\n n, k = map(int, input().split())\n s = input()\n ans = k\n sample = \"RGB\"\n for i in range(n - k + 1):\n cnt = 0\n x = 0\n for j in range(i, i + k):\n if s[j] != sample[x]:\n cnt += 1\n x = (x + 1) % 3\n #print(ans, 7)\n ans = min(ans, cnt)\n cnt = 0\n x = 1\n for j in range(i, i + k):\n if s[j] != sample[x]:\n cnt += 1\n x = (x + 1) % 3\n ans = min(ans, cnt)\n #print(ans, 8)\n cnt = 0\n x = 2\n for j in range(i, i + k):\n if s[j] != sample[x]:\n cnt += 1\n x = (x + 1) % 3\n ans = min(ans, cnt) \n #print(ans, 9) \n print(ans)", "def main():\n q = int(input())\n for i in range(q):\n n, k = map(int, input().split())\n s = input()\n min_ans = 10 ** 9\n for i in range(n - k + 1):\n count1 = 0\n count2 = 0\n count3 = 0\n for j in range(k):\n if (i + j) % 3 == 0:\n if s[i + j] != \"R\":\n count1 += 1\n if s[i + j] != \"G\":\n count2 += 1\n if s[i + j] != \"B\":\n count3 += 1\n if (i + j) % 3 == 1:\n if s[i + j] != \"G\":\n count1 += 1\n if s[i + j] != \"B\":\n count2 += 1\n if s[i + j] != \"R\":\n count3 += 1 \n if (i + j) % 3 == 2:\n if s[i + j] != \"B\":\n count1 += 1\n if s[i + j] != \"R\":\n count2 += 1\n if s[i + j] != \"G\":\n count3 += 1 \n min_ans = min(min_ans, count1, count2, count3)\n print(min_ans)\nmain()", "q = int(input())\nb = []\nfor m in range(q):\n n, k = list(map(int, input().split()))\n l = input()\n k1 = 'R'\n k2 = 'G'\n k3 = 'B'\n for i in range(1, k):\n if k1[i - 1] == 'R':\n k1 = k1 + 'G'\n if k1[i - 1] == 'G':\n k1 = k1 + 'B'\n if k1[i - 1] == 'B':\n k1 = k1 + 'R'\n if k2[i - 1] == 'R':\n k2 = k2 + 'G'\n if k2[i - 1] == 'G':\n k2 = k2 + 'B'\n if k2[i - 1] == 'B':\n k2 = k2 + 'R'\n if k3[i - 1] == 'R':\n k3 = k3 + 'G'\n if k3[i - 1] == 'G':\n k3 = k3 + 'B'\n if k3[i - 1] == 'B':\n k3 = k3 + 'R'\n minn = n\n #print(k1)\n #print(k2)\n #print(k3)\n for i in range(n - k + 1):\n tec = 0\n for j in range(k):\n if l[i + j] != k1[j]:\n tec += 1\n if tec < minn: minn = tec\n for i in range(n - k + 1):\n tec = 0\n for j in range(k):\n if l[i + j] != k2[j]:\n tec += 1\n if tec < minn: minn = tec\n for i in range(n - k + 1):\n tec = 0\n for j in range(k):\n if l[i + j] != k3[j]:\n tec += 1\n #print(l[i+j], k3[j])\n if tec < minn: minn = tec\n b.append(minn)\nfor i in range(q):\n print(b[i])\n", "from sys import stdin\nfrom collections import deque\nc=int(stdin.readline().strip())\nfor cas in range(c):\n n,m=list(map(int,stdin.readline().strip().split()))\n s=deque(stdin.readline().strip())\n arr=[\"R\",\"G\",\"B\"]\n ans=n+3\n for k in range(1):\n\n for i in range(3):\n x=i\n\n dp=[0 for i in range(n+1)]\n for j in range(n):\n\n if s[j]!=arr[x]:\n dp[j+1]+=1\n dp[j+1]+=dp[j]\n if j+1>=m:\n\n ans=min(ans,dp[j+1]-dp[j+1-m])\n x+=1\n x=x%3\n\n print(ans)\n \n \n \n \n \n1\n", "def user99():\n text = 'RGB' * 2222\n for _ in range(int(input())):\n n, k = list(map(int, input().split()))\n s = input()\n ans = 2222\n for i in range(3):\n p = text[i: k + i]\n #print(\"p = \", p)\n for j in range(n - k + 1):\n diff = 0\n #print(s[j: j + k], \"vs\", p)\n for l in range(j, j + k):\n if s[l] != p[l - j]:\n diff += 1\n ans = min(ans, diff)\n print(ans)\n\nuser99()\n", "Q = int(input())\nfor _ in range(Q):\n N, K = list(map(int, input().split()))\n S = input()\n X = [{\"R\":0, \"G\":1, \"B\":2}[s] for s in S]\n mi = K\n for i in range(3):\n d = 0\n for j in range(N):\n if X[j] != (i+j) % 3:\n d += 1\n if j >= K and X[j-K] != (i+j-K) % 3:\n d -= 1\n if j >= K-1:\n mi = min(mi, d)\n print(mi)\n", "R = lambda: map(int, input().split())\nfor _ in range(int(input())):\n n,k = R()\n s = input()\n p = (k+2)//2\n l = \"RGB\"*p\n res = n\n for i in range(n-k+1):\n c = 0\n #print(l[0:k])\n for j in range(0,k):\n c += (s[i+j] != l[j])\n res = min(res,c)\n #print(c)\n c = 0\n #print(l[1:k+1])\n for j in range(1,k+1):\n c += (s[i+j-1] != l[j])\n res = min(res,c)\n #print(c)\n c = 0\n #print(l[2:k+2])\n for j in range(2,k+2):\n c += (s[i+j-2] != l[j])\n res = min(res,c)\n #print(c)\n print(res)", "R = lambda: map(int, input().split())\nfor _ in range(int(input())):\n n,k = R()\n s = input()\n p = (k+2)//2\n l = \"RGB\"*p\n res = n\n for i in range(n-k+1):\n c = 0\n #print(l[0:k])\n for j in range(0,k):\n c += (s[i+j] != l[j])\n res = min(res,c)\n #print(c)\n c = 0\n #print(l[1:k+1])\n for j in range(1,k+1):\n c += (s[i+j-1] != l[j])\n res = min(res,c)\n #print(c)\n c = 0\n #print(l[2:k+2])\n for j in range(2,k+2):\n c += (s[i+j-2] != l[j])\n res = min(res,c)\n #print(c)\n print(res)", "import math\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, k = Read.list_int()\n s = input()\n\n sf = 'RGB' * (k + 2)\n\n max_s = 0\n for i in range(n - k + 1):\n for j in range(3):\n count = 0\n for b in range(k):\n if sf[j + b] == s[i + b]:\n count += 1\n if count > max_s:\n max_s = count\n\n print(k - max_s)\n\n\nquery_count = Read.int()\nfor j in range(query_count):\n solve()\n", "def solve(d, n, k):\n mv = sum(d[0:k])\n v = mv\n for i in range(1, n-k+1):\n mv = mv + d[i+k-1] - d[i-1]\n v = min(v, mv)\n return v\n\nfor _ in range(int(input())):\n n, k = tuple(map(int, input().split()))\n s = input()\n st = 'RGB' * (n//3 + 3)\n diff1, diff2, diff3 = [0 for _ in range(n)], [0 for _ in range(n)], [0 for _ in range(n)]\n\n for i in range(n):\n if s[i] != st[i]: diff1[i] = 1\n if s[i] != st[i+1]: diff2[i] = 1\n if s[i] != st[i+2]: diff3[i] = 1\n\n print(min(solve(diff1, n, k), solve(diff2, n, k), solve(diff3, n, k)))", "'''input\n3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n'''\nimport sys\nfrom collections import defaultdict as dd\n\nmod=10**9+7\n\ndef ri(flag=0):\n\tif flag==0:\n\t\treturn [int(i) for i in sys.stdin.readline().split()]\n\telse:\n\t\treturn int(sys.stdin.readline())\n\n\nfor _ in range(int(input())):\n\tn,k = ri()\n\ta = input()\n\trgb= [0 for i in range(n)]\n\tgbr= [0 for i in range(n)]\n\tbrg= [0 for i in range(n)]\n\n\tfor i in range(n):\n\t\tif i%3==0:\n\t\t\tif a[i]!=\"R\":\n\t\t\t\trgb[i]+=1\n\t\tif i%3==1:\n\t\t\tif a[i]!=\"G\":\n\t\t\t\trgb[i]+=1\n\t\tif i%3==2:\n\t\t\tif a[i]!=\"B\":\n\t\t\t\trgb[i]+=1\n\n\tfor i in range(n):\n\t\tif i%3==0:\n\t\t\tif a[i]!=\"G\":\n\t\t\t\tgbr[i]+=1\n\t\tif i%3==1:\n\t\t\tif a[i]!=\"B\":\n\t\t\t\tgbr[i]+=1\n\t\tif i%3==2:\n\t\t\tif a[i]!=\"R\":\n\t\t\t\tgbr[i]+=1\n\n\tfor i in range(n):\n\t\tif i%3==0:\n\t\t\tif a[i]!=\"B\":\n\t\t\t\tbrg[i]+=1\n\t\tif i%3==1:\n\t\t\tif a[i]!=\"R\":\n\t\t\t\tbrg[i]+=1\n\t\tif i%3==2:\n\t\t\tif a[i]!=\"G\":\n\t\t\t\tbrg[i]+=1\n\n\tfor i in range(1,n):\n\t\trgb[i]+=rgb[i-1]\n\t\tbrg[i]+=brg[i-1]\n\t\tgbr[i]+=gbr[i-1]\n\n\n\tans = 999999999\n\t#print(rgb,gbr,brg)\n\tfor i in range(k-1,n):\n\t\t#print(i,i-k)\n\t\tif i-k ==-1:\n\t\t\tans = min(ans,rgb[i],gbr[i],brg[i])\n\t\telse:\n\t\t\tans = min(ans, rgb[i]- rgb[i-k] , gbr[i]- gbr[i-k], brg[i]- brg[i-k] )\n\n\tprint(ans)\n\n\n\n\n\n\n", "q = int(input())\nfor t in range(q):\n n, k = list(map(int, input().split()))\n rgb = input()\n dp = [0] * 3\n dp[0] = [0] * (n + 1)\n dp[1] = [0] * (n + 1)\n dp[2] = [0] * (n + 1)\n for i in range(0, n):\n if rgb[i] == 'R':\n dp[0][i + 1] = dp[2][i]\n dp[1][i + 1] = dp[0][i] + 1\n dp[2][i + 1] = dp[1][i] + 1\n if rgb[i] == 'G':\n dp[0][i + 1] = dp[2][i] + 1\n dp[1][i + 1] = dp[0][i]\n dp[2][i + 1] = dp[1][i] + 1\n if rgb[i] == 'B':\n dp[0][i + 1] = dp[2][i] + 1\n dp[1][i + 1] = dp[0][i] + 1\n dp[2][i + 1] = dp[1][i]\n repl = k\n dif = k % 3\n for j in range(3):\n for i in range(1, n - k + 2):\n repl = min(repl, -dp[j][i - 1] + dp[(j + dif) % 3][i + k - 1])\n print(repl)\n", "######################################################################\n# Write your code here\nimport sys\ninput = sys.stdin.readline\n#import resource\n#resource.setrlimit(resource.RLIMIT_STACK, [0x10000000, resource.RLIM_INFINITY])\n#sys.setrecursionlimit(0x100000)\n# Write your code here\nRI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]\nrw = lambda : input().strip().split()\nfrom collections import defaultdict as df\n#import heapq \n#heapq.heapify(li) heappush(li,4) heappop(li)\nimport random\n#random.shuffle(list)\ninfinite = float('inf')\n#######################################################################\n\nt=int(input())\n\nfor _ in range(t):\n n,k=RI()\n s=input()\n\n mini=n\n \n test=\"RGB\"*(k//3 + 5)\n for i in range(n-k+1):\n count=0\n \n for j in range(k):\n if(s[i+j]!=test[j]):\n count+=1\n\n mini=min(count,mini)\n\n test=\"GBR\"*(k//3 + 5)\n for i in range(n-k+1):\n count=0\n \n for j in range(k):\n if(s[i+j]!=test[j]):\n count+=1\n\n mini=min(count,mini)\n\n test=\"BRG\"*(k//3 + 5)\n for i in range(n-k+1):\n count=0\n \n for j in range(k):\n if(s[i+j]!=test[j]):\n count+=1\n\n mini=min(count,mini)\n\n print(mini)\n", "from sys import stdin,stdout\ninput=stdin.readline\nfor _ in range(int(input())):\n x=10**5\n n,k=list(map(int,input().split()))\n s=input()\n ans=10**9\n for i in range(n-k+1):\n x=s[i:i+k]\n m=0\n curr=['R','G','B']\n for l in range(3):\n m=0\n z=l\n for j in x:\n if j!=curr[z]:\n m+=1\n z+=1\n z%=3\n ans=min(ans,m)\n print(ans)\n", "######################################################################\n# Write your code here\nimport sys\ninput = sys.stdin.readline\n#import resource\n#resource.setrlimit(resource.RLIMIT_STACK, [0x10000000, resource.RLIM_INFINITY])\n#sys.setrecursionlimit(0x100000)\n# Write your code here\nRI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]\nrw = lambda : input().strip().split()\n#from collections import defaultdict as df\n#import heapq \n#heapq.heapify(li) heappush(li,4) heappop(li)\n#import random\n#random.shuffle(list)\ninfinite = float('inf')\n#######################################################################\n\nt=int(input())\n\nfor _ in range(t):\n n,k=RI()\n s=input()\n\n mini=n\n \n test=\"RGB\"*(k//3 + 5)\n for i in range(n-k+1):\n count=0\n \n for j in range(k):\n if(s[i+j]!=test[j]):\n count+=1\n\n mini=min(count,mini)\n\n test=\"GBR\"*(k//3 + 5)\n for i in range(n-k+1):\n count=0\n \n for j in range(k):\n if(s[i+j]!=test[j]):\n count+=1\n\n mini=min(count,mini)\n\n test=\"BRG\"*(k//3 + 5)\n for i in range(n-k+1):\n count=0\n \n for j in range(k):\n if(s[i+j]!=test[j]):\n count+=1\n\n mini=min(count,mini)\n\n print(mini)\n", "import sys\ninput = lambda: sys.stdin.readline().strip()\nfrom math import ceil\n\ndef mismatch(s1, s2):\n cnt = 0\n for i in range(len(s1)):\n if s1[i]!=s2[i]: cnt+=1\n return cnt\n\nT = int(input())\nfor _ in range(T):\n n, k = list(map(int, input().split()))\n check = ''\n for i in range(ceil((k+2)/3)):\n check+='RGB'\n ls = []\n for i in range(3):\n ls.append(check[i:i+k])\n s = input()\n m = n\n for i in range(n-k+1):\n for j in ls:\n m = min(m, mismatch(s[i:i+k], j))\n print(m)\n", "T=int(input())\nfor _ in range(T):\n n,k=list(map(int,input().split()))\n s=input()\n rq1=''\n rq2=''\n rq3=''\n\n for i in range(k):\n if(i%3==0):\n rq1=rq1+'R'\n rq2=rq2+'G'\n rq3=rq3+'B'\n elif(i%3==1):\n rq1=rq1+'G'\n rq2=rq2+'B'\n rq3=rq3+'R'\n elif(i%3==2):\n rq1=rq1+'B'\n rq2=rq2+'R'\n rq3=rq3+'G'\n\n ans=1000000000000000000\n\n for i in range(0,len(s)-k+1):\n\n a1=0\n a2=0\n a3=0\n\n for j in range(i,i+k):\n\n if(s[j]!=rq1[j-i]):\n a1+=1\n if(s[j]!=rq2[j-i]):\n a2+=1\n if(s[j]!=rq3[j-i]):\n a3+=1\n #print(a1,a2,a3,rq1,rq2,rq3)\n\n ans=min(ans,min(a1,a2,a3))\n\n print(ans)\n \n \n \n \n \n", "q=int(input())\nfor i in range(q):\n\tn,k=map(int,input().split())\n\ts=input()\n\tm=10**4\n\tfor j in range(n):\n\t\tif j+k<=n:\n\t\t\tl1=[\"R\",\"G\",\"B\"]\n\t\t\tm1,m2,m3=0,0,0\n\t\t\tfor i in range(j,j+k):\n\t\t\t\tif l1[(i-j)%3]!=s[i]:\n\t\t\t\t\tm1+=1\n\t\t\tfor i in range(j,j+k):\n\t\t\t\tif l1[(i+1-j)%3]!=s[i]:\n\t\t\t\t\tm2+=1\n\t\t\tfor i in range(j,j+k):\n\t\t\t\tif l1[(i+2-j)%3]!=s[i]:\n\t\t\t\t\tm3+=1\n\t\t\tm=min(m,m1,m2,m3)\n\t\telse:\n\t\t\tbreak\n\tprint(m)", "import sys\ninput = sys.stdin.readline\nq = int(input())\nfor i in range(q):\n n, k = map(int, input().split())\n s = input()\n R, G, B = 0, 0, 0\n ans = float('inf')\n for j in range(n):\n if j % 3 == 0:\n if s[j] == 'R':\n G += 1\n B += 1\n elif s[j] == 'G':\n R += 1\n B += 1\n else:\n R += 1\n G += 1\n elif j % 3 == 1:\n if s[j] == 'R':\n G += 1\n R += 1\n elif s[j] == 'G':\n G += 1\n B += 1\n else:\n R += 1\n B += 1\n else:\n if s[j] == 'R':\n R += 1\n B += 1\n elif s[j] == 'G':\n R += 1\n G += 1\n else:\n G += 1\n B += 1\n if j >= k - 1:\n ans = min(ans, R, G, B)\n if (j - k + 1) % 3 == 0:\n if s[j - k + 1] == 'R':\n G -= 1\n B -= 1\n elif s[j - k + 1] == 'G':\n R -= 1\n B -= 1\n else:\n R -= 1\n G -= 1\n elif (j - k + 1) % 3 == 1:\n if s[j - k + 1] == 'R':\n G -= 1\n R -= 1\n elif s[j - k + 1] == 'G':\n G -= 1\n B -= 1\n else:\n R -= 1\n B -= 1\n else:\n if s[j - k + 1] == 'R':\n R -= 1\n B -= 1\n elif s[j - k + 1] == 'G':\n R -= 1\n G -= 1\n else:\n G -= 1\n B -= 1\n\n print(ans)"] | {
"inputs": [
"3\n5 2\nBGGGG\n5 3\nRBRGR\n5 5\nBBBRR\n",
"1\n18 2\nRBGGGRBBGRRBBGGGGB\n"
],
"outputs": [
"1\n0\n3\n",
"0\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 19,650 | |
187866f49ce75652eda44618f5049968 | UNKNOWN | You are given an array $a$ consisting of $n$ integers $a_1, a_2, \dots , a_n$.
In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $[2, 1, 4]$ you can obtain the following arrays: $[3, 4]$, $[1, 6]$ and $[2, 5]$.
Your task is to find the maximum possible number of elements divisible by $3$ that are in the array after performing this operation an arbitrary (possibly, zero) number of times.
You have to answer $t$ independent queries.
-----Input-----
The first line contains one integer $t$ ($1 \le t \le 1000$) β the number of queries.
The first line of each query contains one integer $n$ ($1 \le n \le 100$).
The second line of each query contains $n$ integers $a_1, a_2, \dots , a_n$ ($1 \le a_i \le 10^9$).
-----Output-----
For each query print one integer in a single line β the maximum possible number of elements divisible by $3$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
-----Example-----
Input
2
5
3 1 2 3 1
7
1 1 1 1 1 2 2
Output
3
3
-----Note-----
In the first query of the example you can apply the following sequence of operations to obtain $3$ elements divisible by $3$: $[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$.
In the second query you can obtain $3$ elements divisible by $3$ with the following sequence of operations: $[1, 1, 1, 1, 1, 2, 2] \rightarrow [1, 1, 1, 1, 2, 3] \rightarrow [1, 1, 1, 3, 3] \rightarrow [2, 1, 3, 3] \rightarrow [3, 3, 3]$. | ["for i in range(int(input())):\n n=int(input())\n l1=list(map(int,input().split()))\n type1=0\n type2=0\n ans=0\n for item in l1:\n if item%3==0:\n ans+=1\n elif item%3==1:\n type1+=1\n else :\n type2+=1\n x=min(type1,type2)\n ans+=x\n type1-=x\n type2-=x\n ans+=(type1//3+type2//3)\n print(ans)", "#!/usr/bin/env python\nfor _ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n f = [0, 0, 0]\n for ai in a:\n f[ai % 3] += 1\n m = min(f[1], f[2])\n f[1] -= m; f[2] -= m\n print(f[0] + m + (f[1] + f[2]) // 3)\n", "#JMD\n#Nagendra Jha-4096\n\n \nimport sys\nimport math\n\n#import fractions\n#import numpy\n \n###File Operations###\nfileoperation=0\nif(fileoperation):\n orig_stdout = sys.stdout\n orig_stdin = sys.stdin\n inputfile = open('W:/Competitive Programming/input.txt', 'r')\n outputfile = open('W:/Competitive Programming/output.txt', 'w')\n sys.stdin = inputfile\n sys.stdout = outputfile\n\n###Defines...###\nmod=1000000007\n \n###FUF's...###\ndef nospace(l):\n ans=''.join(str(i) for i in l)\n return ans\n \n \n \n##### Main ####\nt=int(input())\nfor tt in range(t):\n n=int(input())\n #n,k,s= map(int, sys.stdin.readline().split(' '))\n a=list(map(int,sys.stdin.readline().split(' ')))\n z=0\n o=0\n two=0\n for nu in a:\n if(nu%3==0):\n z+=1\n elif(nu%3==1):\n o+=1\n else:\n two+=1\n ans=min(o,two)\n o-=ans\n two-=ans\n if(o):\n ans+=o//3\n if two:\n ans+=two//3\n print(ans+z)\n\n \n \n#####File Operations#####\nif(fileoperation):\n sys.stdout = orig_stdout\n sys.stdin = orig_stdin\n inputfile.close()\n outputfile.close()", "\n\nfor _ in range(int(input())):\n\tn=int(input())\n\ta=list(map(int,input().split(\" \")))\n\n\tfor i in range(n):\n\t\ta[i]%=3\n\n\tc0=0\n\tc1=0\n\tc2=0\n\n\tfor i in a:\n\t\tif(i==0):\n\t\t\tc0+=1\n\t\telif(i==1):\n\t\t\tc1+=1\n\t\telse:\n\t\t\tc2+=1\n\n\tans=0\n\n\tans+=c0\n\n\tnow=min(c2,c1)\n\n\tans+=now\n\n\tc1-=now\n\tc2-=now\n\n\tans+=c1//3\n\tans+=c2//3\n\n\tprint(ans)\n", "t = int(input())\nfor i in range(t):\n n = int(input())\n a = list(map(int, input().split()))\n d = [0] * 3\n for j in range(n):\n d[a[j] % 3] += 1\n\n num = 0\n num += d[0]\n k = min(d[1], d[2])\n num += k\n d[1], d[2] = d[1] - k, d[2] - k\n num += d[1] // 3\n num += d[2] // 3\n print(num)", "t = int(input())\nfor _ in range(t):\n n = int(input())\n a = list(map(int, input().split()))\n c = [0, 0, 0]\n for i in a:\n c[i % 3] += 1\n if c[1] >= c[2]:\n print(c[0] + c[2] + (c[1] - c[2]) // 3)\n else:\n print(c[0] + c[1] + (c[2] - c[1]) // 3)\n", "def ain():\n return map(int,input().split())\ndef lin():\n return list(ain())\n\n\ndef plist(l):\n for x in l:\n print(x, end= ' ')\n print()\n\ndef indexof(l,v,l3):\n return l3[v]\n\n\nfor _ in range(int(input())):\n n = int(input())\n l = lin()\n a=0\n b=0\n c=0\n for x in l:\n if x%3 == 0:\n a+=1\n elif x%3 == 1:\n b+=1\n else:\n c += 1\n s = a + min(b,c)\n if b > c:\n s += (b-c)//3\n else:\n s += (c-b)//3\n\n print(s)", "t = int(input())\nfor l in range(t):\n n = int(input())\n arr = list(map(int,input().split()))\n co1 = 0\n co2 = 0\n co = 0\n for i in arr:\n if i%3==0:\n co += 1\n if i%3==1:\n co1 += 1\n if i%3==2:\n co2 += 1\n ans = co\n ans += min(co1,co2)\n left = max(co2,co1)-min(co2,co1)\n ans += int(left/3)\n print(ans)", "def main():\n for i in range(int(input())):\n n = int(input())\n a = [int(i) for i in input().split()]\n thr = 0\n tw = 0\n on = 0\n for val in a:\n if val % 3 == 0:\n thr += 1\n elif val % 3 == 2:\n tw += 1\n else:\n on += 1\n if tw == on:\n print(thr + tw)\n elif tw > on:\n print(thr + on + (tw - on) // 3)\n else:\n print(thr + tw + (on - tw) // 3)\n\n\nmain()\n", "def solve():\n n = int(input())\n a = list(map(int, input().split()))\n p0, p1, p2 = 0, 0, 0\n for el in a:\n if el % 3 == 0:\n p0 += 1\n elif el % 3 == 1:\n p1 += 1\n else:\n p2 += 1\n return p0 + min(p1, p2) + (max(p1, p2) - min(p1, p2)) // 3\n\nq = int(input())\nfor i in range(q):\n print(solve())", "import math\nimport bisect\nimport heapq\nfrom collections import defaultdict\n\n\ndef egcd(a, b):\n if a == 0:\n return (b, 0, 1)\n else:\n g, x, y = egcd(b % a, a)\n return (g, y - (b // a) * x, x)\n\n\ndef mulinv(b, n):\n g, x, _ = egcd(b, n)\n if g == 1:\n return x % n\n\n\ndef isprime(n):\n for d in range(2, int(math.sqrt(n))+1):\n if n % d == 0:\n return False\n return True\n\n\ndef argsort(ls):\n return sorted(range(len(ls)), key=ls.__getitem__)\n\n\ndef f(p=0):\n if p == 1:\n return map(int, input().split())\n elif p == 2:\n return list(map(int, input().split()))\n elif p == 3:\n return list(input())\n else:\n return int(input())\n\n\nclass DisjointSet:\n _disjoint_set = list()\n\n def __init__(self, init_arr):\n self._disjoint_set = []\n if init_arr:\n for item in list(set(init_arr)):\n self._disjoint_set.append([item])\n\n def _find_index(self, elem):\n for item in self._disjoint_set:\n if elem in item:\n return self._disjoint_set.index(item)\n return None\n\n def find(self, elem):\n for item in self._disjoint_set:\n if elem in item:\n return self._disjoint_set[self._disjoint_set.index(item)]\n return None\n\n def union(self, elem1, elem2):\n index_elem1 = self._find_index(elem1)\n index_elem2 = self._find_index(elem2)\n if index_elem1 != index_elem2 and index_elem1 is not None and index_elem2 is not None:\n self._disjoint_set[index_elem2] = self._disjoint_set[index_elem2] + self._disjoint_set[index_elem1]\n del self._disjoint_set[index_elem1]\n return self._disjoint_set\n\n def get(self):\n return self._disjoint_set\n\n\ndef graph(n, m, edg=False):\n edges = []\n visited = [0]*n\n g = [list() for _ in range(n+1)]\n for i in range(m):\n u, v = f(1)\n g[u].append(v)\n g[v].append(u)\n if edg:\n edges.append((u, v))\n\n if edg:\n return g, visited, edg\n else:\n return g, visited\n\n\ndef bfs(g, visited):\n queue = [1]\n visited[1] = 1\n for u in queue:\n for v in g[u]:\n if visited[v] == 0:\n queue.append(v)\n visited[v] = 1\n\n\ndef dfs(u, g, visited):\n print(u)\n visited[u] = 1\n for v in g[u]:\n if visited[v] == 0:\n dfs(v, g, visited)\n\n\nt = f()\nfor i in range(t):\n n = f()\n cl = f(2)\n count = 0\n a = 0\n b = 0\n for i in range(n):\n if cl[i]%3==0:\n count+=1\n elif cl[i]%3==1:\n a+=1\n else:\n b+=1\n\n print(count+min(a, b)+(max(a, b) - min(a, b))//3)", "q = int(input())\nfor _ in range(q):\n n = int(input())\n u = list(map(int, input().split()))\n a0, a1, a2 = [0, 0, 0]\n for i in range(n):\n if u[i] % 3 == 0:\n a0 += 1\n elif u[i] % 3 == 1:\n a1 += 1\n else:\n a2 += 1\n w1 = a0 + min(a1, a2)\n w2 = min(a1, a2)\n a1 -= w2; a2 -= w2\n w1 += a1 // 3 + a2 // 3\n print(w1)\n \n", "n = int(input())\nfor i in range(n):\n q = int(input())\n l = list(map(int, input().split()))\n a = 0\n b = 0\n c = 0\n for i in range(q):\n if(l[i]%3==0):\n a+=1\n elif(l[i]%3==1):\n b+=1\n else:\n c+=1\n print(a+min(c,b)+(max(c,b)-min(c,b))//3)\n", "def f():\n l=[int(k)%3 for k in input().split()]\n a=sum([k==1 for k in l])\n b=sum([k==2 for k in l])\n a,b=sorted((a,b))\n c=len(l)-a-b\n return (a+c+(b-a)//3)\nfor k in range(int(input())):\n input()\n print(f())\n", "from collections import Counter\n\nt=int(input())\nfor query in range(t):\n n=int(input())\n A=list(map(int,input().split()))\n\n B=[i%3 for i in A]\n\n C=Counter(B)\n\n ANS=C[0]\n x=min(C[1],C[2])\n ANS+=x\n C[1]-=x\n C[2]-=x\n\n ANS+=C[1]//3+C[2]//3\n\n print(ANS)\n\n \n", "for i in range(int(input())):\n n = int(input()) \n A = list(map(int, input().split())) \n d = {0:0,1:0, 2:0} \n for i in A:\n d[i % 3] += 1\n Z = min(d[1],d[2])\n d[1] -= Z\n d[2] -= Z\n print(d[0] + Z + d[1] // 3 + d[2] // 3)\n \n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n a = list(map(int, input().split()))\n a = [i % 3 for i in a]\n c0 = a.count(0)\n c1 = a.count(1)\n c2 = a.count(2)\n x = min(c1, c2)\n c1 -= x\n c2 -= x\n s = c0 + x + c1 // 3 + c2 // 3\n print(s)\n", "from sys import stdin\nq=int(stdin.readline().strip())\nfor i in range(q):\n n=int(stdin.readline().strip())\n s=list(map(int,stdin.readline().strip().split()))\n u=0\n z=0\n d=0\n for i in range(n):\n s[i]=s[i]%3\n if s[i]==0:\n z+=1\n elif s[i]==1:\n u+=1\n else:\n d+=1\n ans=0\n ans+=z\n ans+=min(u,d)\n if u<=d:\n d-=u\n x=0\n for i in range(d):\n x+=2\n x=x%3\n if x==0:\n ans+=1\n else:\n u-=d\n x=0\n for i in range(u):\n x+=1\n x=x%3\n if x==0:\n ans+=1\n print(ans)\n \n", "n = int(input())\nfor i in range(n):\n x = int(input())\n a = [int(i) for i in input().split()]\n zero = 0\n one = 0\n two = 0\n for i in range(x):\n if a[i] % 3 == 0:\n zero += 1\n elif a[i] % 3 == 1:\n one += 1\n else:\n two += 1\n print(zero + min(two, one) + (max(two, one) - min(two, one)) // 3)", "q = int(input())\nfor i in range(q):\n n = int(input())\n l = list(map(int, input().split()))\n cnt1 = 0\n cnt0 = 0\n cnt2 = 0\n for j in range(n):\n if l[j] % 3 == 0:\n cnt0 += 1\n elif l[j] % 3 == 1:\n cnt1 += 1\n else:\n cnt2 += 1\n cnt0 += min(cnt2, cnt1)\n tmp = cnt2\n cnt2 -= min(tmp, cnt1)\n cnt1 -= min(tmp, cnt1)\n print(cnt0 + cnt2 // 3 + cnt1 // 3)", "from collections import Counter as C\nfor TT in range(1, int(input()) + 1):\n n = int(input()) \n c = C(map(lambda x: int(x) % 3, input().split()))\n x, y, z = c.get(0, 0), c.get(1, 0), c.get(2, 0) \n d = min(y, z)\n y -= d\n z -= d\n x += d\n y //= 3\n z //= 3\n print(x + y + z)", "t = int(input())\nfor i in range(t):\n n = int(input())\n a = [int(s) for s in input().split(' ')]\n ost0, ost1, ost2 = 0, 0, 0\n col = 0\n for el in a:\n if el % 3 == 0:\n ost0 += 1\n elif el % 3 == 1:\n ost1 += 1\n elif el % 3 == 2:\n ost2 += 1\n col += ost0 + min(ost1, ost2) + (max(ost1, ost2) - min(ost1, ost2)) // 3\n print(col)", "t = int(input())\n\nfor _ in range(t):\n n = int(input())\n arr = list(map(int, input().split()))\n\n mod_0, mod_1, mod_2 = 0, 0, 0\n for el in arr:\n if el % 3 == 0:\n mod_0 += 1\n elif el % 3 == 1:\n mod_1 += 1\n elif el % 3 == 2:\n mod_2 += 1\n\n res = mod_0\n\n # add mod 1 and mod 2\n min_1_2 = min(mod_1, mod_2)\n res += min_1_2\n mod_1 -= min_1_2\n mod_2 -= min_1_2\n\n # add mod 1, 2\n res += mod_1 // 3\n res += mod_2 // 3\n print(res)\n", "t = int(input())\n\ndef solve(arr, n):\n ones = 0\n twos = 0\n for item in arr:\n if item % 3 == 1:\n ones += 1\n elif item % 3 == 2:\n twos += 1\n zeros = n - ones - twos\n threes = abs(ones - twos) // 3\n return zeros + min(ones, twos) + threes\n\nfor _ in range(t):\n n = int(input())\n arr = list(map(int, input().strip().split()))\n print(solve(arr, n))\n", "q = int(input())\nfor iqwwq in range(q):\n n = int(input())\n sp = input().split()\n k0, k1, k2 = 0, 0, 0\n for i in sp:\n if int(i) % 3 == 0:\n k0 += 1\n elif int(i) % 3 == 1:\n k1 += 1\n else:\n k2 += 1\n if k2 > k1:\n k2 -= k1\n print(k0 + k1 + (k2 // 3))\n else:\n k1 -= k2\n print(k0 + (k1 // 3) + k2)"] | {
"inputs": [
"2\n5\n3 1 2 3 1\n7\n1 1 1 1 1 2 2\n",
"1\n5\n3 3 3 3 3\n"
],
"outputs": [
"3\n3\n",
"5\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 13,127 | |
6be9fee0c09d94f3863ca75d8355da78 | UNKNOWN | You are given a permutation of length $n$. Recall that the permutation is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2, 3, 1, 5, 4]$ is a permutation, but $[1, 2, 2]$ is not a permutation ($2$ appears twice in the array) and $[1, 3, 4]$ is also not a permutation ($n=3$ but there is $4$ in the array).
You can perform at most $n-1$ operations with the given permutation (it is possible that you don't perform any operations at all). The $i$-th operation allows you to swap elements of the given permutation on positions $i$ and $i+1$. Each operation can be performed at most once. The operations can be performed in arbitrary order.
Your task is to find the lexicographically minimum possible permutation obtained by performing some of the given operations in some order.
You can see the definition of the lexicographical order in the notes section.
You have to answer $q$ independent test cases.
For example, let's consider the permutation $[5, 4, 1, 3, 2]$. The minimum possible permutation we can obtain is $[1, 5, 2, 4, 3]$ and we can do it in the following way:
perform the second operation (swap the second and the third elements) and obtain the permutation $[5, 1, 4, 3, 2]$; perform the fourth operation (swap the fourth and the fifth elements) and obtain the permutation $[5, 1, 4, 2, 3]$; perform the third operation (swap the third and the fourth elements) and obtain the permutation $[5, 1, 2, 4, 3]$. perform the first operation (swap the first and the second elements) and obtain the permutation $[1, 5, 2, 4, 3]$;
Another example is $[1, 2, 4, 3]$. The minimum possible permutation we can obtain is $[1, 2, 3, 4]$ by performing the third operation (swap the third and the fourth elements).
-----Input-----
The first line of the input contains one integer $q$ ($1 \le q \le 100$) β the number of test cases. Then $q$ test cases follow.
The first line of the test case contains one integer $n$ ($1 \le n \le 100$) β the number of elements in the permutation.
The second line of the test case contains $n$ distinct integers from $1$ to $n$ β the given permutation.
-----Output-----
For each test case, print the answer on it β the lexicograhically minimum possible permutation obtained by performing some of the given operations in some order.
-----Example-----
Input
4
5
5 4 1 3 2
4
1 2 4 3
1
1
4
4 3 2 1
Output
1 5 2 4 3
1 2 3 4
1
1 4 3 2
-----Note-----
Recall that the permutation $p$ of length $n$ is lexicographically less than the permutation $q$ of length $n$ if there is such index $i \le n$ that for all $j$ from $1$ to $i - 1$ the condition $p_j = q_j$ is satisfied, and $p_i < q_i$. For example:
$p = [1, 3, 5, 2, 4]$ is less than $q = [1, 3, 5, 4, 2]$ (such $i=4$ exists, that $p_i < q_i$ and for each $j < i$ holds $p_j = q_j$), $p = [1, 2]$ is less than $q = [2, 1]$ (such $i=1$ exists, that $p_i < q_i$ and for each $j < i$ holds $p_j = q_j$). | ["q = int(input())\nfor qi in range(q):\n n = int(input())\n a = list(map(int, input().split()))\n used = [False] * n\n for t in range(n):\n for i in range(len(a) - 1, 0, -1):\n if used[i]:\n continue\n if a[i] < a[i - 1]:\n a[i], a[i - 1] = a[i - 1], a[i]\n used[i] = True\n print(' '.join(str(x) for x in a))", "q=int(input())\nfor t in range(q):\n n=int(input())\n a=list(map(int,input().split()))\n used=[0]*n\n for i in range(1,n+1):\n ind=a.index(i)\n while ind>0 and used[ind-1]==0 and a[ind-1]>i:\n s=a[ind-1]\n a[ind]=s\n a[ind-1]=i\n used[ind-1]=1\n ind-=1\n print(*a)\n", "q=int(input())\nfor i in range(q):\n w=int(input())\n e=list(map(int,input().split()))\n r=[1]*w\n for k in range(1,w+1):\n t=e.index(k)\n while t>0 and r[t-1] and e[t]<e[t-1]:\n if r[t-1]:\n e[t-1],e[t]=e[t],e[t-1]\n r[t-1]=0\n t-=1\n print(*e)", "import sys\ninput = sys.stdin.readline\n\nq=int(input())\n\ndef sortper(begin):\n x=A.index(min(A[begin:]))\n\n return x,A[:begin]+[A[x]]+A[begin:x]+A[x+1:]\n \n\nfor testcases in range(q):\n n=int(input())\n A=list(map(int,input().split()))\n\n begin=0\n\n while begin<n-1:\n nbegin,A=sortper(begin)\n\n if begin==nbegin:\n begin+=1\n else:\n begin=nbegin\n\n #print(begin,\" \",*A)\n print(*A)\n\n \n", "t=int(input())\nfor tt in range(t):\n\tn=int(input())\n\tarr=list(map(int,input().split()))\n\tvisited=[0]*(n)\n\tindex=[0]*(n+1)\n\tfor i in range(1,n+1):\n\t\tindex[i]=arr.index(i)\n\t# while 1:\n\tfor i in range(1,n+1):\n\t\tfor j in range(index[i],0,-1):\n\t\t\tif visited[j]==0 and arr[j-1]>arr[j]:\n\t\t\t\ttemp=arr[j]\n\t\t\t\tarr[j]=arr[j-1]\n\t\t\t\tarr[j-1]=temp\n\t\t\t\tvisited[j]+=1\n\t\t\t\t# flag=True\n\tfor i in arr:\n\t\tprint(i,end=\" \")\n\tprint()", "for _ in range(int(input())):\n n=int(input())\n l=[int(i) for i in input().split()]\n k=n-1 \n i=0 \n while i<n:\n mini=l[i]\n ind=-1 \n j=i+1 \n while j<min(n,i+k+1): \n if l[j]<mini:\n mini=l[j]\n ind=j\n j+=1 \n if ind==-1:\n i+=1 ;\n continue \n #print(ind)\n temp=ind \n while ind>i and k!=0:\n #print('ef')\n l[ind],l[ind-1]=l[ind-1],l[ind]\n # print(l)\n ind-=1 \n k-=1 \n i=temp \n print(*l)", "import io, sys, atexit, os\nimport math as ma\nfrom decimal import Decimal as dec\nfrom itertools import permutations\nfrom itertools import combinations\n\n\ndef li ():\n\treturn list (map (int, sys.stdin.readline ().split ()))\n\n\ndef num ():\n\treturn map (int, sys.stdin.readline ().split ())\n\n\ndef nu ():\n\treturn int (input ())\n\n\ndef find_gcd ( x, y ):\n\twhile (y):\n\t\tx, y = y, x % y\n\treturn x\n\n\ndef lcm ( x, y ):\n\tgg = find_gcd (x, y)\n\treturn (x * y // gg)\n\n\nmm = 1000000007\n\n\ndef solve ():\n\tt = nu()\n\tfor tt in range (t):\n\t\tn=nu()\n\t\ta=li()\n\t\tb=[0]*n\n\t\tfor i in range(1,n+1):\n\t\t\tind=-1\n\t\t\tfor j in range(n):\n\t\t\t\tif(a[j]==i):\n\t\t\t\t\tind=j\n\t\t\t\t\tbreak\n\t\t\twhile(ind>0):\n\t\t\t\toz=ind-1\n\t\t\t\tif(b[oz]==1):\n\t\t\t\t\tbreak\n\t\t\t\tif(a[oz]<a[ind]):\n\t\t\t\t\tbreak\n\t\t\t\tb[oz]=1\n\t\t\t\ta[oz],a[ind]=a[ind],a[oz]\n\t\t\t\tind-=1\n\t\tprint(*a)\n\n\n\n\ndef __starting_point():\n\tsolve ()\n__starting_point()", "from sys import stdin\n\nfor _ in range(int(stdin.readline())):\n\n\tn = int(stdin.readline())\n\tarr = [int(x) for x in stdin.readline().split()]\n\n\tflags = [0]*n\n\n\tany = True\n\n\twhile any==True:\n\n\t\tany = False\n\n\t\tfor i in range(n-1,0,-1):\n\n\t\t\tif arr[i-1]>arr[i] and flags[i-1]==0:\n\t\t\t\t\tany = True\n\t\t\t\t\tflags[i-1] = 1\n\t\t\t\t\tarr[i-1],arr[i] = arr[i],arr[i-1]\n\n\tfor i in arr: print(i,end=\" \")\n\tprint()", "for _ in range(int(input())):\n n = int(input())\n arr = list(map(int, input().split()))\n brr = [0]*(n-1)\n\n for i in range(n-2,-1,-1):\n if arr[i]>arr[i+1]:\n arr[i], arr[i+1] = arr[i+1], arr[i]\n brr[i] = 1\n\n for i in range(n-1):\n if arr[i]>arr[i+1] and brr[i]==0:\n arr[i], arr[i+1] = arr[i+1], arr[i]\n brr[i] = 1\n print(*arr) \n \n", "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn list(map(int,minp().split()))\n\ndef solve():\n\tn = mint()\n\ta = list(mints())\n\tb = [True]*n\n\tfor i in range(n-1):\n\t\tj = i + 1\n\t\tz = (a[i],i)\n\t\twhile j < n and b[j-1]:\n\t\t\tz = min(z, (a[j], j))\n\t\t\tj += 1\n\t\tif z[0] < a[i]:\n\t\t\tj = z[1] - 1\n\t\t\twhile j >= i:\n\t\t\t\ta[j], a[j+1] = a[j+1], a[j]\n\t\t\t\tb[j] = False\n\t\t\t\tj -= 1\n\tprint(*a)\n\n\nfor i in range(mint()):\n\tsolve()\n", "q = int(input())\nfor __ in [0]*q:\n n = int(input())\n a = list(map(int,input().split()))\n idx = [-1]*(n+1)\n for i,e in enumerate(a):\n idx[e] = i\n\n res = []\n k = -1\n for i,e in enumerate(idx):\n if e == -1:\n continue\n if e > k:\n res.append(i)\n if i != 1:\n if res[-1] < res[-2]:\n res[-1],res[-2] = res[-2],res[-1]\n for i in range(k+1,e):\n res.append(a[i])\n k = e\n for e in res:\n if e != res[-1]:\n print(e,end = ' ')\n else:\n print(e)", "import sys\n\n\ndef main():\n for _ in range(int(input())):\n n = int(input())\n arr = get_array()\n d = {}\n\n def solve(i):\n idx = 0\n for j in range(n):\n if arr[j] == i:\n idx = j\n break\n p = idx\n for j in range(idx - 1, -1, -1):\n if p in d:\n break\n if arr[j] < arr[p]:\n break\n arr[p], arr[j] = arr[j], arr[p]\n d[p] = 1\n p -= 1\n\n for i in range(1, n + 1):\n solve(i)\n print(*arr)\n\n\ninput = lambda: sys.stdin.readline().strip()\nget_ints = lambda: list(map(int, input().split()))\nget_array = lambda: list(map(int, input().split()))\nmain()\n", "ct = int(input())\nfor c in range(ct):\n n = int(input())\n li = [int(i) for i in input().split()]\n\n op = [0 for i in range(n)]\n for i in range(1, n+1):\n pos = li.index(i)\n for j in range(pos-1, -1, -1):\n if op[j] == 0 and li[j] > li[j+1]:\n op[j] = 1\n li[j], li[j+1] = li[j+1], li[j]\n else:\n break\n # print(op)\n print(*li)\n", "for _ in range(int(input())):\n n=int(input())\n l1=list(map(int,input().split()))\n stack=[]\n marked={}\n i=0\n j=1\n result=[]\n while j<=n:\n if j not in marked:\n stack=[]\n result.append(j)\n while l1[i]!=j:\n marked[l1[i]]=1\n stack.append(l1[i])\n i+=1\n marked[j]=1\n\n if stack:\n l1[i]=stack[-1]\n del marked[stack[-1]]\n result.extend(stack[:len(stack)-1])\n else :\n i+=1\n j+=1\n print(*result,sep=\" \")\n ", "q=int(input())\nwhile(q):\n q-=1\n n=int(input())\n *a,=map(int,input().split())\n u=[False for i in range(n+1)]\n u[0]=True\n for i in range(1,n+1):\n for j in range(n):\n if a[j]==i:\n x=j\n while not u[x] and a[x]<a[x-1]:\n a[x],a[x-1]=a[x-1],a[x]\n u[x]=True\n x -= 1\n print(*a)", "import sys\ninput=sys.stdin.readline\ny=int(input())\nfor i in range(y):\n\tn=int(input())\n\tarr=list(map(int,input().split())) \n\ta=0\n\tvisited=[0]*n\n\t\n\tfor j in range(n):\n\t\tfor k in range(n-1,0,-1):\n\t\t\tif(visited[k-1]==0 and arr[k-1]>arr[k]):\n\t\t\t\tvisited[k-1]=1\n\t\t\t\ttemp=arr[k-1]\n\t\t\t\tarr[k-1]=arr[k]\n\t\t\t\tarr[k]=temp\n\n\ts=\"\"\n\tfor j in arr:\n\t\ts=s+str(j)+\" \"\n\ts=s[:-1]\n\tprint(s)", "def doit(lst):\n # print(lst)\n n = len(lst)\n if(n<=1):\n return(lst)\n index = lst.index(min(lst))\n if(index==0):\n l = doit(lst[1:])\n return([lst[0]]+l)\n temp = [lst[index-1]]+lst[index+1:]\n \n return([lst[index]] + lst[:index-1]+doit(temp))\n\nt = int(input())\nfor _ in range(t):\n n = int(input())\n lst = list(map(int, input().split()))\n print(*doit(lst))\n \n \n", "def f(a, l):\n m = a[l]\n mi = l\n for i in range(l, len(a)):\n if a[i] < m:\n m = a[i]\n mi = i\n\n for i in range(mi, l, -1):\n a[i] = a[i - 1]\n a[l] = m\n return mi if mi != l else mi + 1\n\n\nfor _ in range(int(input())):\n n = int(input())\n a = [int(x) for x in input().split()]\n mi = 0\n while mi < n:\n mi = f(a, mi)\n print(*a)\n", "q = int(input())\nres = []\nfor _ in range(q):\n n = int(input())\n a = list(map(int, input().split()))\n l = 0\n for m in range(1, n+1):\n i = a.index(m)\n if i <= l:\n continue\n for j in range(i-1, l-1, -1):\n if a[j] < a[j+1]:\n break\n a[j], a[j+1] = a[j+1], a[j]\n l = i\n\n res.append(' '.join(map(str, a)))\n\nprint(*res, sep='\\n')", "t = int(input())\nanswer = []\n\ndef mini(arr):\n minimum = arr[0]\n index = 0\n for i in range (1, len(arr)):\n if minimum > arr[i]:\n minimum = arr[i]\n index = i\n return index\n\nfor i in range (t):\n n = int(input())\n p = list(map(int,input().split()))\n ans = []\n \n while len(p) > 1:\n index = mini(p)\n ans.append(p[index])\n for k in range (index - 1):\n ans.append(p[k])\n p = p[index-1 : index] + p[index + 1:]\n if len(p) == 1:\n ans.append(p[0])\n answer.append(ans)\nfor i in range (t):\n print (*answer[i], sep = \" \")", "t = int(input())\nwhile(t > 0):\n t -= 1\n n = int(input())\n arr = list(map(int, input().split()))\n bol = [True for i in range(n)]\n flag = True\n while(flag):\n flag = False\n for i in range(n-1):\n if(arr[n-i-1] < arr[n-i-2] and bol[n-i-1]):\n bol[n-i-1] = False\n tmp = arr[n-i-1]\n arr[n-i-1] = arr[n-i-2]\n arr[n-i-2] = tmp\n flag = True\n for x in range(n):\n if(x > 0):print(\" \",end=\"\")\n print(arr[x],end=\"\")\n print()", "def optimize(arr, idx):\n if idx >= len(arr):\n return\n min_idx = -1\n min_val = 1e9\n for i in range(idx, len(arr)):\n if arr[i] < min_val:\n min_val = arr[i]\n min_idx = i\n\n \n\n for i in range(min_idx-1, idx-1,-1):\n tmp=arr[i]\n arr[i]=arr[i+1]\n arr[i+1]=tmp\n \n if min_idx == idx:\n min_idx += 1 \n optimize(arr,min_idx)\n\nq=int(input())\nfor t in range(q):\n n=int(input())\n a=[int(x) for x in input().split()]\n optimize(a,0)\n print(*a)\n", "for _ in range(int(input())):\n n = int(input())\n *a, = map(int, input().split())\n ans, i = [], 0\n while a:\n m = min(a)\n x = a.index(m)\n ans.append(m)\n if x == 0:\n a.remove(m)\n continue\n ans += a[:x - 1]\n a = a[x - 1:]\n if m in a:\n a.remove(m)\n \n print(*ans)"] | {
"inputs": [
"4\n5\n5 4 1 3 2\n4\n1 2 4 3\n1\n1\n4\n4 3 2 1\n",
"1\n5\n4 2 3 5 1\n"
],
"outputs": [
"1 5 2 4 3 \n1 2 3 4 \n1 \n1 4 3 2 \n",
"1 4 2 3 5 \n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,961 | |
c723dc1e9556fc2c13a0a9896df0b2f7 | UNKNOWN | There are $n$ students standing in a circle in some order. The index of the $i$-th student is $p_i$. It is guaranteed that all indices of students are distinct integers from $1$ to $n$ (i. e. they form a permutation).
Students want to start a round dance. A clockwise round dance can be started if the student $2$ comes right after the student $1$ in clockwise order (there are no students between them), the student $3$ comes right after the student $2$ in clockwise order, and so on, and the student $n$ comes right after the student $n - 1$ in clockwise order. A counterclockwise round dance is almost the same thing β the only difference is that the student $i$ should be right after the student $i - 1$ in counterclockwise order (this condition should be met for every $i$ from $2$ to $n$).
For example, if the indices of students listed in clockwise order are $[2, 3, 4, 5, 1]$, then they can start a clockwise round dance. If the students have indices $[3, 2, 1, 4]$ in clockwise order, then they can start a counterclockwise round dance.
Your task is to determine whether it is possible to start a round dance. Note that the students cannot change their positions before starting the dance; they cannot swap or leave the circle, and no other student can enter the circle.
You have to answer $q$ independent queries.
-----Input-----
The first line of the input contains one integer $q$ ($1 \le q \le 200$) β the number of queries. Then $q$ queries follow.
The first line of the query contains one integer $n$ ($1 \le n \le 200$) β the number of students.
The second line of the query contains a permutation of indices $p_1, p_2, \dots, p_n$ ($1 \le p_i \le n$), where $p_i$ is the index of the $i$-th student (in clockwise order). It is guaranteed that all $p_i$ are distinct integers from $1$ to $n$ (i. e. they form a permutation).
-----Output-----
For each query, print the answer on it. If a round dance can be started with the given order of students, print "YES". Otherwise print "NO".
-----Example-----
Input
5
4
1 2 3 4
3
1 3 2
5
1 2 3 5 4
1
1
5
3 2 1 5 4
Output
YES
YES
NO
YES
YES | ["'''input\n5\n4\n1 2 3 4\n3\n1 3 2\n5\n1 2 3 5 4\n1\n1\n5\n3 2 1 5 4\n\n'''\nimport sys\nfrom collections import defaultdict as dd\nfrom itertools import permutations as pp\nfrom itertools import combinations as cc\nfrom collections import Counter as ccd\nfrom random import randint as rd\nfrom bisect import bisect_left as bl\nfrom heapq import heappush as hpush\nfrom heapq import heappop as hpop\nmod=10**9+7\n\ndef ri(flag=0):\n\tif flag==0:\n\t\treturn [int(i) for i in sys.stdin.readline().split()]\n\telse:\n\t\treturn int(sys.stdin.readline())\n\n\n\nfor _ in range(ri(1)):\n\tn = ri(1)\n\ta= ri()\n\tidx = a.index(1)\n\n\tcheck1 = 1\n\tcheck2 =1\n\tfor i in range(n):\n\t\tif a[(idx+i)%n] == i+1:\n\t\t\tpass\n\t\telse:\n\t\t\tcheck1=0\n\ta=a[::-1]\n\tidx = a.index(1)\n\tfor i in range(n):\n\t\tif a[(idx+i)%n] == i+1:\n\t\t\tpass\n\t\telse:\n\t\t\tcheck2=0\n\n\tif check1==1 or check2==1:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")", "from collections import deque\nfor _ in range(int(input())):\n n = int(input())\n A = list(map(int, input().split()))\n ans = 'NO'\n B = deque(A)\n C = [i for i in range(1, n + 1)]\n D = C[::-1]\n for i in range(n):\n B.popleft()\n B.append(A[i])\n if list(B) == C or list(B) == D:\n ans = 'YES'\n print(ans)", "q=int(input())\nfor i in range(q):\n n=int(input())\n arr=[int(x) for x in input().split()]\n l=arr[0]\n forwards=True\n back=True\n for j in range(n-1):\n if arr[j]-1!=(arr[0]-1+j)%n:\n forwards=False\n if arr[j]-1!=(arr[0]-1-j)%n:\n back=False\n if forwards==True or back==True:\n print(\"YES\")\n else:\n print(\"NO\")", "q = int(input())\nfor i in range(q):\n\tn = int(input())\n\tp = list(map(int, input().split()))\n\tfor i in range(n - 1):\n\t\tif p[i] + 1 != p[i+1] and not(p[i] == n and p[i+1] == 1):\n\t\t\tbreak\n\telse:\n\t\tprint('YES')\n\t\tcontinue\n\tfor i in range(n - 1):\n\t\tif p[i] - 1 != p[i+1] and not(p[i] == 1 and p[i+1] == n):\n\t\t\tbreak\n\telse:\n\t\tprint('YES')\n\t\tcontinue\n\tprint('NO')\n", "n=int(input())\nfor x in range(n):\n t=int(input())\n r=list(map(int,input().split()))\n r=r+r\n l1=[x for x in range(1,t+1)]\n l2=l1[::-1]\n bo=0\n for i in range(t):\n if(r[i:i+t]==l1):\n bo=1\n if(r[i:i+t]==l2):\n bo=1\n if(bo==1):\n print(\"YES\")\n else:\n print(\"NO\")\n", "from sys import stdin\nq=int(stdin.readline().strip())\nfor i in range(q):\n n=int(stdin.readline().strip())\n s=list(map(int,stdin.readline().strip().split()))\n x=s.index(1)\n y=1\n t=True\n for i in range(n):\n if s[x]!=y:\n t=False\n break\n x=(x+1)%n\n y+=1\n t1=True\n x=s.index(1)\n y=1\n for i in range(n):\n\n if s[x]!=y:\n t1=False\n break\n x=(x-1)%n\n y+=1\n if t or t1:\n print(\"YES\")\n else:\n print(\"NO\")\n \n", "for q in range(int(input())):\n n = int(input())\n a = [int(x) for x in input().split()]\n\n idx = a.index(1)\n\n b = a[idx : ] + a[ : idx]\n c = a[ : idx + 1][::-1] + a[idx +1 : ][::-1]\n\n a.sort()\n\n if b == a or c == a:\n print(\"YES\")\n else:\n print(\"NO\")\n", "for _ in range(int(input())):\n n = int(input())\n l = [*map(int, input().split())]\n res = False\n for i in range(n):\n x = l[i:] + l[:i]\n if all(x[i] < x[i + 1] for i in range(n - 1)) or all(x[i] > x[i + 1] for i in range(n - 1)):\n res = True\n print('YES' if res else 'NO')", "q = int (input())\nwhile q:\n n = int(input())\n a = list(map(int, input().split()))\n a += a\n p = [i for i in range(1, n + 1)]\n flag = False\n for i in range(n):\n if a[i: i + n] == p or a[i: i + n] == p[::-1]:\n print(\"YES\")\n flag = True\n break\n if not flag:\n print(\"NO\")\n q -= 1\n", "for _ in range(int(input())):\n\tn = int(input())\n\tans = [i + 1 for i in range(n)]\n\tl = list(map(int, input().split()))\n\tone = l.index(1)\n\tl = l[one:] + l[:one]\n\trev = l[::-1]\n\tone = rev.index(1)\n\trev = rev[one:] + rev[:one]\n\tif rev == ans or l == ans:\n\t\tprint('YES')\n\telse:\n\t\tprint('NO')", "q = int(input())\nfor _ in range(q):\n n = int(input())\n p = list(map(int, input().split()))\n i = p.index(1)\n p2 = p[i:] + p[:i]\n if p2 == list(range(1, n + 1)) or p2[1:] == list(reversed(list(range(2, n + 1)))):\n print('YES')\n else:\n print('NO')\n", "t = int(input())\nfor _ in range(t):\n\tn = int(input())\n\tc = list(map(int,input().split()))\n\tidx = 0\n\tf = 0\n\tf2 = 0\n\tfor i in range(n):\n\t\tif(c[i]==1):\n\t\t\tidx = i\n\t\t\tbreak\n\n\tfor i in range(n):\n\t\tif(c[(idx+i)%n]!=i+1):\n\t\t\tf = 1\n\t\tif(c[idx-i]!=i+1):\n\t\t\tf2 = 1\n\tif f == 1 and f2 ==1:\n\t\tprint('NO')\n\telse:\n\t\tprint('YES')", "n = int(input())\nfor _ in range(n):\n\t_ = int(input())\n\t*l, = map(int, input().split())\n\tans = False\n\tfor i in range(len(l)-1):\n\t\tif l[i] == len(l):\n\t\t\tif not l[i+1] == 1:\n\t\t\t\tbreak\n\t\telse:\n\t\t\tif not l[i] + 1 == l[i+1]:\n\t\t\t\tbreak\n\telse:\n\t\tans = True\n\tfor i in range(len(l)-1):\n\t\tif l[i] == 1:\n\t\t\tif not l[i+1] == len(l):\n\t\t\t\tbreak\n\t\telse:\n\t\t\tif not l[i] - 1 == l[i+1]:\n\t\t\t\tbreak\n\telse:\n\t\tans = True\n\tif ans:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")", "#579_A\n\nq = int(input())\n\nfor i in range(0, q):\n n = int(input())\n ln = [int(j) for j in input().split(\" \")]\n st = 0\n f = True\n for j in range(1, len(ln)):\n if abs(ln[j] - ln[j - 1]) != 1 and abs(ln[j] - ln[j - 1]) != n - 1:\n f = False\n break\n if abs(ln[0] - ln[-1]) != 1 and abs(ln[0] - ln[-1]) != n - 1:\n f = False\n if f:\n print(\"YES\")\n else:\n print(\"NO\")\n \n", "import math\n# helpful:\n# r,g,b=map(int,input().split())\n#list1 = input().split()\n#for i in range(len(list1)):\n# list1[i] = int(list1[i])\n#print(list1)\n# arr = [[0 for x in range(columns)] for y in range(rows)]\n\nq = int(input())\nfor i in range(q):\n n = int(input())\n arr = input().split()\n for i in range(n):\n arr[i] = int(arr[i])\n if(n<=3):\n print(\"YES\")\n else:\n havent = True\n val = (arr[1]-arr[0]) % n\n if(val != 1 and val != n-1):\n print(\"NO\")\n else:\n for i in range(n-1):\n if((arr[i+1]-arr[i]) % n != val and havent):\n print(\"NO\")\n havent = False\n if(havent):\n print(\"YES\")\n \n \n", "q = int(input())\nfor qq in range(q):\n n = int(input())\n *p, = list(map(int, input().split()))\n for i in range(n-1):\n if (p[i+1]-p[i]!=1 and not(p[i+1]==1 and p[i]==n)):\n break\n else:\n print(\"YES\")\n continue\n\n for i in range(n-1):\n if (p[i+1]-p[i]!=-1 and not(p[i+1]==n and p[i]==1)):\n break\n else:\n print(\"YES\")\n continue\n \n print(\"NO\")\n", "import sys\n\ndef solve(A):\n n = len(A)\n t = A[0]-1\n cw = True\n for a in A:\n if t != a-1:\n cw = False\n t = (t+1)%n\n t = A[0]-1\n ccw = True\n for a in A:\n if t != a-1:\n ccw = False\n t = (n+t-1)%n\n return (ccw or cw)\n\nin_file = sys.stdin #open(\"A.txt\", \"r\") \n\nq = int(in_file.readline().strip())\nfor _ in range(q):\n n = int(in_file.readline().strip())\n A = list(map(int, in_file.readline().strip().split()))\n if solve(A):\n sys.stdout.write(\"YES\\n\")\n else:\n sys.stdout.write(\"NO\\n\")\nsys.stdout.flush()", "for _ in range(int(input())):\n n = int(input())\n p = list(int(a) for a in input().split())\n c = 0\n if p[n-1] < p[0]:\n c += 1\n for i in range(1, n):\n if p[i-1] < p[i]:\n c += 1\n if c == n-1 or c == 1:\n print(\"YES\")\n else:\n print(\"NO\")", "\nq = int(input())\n\nfor i in range(q):\n n = int(input())\n p = list(map(int,input().split()))\n q = p+p+p\n p = sorted(p)\n r = p[::-1]\n f = 0\n for k in range(2*n):\n if q[k:k+n] == r or q[k:k+n] == p:\n f = 1\n break\n if f == 0:\n print(\"NO\")\n else:\n print(\"YES\")\n", "'''q=int(input())\nfor I in range(q):\n n=int(input())\n a=[int(i) for i in input().split()]\n ind = a.find(1)\n ini = [(i+1) for i in range(n)]\n arr1 = a[ind:]\n arr2 = a[:ind]\n if(sorted(arr1)==a['''\n\ndef main():\n t=int(input())\n for q in range(t):\n n = int(input())\n a = [int(x) for x in input().split()]\n\n idx = a.index(1)\n\n b = a[idx : ] + a[ : idx]\n c = a[ : idx + 1][::-1] + a[idx +1 : ][::-1]\n\n a.sort()\n\n if b == a or c == a:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nmain()\n", "''' \u0628\u0650\u0633\u0652\u0645\u0650 \u0627\u0644\u0644\u064e\u0651\u0647\u0650 \u0627\u0644\u0631\u064e\u0651\u062d\u0652\u0645\u064e\u0670\u0646\u0650 \u0627\u0644\u0631\u064e\u0651\u062d\u0650\u064a\u0645\u0650 '''\n#codeforces1203A_live\ngi = lambda : list(map(int,input().split()))\nfor k in range(gi()[0]):\n\tn, = gi()\n\tl = gi()\n\tcl = l[l.index(1):] + l[:l.index(1)]\n\tccl = l[l.index(n):] + l[:l.index(n)]\n\tp = [i for i in range(1, n + 1)]\n\tif cl == p or ccl == p[::-1]:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")", "t = int(input())\n\nwhile t:\n t -= 1\n n = int(input())\n arr = [int(item) for item in input().split(' ')]\n ans = True\n for i in range(n):\n if (arr[i - 1] + 1) % n == arr[i] % n:\n continue\n ans = False\n break\n\n ans2 = True\n for i in range(n):\n if (arr[i] + 1) % n == arr[i - 1] % n:\n continue\n ans2 = False\n break\n print(\"YES\" if ans or ans2 else \"NO\")\n", "w = int(input())\ndef fun(x, n):\n\tif x % n != 0:\n\t\treturn x % n\n\telse:\n\t\treturn n\nfor we in range(w):\n\tn = int(input())\n\tl = list(map(int,input().split()))\n\tif n == 1:\n\t\tprint(\"YES\")\n\telse:\n\t\tstart = l[0]\n\t\todp = 1\n\t\tif l[1] == fun(l[0] + 1, n):\n\t\t\tfor i in range(1, n):\n\t\t\t\tif l[i] != fun(l[i-1] + 1, n):\n\t\t\t\t\todp = 0\n\t\t\t\t\tbreak\n\t\telif l[1] == fun(l[0] - 1, n):\n\t\t\tfor i in range(1, n):\n\t\t\t\tif l[i] != fun(l[i-1] - 1, n):\n\t\t\t\t\todp = 0\n\t\t\t\t\tbreak\n\t\telse:\n\t\t\todp = 0\n\t\tif odp == 0:\n\t\t\tprint(\"NO\")\n\t\telse:\n\t\t\tprint(\"YES\")", "for _ in range(int(input())):\n n = int(input())\n p = list(map(int, input().split()))\n i = p.index(1)\n if p[i:] + p[:i] == sorted(p) or p[i + 1:] + p[:i + 1] == sorted(p, reverse=True):\n print(\"YES\")\n else:\n print(\"NO\")"] | {
"inputs": [
"5\n4\n1 2 3 4\n3\n1 3 2\n5\n1 2 3 5 4\n1\n1\n5\n3 2 1 5 4\n",
"1\n12\n12 3 4 5 6 7 8 9 10 11 1 2\n"
],
"outputs": [
"YES\nYES\nNO\nYES\nYES\n",
"NO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 11,094 | |
a27648b30a743a0c532b2c43880914ad | UNKNOWN | Santa has $n$ candies and he wants to gift them to $k$ kids. He wants to divide as many candies as possible between all $k$ kids. Santa can't divide one candy into parts but he is allowed to not use some candies at all.
Suppose the kid who recieves the minimum number of candies has $a$ candies and the kid who recieves the maximum number of candies has $b$ candies. Then Santa will be satisfied, if the both conditions are met at the same time:
$b - a \le 1$ (it means $b = a$ or $b = a + 1$); the number of kids who has $a+1$ candies (note that $a+1$ not necessarily equals $b$) does not exceed $\lfloor\frac{k}{2}\rfloor$ (less than or equal to $\lfloor\frac{k}{2}\rfloor$).
$\lfloor\frac{k}{2}\rfloor$ is $k$ divided by $2$ and rounded down to the nearest integer. For example, if $k=5$ then $\lfloor\frac{k}{2}\rfloor=\lfloor\frac{5}{2}\rfloor=2$.
Your task is to find the maximum number of candies Santa can give to kids so that he will be satisfied.
You have to answer $t$ independent test cases.
-----Input-----
The first line of the input contains one integer $t$ ($1 \le t \le 5 \cdot 10^4$) β the number of test cases.
The next $t$ lines describe test cases. The $i$-th test case contains two integers $n$ and $k$ ($1 \le n, k \le 10^9$) β the number of candies and the number of kids.
-----Output-----
For each test case print the answer on it β the maximum number of candies Santa can give to kids so that he will be satisfied.
-----Example-----
Input
5
5 2
19 4
12 7
6 2
100000 50010
Output
5
18
10
6
75015
-----Note-----
In the first test case, Santa can give $3$ and $2$ candies to kids. There $a=2, b=3,a+1=3$.
In the second test case, Santa can give $5, 5, 4$ and $4$ candies. There $a=4,b=5,a+1=5$. The answer cannot be greater because then the number of kids with $5$ candies will be $3$.
In the third test case, Santa can distribute candies in the following way: $[1, 2, 2, 1, 1, 2, 1]$. There $a=1,b=2,a+1=2$. He cannot distribute two remaining candies in a way to be satisfied.
In the fourth test case, Santa can distribute candies in the following way: $[3, 3]$. There $a=3, b=3, a+1=4$. Santa distributed all $6$ candies. | ["q = int(input())\nfor z in range(q):\n n, k = map(int, input().split())\n x = n // k\n n -= x * k\n m = min(k // 2, n)\n print(x * k + m)", "t = int(input())\nfor i in range(t):\n\tn, k = list(map(int, input().split()))\n\tz = n // k\n\tn -= z * k\n\tprint(z * k + min(n, k // 2))\n", "import sys\ninput = sys.stdin.readline\n\nt=int(input())\nfor test in range(t):\n n,k=list(map(int,input().split()))\n\n if n%k>k//2:\n n-=(n%k)-k//2\n\n print(n)\n\n", "import sys\nimport collections\nfrom collections import Counter\nimport itertools\nimport math\nimport timeit\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\n\ndef divs(n, start=1):\n divisors = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if n % i == 0:\n if n / i == i:\n divisors.append(i)\n else:\n divisors.extend([i, n // i])\n return divisors\n\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\n\ndef flin(d, x, default=-1):\n left = right = -1\n for i in range(len(d)):\n if d[i] == x:\n if left == -1: left = i\n right = i\n if left == -1:\n return (default, default)\n else:\n return (left, right)\n\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return list(map(int, input().split()))\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\n\n# input = sys.stdin.readline\n\nt = ii()\nfor _ in range(t):\n n, k = mi()\n q = n // k\n print(min(n, q * k + (k // 2)))\n", "t = int(input())\nfor i in range(t):\n\tn, k = list(map(int, input().split()))\n\tn1 = n % k\n\tk1 = int(k / 2)\n\tif n1 <= k1:\n\t\tprint(n)\n\telse:\n\t\tprint(n - n1 + k1)\n", "q=int(input())\nfor i in range(q):\n n,k=map(int,input().split())\n ans=n//k*k+min(n%k,k//2)\n print(ans)", "a = int(input())\nfor i in range(a):\n x, y = map(int, input().split())\n u = x//y\n o = x%y\n print(u*y + min(o, y//2))", "import sys\n# from collections import defaultdict\nt=1\nt=int(input())\nfor i in range(t):\n n,m=list(map(int,sys.stdin.readline().strip().split()))\n # a=list(map(int,sys.stdin.readline().strip().split()))\n # b=list(map(int,sys.stdin.readline().strip().split()))\n # d = defaultdict(int)\n # print((24-n-1)*60+60-m)\n x=n//m\n n\n print(x*m+min(n-x*m,m//2))\n \n", "t=int(input())\nwhile t:\n n,k=map(int,input().split())\n print(n-max(0,n%k-k//2))\n t-=1", "q = int(input())\nfor iwer in range(q):\n\tc, kids = map(int,input().split())\n\tdystr = (c//kids)*kids\n\tcc = c\n\tc -= dystr\n\tpoz = max(0, c - kids//2)\n\tprint(cc-poz)", "t = int(input())\nfor i in range(t):\n n, k = list(map(int, input().split()))\n if n % k <= k // 2:\n print(n)\n else:\n print((n // k) * k + k // 2)\n", "import sys\n\ndef minp():\n\treturn sys.stdin.readline().strip()\n\ndef mint():\n\treturn int(minp())\n\ndef mints():\n\treturn list(map(int, minp().split()))\n\ndef solve():\n\tn, k = mints()\n\tx = n // k\n\tr = n % k\n\tif r > k // 2:\n\t\tprint(n - (r - k//2))\n\telse:\n\t\tprint(n)\n\nfor i in range(mint()):\n\tsolve()\n", "from sys import stdin,stdout\ntt=int(stdin.readline().strip())\nfor t in range(tt):\n n,k=list(map(int,stdin.readline().strip().split()))\n x=n//k\n y=n-x*k\n ans=x*k+min(k//2,y)\n print(ans)\n\n\n", "T = int(input())\nfor _ in range(T):\n n,k = list(map(int, input().split()))\n print(n//k*k + min(n%k, int(k/2)))\n", "for _ in range(int(input())):\n n,k = list(map(int, input().split()))\n ans = (n//k)*k + min(k//2,n%k)\n print(ans)\n", "import sys\ninput = sys.stdin.readline\ndef getInt(): return int(input())\ndef getVars(): return list(map(int, input().split()))\ndef getList(): return list(map(int, input().split()))\ndef getStr(): return input().strip()\n## -------------------------------\n\nt= getInt()\nfor _ in range(t):\n n, k = getVars()\n m = n // k\n if m*k == n:\n print(n)\n continue\n m1 = k//2\n res = min(n, m*k + m1)\n print(res)\n\n", "for tc in range(int(input())):\n ncand, nkid = list(map(int, input().split()))\n res = (ncand//nkid)*nkid\n ncand -= res\n res += min(ncand, nkid//2)\n print(res)\n \n", "for nt in range(int(input())):\n\tn,k=map(int,input().split())\n\ta=n%k\n\tif a>k//2:\n\t\tprint (n-(a-k//2))\n\telse:\n\t\tprint (n)", "import math\nfrom decimal import Decimal\nimport heapq\nfrom collections import deque\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 da():\n\tn, m = list(map(int, input().split()))\n\ta = list(map(int, input().split()))\n\treturn n,m, a \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 \ndef lol(lst,k):\n\tk=k%len(lst)\n\tret=[0]*len(lst)\n\tfor i in range(len(lst)):\n\t\tif i+k<len(lst) and i+k>=0:\n\t\t\tret[i]=lst[i+k]\n\t\tif i+k>=len(lst):\n\t\t\tret[i]=lst[i+k-len(lst)]\n\t\tif i+k<0:\n\t\t\tret[i]=lst[i+k+len(lst)]\n\treturn(ret)\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\ndef fact(a, b):\n\tc = []\n\tans = 0\n\tf = int(math.sqrt(a))\n\tfor i in range(1, f + 1):\n\t\tif a % i == 0:\n\t\t\tc.append(i)\n\tl = len(c)\n\tfor i in range(l):\n\t\tc.append(a // c[i])\n\tfor i in range(len(c)):\n\t\tif c[i] <= b:\n\t\t\tans += 1\n\tif a / f == f and b >= f:\n\t\treturn ans - 1\n\treturn ans\n\n\nimport math\nfrom decimal import Decimal\nimport heapq\nfrom collections import deque\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 da():\n\tn, m = list(map(int, input().split()))\n\ta = list(map(int, input().split()))\n\treturn n,m, a \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 \ndef lol(lst,k):\n\tk=k%len(lst)\n\tret=[0]*len(lst)\n\tfor i in range(len(lst)):\n\t\tif i+k<len(lst) and i+k>=0:\n\t\t\tret[i]=lst[i+k]\n\t\tif i+k>=len(lst):\n\t\t\tret[i]=lst[i+k-len(lst)]\n\t\tif i+k<0:\n\t\t\tret[i]=lst[i+k+len(lst)]\n\treturn(ret)\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 \ndef fact(a, b):\n\tc = []\n\tans = 0\n\tf = int(math.sqrt(a))\n\tfor i in range(1, f + 1):\n\t\tif a % i == 0:\n\t\t\tc.append(i)\n\tl = len(c)\n\tfor i in range(l):\n\t\tc.append(a // c[i])\n\tfor i in range(len(c)):\n\t\tif c[i] <= b:\n\t\t\tans += 1\n\tif a / f == f and b >= f:\n\t\treturn ans - 1\n\treturn ans\n \n \nfor i in range(int(input())):\n\tn, k = list(map(int, input().split()))\n\td = n // k\n\tn -= d * k\n\tans = d * k + min(k // 2, n)\n\tprint(ans) \n", "\n\n\ndef main():\n a, b = list(map(int, input().split()))\n k = b // 2\n print(min(a - (a % b - k), a))\n\n\n\nc = int(input())\n\nfor i in range(c):\n main()\n\n", "t = int(input())\nfor i in range (t):\n n, k = list(map(int,input().split()))\n m = n % k\n print(n - m + min(k//2, m) )", "Q = int(input())\n\nfor q in range(Q):\n n, k = [int(x) for x in input().split()]\n maximum = (n//k)*k + k//2\n print(min([maximum, n]))", "q=int(input())\nfor i in range(q):\n n,k=list(map(int,input().split()))\n y=n%k\n print((n//k)*k+min(y,k//2))\n", "for _ in range(int(input())):\n n,k = [int(s) for s in input().split()]\n ans = (n//k)*k\n ans1 = n%k\n ans+= min(k//2, ans1)\n print(ans)"] | {
"inputs": [
"5\n5 2\n19 4\n12 7\n6 2\n100000 50010\n",
"1\n1233212 4\n"
],
"outputs": [
"5\n18\n10\n6\n75015\n",
"1233212\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 9,380 | |
9c6972c485fa53c65bd129d6e3d1a622 | UNKNOWN | You are given two positive integers $n$ ($1 \le n \le 10^9$) and $k$ ($1 \le k \le 100$). Represent the number $n$ as the sum of $k$ positive integers of the same parity (have the same remainder when divided by $2$).
In other words, find $a_1, a_2, \ldots, a_k$ such that all $a_i>0$, $n = a_1 + a_2 + \ldots + a_k$ and either all $a_i$ are even or all $a_i$ are odd at the same time.
If such a representation does not exist, then report it.
-----Input-----
The first line contains an integer $t$ ($1 \le t \le 1000$) β the number of test cases in the input. Next, $t$ test cases are given, one per line.
Each test case is two positive integers $n$ ($1 \le n \le 10^9$) and $k$ ($1 \le k \le 100$).
-----Output-----
For each test case print:
YES and the required values $a_i$, if the answer exists (if there are several answers, print any of them); NO if the answer does not exist.
The letters in the words YES and NO can be printed in any case.
-----Example-----
Input
8
10 3
100 4
8 7
97 2
8 8
3 10
5 3
1000000000 9
Output
YES
4 2 4
YES
55 5 5 35
NO
NO
YES
1 1 1 1 1 1 1 1
NO
YES
3 1 1
YES
111111110 111111110 111111110 111111110 111111110 111111110 111111110 111111110 111111120 | ["t=int(input())\nfor i in range (t):\n n,k=map(int,input().split())\n if n-k+1>0 and (n-k+1)%2==1:\n print(\"YES\")\n print(*([1]*(k-1)), n-k+1)\n elif n-k*2+2>0 and (n-k*2+2)%2==0:\n print(\"YES\")\n print(*([2]*(k-1)), n-k*2+2)\n else:\n print(\"NO\")", "t = int(input())\nfor _ in range(t):\n n, k = list(map(int, input().split()))\n if n % 2 == k % 2 and n >= k:\n print('YES')\n out = [1] * k\n out[0] += (n - k)\n print(*out)\n elif n % 2 == 0 and n >= 2 * k:\n print('YES')\n out = [2] * k\n out[0] += (n - 2*k)\n print(*out)\n else:\n print('NO')\n", "for _ in range(int(input())):\n n, k = list(map(int, input().split()))\n if k % 2 == 1:\n if n % 2 == 0:\n if 2*k <= n:\n print('YES')\n print(*[2]*(k-1), n-2*(k-1))\n else:\n print('NO')\n else:\n if k <= n:\n print('YES')\n print(*[1]*(k-1), n-k+1)\n else:\n print('NO')\n else:\n if k <= n and n % 2 == 0:\n print('YES')\n print(*[1]*(k-1), n-k+1)\n else:\n print('NO')\n", "import sys\n\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nns = lambda: readline().rstrip()\nni = lambda: int(readline().rstrip())\nnm = lambda: map(int, readline().split())\nnl = lambda: list(map(int, readline().split()))\nprn = lambda x: print(*x, sep='\\n')\n\n\ndef solve():\n n, k = nm()\n l = [1]*(k-1) + [n-k+1]\n if l[-1] > 0 and l[-1] % 2:\n print('YES')\n print(*l)\n return\n l = [2]*(k-1) + [n - 2*(k-1)]\n if l[-1] > 0 and l[-1] % 2 == 0:\n print('YES')\n print(*l)\n return\n print('NO')\n return\n\n# solve()\n\nT = ni()\nfor _ in range(T):\n solve()\n", "for _ in range(int(input())):\n n, k = map(int, input().split())\n odd = n - k + 1\n even = n - ((k-1) * 2)\n if odd > 0 and odd % 2 == 1:\n print('YES')\n print('1 ' * (k-1), odd, sep='')\n elif even > 0 and even % 2 == 0:\n print('YES')\n print('2 ' * (k-1), even, sep='')\n else:\n print('NO')", "for i in range(int(input())):\n n,k=[int(i) for i in input().split()]\n if k>n:\n print('NO')\n elif (n-k+1)%2==1 and n-k+1>0:\n print('YES')\n for i in range(k-1):\n print(1,end=' ')\n print(n-k+1)\n elif (n-2*(k-1))%2==0 and n-2*(k-1)>0:\n print('YES')\n for i in range(k-1):\n print(2,end=' ')\n print(n-2*(k-1))\n else:\n print('NO')\n", "import sys\nimport os\nimport time\nimport collections\nfrom collections import Counter, deque\nimport itertools\nimport math\nimport timeit\nimport random\nimport string\n\n#########################\n# imgur.com/Pkt7iIf.png #\n#########################\n\ndef sieve(n):\n if n < 2: return list()\n prime = [True for _ in range(n + 1)]\n p = 3\n while p * p <= n:\n if prime[p]:\n for i in range(p * 2, n + 1, p):\n prime[i] = False\n p += 2\n r = [2]\n for p in range(3, n + 1, 2):\n if prime[p]:\n r.append(p)\n return r\n\ndef divs(n, start=1):\n divisors = []\n for i in range(start, int(math.sqrt(n) + 1)):\n if n % i == 0:\n if n / i == i:\n divisors.append(i)\n else:\n divisors.extend([i, n // i])\n return divisors\n\ndef divn(n, primes):\n divs_number = 1\n for i in primes:\n if n == 1:\n return divs_number\n t = 1\n while n % i == 0:\n t += 1\n n //= i\n divs_number *= t\n\ndef flin(d, x, default=-1):\n left = right = -1\n for i in range(len(d)):\n if d[i] == x:\n if left == -1: left = i\n right = i\n if left == -1:\n return default, default\n else:\n return left, right\n\ndef ceil(n, k): return n // k + (n % k != 0)\ndef ii(): return int(input())\ndef mi(): return list(map(int, input().split()))\ndef li(): return list(map(int, input().split()))\ndef lcm(a, b): return abs(a * b) // math.gcd(a, b)\ndef prr(a, sep=' '): print(sep.join(map(str, a)))\ndef dd(): return collections.defaultdict(int)\ndef ddl(): return collections.defaultdict(list)\n\n########################################################################################################################\n# input = sys.stdin.readline\n\nfor _ in range(ii()):\n n, k = mi()\n even = n - 2*(k - 1)\n odd = n - (k - 1)\n if odd > 0 and odd % 2:\n res = [1]*(k - 1) + [odd]\n print('YES')\n prr(res, ' ')\n elif even > 0 and even % 2 == 0:\n res = [2] * (k - 1) + [even]\n print('YES')\n prr(res, ' ')\n else:\n print('NO')\n", "for tc in range(int(input())):\n n, k = [int(s) for s in input().split()]\n\n if n % 2 == 1 and k % 2 == 0:\n print('NO')\n continue\n \n if n % 2 == 0 and k % 2 == 1:\n least = 2\n else:\n least = 1\n\n if least * k > n:\n print('NO')\n continue\n\n print('YES')\n print(*([n - least*k + least] + [least] * (k-1)))\n", "t = int(input())\nfor _ in range(t):\n n, k = list(map(int, input().split()))\n ans = []\n if n % 2 == 0:\n if k % 2 == 0:\n for i in range(k-1):\n ans.append(1)\n n -= 1\n ans.append(n)\n\n else:\n for i in range(k-1):\n ans.append(2)\n n -= 2\n ans.append(n)\n\n else:\n if k % 2 == 0:\n ans.append(-1)\n else:\n for i in range(k-1):\n ans.append(1)\n n -= 1\n ans.append(n)\n if min(ans) <= 0:\n print(\"NO\")\n else:\n print(\"YES\")\n print(*ans)\n", "t = int(input())\nfor _ in range(t):\n\tn, k = map(int, input().split())\n\tif k%2 == 0 and n%2 == 1:\n\t\tprint(\"NO\")\n\telif (k%2 == 1 and n%2 == 0 and n < 2*k) or n < k:\n\t\tprint(\"NO\")\n\telif k%2 == 1 and n%2 == 0:\n\t\tprint(\"YES\")\n\t\tans = [2] * (k-1) + [n-2*(k-1)]\n\t\tprint(*ans)\n\telse:\n\t\tprint(\"YES\")\n\t\tans = [1] * (k-1) + [n-k+1]\n\t\tprint(*ans)", "for t in range(int(input())):\n n,k = map(int,input().split())\n if n < k:\n print(\"NO\")\n elif n%2==k%2:\n print(\"YES\")\n print(*([1]*(k-1)+[n-(k-1)]))\n elif n%2==0 and n >= 2*k-1:\n print(\"YES\")\n print(*([2]*(k-1)+[n-2*(k-1)]))\n else:\n print(\"NO\")", "import sys\ninput = sys.stdin.readline\n\nt=int(input())\nfor tests in range(t):\n n,k=list(map(int,input().split()))\n\n if n%2==k%2 and n>=k:\n print(\"YES\")\n ANS=[1]*(k-1)+[n-(k-1)]\n print(*ANS)\n\n elif n%2==0 and n>=2*k:\n print(\"YES\")\n ANS=[2]*(k-1)+[n-2*(k-1)]\n print(*ANS)\n else:\n print(\"NO\")\n \n \n \n", "import math,sys\nfrom sys import stdin, stdout\nfrom collections import Counter, defaultdict, deque\ninput = stdin.readline\nI = lambda:int(input())\nli = lambda:list(map(int,input().split()))\n\ndef case():\n n,k=li()\n if(k>n):\n print(\"NO\")\n return()\n if((n-k-1)%2):\n print(\"YES\")\n for i in range(k-1):\n print(1,end=\" \")\n print(n+1-k)\n return \n if(n-2*k<0):\n print(\"NO\")\n return \n else:\n \n if((n-2*k-2)%2==0):\n print(\"YES\")\n for i in range(k-1):\n print(2,end=\" \")\n print(n-2*k+2)\n else:\n print(\"NO\") \nfor _ in range(int(input())):\n case()", "import math\nfor _ in range(int(input())):\n\tn,k=list(map(int,input().split()))\n\tif n<k:\n\t\tprint(\"NO\")\n\telse:\n\t\tif n%2==0:\n\t\t\tif k%2==0:\n\t\t\t\td=[]\n\t\t\t\tfor i in range(k-1):\n\t\t\t\t\td.append(1)\n\t\t\t\td.append(n-k+1)\n\t\t\t\tprint(\"YES\")\n\t\t\t\tprint(*d)\n\t\t\telse:\n\t\t\t\tif n<2*k:\n\t\t\t\t\tprint(\"NO\")\n\t\t\t\telse:\n\t\t\t\t\td=[]\n\t\t\t\t\tfor i in range(k-1):\n\t\t\t\t\t\td.append(2)\n\t\t\t\t\td.append(n-2*(k-1))\n\t\t\t\t\tprint(\"YES\")\n\t\t\t\t\tprint(*d)\n\t\telse:\n\t\t\tif k%2==1:\n\t\t\t\td=[]\n\t\t\t\tfor i in range(k-1):\n\t\t\t\t\td.append(1)\n\t\t\t\td.append(n-k+1)\n\t\t\t\tprint(\"YES\")\n\t\t\t\tprint(*d)\n\t\t\telse:\n\t\t\t\tprint(\"NO\")\n\n\n\n\t\n", "for f in range(int(input())):\n n,k=map(int,input().split())\n if k%2==0:\n if n%2==0:\n if n<k:\n print(\"NO\")\n else:\n print(\"YES\")\n sol=[1]*k\n sol[0]=n-k+1\n print(*sol)\n else:\n print(\"NO\")\n else:\n if n%2==0:\n if 2*k>n:\n print(\"NO\")\n else:\n print(\"YES\")\n sol=[2]*k\n sol[0]=n-2*k+2\n print(*sol)\n else:\n if k>n:\n print(\"NO\")\n else:\n print(\"YES\")\n sol=[1]*k\n sol[0]=n-k+1\n print(*sol)"] | {
"inputs": [
"8\n10 3\n100 4\n8 7\n97 2\n8 8\n3 10\n5 3\n1000000000 9\n",
"7\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n1 2\n"
],
"outputs": [
"YES\n2 2 6\nYES\n1 1 1 97\nNO\nNO\nYES\n1 1 1 1 1 1 1 1\nNO\nYES\n1 1 3\nYES\n2 2 2 2 2 2 2 2 999999984\n",
"NO\nNO\nNO\nNO\nNO\nNO\nNO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 9,330 | |
3486f033b21db73cc5e64ebec51c2663 | UNKNOWN | Alice and Bob have received three big piles of candies as a gift. Now they want to divide these candies as fair as possible. To do this, Alice takes one pile of candies, then Bob takes one of the other two piles. The last pile is split between Alice and Bob as they want: for example, it is possible that Alice takes the whole pile, and Bob gets nothing from it.
After taking the candies from the piles, if Alice has more candies than Bob, she discards some candies so that the number of candies she has is equal to the number of candies Bob has. Of course, Bob does the same if he has more candies.
Alice and Bob want to have as many candies as possible, and they plan the process of dividing candies accordingly. Please calculate the maximum number of candies Alice can have after this division process (of course, Bob will have the same number of candies).
You have to answer $q$ independent queries.
Let's see the following example: $[1, 3, 4]$. Then Alice can choose the third pile, Bob can take the second pile, and then the only candy from the first pile goes to BobΒ β then Alice has $4$ candies, and Bob has $4$ candies.
Another example is $[1, 10, 100]$. Then Alice can choose the second pile, Bob can choose the first pile, and candies from the third pile can be divided in such a way that Bob takes $54$ candies, and Alice takes $46$ candies. Now Bob has $55$ candies, and Alice has $56$ candies, so she has to discard one candyΒ β and after that, she has $55$ candies too.
-----Input-----
The first line of the input contains one integer $q$ ($1 \le q \le 1000$)Β β the number of queries. Then $q$ queries follow.
The only line of the query contains three integers $a, b$ and $c$ ($1 \le a, b, c \le 10^{16}$)Β β the number of candies in the first, second and third piles correspondingly.
-----Output-----
Print $q$ lines. The $i$-th line should contain the answer for the $i$-th queryΒ β the maximum number of candies Alice can have after the division, if both Alice and Bob act optimally (of course, Bob will have the same number of candies).
-----Example-----
Input
4
1 3 4
1 10 100
10000000000000000 10000000000000000 10000000000000000
23 34 45
Output
4
55
15000000000000000
51 | ["from sys import stdin,stdout\nimport sys\nimport math\n\nt=int(stdin.readline())\nfor i in range(t):\n a=list(map(int,stdin.readline().split()))\n print(sum(a)//2)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "for i in range(int(input())):\n a = list(map(int, input().split()))\n print((a[0] + a[1] + a[2]) // 2)\n", "ll= lambda : list(map(int,input().split()))\ntestcases=1\ntestcases=int(input())\nfor testcase in range(testcases):\n [a,b,c]=ll()\n print((a+b+c)//2)\n", "import sys\n# sys.stdin.readline()\nt=int(sys.stdin.readline())\nfor i in range(t):\n a=list(map(int,sys.stdin.readline().strip().split()))\n op=sum(a)\n print(op//2)\n", "t=int(input())\nfor i in range(0,t):\n\tl=list(map(int,input().split()))\n\ts=sum(l)\n\ts=s//2\n\tprint(s)", "mod = 1000000007\nii = lambda : int(input())\nsi = lambda : input()\ndgl = lambda : list(map(int, input()))\nf = lambda : map(int, input().split())\nil = lambda : list(map(int, input().split()))\nls = lambda : list(input())\nn=ii()\nfor i in range(n):\n a,b,c=f()\n print((a+b+c)//2)", "for _ in range(int(input())):\n a,b,c=map(int,input().split())\n print((a+b+c)//2)", "n = int(input())\nfor _ in range(n):\n\tl = list(map(int, input().split()))\n\ts = sum(l)\n\tprint(s // 2)", "n = int(input())\nfor i in range(n):\n a, b, c = map(int, input().split())\n print((a+b+c)//2)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Jul 14 12:40:58 2019\n\n@author: Hamadeh\n\"\"\"\nclass cinn:\n def __init__(self):\n self.x=[]\n def cin(self,t=int):\n if(len(self.x)==0):\n a=input()\n self.x=a.split()\n self.x.reverse()\n return self.get(t)\n def get(self,t):\n return t(self.x.pop())\n def clist(self,n,t=int): #n is number of inputs, t is type to be casted\n l=[0]*n\n for i in range(n):\n l[i]=self.cin(t)\n return l\n def clist2(self,n,t1=int,t2=int,t3=int,tn=2):\n l=[0]*n\n for i in range(n):\n if(tn==2):\n a1=self.cin(t1)\n a2=self.cin(t2)\n l[i]=(a1,a2)\n elif (tn==3):\n a1=self.cin(t1)\n a2=self.cin(t2)\n a3=self.cin(t3)\n l[i]=(a1,a2,a3)\n return l\n def clist3(self,n,t1=int,t2=int,t3=int):\n return self.clist2(self,n,t1,t2,t3,3)\n def cout(self,i,ans=''): \n if(ans==''):\n print(\"Case #\"+str(i+1)+\":\", end=' ')\n else:\n print(\"Case #\"+str(i+1)+\":\",ans)\n def printf(self,thing):\n print(thing,end='')\n def countlist(self,l,s=0,e=None):\n if(e==None):\n e=len(l)\n dic={}\n for el in range(s,e):\n if l[el] not in dic:\n dic[l[el]]=1\n else:\n dic[l[el]]+=1\n return dic\n def talk (self,x):\n print(x,flush=True)\n def dp1(self,k):\n L=[-1]*(k)\n return L\n def dp2(self,k,kk):\n L=[-1]*(k)\n for i in range(k):\n L[i]=[-1]*kk\n return L\n def isprime(self,n):\n if(n==1 or n==0):\n return False\n for i in range(2,int(n**0.5+1)):\n if(n%i==0):\n return False\n return True\n def factors(self,n): \n from functools import reduce\n return set(reduce(list.__add__, \n ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n def nthprime(self,n):\n #usable up to 10 thousand\n i=0\n s=2\n L=[]\n while(i<n):\n while(not self.isprime(s)):\n s+=1\n L.append(s)\n s+=1\n i+=1\n return L\n def matrixin(self,m,n,t=int):\n L=[]\n for i in range(m):\n p=self.clist(n,t)\n L.append(p)\n return L\n def seive(self,k):\n #1000000 tops\n n=k+1\n L=[True]*n\n L[1]=False\n L[0]=False\n for i in range(2,n):\n if(L[i]==True):\n for j in range(2*i,n,i):\n L[j]=False\n return L\n def seiven(self,n,L):\n i=0\n for j in range(len(L)):\n if(L[j]==True):\n i+=1\n if(i==n):\n return j\n def matrixin2(self,m,t=int):\n L=[]\n for i in range(m):\n iny=self.cin(str)\n lsmall=[]\n for el in iny:\n lsmall.append(t(el))\n L.append(lsmall)\n return L\nc=cinn()\nque=c.cin()\nfor i in range(que):\n q=c.cin()\n x=c.cin()\n z=c.cin()\n print((x+z+q)//2)", "q=int(input())\nfor i in range(q):\n\ta,b,c=map(int,input().split())\n\tprint ((a+b+c)//2)", "for i in range(int(input())):\n a,b,c=map(int, input().split())\n print((a+b+c)//2)", "q = int(input())\nfor Q in range(q):\n A = [int(i) for i in input().split()]\n A.sort()\n alice = A[0]\n bob = A[1]\n excess = A[2]\n\n total = sum(A)\n\n each = total//2\n\n print(each)\n", "import sys\ninput = lambda: sys.stdin.readline().strip()\n\nT = int(input())\nfor i in range(T):\n a, b, c = list(map(int, input().split()))\n print((a+b+c)//2)\n", "Q = int(input())\nfor _ in range(Q):\n a, b, c = list(map(int, input().split()))\n print((a+b+c)//2)\n\n", "from bisect import *\nfrom collections import *\nfrom itertools import *\nimport functools\nimport sys\nimport math\nfrom decimal import *\nfrom copy import *\ngetcontext().prec = 30\nMAX = sys.maxsize\nMAXN = 10**5+10\nMOD = 10**9+7\ndef isprime(n):\n n = abs(int(n))\n if n < 2:\n return False\n if n == 2: \n return True \n if not n & 1: \n return False\n for x in range(3, int(n**0.5) + 1, 2):\n if n % x == 0:\n return False\n return True\n\ndef mhd(a,b):\n return abs(a[0]-b[0])+abs(b[1]-a[1])\n\ndef charIN(x= ' '):\n return(sys.stdin.readline().strip().split(x))\n\ndef arrIN(x = ' '):\n return list(map(int,sys.stdin.readline().strip().split(x)))\n\ndef eld(x,y):\n a = y[0]-x[0]\n b = x[1]-y[1]\n return (a*a+b*b)**0.5\n\ndef lgcd(a):\n g = a[0]\n for i in range(1,len(a)):\n g = math.gcd(g,a[i])\n return g\n\ndef ms(a):\n msf = -MAX\n meh = 0\n st = en = be = 0\n for i in range(len(a)):\n meh+=a[i]\n if msf<meh:\n msf = meh\n st = be\n en = i\n if meh<0:\n meh = 0\n be = i+1\n return msf,st,en\n\ndef ncr(n,r):\n num=den=1\n for i in range(r):\n num = (num*(n-i))%MOD\n den = (den*(i+1))%MOD\n\n return (num*(pow(den,MOD-2,MOD)))%MOD\n\n\n\ndef flush():\n return sys.stdout.flush()\n\n'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''\nfor _ in range(int(input())):\n a,b,c = arrIN()\n print((a+b+c)//2)\n \n", "for _ in range(int(input())):\n l=list(map(int,input().split()))\n a=sum(l)\n print(a//2)", "import math\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 a, b, c = Read.list_int()\n print((a + b + c) // 2)\n\n\nquery_count = Read.int()\nfor j in range(query_count):\n solve()\n", "#Anuneet Anand\nq=int(input())\nwhile q:\n\ta,b,c=list(map(int,input().split()))\n\tA=[a,b,c]\n\tprint(sum(A)//2)\n\tq=q-1\n", "import sys\n\nt = int(input())\nfor i in range(t):\n a, b, c = list(map(int, sys.stdin.readline().split()))\n print((a+b+c)//2)\n", "q = int(input())\nfor _ in range(q):\n a,b,c = list(map(int,input().split()))\n sum = a+b+c\n print(sum//2)\n", "for i in range(int(input())):\n a, b, c = list(map(int, input().split()))\n print((a + b + c) // 2)\n", "t = int(input())\nfor _ in range(t):\n a = list(map(int,input().split()))\n s = sum(a)\n print(s//2)"] | {
"inputs": [
"4\n1 3 4\n1 10 100\n10000000000000000 10000000000000000 10000000000000000\n23 34 45\n",
"1\n111 2 3\n"
],
"outputs": [
"4\n55\n15000000000000000\n51\n",
"58\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 8,191 | |
1fb4a986458d0b68a9532ed108386e4e | UNKNOWN | You are given an array $a$ consisting of $n$ integers $a_1, a_2, \dots, a_n$. You want to split it into exactly $k$ non-empty non-intersecting subsegments such that each subsegment has odd sum (i. e. for each subsegment, the sum of all elements that belong to this subsegment is odd). It is impossible to rearrange (shuffle) the elements of a given array. Each of the $n$ elements of the array $a$ must belong to exactly one of the $k$ subsegments.
Let's see some examples of dividing the array of length $5$ into $3$ subsegments (not necessarily with odd sums): $[1, 2, 3, 4, 5]$ is the initial array, then all possible ways to divide it into $3$ non-empty non-intersecting subsegments are described below: $[1], [2], [3, 4, 5]$; $[1], [2, 3], [4, 5]$; $[1], [2, 3, 4], [5]$; $[1, 2], [3], [4, 5]$; $[1, 2], [3, 4], [5]$; $[1, 2, 3], [4], [5]$.
Of course, it can be impossible to divide the initial array into exactly $k$ subsegments in such a way that each of them will have odd sum of elements. In this case print "NO". Otherwise, print "YES" and any possible division of the array. See the output format for the detailed explanation.
You have to answer $q$ independent queries.
-----Input-----
The first line contains one integer $q$ ($1 \le q \le 2 \cdot 10^5$) β the number of queries. Then $q$ queries follow.
The first line of the query contains two integers $n$ and $k$ ($1 \le k \le n \le 2 \cdot 10^5$) β the number of elements in the array and the number of subsegments, respectively.
The second line of the query contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$), where $a_i$ is the $i$-th element of $a$.
It is guaranteed that the sum of $n$ over all queries does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$).
-----Output-----
For each query, print the answer to it. If it is impossible to divide the initial array into exactly $k$ subsegments in such a way that each of them will have odd sum of elements, print "NO" in the first line. Otherwise, print "YES" in the first line and any possible division of the array in the second line. The division can be represented as $k$ integers $r_1$, $r_2$, ..., $r_k$ such that $1 \le r_1 < r_2 < \dots < r_k = n$, where $r_j$ is the right border of the $j$-th segment (the index of the last element that belongs to the $j$-th segment), so the array is divided into subsegments $[1; r_1], [r_1 + 1; r_2], [r_2 + 1, r_3], \dots, [r_{k - 1} + 1, n]$. Note that $r_k$ is always $n$ but you should print it anyway.
-----Example-----
Input
3
5 3
7 18 3 14 1
5 4
1 2 3 4 5
6 2
1 2 8 4 10 2
Output
YES
1 3 5
NO
NO | ["from sys import stdin\nc=int(stdin.readline().strip())\nfor cas in range(c):\n n,m=list(map(int,stdin.readline().strip().split()))\n s=list(map(int,stdin.readline().strip().split()))\n sm=0\n ans=[]\n ind=-1\n for i in range(n):\n if m==1:\n ind=i\n break\n sm+=s[i]\n if sm%2!=0:\n ans.append(i+1)\n sm=0\n m-=1\n if ind==-1:\n print(\"NO\")\n continue\n sm=sum(s[ind::])\n if sm%2!=0:\n ans.append(n)\n print(\"YES\")\n print(*ans)\n else:\n print(\"NO\")\n\n \n\n", "def main():\n import sys\n input = sys.stdin.readline\n \n def solve():\n n, k = map(int, input().split())\n arr = list(map(int, input().split()))\n curr = 0\n ans = []\n for i in range(n):\n curr += arr[i]\n if curr & 1:\n curr = 0\n ans.append(i + 1)\n if len(ans) < k or ((len(ans) - k) & 1):\n print(\"NO\")\n else:\n print(\"YES\")\n print(*(ans[:k-1]+[n]))\n \n \n for _ in range(int(input())):\n solve()\n \n return 0\n\nmain()", "import sys\ninput = sys.stdin.readline\n\nq=int(input())\n\nfor testcases in range(q):\n n,k=list(map(int,input().split()))\n A=list(map(int,input().split()))\n\n if sum(A)%2!=k%2:\n print(\"NO\")\n continue\n\n ANS=[]\n SUM=0\n for i in range(n):\n SUM+=A[i]\n if SUM%2==1:\n ANS.append(i+1)\n SUM=0\n\n if len(ANS)>=k-1:\n print(\"YES\")\n ANS0=ANS[:k-1]+[n]\n print(*ANS0)\n\n else:\n print(\"NO\")\n\n \n \n", "'''input\n3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2\n\n'''\nimport sys\nfrom collections import defaultdict as dd\nfrom itertools import permutations as pp\nfrom itertools import combinations as cc\nfrom collections import Counter as ccd\nfrom random import randint as rd\nfrom bisect import bisect_left as bl\nfrom heapq import heappush as hpush\nfrom heapq import heappop as hpop\nmod=10**9+7\n\ndef ri(flag=0):\n\tif flag==0:\n\t\treturn [int(i) for i in sys.stdin.readline().split()]\n\telse:\n\t\treturn int(sys.stdin.readline())\n\nfor _ in range(int(input())):\n\tn,k = ri()\n\ta= ri()\n\tsu =[0]\n\tfor i in a:\n\t\tsu.append(su[-1]+i)\n\tans =[]\n\tpre=0\n\tfor i in range(len(a)):\n\t\tpre+=a[i]\n\t\tif len(ans) != k-1 and pre%2 ==1:\n\t\t\tans.append(i+1)\n\t\t\tpre=0\n\tif pre %2 ==1:\n\t\tans.append(n)\n\t\tpre=0\n\n\tif pre !=0 or len(ans)!=k:\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n\t\tprint(*ans)\n", "import sys\ninput = lambda: sys.stdin.readline().strip()\n\nT = int(input())\nfor i in range(T):\n n, k = map(int, input().split())\n ls = list(map(int, input().split()))\n odd = 0\n for i in ls:\n if i%2: odd+=1\n if (odd-k)<0 or (odd-k)%2: print(\"NO\")\n else:\n print(\"YES\")\n cnt = 0\n for i in range(n):\n if cnt==k-1: break\n if ls[i]%2: print(i+1, end=\" \"); cnt+=1\n print(n)\n", "for _ in range(int(input())):\n n,k=list(map(int,input().split()))\n arr=list(map(int,input().split()))\n if k==1 and sum(arr)%2:\n print(\"YES\")\n print(n)\n continue\n elif k==1:\n print(\"NO\")\n continue\n ans=[]\n tot=0\n for ind,i in enumerate(arr):\n tot+=i\n if tot%2:\n k-=1\n ans.append(ind+1)\n tot=0\n if not k:\n break\n if tot!=0 and tot%2==0 or k!=0:\n print(\"NO\")\n continue\n temp=sum(arr[ans[-2]:])\n if temp%2:\n print(\"YES\")\n ans.pop()\n for j in ans:\n print(j,end=\" \")\n print(n)\n else:\n print(\"NO\")", "from sys import stdin\n\nq=int(stdin.readline())\nfor i in range(q):\n n,k=map(int,stdin.readline().split())\n arr=list(map(int,stdin.readline().split()))\n count=0\n ans=[]\n s=0\n for i in range(n):\n if count!=k-1: \n if arr[i]%2!=0:\n ans.append(i+1)\n count+=1\n s=0\n else:\n s+=arr[i]\n else:\n if sum(arr[i:])%2!=0:\n ans.append(n)\n else:\n pass\n break\n if len(ans)!=k:\n print(\"NO\")\n else:\n print(\"YES\")\n for i in range(k-1):\n print(ans[i],end=\" \")\n print(ans[-1]) \n \n", "q = int(input())\nB = []\nOTVET = []\nfor m in range(q):\n n, k = list(map(int, input().split()))\n sttr = list(map(int, input().split()))\n a = list(sttr)\n kolvo = 0\n nechet = []\n for i in range(n):\n if a[i] % 2 == 1:\n kolvo += 1\n nechet.append(i + 1)\n #print(kolvo, k)\n if (kolvo >= k) and ((kolvo - k) % 2 == 0):\n otsh = []\n for i in range(k - 1):\n otsh.append(nechet[i])\n otsh.append(n)\n B.append(1)\n OTVET.append(otsh)\n else:\n B.append(0)\nj = 0\nfor i in range(q):\n if B[i] == 1:\n print(\"YES\")\n print(*OTVET[j])\n j += 1\n else:\n print(\"NO\")\n", "import sys\nfor _ in range(int(input())):\n n,k=list(map(int,sys.stdin.readline().split()))\n a=list(map(int,sys.stdin.readline().split()))\n s=sum(a)\n if (s%2==0 and k%2) or (s%2 and k%2==0):\n print(\"NO\")\n else:\n s=0\n b=[]\n i=0\n j=0\n while i<k-1 and j<n:\n # for i in range(k-1):\n if s%2==0:\n s+=a[j]\n j+=1\n else:\n b.append(j)\n s=0\n i+=1\n b.append(n)\n \n if len(set(b))==k:\n \n print(\"YES\")\n print(*b)\n else:\n print(\"NO\")\n \n \n \n", "# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\n# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!\nfrom sys import stdin, stdout\nimport collections\n \nQ = int(input())\n \n#s = input()\n#N = len(s)\n#arr = [int(x) for x in stdin.readline().split()]\nfor i in range(Q):\n N,K = [int(x) for x in stdin.readline().split()]\n arr = [int(x) for x in stdin.readline().split()]\n \n odds = 0\n \n for i in range(N):\n if arr[i]%2==1:\n odds += 1\n \n if odds<K:\n print('NO')\n continue\n \n elif (odds-K)%2==1:\n print('NO')\n continue\n \n three = (odds-K)//2\n \n print('YES')\n odds = 0\n if K==1:\n print(N)\n continue\n \n for i in range(N):\n if arr[i]%2==1:\n odds += 1\n if three>0 and odds!=3:\n continue\n elif three>0 and odds==3:\n K -= 1\n print(i+1,end=' ')\n three -= 1\n odds = 0\n elif three==0 and odds==1:\n K -= 1\n print(i+1,end=' ')\n odds = 0\n if K==1:\n break\n print(N,end='\\n')\n\n\n\n\n", "t = int(input().strip())\nfor i in range(t):\n n, k = list(map(int, input().strip().split()))\n nums = [int(i) for i in input().strip().split()]\n cur_k = 0\n ans = []\n has = True\n if k == 1:\n if sum(nums) %2 ==0:\n print(\"NO\")\n else:\n print(\"YES\")\n print(n)\n else:\n for i in range(n):\n if cur_k == k - 1:\n if ans[-1] != n:\n if sum(nums[ans[-1]:]) % 2 ==0:\n has = False\n break\n else:\n cur_k += 1\n ans.append(n)\n break\n if nums[i] % 2 == 1:\n ans.append(i + 1)\n cur_k += 1\n #print(\"ans \", ans)\n if cur_k < k or not has:\n print(\"NO\")\n else:\n print(\"YES\")\n print(' '.join(str(i) for i in ans))\n \n", "from sys import stdin\nq = int(stdin.readline())\nfor query in range(q):\n n, k = list(map(int, stdin.readline().split()))\n a = list(map(int, stdin.readline().split()))\n ans = [0]\n for i in range(n):\n if k == 1:\n break\n if a[i] % 2 == 0:\n continue\n ans.append(i + 1)\n k -= 1\n if k != 1 or sum(a[ans[-1]:]) % 2 == 0:\n print(\"NO\")\n continue\n print(\"YES\")\n ans.append(n)\n print(' '.join(map(str, ans[1:])))\n", "import sys\ninput = sys.stdin.readline\n\nQ = int(input())\n\ndef calc(n, k, X):\n if (sum(X)-k) % 2:\n print(\"NO\")\n return 0\n ANS = []\n if k == 1:\n print(\"YES\")\n print(n)\n return 0\n for i in range(N-1):\n if X[i] % 2:\n ANS.append(i+1)\n if len(ANS) == k-1:\n print(\"YES\")\n print(*ANS, n)\n return 0\n else:\n print(\"NO\")\n\nfor _ in range(Q):\n N, K = list(map(int, input().split()))\n calc(N, K, [int(a) for a in input().split()])\n", "from bisect import *\nfrom collections import *\nfrom itertools import *\nimport functools\nimport sys\nimport math\nfrom decimal import *\nfrom copy import *\ngetcontext().prec = 30\nMAX = sys.maxsize\nMAXN = 10**5+10\nMOD = 10**9+7\ndef isprime(n):\n n = abs(int(n))\n if n < 2:\n return False\n if n == 2: \n return True \n if not n & 1: \n return False\n for x in range(3, int(n**0.5) + 1, 2):\n if n % x == 0:\n return False\n return True\n\ndef mhd(a,b):\n return abs(a[0]-b[0])+abs(b[1]-a[1])\n\ndef charIN(x= ' '):\n return(sys.stdin.readline().strip().split(x))\n\ndef arrIN(x = ' '):\n return list(map(int,sys.stdin.readline().strip().split(x)))\n\ndef eld(x,y):\n a = y[0]-x[0]\n b = x[1]-y[1]\n return (a*a+b*b)**0.5\n\ndef lgcd(a):\n g = a[0]\n for i in range(1,len(a)):\n g = math.gcd(g,a[i])\n return g\n\ndef ms(a):\n msf = -MAX\n meh = 0\n st = en = be = 0\n for i in range(len(a)):\n meh+=a[i]\n if msf<meh:\n msf = meh\n st = be\n en = i\n if meh<0:\n meh = 0\n be = i+1\n return msf,st,en\n\ndef ncr(n,r):\n num=den=1\n for i in range(r):\n num = (num*(n-i))%MOD\n den = (den*(i+1))%MOD\n\n return (num*(pow(den,MOD-2,MOD)))%MOD\n\n\n\ndef flush():\n return sys.stdout.flush()\n\n'''*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*'''\nfor _ in range(int(input())):\n n,k = arrIN()\n a = arrIN()\n pre = list(accumulate(a))\n ans = []\n for i in range(n):\n if ans:\n if (pre[i]-pre[ans[-1]])%2:\n ans.append(i)\n else:\n if pre[i]%2:\n ans.append(i)\n #print(ans)\n if len(ans)<k:\n print('NO')\n else:\n if len(ans)==k:\n print('YES')\n print(*[i+1 for i in ans[:len(ans)-1]],n)\n else:\n ext = len(ans)-k\n if ext%2:\n print('NO')\n else:\n print('YES')\n print(*[i+1 for i in ans[:k-1]],n)\n\n\n \n", "import sys\ninput = sys.stdin.readline\nq = int(input())\nfor i in range(q):\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n odd = 0\n for j in range(n):\n if a[j] % 2 != 0:\n odd += 1\n if odd < k:\n print('NO')\n elif odd > k and (odd - k) % 2 != 0:\n print('NO')\n else:\n print('YES')\n ans = []\n for j in range(n):\n if len(ans) == k - 1:\n ans.append(n)\n break\n if a[j] % 2 != 0:\n ans.append(j + 1)\n print(*ans)", "from sys import stdin\ninput=stdin.readline\nfor _ in range(int(input())):\n n,k=list(map(int,input().split()))\n a=list(map(int,input().split()))\n ans=[]\n for i in range(n):\n if a[i]&1:\n ans.append(i+1)\n if len(ans)<k:\n print(\"NO\")\n elif (k-len(ans))&1:\n print(\"NO\")\n else:\n print(\"YES\")\n ans[-1]=n\n print(*ans[len(ans)-k:])\n", "''' CODED WITH LOVE BY SATYAM KUMAR '''\n\nfrom sys import stdin, stdout\nimport cProfile, math\nfrom collections import Counter,defaultdict,deque\nfrom bisect import bisect_left,bisect,bisect_right\nimport itertools\nfrom copy import deepcopy\nfrom fractions import Fraction\nimport sys, threading\nimport operator as op\nfrom functools import reduce\nsys.setrecursionlimit(10**6) # max depth of recursion\nthreading.stack_size(2**27) # new thread will get stack of such size\nfac_warmup = False\nprintHeap = str()\nmemory_constrained = False\nP = 10**9+7\nimport sys\n\nclass merge_find:\n def __init__(self,n):\n self.parent = list(range(n))\n self.size = [1]*n\n self.num_sets = n\n self.lista = [[_] for _ in range(n)]\n def find(self,a):\n to_update = []\n while a != self.parent[a]:\n to_update.append(a)\n a = self.parent[a]\n for b in to_update:\n self.parent[b] = a\n return self.parent[a]\n def merge(self,a,b):\n a = self.find(a)\n b = self.find(b)\n if a==b:\n return\n if self.size[a]<self.size[b]:\n a,b = b,a\n self.num_sets -= 1\n self.parent[b] = a\n self.size[a] += self.size[b]\n self.lista[a] += self.lista[b]\n def set_size(self, a):\n return self.size[self.find(a)]\n def __len__(self):\n return self.num_sets\n\ndef display(string_to_print):\n stdout.write(str(string_to_print) + \"\\n\")\n\ndef primeFactors(n): #n**0.5 complex \n factors = dict()\n for i in range(2,math.ceil(math.sqrt(n))+1): \n while n % i== 0: \n if i in factors:\n factors[i]+=1\n else: factors[i]=1\n n = n // i \n if n>2:\n factors[n]=1\n return (factors)\n\ndef all_factors(n): \n return set(reduce(list.__add__, \n ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0)))\n\ndef fibonacci_modP(n,MOD):\n if n<2: return 1\n #print (n,MOD)\n return (cached_fn(fibonacci_modP, (n+1)//2, MOD)*cached_fn(fibonacci_modP, n//2, MOD) + cached_fn(fibonacci_modP, (n-1) // 2, MOD)*cached_fn(fibonacci_modP, (n-2) // 2, MOD)) % MOD\n\ndef factorial_modP_Wilson(n , p): \n if (p <= n): \n return 0\n res = (p - 1) \n for i in range (n + 1, p): \n res = (res * cached_fn(InverseEuler,i, p)) % p \n return res \n\ndef binary(n,digits = 20):\n b = bin(n)[2:]\n b = '0'*(digits-len(b))+b\n return b\n\ndef isprime(n):\n \"\"\"Returns True if n is prime.\"\"\"\n if n < 4:\n return True\n if n % 2 == 0:\n return False\n if n % 3 == 0:\n return False\n i = 5\n w = 2\n while i * i <= n:\n if n % i == 0:\n return False\n i += w\n w = 6 - w\n return True\n\ndef generate_primes(n):\n prime = [True for i in range(n+1)] \n p = 2\n while (p * p <= n): \n if (prime[p] == True): \n for i in range(p * 2, n+1, p): \n prime[i] = False\n p += 1\n return prime\n\nfactorial_modP = []\ndef warm_up_fac(MOD):\n nonlocal factorial_modP,fac_warmup\n if fac_warmup: return\n factorial_modP= [1 for _ in range(fac_warmup_size+1)]\n for i in range(2,fac_warmup_size):\n factorial_modP[i]= (factorial_modP[i-1]*i) % MOD\n fac_warmup = True\n\ndef InverseEuler(n,MOD):\n return pow(n,MOD-2,MOD)\n\ndef nCr(n, r, MOD):\n nonlocal fac_warmup,factorial_modP\n if not fac_warmup:\n warm_up_fac(MOD)\n fac_warmup = True\n return (factorial_modP[n]*((pow(factorial_modP[r], MOD-2, MOD) * pow(factorial_modP[n-r], MOD-2, MOD)) % MOD)) % MOD\n\ndef test_print(*args):\n if testingMode:\n print(args)\n\ndef display_list(list1, sep=\" \"):\n stdout.write(sep.join(map(str, list1)) + \"\\n\")\n\ndef display_2D_list(li):\n for i in li:\n print(i)\ndef prefix_sum(li):\n sm = 0\n res = []\n for i in li:\n sm+=i\n res.append(sm)\n return res\n\ndef get_int():\n return int(stdin.readline().strip())\n\ndef get_tuple():\n return map(int, stdin.readline().split())\n\ndef get_list():\n return list(map(int, stdin.readline().split()))\nimport heapq,itertools\npq = [] # list of entries arranged in a heap\nentry_finder = {} # mapping of tasks to entries\nREMOVED = '<removed-task>' \ndef add_task(task, priority=0):\n 'Add a new task or update the priority of an existing task'\n if task in entry_finder:\n remove_task(task)\n count = next(counter)\n entry = [priority, count, task]\n entry_finder[task] = entry\n heapq.heappush(pq, entry)\n\ndef remove_task(task):\n 'Mark an existing task as REMOVED. Raise KeyError if not found.'\n entry = entry_finder.pop(task)\n entry[-1] = REMOVED\n\ndef pop_task():\n 'Remove and return the lowest priority task. Raise KeyError if empty.'\n while pq:\n priority, count, task = heapq.heappop(pq)\n if task is not REMOVED:\n del entry_finder[task]\n return task\n raise KeyError('pop from an empty priority queue')\nmemory = dict()\ndef clear_cache():\n nonlocal memory\n memory = dict()\ndef cached_fn(fn, *args):\n nonlocal memory\n if args in memory:\n return memory[args]\n else:\n result = fn(*args)\n memory[args] = result\n return result\n\ndef ncr (n,r):\n return math.factorial(n)/(math.factorial(n-r)*math.factorial(r))\ndef binary_serach(i,li):\n #print(\"Search for \",i)\n fn = lambda x: li[x]-x//i\n x = -1\n b = len(li)\n while b>=1:\n #print(b,x)\n while b+x<len(li) and fn(b+x)>0: #Change this condition 2 to whatever you like\n x+=b\n b=b//2\n return x\n\n# -------------------------------------------------------------- MAIN PROGRAM\nTestCases = True\ntestingMode = False\nfac_warmup_size = 10**5+100\noptimiseForReccursion = False #Can not be used clubbed with TestCases # WHen using recursive functions, use Python 3\nfrom math import factorial\n\ndef main():\n n, k = get_tuple()\n li = get_list()\n odd_indexes = [i+1 for i,ele in enumerate(li) if ele%2!=0]\n if len(odd_indexes)<k:\n print(\"NO\")\n elif len(odd_indexes)%2==k%2:\n ln = odd_indexes[:k-1] + [n]\n print(\"YES\")\n display_list(ln)\n else:\n print(\"NO\")\n\n\n\n\n\n# --------------------------------------------------------------------- END=\n\n\nif TestCases: \n for i in range(get_int()): \n cProfile.run('main()') if testingMode else main() \nelse: (cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()", "n = int( input() )\nresult = []\nfor _ in range(n):\n (n,k) = list( map( int, input().split() ))\n a = list( map( int, input().split() ))\n nbOdds = 0\n for i in a:\n if i % 2 == 1:\n nbOdds += 1\n if nbOdds < k:\n result.append(\"NO\")\n elif (nbOdds - k) % 2 == 0:\n result.append(\"YES\")\n current = []\n for j in range(n):\n if a[j] % 2 == 1 and len(current) < k - 1:\n current.append(j+1)\n current.append(n)\n result.append( \" \".join( list( map(str, current) ) ) )\n\n else:\n result.append(\"NO\")\nprint( \"\\n\".join(result) )\n\n\n", "import sys\n \nt = int(input())\nfor i in range(t):\n n, k = list(map(int, sys.stdin.readline().split()))\n a = list(map(int, sys.stdin.readline().split()))\n p = []\n for i in range(n):\n if a[i] % 2 == 1:\n p.append(i+1)\n if len(p) >= k and (len(p) - k)%2 == 0:\n p = p[:k]\n p[len(p)-1] = n\n print('YES')\n print(*p)\n else:\n print('NO')\n", "from sys import *\nfor _ in range(int(stdin.readline())):\n a,b=list(map(int,stdin.readline().rstrip().split()))\n l=list(map(int,stdin.readline().split()))\n k=[]\n c=0\n for x in range(a):\n if l[x]&1!=0:\n k.append(x+1)\n c+=1\n j=c\n if j<b:\n print(\"NO\")\n else:\n t=j-b\n if t&1==0:\n print(\"YES\")\n for x in range(b-1):\n print(k[x],end=\" \")\n print(a)\n else:\n print(\"NO\")", "'''input\n3\n2 1\n1 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2\n'''\nfrom copy import deepcopy\nfrom bisect import bisect_right\nfrom itertools import combinations\nfrom sys import stdin\n\n\n\ndef dis(first, second, remain):\n\tif second[0] > first[0]:\n\t\tfirst[0], second[0] = second[0], first[0]\n\n\tif remain > first[0] - second[0]:\n\t\tremain -= first[0] - second[0]\n\t\tsecond[0] = first[0]\n\t\tfirst[0] += remain // 2\n\t\treturn first[0]\n\telse:\n\t\treturn second[0] + remain\n\n\n# main starts\nq = int(stdin.readline().strip())\nfor _ in range(q):\n\tn, k = list(map(int, stdin.readline().split()))\n\tarr = list(map(int, stdin.readline().split()))\n\ttemp = 0\n\tcount = 0\n\ti = 0\n\tans = []\n\twhile i < len(arr) and count < k - 1:\n\t\ttemp += arr[i]\n\t\tif temp% 2 == 1:\n\t\t\tans.append(i + 1)\n\t\t\ttemp = 0\n\t\t\tcount += 1\n\t\ti += 1\n\tif len(ans) == 0:\n\t\tif sum(arr) % 2 == 1 and k == 1:\n\t\t\tprint(\"YES\")\n\t\t\tprint(n)\n\t\telse:\n\t\t\tprint(\"NO\")\n\n\telif sum(arr[ans[-1]:]) % 2 == 1:\n\t\tans.append(n)\n\t\tcount += 1\n\t\tif count == k:\n\t\t\tprint(\"YES\")\n\t\t\tprint(*ans)\n\t\telse:\n\t\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"NO\")", "#575_B\n\nimport time\nimport sys\n\nstart = time.time()\n\nq = int(sys.stdin.readline().rstrip())\n\nfor i in range(0, q):\n ns = [int(j) for j in sys.stdin.readline().rstrip().split(\" \")]\n n = ns[0]\n k = ns[1]\n ln = [int(j) for j in sys.stdin.readline().rstrip().split(\" \")]\n if len(ln) == 1:\n if ln[0] % 2 == 1:\n print(\"YES\")\n print(1)\n else:\n print(\"NO\")\n continue\n cc = 1\n inc = 0\n inds = []\n for j in range(0, len(ln)):\n if ln[j] % 2 == 1:\n if inc < k - 1:\n inc += 1\n inds.append(j + 1)\n elif inc < k:\n inc += 1\n else:\n cc += 1\n if inc < k or cc % 2 == 0:\n print(\"NO\")\n else:\n inds.append(n)\n print(\"YES\")\n print(\" \".join([str(j) for j in inds]))\n", "import sys\n\ninf = sys.stdin\n#inf = open(\"input_data.in\", \"r\")\n\nlines = inf.readlines()\n\n\nq = int(lines[0])\n\nfor tests in range(q):\n n, k = (int(val) for val in lines[2*tests+1].split())\n candy = [int(val) for val in lines[2*tests+2].split()]\n \n odds = 0\n \n for i in candy:\n if i % 2 == 1:\n odds += 1\n \n if(odds < k or sum(candy) % 2 != k % 2):\n print(\"NO\")\n else:\n print(\"YES\")\n \n count = 1\n \n for i in range(len(candy)):\n if count >= k:\n print(n)\n break\n if candy[i] % 2 == 1:\n print(i + 1, end = ' ')\n count += 1"] | {
"inputs": [
"3\n5 3\n7 18 3 14 1\n5 4\n1 2 3 4 5\n6 2\n1 2 8 4 10 2\n",
"1\n1 1\n2\n"
],
"outputs": [
"YES\n1 3 5\nNO\nNO\n",
"NO\n"
]
} | INTRODUCTORY | PYTHON3 | CODEFORCES | 24,075 | |
7ec85a48ca6704beafc9bf495f674d37 | UNKNOWN | Reverse bits of a given 32 bits unsigned integer.
Note:
Note that in some languages such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer's internal binary representation is the same, whether it is signed or unsigned.
In Java, the compiler represents the signed integers using 2's complement notation. Therefore, in Example 2 above, the input represents the signed integer -3 and the output represents the signed integer -1073741825.
Follow up:
If this function is called many times, how would you optimize it?
Example 1:
Input: n = 00000010100101000001111010011100
Output: 964176192 (00111001011110000010100101000000)
Explanation: The input binary string 00000010100101000001111010011100 represents the unsigned integer 43261596, so return 964176192 which its binary representation is 00111001011110000010100101000000.
Example 2:
Input: n = 11111111111111111111111111111101
Output: 3221225471 (10111111111111111111111111111111)
Explanation: The input binary string 11111111111111111111111111111101 represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is 10111111111111111111111111111111.
Constraints:
The input must be a binary string of length 32 | ["class Solution:\n def reverseBits(self, n: int) -> int:\n rev = ''\n for i in reversed(bin(n)[2:]):\n rev = rev + i\n rev = rev + '0'*(32-len(rev)) \n \n return int(rev, 2)", "class Solution:\n def reverseBits(self, n: int) -> int:\n a = bin(n)[2:]\n z = \"0\"*(32 - len(a)) + a\n t = z[::-1]\n return int(t, 2)", "class Solution:\n def reverseBits(self, n: int) -> int:\n result = 0\n power = 31\n while n:\n result += (n & 1) << power\n n = n >> 1\n power -= 1\n \n return result", "class Solution:\n def reverseBits(self, n: int) -> int:\n a = bin(n)[2:]\n z = \"0\"*(32 - len(a)) + a\n t = z[::-1]\n return int(t, 2)"] | {"fn_name": "reverseBits", "inputs": [[43261596], [4294967293]], "outputs": [964176192, 3221225471]} | INTRODUCTORY | PYTHON3 | LEETCODE | 811 |
class Solution:
def reverseBits(self, n: int) -> int:
|
7d716ba7d58926cd7c30e6e439a29ea1 | UNKNOWN | Given a non-negative integerΒ numRows, generate the first numRows of Pascal's triangle.
In Pascal's triangle, each number is the sum of the two numbers directly above it.
Example:
Input: 5
Output:
[
[1],
[1,1],
[1,2,1],
[1,3,3,1],
[1,4,6,4,1]
] | ["class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n res = [[1]]\n for i in range(1,numRows):\n res.append(list(map(lambda x, y : x + y, res[-1]+[0], [0]+res[-1])))\n return res[:numRows]\n \n", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n \n if numRows==0:\n return []\n tem=[0,1]\n l=[]\n for i in range(numRows):\n rowlist=[]\n for j in range(len(tem)-1):\n rowlist.append(tem[j]+tem[j+1])\n l.append(rowlist)\n tem=rowlist[:]\n tem.insert(0,0)\n tem.append(0)\n return l\n '''\n ans = [[1] * n for n in range(1, numRows + 1)]\n for i in range(1, numRows + 1):\n for j in range(0, i - 2):\n ans[i - 1][1 + j] = ans[i - 2][j] + ans[i - 2][j + 1]\n return ans'''\n \n \n \n \n \n", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n if numRows==0:\n return []\n res=[[1]]\n for i in range(1,numRows):\n newRow = [1]\n for j in range(1,i):\n newRow.append(res[-1][j-1]+res[-1][j])\n newRow.append(1)\n res.append(newRow)\n return res\n", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n '''\n if numRows==0:\n return []\n tem=[0,1]\n l=[]\n for i in range(numRows):\n rowlist=[]\n for j in range(len(tem)-1):\n rowlist.append(tem[j]+tem[j+1])\n l.append(rowlist)\n tem=rowlist[:]\n tem.insert(0,0)\n tem.append(0)\n return l'''\n ans = [[1] * n for n in range(1, numRows + 1)]\n for i in range(1, numRows + 1):\n for j in range(0, i - 2):\n ans[i - 1][1 + j] = ans[i - 2][j] + ans[i - 2][j + 1]\n return ans\n \n \n \n \n \n", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n A = []\n for i in range(numRows):\n A.append([1 for _ in range(i+1)])\n for j in range(1, i):\n A[i][j] = A[i-1][j-1] + A[i-1][j]\n return A", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n if numRows < 1:\n return []\n base = [1]\n triangle = [base]\n for i in range(1, numRows):\n new_row = [1]\n prev_row = triangle[i-1]\n for j in range(len(prev_row)-1):\n new_row.append(prev_row[j] + prev_row[j+1])\n new_row.append(1)\n triangle.append(new_row)\n return triangle", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n A=[[1],[1,1]]\n if numRows == 0:\n return[]\n elif numRows<3:\n return A[0:numRows]\n else:\n i=3\n while i<=numRows:\n temp=A[i-2][:]\n temp.append(0)\n temp2=temp[::-1]\n temp3=[X+Y for X,Y in zip(temp,temp2)]\n A.append(temp3) \n i+=1 \n print(A)\n return A", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n result = []\n for i in range(numRows):\n result.append([])\n for j in range(i + 1):\n if j in (0, i):\n result[i].append(1)\n else:\n result[i].append(result[i - 1][j - 1] + result[i - 1][j])\n return result", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n \n result = [[]] * numRows\n for i in range(numRows):\n if i == 0:\n result[0] = [1]\n \n if i == 1:\n result[1] = [1, 1]\n \n if i > 1:\n temp = []\n for k in range(i+1): \n left = result[i-1][k-1] if k >= 1 else 0\n right = result[i-1][k] if k < i else 0\n temp.append(left + right)\n \n result[i] = temp\n \n \n return result", "class Solution:\n def my_fact(self, n):\n if n == 1 or n == 0:\n return 1\n else:\n return n * self.my_fact(n-1)\n \n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n res = [[] for i in range(numRows)]\n for n in range(numRows):\n for k in range(0, n+1):\n val = self.my_fact(n) / (self.my_fact(n-k) * self.my_fact(k))\n res[n].append(int(val))\n \n return res", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n if numRows == 0:\n return []\n result = [[1]]\n if numRows == 1:\n return result\n result.append([1, 1])\n if numRows == 2:\n return result\n for row in range(2, numRows):\n l, r = 0, 1\n tmp = [1]\n while r < len(result[row-1]):\n tmp.append(result[row-1][l]+result[row-1][r])\n l += 1\n r += 1\n tmp.append(1)\n result.append(tmp)\n return result", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n if numRows==0:\n return []\n if numRows==1:\n return [[1]]\n if numRows==2:\n return [[1],[1,1]]\n result=[[1],[1,1]]\n for i in range(3,numRows+1):\n if len(result)<i:\n result.append([])\n result[i-1].append(1)\n count=0\n while len(result[i-1])<i-1:\n result[i-1].append(result[i-2][count]+result[i-2][count+1])\n count+=1\n result[i-1].append(1)\n return result", "class Solution:\n def generate(self, numRows):\n \"\"\"\n :type numRows: int\n :rtype: List[List[int]]\n \"\"\"\n \n # def fac(num):\n # factorial = 1\n # for i in range(1, num+1):\n # factorial *= i\n # return factorial\n \n # i = 1\n # L = []\n # while i <= numRows:\n # j = 1\n # l = []\n # while j <= i:\n # l.append(int(fac(i-1)/(fac(j-1)*fac(i-j))))\n # j += 1\n # L.append(l)\n # i += 1\n \n # return L\n \n \n # if numRows == 0:\n # return []\n \n # i = 1\n # L = [[1]]\n # while i+1 <= numRows:\n # j = 0\n # l = []\n # while j <= i:\n # if j == 0 or j == i:\n # l.append(1)\n # else:\n # l.append(L[i-1][j-1]+L[i-1][j])\n # j += 1\n # L.append(l)\n # i += 1\n \n # return L\n \n \n # result = []\n # for i in xrange(numRows):\n # result.append([])\n # for j in xrange(i + 1):\n # if j in (0, i):\n # result[i].append(1)\n # else:\n # result[i].append(result[i - 1][j - 1] + result[i - 1][j])\n # return result\n \n \n # if not numRows: return []\n # res = [[1]]\n # for i in range(1, numRows):\n # res += [list(map(lambda x, y: x + y, res[-1] + [0], [0] + res[-1]))]\n # return res[:numRows]\n \n \n if numRows == 0: return []\n if numRows == 1: return [[1]]\n res = [[1], [1, 1]]\n \n def add(nums):\n res = nums[:1]\n for i, j in enumerate(nums):\n if i < len(nums) - 1:\n res += [nums[i] + nums[i + 1]]\n res += nums[:1]\n return res\n \n while len(res) < numRows:\n # res.extend([add(res[-1])])\n res.append(add(res[-1]))\n return res"] | {"fn_name": "generate", "inputs": [[5], [1]], "outputs": [[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]], [[1]]]} | INTRODUCTORY | PYTHON3 | LEETCODE | 9,494 |
class Solution:
def generate(self, numRows: int) -> List[List[int]]:
|
5abe52963e0c3daa180b01f395b689fa | UNKNOWN | =====Problem Statement=====
You are given an integer N followed by N email addresses. Your task is to print a list containing only valid email addresses in lexicographical order.
Valid email addresses must follow these rules:
It must have the [email protected] format type.
The username can only contain letters, digits, dashes and underscores.
The website name can only have letters and digits.
The maximum length of the extension is 3.
Concept
A filter takes a function returning True or False and applies it to a sequence, returning a list of only those members of the sequence where the function returned True. A Lambda function can be used with filters.
Let's say you have to make a list of the squares of integers from 0 to 9 (both included).
>> l = list(range(10))
>> l = list(map(lambda x:x*x, l))
Now, you only require those elements that are greater than 10 but less than 80.
>> l = list(filter(lambda x: x > 10 and x < 80, l))
Easy, isn't it?
=====Input Format=====
The first line of input is the integer N, the number of email addresses.
N lines follow, each containing a string.
=====Constraints=====
Each line is a non-empty string.
=====Output Format=====
Output a list containing the valid email addresses in lexicographical order. If the list is empty, just output an empty list, []. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nimport re\nn=int(input())\nar=[]\nfor i in range(0,n):\n s=input()\n t=re.search(r\"^[a-zA-Z][\\w-]*@[a-zA-Z0-9]+\\.[a-zA-Z]{1,3}$\",s)\n if t:\n ar.append(s)\nar.sort() \nprint(ar)\n"] | {"inputs": ["3\[email protected]\[email protected]\[email protected]", "2\nharsh@gmail\[email protected]"], "outputs": ["['[email protected]', '[email protected]', '[email protected]']", "['[email protected]']"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 281 |
def fun(s):
# return True if s is a valid email, else return False
def filter_mail(emails):
return list(filter(fun, emails))
if __name__ == '__main__':
n = int(input())
emails = []
for _ in range(n):
emails.append(input())
filtered_emails = filter_mail(emails)
filtered_emails.sort()
print(filtered_emails) |
c081b26f4db2bd4cc7c47e8a2f7563d7 | UNKNOWN | =====Problem Statement=====
Let's learn some new Python concepts! You have to generate a list of the first N fibonacci numbers, 0 being the first number. Then, apply the map function and a lambda expression to cube each fibonacci number and print the list.
Concept
The map() function applies a function to every member of an iterable and returns the result. It takes two parameters: first, the function that is to be applied and secondly, the iterables.
Let's say you are given a list of names, and you have to print a list that contains the length of each name.
>> print (list(map(len, ['Tina', 'Raj', 'Tom'])))
[4, 3, 3]
Lambda is a single expression anonymous function often used as an inline function. In simple words, it is a function that has only one line in its body. It proves very handy in functional and GUI programming.
>> sum = lambda a, b, c: a + b + c
>> sum(1, 2, 3)
6
Note:
Lambda functions cannot use the return statement and can only have a single expression. Unlike def, which creates a function and assigns it a name, lambda creates a function and returns the function itself. Lambda can be used inside lists and dictionaries.
=====Input Format=====
One line of input: an integer N.
=====Output Format=====
A list on a single line containing the cubes of the first N fibonacci numbers. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\ndef sqr(a):\n return a*a*a\nn=int(input())\nif(n==0):\n print(\"[]\")\nelif(n==1):\n print(\"[0]\")\nelse:\n ar=[0]*n\n ar[0]=0\n ar[1]=1\n for i in range(2,n):\n ar[i]=ar[i-1]+ar[i-2]\n\n ar=list(map(sqr,ar))\n print(ar)\n"] | {"inputs": ["5", "6"], "outputs": ["[0, 1, 1, 8, 27]", "[0, 1, 1, 8, 27, 125]"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 332 |
cube = lambda x: # complete the lambda function
def fibonacci(n):
# return a list of fibonacci numbers
if __name__ == '__main__':
n = int(input())
print(list(map(cube, fibonacci(n)))) |
eebff2404d07a9705f773d3e621b9b0f | UNKNOWN | =====Problem Statement=====
You are given a valid XML document, and you have to print the maximum level of nesting in it. Take the depth of the root as 0.
=====Input Format=====
The first line contains N, the number of lines in the XML document.
The next N lines follow containing the XML document.
=====Output Format=====
Output a single line, the integer value of the maximum level of nesting in the XML document. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nxml_str=\"\"\nn=int(input())\nfor i in range(0,n):\n tmp_str=input()\n xml_str=xml_str+tmp_str\n \nimport xml.etree.ElementTree as etree\ntree = etree.ElementTree(etree.fromstring(xml_str))\nroot=tree.getroot()\nar=[]\ndef cnt_node(node):\n return max( [0] + [cnt_node(child)+1 for child in node])\ncnt=cnt_node(root)\nprint(cnt)\n", "maxdepth = 0\ndef depth(elem, level):\n #print(elem)\n if level == -1:\n level = 0\n nonlocal maxdepth\n if level > maxdepth:\n maxdepth = level\n for el in elem:\n depth(el, level+1)\n\n"] | {"inputs": ["6\n<feed xml:lang='en'>\n <title>HackerRank</title>\n <subtitle lang='en'>Programming challenges</subtitle>\n <link rel='alternate' type='text/html' href='http://hackerrank.com/'/>\n <updated>2013-12-25T12:00:00</updated>\n</feed>", "11\n<feed xml:lang='en'>\n <title>HackerRank</title>\n <subtitle lang='en'>Programming challenges</subtitle>\n <link rel='alternate' type='text/html' href='http://hackerrank.com/'/>\n <updated>2013-12-25T12:00:00</updated>\n <entry>\n \t<author gender='male'>Harsh</author>\n <question type='hard'>XML 1</question>\n <description type='text'>This is related to XML parsing</description>\n </entry>\n</feed>"], "outputs": ["1", "2"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 645 |
import xml.etree.ElementTree as etree
maxdepth = 0
def depth(elem, level):
global maxdepth
# your code goes here
if __name__ == '__main__':
n = int(input())
xml = ""
for i in range(n):
xml = xml + input() + "\n"
tree = etree.ElementTree(etree.fromstring(xml))
depth(tree.getroot(), -1)
print(maxdepth) |
a459ecd2696a2a0d57a48d6921f36573 | UNKNOWN | =====Problem Statement=====
Let's dive into the interesting topic of regular expressions! You are given some input, and you are required to check whether they are valid mobile numbers.
Concept
A valid mobile number is a ten digit number starting with a 7, 8, or 9.
=====Input Format=====
The first line contains an integer N, the number of inputs.
N lines follow, each containing some string.
=====Constraints=====
1β€Nβ€10
2β€len(Number)β€15
=====Output Format=====
For every string listed, print "YES" if it is a valid mobile number and "NO" if it is not on separate lines. Do not print the quotes. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nn=int(input())\nfor i in range(0,n):\n tmp_str=input()\n len_tmp_str=len(tmp_str)\n if(len_tmp_str!=10):\n ##print \"LENGTH PROBLEM\"\n print(\"NO\")\n elif(tmp_str[0]!=\"7\" and tmp_str[0]!=\"8\" and tmp_str[0]!=\"9\"):\n ##print \"START PROBLEM\" \n print(\"NO\")\n else:\n check=1\n for i in tmp_str:\n if(i>=\"0\" and i<=\"9\"):\n continue\n else:\n check=0\n break\n if(check==1):\n print(\"YES\")\n else:\n ##print \"NUMBER PROBLEM\" \n print(\"NO\")\n", "import re\n\nn = int(input().strip())\n\nfor _ in range(n):\n tel = input().strip()\n pattern = '^[789][0-9]{9}$'\n print(\"{}\".format(\"YES\" if bool(re.match(pattern, tel)) else \"NO\"))"] | {"inputs": ["2\n9587456281\n1252478965", "3\n8F54698745\n9898959398\n879546242"], "outputs": ["YES\nNO", "NO\nYES\nNO"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 924 |
# Enter your code here. Read input from STDIN. Print output to STDOUT |
55b8e2cbd8a92cb145556d73b232a17e | UNKNOWN | =====Function Descriptions=====
Objective
Today, we're learning about a new data type: sets.
Concept
If the inputs are given on one line separated by a space character, use split() to get the separate values in the form of a list:
>> a = raw_input()
5 4 3 2
>> lis = a.split()
>> print (lis)
['5', '4', '3', '2']
If the list values are all integer types, use the map() method to convert all the strings to integers.
>> newlis = list(map(int, lis))
>> print (newlis)
[5, 4, 3, 2]
Sets are an unordered bag of unique values. A single set contains values of any immutable data type.
CREATING SETS
>> myset = {1, 2} # Directly assigning values to a set
>> myset = set() # Initializing a set
>> myset = set(['a', 'b']) # Creating a set from a list
>> myset
{'a', 'b'}
MODIFYING SETS
Using the add() function:
>> myset.add('c')
>> myset
{'a', 'c', 'b'}
>> myset.add('a') # As 'a' already exists in the set, nothing happens
>> myset.add((5, 4))
>> myset
{'a', 'c', 'b', (5, 4)}
Using the update() function:
>> myset.update([1, 2, 3, 4]) # update() only works for iterable objects
>> myset
{'a', 1, 'c', 'b', 4, 2, (5, 4), 3}
>> myset.update({1, 7, 8})
>> myset
{'a', 1, 'c', 'b', 4, 7, 8, 2, (5, 4), 3}
>> myset.update({1, 6}, [5, 13])
>> myset
{'a', 1, 'c', 'b', 4, 5, 6, 7, 8, 2, (5, 4), 13, 3}
REMOVING ITEMS
Both the discard() and remove() functions take a single value as an argument and removes that value from the set. If that value is not present, discard() does nothing, but remove() will raise a KeyError exception.
>> myset.discard(10)
>> myset
{'a', 1, 'c', 'b', 4, 5, 7, 8, 2, 12, (5, 4), 13, 11, 3}
>> myset.remove(13)
>> myset
{'a', 1, 'c', 'b', 4, 5, 7, 8, 2, 12, (5, 4), 11, 3}
COMMON SET OPERATIONS Using union(), intersection() and difference() functions.
>> a = {2, 4, 5, 9}
>> b = {2, 4, 11, 12}
>> a.union(b) # Values which exist in a or b
{2, 4, 5, 9, 11, 12}
>> a.intersection(b) # Values which exist in a and b
{2, 4}
>> a.difference(b) # Values which exist in a but not in b
{9, 5}
The union() and intersection() functions are symmetric methods:
>> a.union(b) == b.union(a)
True
>> a.intersection(b) == b.intersection(a)
True
>> a.difference(b) == b.difference(a)
False
These other built-in data structures in Python are also useful.
=====Problem Statement=====
Given 2 sets of integers, M and N, print their symmetric difference in ascending order. The term symmetric difference indicates those values that exist in either M or N but do not exist in both.
=====Input Format=====
The first line of input contains an integer, M.
The second line contains M space-separated integers.
The third line contains an integer, N.
The fourth line contains N space-separated integers.
=====Output Format=====
Output the symmetric difference integers in ascending order, one per line. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nm=int(input())\nset_a_str_ar=input().strip().split()\nset_a_ar=list(map(int,set_a_str_ar))\nn=int(input())\nset_b_str_ar=input().strip().split()\nset_b_ar=list(map(int,set_b_str_ar))\n\nset_a_set=set(set_a_ar)\nset_b_set=set(set_b_ar)\nset_a_dif_set=set_a_set.difference(set_b_set)\nset_b_dif_set=set_b_set.difference(set_a_set)\nres_set=set_a_dif_set.union(set_b_dif_set)\nres_ar=list(res_set)\nres_ar.sort()\nfor i in res_ar:\n print(i)\n", "#!/usr/bin/env python3\n\n\ndef __starting_point():\n M = int(input().strip())\n set_m = set(map(int, input().strip().split(' ')))\n \n N = int(input().strip())\n set_n = set(map(int, input().strip().split(' ')))\n \n for el in sorted(set_m ^ set_n):\n print(el)\n\n__starting_point()"] | {"inputs": ["4\n2 4 5 9\n4\n2 4 11 12", "2\n8 -10\n3\n5 6 7"], "outputs": ["5\n9\n11\n12", "-10\n5\n6\n7\n8"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 834 | |
63db0ec8cfd7c9c7ab496320c3ddbf8f | UNKNOWN | =====Function Descriptions=====
collections.namedtuple()
Basically, namedtuples are easy to create, lightweight object types.
They turn tuples into convenient containers for simple tasks.
With namedtuples, you donβt have to use integer indices for accessing members of a tuple.
Example
Code 01
>>> from collections import namedtuple
>>> Point = namedtuple('Point','x,y')
>>> pt1 = Point(1,2)
>>> pt2 = Point(3,4)
>>> dot_product = ( pt1.x * pt2.x ) +( pt1.y * pt2.y )
>>> print dot_product
11
Code 02
>>> from collections import namedtuple
>>> Car = namedtuple('Car','Price Mileage Colour Class')
>>> xyz = Car(Price = 100000, Mileage = 30, Colour = 'Cyan', Class = 'Y')
>>> print xyz
Car(Price=100000, Mileage=30, Colour='Cyan', Class='Y')
>>> print xyz.Class
Y
=====Problem Statement=====
Dr. John Wesley has a spreadsheet containing a list of student's IDs, marks, class and name.
Your task is to help Dr. Wesley calculate the average marks of the students.
Average = Sum of all marks / Total students
Note:
1. Columns can be in any order. IDs, marks, class and name can be written in any order in the spreadsheet.
2. Column names are ID, MARKS, CLASS and NAME. (The spelling and case type of these names won't change.)
=====Input Format=====
The first line contains an integer N, the total number of students.
The second line contains the names of the columns in any order.
The next N lines contains the marks, IDs, name and class, under their respective column names.
=====Constraints=====
0<Nβ€100
=====Output Format=====
Print the average marks of the list corrected to 2 decimal places. | ["n = int(input())\ncol_list = list(input().split())\nmarks_col = col_list.index(\"MARKS\")\nmarks_list = []\nfor i in range(n):\n info_list = list(input().split())\n marks_list.append(float(info_list[marks_col]))\nprint((sum(marks_list)/n))\n", "#!/usr/bin/env python3\n\nfrom collections import namedtuple\n\ndef __starting_point():\n s_num = int(input().strip())\n tuple_fields = input().strip().split()\n \n student = namedtuple('student', tuple_fields)\n library = []\n res = 0\n \n for _ in range(s_num):\n st_info = input().strip().split()\n library.append(student(st_info[0], st_info[1], st_info[2], st_info[3]))\n \n for el in library:\n res += int(el.MARKS)\n \n print(res/s_num)\n__starting_point()"] | {"inputs": ["5\nID MARKS NAME CLASS \n1 97 Raymond 7 \n2 50 Steven 4 \n3 91 Adrian 9 \n4 72 Stewart 5 \n5 80 Peter 6", "5\nMARKS CLASS NAME ID \n92 2 Calum 1 \n82 5 Scott 2 \n94 2 Jason 3 \n55 8 Glenn 4 \n82 2 Fergus 5 "], "outputs": ["78.00", "81.00"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 778 |
# Enter your code here. Read input from STDIN. Print output to STDOUT |
623e6b183f2f52f595ce804db1257ecf | UNKNOWN | =====Problem Statement=====
Given an integer, n, perform the following conditional actions:
If n is odd, print Weird
If n is even and in the inclusive range of 2 to 5, print Not Weird
If n is even and in the inclusive range of 6 to 20, print Weird
If n is even and greater than 20, print Not Weird
=====Input Format=====
A single line containing a positive integer, n.
=====Constraints=====
1β€nβ€100
=====Output Format=====
Print Weird if the number is weird. Otherwise, print Not Weird. | ["#!/bin/python3\n\nimport sys\n\n\nN = int(input().strip())\nn= N\nw = 'Weird'\nnw = 'Not Weird'\nif n % 2 == 1:\n print(w)\nelif n % 2 == 0 and (n>=2 and n<5):\n print(nw)\nelif n % 2 == 0 and (n>=6 and n<=20):\n print(w)\nelif n % 2 == 0 and (n>20):\n print(nw) \n", "def __starting_point():\n n = int(input())\n if n % 2 == 1 or 6 <= n <= 20:\n print(\"Weird\")\n else:\n print(\"Not Weird\")\n\n__starting_point()"] | {"inputs": ["3", "24"], "outputs": ["Weird", "Not Weird"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 458 |
#!/bin/python3
import math
import os
import random
import re
import sys
if __name__ == '__main__':
n = int(input().strip())
check = {True: "Not Weird", False: "Weird"}
print(check[
n%2==0 and (
n in range(2,6) or
n > 20)
])
|
266601d64b581f092d9a34f2e511203c | UNKNOWN | =====Problem Statement=====
You are given a valid XML document, and you have to print its score. The score is calculated by the sum of the score of each element. For any element, the score is equal to the number of attributes it has.
=====Input Format=====
The first line contains N, the number of lines in the XML document.
The next N lines follow containing the XML document.
=====Output Format=====
Output a single line, the integer score of the given XML document. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nxml_str=\"\"\nn=int(input())\nfor i in range(0,n):\n tmp_str=input()\n xml_str=xml_str+tmp_str\n \ncnt=xml_str.count(\"='\")\nprint(cnt)\n", "def get_attr_number(node):\n return len(node.attrib) + sum([get_attr_number(child) for child in node])\n\n\n"] | {"inputs": ["6\n<feed xml:lang='en'>\n <title>HackerRank</title>\n <subtitle lang='en'>Programming challenges</subtitle>\n <link rel='alternate' type='text/html' href='http://hackerrank.com/'/>\n <updated>2013-12-25T12:00:00</updated>\n</feed>", "11\n<feed xml:lang='en'>\n <title>HackerRank</title>\n <subtitle lang='en'>Programming challenges</subtitle>\n <link rel='alternate' type='text/html' href='http://hackerrank.com/'/>\n <updated>2013-12-25T12:00:00</updated>\n <entry>\n \t<author gender='male'>Harsh</author>\n <question type='hard'>XML 1</question>\n <description type='text'>This is related to XML parsing</description>\n </entry>\n</feed>"], "outputs": ["5", "8"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 337 |
import sys
import xml.etree.ElementTree as etree
def get_attr_number(node):
# your code goes here
if __name__ == '__main__':
sys.stdin.readline()
xml = sys.stdin.read()
tree = etree.ElementTree(etree.fromstring(xml))
root = tree.getroot()
print(get_attr_number(root)) |
71db99d7376d1f2e045511fb461b6f68 | UNKNOWN | =====Problem Statement=====
You are given four points A, B, C and D in a 3-dimensional Cartesian coordinate system. You are required to print the angle between the plane made by the points A, B, C and B, C, D in degrees(not radians). Let the angle be PHI.
Cos(PHI) = (X.Y)/|X|Y| where X = AB x BC and Y = BC x CD.
Here, X.Y means the dot product of X and Y, and AB x BC means the cross product of vectors AB and BC. Also, AB = B-A.
=====Input Format=====
One line of input containing the space separated floating number values of the and coordinates of a point.
=====Output Format=====
Output the angle correct up to two decimal places. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\n\nimport math\ndef custom_diff(a,b):\n res0 = a[0] - b[0]\n res1 = a[1] - b[1]\n res2 = a[2] - b[2]\n return [res0,res1,res2]\n\ndef dot_product(a,b):\n return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]\n\ndef abs_val(a):\n tmp_val=a[0]*a[0]+a[1]*a[1]+a[2]*a[2]\n return math.sqrt(tmp_val)\n\n\n\ndef cross(a, b):\n c = [a[1]*b[2] - a[2]*b[1],\n a[2]*b[0] - a[0]*b[2],\n a[0]*b[1] - a[1]*b[0]]\n\n return c\n\na_str_ar=input().strip().split()\nb_str_ar=input().strip().split()\nc_str_ar=input().strip().split()\nd_str_ar=input().strip().split()\n\na=list(map(float,a_str_ar))\nb=list(map(float,b_str_ar))\nc=list(map(float,c_str_ar))\nd=list(map(float,d_str_ar))\n\nab=custom_diff(b,a)\nbc=custom_diff(c,b)\ncd=custom_diff(d,c)\n\nx=cross(ab,bc)\ny=cross(bc,cd)\n \ncosphi_top=dot_product(x,y)\ncosphi_bottom=abs_val(x)*abs_val(y)\ncosphi=cosphi_top/cosphi_bottom\n\nres=math.degrees(math.acos(cosphi))\n\nprint((\"%.2f\" %res))\n", "class Points(object):\n def __init__(self, x, y, z):\n self.x, self.y, self.z = x, y, z\n\n def __sub__(self, no):\n return Points(self.x - no.x,\n self.y - no.y,\n self.z - no.z)\n\n def dot(self, no):\n return self.x*no.x + self.y*no.y + self.z*no.z\n\n def cross(self, no):\n return Points(self.y*no.z - self.z*no.y,\n self.z*no.x - self.x*no.z,\n self.y*no.x - self.x*no.y)\n \n def absolute(self):\n return pow((self.x ** 2 + self.y ** 2 + self.z ** 2), 0.5)"] | {"inputs": ["0 4 5\n1 7 6\n0 5 9\n1 7 2", "5 8.8 9\n4 -1 3\n7 8.7 3.3\n4.4 5.1 6.3"], "outputs": ["8.19", "5.69"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 1,649 |
import math
class Points(object):
def __init__(self, x, y, z):
def __sub__(self, no):
def dot(self, no):
def cross(self, no):
def absolute(self):
return pow((self.x ** 2 + self.y ** 2 + self.z ** 2), 0.5)
if __name__ == '__main__':
points = list()
for i in range(4):
a = list(map(float, input().split()))
points.append(a)
a, b, c, d = Points(*points[0]), Points(*points[1]), Points(*points[2]), Points(*points[3])
x = (b - a).cross(c - b)
y = (c - b).cross(d - c)
angle = math.acos(x.dot(y) / (x.absolute() * y.absolute()))
print("%.2f" % math.degrees(angle)) |
e1bdff6083a183c73d89fba9a421f463 | UNKNOWN | =====Problem Statement=====
In this challenge, the task is to debug the existing code to successfully execute all provided test files.
Consider that vowels in the alphabet are a, e, i, o, u and y.
Function score_words takes a list of lowercase words as an argument and returns a score as follows:
The score of a single word is 2 if the word contains an even number of vowels. Otherwise, the score of this word is 1. The score for the whole list of words is the sum of scores of all words in the list.
Debug the given function score_words such that it returns a correct score.
Your function will be tested on several cases by the locked template code.
=====Input Format=====
The input is read by the provided locked code template. In the first line, there is a single integer n denoting the number of words. In the second line, there are n space-separated lowercase words.
=====Constraints=====
1β€nβ€20
Each word has at most 20 letters and all letters are English lowercase letters
=====Output Format=====
The output is produced by the provided and locked code template. It calls function score_words with the list of words read from the input as the argument and prints the returned score to the output. | ["def is_vowel(letter):\n return letter in ['a', 'e', 'i', 'o', 'u', 'y']\n\ndef score_words(words):\n score = 0\n for word in words:\n num_vowels = 0\n for letter in word:\n if is_vowel(letter):\n num_vowels += 1\n if num_vowels % 2 == 0:\n score += 2\n else:\n score += 1\n return score\n", "def is_vowel(letter):\n return letter in ['a', 'e', 'i', 'o', 'u', 'y']\n\ndef score_words(words):\n score = 0\n for word in words:\n num_vowels = 0\n for letter in word:\n if is_vowel(letter):\n num_vowels += 1\n if num_vowels % 2 == 0:\n score += 2\n else:\n score += 1\n return score"] | {"inputs": ["2\nhacker book\n", "3\nprogramming is awesome\n"], "outputs": ["4\n", "4\n"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 758 |
def is_vowel(letter):
return letter in ['a', 'e', 'i', 'o', 'u', 'y']
def score_words(words):
score = 0
for word in words:
num_vowels = 0
for letter in word:
if is_vowel(letter):
num_vowels += 1
if num_vowels % 2 == 0:
score += 2
else:
++score
return score
n = int(input())
words = input().split()
print(score_words(words)) |
8cb8dcc5e0723258853ada64cc93b039 | UNKNOWN | =====Problem Statement=====
You are given a string, and you have to validate whether it's a valid Roman numeral. If it is valid, print True. Otherwise, print False. Try to create a regular expression for a valid Roman numeral.
=====Input Format=====
A single line of input containing a string of Roman characters.
=====Output Format=====
Output a single line containing True or False according to the instructions above.
=====Constraints=====
The number will be between 1 and 3999 (both included). | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nimport re\ndef my_func(s):\n s = s.upper()\n ##res=re.match(r'^(?=[MDCLXVI])M*(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})(I[XV]|V?I{0,3})$',s)\n res=re.search(r'^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$',s)\n if(s==\"MMMM\"):\n print(\"False\")\n else:\n if res:\n print(\"True\")\n else:\n print(\"False\")\nmy_func(input())\n"] | {"inputs": ["CDXXI", "DXXVIIII"], "outputs": ["True", "False"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 464 |
regex_pattern = r"" # Do not delete 'r'.
import re
print(str(bool(re.match(regex_pattern, input())))) |
0ce6330be85da3177b3ab8d1dab53682 | UNKNOWN | =====Problem Statement=====
Let's dive into decorators! You are given N mobile numbers. Sort them in ascending order then print them in the standard format shown below:
+91 xxxxx xxxxx
The given mobile numbers may have +91, 91 or 0 written before the actual 10 digit number. Alternatively, there may not be any prefix at all. Alternatively, there may not be any prefix at all.
=====Input Format=====
The first line of input contains an integer N, the number of mobile phone numbers. N lines follow each containing a mobile number.
=====Output Format=====
Print N mobile numbers on separate lines in the required format. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nn=int(input())\nar=[]\nfor i in range(0,n):\n tmp_str=input()\n tmp_str=tmp_str[len(tmp_str)-10:]\n ar.append(tmp_str)\n \nar.sort()\nfor i in range(0,len(ar)):\n print((\"+91 \"+ar[i][:5]+\" \"+ar[i][5:]))\n"] | {"inputs": ["3\n07895462130\n919875641230\n9195969878", "3\n09191919191\n9100256236\n+919593621456"], "outputs": ["+91 78954 62130\n+91 91959 69878\n+91 98756 41230", "+91 91002 56236\n+91 91919 19191\n+91 95936 21456"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 298 |
def wrapper(f):
def fun(l):
# complete the function
return fun
@wrapper
def sort_phone(l):
print(*sorted(l), sep='\n')
if __name__ == '__main__':
l = [input() for _ in range(int(input()))]
sort_phone(l)
|
0bca649246140b1afcae01e3e72853d5 | UNKNOWN | =====Problem Statement=====
The provided code stub will read in a dictionary containing key/value pairs of name:[marks] for a list of students. Print the average of the marks array for the student name provided, showing 2 places after the decimal.
=====Example=====
marks key:value pairs are
'alpha': [20,30,40]
'beta': [30,50,70]
query_name = 'beta'
The query_name is 'beta'. beta's average score is (30+50+70)/3 = 50
=====Input Format=====
The first line contains the integer n, the number of students' records. The next n lines contain the names and marks obtained by a student, each value separated by a space. The final line contains query_name, the name of a student to query.
=====Constraints=====
2β€nβ€10
0β€marks[i]β€100
length of marks arrays = 3
=====Output Format=====
Print one line: The average of the marks obtained by the particular student correct to 2 decimal places. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nn=int(input())\nar={}\nfor i in range(0,n):\n s=input()\n ss=s.split(\" \")\n n=ss[0]\n m1=float(ss[1])\n m2=float(ss[2])\n m3=float(ss[3])\n m_avg=(m1+m2+m3)/3.0\n ar[n]=\"%.2f\" % m_avg\ns_name=input()\nprint((ar[s_name]))\n", "def get_avg(marks, student):\n return (sum(marks[student])/len(marks[student]))\n\ndef __starting_point():\n n = int(input())\n student_marks = {}\n for _ in range(n):\n name, *line = input().split()\n scores = list(map(float, line))\n student_marks[name] = scores\n query_name = input()\n print((\"{:.2f}\".format(get_avg(student_marks, query_name))))\n\n__starting_point()"] | {"inputs": ["3\nKrishna 67 68 69\nArjun 70 98 63\nMalika 52 56 60\nMalika", "2\nHarsh 25 26.5 28\nAnurag 26 28 30\nHarsh"], "outputs": ["56.00", "26.50"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 742 |
if __name__ == '__main__':
n = int(input())
student_marks = {}
for _ in range(n):
name, *line = input().split()
scores = list(map(float, line))
student_marks[name] = scores
query_name = input() |
8b9402ca08fcc495d23796cf5a2ccaa5 | UNKNOWN | =====Problem Statement=====
Let's use decorators to build a name directory! You are given some information about N people. Each person has a first name, last name, age and sex ('M' or 'F'). Print their names in a specific format sorted by their age in ascending order i.e. the youngest person's name should be printed first. For two people of the same age, print them in the order of their input.
For Henry Davids, the output should be:
Mr. Henry Davids
For Mary George, the output should be:
Ms. Mary George
=====Input Format=====
The first line contains the integer N, the number of people. N lines follow each containing the space separated values of the first name, last name, age and sex, respectively.
=====Constraints=====
1β€Nβ€10
=====Output Format=====
Output N names on separate lines in the format described above in ascending order of age. | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nar=[]\nn=int(input())\nfor i in range(0,n):\n str_ar=input().strip().split()\n user_name=str_ar[0]+\" \"+str_ar[1]\n user_age=int(str_ar[2])\n user_sex=str_ar[3]\n user_new_name=\"\"\n if(user_sex==\"M\"):\n user_new_name=\"Mr. \"+user_name\n else:\n user_new_name=\"Ms. \"+user_name\n ar.append([user_new_name,user_age])\n\nl = sorted(ar, key=lambda tup: tup[1])\nfor i in range(0,n):\n print((l[i][0]))\n"] | {"inputs": ["3\nMike Thomson 20 M\nRobert Bustle 32 M\nAndria Bustle 30 F", "5\nLaura Moser 50 F\nTed Moser 50 M\nYena Dixit 50 F\nDiya Mirza 50 F\nRex Dsouza 51 M"], "outputs": ["Mr. Mike Thomson\nMs. Andria Bustle\nMr. Robert Bustle", "Ms. Laura Moser\nMr. Ted Moser\nMs. Yena Dixit\nMs. Diya Mirza\nMr. Rex Dsouza"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 522 |
import operator
def person_lister(f):
def inner(people):
# complete the function
return inner
@person_lister
def name_format(person):
return ("Mr. " if person[3] == "M" else "Ms. ") + person[0] + " " + person[1]
if __name__ == '__main__':
people = [input().split() for i in range(int(input()))]
print(*name_format(people), sep='\n') |
99748d1965c7e8aea5e99cf6b17c520c | UNKNOWN | =====Problem Statement=====
Let's learn about list comprehensions! You are given three integers x, y and z representing the dimensions of a cuboid along with an integer n. Print a list of all possible coordinates given by (i,j,k) on a 3D grid where the sum of i+j+k is not equal to n. Here, 0β€iβ€x;0β€jβ€y;0β€kβ€z. Please use list comprehensions rather than multiple loops, as a learning exercise.
=====Example=====
x = 1
y = 1
z = 2
n = 3
All permutations of [i,j,k] are:
[[0,0,0],[0,0,1],[0,0,2],[0,1,0],[0,1,1],[0,1,2],[1,0,0],[1,0,1],[1,0,2],[1,1,0],[1,1,1],[1,1,2]]
Print an array of the elements that do not sum to n = 3
[[0,0,0],[0,0,1],[0,0,2],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,2]]
=====Input Format=====
Four integers x, y, z and n, each on a separate line.
=====Constraints=====
Print the list in lexographic increasing order | ["# Enter your code here. Read input from STDIN. Print output to STDOUT\nx=int(input())\ny=int(input())\nz=int(input())\nn=int(input())\nprint([ [i,j,k] for i in range(x+1) for j in range(y+1) for k in range(z+1) if i+j+k != n ])\n", "def __starting_point():\n x = int(input())\n y = int(input())\n z = int(input())\n n = int(input())\n \n print([ [ i, j, k] for i in range(x + 1) for j in range(y + 1) for k in range(z + 1) if ( (i + j + k) != n )])\n\n__starting_point()"] | {"inputs": ["1\n1\n1\n2", "2\n2\n2\n2"], "outputs": ["[[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]", "[[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 2], [0, 2, 1], [0, 2, 2], [1, 0, 0], [1, 0, 2], [1, 1, 1], [1, 1, 2], [1, 2, 0], [1, 2, 1], [1, 2, 2], [2, 0, 1], [2, 0, 2], [2, 1, 0], [2, 1, 1], [2, 1, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]]"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 492 |
if __name__ == '__main__':
x = int(input())
y = int(input())
z = int(input())
n = int(input()) |
e94b27c15ae9f82ecc6dcde454a6138b | UNKNOWN | =====Problem Statement=====
For this challenge, you are given two complex numbers, and you have to print the result of their addition, subtraction, multiplication, division and modulus operations. The real and imaginary precision part should be correct up to two decimal places.
=====Input Format=====
One line of input: The real and imaginary part of a number separated by a space.
=====Output Format=====
For two complex numbers C and D, the output should be in the following sequence on separate lines:
C+D
C-D
C*D
C/D
mod(C)
mod(D)
For complex numbers with non-zero real (A) and complex part (B), the output should be in the following format:
Replace the plus symbol (+) with a minus symbol (-) when B<0.
For complex numbers with a zero complex part i.e. real numbers, the output should be:
A+0.00i
For complex numbers where the real part is zero and the complex part is non-zero, the output should be:
0.00+Bi | ["# Enter your code here. Read input from STDIN. Print output to \n\n\nimport math\n\nclass ComplexNumber(object): \n def __init__(self, real, compl): \n self.real = real \n self.compl = compl\n pass\n def __str__(self):\n if (self.compl >= 0):\n return '{0:.2f}'.format(self.real) +'+'+ '{0:.2f}'.format(self.compl) +'i' \n return '{0:.2f}'.format(self.real) +'-'+ '{0:.2f}'.format(abs(self.compl)) +'i' \n def __add__(x, y):\n return ComplexNumber(x.real+y.real, x.compl+y.compl)\n def __sub__(x, y):\n return ComplexNumber(x.real-y.real, x.compl-y.compl)\n def __mul__(x, y):\n return ComplexNumber(x.real*y.real - x.compl*y.compl, x.compl*y.real + x.real*y.compl)\n def __truediv__(x, y):\n return ComplexNumber((x.real*y.real + x.compl*y.compl) / (y.real*y.real + y.compl*y.compl), \n (x.compl*y.real - x.real*y.compl) / (y.real*y.real + y.compl*y.compl))\n def mod(self):\n return ComplexNumber(math.sqrt(self.real*self.real + self.compl*self.compl), 0)\n \nhelp = list(map(float, input().split(' '))) \nx = ComplexNumber(help[0], help[1]) \nhelp = list(map(float, input().split(' '))) \ny = ComplexNumber(help[0], help[1]) \n\nprint(x+y)\nprint(x-y)\nprint(x*y)\nprint(x/y)\nprint(x.mod())\nprint(y.mod())", "import numbers\n\nr1, i1 = map(float, input().split())\nr2, i2 = map(float, input().split())\nc1 = complex(r1, i1)\nc2 = complex(r2, i2)\n\ndef printer(c):\n real = c.real\n imag = c.imag\n\n sign = '+' if imag >= 0 else '-'\n print('{:.2f}{}{:.2f}i'.format(real, sign, abs(imag)))\n\ndef mod(c):\n return (c.real * c.real + c.imag * c.imag) ** 0.5\n\nprinter(c1 + c2)\nprinter(c1 - c2)\nprinter(c1 * c2)\nprinter(c1 / c2)\nprint('{:.2f}+0.00i'.format(mod(c1)))\nprint('{:.2f}+0.00i'.format(mod(c2)))"] | {"inputs": ["2 1\n5 6", "5.9 6\n9 10"], "outputs": ["7.00+7.00i\n-3.00-5.00i\n4.00+17.00i\n0.26-0.11i\n2.24+0.00i\n7.81+0.00i", "14.90+16.00i\n-3.10-4.00i\n-6.90+113.00i\n0.62-0.03i\n8.41+0.00i\n13.45+0.00i"]} | INTRODUCTORY | PYTHON3 | HACKERRANK | 1,876 |
import math
class Complex(object):
def __init__(self, real, imaginary):
def __add__(self, no):
def __sub__(self, no):
def __mul__(self, no):
def __truediv__(self, no):
def mod(self):
def __str__(self):
if self.imaginary == 0:
result = "%.2f+0.00i" % (self.real)
elif self.real == 0:
if self.imaginary >= 0:
result = "0.00+%.2fi" % (self.imaginary)
else:
result = "0.00-%.2fi" % (abs(self.imaginary))
elif self.imaginary > 0:
result = "%.2f+%.2fi" % (self.real, self.imaginary)
else:
result = "%.2f-%.2fi" % (self.real, abs(self.imaginary))
return result
if __name__ == '__main__':
c = map(float, input().split())
d = map(float, input().split())
x = Complex(*c)
y = Complex(*d)
print(*map(str, [x+y, x-y, x*y, x/y, x.mod(), y.mod()]), sep='\n') |
23584ab5b6ae30839ddda0df1d0bb10e | UNKNOWN | Snuke signed up for a new website which holds programming competitions.
He worried that he might forget his password, and he took notes of it.
Since directly recording his password would cause him trouble if stolen,
he took two notes: one contains the characters at the odd-numbered positions, and the other contains the characters at the even-numbered positions.
You are given two strings O and E. O contains the characters at the odd-numbered positions retaining their relative order, and E contains the characters at the even-numbered positions retaining their relative order.
Restore the original password.
-----Constraints-----
- O and E consists of lowercase English letters (a - z).
- 1 \leq |O|,|E| \leq 50
- |O| - |E| is either 0 or 1.
-----Input-----
Input is given from Standard Input in the following format:
O
E
-----Output-----
Print the original password.
-----Sample Input-----
xyz
abc
-----Sample Output-----
xaybzc
The original password is xaybzc. Extracting the characters at the odd-numbered positions results in xyz, and extracting the characters at the even-numbered positions results in abc. | ["q=str(input())\ne=str(input())\na=len(q)\nb=len(e)\nc=\"\"\nif a==b:\n for i in range(a):\n c+=q[i]\n c+=e[i]\nelse:\n for i in range(b):\n c+=q[i]\n c+=e[i]\n c+=q[a-1]\n\nprint(c)", "o = input()\ne = input()\npassword = \"\"\n\nfor i in range(len(o)):\n password += o[i]\n if len(e) > i:\n password += e[i]\n\nprint(password)", "O = input()\nE = input()\nAns = []\n\nif len(O) - len(E) == 0:\n for i in range(len(O)):\n \tAns.append(O[i])\n \tAns.append(E[i])\nelse:\n for i in range(len(E)):\n Ans.append(O[i])\n Ans.append(E[i])\n Ans.append(O[len(O)-1])\n \nprint(''.join(Ans))", "o = input()\ne = input()\nres = \"\"\nn = min(len(o), len(e))\nfor i in range(n):\n res += o[i] + e[i]\n\nif len(e) > len(o):\n res += e[-1]\nelif len(e) < len(o):\n res += o[-1]\n\nprint(res)\n", "a = input()\nb = input()\nli = []\nif len(a) == len(b):\n for i in range(len(a)):\n li.append(a[i]+b[i])\nelse:\n for i in range(len(b)):\n li.append(a[i]+b[i])\n li.append(a[-1])\nprint(''.join(li))", "A = input()\nB = input()\n\npw = \"\"\nif len(A) == len(B):\n for i in range(len(A)):\n pw += A[i]\n pw += B[i]\n print(pw)\n return\n\nelse:\n for i in range(len(B)):\n pw += A[i]\n pw += B[i]\n print(pw + A[-1])\n return", "a,b=input(),input();n=[i+j for i,j in zip(a,b)]\nprint(*[n,n+[a[-1]]][len(a)-len(b)==1],sep='')", "a = list(input())\nb = list(input())\nf = False\nx = []\nif len(a)> len(b):\n b.append(0)\n f = True\nfor i in range(len(a)):\n x.append(a[i])\n x.append(b[i])\nif f:\n x.pop()\nprint(\"\".join(x))", "o = input()\ne = input()\ne += \" \"\nans = \"\"\nfor i in range(len(o)):\n ans += o[i]\n ans += e[i]\nprint(ans)", "o = [a for a in str(input())]\ne = [b for b in str(input())]\nans = []\nfor i in range(len(e)):\n ans.append(o[i])\n ans.append(e[i])\nif len(o) > len(e):\n ans.append(o[-1])\nprint(\"\".join(ans))", "import math\nimport collections\nii = lambda : int(input())\nmi = lambda : map(int,input().split())\nli = lambda : list(map(int,input().split()))\n\no = input()\ne = input()\nfor i in range(len(e)):\n print(o[i] + e[i] ,end = \"\")\nif len(o) != len(e):\n print(o[-1])\nelse:\n print()", "from collections import deque\nfrom itertools import count\nOdd = deque(input())\nEven = deque(input())\nrtnList = lambda x: Odd if x & 1 else Even\nans = ''\nfor i in count(1,1):\n try:\n s = rtnList(i).popleft()\n except IndexError:\n print(ans)\n return\n ans += s\n", "O = input()\nE = input()\no = len(O)\ne = len(E)\n[print(O[i], E[i], sep = \"\", end = \"\") for i in range(min(o, e))]\nprint(\"\" if o == e else O[-1])", "O = list(input())\nE = list(input())\n\nans = [0]*(len(O)+len(E))\nfor i in range(len(ans)):\n if i % 2 == 0:\n ans[i] = O[0]\n del O[0]\n else:\n ans[i] = E[0]\n del E[0]\n \nprint(\"\".join(ans))", "O=input()\nE=input()\nans=\"\"\nfor i in range(len(O)) :\n ans+=O[i]\n if i<len(E) :\n ans+=E[i]\nprint(ans)", "o = input()\ne = input()\nans = []\nfor i in range(len(e)):\n ans.append(o[i])\n ans.append(e[i])\nif len(o) != len(e):\n ans.append(o[-1])\nprint(\"\".join(ans))", "li_o = input()\nli_e = input()\nan = ''\nfor i in range(len(li_o)):\n an += li_o[i]\n if i != len(li_e):\n an += li_e[i]\n else:\n break\nprint(an)", "s = list(input())\nt = list(input())\nl = min(len(s),len(t))\nif len(s)>len(t):\n x = 1\nelif len(s)<len(t):\n x = 2\nelse:\n x = 0\nfor i in range(l):\n print(s[i],end = \"\")\n print(t[i],end = \"\")\nif x == 1:\n print(s[-1])\nelif x == 2:\n print(t[-1])", "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom math import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\nimport bisect\nimport heapq\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165g\n#\n# \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7cfb\n# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);\n# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\n#mod = 998244353\nINF = float('inf')\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n return list(map(int,readline().split()))\ndef readTuples():\n return tuple(map(int,readline().split()))\ndef I():\n return int(readline())\no = input()\ne = input()\nans = \"\"\nfor i in range(len(o)):\n ans += o[i]\n if i >= len(e):\n pass\n else:\n ans += e[i]\nprint(ans)\n", "O = str(input())\nE = str(input())\nS = ''\nfor i in range(len(O) + len(E)):\n if i % 2 == 0:\n S += O[(i // 2)]\n else:\n S += E[(i // 2)]\n \nprint(S)", "o = list(input())\ne = list(input())\n\nlst = []\nfor oo,ee in zip(o,e):\n lst.append(oo+ee)\n\nif len(o)-len(e) == 1:\n lst.append(o[-1])\n\nprint(\"\".join(lst))", "o=input()\ne=input()\nO=len(o)\nE=len(e)\na=[]\nif O==E:\n for i in range(O):\n a.append(o[i]+e[i])\n b=''.join(a)\n print(b)\nelse:\n for i in range(E):\n a.append(o[i]+e[i])\n a.append(o[O-1])\n b=''.join(a)\n print(b)", "def answer(o: str, e: str) -> str:\n result = ''\n e += ' '\n for i in range(len(o)):\n result += o[i] + e[i]\n\n return result.strip()\n\n\ndef main():\n o = input()\n e = input()\n print(answer(o, e))\n\n\ndef __starting_point():\n main()\n__starting_point()", "def main():\n O = input()\n E = input()\n pas = ''\n for i in range(len(E)):\n pas += O[i] + E[i]\n if len(O) > len(E):\n pas += O[-1]\n print(pas)\n\ndef __starting_point():\n main()\n__starting_point()", "def main():\n O = list(input())\n E = list(input())\n O.reverse()\n E.reverse()\n ans = ''\n for _ in range(200):\n ans += O.pop()\n if len(E) == 0:\n break\n ans += E.pop()\n if len(O) == 0:\n break\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "o=input()\ne=input()\np=\"\"\nfor i in range(len(e)):\n p+=o[i]\n p+=e[i]\nif len(o)!=len(e):\n p+=o[-1]\nprint(p)\n\n\n", "o = input()\ne = input()\nfor i in range(len(o)):\n print(o[i], end=\"\")\n if i < len(e):\n print(e[i], end=\"\")\nprint()\n", "o=list(input())\ne=input()\nfor i in range(len(e)):\n o.insert(2*i+1,e[i])\nprint(*o,sep=\"\")\n", "O=input()\nE=input()\nans=\"\"\nfor i in range(len(E)):\n ans+=O[i]\n ans+=E[i]\n\nif len(O)!=len(E):\n ans+=O[-1]\nprint(ans)", "o=input()\ne=input()\nn=len(o)\nm=len(e)\nans=[]\nfor i in range(m):\n ans.append(o[i])\n ans.append(e[i])\nif n-m==0:\n print(*ans,sep='')\nelse:\n ans.append(o[n-1])\n print(*ans,sep='')", "o = list(input())\ne = list(input())+[\"\"]\nfor s,t in zip(o,e):\n print(s+t,end=\"\")\n", "import sys\ninput = sys.stdin.readline\nfrom collections import deque\n\n\ndef read():\n O = input().strip()\n E = input().strip()\n return O, E\n\n\ndef solve(O, E):\n ans = []\n oq = deque(O)\n eq = deque(E)\n while eq:\n ans.append(oq.popleft())\n ans.append(eq.popleft())\n if oq:\n ans.append(oq.popleft())\n return \"\".join(ans)\n\n\ndef __starting_point():\n inputs = read()\n outputs = solve(*inputs)\n if outputs is not None:\n print((\"%s\" % str(outputs)))\n\n__starting_point()", "o=input()\ne=input()\nans=''\nfor i in range(len(e)):\n ans+=o[i]\n ans+=e[i]\nif len(o)==len(e):\n print(ans)\nelse:\n print((ans+o[-1]))\n", "o = input()\ne = input()\nans = ''\nfor i in range(len(e)):\n ans +=o[i]+e[i]\nif len(o) != len(e):\n ans +=o[-1]\nprint(ans)", "o = input()\ne = input()\n\nans = ''\nfor i,j in zip(o,e):\n ans+= i+j\nif len(o) != len(e):\n ans+=o[-1]\nprint(ans)", "O = list(input())\nE = list(input())\n\nres = []\n\nif len(O) - len(E) == 0:\n for i, j in zip(O, E):\n res.append(i)\n res.append(j)\nelse:\n E.append('')\n for i, j in zip(O, E):\n res.append(i)\n res.append(j)\n res.pop(-1)\n \npw = ''.join(res)\nprint(pw)", "o=input()\ne=input()\ns=[]\ni=1\nj=0\nwhile True:\n if i%2==0:\n s.append(e[j])\n i+=1\n j+=1\n else:\n s.append(o[j])\n i+=1\n if i>=len(o)+len(e)+1:\n break\nfor i in range(len(s)):\n print(s[i],end=\"\")", "O = input()\nE = input()\nt = \"\"\nn = min(len(O), len(E))\nfor i in range(n):\n t += O[i] + E[i]\nif len(O) > len(E):\n t += O[len(O)-1]\nelif len(O) < len(E):\n t += E[len(E)-1]\nprint(t)\n", "#n = int(input())\n#a, b = map(int,input().split())\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\no = list(input())\ne = list(input())\noc = 0\nec = 0\n\nans = ''\n\nn = len(o)+len(e)\nfor i in range(1,n+1):\n if i % 2 == 0:\n add = e[ec]\n ec += 1\n else:\n add = o[oc]\n oc += 1\n ans += add\n\nprint(ans)\n", "a = input()\nb = input()\ns = \"\"\nfor i in range(len(b)):\n s += a[i] + b[i]\nif len(a) > len(b):\n s += a[-1]\nprint(s)", "a = list(input())\nb = list(input())\n\nfor i in range(0, len(a) + len(b)):\n if i % 2 == 0:\n print(a.pop(0), end = \"\")\n else:\n print(b.pop(0), end = \"\")\n", "o = input()\ne = input()\nans = ''\nif len(o) == len(e):\n time = len(o) * 2\nelse:\n time = len(o) * 2 - 1\nfor i in range(time):\n if i % 2 == 0:\n ans += o[i // 2]\n else:\n ans += e[i // 2]\nprint(ans)", "o = input()\ne = input()\nans = ''\nfor i in range(len(e)):\n ans += o[i]+e[i]\n\nif len(o) == len(e):\n print(ans)\nelse:\n print(ans+o[-1])", "O = input()\nE = input()\n\ncombi=''\n\nfor i in range(len(O)+len(E)):\n if i%2==0:\n combi+=O[i//2]\n elif i%2!=2:\n combi+=E[i//2]\nprint(combi)", "\nO = input()\nE = input()\n\ni = 0\nfor i in range(len(O)):\n print(O[i],end='')\n if i < len(E):\n print(E[i],end='')\n i += 1\n", "o = list(input())\ne = list(input())\nfor i in range(len(e)):\n print(o[i],end=\"\")\n print(e[i],end=\"\")\nif len(o) > len(e):\n print(o[-1])", "odd = list(map(str, input()))\neven = list(map(str, input()))\nif len(odd)==len(even):\n L=len(odd)*2\nelse:\n L=len(odd)+len(even)\nli=[]\n\nfor i in range(1,L+1):\n if i%2==1:\n if i==1:\n li.append(odd[0])\n else:\n li.append(odd[i//2])\n else:\n li.append(even[i//2-1])\n \nprint(''.join(li))", "O = input()\nE = input()\ns = \"\"\n\nfor so,se in zip(O,E):\n s += so+se\n\nif len(list(O)) > len(list(E)):\n s += O[-1]\nelif len(list(O)) < len(list(E)):\n s += E[-1]\n \nprint(*s,sep=\"\")", "o = list(input())\ne = list(input())\n\nans = list()\n\nfor i in range(len(e)):\n ans.append(o[i])\n ans.append(e[i])\n\nif len(o) != len(e):\n ans.append(o[-1])\n\nprint((''.join(ans)))\n", "o = input()\ne = input()\nd = \"\"\nif len(o) == len(e):\n for i in range(len(o)):\n d += o[i]\n d += e[i]\n print(d)\nelse:\n for i in range(len(e)):\n d += o[i]\n d += e[i]\n d += o[-1]\n print(d)", "O = input()\nE = input()\nfor i in range(min(len(O),len(E))):\n\tprint(O[i],E[i],sep=\"\",end=\"\")\nif len(O) > len(E):\n\tprint(O[-1])", "O = input()\nE = input()\n\nans = ''\n\nif len(O) == len(E):\n for i in range(len(O)):\n ans += O[i]\n ans += E[i]\nelse:\n for i in range(len(E)):\n ans += O[i]\n ans += E[i]\n ans += O[-1]\n\nprint(ans)", "a,b=input(),input();n=[i+j for i,j in zip(a,b)]\nprint(*[n,n+[a[-1]]][len(a)-len(b)],sep='')", "o = list(input())\ne = list(input())\n\nans = ''\nfor i in range(len(e)):\n ans += o[i] + e[i]\nif len(o) > len(e):\n ans += o[len(o) - 1]\nprint(ans)", "def actual(O, E):\n s = ''.join([f'{o}{e}' for o, e in zip(O, E)])\n\n if len(O) - len(E) == 1:\n s += O[-1]\n\n return s\n\nO = input()\nE = input()\n\nprint(actual(O, E))", "o = input()\ne = input()\n\nans = ''\nfor i in range(len(e)):\n ans += o[i]\n ans += e[i]\nif len(e) < len(o):\n ans += o[-1]\nprint(ans)\n", "o=input()\ne=input()\n\np=\"\"\n\nfor i in range(len(o)):\n p+=o[i]\n if i<len(e):\n p+=e[i]\n \nprint (p)\n\n\n", "o = str(input())\ne = str(input())\n\nans = ''\nfor i in range(len(e)):\n ans += o[i]\n ans += e[i]\nif len(o) != len(e):\n ans += o[-1]\nprint(ans)", "o = input()\ne = input()\nans = []\nfor i in range(len(o)+len(e)):\n if i%2 == 0:\n ans.append(o[i//2])\n else:\n ans.append(e[i//2])\nprint(\"\".join(ans))", "o, e = [input() for i in range(2)]\nfor i in range(len(e)):\n print(o[i], end = \"\")\n print(e[i], end = \"\")\nif len(o) - len(e) == 1:\n print(o[len(o)-1])", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n O = input().rstrip()\n E = input().rstrip()\n password=\"\"\n last = \"\"\n\n if len(O) > len(E):\n last = O[-1]\n elif len(O) < len(E):\n last = E[-1]\n else:\n last=\"\"\n\n for p1,p2 in zip(O,E):\n password+=p1+p2\n print(password+last)\n\ndef __starting_point():\n main()\n__starting_point()", "O = input()\nE = input()\n\nresult = ''\nif len(O) == len(E):\n for i in range(len(O)):\n result += O[i] + E[i]\nelse:\n for i in range(len(E)):\n result += O[i] + E[i]\n result += O[-1]\n\nprint(result)", "o = input()\ne = input()\nans = ''\nfor i in range(len(e)):\n ans += o[i] + e[i]\nif len(o) - len(e) == 1:\n ans += o[len(o)-1]\nprint(ans)", "o = input()\ne = input()\n\nfor i in range(len(e)):\n print(o[i], end = '')\n print(e[i], end = '')\n\nif len(o) != len(e):\n print(o[len(o)-1])", "o = input()\ne = input()\n\nn = len(o) + len(e)\ns = ['' for _ in range(n)]\nfor i in range(n):\n j = i // 2\n if i % 2 == 0:\n s[i] = o[j]\n else:\n s[i] = e[j]\n\nprint((''.join(s)))\n", "O = input()\nE = input()\n\nans = ''\n\nfor i in range(len(E)):\n ans += O[i] + E[i]\n\nif len(O) != len(E):\n ans += O[-1]\n\nprint(ans)\n", "o = str(input())\ne = str(input())\na = ''\nfor i in range(len(e)):\n a += o[i]\n a += e[i]\n if len(o) != len(e) and i == len(e) - 1:\n a += o[i + 1]\nprint(a)", "#58B\nA=list(input())\nB=list(input())\nx=A[0]+B[0]\nfor i in range(1,len(B)):\n x=x+A[i]+B[i]\nif len(A)>len(B):\n x=x+A[-1]\nprint(x)", "o = input()\ne = input()\n\nans = ''\nfor i in range(len(o) + len(e)):\n if i % 2 == 0:\n ans += o[i - (i // 2)]\n else:\n ans += e[i - ((i + 1) // 2)]\n\nprint(ans)\n", "s1 = input()\ns2 = input()\nans = \"\"\nfor i,j in zip(s1, s2):\n ans += (i + j)\n \nif len(s1) != len(s2):\n ans += s1[-1]\nprint(ans)", "o = input()\ne = input()\n\np = ''\nfor i in range(len(e)):\n p += o[i] + e[i]\nif len(o) > len(e):\n p += o[-1]\nprint(p)", "s = input()\nt = input()\nans = \"\"\nif (len(s) + len(t)) % 2 == 0:\n for i in range(len(s)):\n ans += s[i]\n ans += t[i]\nelse:\n for i in range(len(t)):\n ans += s[i]\n ans += t[i]\n ans += s[-1]\n \nprint(ans)", "O = input()\nE = input()\nS = \"\"\n\nif len(O) == len(E):\n for i in range(len(O)):\n S += O[i] + E[i]\n \nelse:\n for i in range(len(E)):\n S += O[i] + E[i]\n S += O[len(O)-1]\n \nprint(S)", "O = input()\nE = input()\n\npassword = ''\nfor o, e in zip(O, E):\n s = o + e\n password += s\n\nif len(O) > len(E):\n print(password + O[-1])\nelif len(O) < len(E):\n print(password + E[-1])\nelse:\n print(password)", "o = input()\ne = input()\na = \"\"\n\nfor i in range(len(o)):\n a += o[i]\n if i < len(e):\n a += e[i]\n\nprint(a)", "O = list(input())\nE = list(input())+[\"\"]\n\nfor o,e in zip(O, E):\n print(o+e,end=\"\")\n", "ans = \"\"\nO = input()\nE = input()\nfor o, e in zip(O, E):\n ans += o + e\nif len(O) > len(E):\n ans += O[-1]\n\nprint(ans)\n", "o = str(input())\ne = str(input())\n\nans = \"\"\njudge = False\nif len(o)-len(e) == 1:\n judge = True\n\nfor i in range(len(e)):\n ans += o[i]\n ans += e[i]\nif judge:\n ans += o[-1]\n\nprint(ans)", "#!/usr/bin/env python3\n\ndef main():\n a = list(input())\n b = list(input()) + [\"\"]\n for i in range(len(a)):\n print(a[i], end=\"\")\n print(b[i], end=\"\")\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import math\na=input()\nb=input()\n\nn=''\nfor i in range(len(a)+len(b)):\n if i%2==0:\n n=n+a[i//2]\n else:\n n=n+b[math.ceil(i/2)-1]\nprint(n)", "o = input()\ne = input()\nans = \"\".join([o[i]+e[i] for i in range(min(len(o), len(e)))])\nif len(o)!=len(e):\n if len(o) > len(e): ans += o[-1]\n else: ans += e[-1]\nprint(ans)", "# B - \u2235\u2234\u2235\ndef main():\n o = list(input())\n d = list(input())\n\n for i in range(len(o)+len(d)):\n if i % 2 == 0:\n print(o.pop(0), end='')\n else:\n print(d.pop(0), end='')\n\n \n \ndef __starting_point():\n main()\n__starting_point()", "o = input()\ne = input()\n\nlen_o = len(o)\nlen_e = len(e)\nans = ''\n\nif len_o == len_e:\n for i in range(len_o):\n ans += o[i]\n ans += e[i]\nelif len_o > len_e:\n for i in range(len_e):\n ans += o[i]\n ans += e[i]\n for i in range(len_e, len_o):\n ans += o[i]\nelse:\n for i in range(len_o):\n ans += o[i]\n ans += e[i]\n for i in range(len_o, len_e):\n ans += e[i]\nprint(ans)\n", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\nINF = float('inf')\nMOD = 10**9 + 7\n#MOD = 998244353\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lintdec(): return list(map(lambda x:int(x) - 1, input().split()))\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nO = si()\nE = si()\n\nfor i in range(len(O + E)):\n if i % 2:\n print(E[i // 2], end='')\n else:\n print(O[i // 2], end='')\nprint()", "o = input()\ne = input()\n\nres = \"\"\nfor i, j in zip(o, e):\n res += i + j\nif(len(o) != len(e)): res += o[-1]\nprint(res)", "o = input()\ne = input()\np = ''\nif len(o) == len(e):\n for i in range(0, len(o)):\n p += o[i] + e[i]\n \nelif len(o) >= len(e):\n for i in range(0, len(e)):\n p += o[i] + e[i]\n p += o[-1]\n \nprint(p)", "a,b=input(),input()+' ';print(*[i+j for i,j in zip(a,b)],sep='')", "o = input()\ne = input()\nl = []\nif len(o)-len(e) == 1:\n for i in range(len(e)):\n l.append(o[i])\n l.append(e[i])\n l.append(o[-1])\nelse:\n for i in range(len(o)):\n l.append(o[i])\n l.append(e[i])\nprint(\"\".join(l))", "o = input()\ne = input()\n\nfor i in range(len(e)):\n print(o[i]+e[i], end=\"\")\n\nif len(o) - len(e) == 1:\n print(o[-1])", "o, e = input(), input() + \" \"\nfor x, y in zip(o, e):\n print(x + y, end=\"\")", "o = input()\ne = input()\ns = \"\"\nfor i in range(len(e)):\n s += o[i]\n s += e[i]\nif len(o) == len(e):\n print(s)\nelse :\n s += o[-1]\n print(s)", "o = input()\nt = input()\n\nans = \"\"\n\nfor i in range(min(len(o), len(t))):\n ans += o[i] + t[i]\n\nif len(o) > len(t):\n ans += o[-1]\nelif len(o) < len(t):\n ans += t[-1]\nelse:\n pass\n\nprint(ans)", "o = input()\ne = input()\n\npw = ''\nfor i in range(len(o)):\n pw += o[i]\n if i < len(e):\n pw += e[i]\nprint(pw)", "O = list(input())\nlo = len(O)\nE = list(input())\nle = len(E)\nw = lo + le\n\nX = ['*']*w\nfor i in range(le):\n X[2*i] =O[i]\n X[2*i+1] = E[i]\nif lo > le:\n X[-1] = O[-1]\n \nprint(''.join(X))", "a=input()\nb=input()\nc=len(a)\nd=len(b)\nx=\"\"\nif c<=d:\n for i in range(c):\n x=x+a[i]\n x=x+b[i]\n print(x)\nif c>d:\n for i in range(d):\n x=x+a[i]\n x=x+b[i]\n x=x+a[len(a)-1]\n print(x)", "o = list(input())\ne = list(input())\ns = []\nt = \"\"\nif len(o+e) % 2 == 0:\n for i in range(int(len(o+e)/2)):\n s.append(o[i]+e[i])\n t = t.join(s)\nelse:\n for i in range(int(len(o+e)/2)):\n s.append(o[i]+e[i])\n t = t.join(s)\n t = t + o[int(len(o+e)/2)]\n\nprint(t)\n", "o = list(input())\ne = list(input()) + [\"\"]\nans = \"\".join(o + e for o, e in zip(o, e))\nprint(ans)", "#!/usr/bin/env python3\n\ndef main():\n a = input()\n b = input()\n for i in range(len(a)):\n print(a[i], end=\"\")\n if i < len(b):\n print(b[i], end=\"\")\n print()\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "O = list(input())\nE = list(input())+['']\nprint(*[o+e for o,e in zip(O,E)], sep=\"\")\n", "O = input()\nE = input()\n\nans = \"\"\nwhile len(O)>0:\n ans += O[:1]+E[:1]\n O = O[1:]\n E = E[1:]\nprint(ans)"] | {"inputs": ["xyz\nabc\n", "atcoderbeginnercontest\natcoderregularcontest\n"], "outputs": ["xaybzc\n", "aattccooddeerrbreeggiunlnaerrccoonntteesstt\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 21,496 | |
278ff6aa2669a17f37144ed9ba42c63a | UNKNOWN | Sig has built his own keyboard. Designed for ultimate simplicity, this keyboard only has 3 keys on it: the 0 key, the 1 key and the backspace key.
To begin with, he is using a plain text editor with this keyboard. This editor always displays one string (possibly empty). Just after the editor is launched, this string is empty. When each key on the keyboard is pressed, the following changes occur to the string:
- The 0 key: a letter 0 will be inserted to the right of the string.
- The 1 key: a letter 1 will be inserted to the right of the string.
- The backspace key: if the string is empty, nothing happens. Otherwise, the rightmost letter of the string is deleted.
Sig has launched the editor, and pressed these keys several times. You are given a string s, which is a record of his keystrokes in order. In this string, the letter 0 stands for the 0 key, the letter 1 stands for the 1 key and the letter B stands for the backspace key. What string is displayed in the editor now?
-----Constraints-----
- 1 β¦ |s| β¦ 10 (|s| denotes the length of s)
- s consists of the letters 0, 1 and B.
- The correct answer is not an empty string.
-----Input-----
The input is given from Standard Input in the following format:
s
-----Output-----
Print the string displayed in the editor in the end.
-----Sample Input-----
01B0
-----Sample Output-----
00
Each time the key is pressed, the string in the editor will change as follows: 0, 01, 0, 00. | ["from collections import deque\n\nS = input()\n\nans = deque([])\n\nfor s in S:\n if s==\"B\":\n if ans:\n ans.pop()\n else:\n ans.append(s)\n \nprint(\"\".join(ans))", "a = list(input())\n\nb = []\n\nfor i in range(int(len(a))):\n\tt = a[int(i)]\n\tif t == \"0\":\n\t\tb.append(\"0\")\n\telif t == \"1\":\n\t\tb.append(\"1\")\n\telse :\n\t\tif len(b) > 0:\n\t\t\tdel b[-1]\nprint(\"\".join(b))", "s = input()\nn = len(s)\n\nans = []\nfor i in range(n):\n if s[i] == \"0\":\n ans.append(\"0\")\n elif s[i] == \"1\":\n ans.append(\"1\")\n else:\n if ans:\n ans.pop()\n \nprint(\"\".join(ans))", "# S\u306e\u5165\u529b\u53d7\u4ed8\nS = input()\n# S\u3092\u9806\u306b\u8aad\u307f\u8fbc\u307fB\u304c\u3042\u3063\u305f\u3068\u304d\u76f4\u524d\u306e\u6587\u5b57\u3068\u4e00\u7dd2\u306b\u6d88\u53bb\nSTR = \"\"\nfor i in S:\n STR = STR + i\n if i == \"B\" and STR == \"\":\n STR = \"\"\n elif i == \"B\":\n STR = STR[:len(STR) - 2]\nprint(STR)\n", "s = input()\n\nans = ''\nfor i in range(len(s)):\n if s[i] == 'B':\n ans = ans[:-1]\n else:\n ans += s[i]\n\nprint(ans)", "S = input()\n\nstack = []\n\nfor s in S:\n if not stack and s!=\"B\":\n stack.append(s)\n elif s==\"B\":\n if stack:stack.pop()\n else:continue\n else:\n stack.append(s)\nprint(\"\".join(stack))", "binaryKeyboard = list(input())\nans = []\n\nfor i in binaryKeyboard:\n if i=='0' or i == '1':\n ans.append(i)\n else:\n if len(ans) == 0:\n continue\n else:\n del ans[-1]\nprint((''.join(ans)))\n", "x=input()\nz=''\n\nfor i in x:\n if i == '0':\n z= z+i\n elif i == '1':\n z= z+i\n elif i == 'B':\n z= z[:-1]\n\nprint(z) ", "buf=''\nfor c in input():\n if c=='B': buf=buf[:-1]\n else: buf += c\nprint(buf)", "buf = ''\nstr = input()\nfor i in range(len(str)):\n if str[i] == 'B':\n if len(buf) != 0:\n buf = buf[0:len(buf)-1]\n else:\n continue\n else:\n buf += str[i]\n\nprint(buf)", "s = input()\nx = []\nfor i in range(len(s)):\n if s[i] == \"0\":\n x.append(\"0\")\n elif s[i] == \"1\":\n x.append(\"1\")\n elif s[i] == \"B\" and len(x) > 0 :\n x.pop(-1)\nprint(\"\".join(x))", "s = input()\na = \"\"\nfor i in s:\n if i == \"0\":\n a+=\"0\"\n elif i == \"1\":\n a+=\"1\"\n else:\n if a!=\"\":\n a=a[:-1]\n \nprint(a)", "s = input()\nans = []\nfor i in range(len(s)):\n if s[i] == 'B':\n if ans:\n ans.pop()\n else:\n ans.append(s[i])\nprint((''.join(ans)))\n\n", "s = input()\n\nans = \"\"\nfor c in s:\n if c == '0':\n ans += c\n elif c == '1':\n ans += c\n else: # c == 'B'\n if ans != \"\":\n ans = ans[:-1]\n\nprint(ans)", "s=input()\noutput=''\nfor i in s:\n if i!='B':\n output+=i\n elif i=='B':\n output=output[:-1]\nprint(output)\n", "a = list(input())\nans = []\nfor i in range(len(a)):\n if a[i] == '0':\n ans.append('0')\n elif a[i] == '1':\n ans.append('1')\n elif a[i] == 'B':\n if ans == []:\n continue\n else:\n ans.pop(-1)\nprint(''.join(ans))", "S = input()\n\nF = []\nfor ch in S:\n if ch == \"B\": \n if len(F) > 0:\n F.pop()\n else:\n F.append(ch)\n \nprint(\"\".join(F))", "s = list(input())\nw_len = len(s)\nword = []\nfor x in range(w_len):\n if s[x] == 'B':\n if word != []:\n word.pop(-1)\n else:\n word.append(s[x])\nresult = ''\nfor y in word:\n result = result+y\nprint(result)", "s = input()\na = \"\"\nfor i in range(len(s)):\n if s[i] == \"B\":\n a = a[:-1]\n else:\n a += s[i]\nprint(a)", "a = list(input())\n\nb = []\n\nfor i in range(int(len(a))):\n\tt = a[int(i)]\n\tif t == \"0\":\n\t\tb.append(\"0\")\n\telif t == \"1\":\n\t\tb.append(\"1\")\n\telse :\n\t\tif len(b) > 0:\n\t\t\tdel b[-1]\nprint(\"\".join(b))", "import math\nfrom math import gcd,pi,sqrt\nINF = float(\"inf\")\nMOD = 10**9 + 7\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nimport bisect\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return map(int, input().split())\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\n\n\ndef main():\n S = input()\n ans = \"\"\n for i in S:\n if i != \"\" and i == \"B\":\n ans = ans[:-1]\n if i != \"B\":\n ans = ans + i\n print(ans)\n \n\ndef __starting_point():\n main()\n__starting_point()", "s = str(input())\na = []\n \nfor i in range(len(s)):\n if s[i] == '0':\n a.append('0')\n elif s[i] == '1':\n a.append('1')\n else:\n if len(a) != 0:\n a.pop()\n \nprint(''.join(a))", "s = list(input())\nli = []\nfor i in s:\n if i == '0':\n li.append('0')\n elif i == '1':\n li.append('1')\n elif i == 'B':\n if li == []:\n pass\n else:\n li.pop(-1)\nprint(''.join(li))", "binaryKeyboard=list(input())\nans=[]\nfor i in binaryKeyboard:\n if i==\"0\" or i==\"1\":\n ans.append(i)\n else:\n if len(ans)==0:\n continue\n else:\n del ans[-1]\nprint(''.join(ans))", "S=list(input())\n\nans=[]\n\nfor s in S:\n if s == \"B\":\n if len(ans)>0:\n del ans[-1]\n else:\n ans.append(s)\n \nprint(\"\".join(ans))", "s = str(input())\na = []\n\nfor i in range(len(s)):\n if s[i] == '0':\n a.append('0')\n elif s[i] == '1':\n a.append('1')\n else:\n if len(a) != 0:\n a.pop()\n\nprint(''.join(a))", "n=[]\nfor i in input():\n if i=='B':\n if n: n.pop()\n else:\n n.append(i)\nprint(*n,sep='')", "S = input()\nans = \"\"\nfor s in S:\n if s == \"B\":\n if ans:\n ans = ans[:-1]\n else:\n ans += s\nprint(ans)\n", "s=list(input())\nans=list()\nfor i in s:\n if i==\"0\":\n ans.append(0)\n elif i==\"1\":\n ans.append(1)\n else:\n try:\n ans.pop(-1)\n except:\n pass\nfor i in ans:\n print(i,end=\"\")\nprint()", "s=input()\na=''\n\nfor i in s:\n if i=='B':\n a=a[:-1]\n \n else:\n a+=i\nprint(a)\n", "def handle_string(string):\n new_string = ''\n for i in range(len(string)):\n if string[i]=='B':\n if len(new_string)!=0:\n new_string = new_string[0:len(new_string)-1]\n else:\n continue\n else:\n new_string = new_string+string[i]\n return new_string\ninput_string = input()\nprint(handle_string(input_string))", "n = input()\na = \"\"\nfor i in n:\n if i ==\"0\":\n a+=i\n elif i ==\"1\":\n a+=i\n elif i ==\"B\":\n a = a[:-1]\nprint(a)", "s = list(input())\nx = len(s)\na = []\n\nfor i in range(x):\n if s[i] == '0':\n a.append('0')\n elif s[i] == '1':\n a.append('1')\n elif s[i] == 'B':\n if a == []:\n continue\n else:\n a.pop(-1)\nb = ''.join(a)\nprint(b)", "s=input()\ndata=[]\nfor i in range(len(s)):\n if s[i]=='0':\n data.append('0')\n elif s[i]=='1':\n data.append('1')\n else:\n if len(data)==0:\n continue\n else:\n data.pop()\nprint(*data,sep='')", "n = \"\"\ncommand = input()\nfor i in command:\n if i == \"B\":\n n=n[:-1]\n else:\n n+=i\nprint(n)", "#!/usr/bin/env python3\n\nS = input()\nret = ''\nfor i in range(len(S)):\n if S[i] == '0': ret += '0'\n elif S[i] == '1': ret += '1'\n else: ret = ret[:-1]\n\nprint(ret)\n", "s=input()\nans=''\nfor c in s:\n if c=='0':\n ans+='0'\n elif c=='1':\n ans+='1'\n else:\n ans=ans[:len(ans)-1]\nprint(ans)", "s = str(input())\nans = \"\"\nfor i in range(len(s)):\n if(s[i]!=\"B\"):\n ans += s[i]\n else:\n if(ans != \"\"):\n ans = ans[:-1]\nprint(ans)\n\n", "#!/usr/bin/env python3\ns = input()\nlen_s = len(s)\n\ntext = ''\nfor i in range(len_s):\n if s[i] == '0':\n text += '0'\n elif s[i] == '1':\n text += '1'\n else:\n if text == '':\n pass\n else:\n text = text[:-1]\nprint(text)\n", "key = list(input())\nans = []\n\nfor i in key:\n if i == '0' or i == '1':\n ans.append(i)\n elif len(ans) == 0:\n continue\n else:\n del ans[-1]\n\nprint(''.join(ans))", "s=input()\nans=''\nfor i in s:\n if i!='B':\n ans+=i\n else:\n ans=ans[:-1]\nprint(ans)", "s = input()\nans = ''\nfor i in range(len(s)):\n if s[i] == '0':\n ans += '0'\n \n elif s[i] == '1':\n ans += '1'\n \n else:\n if ans != '':\n ans = ans[:-1]\n \nprint(ans)", "from collections import deque\n\n\ndef main():\n ss = list(input())\n ans = deque([])\n for s in ss:\n if s == '0':\n ans.append(s)\n elif s == '1':\n ans.append(s)\n else:\n if len(ans) == 0:\n pass\n else:\n ans.pop()\n print(*list(ans), sep='')\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\n\nout =''\nfor x in s:\n if x != 'B':\n out += x\n else:\n if out == '':\n continue\n else:\n out = out[:-1]\nprint(out)", "from sys import stdin\ninput = stdin.readline\n\nS = input().strip()\nP = ''\nfor s in S:\n if s == 'B':\n if P != '':\n P = P[:-1]\n else:\n P = P + s\nprint(P)", "first_str =input()\n\ninput_list = list(first_str)\n\ntotal_list = list()\n\nfor i in input_list:\n if i == \"0\":\n total_list.append(\"0\")\n \n elif i == \"1\":\n total_list.append(\"1\")\n \n else:\n if not total_list:\n pass\n else:\n total_list.pop(-1)\n \ntotal = \"\".join([str(_) for _ in total_list])\nprint(total)", "# -*- coding: utf-8 -*-\n\nS = list(input())\nans = []\n\nfor i in range(len(S)):\n if S[i] == 'B':\n if len(ans) == 0:\n continue\n else:\n ans.pop()\n else:\n ans.append(S[i])\n\nfor i in range(len(ans)):\n print(ans[i] , end = \"\")\n\nprint()\n\n", "import sys\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\n\ndef solve():\n s = ins()\n x = []\n for c in s:\n if c in \"01\":\n x.append(c)\n elif x:\n x.pop()\n return \"\".join(x)\n\n\nprint(solve())\n", "S = str(input())\n\nstack = []\n\nfor s in S:\n if s == '0' or s == '1':\n stack.append(s)\n elif s == 'B':\n if not stack:\n continue\n else:\n stack.pop()\n\nfor s in stack:print(s,end='')", "s = input()\nans = ''\n\nfor char in s:\n if char == '0':\n ans += '0'\n if char == '1':\n ans += '1'\n if char == 'B':\n ans = ans[:-1]\nprint(ans)", "S = input()\n\nans = ''\nfor s in S:\n if s == '0':\n ans+='0'\n elif s == '1':\n ans += '1'\n else:\n if len(ans)>0:\n ans = ans[:-1]\nprint(ans)\n", "s = input()\nans = ''\nfor c in s:\n if c == '0':\n ans += '0'\n elif c == '1':\n ans += '1'\n else:\n ans = ans[:len(ans) - 1]\nprint(ans)", "s = list(input())\nans = []\nfor i in range(len(s)) :\n if s[i] == \"0\" :\n ans.append(\"0\")\n elif s[i] == \"1\" :\n ans.append(\"1\")\n elif s[i] == \"B\" and len(ans) > 0 :\n del ans[-1]\nprint((\"\".join(ans)))\n", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(s: str):\n a = []\n for c in s:\n if c == \"B\":\n if a:\n a.pop()\n else:\n a.append(c)\n return \"\".join(a)\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n s = next(tokens) # type: str\n print((solve(s)))\n\ndef test():\n import doctest\n doctest.testmod()\n\ndef __starting_point():\n #test()\n main()\n\n__starting_point()", "s = [ss for ss in str(input())]\nans = []\nfor i in s:\n if i == \"0\" or i == \"1\":\n ans.append(i)\n elif len(ans) > 0:\n ans.pop(-1)\nprint(\"\".join(ans))", "def main():\n s = str(input())\n\n ans = []\n for val in s :\n if val == \"B\" and ans == [] :\n pass\n elif val == \"B\" and ans != [] :\n ans.pop(-1)\n else :\n ans.append(val)\n\n ans_str = \"\"\n for val in ans :\n ans_str = ans_str + val\n\n print(ans_str)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\nl = []\nfor i in range(len(s)):\n if s[i] == '0':\n l.append('0')\n elif s[i] == '1':\n l.append('1')\n else:\n if l == []:\n continue\n else:\n del l[-1]\nprint((''.join(l)))\n", "s = input()\nans = []\n\nfor i in s:\n if i=='B':\n if ans != []:\n ans.pop(-1)\n else:\n ans.append(i)\nprint(''.join(ans))", "n = input()\nstr = ''\nfor i in n:\n if i == '0' or i == '1':\n str = str + i\n if i == 'B':\n str = str[:-1]\n \nprint(str)", "s = input()\nans = []\nfor i in s:\n if i == \"0\":\n ans.append(0)\n elif i == \"1\":\n ans.append(1)\n else:\n if len(ans) != 0:\n ans.pop(-1)\nprint(*ans,sep=\"\")", "s = input()\n\nans=\"\"\n\nfor i in range(len(s)):\n if s[i]==\"B\":\n ans = ans[:-1]\n else:\n ans+=s[i]\nprint(ans)", "from collections import deque\nd = deque()\nfor c in input():\n if c != 'B': d.append(c) \n elif len(d) != 0: d.pop()\nprint(*d, sep='')", "s = input()\nans = ''\nfor i in range(len(s)):\n\tif s[i] == '0':\n\t\tans += '0' \n\telif s[i] == '1':\n\t\tans += '1' \n\telse:\n\t\tif ans != '':\n\t\t\tans = ans[:-1] \nprint(ans)", "# cook your dish here\ns = str(input())\na = \"\"\nfor i in s:\n if i!='B':\n a = a + i\n else:\n if len(a)!=0:\n a = a[0:len(a)-1]\nprint(a)", "s = input()\na = []\nfor c in s:\n if c in ['0', '1']:\n a.append(c)\n else:\n if len(a) != 0:\n a.pop()\nprint(''.join(a))", "s = input()\nnumB = 0\nr = \"\"\nfor i in range(len(s))[::-1]:\n if s[i] == \"B\":\n numB = numB+1\n continue\n if numB > 0 and (s[i]==\"0\" or s[i]==\"1\"):\n numB = numB-1\n continue\n r = r + s[i]\n\nprint((''.join(list(reversed(r)))))\n\n", "s = input()\n\nstack = []\n\nfor c in s:\n if c == \"B\":\n if len(stack) == 0:\n continue\n else:\n stack.pop(-1)\n else:\n stack.extend(c)\nfor c in stack:\n print(c, end=\"\")\n", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tB\n# CreatedDate: 2020-10-03 20:05:16 +0900\n# LastModified: 2020-10-03 20:28:14 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\n\n\ndef main():\n S = input()\n stack = []\n for s in S:\n if s == '0' or s == '1':\n stack.append(s)\n elif s == 'B' and stack:\n stack.pop()\n for sta in stack:\n print(sta, end=\"\")\n print()\n\n\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s=input()\nres=\"\"\nfor i in s:\n if i!=\"B\":\n res+=i\n else:\n res=res[:len(res)-1]\nprint(res)", "s = input()\nlis = []\nfor c in s:\n if c == 'B':\n if len(lis):\n lis = lis[:-1]\n else:\n continue\n else:\n lis.append(int(c))\n\nfor i in lis:\n print(i, end=\"\")\nprint()", "i = input()\nans = \"\"\nfor s in i:\n if s != \"B\":\n ans += s\n else:\n ans = ans[:-1]\n \nprint(ans)", "import math\nfrom datetime import date\n\ndef main():\n\t\t\n\ts = input()\n\tans = []\n\n\tfor c in s:\n\t\tif c != 'B':\n\t\t\tans.append(c)\n\t\telse:\n\t\t\tif len(ans) != 0:\n\t\t\t\tans.pop();\n\n\tline = \"\"\n\tfor c in ans:\n\t\tline += c\n\n\tprint(line)\n\t\nmain()\n", "#!/usr/bin/env python3\ns=input()\nans=[]\nfor i in s:\n if i=='0' or i=='1':\n ans.append(i)\n else:\n if len(ans):\n ans.pop()\nprint(''.join(ans))", "s=input()\nfin=\"\"\nfor c in s:\n if c=='1':\n fin+=\"1\"\n elif c=='0':\n fin+=\"0\"\n else:\n if len(fin)>0:\n fin=fin[:-1]\nprint(fin)\n", "a = input()\ntest = ''\nfor i in range(len(a)):\n if a[i] == '0':\n test += '0'\n elif a[i] == '1':\n test += '1'\n else:\n if len(a) == 0:\n pass\n else:\n test = test[:-1]\n \nprint(test)", "S = str(input())\n\nans = []\nfor i in range(len(S)):\n if S[i] == \"B\":\n if ans == []:\n continue\n else:\n ans = ans[:-1]\n else:\n ans.append(S[i])\n #print(ans)\n#print(ans) \n\nfor i in range(len(ans)):\n print(ans[i], end = \"\")", "s = str(input())\nans = []\nfor i in range(len(s)):\n if s[i] == \"B\":\n if len(ans) != 0: ans.pop()\n else : ans.append(s[i])\nprint(''.join(ans))", "s = input()\nS = \"\"\nfor i in s:\n if i == \"B\":\n S = S[:-1]\n else:\n S += i\nprint(S)", "s = input()\nans = \"\"\nfor i in s:\n if i == 'B':\n if ans != \"\":\n ans = ans[:-1]\n else:\n ans += i\nprint(ans)", "s=input()\nans=\"\"\nfor c in s:\n if c=='B':\n if ans:\n ans=ans[0:-1]\n else:\n ans+=c\nprint(ans)", "s = input()\nans = \"\"\nfor char in s:\n if char == 'B':\n if ans == \"\":\n pass\n else:\n l = len(ans)\n ans = ans[0:l-1]\n else:\n ans += char\nprint(ans)\n", "import sys\nimport math\nimport itertools\nimport collections\nimport heapq\nimport re\nimport numpy as np\nfrom functools import reduce\n\nrr = lambda: sys.stdin.readline().rstrip()\nrs = lambda: sys.stdin.readline().split()\nri = lambda: int(sys.stdin.readline())\nrm = lambda: list(map(int, sys.stdin.readline().split()))\nrl = lambda: list(map(int, sys.stdin.readline().split()))\ninf = float('inf')\nmod = 10**9 + 7\n\ns = rr()\nans = ''\nfor i in s:\n if i == '0':\n ans += '0'\n elif i == '1':\n ans += '1'\n elif ans:\n ans = ans[:-1]\nprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n", "# https://atcoder.jp/contests/abc043/tasks/abc043_b\n\n\"\"\"\n\u53cc\u65b9\u5411\u30ad\u30e5\u30fc\u3092\u3064\u304b\u3063\u3066\u5b9f\u88c5\u3059\u308b\n\n\u3053\u306e\u3069\u308c\u304b\u306e\u64cd\u4f5c\u304c\u3067\u304d\u308b\n* 0 \u3092\u30ad\u30e5\u30fc\u306b\u5165\u308c\u308b\n* 1 \u3092\u30ad\u30e5\u30fc\u306b\u5165\u308c\u308b\n* \u30ad\u30e5\u30fc\u306e\u6700\u5f8c\u306e\u3082\u306e\u3092\u51fa\u3059\n\n\u6ce8\u610f: \u30ad\u30e5\u30fc\u304c\u7a7a\u306e\u5834\u5408\u306b\u30d0\u30c3\u30af\u30b9\u30da\u30fc\u30b9\u3092\u3057\u3066\u3082\u4f55\u3082\u8d77\u304d\u306a\u3044\u3088\u3046\u306b\u3059\u308b\n\"\"\"\n\nfrom collections import deque\n\nq = deque()\n\ns = input()\nfor operation in s:\n if operation == \"0\":\n # \u53f3\u7aef\u306b0\u3092\u8ffd\u52a0\n q.append(\"0\")\n\n elif operation == \"1\":\n # \u53f3\u7aef\u306b1\u3092\u8ffd\u52a0\n q.append(\"1\")\n\n elif operation == \"B\":\n # \u30d0\u30c3\u30af\u30b9\u30da\u30fc\u30b9\n # \u53f3\u7aef\u3092\u4e00\u3064\u524a\u9664\n # q \u306e\u4e2d\u8eab\u304c\u7a7a\u3067\u3082\u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u3044\u3088\u3046\u306b\u4f8b\u5916\u51e6\u7406\n try:\n q.pop()\n except IndexError:\n pass # \u4f55\u3082\u3057\u306a\u3044\n\n# \u30ad\u30e5\u30fc\u306e\u4e2d\u8eab\u3092\u9806\u756a\u306b\u53d6\u308a\u51fa\u3057\u3066\u6587\u5b57\u5217\u306b\u5909\u63db\nanswer = \"\"\nfor i in q:\n answer = answer + i\n\nprint(answer)\n", "s=str(input())\n\nl=[]\nfor i in s:\n if i==\"0\" or i==\"1\":\n l.append(i)\n elif i==\"B\" and len(l)!=0:\n l.pop(len(l)-1)\n \nprint(*l,sep='')\n ", "import math\nimport collections\nii = lambda : int(input())\nmi = lambda : map(int,input().split())\nli = lambda : list(map(int,input().split()))\n\ns = input()\n\nans = ''\nfor i in range(len(s)):\n if s[i] == 'B':\n if len(ans) == 0: continue\n ans = ans[0:-1]\n else:\n ans += s[i]\nprint(ans)", "s = input()\nans = []\nfor i in range(len(s)):\n if s[i] == \"B\":\n if len(ans) != 0:\n ans.pop()\n else:\n ans.append(s[i])\nprint(\"\".join(ans))", "s = input()\nans = ''\n\nfor i in range(len(s)):\n if s[i] != 'B':\n ans += s[i]\n else:\n ans = ans[:-1]\n\nprint(ans)", "s = input()\nL = []\nfor x in s:\n if x == \"0\":\n L.append(\"0\")\n elif x == \"1\":\n L.append(\"1\")\n else:\n if len(L) >= 1:\n del L[-1]\nprint(\"\".join(L))", "def answer(s: str) -> str:\n result = ''\n for c in s:\n if c == 'B':\n result = result[:-1]\n else:\n result += c\n\n return result\n\ndef main():\n s = input()\n print((answer(s)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\nans = \"\"\nfor char in s:\n if char != 'B':\n ans += char\n else:\n if ans == \"\":\n pass\n else:\n le = len(ans)\n ans = ans[0:le - 1]\nprint(ans)\n", "s = input()\nans = \"\"\nfor i in s:\n if i == \"B\":\n ans = ans[:-1]\n else:\n ans += i\nprint(ans)", "s = input()\nst = []\nfor e in s:\n if e == 'B':\n if len(st) != 0:\n st.pop()\n else:\n st.append(int(e))\nprint((''.join(map(str,st))))\n", "s = list(input())\nres = []\nfor i in range(len(s)):\n if s[i] == \"1\":\n res.append(\"1\")\n elif s[i] == \"0\":\n res.append(\"0\")\n else:\n if res == []:\n continue\n else:\n del res[-1]\n\nprint(\"\".join(res))", "a = input()\nb = ''\nfor elem in a:\n if elem == '1':\n b +='1'\n elif elem == '0':\n b += '0'\n else:\n b = b[:-1]\nprint(b)", "s = input()\nans = ''\nfor c in s:\n if c == '0':\n ans += '0'\n elif c == '1':\n ans += '1'\n elif c == 'B' and ans:\n ans = ans[:-1]\nprint(ans)", "s = input()\nans = ''\n\nfor c in s:\n if c != 'B':\n ans += c\n else:\n ans = ans[:-1]\n\nprint(ans)", "s=input()\na=\"\"\nfor i in range(len(s)):\n if s[i]==\"0\":\n a+=\"0\"\n elif s[i]==\"1\":\n a+=\"1\"\n else:\n if a!=\"\":\n a=a[:-1]\nprint(a)", "s = input()\nans = \"\"\nfor _ in range(len(s)):\n if s[0] == \"0\":\n ans += \"0\"\n s = s[1:]\n elif s[0] == \"1\":\n ans += \"1\"\n s = s[1:]\n else:\n s = s[1:]\n ans = ans[:-1]\nprint(ans)", "\nopperations = list(input())\ndisplay_stack = []\nfor opperation in opperations:\n if opperation == \"B\":\n if display_stack:\n display_stack.pop()\n else:\n display_stack.append(opperation)\nprint(''.join(display_stack))", "s = input()\nres = \"\"\nfor i in range(len(s)):\n if s[i] == \"1\" or s[i] == \"0\":\n res += s[i]\n elif s[i] == \"B\" and len(res) != 0:\n res = res[:-1]\n\nprint(res)\n"] | {"inputs": ["01B0\n", "0BB1\n"], "outputs": ["00\n", "1\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 23,894 | |
2005e88cda0c51d60ce7586eac203502 | UNKNOWN | N persons are standing in a row. The height of the i-th person from the front is A_i.
We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:
Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.
Find the minimum total height of the stools needed to meet this goal.
-----Constraints-----
- 1 \leq N \leq 2\times 10^5
- 1 \leq A_i \leq 10^9
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
N
A_1 \ldots A_N
-----Output-----
Print the minimum total height of the stools needed to meet the goal.
-----Sample Input-----
5
2 1 5 4 3
-----Sample Output-----
4
If the persons stand on stools of heights 0, 1, 0, 1, and 2, respectively, their heights will be 2, 2, 5, 5, and 5, satisfying the condition.
We cannot meet the goal with a smaller total height of the stools. | ["N = int(input())\nA = list(map(int,input().split()))\nT = 0\nfor i in range(len(A)-1):\n if (A[i] > A[i + 1]):\n T += A[i] - A[i +1]\n A[i+1] = A[i] \nprint(T)", "n=int(input())\na=list(map(int, input().split()))\nans=0\nfor i in range(1,n):\n\tif a[i] < a[i-1]:\n\t\tans += a[i-1] - a[i]\n\t\ta[i] = a[i-1]\nprint(ans)", "n = int(input())\na = input().split()\na = [ int(i) for i in a ]\nnum = 0\nmaxa = a[0]\nfor i in range(1, len(a) ):\n if maxa < a[i]:\n maxa = a[i]\n elif maxa > a[i]:\n num += maxa - a[i]\n else:\n pass\nprint(num)\n \n \n \n\n", "a=int(input())\nlis=list(map(int,input().split()))\nans=0\nfor i in range(a-1):\n if lis[i]>lis[i+1]:\n j=lis[i]-lis[i+1]\n ans+=j\n lis[i+1]=lis[i]\nprint(ans)", "from typing import List\n\n\ndef answer(n: int, a: List[int]) -> int:\n height_sum = 0\n current_tallest = 0\n\n for i in a:\n if i < current_tallest:\n height_sum += current_tallest - i\n elif current_tallest < i:\n current_tallest = i\n\n return height_sum\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n print((answer(n, a)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int, input().split()))\ntmp = a[0]\nans = 0\nfor i in range(1,n):\n if tmp > a[i]:\n ans += tmp - a[i]\n else:\n tmp = a[i]\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\nA_sub = A[1:]\na_before = A[0]\ncount = 0\nfor a in A_sub:\n if a < a_before:\n count += a_before - a\n else:\n a_before = a\nprint(count)", "n = int(input())\na = list(map(int,input().split()))\ntall = 0\nans = 0\nfor an in a:\n if an < tall:\n ans += tall - an\n elif an > tall:\n tall = an\nprint(ans)", "s=int(input())\nx=list(map(int,input().split()))\nsum=0\nmaxi=x[0]\nfor i in x:\n maxi=max(maxi,i)\n sum+=(maxi-i)\nprint(sum)", "N = int(input())\nA = list(map(int, input().split()))\ncount = 0\n\nfor i in range(N-1):\n if A[i] > A[i+1]:\n count += A[i] - A[i+1]\n A[i+1] = A[i]\n \nprint(count)", "# -*- coding utf-8 -*-\n\nMOD = 10 ** 9 + 7\n\nN = int(input())\nAN = list(map(int, input().split()))\n\nans = 0\nm = AN[0]\nfor i in range(1, N):\n if m > AN[i]:\n ans += m - AN[i]\n m = max(m, AN[i])\n\nprint(ans)\n", "N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nfor i in range(1, len(A)):\n height = max(0, A[i-1] - A[i])\n A[i] += height\n ans += height\n\nprint(ans)\n", "N=int(input())\nA=list(map(int,input().split()))\nresult=0\nminimum=0\nfor a in A:\n if a>minimum:\n minimum=a\n elif a<minimum:\n result+=minimum-a\nprint(result)", "n = int(input())\na = list(map(int, input().split()))\nmax = a[0]\nans = 0\n\nfor i in range(1, n):\n if max < a[i]:\n max = a[i]\n\n if a[i] < max:\n ans += max - a[i]\n\nprint(ans)", "n = int(input())\na = [int(s) for s in input().split()]\nallsum = sum(a)\nfor i in range(1,n):\n if a[i] < a[i-1]:\n a[i] = a[i-1]\nprint(sum(a) - allsum)", "N = int(input())\nA = list(map(int,input().split()))\n\nmax_n = A[0]\nans = 0\nfor i in range(N):\n tmp = max_n - A[i]\n if tmp > 0:\n ans += tmp\n if max_n < A[i]:\n max_n = A[i]\nprint(ans)\n \n", "# -*- coding: utf-8 -*-\n\n\n# \u5165\u529b\u3092\u6574\u6570\u306b\u5909\u63db\u3057\u3066\u53d7\u3051\u53d6\u308b\ndef input_int():\n return int(input())\n\n\n# \u30de\u30a4\u30ca\u30b91\u3057\u305f\u5024\u3092\u8fd4\u5374\ndef int1(x):\n return int(x) - 1\n\n\n# \u534a\u89d2\u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u5165\u529b\u3092Int\u306b\u5909\u63db\u3057\u3066Map\u3067\u53d7\u3051\u53d6\u308b\ndef input_to_int_map():\n return list(map(int, input().split()))\n\n\n# \u534a\u89d2\u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u5165\u529b\u3092Int\u306b\u5909\u63db\u3057\u3066\u53d7\u3051\u53d6\u308b\ndef input_to_int_tuple():\n return tuple(map(int, input().split()))\n\n\n# \u534a\u89d2\u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u5165\u529b\u3092Int\u306b\u5909\u63db\u3057\u3066\u30de\u30a4\u30ca\u30b91\u3057\u305f\u5024\u3092\u53d7\u3051\u53d6\u308b\ndef input_to_int_tuple_minus1():\n return tuple(map(int1, input().split()))\n\n\ndef main():\n N = input_int()\n A = input_to_int_tuple()\n\n result = 0\n max_a = 0\n for a in A:\n if max_a > a:\n result += max_a - a\n max_a = max(a, max_a)\n\n return result\n\n\ndef __starting_point():\n print((main()))\n\n__starting_point()", "n = input()\nx = [int(i) for i in input().split()]\n\ntmp = x[0]\ntot = 0\n\n\nfor i in x:\n if i <= tmp:\n tot += tmp - i\n else:\n tmp = i\n\n\nprint(f\"{tot}\")", "def c176(n, alist):\n\n ans = 0\n tmp = alist[0]\n\n for i in alist:\n if tmp <= i:\n tmp = i\n continue\n ans += tmp - i\n\n return ans\n\ndef main():\n n = int(input())\n alist = list(map(int, input().split()))\n print(c176(n, alist))\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\na = list(map(int, input().split()))\n\nmax_height = -1\ns = 0\n\nfor i in a:\n max_height = max(max_height, i)\n d = max_height - i\n s += d\n\nprint(s)", "N = int(input())\nA = list(map(int, input().split()))\nans = 0\nfor i in range(1, N):\n if A[i - 1] > A[i]:\n ans += A[i - 1] - A[i]\n A[i] = A[i - 1]\nprint(ans)", "_,A=open(0);m=x=0\nfor a in map(int,A.split()):x+=max(m-a,0);m=max(m,a)\nprint(x)", "n = int(input())\nA = list(map(int,input().split()))\nans = 0\nprev_h = 0\nfor i,h in enumerate(A):\n if i == 0:\n prev_h = h\n else:\n if h < prev_h:\n ans += prev_h - h\n else:\n prev_h = h\n\nprint (ans)\n", "n=int(input())\nA=list(map(int,input().split()))\nans=0\nfor i in range(n-1):\n ans+=max(0,A[i]-A[i+1])\n A[i+1]=max(A[i+1],A[i])\nprint(ans)", "n = int(input())\na = list(map(int,input().split()))\nm = 0\nans = 0\n\nfor i in range(n-1):\n if a[i] > m:\n m = a[i]\n if a[i+1] < m:\n ans += m-a[i+1]\n a[i+1] = m\n\nprint(ans)\n", "n = int(input())\n\na = list(map(int, input().split()))\n\nh = 0\nans = 0\n\nfor i in range(n):\n h = max(h, a[i])\n ans += h - a[i]\n\n\nprint(ans)\n", "n=int(input())\nA=list(map(int,input().split()))\nb=sum(A)\nfor i in range(n-1):\n\tif A[i+1]<A[i]:\n\t\tA[i+1]=A[i]\nprint(sum(A)-b)", "N = int(input())\nA = list(map(int,input().split()))\nstep = 0\nsum = 0\nfor i in range(N-1):\n step = A[i]-A[i+1]\n if(step >= 1):\n sum = sum + step\n A[i+1] = A[i]\n else:continue\nprint(sum)", "n = int(input())\nlst = list(map(int, input().split()))\ntall = lst[0]\nans = 0\nfor i in range(1, n):\n if tall > lst[i]:\n ans += tall - lst[i]\n else:\n tall = lst[i]\nprint(ans)\n", "n = int(input())\na = list(map(int, input().split()))\n\nans = 0\nh = 0\nfor x in a:\n\tans += max(0, h-x)\n\th = max(h, x)\n\nprint(ans)\n", "N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nmax_num = 0\n\nfor i in range(N):\n max_num = max(max_num, A[i])\n bi = max_num\n ans += bi - A[i]\n\nprint(ans)\n", "# -*- coding: utf-8 -*-\nn=int(input())\nalist=list(map(int,input().split()))\nans=0\nb=0\nc=0\nk=0\nfor i in range(n):\n b+=alist[i]\n c+=alist[0+k]\n if b<c:\n ans+=c-b\n b=c\n elif b>c:\n k=i\n c=b\nprint(ans)", "n=int(input())\ns=0\nx=list(map(int,input().split()))\nz=x[0]\nfor i in range(len(x)):\n if(z>x[i]):\n s+=z-x[i]\n else:\n z=x[i]\nprint(s)", "def solve(n, a):\n res, th = 0, 0\n for x in a:\n th = max(th, x)\n res += th - x\n return res\n\nn = int(input())\na = list(map(int, input().split()))\nprint(solve(n, a))", "import sys\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nsys.setrecursionlimit(20000000)\n\nMOD = 10 ** 9 + 7\nINF = float(\"inf\")\n\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n answer = 0\n last = A[0]\n for i in range(1, N):\n if A[i] >= last:\n last = A[i]\n else:\n answer += last - A[i]\n print(answer)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n=int(input())\na=list(map(int,input().split()))\ncnt=0\nfor i in range(n-1):\n if a[i+1]<a[i]:\n cnt += a[i]-a[i+1]\n a[i+1] += a[i]-a[i+1]\nprint(cnt)", "\n# 1\u884c\u76ee\u306e\u5165\u529b\u306f\u4f7f\u7528\u3057\u306a\u3044\ninput()\n# 2\u884c\u76ee\u306e\u5165\u529b\u306f\u6574\u6570\u306e\u914d\u5217\u3068\u3057\u3066\u53d6\u5f97\nA = list(map(int, input().split()))\n\n# \u6700\u5927\u306eAi\u3092\u8a2d\u5b9a\nmax_A = 0\n# output\nsum_A = 0\n\nfor Ai in A:\n max_A = max(Ai, max_A)\n if max_A > Ai:\n sum_A += max_A - Ai\n\nprint(sum_A)", "N = int(input())\nA = list(map(int, input().split()))\nmaxhigh = 0\nans = 0\nfor i in A:\n if maxhigh> i:\n ans += maxhigh - i\n else:\n maxhigh = i\nprint(ans)", "import sys\nfrom sys import stdin\ndef I():\n return stdin.readline().rstrip()\ndef MI():\n return map(int,stdin.readline().rstrip().split())\ndef LI():\n return list(map(int,stdin.readline().rstrip().split()))\n#main part\nn=int(I())\na=LI()\nans=0\nfor i in range(n-1):\n if a[i]>a[i+1]:\n ans+=a[i]-a[i+1]\n a[i+1]=a[i]\nprint(ans)", "n=int(input())\na=list(map(int,input().split()))\ns=0\nfor i in range(1,n):\n if a[i-1] > a[i]:\n s+=a[i-1]-a[i]\n a[i] = a[i-1]\n \nprint(s)\n", "n= int(input())\na = list(map(int,input().split()))\nli = [a[0]]\nfor i in range(n-1):\n if li[i] < a[i+1]:\n li.append(a[i+1])\n else:\n li.append(li[i])\n \nans = 0\nfor j in range(n):\n ans += li[j] - a[j]\n \nprint(ans)", "N = int(input())\nAn = list(map(int, input().split()))\nm = 0\nans = 0\nfor a in An:\n if a < m:\n ans += m - a\n else:\n m = a\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\nasum = sum(a)\nfor i in range(1, n):\n if a[i] < a[i - 1]:\n a[i] = a[i - 1]\nprint((sum(a)-asum))\n", "def main():\n N = int(input())\n a = list(map(int, input().split()))\n \n DP = [0] * N\n max_i = 0\n \n for i in range(1, N):\n if a[max_i] > a[i]:\n DP[i] += (a[max_i]-a[i])\n elif a[max_i] < a[i]:\n max_i = i\n \n \n print(sum(DP))\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\nnums = [int(i) for i in input().split()]\n\nbefore = 0\nans = 0\nfor i in range(N):\n if i == 0:\n before =nums[i]\n continue\n if before > nums[i]:\n ans +=before - nums[i]\n else:\n before = nums[i]\n\nprint(ans)\n", "N = int(input())\nA = list(map(int, input().split()))\nh = 0\nfor i in range(N-1):\n if A[i+1] >= A[i]:\n continue\n else:\n tmp = A[i] - A[i+1]\n A[i+1] += tmp\n h += tmp\nprint(h)\n", "n = int(input())\na = list(map(int,input().split()))\nans = 0\nfor i in range(len(a) - 1):\n if a[i+1] < a[i]:\n ans += a[i] - a[i+1]\n a[i+1] = a[i]\nprint(ans)\n\n", "n = int(input())\na = list(map(int, input().split()))\n\nheight = 0\nfor i in range(n - 1):\n if a[i] > a[i + 1]:\n height += a[i] - a[i + 1]\n a[i + 1] = a[i]\nprint(height)", "n=int(input())\nx=list(map(int,input().split()))\nc=0\ntot=0\nfor i in range(n-1):\n if x[i]>x[i+1]:\n c=x[i]-x[i+1]\n tot=tot+c\n x[i+1]=x[i+1]+c\nprint(tot)\n", "N = int(input())\nA = list(map(int,input().split()))\ncount = 0\nmh = A[0]\nfor i in range(1,len(A)):\n if mh > A[i]:\n count += mh-A[i]\n else:\n mh = A[i]\nprint(count)", "n = int(input())\na = list(map(int,input().split()))\nans = 0\nif a == sorted(a):\n print(ans)\n return\nb = a.index(max(a))\nfor i in range(0,b):\n if a[i] > a[i+1]:\n ans = ans + a[i]-a[i+1]\n a[i+1] = a[i]\nans = ans + max(a)*len(a[b+1:])-sum(a[b+1:])\nprint(ans)", "N=int(input())\nA=list(map(int,input().split()))\na=0\ns=[]\nfor i in A:\n if i<a:\n s.append(a-i)\n \n else:\n a=i\nprint((sum(s)))\n", "import sys\n\nN = int(input())\nA = list(map(int, input().split()))\n\nm = A[0]\ncount = 0\nfor a in A:\n if m > a:\n count += m-a\n else:\n m = a\nprint(count)\n", "n = int(input())\nA = list(map(int, input().split()))\n\nans = 0\n\nfor i in range(n-1):\n if A[i+1] >= A[i]:\n pass\n elif A[i+1] < A[i]:\n ans += A[i] - A[i+1]\n A[i+1] += A[i] - A[i+1]\n\nprint(ans)", "n = int(input())\naaa = list(map(int, input().split()))\nans = 0\nfor i in range(1, n):\n diff = aaa[i] - aaa[i - 1]\n if diff < 0:\n aaa[i] -= diff\n ans -= diff\nprint(ans)", "N=int(input())\nA=list(map(int,input().split()))\ncount=0\nfor i in range(1,N):\n if A[i-1]>A[i]:\n count+=A[i-1]-A[i]\n A[i]=A[i-1]\nprint(count)", "N = int(input())\nA_list = list(map(int, input().split()))\n\nA_max = A_list[0]\nans = 0\n\nfor i in(A_list):\n if i > A_max:\n A_max = i\n elif i < A_max:\n ans += A_max - i\n\nprint(ans)", "#abc176c\nn=int(input())\na=list(map(int,input().split()))\nres=0\nfor i in range(1,n):\n d=max(a[i-1]-a[i],0)\n res+=d\n a[i]+=d\nprint(res)\n", "N = int(input())\nA = list(map(int, input().split()))\nans = 0\nfor i in range(N-1):\n if A[i+1]<A[i]:\n ans += A[i]-A[i+1]\n A[i+1] += A[i]-A[i+1]\n\nprint(ans)\n", "n = int(input())\na = list(map(int, input().split(\" \")))\na_max = 0\nstep = 0\n\nfor i in range(n):\n if a_max < a[i]:\n a_max = a[i]\n a_num = i\n else:\n step += a_max - a[i]\n\nprint(step)", "n = int(input())\nl = list(map(int,input().split()))\nal = []\n \nfor i in range(0,n-1):\n if(l[i]<=l[i+1]):\n al.append(0)\n else:\n al.append(l[i]-l[i+1])\n l[i+1] = l[i]\n\nprint(sum(al))", "N = int(input())\nh = list(map(int, input().split()))\nstep=0\nsteps=0\nfor i in range(N-1):\n if h[i+1] < h[i]+step:\n step=h[i]-h[i+1] +step\n steps+=step\n else:\n step=0\nprint(steps)", "N = int(input())\nA = list(map(int, input().split()))\ntot = 0\nfor i, a in enumerate(A):\n if i == 0:\n forward = a\n continue\n if forward >= a:\n tot += forward - a\n else:\n forward = a\nprint(tot)", "N = int(input())\nnum_list = list(map(int, input().split()))\n\nANS = 0\ntall = 0\npre = 0\n\nfor i in range(N):\n if tall > num_list[i]:\n pre = (tall - num_list[i])\n ANS += pre\n tall = num_list[i] + pre\n else:\n tall = num_list[i]\n\nprint(ANS)\n", "n = int(input())\na = list(map(int, input().split()))\nans = 0\nh = a[0]\nfor i in range(n):\n ans += max(a[i],h) - a[i]\n h = max(a[i],h)\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\n\ncnt = 0\n\nfor i in range(N-1):\n if A[i+1] >= A[i]:\n pass\n else:\n cnt += A[i] - A[i+1]\n A[i+1] = A[i]\n\nprint(cnt)", "n = int(input())\na = [int(i) for i in input().split()]\nmx = a[0]\nans = 0\nfor i in a:\n if mx > i:\n ans += mx - i\n elif mx < i:\n mx = i\nprint(ans)\n", "def main():\n N = int(input())\n A = list(map(int, input().split()))\n\n dp = [0] * N\n for i in range(1, N):\n h = A[i - 1] - A[i]\n if h > 0:\n A[i] += h\n dp[i] = dp[i-1] + h\n else:\n dp[i] = dp[i-1]\n\n print((dp[-1]))\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int,input().split()))\nans = 0\nif a == sorted(a):\n print(ans)\n return\nfor i in range(n-1):\n if a[i] > a[i+1]:\n ans = ans + a[i]-a[i+1]\n a[i+1] = a[i] \nprint(ans)", "from sys import stdin\nN = int(stdin.readline().rstrip())\nA = [int(_) for _ in stdin.readline().rstrip().split()]\nans, tmp_max = 0, 0\nfor a in A:\n if a > tmp_max:\n tmp_max = a\n else:\n ans += (tmp_max - a)\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\n\ncount = 0\nmax_value = A[0]\nfor i in range(N-1):\n #pdb.set_trace()\n if(max_value > A[i+1]):\n count += max_value-A[i+1]\n if (max_value < A[i+1]):\n max_value = A[i+1]\nprint(count)", "n = int(input())\na = list(map(int,input().split()))\n\nsum = 0\nmax = a[0]\n\nfor i in range(n):\n\tif(max > a[i]):\n\t\tsum += (max - a[i])\n\telse:\n\t\tmax = a[i]\nprint(sum)", "N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\n\nfor i in range(N-1):\n if A[i+1] <= A[i]:\n ans += A[i] - A[i+1]\n A[i+1] = A[i]\n else:\n pass\n\nprint(ans)\n", "import sys\nfrom collections import deque, defaultdict, Counter\nfrom itertools import accumulate, product, permutations, combinations\nfrom operator import itemgetter\nfrom bisect import bisect_left, bisect_right\nfrom heapq import heappop, heappush\nfrom math import ceil, floor, sqrt, gcd, inf\nfrom copy import deepcopy\nimport numpy as np\nimport scipy as sp\n\nINF = inf\nMOD = 1000000007\n\nn = int(input())\nA = [int(i) for i in input().split()]\n\ntmp = 0\nres = 0\n\nfor i in range(n):\n if tmp < A[i]:\n tmp = A[i]\n else:\n res += tmp - A[i]\n\nprint(res)\n", "n = int(input())\na = list(map(int,input().split()))\nans = 0\nfor i in range(1,n):\n d = max(a[i-1]-a[i],0)\n ans += d\n a[i] += d\nprint(ans)\n", "import sys\ndef rs(): return sys.stdin.readline().rstrip()\ndef ri(): return int(rs())\ndef rs_(): return [_ for _ in rs().split()]\ndef ri_(): return [int(_) for _ in rs().split()]\n\nN = ri()\nA = ri_()\nans = 0\ntmp = A[0]\nfor i in range(1, N):\n if tmp > A[i]:\n ans += tmp - A[i]\n else:\n tmp = A[i]\nprint(ans)", "\"\"\"\n1 2 3 4 5 6 ..... N(\u4eba)\n i = \u8eab\u9577:Ai(cm)\n\nif A[i] > A[i+1]:\n A[i] == A[i+1] + \u8e0f\u307f\u53f0\n\"\"\"\ndef step():\n # \u5165\u529b\n N = int(input())\n A = list(map(int, input().split()))\n # \u51e6\u7406\n step_height_sum = 0\n for i in range(len(A)-1):\n if A[i] > A[i+1]:\n step_height_sum += A[i]-A[i+1]\n A[i+1] = A[i]\n return step_height_sum\n \nresult = step()\nprint(result)", "n = int(input())\na = list(map(int,input().split()))\nans = 0\nx = a[0]\nfor i in range(n):\n x = max(x,a[i])\n if a[i]<x:\n ans+=x-a[i]\nprint(ans)", "n=int(input())\nlst=list(map(int,input().split()))\n\nnow=lst[0]\nsm=0\n\nfor i in range(1,n):\n if lst[i]>=now :\n now=lst[i]\n continue\n sm+=now-lst[i]\n\nprint(sm)", "n = int(input())\n\npeople = list(map(int, input().split()))\n\ncount = 0\n\nfor i in range(n):\n if i == 0 or people[i-1] <= people[i]:\n continue\n else:\n count += people[i-1] - people[i]\n people[i] += people[i-1] - people[i]\nprint(count)", "n=int(input())\na=list(map(int, input().split()))\nans=0\nfor i in range(n-1):\n if a[i]>a[i+1]:\n ans+=a[i]-a[i+1]\n a[i+1]=a[i]\nprint(ans)", "\nN = int(input())\nA = input()\n\nAa = A.split()\n\ni = 0\n\ntotal = 0\n\nfor i in range(N-1):\n left = int(Aa[i])\n right = int(Aa[i+1])\n\n diff = 0\n\n if left>right:\n diff = abs(right-left)\n total = total + diff\n Aa[i+1] = right + diff\n else:\n total = total + 0\n \n\nprint(total)\n", "n = int(input())\na = list(map(int,input().split()))\nans = 0\nfor i in range(1,n):\n if a[i] < a[i-1]:\n ans += a[i-1]-a[i]\n a[i] += a[i-1]-a[i]\nprint(ans)", "\ndef main(A):\n ans = 0\n max_num = A[0]\n for a in A:\n max_num = max(max_num, a)\n ans += max_num - a\n\n return ans\n\ndef __starting_point():\n N = int(input())\n A = list(map(int, input().split()))\n ans = main(A)\n print(ans)\n\n\n__starting_point()", "N = int(input())\nAs = list(map(int, input().split()))\n\nans_step_sum = 0\ncurrent_max_height = As[0]\n\nfor Ai in As[1:]:\n diff = current_max_height - Ai\n if diff > 0: ans_step_sum += diff\n else: current_max_height = Ai\nprint(ans_step_sum)", "n=int(input())\nx=list(map(int,input().split()))\n\na=x[0]\nc=[]\n\nfor i in range(1,n):\n if x[i]<a:\n c.append(a-x[i])\n if x[i]>a:\n a=x[i]\nprint(sum(c))", "n =int(input())\nl = list(map(int, input().split()))\nans=0\nfor i in range(1,n):\n if l[i-1] > l[i]:\n ans +=l[i-1] - l[i]\n l[i] =l[i-1]\nprint(ans)", "n = int(input())\na = [int(i) for i in input().split()]\n\nans = 0\nmax_a = a[0]\n\nfor i in range(1, n):\n if max_a > a[i]:\n ans += max_a - a[i]\n elif max_a == a[i]:\n pass\n else:\n max_a = a[i]\nprint(ans)", "# coding: utf-8\n# Your code here!\n\nclass Person:\n def __init__(self, num, height):\n self.num = num\n self.height = height\n \n @staticmethod\n def static():\n print(\"static\")\n\n\ndef main():\n number = int(input())\n person_list = list(map(int, input().split()))\n \n ans = 0\n for num, person in enumerate(person_list):\n if num > 0:\n if person < person_list[num-1]:\n person_list[num] = person_list[num-1]\n ans += person_list[num-1] - person\n \n \n print(ans)\n\ndef __starting_point():\n main()\n \n\n__starting_point()", "N = int(input())\nA_l = map(int, input().split())\nM = 0\nB = 0\nfor i in A_l:\n if i >= M:\n B += 0\n M = i\n else:\n B += M-i\nprint(B)", "N = int(input())\nAs = list(map(int, input().split()))\ntlest, total = As[0], 0\nfor i in range(1, N):\n\ttlest = max(tlest, As[i])\n\tif tlest - As[i]:\n\t\ttotal += tlest - As[i]\nprint(total)\n", "n=int(input())\na=list(map(int,input().split()))\nres=0\nans=-1\nfor i in range(n):\n if(a[i]>=ans):\n ans=a[i]\n elif(a[i]<ans):\n res+=ans-a[i]\nprint(res)\n", "n=int(input())\na=list(map(int, input().split()))\nmax=a[0]\ndai=0\nfor i in range(n):\n #print(f\"{i}\u56de\u76ee\")\n if max>a[i]:\n dai+=max-a[i]\n \n else:\n max=a[i]\n #print(max,dai)\nprint(dai)", "def steps():\n biggerone=0\n ans=0\n list_a=[]\n cnt=int(input())\n a=input()\n list_a=[int(x) for x in a.split()]\n if len(list_a)!=cnt:\n print('Wrong input')\n\n if ans==0:\n ans=None\n\n steps()\n\n else:\n\n for i in range(0,len(list_a)-1):\n if i ==0:\n biggerone=list_a[i]\n\n if biggerone>list_a[i+1]:\n ans+=biggerone-list_a[i+1]\n else:\n biggerone=list_a[i+1]\n\n print(ans)\n\nsteps()\n", "n = int(input())\n\nheights=list(map(int, input().split()))\nhumidais=[]\n\nfor i in range(n):\n if i >= 1:\n if heights[i-1] > heights[i]:\n humidai = heights[i-1] - heights[i]\n humidais.append(humidai)\n heights[i] = heights[i] + humidai\n\nans = 0\nfor i in range(len(humidais)):\n ans += humidais[i]\n \nprint(ans)", "N = int(input())\nA = list(map(int,input().split()))\nmaximum = A[0]\nans = 0\n\nfor i in range(N):\n if maximum >= A[i]:\n ans += (maximum - A[i])\n else:\n maximum = max(maximum, A[i])\n\nprint(ans)", "import math\n\n\ndef cin():\n return list(map(int, input().split()))\n\n\nN = int(input())\ndata = cin()\ntotal = 0\n\n\nfor i in range(N - 1):\n if data[i + 1] < data[i]:\n total += data[i] - data[i + 1]\n data[i + 1] = data[i]\n\nprint(total)\n", "N = int(input())\nA = [int(d) for d in input().split()]\n\nS = []\nX = 0\nfor i in range(N):\n if X < A[i]:\n X = A[i]\n else:\n pass\n S.append( X - A[i] )\n\nprint(sum(S))", "N = int(input())\nA = list(map(int, input().split()))\n\nresult = 0\nfor i in range(1, N):\n if A[i] < A[i - 1]:\n result += A[i - 1] - A[i]\n A[i] = A[i - 1]\nprint(result)\n", "n = int(input())\narr = [int(x) for x in input().split()]\n\nheights = 0\nfor i in range(1,len(arr)):\n if arr[i-1] > arr[i]:\n heights += arr[i-1] - arr[i]\n arr[i] = arr[i-1]\n\nprint(heights)\n"] | {"inputs": ["5\n2 1 5 4 3\n", "5\n3 3 3 3 3\n"], "outputs": ["4\n", "0\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 24,220 | |
40e2d0d128a66e1c1e36994d5253e3d3 | UNKNOWN | Alice, Bob and Charlie are playing Card Game for Three, as below:
- At first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.
- The players take turns. Alice goes first.
- If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)
- If the current player's deck is empty, the game ends and the current player wins the game.
You are given the initial decks of the players.
More specifically, you are given three strings S_A, S_B and S_C. The i-th (1β¦iβ¦|S_A|) letter in S_A is the letter on the i-th card in Alice's initial deck. S_B and S_C describes Bob's and Charlie's initial decks in the same way.
Determine the winner of the game.
-----Constraints-----
- 1β¦|S_A|β¦100
- 1β¦|S_B|β¦100
- 1β¦|S_C|β¦100
- Each letter in S_A, S_B, S_C is a, b or c.
-----Input-----
The input is given from Standard Input in the following format:
S_A
S_B
S_C
-----Output-----
If Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.
-----Sample Input-----
aca
accc
ca
-----Sample Output-----
A
The game will progress as below:
- Alice discards the top card in her deck, a. Alice takes the next turn.
- Alice discards the top card in her deck, c. Charlie takes the next turn.
- Charlie discards the top card in his deck, c. Charlie takes the next turn.
- Charlie discards the top card in his deck, a. Alice takes the next turn.
- Alice discards the top card in her deck, a. Alice takes the next turn.
- Alice's deck is empty. The game ends and Alice wins the game. | ["A = input()\nB = input()\nC = input()\nturn = 'a'\nwhile True:\n if turn == 'a':\n if len(A) == 0:\n print('A')\n break\n turn = A[0]\n A = A[1:]\n elif turn == 'b':\n if len(B) == 0:\n print('B')\n break\n turn = B[0]\n B = B[1:]\n else:\n if len(C) == 0:\n print('C')\n break\n turn = C[0]\n C = C[1:]", "# ABC045\nfrom collections import deque\nS_A = deque(input())\nS_B = deque(input())\nS_C = deque(input())\n\n# \u6700\u521d\u306fA\u304b\u3089\nnext_turn = 'a'\n\nwhile True:\n # \u52dd\u5229\u5224\u5b9a\n if len(S_A) == 0 and next_turn == 'a':\n print(\"A\")\n return\n elif len(S_B) == 0 and next_turn == 'b':\n print(\"B\")\n return\n elif len(S_C) == 0 and next_turn == 'c':\n print(\"C\")\n return\n else:\n if next_turn == 'a':\n next_turn = S_A.popleft()\n elif next_turn == 'b':\n next_turn = S_B.popleft()\n elif next_turn == 'c':\n next_turn = S_C.popleft()\n", "sa = list(input())\nsb = list(input())\nsc = list(input())\nmode = \"a\"\nwhile True:\n if mode == \"a\":\n if len(sa) == 0:\n print(\"A\")\n return\n mode = sa.pop(0)\n elif mode == \"b\":\n if len(sb) == 0:\n print(\"B\")\n return\n mode = sb.pop(0)\n elif mode == \"c\":\n if len(sc) == 0:\n print(\"C\")\n return\n mode = sc.pop(0)\n", "from collections import deque\n\n\ndef discard(c: str, da: deque, db: deque, dc: deque) -> str:\n if eval(f'len(d{c})'):\n c = eval(f'd{c}.popleft()')\n else:\n return c.upper()\n\n return discard(c, da, db, dc)\n\n\ndef answer(sa: str, sb: str, sc: str) -> str:\n deque_a = deque(list(sa))\n deque_b = deque(list(sb))\n deque_c = deque(list(sc))\n return discard(deque_a.popleft(), deque_a, deque_b, deque_c)\n\n\ndef main():\n sa, sb, sc = [input() for _ in range(3)]\n print(answer(sa, sb, sc))\n\n\ndef __starting_point():\n main()\n__starting_point()", "a=input()\nb=input()\nc=input()\ni=a\nwhile True:\n if i[0]==\"a\":\n if a==\"\" or (i==a and len(a)==1):\n print(\"A\")\n break\n else:\n if i==a:\n a=a[1:]\n i=a\n elif i==b:\n b=b[1:]\n i=a\n else:\n c=c[1:]\n i=a\n elif i[0]==\"b\":\n if b==\"\" or (i==b and len(b)==1):\n print(\"B\")\n break\n else:\n if i==a:\n a=a[1:]\n i=b\n elif i==b:\n b=b[1:]\n i=b\n else:\n c=c[1:]\n i=b\n else:\n if c==\"\" or (i==c and len(c)==1):\n print(\"C\")\n break\n else:\n if i==a:\n a=a[1:]\n i=c\n elif i==b:\n b=b[1:]\n i=c\n else:\n c=c[1:]\n i=c", "from collections import deque \nA=deque(list(input()))\nB=deque(input())\nC=deque(list(input()))\nnow='a'\nwhile len(A)>=0 and len(B)>=0 and len(C)>=0:\n if now=='a':\n if A:\n now=A.popleft()\n else:\n print('A')\n return\n elif now=='b':\n if B:\n now=B.popleft()\n else:\n print('B')\n return\n else:\n if C:\n now=C.popleft()\n else:\n print('C')\n return", "S = {}\nfor i in 'ABC':\n S[i] = [w for w in input()]\nans = ''\njudge = True\nturn = S['A'].pop(0).upper()\nwhile judge:\n if S[turn] == []:\n ans = turn\n judge = False\n else:\n turn = S[turn].pop(0).upper()\nprint(ans)", "a, b, c = input(), input(), input()\n\nif len(a) == 1:\n print(\"A\")\n return\n\nnext = a[0]\na = a[1:]\n\nwhile True:\n try:\n if next == \"a\":\n next = a[0]\n a = a[1:]\n elif next == \"b\":\n next = b[0]\n b = b[1:]\n elif next == \"c\":\n next = c[0]\n c = c[1:]\n except:\n if next == \"a\":\n print(\"A\")\n elif next == \"b\":\n print(\"B\")\n else:\n print(\"C\")\n return\n", "a,b,c = [input() for i in range(3)]\nsa = 'a'\nfor i in range(1796):\n try:\n if sa == 'a':\n sa = a[0]\n a = a[1:]\n\n elif sa == 'b':\n sa = b[0]\n b = b[1:]\n\n elif sa == 'c':\n sa = c[0]\n c = c[1:]\n except:\n print(sa.upper())\n break", "S_s = [input() for _ in range(3)]\nturn = 0\npos = [0, 0, 0]\ndic = {\"a\":0, \"b\":1, \"c\":2}\nwhile 1:\n try:\n n_turn = dic[S_s[turn][pos[turn]]]\n pos[turn] += 1\n turn = n_turn\n except IndexError:\n break\nprint(\"ABC\"[turn])", "SA = input()\nSB = input()\nSC = input()\n\npointer = SA[0]\nSA = SA[1:]\nd = {'a': SA, 'b': SB, 'c': SC}\n\nwhile True:\n if d[pointer] == '':\n ans = pointer\n break\n tmp = d[pointer][0]\n d[pointer] = d[pointer][1:]\n pointer = tmp\n\nprint(ans.upper())", "A = input()\nB = input()\nC = input()\nn = A[0]\nA = A[1:]\nwhile True:\n if n == \"a\":\n if len(A) == 0:\n print(\"A\")\n break\n n = A[0]\n A = A[1:]\n\n elif n == \"b\":\n if len(B) == 0:\n print(\"B\") \n break\n n = B[0]\n B = B[1:]\n else:\n if len(C) == 0:\n print(\"C\")\n break\n n = C[0]\n C = C[1:]\n \n \n \n \n \n \n \n \n", "a=list(input())\nb=list(input())\nc=list(input())\nabc=[a,b,c]\nname=['a','b','c']\nnow=0\nwhile True:\n\tif len(abc[now])==0:\n\t\tprint((name[now].upper()))\n\t\treturn\n\tnow=name.index(abc[now].pop(0))\n\n", "SA = input()\nSB = input()\nSC = input()\nR = SA[0]\nSA = SA[1:]\nwhile not R == \"\":\n if R == \"a\":\n R = SA[:1]\n SA = SA[1:]\n E = \"A\"\n elif R == \"b\":\n R = SB[:1]\n SB = SB[1:]\n E = \"B\"\n else:\n R = SC[:1]\n SC = SC[1:]\n E = \"C\"\nprint(E)\n", "from collections import deque\ns1 = str(input())\ns2 = str(input())\ns3 = str(input())\na = []\nb = []\nc = []\nfor i in range(len(s1)):\n a.append(s1[i])\nfor i in range(len(s2)):\n b.append(s2[i])\nfor i in range(len(s3)):\n c.append(s3[i])\na = deque(a)\nb = deque(b)\nc = deque(c)\n\nx = a.popleft()\nwhile True:\n if x == 'a':\n if len(a) == 0:\n print('A')\n break\n x = a.popleft()\n elif x == 'b':\n if len(b) == 0:\n print('B')\n break\n x = b.popleft()\n else:\n if len(c) == 0:\n print('C')\n break\n x = c.popleft()\n\n\n", "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: list(map(int, INPUT().split()))\nS_MAP = lambda: list(map(str, INPUT().split()))\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef main():\n S = [INPUT() for _ in range(3)]\n ctoi = lambda c: ord(c) - ord('a')\n\n num = 0\n while len(S[num]) > 0:\n init = S[num][0]\n S[num] = S[num][1:]\n num = ctoi(init)\n\n print((\"ABC\"[num]))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "Sa = list(input())\nSb = list(input())\nSc = list(input())\nturn = Sa\nans =\"A\"\nwhile turn != []:\n card =turn[0]\n turn.pop(0)\n if card ==\"a\":\n turn =Sa\n ans =\"A\"\n elif card ==\"b\":\n turn =Sb\n ans =\"B\"\n else:\n turn =Sc\n ans =\"C\"\nprint(ans)", "def check(n):\n if n=='a':\n if len(a)>0: check(a.pop())\n else: print('A')\n elif n=='b':\n if len(b)>0: check(b.pop())\n else: print('B')\n elif n=='c':\n if len(c)>0: check(c.pop())\n else: print('C')\na,b,c=[[*input()][::-1] for _ in range(3)]\ncheck(a.pop())", "a=[input(),input(),input()]\nnow=0\nwhile a[now]:\n y=a[now][0];a[now]=a[now][1:];now=ord(y)-ord('a')\nprint(\"ABC\"[now])", "S = {}\nS['a'] = input()\nS['b'] = input()\nS['c'] = input()\nturn = 'a'\nwhile True:\n hand = S[turn]\n if len(hand) == 0: break\n S[turn] = hand[1:]\n turn = hand[0]\n\nprint(turn.upper())", "s = {'a': input(), 'b': input(), 'c': input()}\n\nnow = 'a'\nwhile s[now] != '':\n next = s[now][0]\n s[now] = s[now][1:]\n now = next\nprint(now.upper())", "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom fractions import gcd\nfrom bisect import bisect, bisect_left, bisect_right\n\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return list(map(int, input().split()))\ndef S_MAP(): return list(map(str, input().split()))\ndef LIST(): return list(map(int, input().split()))\ndef S_LIST(): return list(map(str, input().split()))\n \nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nA = deque(list(input()))\nB = deque(list(input()))\nC = deque(list(input()))\n\n# while len(A) == 0 or len(B) == 0 or len(C) == 0:\np = A.popleft()\nwhile 1:\n if p == \"a\":\n if len(A) == 0:\n print(\"A\")\n return\n else:\n p = A.popleft()\n if p == \"b\":\n if len(B) == 0:\n print(\"B\")\n return\n else:\n p = B.popleft()\n\n if p == \"c\":\n if len(C) == 0:\n print(\"C\")\n return\n else:\n p = C.popleft()\n \n \n\n", "a = list(input())\nb = list(input())\nc = list(input())\n\n\ndef check(x=\"a\"):\n try:\n if x == \"a\":\n x = a.pop(0)\n check(x)\n elif x == \"b\":\n x = b.pop(0)\n check(x)\n elif x == \"c\":\n x = c.pop(0)\n check(x)\n except IndexError:\n print((x.upper()))\n\n\ncheck()\n", "Sa = list(input())\nSb = list(input())\nSc = list(input())\nturn = Sa\nans = \"A\"\nwhile turn != []:\n card = turn[0]\n turn.pop(0)\n if card == \"a\":\n turn = Sa\n ans = \"A\"\n elif card == \"b\":\n turn = Sb\n ans = \"B\"\n else:\n turn = Sc\n ans = \"C\"\nprint(ans)", "a = list(input())[::-1]\nb = list(input())[::-1]\nc = list(input())[::-1]\n\nabc = [a, b, c]\nnum1 = {'a':0, 'b':1, 'c':2}\nnum2 = ['A', 'B', 'C']\nd = 0\nwhile True:\n if abc[d]:\n d = num1[abc[d].pop()]\n else:\n break\nprint(num2[d])", "Cards = {'a':list(input()),'b':list(input()),'c':list(input())}\n\ndef solve(p):\n nonlocal Cards\n if len(Cards[p]) == 0:\n return p.capitalize()\n np = Cards[p].pop(0)\n return solve(np)\n\nprint(solve('a'))", "a = list(input())\nb = list(input())\nc = list(input())\n\ntgt = a.pop(0)\n\nwhile True:\n if tgt == 'a':\n if a:\n tgt = a.pop(0)\n else:\n ans = 'A'\n break\n elif tgt == 'b':\n if b:\n tgt = b.pop(0)\n else:\n ans = 'B'\n break\n else:\n if c:\n tgt = c.pop(0)\n else:\n ans = 'C'\n break\nprint(ans)", "#\n# abc045 b\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"aca\naccc\nca\"\"\"\n output = \"\"\"A\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"abcb\naacb\nbccc\"\"\"\n output = \"\"\"C\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n A = list(input()) + [0]\n B = list(input()) + [0]\n C = list(input()) + [0]\n\n T = \"a\"\n while len(A) and len(B) and len(C):\n if T == \"a\":\n T = A.pop(0)\n elif T == \"b\":\n T = B.pop(0)\n else:\n T = C.pop(0)\n\n if len(A) == 0:\n print(\"A\")\n elif len(B) == 0:\n print(\"B\")\n else:\n print(\"C\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "d = { 'a':input(), 'b':input(), 'c':input() }\npointer = 'a'\nwhile True:\n if 0 < len(d[pointer]):\n tmp = d[pointer][0]\n d[pointer] = d[pointer][1:]\n pointer = tmp\n else:\n print((pointer.upper()))\n break\n", "SA=str(input())+\"f\"\nSB=str(input())+\"f\"\nSC=str(input())+\"f\"\nA,B,C=1,0,0\ni=0\nx=SA[0]\n\nwhile i < len(SA + SB + SC):\n if x == \"a\":\n x = SA[A]\n A+=1\n elif x == \"b\":\n x = SB[B]\n B+=1\n elif x == \"c\":\n x = SC[C]\n C+=1\n \n if A==len(SA):\n ans=\"A\"\n break\n elif B==len(SB):\n ans=\"B\"\n break\n elif C==len(SC):\n ans=\"C\"\n break\n i+=1\nprint(ans)", "A,B,C = [input() for i in range(3)]\nturn=\"a\"\n\nwhile True:\n if turn == \"a\":\n if A == \"\":\n print(\"A\")\n break\n turn = A[0]\n A = A[1:]\n elif turn == \"b\":\n if B == \"\":\n print(\"B\")\n break\n turn = B[0]\n B = B[1:]\n else:\n if C == \"\":\n print(\"C\")\n break\n turn = C[0]\n C = C[1:] ", "Sa = input()\nSb = input()\nSc = input()\nS_dic = {0:'a', 1:'b', 2:'c'}\nS_dic_L = {0:'A', 1:'B', 2:'C'}\nS_dic_inv = {'a':0, 'b':1, 'c':2}\n\nS = [Sa, Sb, Sc]\n\ndef find_game(x):\n if S[x] == '':\n print((S_dic_L[x]))\n return\n\n else:\n p = S[x][0]\n S[x] = S[x][1:]\n\n find_game(S_dic_inv[p])\n\nfind_game(0)\n", "S = {i:list(input()) for i in \"abc\"}\ns = \"a\"\nwhile S[s]:\n s = S[s].pop(0)\nprint(s.upper())", "from collections import deque\n\ns = {}\n\ns = {\n \"a\": deque(list(input())),\n \"b\": deque(list(input())),\n \"c\": deque(list(input())),\n}\n\nt = \"a\"\n\nwhile s[t]:\n t = s[t].popleft()\n\nprint((t.upper()))\n", "A = [input() for _ in range(3)]\n\nnxt = A[0][0]\nA[0] = A[0][1:]\nwhile True:\n now = ord(nxt) - ord('a')\n if A[now] == '':\n ans = chr(now + ord('A'))\n break\n nxt = A[now][0]\n A[now] = A[now][1:]\n\nprint(ans)", "SA = input()\nSB = input()\nSC = input()\nS = {'a' : SA, 'b' : SB, 'c' : SC}\ncard = S['a'][0]\nwhile True:\n if S[card] == '':\n print(card.upper())\n break\n S[card], card = S[card][1:], S[card][0]", "from collections import deque\n\n\ndef main():\n sas = deque(list(input()))\n sbs = deque(list(input()))\n scs = deque(list(input()))\n\n deques = {\"A\": sas, \"B\": sbs, \"C\": scs}\n player = \"A\"\n while True:\n if len(deques[player]) == 0:\n ans = player\n break\n player_temp = deques[player].popleft()\n player = player_temp.upper()\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a = list(input())\nb = list(input())\nc = list(input())\n\nA = len(a)\nB = len(b)\nC = len(c)\ncnta = 0\ncntb = 0\ncntc = 0\nfor i in range(A+B+C):\n if i == 0:\n cnta += 1\n if cnta > A:\n print(\"A\")\n break\n q = a[0]\n a.pop(0)\n continue\n if q == \"b\":\n cntb += 1\n if cntb > B:\n print(\"B\")\n break\n q = b[0]\n b.pop(0)\n \n elif q == \"a\":\n cnta += 1\n if cnta > A:\n print(\"A\")\n break\n q = a[0]\n a.pop(0)\n\n else:\n cntc += 1\n if cntc > C:\n print(\"C\")\n break\n q = c[0]\n c.pop(0)", "s = {'a': input(), 'b': input(), 'c': input()}\n \nnow = 'a'\nwhile s[now] != '':\n next = s[now][0]\n s[now] = s[now][1:]\n now = next\nprint(now.upper())", "A = input()\nB = input()\nC = input()\n\nturn = 'a'\nwhile True:\n num_card_A = len(A)\n num_card_B = len(B)\n num_card_C = len(C)\n if turn == 'a':\n if num_card_A == 0:\n winner = 'A'\n break\n turn = A[0]\n A = A[1:]\n elif turn == 'b':\n if num_card_B == 0:\n winner = 'B'\n break\n turn = B[0]\n B = B[1:]\n elif turn == 'c':\n if num_card_C == 0:\n winner = 'C'\n break\n turn = C[0]\n C = C[1:]\n\nprint(winner)", "def main():\n SA = list(input())\n SB = list(input())\n SC = list(input())\n\n SA.reverse()\n SB.reverse()\n SC.reverse()\n\n turn = 'a'\n for i in range(400):\n if turn == 'a':\n if len(SA) == 0:\n print('A')\n return\n turn = SA.pop()\n elif turn == 'b':\n if len(SB) == 0:\n print('B')\n return\n turn = SB.pop()\n else:\n if len(SC) == 0:\n print('C')\n return\n turn = SC.pop()\n \ndef __starting_point():\n main()\n\n__starting_point()", "S = {i:list(input()) for i in \"abc\"}\nn = \"a\"\nwhile S[n]:\n n = S[n].pop(0)\n\nprint(n.upper())", "a, b, c = input(), input(), input()\nref = a[0]\na = a[1:]\nif len(a) == 0:\n print(\"A\")\n return\nfor _ in range(len(a)+len(b)+len(c)):\n if ref == \"a\":\n if len(a) == 0:\n print(\"A\")\n return\n ref = a[0]\n a = a[1:]\n\n elif ref == \"b\":\n if len(b) == 0:\n print(\"B\")\n return\n ref = b[0]\n b = b[1:]\n \n else:\n if len(c) == 0:\n print(\"C\")\n return\n ref = c[0]\n c = c[1:]", "card = {c: list(input()) for c in \"abc\"}\ns = \"a\"\nwhile card[s]:\n s = card[s].pop(0)\nprint(s.upper())", "S = {i: list(input()) for i in \"abc\"}\nn = \"a\"\nwhile S[n]:\n n = S[n].pop(0)\n \nprint(n.upper())", "A,B,C=[input() for i in range(0,3)]\n\nturn='a'\nwhile True:\n if turn == 'a':\n if A ==\"\":\n print('A')\n break\n turn=A[0]\n A=A[1:]\n elif turn=='b':\n if B==\"\":\n print('B')\n break\n turn=B[0]\n B=B[1:]\n else:\n if C==\"\":\n print('C')\n break\n turn=C[0]\n C=C[1:]", "s=[input() for i in range(3)]\nturn=[\"a\",\"b\",\"c\"]\nt=0\nwhile s[t]:\n tt=turn.index(s[t][0])\n s[t]=s[t][1:]\n t=tt\nprint(turn[t].upper())", "S = [input() for _ in range(3)]\nnext = 0\ntemp = \"\"\nwin = \"\"\nwhile True:\n if len(S[next]) == 0:\n win = [\"A\",\"B\",\"C\"][next]\n break\n temp = S[next][0]\n S[next] = S[next][1:]\n next = ord(temp)-97\nprint(win)", "cards_map = {}\ncards_map['A'] = list(input().upper())\ncards_map['B'] = list(input().upper())\ncards_map['C'] = list(input().upper())\ncurrent = 'A'\nwhile True:\n if len(cards_map[current]) == 0:\n break\n else:\n current = cards_map[current].pop(0)\nprint(current)", "A=input()\nB=input()\nC=input()\nmoto=A\nsuji=\"a\"\nwhile True:\n if len(moto)==0:\n if suji==\"a\":\n print(\"A\")\n return\n if suji==\"b\":\n print(\"B\")\n return\n if suji==\"c\":\n print(\"C\")\n return\n s=moto[0]\n if suji==\"a\":\n A=A[1:]\n if suji==\"b\":\n B=B[1:]\n if suji==\"c\":\n C=C[1:]\n if s==\"a\":\n moto=A\n suji=\"a\"\n if s==\"b\":\n moto=B\n suji=\"b\"\n if s==\"c\":\n moto=C\n suji=\"c\"", "G = {}\nl =[\"a\",\"b\",\"c\"]\nfor i in l:\n G[i] = list(input())\ns = l[0]\nwhile(True):\n if len(G[s]) ==0:\n print((s.upper()))\n break\n s = G[s].pop(0)\n", "a = list(input())\nb = list(input())\nc = list(input())\nnext = a.pop(0)\nwhile True:\n if next == \"a\":\n if a == []:\n print(\"A\")\n break\n else:\n next = a.pop(0)\n elif next == \"b\":\n if b == []:\n print(\"B\")\n break\n else:\n next = b.pop(0)\n else:\n if c == []:\n print(\"C\")\n break\n else:\n next =c.pop(0)", "a = input()\nb = input()\nc = input()\n\nd = 'A'\nwhile True:\n if d == 'A':\n if len(a) == 0:\n break\n s = a[0]\n a = a[1:]\n elif d == 'B':\n if len(b) == 0:\n break\n s = b[0]\n b = b[1:]\n else:\n if len(c) == 0:\n break\n s = c[0]\n c = c[1:]\n if s == 'a':\n d = 'A'\n elif s == 'b':\n d = 'B'\n else:\n d = 'C'\nprint (d)\n", "a = input()\nb = input()\nc = input()\n\nturn = 'a'\nwhile True:\n if turn == 'a':\n if a == '':\n print('A')\n return\n elif a[0] == 'a':\n turn = 'a'\n elif a[0] == 'b':\n turn = 'b'\n else:\n turn = 'c'\n a = a[1:]\n elif turn == 'b':\n if b == '':\n print('B')\n return\n elif b[0] == 'a':\n turn = 'a'\n elif b[0] == 'b':\n turn = 'b'\n else:\n turn = 'c'\n b = b[1:]\n else:\n if c == '':\n print('C')\n return\n elif c[0] == 'a':\n turn = 'a'\n elif c[0] == 'b':\n turn = 'b'\n else:\n turn = 'c'\n c = c[1:]\n", "a_line = input()\na_line = list(a_line)\n#print(a_line)\nb_line = input()\nb_line = list(b_line)\n\nc_line = input()\nc_line = list(c_line)\n\nend = 0\nturn = \"a\"\n\nwhile(end == 0):\n if turn==\"a\":\n if len(a_line) == 0:\n end = \"A\"\n else:\n temp = a_line[0]\n del a_line[0]\n #print(a_line)\n turn = temp\n \n \n elif turn==\"b\":\n if len(b_line) == 0:\n end = \"B\"\n else:\n temp = b_line[0]\n del b_line[0]\n #print(b_line)\n turn = temp \n \n else:\n if len(c_line) == 0:\n end = \"C\"\n else:\n temp = c_line[0]\n del c_line[0]\n #print(b_line)\n turn = temp \n \n \nprint(end) ", "s=[list(input()) for i in range(3)]\nturn=[\"a\",\"b\",\"c\"]\nt=0\nwhile s[t]:\n t=turn.index(s[t].pop(0))\nprint(turn[t].upper())", "Sa = input()\nSb = input()\nSc = input()\n\nnow = 'a'\nwhile True:\n # if len(Sa) == 0 or len(Sb) == 0 or len(Sc) == 0:\n # break\n if now == 'a':\n if len(Sa) == 0:\n print((now.capitalize()))\n return\n now = Sa[0]\n Sa = Sa[1:len(Sa) + 1]\n continue\n\n elif now == 'b':\n if len(Sb) == 0:\n print((now.capitalize()))\n return\n now = Sb[0]\n Sb = Sb[1:len(Sb) + 1]\n continue\n\n elif now == 'c':\n if len(Sc) == 0:\n print((now.capitalize()))\n return\n now = Sc[0]\n Sc = Sc[1:len(Sc) + 1]\n continue\n", "a=input()\nb=input()\nc=input()\na+=\"A\"\nb+=\"B\"\nc+=\"C\"\nn=a\nwhile True:\n if len(n)>1:\n k=n[0]\n if n==a:\n a=a[1:]\n elif n==b:\n b=b[1:]\n else:\n c=c[1:]\n if k==\"a\":\n n=a\n elif k==\"b\":\n n=b\n else:\n n=c\n else:\n print(n[-1])\n break", "from collections import deque\na=deque(input())\nb=deque(input())\nc=deque(input())\n\ns={\"a\":a,\"b\":b,\"c\":c}\nt=\"a\"\nwhile 1:\n if s[t]==deque():\n ans=t\n break\n t=s[t].popleft()\nprint(ans.upper())", "A=list(input())\nB=list(input())\nC=list(input())\nli=[A,B,C]\nsw=True\nk=0\nwhile sw==True:\n if li[k][0]==\"a\":\n del li[k][0]\n k=0\n elif li[k][0]==\"b\":\n del li[k][0]\n k=1\n elif li[k][0]==\"c\":\n del li[k][0]\n k=2\n if li[k]==[]:\n sw=False\nans=[\"A\",\"B\",\"C\"]\nprint((ans[k]))\n", "a = list(str(input()))\nb = list(str(input()))\nc = list(str(input()))\nn = a.pop(0)\nm = 0\nwhile True:\n if n == 'a':\n if len(a) == 0:\n break\n n = a.pop(0)\n elif n == 'b':\n if len(b) == 0:\n break\n n = b.pop(0)\n else:\n if len(c) == 0:\n break\n n = c.pop(0)\nprint(n.upper())", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(S_A: str, S_B: str, S_C: str):\n d = dict(list(zip(\"abc\", list(map(iter, [S_A, S_B, S_C])))))\n try:\n u = \"a\"\n while True:\n u = next(d[u])\n except StopIteration:\n return u.upper()\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n S_A = next(tokens) # type: str\n S_B = next(tokens) # type: str\n S_C = next(tokens) # type: str\n print((solve(S_A, S_B, S_C)))\n\ndef test():\n import doctest\n doctest.testmod()\n\ndef __starting_point():\n #test()\n main()\n\n__starting_point()", "s=[input() for i in range(3)]\nturn=[\"a\",\"b\",\"c\"]\nt=0\nfor i in range(300):\n if len(s[t])==0:\n print((turn[t].upper()))\n break\n if turn[t]==s[t][0]:\n s[t]=s[t][1:]\n #print(s)\n else:\n tt=turn.index(s[t][0])\n s[t]=s[t][1:]\n t=tt\n #print(s)\n", "sa = input()\nsb = input()\nsc = input()\ns = []\ns.append(sa.replace('a', '0').replace('b', '1').replace('c', '2'))\ns.append(sb.replace('a', '0').replace('b', '1').replace('c', '2'))\ns.append(sc.replace('a', '0').replace('b', '1').replace('c', '2'))\ni = 0\nwhile s[i]!='':\n j = int(s[i][0])\n s[i] = s[i][1:]\n i = j\nans = 'ABC'\n\nprint(ans[i])", "Sa = input()\nSb = input()\nSc = input()\n\ntmp = Sa[0]\nSa = Sa[1:]\nwhile True:\n if tmp == \"a\":\n if not Sa:\n print(\"A\")\n return\n\n tmp = Sa[0]\n Sa = Sa[1:]\n\n if tmp == \"b\":\n if not Sb:\n print(\"B\")\n return\n\n tmp = Sb[0]\n Sb = Sb[1:]\n\n if tmp == \"c\":\n if not Sc:\n print(\"C\")\n return\n tmp = Sc[0]\n Sc = Sc[1:]", "from collections import deque\na = list(input())\nb = list(input())\nc = list(input())\n\na = deque(a)\nb = deque(b)\nc = deque(c)\n\nx = 'a'\nwhile True:\n if x == 'a':\n if a:\n x = a.popleft()\n else:\n print('A')\n return\n elif x == 'b':\n if b:\n x = b.popleft()\n else:\n print('B')\n return\n else:\n if c:\n x = c.popleft()\n else:\n print('C')\n return\n", "code_A = ord('A')\ncode_a = ord('a')\nA = [input() for _ in range(3)]\n\nnxt = A[0][0]\nA[0] = A[0][1:]\nwhile True:\n now = ord(nxt) - code_a\n if A[now] == '':\n ans = chr(now + code_A)\n break\n nxt = A[now][0]\n A[now] = A[now][1:]\n\nprint(ans)", "from collections import deque\na = deque(reversed(input()))\nb = deque(reversed(input()))\nc = deque(reversed(input()))\nne = a.pop()\nwhile(True):\n if ne == 'a':\n if not a: break\n ne = a.pop()\n elif ne == 'b':\n if not b: break\n ne = b.pop()\n else:\n if not c: break\n ne = c.pop()\nprint(ne.upper())", "S = [\"\"] * 3\nS[0] = input()\nS[1] = input()\nS[2] = input()\nindex = [0] * 3\nturn = 0\n\nwhile True:\n if index[turn] == len(S[turn]):\n print((chr(ord('A') + turn)))\n break\n else:\n nextTurn = ord(S[turn][index[turn]]) - ord('a')\n index[turn] += 1\n turn = nextTurn\n", "a = list(input())\nb = list(input())\nc = list(input())\n\nt = a.pop(0)\nl = 0\nwhile True:\n if t == 'a':\n if len(a) == 0:\n break\n t = a.pop(0)\n elif t == 'b':\n if len(b) == 0:\n break\n t = b.pop(0)\n elif t == 'c':\n if len(c) == 0:\n break\n t = c.pop(0)\n\nprint(t.upper())", "import numpy\na = list(input())\nb = list(input())\nc = list(input())\n\n\ndef check(x=\"a\"):\n try:\n if x == \"a\":\n x = a.pop(0)\n check(x)\n elif x == \"b\":\n x = b.pop(0)\n check(x)\n elif x == \"c\":\n x = c.pop(0)\n check(x)\n except IndexError:\n print((x.upper()))\n\n\ncheck()\n", "sa = input().replace('a', '0').replace('b', '1').replace('c', '2')\nsb = input().replace('a', '0').replace('b', '1').replace('c', '2')\nsc = input().replace('a', '0').replace('b', '1').replace('c', '2')\nsl = [sa, sb, sc]\nabc = ['A', 'B',' C']\nturn = 0\n\nwhile True:\n if len(sl[turn]) == 0:\n print(abc[turn])\n return\n else:\n sl[turn], turn = sl[turn][1:], int(sl[turn][0])\n\nprint(sl)", "sa=input()+'a'\nsb=input()+'b'\nsc=input()+'c'\nst='a'\na=0\nb=0\nc=0\nwhile a<len(sa) and b<len(sb) and c<len(sc):\n if st=='a':\n st=sa[a]\n a+=1\n elif st=='b':\n st=sb[b]\n b+=1\n else:\n st=sc[c]\n c+=1\nif a==len(sa):\n print('A')\nelif b==len(sb):\n print('B')\nelse:\n print('C')", "s=[list(input()) for i in range(3)]\nn=[len(s[0]), len(s[1]), len(s[2])]\ncount = [0, 0, 0]\nturn = 0\n\nwhile(True):\n #print(count, n)\n count[turn] += 1\n if count[0] > n[0]:\n print(\"A\")\n break\n elif count[1] > n[1]:\n print(\"B\")\n break\n elif count[2] > n[2]:\n print(\"C\")\n break\n turn = ord(s[turn][count[turn]-1])-97\n #print(count, turn)\n\n", "import sys\nimport re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import accumulate, permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom fractions import gcd\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return list(map(int, input().split()))\ndef LIST(): return list(map(int, input().split()))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nS = [deque(input().replace('a', '0').replace('b', '1').replace('c', '2')) for _ in range(3)]\n\nnext = '0'\nwhile True:\n tmp = S[int(next)]\n if len(tmp) == 0:\n ans = next\n break\n else:\n next = tmp.popleft()\n\nif ans == '0':\n print('A')\nelif ans == '1':\n print('B')\nelse:\n print('C')\n", "a,b,c = [str(input()) for i in range(3)]\ncurrent = 'a'\nwhile True:\n try:\n cur = current[len(current)-1]\n if cur == 'a':\n current+=a[0]\n a=a[1:]\n elif cur == 'b':\n current+=b[0]\n b=b[1:]\n elif cur == 'c':\n current+=c[0]\n c=c[1:]\n except:\n print(current[len(current)-1].upper())\n break", "sa = list(input())\nsb = list(input())\nsc = list(input())\nturn = \"a\"\nfor i in range(len(sa+sb+sc)):\n if turn == \"a\":\n if len(sa) == 0:\n print(\"A\")\n break\n else:\n turn = sa[0]\n sa.remove(sa[0])\n elif turn == \"b\":\n if len(sb) == 0:\n print(\"B\")\n break\n else:\n turn = sb[0]\n sb.remove(sb[0])\n else:\n if len(sc) == 0:\n print(\"C\")\n break\n else:\n turn = sc[0]\n sc.remove(sc[0])", "SA = list(input())\nSB = list(input())\nSC = list(input())\n\nx = 'a'\n\nwhile True:\n if x == 'a':\n if len(SA)==0:\n print('A')\n return\n x = SA[0]\n SA.remove(x)\n if x == 'b':\n if len(SB)==0:\n print('B')\n return\n x = SB[0]\n SB.remove(x)\n if x == 'c':\n if len(SC)==0:\n print('C')\n return\n x = SC[0]\n SC.remove(x)\n\n", "#68 B - 3\u4eba\u3067\u30ab\u30fc\u30c9\u30b2\u30fc\u30e0\u30a4\u30fc\u30b8\u30fc\nfrom collections import deque\nSa = deque(input())\nSb = deque(input())\nSc = deque(input())\n\nturn = 0\nwhile True:\n if turn == 0:\n if len(Sa) == 0:\n ans = 'A'\n break\n tgt = Sa.popleft()\n if tgt == 'b':\n turn = 1\n elif tgt == 'c':\n turn = 2\n if turn == 1:\n if len(Sb) == 0:\n ans = 'B'\n break\n tgt = Sb.popleft()\n if tgt == 'a':\n turn = 0\n elif tgt == 'c':\n turn = 2\n if turn == 2:\n if len(Sc) == 0:\n ans = 'C'\n break\n tgt = Sc.popleft()\n if tgt == 'a':\n turn = 0\n elif tgt == 'b':\n turn = 1\nprint(ans)", "a = input()\nb = input()\nc = input()\nnext = a[0]\na = a[1:]\nwhile True:\n if next == \"a\":\n if a == \"\":\n print(\"A\")\n break\n else:\n next = a[0]\n a = a[1:]\n elif next == \"b\":\n if b == \"\":\n print(\"B\")\n break\n else:\n next = b[0]\n b = b[1:]\n else:\n if c == \"\":\n print(\"C\")\n break\n else:\n next = c[0]\n c = c[1:]", "s = [input() for i in range(3)]\nt = [\"a\", \"b\", \"c\"]\ncur = 0\nwhile len(s[cur]) > 0:\n next = s[cur][0]\n s[cur] = s[cur][1:]\n cur = t.index(next)\nprint(t[cur].upper())", "import sys\nfrom collections import deque\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\n\ndef solve():\n S = [deque(ins()) for _ in range(3)]\n abc = {\"a\": 0, \"b\": 1, \"c\": 2}\n i = 0\n while True:\n if not S[i]:\n return i\n x = S[i].popleft()\n i = abc[x]\n return\n\n\nprint(\"ABC\"[solve()])\n", "class Combination:\n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1 for i in range(self.n + 1)]\n self.finv = [1 for i in range(self.n + 1)]\n for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n def comb(self, n, m):\n return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod\ndef iparse():\n return list(map(int, input().split()))\n\ndef __starting_point():\n s = [list(input()) for i in range(3)]\n for e in s:\n e.reverse()\n \n turn = 0\n while True:\n if len(s[turn]) == 0:\n break\n tmp = s[turn].pop()\n if tmp == 'a':\n turn = 0\n elif tmp == 'b':\n turn = 1\n else:\n turn = 2\n\n if turn == 0:\n print(\"A\")\n elif turn == 1:\n print(\"B\")\n else:\n print(\"C\")\n \n \n\n__starting_point()", "a = list(map(str,input()))\nb = list(map(str,input()))\nc = list(map(str,input()))\ns = a.pop(0)\nwhile True:\n if a == [] and s == \"a\":\n print(\"A\")\n return\n elif b == [] and s == \"b\":\n print(\"B\")\n return\n elif c == [] and s == \"c\":\n print(\"C\")\n return\n if s == \"a\":\n s = a.pop(0)\n elif s == \"b\":\n s = b.pop(0)\n elif s == \"c\":\n s = c.pop(0)\n", "a=input()\nb=input()\nc=input()\ni=0\nj=0\nk=0\nt='a'\nwhile 1:\n if t=='a':\n if i==len(a):\n print('A')\n break\n t=a[i]\n i+=1\n elif t=='b':\n if j==len(b):\n print('B')\n break\n t=b[j]\n j+=1\n elif t=='c':\n if k==len(c):\n print('C')\n break\n t=c[k]\n k+=1\n", "s=[0,0,0]\ns[0]=list(input())\ns[1]=list(input())\ns[2]=list(input())\nn=0\nfor i in range(100000):\n if len(s[n])==0:\n break\n tmp=s[n].pop(0)\n if tmp==\"a\":\n n=0\n elif tmp==\"b\":\n n=1\n else:\n n=2\n\nif n==0:\n print(\"A\")\nelif n==1:\n print(\"B\")\nelse:\n print(\"C\")", "#!/usr/bin/env python3\nimport sys\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef main():\n A = input()\n B = input()\n C = input()\n\n w = 'a'\n while True:\n if w == 'a':\n if A == '':\n print('A')\n return\n w = A[0]\n A = A[1:]\n if w == 'b':\n if B == '':\n print('B')\n return\n w = B[0]\n B = B[1:]\n if w == 'c':\n if C == '':\n print('C')\n return\n w = C[0]\n C = C[1:]\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a=list(input())\nb=list(input())\nc=list(input())\nans=\"a\"\nwhile True:\n try:\n if ans == \"a\":\n ans=a[0]\n a=a[1:]\n elif ans == \"b\":\n ans = b[0]\n b=b[1:]\n elif ans == \"c\":\n ans = c[0]\n c=c[1:]\n except:\n print((ans.upper()))\n break\n", "sa = input()\nsb = input()\nsc = input()\n\nturn = sa[0]\nsa = sa[1:]\nwhile True:\n if turn == \"a\":\n if sa == \"\":\n print(\"A\")\n break\n else:\n turn = sa[0]\n sa = sa[1:]\n elif turn == \"b\":\n if sb == \"\":\n print(\"B\")\n break\n else:\n turn = sb[0]\n sb = sb[1:]\n elif turn == \"c\":\n if sc == \"\":\n print(\"C\")\n break\n else:\n turn = sc[0]\n sc = sc[1:]\n", "from collections import deque\n\ndef main():\n\n players = {\n 'a': None,\n 'b': None,\n 'c': None\n }\n\n for i in players:\n players[i] = deque(tuple(input()))\n\n card = 'a'\n while players[card]:\n card = players[card].popleft()\n\n print(card.upper())\n\n\ndef __starting_point():\n main()\n__starting_point()", "SA = input()\nSB = input()\nSC = input()\n\nindexA = 0\nindexB = 0\nindexC = 0\nturn = 'A'\nwinner = ''\nwhile 1:\n if turn == 'A':\n if indexA == len(SA):\n winner = 'A'\n break\n if SA[indexA] == 'a':\n turn = 'A'\n elif SA[indexA] == 'b':\n turn = 'B'\n elif SA[indexA] == 'c':\n turn = 'C'\n indexA += 1\n elif turn == 'B':\n if indexB == len(SB):\n winner = 'B'\n break\n if SB[indexB] == 'a':\n turn = 'A'\n elif SB[indexB] == 'b':\n turn = 'B'\n elif SB[indexB] == 'c':\n turn = 'C'\n indexB += 1\n elif turn == 'C':\n if indexC == len(SC):\n winner = 'C'\n break\n if SC[indexC] == 'a':\n turn = 'A'\n elif SC[indexC] == 'b':\n turn = 'B'\n elif SC[indexC] == 'c':\n turn = 'C'\n indexC += 1\nprint(winner)\n", "a = list(input())\nb = list(input())\nc = list(input())\n\nD = {'a':a, 'b':b, 'c':c}\ncurr = 'a'\nwhile True:\n tmp = D[curr]\n if tmp == []:\n break\n curr = tmp.pop(0)\nprint((curr.upper()))\n \n \n", "SA = input()\nSB = input()\nSC = input()\n\nindexA = 0\nindexB = 0\nindexC = 0\nturn = 'A'\nwinner = ''\nwhile 1:\n if turn == 'A':\n if indexA == len(SA):\n winner = 'A'\n break\n if SA[indexA] == 'a':\n turn = 'A'\n elif SA[indexA] == 'b':\n turn = 'B'\n elif SA[indexA] == 'c':\n turn = 'C'\n indexA += 1\n elif turn == 'B':\n if indexB == len(SB):\n winner = 'B'\n break\n if SB[indexB] == 'a':\n turn = 'A'\n elif SB[indexB] == 'b':\n turn = 'B'\n elif SB[indexB] == 'c':\n turn = 'C'\n indexB += 1\n elif turn == 'C':\n if indexC == len(SC):\n winner = 'C'\n break\n if SC[indexC] == 'a':\n turn = 'A'\n elif SC[indexC] == 'b':\n turn = 'B'\n elif SC[indexC] == 'c':\n turn = 'C'\n indexC += 1\nprint(winner)", "import collections as col\n\nA = str(input())\nB = str(input())\nC = str(input())\n\nA_queue = col.deque()\nB_queue = col.deque()\nC_queue = col.deque()\n\nfor i in range (0, len(A)):\n\tA_queue.append(A[i])\nfor i in range (0, len(B)):\n\tB_queue.append(B[i])\nfor i in range (0, len(C)):\n\tC_queue.append(C[i])\n\nD = ['a','b','c']\n \nstart = 0 \nfor i in range (0, 300):\n\tif start == 0:\n\t\tif len(A_queue) == 0:\n\t\t\tprint('A')\n\t\t\treturn\n\t\telse:\n\t\t\tV = A_queue.popleft()\n\t\t\tstart = D.index(V)\n\telif start == 1:\n\t\tif len(B_queue) == 0:\n\t\t\tprint('B')\n\t\t\treturn\n\t\telse:\n\t\t\tV = B_queue.popleft()\n\t\t\tstart = D.index(V) \n\telse:\n\t\tif len(C_queue) == 0:\n\t\t\tprint('C')\n\t\t\treturn\n\t\telse:\n\t\t\tV = C_queue.popleft()\n\t\t\tstart = D.index(V) ", "import sys\nimport math\nfrom collections import deque\n\n\ninint = lambda: int(sys.stdin.readline())\ninintm = lambda: map(int, sys.stdin.readline().split())\ninintl = lambda: list(inintm())\ninstrm = lambda: map(str, sys.stdin.readline().split())\ninstrl = lambda: list(instrm())\n\ns_at = input()[::-1]\ns_bt = input()[::-1]\ns_ct = input()[::-1]\n\ns_a = deque()\ns_b = deque()\ns_c = deque()\n\nfor i in range(len(s_at)):\n s_a.append(s_at[i])\n\nfor i in range(len(s_bt)):\n s_b.append(s_bt[i])\n\nfor i in range(len(s_ct)):\n s_c.append(s_ct[i])\n\nnow = \"a\"\n\nwhile True:\n if now == \"a\":\n if len(s_a) == 0:\n print(\"A\")\n return\n now = s_a[-1]\n s_a.pop()\n elif now == \"b\":\n if len(s_b) == 0:\n print(\"B\")\n return\n now = s_b[-1]\n s_b.pop()\n else:\n if len(s_c) == 0:\n print(\"C\")\n return\n now = s_c[-1]\n s_c.pop()", "Sa = list(input())\nSb = list(input())\nSc = list(input())\ncard = Sa.pop(0)\nwhile True:\n if card == 'a':\n S = Sa\n if card == 'b':\n S = Sb\n if card == 'c':\n S = Sc\n try:\n card = S.pop(0)\n except:\n print(card.upper())\n break", "A,B,C = (list(input()) for T in range(0,3))\nNext = A.pop(0)\nwhile True:\n if Next=='a':\n if not len(A):\n print('A')\n break\n Next = A.pop(0)\n elif Next=='b':\n if not len(B):\n print('B')\n break\n Next = B.pop(0)\n else:\n if not len(C):\n print('C')\n break\n Next = C.pop(0)", "A = input()\nB = input()\nC = input()\n\nnow = A[:1]\nA = A[1:]\n\nwhile(1):\n if(now == 'a'):\n if(len(A) == 0):\n print(\"A\")\n return\n now = A[:1]\n A = A[1:]\n elif(now == 'b'):\n if(len(B) == 0):\n print(\"B\")\n return\n now = B[:1]\n B = B[1:]\n else:\n if(len(C) == 0):\n print(\"C\")\n return\n now = C[:1]\n C = C[1:]\n", "from collections import deque\nsa = input()\nsb = input()\nsc = input()\n\nq = deque(sa[0])\nsa = sa[1:]\nwhile q:\n t = q.pop()\n if t == \"a\":\n if not sa:\n ans = \"A\"\n break\n q.append(sa[0])\n sa = sa[1:]\n elif t == \"b\":\n if not sb:\n ans = \"B\"\n break\n q.append(sb[0])\n sb = sb[1:]\n elif t == \"c\":\n if not sc:\n ans = \"C\"\n break\n q.append(sc[0])\n sc = sc[1:]\nprint(ans)", "from collections import deque\nA = deque(list(input()))\nB = deque(list(input()))\nC = deque(list(input()))\n\ntern = \"a\"\nwhile True:\n if tern == \"a\":\n if A:\n tern = A.popleft()\n continue\n win = \"A\"\n break\n elif tern == \"b\":\n if B:\n tern = B.popleft()\n continue\n win = \"B\"\n break\n elif tern == \"c\":\n if C:\n tern = C.popleft()\n continue\n win = \"C\"\n break\n \nprint(win)"] | {"inputs": ["aca\naccc\nca\n", "abcb\naacb\nbccc\n"], "outputs": ["A\n", "C\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 45,656 | |
d3630389eb33d6dd6f37bef2725964bd | UNKNOWN | Iroha loves Haiku. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.
To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.
-----Constraints-----
- 1β¦A,B,Cβ¦10
-----Input-----
The input is given from Standard Input in the following format:
A B C
-----Output-----
If it is possible to construct a Haiku by using each of the phrases once, print YES (case-sensitive). Otherwise, print NO.
-----Sample Input-----
5 5 7
-----Sample Output-----
YES
Using three phrases of length 5, 5 and 7, it is possible to construct a Haiku. | ["haiku = list(map(int, input().split()))\nif haiku == [5, 5, 7] or haiku == [5, 7, 5] or haiku == [7, 5, 5]:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "a,b,c=map(int,input().split())\nb5=0\nb7=0\nif a==5:\n b5+=1\nif a==7:\n b7+=1\nif b==5:\n b5+=1\nif b==7:\n b7+=1\nif c==5:\n b5+=1\nif c==7:\n b7+=1\nif b5==2 and b7==1:\n print(\"YES\")\nelse:\n print(\"NO\")", "a=sorted(list(map(int,input().split())))\nif a[0]==a[1]==5 and a[2]==7:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "L = list(map(int, input().split()))\n\nif L == [5, 7, 5] or L == [5, 5, 7] or L == [7, 5, 5]:\n print('YES')\nelse:\n print('NO')", "A,B,C = list(map(int,input().split()))\nsev = 0\nfiv = 0\n\nif A == 7 :\n sev += 1\nelif A == 5:\n fiv += 1\nif B == 7:\n sev += 1\nelif B == 5:\n fiv += 1\nif C == 7:\n sev += 1\nelif C == 5:\n fiv += 1\nif sev == 1 and fiv == 2:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n\n", "array = list(map(str, input().split()))\nif ( array.count('5') == 2 ) and ( array.count( '7') == 1 ):\n print('YES')\nelse:\n print('NO')", "text = str(input())\ncnt = 0\n\nfor i in text:\n if i == \"5\":\n cnt += 1\n if i == \"7\":\n cnt += 2\n\nif cnt == 4:\n print(\"YES\")\nelse:\n print(\"NO\")", "# coding:UTF-8\nimport sys\n\n\ndef resultSur97(x):\n return x % (10 ** 9 + 7)\n\n\ndef __starting_point():\n # ------ \u5165\u529b ------#\n # 1\u884c\u5165\u529b\n aList = list(map(int, input().split())) # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n\n x = 5\n\n # ------ \u51e6\u7406 ------#\n c5 = 0\n c7 = 0\n for a in aList:\n if a == 5:\n c5 += 1\n elif a == 7:\n c7 += 1\n\n # ------ \u51fa\u529b ------#\n if c5 == 2 and c7 == 1:\n print(\"YES\")\n else:\n print(\"NO\")\n\n__starting_point()", "S = input()\nprint('YES' if S.count(\"5\") == 2 and S.count(\"7\") == 1 else 'NO')", "print('YES' if sorted(input().split()) == ['5', '5', '7'] else 'NO')", "a,b,c = map(int,input().split())\nif a+b+c == 17 and a*b*c == 175:\n print('YES')\nelse:\n print('NO')", "w_list = list(map(int, input().split()))\n\nif w_list.count(5) == 2 and w_list.count(7) == 1:\n print(\"YES\")\n \nelse:\n print(\"NO\")", "l = [int(x) for x in input().split()]\nl = sorted(l)\nif l.count(5)==2 and l.count(7)==1:\n print(\"YES\")\nelse:\n print(\"NO\")", "from typing import List\n\n\ndef answer(abc: List[int]) -> str:\n return 'YES' if sorted(abc) == [5, 5, 7] else 'NO'\n\n\ndef main():\n abc = list(map(int, input().split()))\n print(answer(abc))\n\n\ndef __starting_point():\n main()\n__starting_point()", "n = list(map(int,input().split()))\nN5 = 0\nN7 = 0\nfor i in n:\n if i == 5:\n N5 += 1\n elif i == 7:\n N7 += 1\nif N5 == 2 and N7 ==1:\n print(\"YES\")\nelse:\n print(\"NO\")", "A = map(int,input().split())\n\nAS = sorted(A)\n\nI = [5,5,7]\n\nif AS == I:\n print(\"YES\")\nelse:\n print(\"NO\")", "A,B,C=map(int, input().split())\nif (A==5 and B==7 and C==5) or (A==5 and B==5 and C==7) or (A==7 and B==5 and C==5):\n print (\"YES\")\nelse:\n print (\"NO\")", "#!/usr/bin/env python3\n\nin_arr = input().split()\n\nif in_arr.count('5') == 2 and in_arr.count('7') == 1:\n print('YES')\nelse:\n print('NO')\n", "l = list(input().split())\nl.sort()\nif l == ['5', '5', '7']:\n print(\"YES\")\nelse:\n print(\"NO\")", "A, B, C = map(int,input().split())\nif A + B + C == 17 and max(A, B, C) == 7 and min(A, B, C) == 5:\n print(\"YES\")\nelse:\n print(\"NO\")", "import collections\nimport sys\n\nm = collections.defaultdict(int)\nline = input()\nfor d in line.split():\n m[d] += 1\nif m['5'] == 2 and m['7'] == 1:\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\nif a == 5:\n if b == 5 and c == 7 or b == 7 and c == 5:\n print(\"YES\")\n else:\n print(\"NO\")\nelif a == 7 and b == c == 5:\n print(\"YES\")\nelse:\n print(\"NO\")", "p=list(map(int,input().split()))\np.sort()\nif p==[5,5,7]:\n print(\"YES\")\nelse:\n print(\"NO\")", "from collections import Counter\nN = dict(Counter(map(int,input().split())))\nprint(\"YES\") if (N[5]==2 and N[7]==1) else print(\"NO\")", "# -*- coding: utf-8 -*-\n\ndef __starting_point():\n # str_list = [map(int, input().split())]\n # if str_list.count(5) == 2 and str_list.count(7) == 1:\n # print('YES')\n # else:\n # print('NO')\n str_list = list(map(int, input().split()))\n if sum(str_list) == 17:\n print('YES')\n else:\n print('NO')\n\n\n\n\n\n\n__starting_point()", "queue=list(map(int,input().split()))\nqueue.sort()\nif queue[0]==5 and queue[1]==5 and queue[2]==7:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "A, B, C = map(int, input().split())\n \nnum5 = 0\nnum7 = 0\nans = 'NO'\n \nfor num in [A, B, C]:\n if num == 5:\n num5+=1\n elif num == 7:\n num7+=1\n else:\n break\nif num5 ==2 and num7 == 1:\n ans = 'YES'\nprint(ans)", "a,b,c=map(int,input().split())\n\nif a*b*c==5*5*7:\n print(\"YES\")\nelse:\n print(\"NO\")", "Len = list(map(int, input().split()))\n\nif Len.count(5) == 2 and Len.count(7) == 1:\n print('YES')\nelse:\n print('NO')", "import math\nfrom datetime import date\n\ndef main():\n\t\t\n\tline = input().split()\n\ta = [int(x) for x in line]\n\ta.sort()\n\n\tif a[0] == 5 and a[1] == 5 and a[2] == 7:\n\t\tprint(\"YES\")\n\telse:\n\t\tprint(\"NO\")\n\t\nmain()\n", "a, b, c = map(int, input().split())\nif a == 5 and b == 5 and c == 7:\n print('YES')\nelif a == 5 and b == 7 and c == 5:\n print('YES')\n\nelif a == 7 and b == 5 and c == 5:\n print('YES')\n\nelse:\n print('NO')", "a = [int(x) for x in input().split()]\na.sort()\nif a == [5,5,7]:\n print(\"YES\")\nelse:\n print(\"NO\")", "x = input().split()\nfn = 0\nsn = 0\n \nfor i in range(len(x)):\n if int(x[i]) == 5:\n fn += 1\n elif int(x[i]) == 7:\n sn += 1\n \nif fn == 2:\n if sn == 1:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")", "# -*- coding: utf-8 -*-\n\ndef __starting_point():\n str_list = list(map(int, input().split()))\n if sum(str_list) == 17:\n print('YES')\n else:\n print('NO')\n\n__starting_point()", "a = list(map(int, input().split()))\na.sort()\nif a == [5, 5, 7]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "def iroha():\n A, B, C = map(int, input().split())\n S = A + B + C\n if S == 17:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\ndef __starting_point():\n iroha()\n__starting_point()", "a,b,c = map(int,input().split())\nif(a+b+c==17 and (a==5 or a==7) and (b==5 or b==7) and (c==5 or c==7)):\n print(\"YES\")\nelse:\n print(\"NO\")", "lst = list(map(int, input().split()))\nlst.sort()\n\nif lst[0] == 5 and lst[1] == 5 and lst[2] == 7:\n print(\"YES\")\nelse:\n print(\"NO\")", "import sys\ninput = lambda: sys.stdin.readline().rstrip()\n\ndef main():\n x = list(map(int, input().split()))\n if x.count(5) == 2 and x.count(7) == 1:\n print(\"YES\")\n else:\n print(\"NO\")\n \ndef __starting_point():\n main()\n__starting_point()", "A = list(map(int, input().split()))\nA.sort()\nif A[0] == 5 and A[1] == 5 and A[2] ==7:\n print('YES')\nelse:\n print('NO')", "ward = list(map(int, input().split()))\n\nward_sorted = sorted(ward)\n\nif (ward_sorted[0]==5) & (ward_sorted[1]==5) & (ward_sorted[2]==7):\n print('YES')\nelse:\n print('NO')\n", "X = list(map(int,input().split()))\n\n\nprint((\"YES\" if X.count(5) == 2 and X.count(7) == 1 else \"NO\"))\n", "a, b, c = map(int, input().split())\nif(a*b*c == 175):\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c = map(int,input().split())\nabclist = [a,b,c]\nif abclist.count(5) == 2:\n print(\"YES\")\nelse:\n print(\"NO\")", "A,B,C = map(int, input().split())\nif A == 5 and B == 5 and C == 7:\n print(\"YES\")\nelif A == 5 and C == 5 and B == 7:\n print(\"YES\")\nelif C == 5 and B == 5 and A == 7:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c = input().split()\n\nif (a+b+c).count('5')==2 and (a+b+c).count('7') ==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a = list(map(int,input().split()))\na.sort()\nif a[0]==5 and a[1]==5 and a[2]==7:\n print('YES')\nelse:\n print('NO')", "s=input();print('YNEOS'[s.count('5')!=2or s.count('7')!=1::2])", "a = [int(x) for x in input().split()]\na.sort()\nif a == [5,5,7]:\n print(\"YES\")\nelse:\n print(\"NO\")", "a = map(int, input().split())\n\ndef answer(a: list) -> str:\n a = sorted(a)\n if a == [5, 5, 7]:\n return 'YES'\n else:\n return 'NO'\n\nprint(answer(a))", "val = map(int, input().split())\n\ncheck_count = 0\nfor i in val:\n if i not in [5, 7]:\n print('NO')\n if i == 5:\n check_count += 1\n\nif check_count == 2:\n print('YES')\nelse:\n print('NO')", "abc = list(input().split())\n\nif abc.count('5') == 2 and abc.count('7') == 1:\n print('YES')\nelse:\n print('NO')", "from sys import stdin, stdout\nfrom time import perf_counter\n\nimport sys\nsys.setrecursionlimit(10**9)\nmod = 10**9+7\n\n# import sys\n# sys.stdout = open(\"e:/cp/output.txt\",\"w\")\n# sys.stdin = open(\"e:/cp/input.txt\",\"r\")\nl=sorted(map(int,input().split()))\nprint((\"YES\" if l == [5,5,7] else \"NO\"))\n", "a= list(map(str,input().split()))\n\nif a.count(\"5\") == 2:\n\tif a.count(\"7\") == 1:\n\t\tprint(\"YES\")\n\t\treturn\n\nprint(\"NO\")", "print(['YES','NO'][sum(list(map(int,input().split()))) != 17])", "a = list(map(int,input().split()))\n \na.sort()\nprint('YES' if a[0] == 5 and a[1] == 5 and a[2] == 7 else 'NO')", "li=list(map(int,input().split()))\n\nif li.count(5)>=2:\n print('YES')\nelse:\n print('NO')", "a,b,c = map(int, input().split())\nif(a==5 and b==5):\n\tprint(\"YES\")\nelif(b==5 and c==5):\n\tprint(\"YES\")\nelif(a==5 and c==5):\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "abc = list(map(int,input().split()))\n\nprint(\"YES\" if abc.count(5) == 2 and abc.count(7) == 1 else \"NO\")", "inp = input()\n\nif(inp == '5 7 5' or inp == '7 5 5' or inp == '5 5 7'):\n print('YES')\nelse:\n print('NO')", "L = list(map(int, input().split()))\nL.sort()\nprint(\"YES\") if L == [5,5,7] else print(\"NO\")", "import sys\nsys.setrecursionlimit(100000)\n\nA = list(map(int, input().split()))\nA.sort()\n\nif A[0] == 5 and A[1] == 5 and A[2] == 7:\n print(\"YES\")\nelse:\n print(\"NO\")", "s= list(map(int,input().split()))\n\ns.sort()\n\nif s == [5,5,7]:\n print('YES')\n \nelse:\n print('NO')", "a, b, c = input().split()\na, b, c = int(a), int(b), int(c)\nif a == 5 and b == 7 and c == 5:\n\tprint(\"YES\")\nelif a == 5 and b == 5 and c == 7:\n\tprint(\"YES\")\nelif a == 7 and b == 5 and c == 5:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "def atc_042a(input_value: str) -> str:\n ABC = input_value.split(\" \")\n if ABC.count(\"5\") == 2 and ABC.count(\"7\") == 1:\n return \"YES\"\n return \"NO\"\n\ninput_value_1 = input()\nprint(atc_042a(input_value_1))", "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\na = list(map(int, input().split()))\n\nif 7 == a[0]:\n if 5 == a[1] and 5 == a[2]:\n print(\"YES\", end=\"\\n\")\n else:\n print(\"NO\", end=\"\\n\") \n\nelif 5 == a[0]:\n if (7 == a[1] and 5 == a[2]) or (5 == a[1] and 7 == a[2]):\n print(\"YES\", end=\"\\n\")\n else:\n print(\"NO\", end=\"\\n\") \nelse:\n print(\"NO\", end=\"\\n\")", "l = input().split()\nl = list(map(int,l))\nl.sort()\nif l[0]==l[1]==5 and l[2]==7:\n print(\"YES\")\nelse:\n print(\"NO\")", "l_n = list(map(str, input().split()))\n\nprint(('YES' if l_n.count('5') == 2 and l_n.count('7') == 1 else 'NO'))\n", "x = list(map(int, input().split()))\nx.sort()\nf = True\nfor i, e in enumerate(x):\n tmp = 5\n if i == 2:\n tmp = 7\n\n f &= (tmp == e)\nprint((\"YES\" if f else \"NO\"))\n", "a = list(map(int, input().split()))\na.sort()\n\nif a == [5,5,7]:\n print(\"YES\")\nelse:\n print(\"NO\")", "L=[int(i) for i in input().split()]\ncount5=0\ncount7=0\nfor i in range(3):\n if L[i]==5:\n count5+=1\n if L[i]==7:\n count7+=1\nif count5==2 and count7==1:\n print(\"YES\")\nelse:\n print(\"NO\")", "\"\"\"\nABC042 A \u548c\u98a8\u3044\u308d\u306f\u3061\u3083\u3093\u30a4\u30fc\u30b8\u30fc\nhttps://atcoder.jp/contests/abc042/tasks/abc042_a\n\"\"\"\n\nl = list(map(int, input().split()))\nl5 = l.count(5)\nl7 = l.count(7)\n\nif l5 == 2 and l7 == 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "A, B, C = map(int, input().split())\n\nif sorted([A, B, C]) == [5, 5, 7]:\n print('YES')\nelse:\n print('NO')", "# \u6574\u6570\u306e\u5165\u529b\na, b, c = map(int, input().split())\n# \u5408\u8a0817\u3067\u306a\u3044\u3068\u304dNO\u3092\u51fa\u529b\nif not (a+b+c == 17):\n print(\"NO\")\n return\n# 7\u3092\u542b\u307e\u306a\u3044\u3068\u304dNO\u3092\u51fa\u529b\nif not 7 in (a, b, c):\n print(\"NO\")\n return\n# 5\u3092\u542b\u307e\u306a\u3044\u3068\u304dNO\u3092\u51fa\u529b\u3001\u305d\u308c\u4ee5\u5916\u306fYES\u3092\u51fa\u529b\nif not 5 in (a, b, c):\n print(\"NO\")\n return\nelse:\n print(\"YES\")", "x = input()\nmode = 0\ncount = 0\nfor num in x.split(\" \"):\n if num == '5':\n mode+=1\n elif num =='7':\n mode+=4\n count+=1\n\nif mode == 6 and count == 3:\n print(\"YES\")\nelse:\n print(\"NO\")", "line = input()\n\nif line == '5 5 7' or line == '5 7 5' or line == '7 5 5':\n print('YES')\nelse:\n print('NO')", "print('YNEOS'[''.join(sorted(input().split()))!='557'::2])", "abc = sorted(list(map(int, input().split())))\nif abc[0] == abc[1] == 5 and abc[2] == 7:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s=input();z=s.count;print('YNEOS'[z('5')!=2or z('7')!=1::2])", "A = list(map(int, input().split()))\n\nans = 'NO'\n\nif A.count(5) == 2 and A.count(7) == 1:\n ans = 'YES'\n\nprint(ans)", "a = list(map(int, input().split()))\nif a.count(5) == 2 and a.count(7) == 1:\n print('YES')\nelse:\n print('NO')", "a = input()\nb = a.split()\n\nif b[0]==\"5\" and b[1]==\"5\" and b[2]==\"7\":\n print(\"YES\")\nelif b[0]==\"5\" and b[1]==\"7\" and b[2]==\"5\":\n print(\"YES\")\nelif b[0]==\"7\" and b[1]==\"5\" and b[2]==\"5\":\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = map(int, input().split())\niroha = [a, b, c]\nif iroha.count(5) == 2 and iroha.count(7) == 1:\n print(\"YES\")\nelse:\n print(\"NO\")", "a = list(map(int,input().split()))\n\na.sort()\n\nif a == [5,5,7]:\n print('YES')\nelse:\n print('NO')\n\n", "w=sorted(input().split())\ncri=[\"5\",\"5\",\"7\"]\nprint(\"YES\" if w==cri else \"NO\")", "phrases = sorted([int(x) for x in input().split()])\nif phrases[0] == 5 and phrases[1] == 5 and phrases[2] == 7:\n print('YES')\nelse:\n print('NO')\n", "a,b,c = list(map(int,input().split()))\nif a%5!=0 and a%7!=0:\n print('NO')\nelif b%5!=0 and b%7!=0:\n print('NO')\nelif c%5!=0 and c%7!=0:\n print('NO')\nelif a%7==0:\n if b%5==0 and c%5==0:\n print('YES')\n else:\n print('NO')\nelif b%7==0:\n if a%5==0 and c%5==0:\n print('YES')\n else:\n print('NO')\nelse:\n if a%5==0 and b%5==0:\n print('YES')\n else:\n print('NO')\n", "A, B, C = map(int, input().split())\nif A == 5 and B == 5 and C == 7:\n print(\"YES\")\nelif A == 5 and B == 7 and C == 5:\n print(\"YES\")\nelif A == 7 and B == 5 and C == 5:\n print(\"YES\")\nelse:\n print(\"NO\")", "a = list(map(int,input().split()))\nnum_5 = 0\nnum_7 = 0\n\nfor i in a:\n if i==5:\n num_5 = num_5+1\n if i==7:\n num_7 = num_7+1\n\nif num_5==2 and num_7==1:\n print(\"YES\")\nelse:\n print(\"NO\")", "x = input()\nstr_a = x.split(\" \")\narray=[0]*10\nfor s in str_a:\n array[int(s)]+=1\nif array[5]==2 and array[7]==1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "text = str(input())\ncnt = 0\n\nfor i in text:\n if i == \"5\":\n cnt += 1\n if i == \"7\":\n cnt += 2\n\nif cnt == 4:\n print(\"YES\")\nelse:\n print(\"NO\")", "nums = list(map(int, input().split()))\nif nums.count(5) == 2 and nums.count(7) == 1:\n print(\"YES\")\nelse:\n print(\"NO\")", "a = list(map(int, input().split()))\na.sort()\nprint(\"YES\") if a == [5, 5, 7] else print(\"NO\")\n", "a, b, c = map(int, input().split())\niroha = [a, b, c]\nif iroha.count(5) == 2 and iroha.count(7) == 1:\n print(\"YES\")\nelse:\n print(\"NO\")", "num=list(map(int,input().split()))\nnum.sort()\nprint(('YES' if num==[5,5,7] else 'NO'))\n", "li = list(map(int, input().split()))\ncount5 = count7 = 0\nfor l in li:\n if l == 5:\n count5 += 1\n elif l == 7:\n count7 += 1\n else:\n print(\"NO\")\n return\nif count5 == 2 and count7 == 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "arr = list(map(int, input().split()))\n\nif arr.count(5) == 2 and arr.count(7) == 1:\n print(\"YES\")\nelse:\n print(\"NO\")\n"] | {"inputs": ["5 5 7\n", "7 7 5\n"], "outputs": ["YES\n", "NO\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 16,918 | |
5c1ee998babc7c9980f1f0e56a2bb954 | UNKNOWN | It is November 18 now in Japan. By the way, 11 and 18 are adjacent Lucas numbers.
You are given an integer N. Find the N-th Lucas number.
Here, the i-th Lucas number L_i is defined as follows:
- L_0=2
- L_1=1
- L_i=L_{i-1}+L_{i-2} (iβ₯2)
-----Constraints-----
- 1β€Nβ€86
- It is guaranteed that the answer is less than 10^{18}.
- N is an integer.
-----Input-----
Input is given from Standard Input in the following format:
N
-----Output-----
Print the N-th Lucas number.
-----Sample Input-----
5
-----Sample Output-----
11
- L_0=2
- L_1=1
- L_2=L_0+L_1=3
- L_3=L_1+L_2=4
- L_4=L_2+L_3=7
- L_5=L_3+L_4=11
Thus, the 5-th Lucas number is 11. | ["n=int(input())\na,b=2,1\nfor i in range(n):\n nxt=a+b\n a,b=b,nxt\nprint(a)", "n=int(input())\ndef fibonacci(n):\n fib = [2, 1]\n for i in range(2, n):\n fib.append(fib[i - 2] + fib[i - 1])\n \n return fib[n -1]\nprint(fibonacci(n+1))", "n = int(input())\nlucas = [2,1]\nfor i in range(2,n+1):\n lucas.append(lucas[-2]+lucas[-1])\nprint(lucas[-1])", "n = int(input())\n\nnum_list = [0]*(n+1)\nnum_list[0] = 2\nnum_list[1] = 1\nfor i in range(2, n+1,1):\n num_list[i] = num_list[i-1] + num_list[i-2]\n\nans = num_list[n]\nprint(ans)", "N = int(input())\nl1 = 2\nl2 = 1\n\nfor i in range(N-1):\n l1, l2 = l2, l1 + l2\nprint(l2)\n", "n = int(input())\nif n == 1:\n print(1)\nelse:\n x = [2, 1]\n for i in range(2, n+1):\n x.append(x[i-2] + x[i-1])\n print(x[n])", "n=int(input())\nlucas=[2,1]\nfor i in range(2,n+1):\n lucas.append(lucas[i-1]+lucas[i-2])\nprint(lucas[-1])", "n = int(input())\na = 2\nb = 1\nfor i in range(n-1):\n c=b+a\n a,b=b,c\nif n == 0:\n print(a)\nelif n == 1:\n print(b)\nelse:\n print(c)", "N = int(input())\n\nif N == 0:\n print(2)\nelif N == 1:\n print(1)\nelse:\n \n n_2 = 2\n n_1 = 1\n \n for _ in range(N-1):\n n_0 = n_1 + n_2\n n_2 = n_1\n n_1 = n_0\n \n \n print(n_0)", "import numpy as np\nn = int(input())\nl = np.zeros(87,dtype=int)\nl[0] = 2\nl[1] = 1\nfor i in range(2,87):\n l[i] = l[i-1] + l[i-2]\nprint(l[n])", "n = int(input())\na, b = 2, 1\nfor i in range(n):\n a, b = b, a+b\nprint(a)\n", "N = int(input())\n\nL = [2, 1]\n\nfor i in range(N-1):\n if i == 0:\n L.append(L[0] + L[1])\n else:\n L.append(L[i] + L[i+1])\n\nprint((L[-1]))\n", "n = int(input())\nl0 = 2\nl1 = 1\nsum_ = 1\nfor i in range(n-1):\n sum_ = l0 + l1\n l0 = l1\n l1 = sum_\nprint(sum_)", "\nn = int(input())\na_ = 2\na = 1\nfor i in range(n-1):\n a, a_ = a + a_, a\nprint(a)", "n = int(input())\ncalc_r = [0]*(n+1)\ncalc_r[0] = 2\ncalc_r[1] = 1\n\nfor i in range(2,n+1):\n calc_r[i] = calc_r[i-1] + calc_r[i-2]\nans = calc_r[n]\nprint(ans)", "n=int(input())\ns=[]\ns.append(2)\ns.append(1)\nif n==1:\n print('1')\n return\nelse:\n for i in range(2,87):\n k = s[i-2]+s[i-1]\n s.append(k)\n if i==n:\n print((s[i]))\n return\n", "n = int(input())\n\narr = [0 for i in range(n+1)]\narr[0] = 2\narr[1] = 1\nfor i in range(2,n+1):\n arr[i] = arr[i-1] + arr[i-2]\nprint(arr[n])", "n = int(input())\nluk = [2,1]\nfor i in range(2,n+1):\n luk.append(luk[i-1]+luk[i-2])\nprint(luk[-1])", "N = int(input())\nL = [0] * 100\nL[0] = 2\nL[1] = 1\nfor i in range(2,N + 1):\n L[i] = L[i - 1] + L[i - 2]\nprint(L[N])", "n = int(input())\nl = [2, 1]\n\nfor i in range(85):\n l.append(l[-2]+l[-1])\n\nprint(l[n])", "N = int(input())\n\nif N == 0:\n print((2))\n return\nelif N == 1:\n print((1))\n return\n\nL_2 = 2\nL_1 = 1\nfor i in range(N-1):\n L = L_1+L_2\n L_2 = L_1\n L_1 = L\nprint(L)\n", "N = int(input())\na,b = 2,1\nfor i in range(N):\n a,b = b,(a+b)\nprint(a)", "def answer(n: int) -> int:\n if n == 1:\n return 1\n\n two_previous_l = 2\n previous_l = 1\n l = 3\n for _ in range(n - 2):\n two_previous_l = previous_l\n previous_l = l\n l = previous_l + two_previous_l\n\n return l\n\n\ndef main():\n n = int(input())\n print((answer(n)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nif n == 0:\n print(2)\n return\nelif n == 1:\n print(1)\n return\n \nq = [2,1]\nfor i in range(2,88):\n m = q[i-1]+q[i-2]\n q.append(m)\n \nprint(q[n])", "n = int(input())\nLuca = [0]*100\nLuca[0] = 2\nLuca[1] = 1\n\nfor i in range(2,n+1):\n Luca[i] = Luca[i-1] + Luca[i-2]\n\nprint(Luca[n])", "N = int(input())\n\nlucas_list = []\n\nfor i in range(N + 1):\n if i == 0:\n lucas_list.append(2)\n elif i == 1:\n lucas_list.append(1)\n else:\n lucas_list.append(lucas_list[-1] + lucas_list[-2])\nelse:\n print(lucas_list[-1])", "n= int(input())\na,b,c = 2,1,3\nfor i in range(n):\n a,b,c=b,c,b+c\nprint(a)", "n = int(input())\nif n == 0:\n print(2)\nelif n == 1:\n print(1)\nelse:\n a = 2\n b = 1\n for i in range(2, n + 1):\n c = b\n b += a\n a = c\n print(b)", "n = int(input())\nl1 = 2\nl2 = 1\nl = 1\nfor i in range(n-1):\n l = l1+l2\n l1, l2 = l2, l\nprint(l)", "import sys\nN = int(input())\nif(N==1):\n print(1)\n return\nans = 0\nL0 = 2\nL1 = 1\nfor i in range(N-1):\n ans = L0 + L1\n L0 = L1\n L1 = ans\nprint(ans)", "N = int(input())\n\nL = [2, 1]\nif N < 2:\n print(L[N])\nelse:\n for i in range(2, N+1):\n L.append(L[i-2]+L[i-1])\n print(L[-1])", "n = int(input())\nl =[2,1]\nfor i in range(2,n+1):\n l.append(l[i-1]+l[i-2])\nprint(l[n])", "n = int(input())\nluca = [0 for i in range(n+1)]\nluca[0] = 2\nluca[1] = 1\nfor j in range(2,n+1):\n luca[j] = luca[j-1] + luca[j-2]\nprint(luca[n])", "N = int(input())\ndp = [[]for i in range(87)] \ndp[0] = 2\ndp[1] = 1\n\nfor i in range(2,87):\n dp[i] = dp[i-1]+dp[i-2]\n if i == N:\n print(dp[i])\n break\nelse:\n print(dp[N])", "n=int(input())\nl=[0 for i in range(n+1)]\nl[0]=2\nl[1]=1\nfor j in range(2,n+1):\n l[j]=l[j-1]+l[j-2]\nprint(l[n])", "a=int(input())\nL=[2,1]\nfor i in range(a-1):\n L.append(L[i]+L[i+1])\nprint(L[a])", "n = int(input())\nlyca = [2,1]\nfor i in range(2,87):\n lyca.append(lyca[i-1]+lyca[i-2])\nprint(lyca[n])", "n = int(input())\nl0 = 2\nl1 = 1\n\nif n == 1:\n print(l1)\nelse:\n for i in range(n-1):\n ln = l0 + l1\n l0 = l1\n l1 = ln\n print(ln)", "N = int(input())\nl = [2,1]\nif N == 1 :\n print(l[1])\n return\nfor i in range(2,N+1) :\n l.append(l[i-2] + l[i-1])\nprint(l[-1])", "N = int(input())\nL = [2, 1]\ni = 0\nwhile i < N:\n buff = L[0]\n L[0] = L[1]\n L[1] += buff\n i += 1\nprint((L[0]))\n", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\nN = int(input())\nL=[2,1]\nfor i in range(N-1):\n L.append(L[i]+L[i+1])\n\nprint(L[N])", "from collections import defaultdict\n\n\ndef mapt(fn, *args):\n return tuple(map(fn, *args))\n\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\n\ndef main():\n n = int(input())\n l = defaultdict(int)\n l[0], l[1] = 2, 1\n for i in range(2, n+1):\n l[i] = l[i-1] + l[i-2]\n print(l[n])\n\n\nmain()", "n = int(input())\na = 2\nb = 1\nc = 3\nfor i in range(n):\n c = b + a\n a = b\n b = c\nprint(a)", "N = int(input())\n\nL = [2, 1]\n\nif N <= 1:\n print(L[N])\n return\nelse:\n for i in range(N-1):\n L.append(L[-1] + L[-2])\n\nprint(L[-1])", "def main():\n N = int(input())\n L = [2, 1]\n for i in range(1, N):\n L.append(L[i-1]+L[i])\n print(L[-1])\nmain()", "N = int(input())\nl_list = [2,1]\nfor i in range(2,N+1):\n a = l_list[i-1] + l_list[i-2]\n l_list.append(a)\nprint(l_list[N])", "N = int(input())\nL = [0] * (N+1)\nL[0] = 2\nL[1] = 1\nfor i in range(2,N+1):\n L[i] = L[i-1] + L[i-2]\nprint((L[N]))\n", "n=int(input())\na=2\nb=1\ni=0\nwhile i<n:\n d=a\n a=b\n b=d+b\n i=i+1\nprint(a)", "N = int (input ())\nL1,L2 = 2,1\nL3 = 1\nx = 1\nfor i in range (N-1):\n if x == 1:\n L1 = L1+L2\n L3 = L1\n x = 2\n else:\n L2 = L1+L2\n L3 = L2\n x = 1\nprint (L3)", "N = int(input())\nL = [0] * (N+1)\nL[0] = 2\nL[1] = 1\nfor i in range(2,N+1):\n L[i] = L[i-1] + L[i-2]\nprint(L[N])", "N = int(input())\nl = [2, 1]\nif N == 1:\n print(1)\nelse:\n for i in range(2, N+1):\n l.append(l[i-2] + l[i-1])\n print(l[-1])", "n=int(input())\n\nif n==1:\n print(1)\nelif n==2:\n print(3)\nelse:\n ans=0\n num_1=2\n num_2=1\n for i in range(n-1):\n ans = num_1+num_2\n num_1,num_2 = num_2, ans\n print(ans)", "# coding = SJIS\n\nn = int(input())\n\nluca = [2, 1]\n\nif n >= 2:\n for i in range(n - 1):\n luca.append(luca[-1] + luca[-2])\n print(luca[-1])\n\nelse:\n print(1)", "N = int(input())\nL = [2, 1]\n\nfor i in range(2, N + 1):\n L.append(L[i - 1] + L[i - 2])\n\nprint((L[N]))\n", "N = int(input())\n\nif N == 1:\n print(1)\n return\n\nL1 = 1\nL0 = 2\n\nfor i in range(2,N+1):\n LC = L1 + L0\n L0 = L1\n L1 = LC\n \nprint(LC)", "import sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = 10**20\ndef I(): return int(input())\ndef F(): return float(input())\ndef S(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LS(): return input().split()\n\ndef resolve():\n N = I()\n\n lucas = [0] * (N + 1)\n lucas[0] = 2\n lucas[1] = 1\n for i in range(N - 1):\n lucas[i+2] = lucas[i] + lucas[i+1]\n\n print((lucas[-1]))\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "def __starting_point():\n\n n = int(input())\n\n A = [2,1]\n for i in range(2,n+1):\n A.append(A[i-2] + A[i-1])\n print(A[n])\n__starting_point()", "n = int(input())\nl = [0] * (n+1)\nl[0] = 2\nl[1] = 1\n\nif n == 1:\n ans = l[1]\nelse:\n for i in range(2, n+1):\n l[i] = l[i-1] + l[i-2]\n ans = l[-1]\nprint(ans)", "from functools import lru_cache\nN = int(input())\n@lru_cache(86)\ndef lucas(x):\n if x == 0:\n return 2\n if x ==1:\n return 1\n else:\n \n return lucas(x-1) + lucas(x-2)\nprint(lucas(N))", "n = int(input())\nimport sys\ndp = [0]*(n+3)\n\ndp[0]=2\ndp[1]=1\nif n<=1:\n print(dp[n])\n return\n\nfor i in range(2,n+1):\n dp[i]=dp[i-1]+dp[i-2]\n\nprint(dp[n])", "#79B\nN=int(input())\ndata=[2]\ndata.append(1)\nfor i in range(2,N+1):\n data.append(data[i-1]+data[i-2])\n \nprint(data[N]) ", "n = int(input())\nl = [2,1]\nif n == 0:\n print(2)\nelif n == 1:\n print(1)\nelse:\n for i in range(n-1):\n l.append(l[-1]+l[-2])\n print(l[-1])", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\n\nif n == 1:\n print((1))\n return\n\na = 2\nb = 1\nnow = 3\ncount = 2\nfor i in range(2, n):\n a = b\n b = now\n now = a+b\n\nprint(now)\n", "N = int(input())\nANS = [2, 1]\nfor i in range(1, N):\n ANS.append(ANS[i]+ANS[i-1])\nprint(ANS[N])", "n = int(input())\n\nlucas = [2, 1]\nfor i in range(2, n+1):\n lucas.append(lucas[i-1] + lucas[i-2])\n\nprint(lucas[-1])", "n = int(input())\nl = []\nl.append(2)\nl.append(1)\n\nfor i in range(2, n + 1):\n l.append(l[i - 1] + l[i - 2])\nprint(l[-1])", "N = int(input())\n\nL = [2, 1]\nfor i in range(2, N+1):\n L.append(L[i-1] + L[i-2])\nprint((L[N]))\n", "N=int(input())\ns=2\nt=1\nfor i in range(0,N):\n u=s+t\n s,t,u=t,u,s # s\u306e\u5909\u63db\u3092t\u306b\u3057\u305f\u3002\n \nprint(s)\n", "N = int(input())\n\n\ndef luca(n):\n a = 1\n b = 2\n for i in range(n):\n a, b = a+b, a\n return b\n\n\nprint(luca(N))", "\nN = int(input())\nL = [2, 1] + [0] * (N-1)\nfor i in range(2, N+1):\n L[i] = L[i-1] + L[i-2]\n\nprint(L[N])", "n = int(input())\ndata = [0]*87\ndata[0] = 2\ndata[1] = 1\nif n >= 2:\n for i in range(2,n+1):\n data[i] =data[i-1] + data[i-2]\nprint(data[n])", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n numbers=[2,1]\n number = int(input())\n\n for i in range(2,number+1):\n numbers.append(numbers[i-1]+numbers[i-2])\n print(numbers[-1])\n \ndef __starting_point():\n main()\n__starting_point()", "N=int(input())\nL=[0]*(N+1)\nL[0]=2\nL[1]=1\nif N==1 :\n print(1)\nelse :\n for i in range(2,N+1) :\n L[i]=L[i-1]+L[i-2]\n print(L[N])", "li=[2,1]\nN=int(input())\nfor i in range(N):\n li.append(li[i]+li[i+1])\nprint((li[N]))\n", "n = int(input())\n\nL0, L1 = 2, 1\nif n == 1:\n print(L1)\nelse:\n for _ in range(n - 1):\n L = L0 + L1\n L0, L1 = L1, L\n print(L)", "n = int(input())\n\na = [2,1]\n\nfor x in range(n-1):\n a.append(a[x] + a[x+1])\n \nprint(a[-1])", "n = int(input())\nlist_lucas = [2, 1]\nlucas = 0\nfor i in range(0, n - 1):\n lucas = list_lucas[i] + list_lucas[i + 1]\n list_lucas.append(lucas)\n lucas = 0\nprint(list_lucas[-1])", "n = int(input())\na = [2,1]\nfor i in range(2,n+1):\n a.append(a[i-1]+a[i-2])\nprint(a[n])", "#\n# abc079 b\n#\nimport sys\nfrom io import StringIO\nimport unittest\nfrom functools import lru_cache\n\nsys.setrecursionlimit(10**9)\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"5\"\"\"\n output = \"\"\"11\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"86\"\"\"\n output = \"\"\"939587134549734843\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n\n print((L(N)))\n\n\n@lru_cache(maxsize=1000)\ndef L(n):\n if n == 0:\n return 2\n elif n == 1:\n return 1\n else:\n return L(n-1) + L(n-2)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "from functools import lru_cache\n\n@lru_cache\ndef lucas(n):\n if n == 0:\n return 2\n if n == 1:\n return 1\n else:\n return lucas(n-1)+lucas(n-2)\n\nN = int(input())\nprint((lucas(N)))\n", "N=int(input())\nL=[2,1]\nfor _ in range(N-1):\n L.append(L[-1]+L[-2])\nprint((L[-1]))\n", "N = int(input())\nres = [2, 1]\n\nfor i in range(N-1):\n res.append(res[-1] + res[-2])\nprint(res[-1])", "n = int(input())\nli = [2,1]\nfor i in range(1,n):\n li.append(li[i]+li[i-1])\nprint((li[-1]))\n", "a = 2\nb = 1\nfor i in range(int(input())):\n a, b = b, a + b\nprint(a)", "n = int(input())\nl = [2, 1]\nfor i in range(n-1):\n L = l[i] + l[i+1]\n l.append(L)\nprint(l[n])", "l = [2, 1] + [0] * 100\nfor i in range(2, 87):\n l[i] = l[i - 1] + l[i - 2]\nprint(l[int(input())])", "n = int(input())\nl = [2, 1]\nfor i in range(2, 90):\n x = l[i-2] + l[i-1]\n l.append(x)\n\nprint((l[n]))\n", "\nN = int(input())\nL = [2, 1]\nif N == 1:\n print(1)\n return\n\nfor i in range(2, N+1):\n L[i % 2] = sum(L)\nprint(L[N % 2])", "N = int(input())\n\nL = [2, 1]\nfor i in range(2, N+1):\n L.append(L[i-2] + L[i-1])\n\nprint(L[-1])", "n = int(input())\n\na = [0] * (n + 1)\na[0] = 2\na[1] = 1\nfor i in range(2, n + 1):\n a[i] = a[i - 1] + a[i - 2]\n\nprint((a[n]))\n", "n = int(input())\nl = [2, 1]\nfor _ in range(n - 1):\n l.append(l[-2] + l[-1])\nprint(l[-1])", "N = int(input())\nls = [0] * (N + 1)\n\nls[0], ls[1] = 2, 1\n\nfor i in range(2,N+1):\n ls[i] += ls[i-1] + ls[i-2]\n \nprint(ls[N])", "n = int(input())\nif n == 1:\n print(1)\n return\nx = 2\ny = 1\nans = 0\nfor i in range(n-1):\n ans = x + y\n x = y\n y = ans\nprint(ans)", "n = int(input())\na,b = 2,1\nfor i in range(n):\n a,b=b,a+b\nprint(a)", "n = int(input())\nl = [2, 1]\n\nfor i in range(2, n + 1):\n li = l[i - 1] + l[i - 2]\n l.append(li)\nprint(l[len(l) - 1])", "lst = list()\nlst.append(2)\nlst.append(1)\n\nn = int(input())\nfor i in range(2, n + 1):\n ans = lst[i - 2] + lst[i - 1]\n lst.append(ans)\n\nprint(lst[n])", "n = int(input())\nl = [0] * (n+1)\nl[0] = 2\nl[1] = 1\n\nif n == 1:\n ans = l[1]\nelse:\n for i in range(2, n+1):\n l[i] = l[i-1] + l[i-2]\n ans = l[-1]\nprint(ans)", "def resolve():\n '''\n code here\n '''\n N = int(input())\n\n memo = [0 for _ in range(N+1)]\n memo[:2] = [2, 1]\n\n for i in range(2, N+1):\n memo[i] = memo[i-1] + memo[i-2]\n\n print((memo[N]))\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "n = int(input())\nl = [2,1]\n\nfor i in range(2,n+1):\n l.append(l[i-2]+l[i-1])\n\nprint(l[n])"] | {"inputs": ["5\n", "86\n"], "outputs": ["11\n", "939587134549734843\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 16,095 | |
99b112ab2a521ed07053572880a3a46a | UNKNOWN | You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.
An example of a trapezoid
Find the area of this trapezoid.
-----Constraints-----
- 1β¦aβ¦100
- 1β¦bβ¦100
- 1β¦hβ¦100
- All input values are integers.
- h is even.
-----Input-----
The input is given from Standard Input in the following format:
a
b
h
-----Output-----
Print the area of the given trapezoid. It is guaranteed that the area is an integer.
-----Sample Input-----
3
4
2
-----Sample Output-----
7
When the lengths of the upper base, lower base, and height are 3, 4, and 2, respectively, the area of the trapezoid is (3+4)Γ2/2 = 7. | ["\na = int(input())\nb = int(input())\nh = int(input())\ns = (a+b)*h/2\nprint(int(s))", "# \u5165\u529b\na = int(input())\nb = int(input())\nh = int(input())\n\n# \u51e6\u7406\narea = (a + b) * h // 2\n\n# \u51fa\u529b\nprint(area)", "a,b,h=list(map(int,(input(),input(),input())))\nprint(((a+b)*h//2))\n\n", "a = int(input())\nb = int(input())\nc = int(input())\n \nprint(int(((a + b) * c) /2))", "a = int(input())\nb = int(input())\nh = int(input())\nprint((a+b)*h//2)", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint((a + b) * h // 2)", "a, b, h = int(input()), int(input()), int(input())\n\nprint(int((a+b)*h/2))", "a = int(input())\nb = int(input())\nh = int(input())\nprint((a + b) * h // 2)", "a,b,h = [int(input()) for _ in range(3)]\nprint(round(((a + b)*h)/2))", "a,b,c=[int(input()) for i in range(3)]\nprint(int(a+b)*c//2)", "a = [int(input()) for i in range(3)]\nprint((a[0]+a[1])*a[2]//2)", "a=int(input())\nb=int(input())\nh=int(input())\n\nprint((a+b)*h//2)", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint((b + a) * h // 2)", "import math\na = int(input())\nb = int(input())\nh = int(input())\n\nanswer = (a + b) * h / 2\n\nprint(math.ceil(answer))", "a = int(input())\nb = int(input())\nh = int(input())\nprint((a+b)*h//2)", "from sys import stdin\ninput = stdin.readline\n\na = int(input())\nb = int(input())\nh = int(input())\n\nprint((a+b)*h//2)", "a = int(input())\nb = int(input())\nh = int(input())\n\nans = (a + b) * h / 2\nprint(int(ans))", "a = int(input())\nb = int(input())\nh = int(input())\nprint((a+b)*h//2)", "# 045_a\na = int(input()) # \u4e0a\u5e95\u306e\u9577\u3055\nb = int(input()) # \u4e0b\u5e95\u306e\u9577\u3055\nh = int(input()) # \u9ad8\u3055\n\nif (1 <= a & a <= 100) & (1 <= b & b <= 100) & (1 <= h & h <= 100):\n if (h % 2 == 0):\n s = int((a + b) * h / 2)\n print(s)", "a = int(input())\nb = int(input())\nh = int(input())\nprint((int((a + b) * h / 2)))\n", "a=int(input())\nb=int(input())\nh=int(input())\n\nprint(int((a+b)*h/2))", "a,b,h=[int(input()) for i in range(3)]\nprint(int((a+b)/2*h))", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint(int((a+b)*h*0.5))", "a=int(input())\nb=int(input())\nh=int(input())\nprint(int((a+b)*h/2))", "a,b,h = [int(input()) for i in range(3)]\nprint(int((a+b)/2*h))", "a = int(input())\nb = int(input())\nh = int(input())\nprint((int((a + b)*h/2)))\n", "a=int(input())\nb=int(input())\nh=int(input())\n\nprint(int((a+b)*h/2))", "# \u53f0\u5f62\u306e\u9762\u7a4d\n# \uff08\u4e0a\u5e95 + \u4e0b\u5e95\uff09* \u9ad8\u3055 / 2\n\n# \u5165\u529b\na = int(input())\nb = int(input())\nh = int(input())\n\n# \u51e6\u7406\nanswer = int((a + b) * h / 2)\nprint(answer)\n", "a = int(input())\nb = int(input())\nh = int(input())\nprint((a + b) * h // 2)", "# \u6570\u5024\u306e\u53d6\u5f97\na = int(input())\nb = int(input())\nh = int(input())\n \n# \u9762\u7a4d\u3092\u6c42\u3081\u3066\u51fa\u529b\narea = int((a + b) * h / 2)\nprint(area)", "a,b,c=[int(input()) for i in range(3)]\nprint(((a+b)*c//2))\n", "a = int(input())\nb = int(input())\nh = int(input())\n\n\nprint((((a + b) * h) // 2))\n", "a=int(input())\nb=int(input())\nc=int(input())\nprint((a+b)*c//2)", "L = [int(input()) for _ in range(3)]\nprint((L[0]+L[1])*L[2]//2)", "a = int(input())\nb = int(input())\nh = int(input())\nz =int((a + b)*h/2)\nprint(z)", "a = int(input()) # \u4e0a\u8fba\nb = int(input()) # \u4e0b\u8fba\nh = int(input()) # \u9ad8\u3055\n\nprint((a + b) * h // 2)", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint((a + b) * h // 2)", "a = int(input())\nb = int(input())\nh = int(input())\ns = (a + b) * h // 2\nprint(s)", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint(int((a + b) * h / 2))", "a,b,h=[int(input()) for i in range(0,3)]\nprint(((a+b)*h//2))\n", "a=int(input())\nb=int(input())\nh=int(input())\n\nprint((a+b)*h//2)", "a = int(input())\nb = int(input())\nh = int(input())\n\nret = (a+b)*h//2\nprint(ret)", "a, b, h = [int(input()) for _ in range(3)]\nprint((a + b) * h // 2)", "a = int(input())\nb =int(input())\nh = int(input())\n \nprint(int(((a+b)*h)/2))", "# \u4e0a\u5e95\u306e\u9577\u3055\u304ca\u3001\u4e0b\u5e95\u306e\u9577\u3055\u304cb\u3001\u9ad8\u3055\u304ch\u306e\u53f0\u5f62\u306e\u9762\u7a4d\n\na = int(input())\nb = int(input())\nh = int(input())\n\nprint(((a + b) * h // 2))\n", "a = int(input())\nb = int(input())\nh = int(input())\n\narea = (a+b)*(h/2)\nprint(int(area))", "a=int(input())\nb=int(input())\nh=int(input())\nprint(int((a+b)*h/2))", "a = int(input())\nb = int(input())\nh = int(input())\nprint(int((a + b) * h / 2))", "a, b, h = [int(input()) for i in range(3)]\n\nprint((int((a + b) * h / 2)))\n", "a = []\nfor i in range (3):\n b = int(input())\n a.append(b)\nprint(int((a[0]+a[1])*a[2]/2))", "a = int(input())\nb = int(input())\nh = int(input())\nprint('{:.0f}'.format(h/2*(a+b)))", "a = int(input())\nb = int(input())\nh = int(input())\ns = (a+b)*h/2\nprint(int(s))", "val = [int(input()) for i in range(3)]\nprint(int((val[0] + val[1]) * val[2] / 2))", "import math\nfrom datetime import date\n\ndef main():\n\t\n\ta = int(input())\n\tb = int(input())\n\th = int(input())\n\n\tarea = (a + b) * h // 2\n\tprint(area)\n\nmain()\n", "\"\"\"\nABC045 A A - \u53f0\u5f62\nhttps://atcoder.jp/contests/abc045/tasks/abc045_a\n\"\"\"\n\nn = [int(input()) for i in range(3)]\n\nprint(((n[0]+n[1])*n[2]//2))\n", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint((a + b) * h // 2)", "a = int(input())\nb = int(input())\nh = int(input())\nprint(int(((a+b)*h)/2))", "a=int(input())\nb=int(input())\nh=int(input())\nprint(((a+b)*h//2))\n", "a = int(input())\nb = int(input())\nh = int(input())\nS = (a+b)*h/2\nprint(round(S))", "a = int(input())\nb = int(input())\nh = int(input())\nprint(round(h/2*(a+b)))", "print(int((int(input())+int(input()))*int(input())/2))", "a = int(input())\nb = int(input())\nh = int(input())\n\nans = (a+b) * h // 2\nprint(ans)", "A, B, H = [int(input()) for _ in range(3)]\nprint((A+B)*H//2)", "def solve():\n a = int(input())\n b = int(input())\n h = int(input())\n print((a + b) * h // 2)\n\n\ndef __starting_point():\n solve()\n__starting_point()", "def solve(a, b, h):\n ans = (a+b)*h//2\n return ans\n\n\ndef __starting_point():\n a = int(input())\n b = int(input())\n h = int(input())\n print((solve(a, b, h)))\n\n__starting_point()", "a,b,h=[int(input()) for i in range(3)]\n\nprint((a+b)*h//2)", "a,b,c = [int(input()) for i in range(3)]\n\nprint(round((a+b)*c/2))", "a = int(input())\nb = int(input())\nh = int(input())\nprint(int(0.5 * h * (a + b)))", "a,b,h = [int(input()) for i in range(3)]\nprint(int((a+b)*(h/2)))", "a=int(input())\nb=int(input())\nh=int(input())\nprint((a+b)*h//2)", "a, b, h = int(input()), int(input()), int(input())\nprint((a+b)*h//2)", "# import math\n# import statistics\n# a=input()\n#b,c=int(input()),int(input())\n# c=[]\n# for i in a:\n# c.append(i)\n#e1,e2,e3 = map(int,input().split())\n#f = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\n# h = []\n# for i in range(e1):\n# h.append(list(map(int,input().split())))\n\na = int(input())\nb = int(input())\nh = int(input())\nprint(int((a+b)*h/2))", "a = int(input())\nb = int(input())\nh = int(input())\nprint((a+b) * h // 2)", "a = int(input())\nb = int(input())\nc = int(input())\n\nprint(((a+b)*c//2))\n", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint(((a+b)*h)//2)", "def iroha():\n a, b, c = [int(input()) for i in range(3)]\n num = (a+b)*c / 2\n result = int(num)\n print(result)\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint(int(((a + b) * h) / 2))", "a,b,h = [int(input()) for _ in range(3)]\nprint((a+b)*h//2)", "a=int(input())\nb=int(input())\nh=int(input())\nprint(int((a+b)*h/2))", "a = int(input())\nb = int(input())\nh = int(input())\n\nanswer = (a + b) * h // 2\n\nprint(answer)", "a = int(input())\nb = int(input())\nc = int(input())\n\nprint(((b + a) * c) // 2)", "a = int(input())\nb = int(input())\nx = int(input())\nprint((a+b)*x // 2)", "a = int(input()) \nb = int(input()) \nh = int(input())\nprint((int((a + b) * h / 2)))\n", "a,b,h=[int(input()) for _ in range(3)];print((a+b)*h//2)", "a = int(input())\nb = int(input())\nh = int(input())\ns = (a + b) * h / 2\nprint(int(s))", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint(((a+b)*h)//2)", "a = int(input())\nb = int(input())\nc = int(input())\nprint(int((a + b) / 2 * c))", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint(((a + b)*h//2))\n", "a = int(input())\nb = int(input())\nh = int(input())\nprint(int((a+b)*h/2))", "a=int(input())\nb=int(input())\nh=int(input())\n\nprint((a+b)*h//2)", "#\n# abc045 a\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"3\n4\n2\"\"\"\n output = \"\"\"7\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"4\n4\n4\"\"\"\n output = \"\"\"16\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n a = int(input())\n b = int(input())\n h = int(input())\n print(((a+b)*h//2))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "#45\na=int(input())\nb=int(input())\nh=int(input())\nif h%2==0:\n print(int((a+b)*h/2))", "a = int(input())\nb = int(input())\nh = int(input())\n\nprint(((a + b) * h // 2))\n", "a = int(input())\nb = int(input())\nh = int(input())\n\ny = (a + b)*h/2\nprint((int(y)))\n\n", "a=int(input())\nb=int(input())\nh=int(input())\nans=max(a,b)*h-(abs(b-a)*h//2)\nprint(ans)", "import sys\na, b, h =map(int, sys.stdin.readlines())\nprint((a+b)*h//2)", "a = [int(input()) for i in range(3)]\nprint((int((a[0]+a[1])*a[2]/2)))\n", "a = int(input())\nb = int(input())\nh = int(input())\nprint(((a+b)*h)//2)", "a=int(input())\nb=int(input())\nh=int(input())\nprint((a+b)*h//2)", "a,b,h=int(input()),int(input()),int(input())\nprint((a+b)*h//2)"] | {"inputs": ["3\n4\n2\n", "4\n4\n4\n"], "outputs": ["7\n", "16\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 10,478 | |
c8a46dc0a35e9c0aa611fff19a311ae4 | UNKNOWN | Given are N integers A_1,\ldots,A_N.
Find the sum of A_i \times A_j over all pairs (i,j) such that 1\leq i < j \leq N, modulo (10^9+7).
-----Constraints-----
- 2 \leq N \leq 2\times 10^5
- 0 \leq A_i \leq 10^9
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
N
A_1 \ldots A_N
-----Output-----
Print \sum_{i=1}^{N-1}\sum_{j=i+1}^{N} A_i A_j, modulo (10^9+7).
-----Sample Input-----
3
1 2 3
-----Sample Output-----
11
We have 1 \times 2 + 1 \times 3 + 2 \times 3 = 11. | ["(N), *D = [list(map(int, s.split())) for s in open(0)]\nV = D[0]\nA = V.pop(N[0]-1)\nM = 1000000000 + 7\nR=0\nfor value in reversed(V):\n R = R + ((A) * value) % M\n A = A + value\nprint(R % M)", "def main():\n N=int(input())\n CONST= 10**9+7\n Output = 0\n lis = list(map(int,input().split())) \n lis.sort()\n SumLis = [0]*N\n for i,item in enumerate(lis):\n SumLis[i] += SumLis[i-1]+item\n for i,item in enumerate(lis):\n Output += lis[i] * (SumLis[-1]-SumLis[i])\n Output %= CONST\n print(Output)\n\n \ndef __starting_point():\n main()\n\n\n__starting_point()", "def cumsum(xs):\n result = [xs[0]]\n for x in xs[1:]:\n result.append(result[-1] + x)\n return result\n\nN = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nMOD = 10**9 + 7\nA.reverse()\nruisekiwa = cumsum(A)\nruisekiwa.reverse()\nA.reverse()\n\nfor i in range(N-1):\n ans = (ans + A[i] * ruisekiwa[i+1]) % MOD\n\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\ns = [0]\nfor i in range(n):\n\ts.append(s[i] + a[i])\nans = sum(a[i] * (s[n]-s[i+1]) for i in range(n))\nprint(ans % (10**9 + 7))", "n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\ns = sum(a)\nans = 0\n\nfor x in a:\n s -= x\n ans += s * x\n \nprint(ans%mod)", "N = int(input())\nA = list(map(int, input().split()))\nA2 = [A[0]]\nmod = 10 ** 9 + 7\nres = 0\nfor i in range(1, N):\n A2.append((A2[i-1] + A[i]) % mod)\nfor i in range(N-1):\n res = (res + A[i] * (A2[N-1] - A2[i])) % mod\nprint(res)", "n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\nans = 0\ns = sum(a)\n\nfor x in a:\n s -= x\n ans += s * x\n ans %= mod\n \nans %= mod\nprint(ans)", "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr = 0\n\n\ndef cumsum(xs):\n result = []\n for i in range(len(xs)):\n if i == 0:\n result.append(xs[0])\n else:\n result.append(result[-1] + xs[i])\n return result\n\n\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N-1):\n r += (numbers[i]*num_sum[i])%CONST\nprint((r % CONST))\n", "import math\nprime = [True for i in range(10**6+1)]\ndef SieveOfEratosthenes(n): \n\tp = 2\n\twhile (p * p <= n): \n\t\tif (prime[p] == True):\n\t\t\tfor i in range(p * p, n+1, p): \n\t\t\t\tprime[i] = False\n\t\tp += 1\n\ndef __starting_point():\n\tN = int(input())\n\tL = list(map(int,input().split()))\n\tMOD = 10**9 + 7\n\tsum_L = sum(L)\n\tans = 0\n\tfor i in range(N - 1):\n\t\tsum_L = sum_L - L[i]\n\t\tans = (ans + sum_L*L[i])%MOD\n\tprint(ans)\n\n\n\n\n\n__starting_point()", "import math\nprime = [True for i in range(10**6+1)]\ndef SieveOfEratosthenes(n): \n\tp = 2\n\twhile (p * p <= n): \n\t\tif (prime[p] == True):\n\t\t\tfor i in range(p * p, n+1, p): \n\t\t\t\tprime[i] = False\n\t\tp += 1\n\ndef __starting_point():\n\tN = int(input())\n\tL = list(map(int,input().split()))\n\tMOD = 10**9 + 7\n\tsum_L = sum(L)\n\tans = 0\n\tfor i in range(N - 1):\n\t\tsum_L = sum_L - L[i]\n\t\tans = (ans + sum_L*L[i])%MOD\n\tprint(ans)\n\n\n\n\n3\n__starting_point()", "N = int(input())\nA = list(map(int, input().split()))\nmod = 10**9+7\n\n# result = 0\n# for i in range(N):\n# for j in range(N):\n# if i < j:\n# result += (A[i] * A[j]) % mod\n\n# print(result % mod)\n\n# result = 0\n# for i in range(N):\n# j = i+1\n\n# while(j < N):\n# result += (A[i] * A[j]) % mod\n# #print(i, \" : \", j)\n# j += 1\n\n# print(result % mod)\n\nA_sum = sum(A)\nresult = 0\nfor i in range(N):\n A_sum = A_sum - A[i]\n result += (A[i] * A_sum) % mod\n\nprint(result % mod)", "n = int(input())\na = list(map(int, input().split()))\ns = [0]\nfor i in range(n):\n\ts.append(s[i] + a[i]) # \u7d2f\u7a4d\u548c\nans = sum(a[i] * (s[n]-s[i+1]) for i in range(n))\nprint(ans % (10**9 + 7))", "N = int(input())\nA = list(map(int, input().split()))\ns = 0\ns2 = sum(A)\n\nfor i in range(N-1):\n s2 -= A[i]\n s += A[i] * s2\n\nanswer = s % (10**9+7)\nprint(answer)", "n = int(input())\na = list(map(int,input().split()))\nsuma = sum(a)\nc = 0\nfor num in a:\n c += num**2\nprint((suma**2-c)//2%(10**9+7))", "n = int(input().strip())\nl = list(map(int,input().strip().split()))\ns = sum(l)\nans=0\nMOD=1000000007\nfor i in range(n-1):\n\tans+=l[i]*(s-l[i])\n\ts-=l[i]\n\t\nprint((ans%MOD))\n\t\n", "import numpy as np\nn=int(input())\na= sorted(map(int,input().split()))\nb=np.cumsum(a,dtype=np.int64)\nc=0\nmod=10**9+7\nfor i in range(n-1):\n ## a[i]*(\u5168\u7d2f\u7a4d\u548c - i\u4ee5\u4e0b\u306e\u7d2f\u7a4d\u548c)\n c+=(a[i]%mod)*((b[-1]-b[i])%mod)\n c%=mod\nprint(c)", "mod = 10**9 + 7\nn = int(input())\nl = list(map(int,input().split()))\nsum_l = sum(l)\nans = 0\nfor i in range(n):\n sum_l -= l[i]\n ans += sum_l * l[i]\nprint(ans%mod)", "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr = 0\n\n\ndef cumsum(xs):\n result = []\n for i in range(len(xs)):\n if i == 0:\n result.append(xs[0])\n else:\n result.append(result[-1] + xs[i])\n return result\n\n\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N-1):\n r += (numbers[i]*num_sum[i])%CONST\nprint((r % CONST))\n", "n = int(input())\narr = input()\nar = list(map(int,arr.split(' ')))\nsum=0\ns=0\nmod=1000000007\nfor i in range(0,n):\n sum=sum+(ar[i]*ar[i])\n s=s+ar[i]\ns=s*s\nprint(((s-sum)//2)%mod)", "N = int(input())\nA = list(map(int, input().split()))\nprint((sum(A)**2-sum(a**2 for a in A))//2%(10**9+7))", "n = int(input())\nA = [int(x) for x in input().split()]\nmod = 10**9+7\na_cum = [0] * (n+1)\n# \u7d2f\u7a4d\u548c\u306e\u8a08\u7b97\nfor i in range(n):\n a_cum[i + 1] = a_cum[i] + A[i]\nans = 0\nfor i in range(len(A)-1):\n # a_cum[n]\u306f\u5168\u3066\u306e\u5408\u8a08\u3068\u540c\u7fa9\u3002a_cum\u306findex\u304c1\u3064\u305a\u308c\u3066\u3044\u308b\u306e\u3067\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002 \n ans += A[i] * (a_cum[n] - a_cum[i+1]) % mod\nans %= mod\nprint(ans)", "n=int(input())\nalst=list(map(int,input().split()))\nmod=10**9+7\n\nlst_sm=sum(alst)\nsm=lst_sm**2\nfor i in range(n):\n sm-=alst[i]**2\nsm//=2\nprint((sm%mod))\n", "n = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nans = 0\ntotal = sum(a)\nfor i in range(n):\n total -= a[i]\n ans = (ans + total * a[i]) % mod\n\nprint(ans)", "import numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())),dtype=np.int64)\nMOD = 10**9+7\nB = np.cumsum(A[N-1:0:-1])[::-1]\nB %= MOD\nprint((np.sum(A[:N-1] * B % MOD) % MOD))\n", "n = int(input())\na = list(map(int,input().split()))\ns = sum(a)\nans = 0\nsub = 0\n\nfor i in range(n):\n ans += a[i]*s\n \nfor j in range(n):\n sub += a[j]**2\n \nprint(((ans-sub)//2)%(10**9 + 7))", "def cusum(a):\n cusum = [a[0]]\n for i in range(len(a)-1):\n cusum.append(cusum[i] + a[i+1])\n return cusum\n\n\ndef solve1(n, a):\n ans = 0\n mod = 10**9 + 7\n cusum_a = cusum(a)\n\n for i in range(n):\n ans += a[i] * (cusum_a[-1] - cusum_a[i])\n \"\"\"\n print(a[i], \"*\",\n \"(\", a[i+1:], \"=\", (cusum_a[-1] - cusum_a[i]), \")\",\n \"=\", a[i] * (cusum_a[-1] - cusum_a[i]))\n \"\"\"\n ans %= mod\n\n return ans\n\n\nn = int(input())\na = list(map(int, input().split(\" \")))\nprint((solve1(n, a)))\n", "import sys\n# from numpy import cumsum\ninput = sys.stdin.readline\nn = int(input())\na = [int(_) for _ in input().split()]\nmod = 10**9 + 7\nans = 0\ns = [0]\na_ = a[::-1]\nfor i in range(len(a_)-1):\n s.append(s[i]+a_[i])\ns = s[::-1]\ns.pop(len(s)-1)\n# print(s)\nfor i in range(len(a)-1):\n ans += a[i] * s[i]\n ans = ans % mod\nprint(ans)", "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr = 0\n\n\ndef cumsum(xs):\n result = []\n for i in range(len(xs)):\n if i == 0:\n result.append(xs[0])\n else:\n result.append(result[-1] + xs[i])\n return result\n\n\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N - 1):\n r += (numbers[i] * num_sum[i]) % CONST\nprint((r % CONST))\n", "n = int(input())\na = list(map(int,input().split()))\ns = sum(a)\nx = [i**2 for i in a]\nx = sum(x)\nans = (s**2-x)//2\nprint(ans%(10**9+7))", "n = int(input())\na = list(map(int, input().split()))\ns = [0]*(n+1)\nmod = 10**9 + 7\nfor i in range(1,n+1):\n s[i] = s[i-1] + a[i-1]\nans = 0\nfor j in range(1,n):\n ans += a[j-1]*(s[n]-s[j])\nprint(ans%mod)", "# -*- coding utf-8 -*-\n\nMOD = 10 ** 9 + 7\n\nN = int(input())\nAN = list(map(int, input().split()))\n\ncumsum = [0] * (len(AN) + 1)\nfor i in range(1, N + 1):\n cumsum[i] = cumsum[i - 1] + AN[i - 1]\n\nans = 0\nfor i in range(1, N):\n ans += AN[i] * cumsum[i]\n ans %= MOD\n\n\nprint(ans)\n", "n = input()\na = list(map(int,input().split()))\nsum = 0\nmsum = 0\nfor i in a:\n sum += i\n msum += i*i\nans = int((sum*sum - msum)//2)\nprint(int(ans%1000000007))", "n = int(input())\nl = list(map(int,input().split()))\nA = sum(l)-l[0]\nans = 0\nfor i in range(len(l)) :\n ans += l[i]*A\n \n if A == l[-1] :\n break\n else :\n A -= l[i+1]\n\nprint(ans%(10**9+7))", "#abc177c\nn=int(input())\na=list(map(int,input().split()))\ns=sum(a)\nt=sum([x*x for x in a])\nprint(((s*s-t)//2%(10**9+7)))\n", "def cin():\n return list(map(int, input().split()))\n\n\nN = int(input())\nA = cin()\n\ntotal = 0\nstore = 0\nfor i in range(N - 1):\n store += A[N - i - 1]\n total += A[N - i - 2] * store\nprint((total % (pow(10, 9) + 7)))\n", "N=int(input())\nb = 0\na = list(map(int, input().split()))\nc = 0\nfor i in range(0,N):\n c = c + a[i]\nfor i in range(0,N):\n c = c - a[i]\n b = (b + a[i] * c) %(10**9+7)\nprint(b)", "N = int(input())\nmod = 10**9 + 7\nA = list(map(int, input().split()))\nAsum = sum(A)\nans = 0\nfor a in A:\n Asum -= a\n ans += a*Asum % mod\nprint(ans % mod)", "n = int(input())\na = list(map(int,input().split()))\ncount = 0\nans = 0\nfor i in range(1,n):\n count += a[-i]\n ans += a[-i-1]*count\n ans = ans%(10**9+7)\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\ns = sum(a)\nans = 0\nfor i in a:\n s -= i\n ans += i*s\nmod = ans % (10**9 + 7)\nprint(mod)", "MOD=10**9+7\nN=int(input())\nA=list(map(int,input().split()))\nsum_of_all=sum(A)**2\nsum_of_diagonal=0\nfor i in range(N):\n sum_of_diagonal+=A[i]**2\nprint((sum_of_all-sum_of_diagonal)//2%MOD)", "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr=0\n\ndef cumsum(xs):\n result = []\n for i in range(len(xs)):\n if i == 0:\n result.append(xs[0])\n else:\n result.append(result[-1] + xs[i])\n return result\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N-1):\n r+=(numbers[i]*num_sum[i])%CONST\nprint(r%CONST)", "n = int(input())\nA = list(map(int, input().split()))\n\nmod = 10 ** 9 + 7\ns = sum(A) % mod\nans = 0\nfor i in range(n):\n s -= A[i]\n ans = (ans + (A[i] * s) % mod) % mod\nprint(ans)", "n = int(input())\nc = list(map(int, input().split()))\nc_ans = []\nans = 0\n\n#print(c)\nfor i in range(n):\n ans += c[i]\n #print(ans)\n c_ans.append(ans)\n \nre_ans = 0\n#print(c_ans)\n\nfor i in range(n):\n re_ans += c[i] * (c_ans[n-1] - c_ans[i])\n\nre_ans = re_ans % (10**9 + 7)\nprint(re_ans)", "n = int(input())\nA = list(map(int, input().split()))\n\ntotal = (sum(A))**2\nfor i in range(n):\n total -= (A[i])**2\nans = (total//2)%(10**9+7)\nprint(ans)\n", "from functools import reduce\nfrom operator import add\n\nN = int(input())\nA = list(map(int, input().split()))\n\ndef cum(total, a):\n total.append(a + total[-1])\n return total\n\ncumsum = reduce(cum, A, [0])\ncum_last = cumsum[-1]\n\np = 1000000007\n\ndef i_fixed(i):\n return (A[i] * (cum_last - cumsum[i+1])) % p\n\ndef solve():\n return map(i_fixed, range(N-1))\n\nprint(sum(solve()) % p)", "n = int(input())\na = list(map(int, input().split()))\nans = 0\nmod = 10**9 + 7\nb = sum(a)\n\nfor i in range(n-1):\n b = b-a[i]\n ans += a[i]*b\n\nprint(ans%mod)", "n = int(input())\na = list(map(int, input().split()))\n\nsuma = sum(a)\nans = 0\nfor i in range(len(a)):\n suma = suma - a[i]\n ans += suma * a[i]\nans = ans % (10**9+7)\nprint(ans)", "n=int(input())\na=list(map(int, input().split()))\ns=[]\nc=0\nans = 0\nfor i in a:\n\tc += i\n\ts.append(c)\nfor i in range(n-1):\n\tans += (a[i] * (s[n-1]-s[i])) % 1000000007\nprint(ans % 1000000007)", "import numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())),dtype=np.int64)\nMOD = 10**9+7\nB = np.cumsum(A[N-1:0:-1])[::-1]\nB %= MOD\n\nans = 0\nfor i,j in zip(A[:N-1], B):\n ans += i*j\n ans %= MOD\nprint(ans)\n# ans = 0\n# for i in range(N-1):\n# ans += A[i] * B[i]\n# ans %= MOD\n#\n# print(ans)\n", "def __starting_point():\n\n N = int(input())\n A = list(map(int, input().lstrip().split(' ')))\n\n cumA = [A[0]]\n for i in range(1,N):\n cumA.append(cumA[-1] + A[i])\n \n count = 0\n for i in range(N - 1):\n count += A[i] * ( cumA[N-1] - cumA[i] )\n \n print(count % (10**9 + 7))\n__starting_point()", "def main():\n N = int(input())\n mod = 10**9 + 7\n \n a = list(map(int, input().split()))\n\n ans = 0\n s = 0\n \n for i in range(1, N):\n s += a[i]\n \n \n for i in range(1, N):\n ans += (a[i-1] * s) % mod\n s -= a[i]\n \n print(ans % mod)\n \n \n \ndef __starting_point():\n main()\n__starting_point()", "import numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())),dtype=np.int64)\nMOD = 10**9+7\nB = np.cumsum(A[N-1:0:-1])[::-1]\nB %= MOD\nprint((np.sum((A[:N-1] * B) % MOD) % MOD))\n", "N = int(input())\nA = [int(a) for a in input().split()]\nmod = 10**9+7\n\nL = [0]*(N+1)\nfor i in range(N):\n L[i+1] = (L[i]+A[i])%mod\n\nans = 0\nfor i in range(N):\n ans += A[i]*(L[-1]-L[i+1])\n ans %= mod\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\n\nmod = 10**9+7\n\nsum_list = []\nsum_ = 0\nfor i in range(len(A)-1):\n sum_ += A[i+1]\n sum_list.append(sum_)\n \nlen_ = 0\nfor i in range(len(A)-1):\n len_ += (A[i+1] * (sum_list[-1] - sum_list[i]) )% mod\n\nprint(((len_+A[0]*sum_list[-1])%mod))\n", "N, = map(int,input().split())\nA = list(map(int,input().split()))\nsu = A[N-1]\nsuu = su*A[N-2]\nfor i in reversed(range(1,N-1)):\n su+=A[i]\n suu+=(su*A[i-1])\nprint(suu%(10 ** 9+7))", "import sys\nn=int(input())\na=[int(x) for x in input().split()]\n\ns=0\nfor i in range(n):\n s+=a[i]\nc=0\nsum=0\nfor k in range(n-1):\n c+=a[k]\n co=s-c\n sum+=a[k]*co\n\nprint((sum%(10**9+7)))\n", "from sys import stdin\nN = int(stdin.readline().rstrip())\nA = [int(_) for _ in stdin.readline().rstrip().split()]\n\nsa = sum(A)\nans = 0\n\nfor i in range(N):\n sa -= A[i]\n ans += A[i]*sa \n ans %= (10**9+7)\n\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\nrsum = [0 for _ in range(N)]\nans = 0\nfor i in range(N):\n if i == 0:\n continue\n rsum[-(i+1)] = rsum[-i] + A[-i]\nfor i in range(N):\n ans += A[i] * rsum[i]\nans %= (10 ** 9 + 7)\nprint(ans)", "n = int(input())\nA = list(map(int, input().split()))\n\ns = 0\nsum = 0\nans = 0\n\nfor i in range(n):\n s += A[i]\n\nfor j in range(n-1):\n s -= A[j]\n sum += A[j] * s\n\nans = sum % (10**9+7)\nprint(ans)", "MOD = 10 ** 9 + 7 # MOD\u306f\u5909\u6570\u306b\u5165\u308c\u3066\u3057\u307e\u3063\u305f\u307b\u3046\u304c\u6253\u3061\u9593\u9055\u3048\u306a\u304f\u3066\u3044\u3044\u3067\u3059\n\nN = int(input())\nA = list(map(int, input().split()))\n\nS = sum(A) % MOD\nans = 0\n\n# A_N\u3082\u542b\u307e\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u3068\u304d\u306fs=0\u306a\u306e\u3067\u554f\u984c\u3042\u308a\u307e\u305b\u3093\nfor x in A:\n S -= x # \u81ea\u5206\u3068\u81ea\u5206\u81ea\u8eab\u3092\u639b\u3051\u306a\u3044\u3088\u3046\u306b\u3001\u5148\u306b\u5f15\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\n S %= MOD # MOD\u306f\u3044\u3061\u3044\u3061\u53d6\u3063\u3066\u304a\u304f\u3068\u3044\u3044\u3067\u3059\n ans += S * x\n ans %= MOD\n\nans %= MOD # \u3053\u306e\u884c\u306f\u5b8c\u5168\u306b\u4e0d\u8981\u3067\u3059\u304c\u3001\u6700\u5f8c\u3060\u3051MOD\u3092\u53d6\u308a\u5fd8\u308c\u3066WA\u306b\u306a\u308b\u30df\u30b9\u306f\u975e\u5e38\u306b\u3088\u304f\u3042\u308b\u306e\u3067\u3001\u5fc5\u8981\u4ee5\u4e0a\u306b\u53d6\u3063\u3066\u304a\u304f\u3068\u5b89\u5fc3\u3067\u304d\u307e\u3059\nprint(ans)", "p = 10**9 + 7\nn = int(input())\naa = list(map(int, input().split()))\ns = 0\nfor a in aa:\n s += a**2\n\nsa = sum(aa)\nb = sa*sa\nans = (b-s)//2\n\nprint(ans % p)", "import sys\n#import time\nfrom collections import deque, Counter, defaultdict\n#from fractions import gcd\nimport bisect\nimport heapq\n#import math\nimport itertools\nimport numpy as np\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\ninf = 10**18\nMOD = 1000000007\nri = lambda : int(input())\nrs = lambda : input().strip()\nrl = lambda : list(map(int, input().split()))\nmod = 998244353\n\nn = ri()\na = rl()\ncs = 0\nli = []\nfor i in a:\n cs+=i\n li.append(cs)\nsum_ = sum(a)\nans = 0\nfor i in range(len(a)):\n ans += a[i]*(sum_-li[i])%MOD\nprint(ans%MOD)", "mod = 1000000000+7\n\nn = int(input())\nAs = list(map(int, input().split()))\n\n\nsum_ = sum(As)\nret = 0\nfor i in range(n-1):\n sum_ -= As[n-1-i]\n ret += sum_ * As[n-1-i]\n ret %= mod\n\nprint(ret)", "import numpy as np\nn=int(input())\na= sorted(map(int,input().split()))\nb=np.cumsum(a,dtype=np.int64)\nc=0\nmod=10**9+7\nfor i in range(n-1):\n c+=(a[i]%mod)*((b[-1]-b[i])%mod)\n c%=mod\nprint(c)", "n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\nb = sum(a)\nc = sum([i*i for i in a])\nans = ((b**2 - c)//2)%mod\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\nmysum = sum(A)\ntotal = 0\nfor i in range(N-1):\n mysum -= A[i]\n total += A[i] * mysum\nprint(total % 1000000007)", "import numpy as np\nN = int(input())\nA = np.array(list(map(int, input().split())),dtype=np.int64)\nMOD = 10**9+7\nB = np.cumsum(A[N-1:0:-1])[::-1]\nB %= MOD\nprint((np.sum((A[:N-1] * B) % MOD) % MOD))\n", "n = int(input())\nli = list(map(int, input().split()))\nmod = 10**9 + 7\nsm = sum(li)\nmul = sum([i**2 for i in li])\nans = ((sm ** 2 - mul) // 2) % mod\nprint(ans)\n", "N = int(input())\nA = list(map(int,input().split()))\n\n# \u89e3\u8aac\u3092\u8aad\u3093\u3067\u89e3\u3044\u305f\n\n# \u7d2f\u7a4d\u548c\u306e\u8a08\u7b97\n\nsm = [0]\nfor i in range(N):\n sm.append(sm[i]+A[i])\n\n# \u7d2f\u7a4d\u548c\u3092\u4f7f\u3063\u305f\u89e3\u7b54\nans = 0\nfor j in range(N):\n ans += A[j]*(sm[N]-sm[j+1])\n \nprint(ans % (10**9+7))", "N = int(input())\nA = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\nS = sum(A) % MOD\n\nans = 0\nfor i in range(N - 1):\n S -= A[i]\n S %= MOD\n ans += (A[i] % MOD) * S\n ans %= MOD\n \nprint(ans)", "N=int(input())\nA=[0]*N\nS=[0]*(N+1)\nA=list(map(int,input().split()))\nmod=10**9+7\n\nfor i in range(N):\n S[i+1]=(S[i]+A[i])%mod\n\ncnt=0\nfor j in range(N-1):\n cnt+=A[j]*(S[N]-S[j+1])%mod\n\nprint(cnt%mod)", "import numpy as np\nn=int(input())\na= sorted(map(int,input().split()))\nb=np.cumsum(a,dtype=np.int64)\nc=0\nmod=10**9+7\nfor i in range(n-1):\n c+=(a[i]%mod)*((b[-1]-b[i])%mod)\n c%=mod\nprint(c)", "import sys\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\nsys.setrecursionlimit(20000000)\n\nMOD = 10 ** 9 + 7\nINF = float(\"inf\")\n\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n for i in range(N):\n A[i] %= MOD\n S = sum(A)\n answer = 0\n for i in range(N):\n S = S - A[i]\n answer += A[i] * S\n answer %= MOD\n print(answer)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int, input().split()))\n\nmod = 1000000007\nsum = 0\nans = 0\nfor i in range(n):\n\tans = (ans + a[i]*sum) % mod\n\tsum += a[i]\nprint(ans)\n", "N = int(input())\nA = list(map(int,input().split()))\n\nans = 0\n\nMOD = 10 ** 9 + 7\n\nsum_A = sum(A)\n\nfor i in range(N):\n sum_A -= A[i]\n ans += (sum_A * A[i])\n\nprint((ans % MOD))\n", "N = int(input())\nA = list(map(int, input().split()))\n\nMOD = 10**9 + 7\ns = 0\n\nfor i in range(N):\n s += A[i]\nans = 0\nfor i in range(N-1):\n s -= A[i]\n ans += A[i] * s\n ans %= MOD\n\nprint(ans)", "mod = 10 ** 9 + 7\nN = int(input())\nA = list(map(int,input().split()))\nsum_of_all = sum(A)**2\nsum_of_diagonal = 0\nfor i in range(N):\n sum_of_diagonal += A[i]**2\nprint((sum_of_all - sum_of_diagonal) // 2 % mod)", "N = int(input())\nA = list(map(int,input().split()))\n\nM = 10**9 + 7\n\nAns = 0\n\nT = sum(A)\n\nfor i in range(N-1):\n T -= A[i]\n Ans += A[i] * T\n Ans %= M\n\nprint(Ans)\n", "n=int(input())\nli=list(map(int,input().split()))\ns=sum(li)\nc=0\nfor i in range(n-1):\n s-=li[i]\n c+=li[i]*s\nprint(c%(10**9+7))", "import numpy as np\nimport itertools as it\nn = int(input())\na = list(map(int, input().split()))\n_sum = 0\nans = 0\nmod = 1000000007\n \nfor i in range (n):\n _sum += a[i]\n _sum %= mod\n\nfor i in range (n):\n _sum -= a[i]\n if _sum < 0:\n _sum += mod\n ans += a[i] * _sum\n ans %= mod\n\nprint(ans)", "import itertools\n\nn = int(input())\na = list(map(int,input().split()))\nans = 0\n\nlis = list(itertools.accumulate(reversed(a)))\n\nfor i in range(n-1):\n ans += a[i]*lis[n-2-i]\n \nprint(ans%(10**9 + 7))", "n = int(input())\na = list(map(int, input().split()))\nlim = (10 ** 9) + 7\nans = 0\ntemp = a[-1]\nfor i in range(2,n+1):\n ans += a[-i] * temp\n temp += a[-i]\n# print(\"ans = {} temp = {}\".format(ans,temp))\n\nprint(ans%lim)", "n = int(input())\nli = list(map(int,input().split()))\ns = [li[0]]\nans = 0\nm = 10**9 +7\nfor i in range(n-1):\n s.append(li[i+1] + s[i])\n\nfor j in range(n-1):\n ans += (li[j] * (s[n-1]-s[j])) % m\n\nprint(ans%m)", "mod = 10**9 + 7\n\nn = int(input())\na = list(map(int, input().split()))\ns = sum(a) % mod\nans = 0\n\nfor x in a:\n s -= x\n s %= mod\n ans += s * x\n ans %= mod\n \nans %= mod\n\nprint(ans)", "mod = 10**9 + 7\nn = int(input())\na = [int(i) for i in input().split()]\ns = sum(a)\nout = 0\nfor i in a:\n s -= i\n out += s * i\n out %= mod\nprint(out)", "N = int(input())\nnum = list(map(int, input().split(' ')))\nans = 0\ntotal = sum(num)\nMOD = 10 ** 9 + 7\nfor a in num:\n total -= a\n ans += a * total \n ans %= MOD\nans %= MOD\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\n\nmod = (10**9)+7\nans = 0\nsums = [0]*N\nsums[0] = A[0]\nfor i in range(1, N):\n sums[i] = sums[i-1] + A[i]\n\nfor j in range(N):\n ans += A[j]*(sums[-1]-sums[j])\n\nprint(ans%mod)", "n = int(input())\na = list(map(int, input().split()))\na_sum = sum(a)\nans = 0\nmod = 10**9 + 7\n\nfor i in range(n-1):\n a_sum = a_sum - a[i]\n ans += a[i] * a_sum\n\nprint(ans%mod)", "n = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nrr = [0 for i in range(n + 1)]\n\nfor i in range(n):\n rr[i + 1] = (A[i] + rr[i]) % mod\n\nans = 0\nfor i in range(n):\n ans += A[i] * (rr[n] - rr[i + 1]) % mod\n\nprint((ans % mod))\n", "import itertools\nn = int(input())\nA = list(map(int, input().split()))\nA2=[]\nfor i in range(n):\n A2.append(A[n-1-i])\n\nacc_A2 = list(itertools.accumulate(A2))\nmod = (10**9)+7\n\ngoukei = 0\n\nfor i in range(n-1):\n goukei += A[i]*acc_A2[n-2-i]\n\nprint(goukei%mod)", "import numpy as np\nn=int(input())\na= sorted(map(int,input().split()))\nb=np.cumsum(a)\nc=0\nmod=10**9+7\nfor i in range(n-1):\n c+=int(a[i])*(int(b[-1])-int(b[i]))\n c%=mod\nprint(c)", "CONST = 10 ** 9 + 7\nN = int(input())\nnumbers = list(map(int, input().split()))\nr=0\n\ndef cumsum(xs):\n result = []\n for i in range(len(xs)):\n if i == 0:\n result.append(xs[0])\n else:\n result.append(result[-1] + xs[i])\n return result\nnumbers.reverse()\nnum_sum = cumsum(numbers)\nnum_sum.reverse()\nnumbers.reverse()\ndel num_sum[0]\nfor i in range(N-1):\n r+=(numbers[i]*num_sum[i])%CONST\nprint((r%CONST))\n", "import sys\nfrom collections import deque, defaultdict, Counter\nfrom itertools import accumulate, product, permutations, combinations\nfrom operator import itemgetter\nfrom bisect import bisect_left, bisect_right\nfrom heapq import heappop, heappush\nfrom math import ceil, floor, sqrt, gcd, inf\nfrom copy import deepcopy\nimport numpy as np\nimport scipy as sp\n\nINF = inf\nMOD = 1000000007\n\nn = int(input())\nA = [int(i) for i in input().split()]\n\ntmp = 0\nres = 0\n\nres = sum(A) ** 2\nfor i in range(n):\n res -= A[i] ** 2\nres = res // 2 % MOD\n\nprint(res)\n", "n = int(input())\nA = list(map(int,input().split()))\npaA = [0 for _ in range(n-1)]\npaA[0] = A[n-1]\nmod = 10**9 + 7\nfor i in range(1,n-1):\n paA[i] = paA[i-1] + A[n-1-i]\nsuma = 0\nfor i in range(n-1):\n suma += A[i] * paA[n-i-2]\n suma = suma % mod\nprint(suma)", "n = int(input())\na_list = list(map(int, input().split()))\n\nsum = 0\ns_list=[]\nans = 0\n\nfor i in range(n):\n sum += a_list[i]\n s_list.append(sum)\n\nfor i in range(n-1):\n ans += a_list[i] * (s_list[n-1]-s_list[i])\n\nprint((ans % (7+10**9)))\n", "n = int(input())\na = list(map(int,input().split()))\na.sort()\ns = sum(a)\nx = [i**2 for i in a]\nx = sum(x)\nans = (s**2-x)//2\nmod = 10**9+7\nprint(ans%mod)", "import sys\n\nN = int(input())\nA = list(map(int, input().split()))\n\nsum = [A[N-1]]\nans = 0\nfor i in range(1, N):\n ans += A[N-i-1]*sum[-1]%(10**9+7)\n ans %= (10**9+7)\n sum.append((sum[-1]+A[N-i-1])%(10**9+7))\nprint(ans)\n", "mod = 10**9+7\nn = int(input())\nl = list(map(int, input().split()))\nans = []\na = sum(l)\nfor i in range(len(l)):\n a = a - l[i]\n ans.append(l[i] * a)\n\nprint((sum(ans)%mod))\n\n\n", "n=int(input())\na=list(map(int,input().split()))\nmod=10**9+7\nsm=sum(a)\nmul=sum(i**2 for i in a)\nans=((sm ** 2 - mul) // 2) % mod\nprint(ans)\n\n"] | {"inputs": ["3\n1 2 3\n", "4\n141421356 17320508 22360679 244949\n"], "outputs": ["11\n", "437235829\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 26,548 | |
16d428dbc4cbb095be75f9ffc5cc15c3 | UNKNOWN | AtCoDeer has three cards, one red, one green and one blue.
An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.
We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.
Is this integer a multiple of 4?
-----Constraints-----
- 1 β€ r, g, b β€ 9
-----Input-----
Input is given from Standard Input in the following format:
r g b
-----Output-----
If the three-digit integer is a multiple of 4, print YES (case-sensitive); otherwise, print NO.
-----Sample Input-----
4 3 2
-----Sample Output-----
YES
432 is a multiple of 4, and thus YES should be printed. | ["rgb = list(map(int, input().split()))\n\nl = ''.join(str(n) for n in rgb)\nif int(l)%4 == 0:\n print('YES')\nelse:\n print('NO')", "r, g, b = list(map(int, input().split()))\nprint((\"YES\" if (r * 100 + g * 10 + b) % 4 == 0 else \"NO\"))\n", "# A - RGB Cards\n# https://atcoder.jp/contests/abc064/tasks/abc064_a\n\nr, g, b = list(map(str, input().split()))\n\ni = int(r + g + b)\nresult = 'NO'\n\nif i % 4 == 0:\n result = 'YES'\n\nprint(result)\n", "r, g, b = input().split()\nn = r + g + b\nif int(n) % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "r, g, b = map(int, input().split())\n\nif (r * 100 + g * 10 + b) % 4 == 0:\n print('YES')\nelse:\n print('NO')", "if int(''.join(input().split()[1:])) % 4 == 0:\n print('YES')\nelse:\n print('NO')", "r, g, b = map(int, input().split())\n\nanswer = r * 100 + g * 10 + b\n\nif answer % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r, g, b = map(str, input().split())\n\nrgb = str(r) + str(g) + str(b)\n\nif int(rgb) % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = input().split()\nn = int(a+b+c)\n\nprint('NO') if n % 4 else print('YES')", "a = int(input().replace(\" \",\"\"))\nprint(\"YES\" if a % 4 == 0 else \"NO\")", "# 064_a\nr,g,b=map(int,input().split())\nnum=int(str(r)+str(g)+str(b))\nif (1<=r and r<=9) and (1<=g and g<=9) and(1<=b and b<=9):\n if num % 4 == 0:\n print('YES')\n else:\n print('NO')", "r, g, b = list(map(int, input().split()))\nrgb = int(r * 100 + g * 10 + b)\nif rgb % 4 == 0:\n print('YES')\nelse:\n print('NO')\n", "r,g,b = input().split()\nnum = r + g + b\nprint(\"YES\" if int(num) % 4 == 0 else \"NO\")", "# A - RGB Cards\n\n# \u6574\u6570r,g,b\u3092\u5165\u529b\u3057\u3001\u5de6\u304b\u3089\u4e26\u3079\u3066\u3067\u304d\u305f3\u6841\u306e\u6574\u6570\u304c4\u306e\u500d\u6570\u3067\u3042\u308b\u304b\u5224\u5b9a\u3059\u308b\n\n\nr,g,b = list(map(str,input().split()))\n\nanswer = int(r + g + b)\n\nif answer % 4 == 0:\n print('YES')\nelse:\n print('NO')\n", "r, g, b = input().split()\nif int(r+g+b)%4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "# AtCoDeer\u541b\u306f\u3001\u8d64\u3001\u7dd1\u3001\u9752\u8272\u306e\u30ab\u30fc\u30c9\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002\n# \u305d\u308c\u305e\u308c\u306e\u30ab\u30fc\u30c9\u306b\u306f1\u4ee5\u4e0a9\u4ee5\u4e0b\u306e\u6574\u6570\u304c\u66f8\u304b\u308c\u3066\u304a\u308a\u3001\u8d64\u8272\u306e\u30ab\u30fc\u30c9\u306b\u306fr\u3001\u7dd1\u8272\u306e\u30ab\u30fc\u30c9\u306b\u306fg\u3001\u9752\u8272\u306e\u30ab\u30fc\u30c9\u306b\u306fb\u304c\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002\n# 3\u3064\u306e\u30ab\u30fc\u30c9\u3092\u5de6\u304b\u3089\u9806\u306b\u8d64\u3001\u7dd1\u3001\u9752\u8272\u306e\u9806\u306b\u4e26\u3079\u3001\u5de6\u304b\u3089\u6574\u6570\u3092\u8aad\u3093\u3060\u3068\u304d\u306b\u3053\u308c\u304c4\u306e\u500d\u6570\u3067\u3042\u308b\u304b\u5224\u5b9a\u3057\u306a\u3055\u3044\u3002\n\nr,g,b = map(int,input().split())\n\nif 1 <= r <=9 and 1 <= g <=9 and 1 <= b <=9 and (100 * r + 10 * g + b) % 4 == 0: # r\u3092100\u500d\u3001g\u309210\u500d\u306b\u3057\u3066\u3001\u305d\u308c\u305e\u308c100\u306e\u4f4d\u300110\u306e\u4f4d\u3068\u3059\u308b\u3002\n print('YES')\n\nelse:\n print('NO')", "if int(input().replace(\" \", \"\"))%4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r, g, b = map(int, input().split())\njudged = int(str(g) + str(b))\nif judged % 4 == 0:\n print('YES')\nelse:\n print('NO')", "r,g,b = list(map(int,input().split()))\nprint((\"YES\" if (r*100+g*10+b)%4 == 0 else \"NO\"))\n", "r, g, b = map(str, input().split())\n\nsumstr = r + g + b\nsumint = int(sumstr)\n\nif sumint % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r,g,b=list(map(int,input().split()))\nprint(('YES' if int(r*100+10*g+b)%4==0 else 'NO'))\n", "a,b,c=map(int,input().split())\nif (a*100+b*10+c)%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c = input().split()\nn = int(a+b+c)\nif n % 4 == 0:\n print('YES')\nelse:\n print('NO')", "# \u6587\u5b57\u5217\u3068\u3057\u3066\u5165\u529b\nr, g, b = map(str, input().split())\n\n# \u9023\u7d50\nRGB = r + g + b\n\n# \u6574\u6570\u306b\u623b\u3057\u30664\u3067\u5272\u308b\nif int(RGB) % 4 == 0:\n print('YES')\nelse:\n print('NO')", "r,g,b=map(int, input().split())\nprint(\"YES\" if (10*g+b)%4==0 else \"NO\")", "N = int(\"\".join(map(str,input().split())))\nprint((\"NO\",\"YES\")[N % 4 == 0])", "r, g, b = map(int, input().split())\nif (r*100+g*10+b)%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c=[int(s) for s in input().split()]\nif (10*b+c)%4==0:\n print('YES')\nelse:\n print('NO')", "r,g,b = map(int,input().split())\na = r*100+g*10+b\nprint(\"YES\" if a % 4 == 0 else \"NO\")", "if int(''.join(input().split())) % 4==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n \n", "r, g, b=input().split()\nif int(g+b)%4==0:\n print('YES')\nelse:\n print('NO')", "a = list(map(int,input().split()))\nif((a[0]*100+a[1]*10+a[2])%4 == 0 ): print(\"YES\")\nelse: print(\"NO\")", "# \u5165\u529b\nr, g, b = list(map(int, input().split()))\n\n# \u51fa\u529b\nif 1 <= r and g and b <= 9:\n if ((r * 100) + (g * 10) + b) % 4 == 0:\n print('YES')\n else:\n print('NO')\n", "a, b, c = map(int, input().split())\nx = str(a) + str(b) + str(c)\nif int(x) % 4 == 0:\n print('YES')\nelse:\n print('NO')", "print(\"YES\" if int(input().replace(\" \",\"\"))%4==0 else \"NO\")", "r,g,b = map(int,input().split())\nprint(\"YES\" if (g*10+b) % 4 == 0 else \"NO\")", "r, g, b = map(str, input().split())\n\nnumber = r + g + b\nprint(\"YES\" if int(number) % 4 == 0 else \"NO\")", "# 3\u679a\u306e\u30ab\u30fc\u30c9\u3092\u4e26\u3079\u305f3\u6841\u306e\u6574\u6570\u304c4\u306e\u500d\u6570\u304b\n\nr, g, b = map(int, input().split())\nanswer = 100 * r + 10 * g + b\n\nif answer % 4 == 0:\n print('YES')\nelse:\n print('NO')", "num = input().replace(' ', '')\n\nif int(num) % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\nINF = float('inf')\nMOD = 10**9 + 7\n#MOD = 998244353\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lintdec(): return list([int(x) - 1 for x in input().split()])\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nprint(('NO' if int(''.join(lstr())) % 4 else 'YES'))\n", "r, g, b = input().split()\n\nprint(\"YES\" if int(r + g + b) % 4 == 0 else \"NO\")", "r, g, b = list(map(int, input().split()))\na = 100 * r + 10 * g + b\nif a % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a,b,c = input().split()\nif int(b+c)%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "r, g, b = map(int,input().split())\n\nif (r * 100 + g * 10 + b) % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r, g, b = map(int, input().split())\nx = 2 * g + b\nprint(\"YES\" if x % 4 == 0 else \"NO\")", "r, g, b = map(int, input().split())\nif (g*10+b)%4 == 0:\n print('YES')\nelse:\n print('NO')", "r, g, b = list(map(int, input().split()))\nif (10 * g + b ) % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a,b,c=map(int,input().split())\nif (10*b+c)%4==0:\n print('YES')\nelse:\n print('NO')", "r, g, b = map(str, input().split())\n\nnumber = int(r + g + b)\n\nif number % 4 == 0:\n print('YES')\nelse:\n print('NO')", "r, g, b = map(int, input().split())\n\nresult = int(\"{}{}{}\".format(r,g,b))\nif result % 4 == 0:\n print('YES')\nelse:\n print('NO')", "n = list(input().split())\nn = int(\"\".join(n))\nif n % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r, g, b = map(int, input().split())\nN = 10*g + b\n\nif N % 4 == 0:\n print('YES')\nelse:\n print('NO')", "r, g, b = map(str, input().split())\n\nans = int(r+g+b)\n\nif ans %4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c=map(int,input().split())\nif (10*b+c)%4==0:print('YES')\nelse:print('NO')", "r,g,b = map(int,input().split())\n\nif (g*10+b) % 4 == 0:\n print('YES')\n \nelse:\n print('NO')", "number=int(\"\".join(input().split()))\nif number % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r, g, b = (int(x) for x in input().split())\n\n\ns = 100*r+10*g+b\n\nif s%4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "rgb=list(input().split())\nl=int(''.join(rgb))\nprint(\"NO\" if l%4 else \"YES\")", "a,b,c=map(int,input().split())\nif (10*b+c)%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c=map(int,input().split())\nif (a*100+b*10+c)%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r, g, b = input().split()\n\nans = int(r) * 100 + int(g) *10 + int(b)\n\nif ans % 4 == 0:\n print(\"YES\")\nelif ans % 4 != 0:\n print(\"NO\")", "r,g,b = map(int,input().split())\nif((10*g + b) % 4 == 0):\n print('YES')\nelse:\n print('NO')", "def iroha():\n a, b, c = input().split()\n num = int(a+b+c)\n print((\"YES\" if num % 4 == 0 else \"NO\"))\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "r,g,b=input().split()\na=int(r+g+b)\nif a%4==0:\n print('YES')\nelse:\n print('NO')", "r, g, b = map(int,input().split())\nif (100 * r + 10 * g + b) % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r, g, b = map(int, input().split())\nx = 10 * g + b\nif x % 4 == 0: print('YES')\nelse: print('NO')", "r,g,b=input().split()\nif int(r+g+b)%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")", "n = ''\n\nfor s in input().split():\n n += s\n\nif int(n) % 4 == 0:\n print('YES')\nelse:\n print('NO')", "r, g, b = list(map(int, input().split()))\nnum = r * 100 + g * 10 + b * 1\nif num%4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "if int(\"\".join(input().split())) % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "print('YES' if int(''.join(input().split()))%4 == 0 else 'NO')", "l=input().split()\ns=''.join(l)\ns=int(s)\nprint('YES' if s%4==0 else 'NO')", "# \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u306e\u6574\u6570\u306e\u5165\u529b\na, b, c = input().split()\nnumber = int(a + b + c)\nif number % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r, g, b = list(map(str, input().split()))\nli = r + g + b\n\nif int(li)%4==0:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")\n", "r, g, b = list(map(str, input().split()))\nif int(r + g + b) % 4 == 0:\n print('YES')\nelse:\n print('NO')", "a=input().split()\nb=''.join(a)\n\nif int(b)%4==0:\n print('YES')\n \nelse:\n print('NO')", "r, g, b = input().split()\n\nif int(g + b) % 4 == 0:\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\n\nif (a*100 + b*10 + c) % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "# \u5165\u529b\nr, g, b = map(int,input().split())\n\n# \u51e6\u7406\nanswer = (r * 100 + g * 10 + b) % 4\nif answer == 0:\n print('YES')\nelse:\n print('NO')", "a,b,c=input().split()\nif int(b+c)%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r,g,b = input().split()\n\nans = int(r+g+b)\n\nif ans % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r,g,b = list(map(int,input().split()))\n\nN = (r * 100) + (g * 10) + b\nif N % 4 == 0:\n print('YES')\nelse:\n print('NO')\n", "#n = int(input())\nr, g, b = list(map(str, input().split()))\n#al = list(map(int, input().split()))\n#al=[list(input()) for i in range(n)]\n\nv = int(r+g+b)\nif v % 4 == 0:\n print('YES')\nelse:\n print('NO')\n", "if int(input().replace(' ',''))%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "print(\"NO\") if int(input().replace(\" \",\"\"))%4 else print(\"YES\")", "if int(input().replace(\" \",\"\"))%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")", "\nr,g,b = map(int,input().split())\na = r *100+g*10+b\nif a % 4 == 0:\n print('YES')\nelse:\n print('NO')", "r, g, b = list(map(int, input().split()))\nnum = 10*g + b\nif num % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "# AtCoDeer\u541b\u306f\u3001\u8d64\u3001\u7dd1\u3001\u9752\u8272\u306e\u30ab\u30fc\u30c9\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002\n# \u305d\u308c\u305e\u308c\u306e\u30ab\u30fc\u30c9\u306b\u306f 1 \u4ee5\u4e0a 9 \u4ee5\u4e0b\u306e\u6574\u6570\u304c\u66f8\u304b\u308c\u3066\u304a\u308a\u3001\n# \u8d64\u8272\u306e\u30ab\u30fc\u30c9\u306b\u306f r\u3001\u7dd1\u8272\u306e\u30ab\u30fc\u30c9\u306b\u306f g\u3001\n# \u9752\u8272\u306e\u30ab\u30fc\u30c9\u306b\u306f b \u304c\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002\n# 3\u3064\u306e\u30ab\u30fc\u30c9\u3092\u5de6\u304b\u3089\u9806\u306b\u8d64\u3001\u7dd1\u3001\u9752\u8272\u306e\u9806\u306b\u4e26\u3079\u3001\n# \u5de6\u304b\u3089\u6574\u6570\u3092\u8aad\u3093\u3060\u3068\u304d\u306b\u3053\u308c\u304c 4\u306e\u500d\u6570\u3067\u3042\u308b\u304b\u5224\u5b9a\u3057\u306a\u3055\u3044\u3002\n\n# \u5236\u7d04\n# 1 \u2266 r, g, b \u2266 9\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 r, g , b \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\nr, g, b = list(map(int, input().split()))\n\n# 3\u6841\u306e\u6570\u5024\uff08agb\u3068\u4e26\u3079\u305f\u6570\u5024\uff09\u304c 4\u306e\u500d\u6570\u304b\u3092\u5224\u5b9a\u3057\u3001\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\ninput_rgb = r * 100 + g * 10 + b\nresult = \"ret\"\n\nif input_rgb % 4 == 0:\n result = \"YES\"\nelse:\n result = \"NO\"\n\nprint(result)\n", "'''\nabc064 A - RGB Cards\nhttps://atcoder.jp/contests/abc064/tasks/abc064_a\n'''\n\nr, g, b = list(map(int, input().split()))\ni = r*100+g*10+b\nif i%4 == 0:\n ans = 'YES'\nelse:\n ans = 'NO'\nprint(ans)\n", "r,g,b=map(int,input().split())\n\nrgb=r*100+g*10+b\nif rgb%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r,g,b=map(int,input().split())\nif (10*g+b)%4==0 :\n print(\"YES\")\nelse :\n print(\"NO\")", "# AtCoder abc064 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\nr, g, b = list(map(int, input().split()))\n\n# \u51e6\u7406\nanswer = r * 100 + g *10 + b\n\n# \u5224\u5b9a\nif (answer % 4) == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a, b, c = map(str, input().split())\nnum = int(a + b + c)\n \nif num % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r,g,b = input().split()\n\na = r + g + b\n\nif int(a) % 4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")", "r,g,b = input().split()\nif int(r + g + b) % 4 == 0:\n print('YES')\nelse:\n print('NO')", "r, g, b = map(int,input().split())\nans = 100*r + 10 *g + b\nif ans % 4 == 0:\n print('YES')\nelse :\n print('NO')", "r,g,b = list(map(int,input().split()))\nif (g*10+b)%4 == 0:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "r,g,b=input().split()\nif int(r+g+b)%4==0:\n print(\"YES\")\nelse:\n print(\"NO\")"] | {"inputs": ["4 3 2\n", "2 3 4\n"], "outputs": ["YES\n", "NO\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 14,945 | |
51e3ac1502a93830ff72638fe3cdd461 | UNKNOWN | There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:
- Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard after K operations?
-----Constraints-----
- A, B and C are integers between 1 and 50 (inclusive).
- K is an integer between 1 and 10 (inclusive).
-----Input-----
Input is given from Standard Input in the following format:
A B C
K
-----Output-----
Print the largest possible sum of the integers written on the blackboard after K operations by E869220.
-----Sample Input-----
5 3 11
1
-----Sample Output-----
30
In this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.
There are three choices:
- Double 5: The integers written on the board after the operation are 10, 3, 11.
- Double 3: The integers written on the board after the operation are 5, 6, 11.
- Double 11: The integers written on the board after the operation are 5, 3, 22.
If he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3. | ["a,b,c=list(map(int,input().split()))\nk=int(input())\n\nx=max(a,b,c)\n\nprint(((a+b+c)-x+x*(2**k)))\n", "a,b,c=map(int,input().split())\nk=int(input())\nprint(a+b+c+max(a,b,c)*(2**k-1))", "A, B, C = map(int, input().split())\nK = int(input())\n\nX = sorted([A, B, C])\nfor _ in range(K):\n X[-1] *= 2\n \nprint(sum(X))", "def ans096(A: int, B: int, C: int, K: int):\n int_list = [A, B, C]\n int_list.sort()\n third=int_list[-1]\n for i in range(K):\n third*=2\n return int_list[0]+int_list[1]+third\n\nA,B,C=map(int,input().split())\nK=int(input())\nprint(ans096(A,B,C,K))", "abc = list(map(int, input().split()))\nk = int(input())\n\nfor i in range(k):\n abc.sort()\n abc[2] *= 2\n \nprint(sum(abc))", "a = sorted(map(int, input().split()))\nk = int(input())\nprint(a[0] + a[1] + a[2] * (2**k))", "import sys\nlines = [s.rstrip(\"\\n\") for s in sys.stdin.readlines()]\nnum_list = [int(num) for num in lines.pop(0).split(\" \")]\nk, = [int(num) for num in lines.pop(0).split(\" \")]\n\nm = max(num_list)\nans = sum(num_list) - m + (m * (2 ** k))\nprint(ans)\n", "import math\n# b=input()\n# c=[]\n# for i in range(b):\n# c.append(a[i])\na = list(map(int,input().split()))\n#b = list(map(int,input().split()))\ns=int(input())\n\nfor i in range(s):\n\ta[a.index(max(a))]=\ta[a.index(max(a))]*2\n\t\nprint(sum(a))", "l = list(map(int, input().split()))\nk = int(input())\nnum = max(l)\nl.remove(num)\nfor i in range(k):\n num = num * 2\nprint(sum(l) + num)", "A,B,C=map(int, input().split())\nK=int(input())\n\nM=sorted([A,B,C])\nm=M[-1]\n\nm=m*2**K\n\nprint(m+M[0]+M[1])", "L = sorted(map(int, input().split()))\nk = int(input())\nprint(L[0]+L[1]+L[2]*2**k)", "a, b, c = list(map(int, input().split()))\nK = int(input())\nm = max(a, b, c)\nprint((a + b + c + (2**K - 1) * m))\n", "a, b, c = map(int, input().split())\nk = int(input())\nprint(a + b + c + max(a, b, c) * (2 ** k - 1))", "a = list(map(int, input().split()))\nk = int(input())\na.sort()\nprint(a[0] + a[1] + a[2] + (a[2] * (2 ** k - 1)))", "def main():\n A = list(map(int, input().split()))\n K = int(input())\n A.sort()\n A.append(A.pop()*(2**K))\n print((sum(A)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "A,B,C = map (int, input ().split ())\nS = int (input ())\nif A>B>C or A>C>B:\n for i in range (S):\n A = A*2\n print (A+B+C)\nelif B>A>C or B>C>A:\n for i in range (S):\n B = B*2\n print (A+B+C)\nelse:\n for i in range (S):\n C = C*2\n print (A+B+C)", "a,b,c = map(int, input().split())\nk = int(input())\n\nans = a+b+c + (max(a,b,c))*(2**k-1)\nprint(ans)", "l=[int(x) for x in input().split()]\nk=int(input())\nm=max(l)\nl.remove(max(l))\nfor i in range(k):\n m *= 2 \nprint(sum(l)+m)", "x = list(map(int, input().split()))\nfor i in range(int(input())):\n x.sort()\n x[-1]=x[-1]*2\nprint(sum(x))", "X=list(map(int,input().split()))\nK=int(input())\nX.sort()\nfor i in range(K):\n X[-1]=X[-1]*2\nprint(sum(X))", "a,b,c=list(map(int,input().split()))\nn=int(input())\n\na,b,c= sorted([a,b,c])\nprint((a+b+c*2**n))\n", "A = list(map(int,input().split()))\nK = int(input())\n\nfor i in range(K):\n max_A = max(A)\n A.append(max_A * 2)\n A.remove(max_A)\n\nprint(sum(A))", "a, b, c = map(int, input().split())\nk = int(input())\n\nif max([a,b,c]) == c:\n ans = c*(2**k) + b + a\nelif max([a,b,c]) == b:\n ans = b*(2**k) + a + c\nelse:\n ans = a*(2**k) + b + c\nprint(ans)", "lis = list(map(int,input().split()))\na = int(input())\nlis.sort(reverse = True)\nfor i in range(a):\n lis[0] *= 2\nprint(sum(lis))", "n = list(map(int,input().split()))\nk = int(input())\nfor _ in range(k):\n n[n.index(max(n))] *= 2\nprint(sum(n)) ", "l = list(map(int, input().split()))\nk = int(input())\nl.sort()\nprint(l[2]*(2**k)+l[0]+l[1])", "A = list(map(int,input().split()))\nK = int(input())\nfor _ in range(K):\n A[A.index(max(A))]*=2\n\nprint(sum(A))", "a=list(map(int,input().split()))\nk=int(input())\nb=max(a)\nfor i in range(k):\n b*=2\n \nprint((sum(a)-max(a)+b))\n", "A, B, C = map(int,input().split())\nK = int(input())\n\nn_list = [A, B, C]\nx = max(n_list)\nn_list.append(x * 2 ** K)\nn_list.remove(x)\nprint(sum(n_list))", "def answer(a: int, b: int, c: int, k: int) -> int:\n nums = sorted((a, b, c))\n nums[-1] = nums[-1] * 2 ** k\n\n return sum(nums)\n\n\ndef main():\n a, b, c = list(map(int, input().split()))\n k = int(input())\n print((answer(a, b, c, k)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "display = sorted(list(map(int, input().split())))\nK = int(input())\n\nmaximum = display[-1]\nfor i in range(K):\n maximum = maximum*2\n# print(maximum)\n# print(display[:-1])\n# print(sum(display[:-1]))\nprint(sum(display[:-1])+maximum)", "A, B, C = sorted([int(i) for i in input().split()])\nK = int(input())\nprint((A + B + (C * (2**K))))\n", "l=list(map(int,input().split()))\nk=int(input())\n\nd=max(l)\ne=d*(2**k)\n\nl.remove(max(l))\nl.append(e)\n\nprint((sum(l)))\n", "argList = list(map(int, input().split()))\nk = int(input())\nprint((sum(argList)-max(argList)) + max(argList)*2**k)", "A,B,C = map(int,input().split())\nMax = max(A,B,C)\nK = int(input())\nMax *= 2**K\nprint(min((A+B+Max),(A+Max+C),(Max+B+C)))", "l = list(map(int,input().split()))\nn = int(input())\nls = sorted(l)\nprint(ls[0]+ls[1]+ls[2]*(2**n))", "lst = input().split()\nK = int(input())\nfor i in range(3):\n lst[i] = int(lst[i])\n\nprint(sum(lst) + (max(lst) * ((2 ** K) - 1)))", "l = list(map(int, input().split()))\nk = int(input())\nfor i in range(k):\n a = max(l)\n i = l.index(a)\n l[i] = l[i] * 2\n \nprint(sum(l))", "def mapt(fn, *args):\n return tuple(map(fn, *args))\n\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\n\ndef main():\n a, b, c = sorted(Input())\n k = int(input())\n\n for i in range(k):\n c *= 2\n print(a+b+c)\n\n\nmain()", "a,b,c=list(map(int,input().split()))\nk=int(input())\nprint(max([a,b,c])*2**k+sum([a,b,c])-max([a,b,c]))", "A,B,C = map(int,input().split())\nK = int(input())\n\nmax_num = max(A,B,C)\nif A == max_num:\n print(A * (2 ** K) + B + C)\nelif B == max_num:\n print(B * (2 ** K) + A + C)\nelse:\n print(C * (2 ** K) + B + A)", "abc = list(map(int, input().split()))\nk = int(input())\nabc.sort()\nprint(sum(abc[:2] ,abc[-1] * (2 ** k)))", "N_List = list(map(int,input().split()))\nN = int(input())\nmaxN = max(N_List)\nprint(sum(N_List)-maxN+maxN*(2**N))", "s=list(map(int,input().split()))\nk=int(input())\ns.sort()\nm=1\nm *= (s[2]*(2**k))\nprint(m+s[0]+s[1])", "a,b,c = map(int, input().split())\nk = int(input())\n\nm = max(a,b,c)\nre = sum([a,b,c]) - m\nprint(re + m*2**(k))", "ABC = [int(_) for _ in input().split()]\nK = int(input())\n\nABC = sorted(ABC)\n\nret = ABC[2]\nfor i in range(K):\n ret = ret * 2\n\nret += sum(ABC[:2])\n\nprint(ret)", "a=list(map(int,input().split()))\nk=int(input())\nc=max(a[0],a[1],a[2])\nb=a[0]+a[1]+a[2]\nb=b-c\nfor i in range(0,k):\n c=c*2\nprint(b+c) ", "A, B, C = [int(i) for i in input().split()]\nK = int(input())\n\nm = max(A, B, C)\nprint((sum([A, B, C]) - m + m * 2 ** K))\n", "num1, num2, num3 = map(int, input().split())\ncount = int(input())\n\nmax_num = max(num1, max(num2, num3))\n\nsum_num = num1 + num2 + num3 - max_num\nend_num = max_num\nfor i in range(count):\n end_num *= 2\n\nprint(sum_num + end_num)", "num_list = list(map(int, input().split()))\nk = int(input())\n\nmax = 0\nindex = -1\nfor i in num_list:\n if max < i:\n max = i\n index = num_list.index(i)\n\nchange = max*(2**k)\nnum_list[index] = change\nans = 0\nfor j in num_list:\n ans += j\n\nprint(ans)", "A, B, C = list(map(int,input().split()))\nK = int(input())\nNumbers = [A,B,C]\n\nNumbers.sort(reverse=True)\n\nfor i in range(K):\n twice = Numbers[0] * 2\n Numbers[0] = twice\n\nprint((sum(Numbers)))\n\n", "mylists = list(map(int, input().split()))\nk = int(input())\n\nmylists.sort(reverse=True)\nprint((mylists[0] * 2 ** k - mylists[0] + sum(mylists)))\n", "a,b,c = map(int,input().split())\nk = int(input())\nprint(max(a,b,c)*(2**k-1)+a+b+c)", "a = list(map(int,input().split()))\nk = int(input())\na.sort()\na[2] = a[2] *(2**k)\nprint(sum(a))", "l = list(map(int, input().split()))\nk = int(input())\ni = l.index(max(l))\nm = l[i]\ndel l[i]\nl.append(m * 2 ** k)\nprint((sum(l)))\n", "n = [int(s) for s in input().split()]\nk = int(input())\n\nfor i in range(k):\n max_id = n.index(max(n))\n n[max_id] *= 2\nprint(sum(n)) ", "a,b,c=list(map(int,input().split()))\nk=int(input())\nd=max(a,b,c)\nprint((a+b+c-d+d*2**k))\n", "a=[int(i) for i in input().split()]\nk=int(input())\n\nsum_a=sum(a)\n\nans=sum_a-max(a)+max(a)*2**k\n\nprint(ans)", "abc = list(map(int, input().split()))\nk = int(input())\nfor i in range(k):\n abc.sort()\n abc[2] *= 2\nprint(sum(abc))", "A=list(map(int,input().split()))\nK=int(input())\nA.sort()\nA[2]=A[2]*2**K\nprint((sum(A)))\n", "ABC = sorted(map(int, input().split()))\nK = int(input())\n\nprint((ABC[0] + ABC[1] + ABC[2] * 2**K))\n", "a = [int(x) for x in input().split()]\nk = int(input())\nprint(sum(a) - max(a) + max(a) * (2 ** k))", "abc = list(map(int, input().split()))\nk = int(input())\nmx = abc.pop(abc.index(max(abc)))\nprint((mx * pow(2, k) + sum(abc)))\n", "l = list(map(int,input().split()))\nk = int(input())\nl.sort(reverse=True)\nfor i in range(k):\n l[0] *= 2\nprint(sum(l))", "#!/usr/bin/env python3\n\n\nabc = list(map(int, input().split()))\nk = int(input())\n\n\nabc.sort()\n\nprint((abc[0]+abc[1]+abc[2]*2**(k)))\n", "#\n# abc096 b\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"5 3 11\n1\"\"\"\n output = \"\"\"30\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"3 3 4\n2\"\"\"\n output = \"\"\"22\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n I = list(map(int, input().split()))\n K = int(input())\n\n for i in range(K):\n t = max(I)\n I.remove(t)\n I.append(t*2)\n\n print((sum(I)))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "A,B,C = sorted(map(int,input().split()))\nK=int(input())\n\nfor i in range(K):\n\tC*=2\n\nprint((A+B+C))\n", "nums = list(map(int, input().split()))\nk = int(input())\nx = max(nums)\nmulx = x*(2**k)\nprint((mulx + sum(nums)-x))\n", "a,b,c = map(int, input().split())\nk = int(input())\nans = a+b+c+max(a,b,c)*(2**k-1)\nprint(ans)", "def resolve():\n a = list(map(int, input().split()))\n k = int(input())\n a.sort()\n for i in range(k):\n a[2] = a[2] * 2\n print(sum(a))\nresolve()", "ABC = list(map(int, input().split()))\nK = int(input())\n\nprint(max(ABC)*(2**K - 1) + sum(ABC))", "A, B, C = map(int, input().split())\nK = int(input())\nif max(A, B, C) == A:\n A *= 2**K\nelif max(A, B, C) == B:\n B *= 2**K\nelse:\n C *= 2**K\nprint(A+B+C)", "List = list(map(int, input().split()))\nK = int(input())\nsort = sorted(List)\nfor i in range(K):\n sort[-1] = sort[-1]*2\nprint((sum(sort))) \n", "a = list(map(int, input().split()))\nk = int(input())\na.sort(reverse=True)\na[0] *= 2**k\nprint(sum(a))", "a,b,c = map(int,input().split())\nk = int(input())\nprint(max(a,b,c)*(2**k-1)+a+b+c)", "a,b,c=sorted(map(int,input().split()))\nprint(a+b+pow(2,int(input()) )*c )", "A=list(map(int,input().split()))\nK=int(input())\n\nans=sum(A)\nans+=max(A)*(2**K-1)\nprint(ans)", "a,b,c = map(int,input().split())\nk = int(input())\nprint(max(a,b,c)*(2**k-1)+a+b+c)", "import heapq\n\nval = list(map(lambda x: -int(x), input().split()))\nK = int(input())\n\nheapq.heapify(val)\n\nfor i in range(K):\n v = heapq.heappop(val)\n heapq.heappush(val, v * 2)\n\nprint(-sum(val))", "A=list(map(int,input().split()))\n\nK=int(input())\n\nA.sort(reverse=True)\n\nprint((A[0]*2**K+A[1]+A[2]))\n", "l = list(map(int,input().split()))\nn = int(input())\nls = sorted(l)\nprint(ls[0]+ls[1]+ls[2]*(2**n))", "A = list(map(int,input().split()))\nK = int(input())\n\nfor i in range(K):\n max_A = max(A)\n A.append(max_A * 2)\n A.remove(max_A)\n\nprint(sum(A))", "nums = sorted(list(map(int, input().split())), reverse=True)\nK = int(input())\n\nprint(nums[0]*(2**K) + nums[1] + nums[2])", "a,b,c=list(map(int,input().split()))\nk=int(input())\nprint((a+b+c-max(a,b,c)+max(a,b,c)*pow(2,k)))\n", "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n ABC = LI()\n K = I()\n ABC.sort()\n\n ans = sum(ABC[:2]) + ABC[2] * 2 ** K\n print(ans)\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "a = list(map(int, input().split()))\nk = int(input())\n\na.sort()\n\nprint(sum(a[:-1]) + a[-1] * 2 ** k)", "m, *A = sorted([int(x) for x in input().split()], reverse=True)\nK = int(input())\n \nprint((m * 2**K) + sum(A))", "a,b,c = map(int, input().split())\nk = int(input())\nl = [a,b,c]\nl.sort()\nprint(l[-1]*2**k + sum(l[:-1]))", "a, b, c = map(int, input().split())\nk = int(input())\nx = max(a, b, c)\nif x == a:\n print(a*2**k + b + c)\nelif x == b:\n print(a + b*2**k + c)\nelse:\n print(a + b + c*2**k)", "a, b, c = map(int, input().split())\nk = int(input())\nm = max(a, b, c)\n\nfor i in range(k):\n m *= 2\n \nprint(sum([a, b, c]) - max(a, b, c) + m)", "A, B, C = map(int, input().split())\nK = int(input())\nprint(sum([A, B, C])+max(A, B, C)*2**K-max(A, B, C))", "a=list(map(int,input().split()))\nb=int(input())\na.sort()\nprint(a[0]+a[1]+(a[2]*(2**b)))", "l = list(map(int, input().split()))\nk = int(input())\nl.sort()\nprint(l[0] + l[1] + l[2] * (2 ** k))", "a = sorted(list(map(int, input().split())))\nm = a.pop()\nfor i in range(int(input())):\n m *= 2\nprint(sum(a) + m)", "list_abc = sorted([int(i) for i in input().split()])\nk = int(input())\nprint(list_abc[2] * 2 ** k + sum(list_abc[:2]))", "a,b,c=map(int,input().split())\nk=int(input())\nprint((2**k-1)*max([a,b,c])+sum([a,b,c]))", "a = list(map(int, input().split()))\na.sort()\nk = int(input())\nres = a[0] + a[1] + a[2] * (2 ** k)\nprint(res)\n", "a,b,c = map(int, input().split())\nk = int(input())\nprint(a+b+c+max(a,b,c)*((2**k)-1))", "a = list(map(int, input().split()))\nk = int(input())\n\na.sort()\na[-1] *= 2 ** k\n\nprint((sum(a)))\n"] | {"inputs": ["5 3 11\n1\n", "3 3 4\n2\n"], "outputs": ["30\n", "22\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 15,106 | |
7009ec6050aa25cc0be3e362f5b4a0db | UNKNOWN | Let w be a string consisting of lowercase letters.
We will call w beautiful if the following condition is satisfied:
- Each lowercase letter of the English alphabet occurs even number of times in w.
You are given the string w. Determine if w is beautiful.
-----Constraints-----
- 1 \leq |w| \leq 100
- w consists of lowercase letters (a-z).
-----Input-----
The input is given from Standard Input in the following format:
w
-----Output-----
Print Yes if w is beautiful. Print No otherwise.
-----Sample Input-----
abaccaba
-----Sample Output-----
Yes
a occurs four times, b occurs twice, c occurs twice and the other letters occur zero times. | ["import sys\nimport string\nw = input()\na_z = string.ascii_letters\nfor i in a_z:\n if w.count(i) & 1:\n print('No')\n return\nprint('Yes')", "# import math\n# import statistics\na=input()\n#b,c=int(input()),int(input())\nc=[]\nfor i in a:\n c.append(i)\n#e1,e2 = map(int,input().split())\n# f = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\n# h = []\n# for i in range(e1):\n# h.append(list(map(int,input().split())))\nse=set(c)\nc.sort()\ncount=1\nres=[]\nfor i in range(len(c)-1):\n if c[i]==c[i+1]:\n count+=1\n else:\n if count%2==0:\n res.append(c[i])\n count=1\nif count%2==0:\n res.append(c[-1])\nif len(res)==len(se):\n print(\"Yes\")\nelse:\n print(\"No\")\n", "w=input()\nS=\"abcdefghijklmnopqrstuvwxyz\"\n\nflag=True\nfor c in S:\n if w.count(c)%2==1:\n flag=False\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "import collections\nw = input()\nc = collections.Counter(w)\nfor i in c.values():\n if i%2==1:\n print('No')\n break\nelse:\n print('Yes')", "a = input()\ndic = {}\nfor i in a:\n if i in dic:\n dic[i] += 1\n else:\n dic[i] = 1\nfor i in dic:\n if dic[i] % 2 != 0:\n print(\"No\")\n return\nprint(\"Yes\")", "s=[*input()];print('NYoe s'[all([s.count(i)%2==0 for i in set(s)])::2])", "w = input()\nd = {}\nfor i in range(len(w)):\n if w[i] not in list(d.keys()):\n d[w[i]] = 1\n else:\n d[w[i]] += 1\n\nfor v in list(d.values()):\n if v%2 != 0:\n print(\"No\")\n return\nprint(\"Yes\")\n", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\nw = input()\nfor i in \"abcdefghijklmnopqrstuvwxyz\":\n if w.count(i)%2==1:\n print(\"No\")\n return\n\nprint(\"Yes\")", "w = input()\n\na = ord('a')\nz = ord('z')\n\nfor i in range(a,z+1):\n x = w.count(chr(i))\n if x%2 == 1:\n print('No')\n return\n \nprint('Yes')\n", "S = input()\n\nP = set()\nfor s in S:\n if s not in P and S.count(s)%2 != 0:\n print(\"No\")\n return\n P.add(s)\nprint(\"Yes\")", "from sys import stdin\ninput = stdin.readline\n\nD = {'a':0, 'b':1, 'c':2, 'd':3, 'e':4,\n 'f':5, 'g':6, 'h':7, 'i':8, 'j':9,\n 'k':10,'l':11,'m':12,'n':13,'o':14,\n 'p':15,'q':16,'r':17,'s':18,'t':19,\n 'u':20,'v':21,'w':22,'x':23,'y':24,'z':25}\n\nW = list(input().strip())\n\nT = [0] * 26\n\nfor w in W:\n T[D[w]] += 1\n\nb = True\nfor i in range(26):\n if T[i]%2 == 1:\n b = False\n break\nif b == True:\n print('Yes')\nelse:\n print('No')", "w = list(input())\nx = list(set(w))\nfor i in x:\n y = w.count(i)\n if y % 2 != 0:\n print('No')\n return\nprint('Yes')", "s = str(input())\ntemp = 'a'\nflag = 0\nfor i in range(1,27):\n if s.count(temp)%2==1:\n flag=1\n break\n temp = chr(ord(temp) + 1)\nif flag==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\ndic = 'abcdefghijklmnopqrstuvwxyz'\nfor i in range(26):\n if n.count(str(dic[i]))%2!=0:\n print(\"No\")\n return\nprint(\"Yes\")", "w=input()\na=\"abcdefghijklmnopqrstuvwxyz\"\nb=0\nfor i in range(26):\n if w.count(a[i])%2==0:\n b+=0\n else:\n b+=1\nprint(\"Yes\" if b==0 else \"No\")", "import collections \n\nw = str(input())\nx = collections.Counter(w)\nn = 0\n\n \nfor i in list(x.values()):\n if i % 2 ==0:\n n += 1\n continue\n \n\nif n == len(list(x.values())):\n print('Yes')\n\nelse:\n print('No')\n\n \n", "import collections as c\nprint('NYoe s'[all([1 if i%2==0 else 0 for i in c.Counter(input()).values()])::2])", "w = input()\nalpha = \"abcdefghijklmnopqrstuvwxyz\"\n\ncheck = True\nfor a in alpha:\n if w.count(a) % 2 == 1:\n check = False\n \nprint(\"Yes\" if check else \"No\")", "w = input()\nwhile len(w) > 0:\n a = w[0]\n if w.count(a)%2 != 0:\n print(\"No\")\n return\n w = w.replace(a,\"\")\nprint(\"Yes\")", "w = list(input())\ns = set(w)\nfor i in s:\n if w.count(i)%2 != 0:\n print(\"No\")\n break\nelse:\n print(\"Yes\")\n", "w = list(input())\n\nw.sort()\n\ncnt = 1\n\nfor i in range(len(w)-1):\n if w[i] != w[i+1]:\n if cnt % 2 == 1:\n print('No')\n return\n else:\n cnt = 1\n else:\n cnt += 1\n\nif cnt % 2 == 1:\n print('No')\nelse:\n print('Yes')", "w=input()\nre=[w.count(i) for i in w]\nprint(\"Yes\" if all(i%2==0 for i in re) else \"No\")", "import collections\nw = list(input())\nwc = collections.Counter(w)\nnum = 0\nfor i, x in enumerate(wc):\n if(wc[x]%2==0):\n num += 1\nif(num==len(wc)):\n print('Yes')\nelse:\n print('No')", "w = input()\nfor i in range(len(w)):\n if w.count(w[i]) % 2 == 1:\n print('No')\n return\nprint('Yes')", "s = input()\nd = {}\nfor i in range(len(s)):\n if s[i] in d:\n d[s[i]] += 1\n else:\n d[s[i]] = 1\nfor v in d.values():\n if v % 2:\n print('No')\n return\nprint('Yes')", "w = input()\nchar_map = { c: 0 for c in w }\nfor c in w:\n char_map[c] += 1\n\nflag = True\nfor val in list(char_map.values()):\n if val % 2 != 0:\n flag = False\n break\n\nprint(('Yes' if flag else 'No'))\n", "import collections\nimport sys\na=input()\nb=[]\n\nfor i in a:\n b.append(i)\n \nb.sort()\nc=collections.Counter(b)\nc=list(c.values())\n\nfor i in range(len(c)):\n if int(c[i])%2==0:\n q=0\n else:\n q=1\n print('No')\n return\n \nprint('Yes')\n", "import string\n\nw = list(map(str, input()))\nans = \"\"\n\nalp = list(map(str, string.ascii_lowercase))\nfor char in alp:\n if w.count(char) % 2 == 0:\n ans = \"Yes\"\n else:\n ans = \"No\"\n break\nprint(ans)", "a = input()\n\nfor i in a:\n\tif a.count(i)%2==1:\n\t\tprint(\"No\")\n\t\t\n\t\treturn\n\nprint(\"Yes\")", "import collections\nw = list(input())\nc = collections.Counter(w)\ntmp = list(c.values())\nfor i in tmp:\n if i % 2 == 1:\n print(\"No\")\n return\nprint(\"Yes\")", "from collections import Counter\nw = input()\nc = Counter(w)\nans = True\nfor v in c.values():\n if v%2==1:\n ans = False\nprint(\"Yes\" if ans == True else \"No\")", "from collections import Counter\n\n\ndef answer(w: str) -> str:\n counts = list(Counter(w).values())\n for count in counts:\n if count % 2 == 1:\n return 'No'\n\n return 'Yes'\n\ndef main():\n w = input()\n print((answer(w)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "import collections\nw = list(input())\n\ncnt = collections.Counter(w)\nans = \"Yes\"\nfor v in list(cnt.values()):\n if v%2!=0:\n ans = \"No\"\n break\n \nprint(ans)\n", "s = list(input())\nif all(s.count(x) % 2 == 0 for x in set(s)):\n print(\"Yes\")\nelse:\n print(\"No\")", "w=sorted(input())\ntotal=False\nif len(w)==1:\n total=True\n print(\"No\")\nelse:\n for i in range(0,len(w),2):\n if w[i]!=w[i+1]:\n print(\"No\")\n total=True\n break\nif total==False:\n print(\"Yes\")", "w = input()\nfrom collections import Counter\nwc = Counter(w)\n\nfor c in wc.values():\n if c%2 == 1:\n print('No')\n break\nelse:\n print('Yes')", "s=input();print('NYoe s'[all([s.count(i)%2==0 for i in s])::2])", "w = str(input())\nL = []\nfor i in w:\n L.append(i)\nif len(L) % 2 == 1:\n print('No')\n return\nL.sort()\nfor j in range(0,len(L),2):\n if L[j] != L[j + 1]:\n print('No')\n return\nprint('Yes')\n \n", "from collections import Counter\n\nw = input()\nc = Counter(w)\nfor i in c.values():\n if i % 2 != 0:\n print('No')\n return\nprint('Yes')", "w=input()\na=list('abcdefghijklmnopqrstuvwxyz')\nfor A in a:\n if w.count(A) % 2 == 1:\n print('No')\n return\nprint('Yes')", "li = [0]*26\nw = input()\nfor i in range(len(w)):\n li[ord(w[i])-97] += 1\nfor i in range(26):\n if li[i] % 2 == 1:\n print(\"No\")\n return\nprint(\"Yes\")", "W = input()\nexist_list = []\nans = \"No\"\nfor w in W:\n if w in exist_list:\n continue\n\n if W.count(w) % 2 != 0:\n break\n\n exist_list.append(w)\nelse:\n ans = \"Yes\"\n\nprint(ans)\n", "w = input()\n\nw_list = [a for a in w]\nw_set = set(w_list)\n\nans = 'Yes'\nfor i in w_set:\n if w_list.count(i)%2 != 0:\n ans = 'No'\n break\n\nprint(ans)", "a=input();b=set(a)\n\nfor i in b:\n if a.count(i) % 2 != 0:\n print('No')\n return\n \nprint('Yes')\n", "from collections import Counter\n\nW = input()\nC = Counter(W)\n\nfor v in list(C.values()):\n if v % 2:\n print(\"No\")\n return\nprint(\"Yes\")\n", "w = str(input())\ndata1 = []\nfor i in range(len(w)):\n data1.append(w[i])\n \ndata2 = []\nfor i in range(len(w)):\n if not w[i] in data2:\n data2.append(w[i])\n\nerror = 0\nfor x in data2:\n if data1.count(x) % 2 != 0:\n error += 1\n break\n\nif error == 0:\n print('Yes')\nelse:\n print('No')", "w = list(input())\ns = set(w)\nfor i in s:\n if w.count(i)%2 != 0:\n print(\"No\")\n break\nelse:\n print(\"Yes\")", "W = input()\ns = list(set(W))\nl = len(s)\n\n\nfor i in range(l):\n for a in s[i]:\n if W.count(a)%2 == 1:\n print(\"No\")\n return\n else:\n break\nprint(\"Yes\")\n", "l = input()\n\nfor i in l:\n if l.count(i) % 2 == 1:\n print(\"No\")\n return\nprint(\"Yes\")", "w = input()\nans = 'Yes'\nif len(w) % 2 == 1:\n ans = 'No'\nelse:\n s = sorted(w)\n count = 1\n for i in range(1, len(s)):\n if s[i] == s[i - 1]:\n count += 1\n else:\n if count % 2 == 1:\n ans = 'No'\n break\n count = 1\nprint(ans)", "from collections import Counter as CC\nw = list(input())\nD = CC(w)\nfor i in D:\n if D[i] % 2 != 0:\n print('No')\n break\nelse:\n print('Yes')", "w = input()\nD = {}\nfor i in w:\n if i not in D:\n D[i] = 0\n D[i] += 1\nfor i in D:\n if D[i] % 2 == 1:\n print('No')\n break\nelse:\n print('Yes')", "w = input()\nl = [chr(ord(\"a\")+i) for i in range(26)]\nfor i in l:\n if w.count(i) % 2 != 0:\n print('No')\n return\nprint('Yes')", "w = input()\nans = True\n\nfor i in w:\n cnt = 0\n for j in w:\n if i == j:\n cnt += 1\n if cnt%2 != 0:\n ans = False\n break\n \nif ans:\n print(\"Yes\")\nelse:\n print(\"No\")", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n S = input().rstrip()\n s_dict={}\n\n for s in S:\n if s not in s_dict:\n tmp={s:1}\n s_dict.update(tmp)\n else:\n count=s_dict[s]\n count+=1\n s_dict[s]=count\n \n for i,v in s_dict.items():\n if v % 2 !=0:\n print(\"No\")\n return\n else:\n continue \n print(\"Yes\")\ndef __starting_point():\n main()\n__starting_point()", "w = input()\nx = set(w)\ny = []\nfor i in x:\n y.append(w.count(i))\nfor j in y:\n if j%2 == 0:\n continue\n else:\n print(\"No\")\n return\nprint(\"Yes\")\n", "s = input()\nal = \"abcdefghijklmnopqrstuvwxyz\"\nf = True\nfor e in al:\n if s.count(e)%2 != 0:\n f = False\n break\nprint(\"Yes\" if f else \"No\")", "w = input()\n\nimport collections as c\n\ncounts = c.Counter(w)\nif all(elem % 2 == 0 for elem in counts.values()):\n print('Yes')\nelse:\n print('No')", "data = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nw = input()\n\n\nfor i in range(26):\n if w.count(data[i]) % 2 != 0:\n print('No')\n return\nprint('Yes')", "a = list(input())\na.sort()\nb = list(set(a))\nfor i in range(len(b)):\n if a.count(b[i]) % 2 == 0:\n continue\n else:\n print(\"No\")\n return\nprint(\"Yes\")", "from collections import deque\nd = deque()\nfor w in input():\n d.remove(w) if w in d else d.append(w) \nprint(['Yes','No'][len(d)!=0])", "s = input()\ndi = {}\nfor c in s:\n di[c] = 0\nfor c in s:\n di[c] +=1\n \nis_beautiful = True\nfor c in s:\n if di[c] %2 ==1:\n is_beautiful = False\n\nprint(('Yes' if is_beautiful else 'No'))\n", "import sys\nw=input()\ncount={}\nfor i in w:\n count.setdefault(i,0)\n count[i]+=1\nfor j in list(count.values()):\n if j%2!=0:\n print('No')\n return\nprint('Yes')\n", "a = input()\n \nfor i in a:\n\tif a.count(i)%2==1:\n\t\tprint(\"No\")\n\t\t\n\t\treturn\n \nprint(\"Yes\")", "import collections\nw = list(input())\n\ncnt = collections.Counter(w)\nans = \"Yes\"\nfor v in cnt.values():\n if v%2!=0:\n ans = \"No\"\n break\n \nprint(ans)", "w = input()\nw_set = set(w)\nd = {}\nfor i in w_set:\n d[i] = 0\nfor i in w:\n d[i] += 1\n\nfor i in d.values():\n if i % 2 != 0:\n print(\"No\")\n break\nelse:\n print(\"Yes\")", "w = input()\n\ndic = {}\nfor c in w:\n if c not in dic:\n dic[c] = 1\n else:\n dic[c] += 1\n \nfor key in dic:\n if dic[key] % 2 != 0:\n print(\"No\")\n return\nprint(\"Yes\")\n", "w=input()\nl=[0 for _ in range(26)]\nFlag=True\nfor i in w:\n num=ord(i)-97\n #print(num)\n l[num]+=1\nfor i in l:\n if i%2==1:\n Flag=False\nif Flag:\n print('Yes')\nelse:\n print('No')\n", "import collections\nw = list(str(input()))\nl = collections.Counter(w)\ns = set(w)\n\nfor i in s:\n if int(l[i])%2 != 0:\n print('No')\n break\nelse:\n print('Yes')\n", "w = input()\nwl = []\n\nfor i in range(len(w)):\n wl.append(w[i])\n \nwl.sort()\n\na = 1\njudge = 1\nif len(w)%2 == 0:\n for n in range(len(w)-1):\n if wl[a+n] == wl[a+n-1]:\n judge += 1\n else:\n if judge%2 != 0:\n print(\"No\")\n return\n else:\n judge = 1\n if n == len(w)-2:\n if judge%2 == 0:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "S = input()\nfor i in range(len(S)):\n if S.count(S[i])%2 == 1:\n print(\"No\")\n return\nprint(\"Yes\")", "import collections\n\nw = list(input())\nc = collections.Counter(w)\nif all(x % 2 == 0 for x in c.values()):\n print('Yes')\nelse:\n print('No')", "s = input()\nflag = [0] * 26\n\nfor i in range(len(s)):\n flag[ord(s[i])-97] += 1\n\nres = \"Yes\"\n\nfor i in range(26):\n if flag[i] % 2 == 1:\n res = \"No\"\n\nprint(res)", "w = input()\nf = True\nfor i in w:\n c = 0\n for k in w:\n if i == k:\n c += 1\n\n if c % 2 != 0:\n f = False\nif not f:\n print(\"No\")\nelse:\n print(\"Yes\")\n", "def main():\n w = str(input())\n wl = []\n for ww in w :\n wl.append(ww)\n if len(w) % 2 != 0 :\n ans = \"No\"\n else :\n ans = \"Yes\"\n for val in wl :\n if wl.count(val) % 2 == 0 :\n pass\n else :\n ans = \"No\"\n break\n print(ans)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "w = input()\nbea = True\n\nelements = set(list(w))\nfor element in elements:\n if w.count(element) % 2 != 0:\n print(\"No\")\n bea = False\n break\n\nif bea:\n print(\"Yes\")", "import math\nfrom datetime import date\n\ndef main():\n\t\n\ts = input()\n\ta = [0 for i in range(26)]\n\n\tfor c in s:\n\t\ta[ord(c) - ord('a')] += 1\n\n\tok = 'True'\n\tfor i in range(26):\n\t\tif a[i] % 2 == 1:\n\t\t\tok = 'False'\n\n\tif ok == 'True':\n\t\tprint(\"Yes\")\n\telse:\n\t\tprint(\"No\")\n\nmain()\n", "w = input()\ncnt = [0] * 26\nfor c in w:\n n = ord(c) - ord('a')\n cnt[n] += 1\nfor temp in cnt:\n if temp % 2 != 0:\n print(\"No\")\n return\nelse:\n print(\"Yes\")", "w = input()\n\nfor i in w:\n count = 0\n for j in w:\n if i == j:\n count += 1\n if count % 2 != 0:\n ans = 'No'\n break\n else:\n ans = 'Yes'\nprint(ans)\n", "w = input()\n\nd = {}\n\nfor i in list(w):\n if i not in list(d.keys()):\n d[i] = 1\n else:\n d[i] += 1\n\nans = 'Yes'\nfor _, v in list(d.items()):\n if v%2 != 0:\n ans = 'No'\n break\nprint(ans)\n", "import collections\nS = list(input())\nD = collections.Counter(S)\nans = 'Yes'\n\nfor v in D.values():\n if v % 2 != 0:\n ans = 'No'\n break\n\nprint(ans)", "from collections import Counter\nw = input()\nd = Counter(w)\nif (sum(d.values())) % 2 == 0 and len([c for c in d.values() if c %2 ==0]) == len(d):\n print(\"Yes\")\nelse:\n print(\"No\")", "W = input()\nans = 'Yes'\n\nif len(W)%2 == 0:\n W_ele = set([w for w in W])\n for w in W_ele:\n if W.count(w) % 2 == 1:\n ans = 'No'\nelse:\n ans = 'No'\nprint(ans)", "from collections import Counter\n\nw = input()\n\nw = Counter(w)\n\nresult = 'Yes'\nfor v in w.values():\n if v % 2 == 0:\n continue\n else:\n result = 'No'\n break\nprint(result)", "\nw = input()\ns = set(list(w))\n\nfor item in s:\n if w.count(item) % 2 != 0:\n print('No')\n return\nprint('Yes')", "w=input()\nans=\"Yes\"\nfor i in w:\n if w.count(i)%2!=0:\n ans=\"No\"\n break\nprint(ans)", "w = input()\nans = \"Yes\"\n\nfor i in range(26):\n if w.count(chr(ord(\"a\")+i)) % 2 == 1:\n ans = \"No\"\n break\n\nprint(ans)\n", "w = input()\nw_set = set(w)\nd = {}\nfor i in w_set:\n d[i] = 0\nfor i in w:\n d[i] += 1\n\nfor i in d.values():\n if i % 2 != 0:\n print(\"No\")\n return\nprint(\"Yes\")", "import collections\ns = input()\nl = collections.Counter(s)\nfor i in l.values():\n if i % 2 != 0:\n print(\"No\")\n return\nprint(\"Yes\")", "s = input()\nprint(\"Yes\" if all(s.count(i)%2==0 for i in set(s)) else \"No\")", "w=input()\ndi={}\nfor i in w:\n if i in di:\n di[i]+=1\n else:\n di[i]=1\nfor i in di.values():\n if i&1:\n print(\"No\")\n return\nprint(\"Yes\")", "w = input()\nans = True\nfor i in w:\n cnt = 0\n for j in w:\n if i == j:\n cnt += 1\n if cnt % 2 != 0:\n ans = False\n break\n \nif ans:\n print(\"Yes\")\nelse:\n print(\"No\")", "# -*- coding: utf-8 -*-\n\nS = list(input())\ncun = 0\nss = set()\n\nfor i in S:\n ss.add(i)\n\nfor i in ss:\n cun = 0\n\n for p in range(len(S)):\n if i == S[p]:\n cun += 1\n if cun % 2 != 0:\n print(\"No\")\n return\n\nprint(\"Yes\")\n\n\n", "from collections import Counter\n\nw = Counter([c for c in input()])\nif all([v % 2 == 0 for k, v in w.items()]):\n print('Yes')\nelse:\n print('No')", "w = input()\nfor c in set(w):\n if w.count(c) % 2:\n print('No')\n break\nelse:\n print('Yes')", "s=input();print('NYoe s'[all([s.count(i)%2==0 for i in set(s)])::2])", "s=[*input()];print('NYoe s'[all([1 if s.count(i)%2==0 else 0 for i in set(s)])::2])", "w = input()\na = 0\nfor i in range(97, 124):\n cnt = 0\n for j in w:\n if j == chr(i):\n cnt += 1\n if cnt%2 != 0:\n print(\"No\")\n break\n else:\n a += 1\n if a == 27:\n print(\"Yes\")\n break", "s = input()\nfor i in range(len(s)):\n if s.count(s[i]) % 2 != 0:\n print('No')\n return\nprint('Yes')"] | {"inputs": ["abaccaba\n", "hthth\n"], "outputs": ["Yes\n", "No\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 19,545 | |
2d67bfce9ac9bb116b1c2f9a98a3a6a0 | UNKNOWN | There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i-th operation (1β€iβ€N), b_i copies of an integer a_i are inserted into the array.
Find the K-th smallest integer in the array after the N operations.
For example, the 4-th smallest integer in the array \{1,2,2,3,3,3\} is 3.
-----Constraints-----
- 1β€Nβ€10^5
- 1β€a_i,b_iβ€10^5
- 1β€Kβ€b_1β¦+β¦b_n
- All input values are integers.
-----Input-----
Input is given from Standard Input in the following format:
N K
a_1 b_1
:
a_N b_N
-----Output-----
Print the K-th smallest integer in the array after the N operations.
-----Sample Input-----
3 4
1 1
2 2
3 3
-----Sample Output-----
3
The resulting array is the same as the one in the problem statement. | ["n, k = list(map(int, input().split()))\nab = [list(map(int, input().split())) for _ in range(n)]\n\nab.sort()\n\nnum_sum = 0\n\nfor a, b in ab:\n num_sum += b\n if num_sum >= k:\n print(a)\n return\n", "N, K = map(int, input().split())\narr = [0]*(10**5+1)\n\nfor i in range(N):\n a,b = map(int, input().split())\n arr[a] += b\n\ns = 0\nfor i in range(10**5+1):\n s += arr[i]\n if s >= K:\n print(i)\n break", "N, K = map(int, input().split())\ns = 0\nab = [[0, 0] for i in range(N)]\nfor i in range(N):\n ab[i][0], ab[i][1] = map(int, input().split())\nab = sorted(ab)\n\n#print(ab)\nfor i in range(N):\n s += ab[i][1]\n if s >= K:\n print(ab[i][0])\n break", "from sys import stdin\ninput = stdin.readline\n \nfrom itertools import accumulate\nfrom bisect import bisect_left\n \nN, K = map(int, input().split())\n \nmemo = [0] * 100010\nfor _ in range(N):\n a, b = map(int, input().split())\n memo[a] += b\n \nprint(bisect_left(list(accumulate(memo)), K))", "n, k = list(map(int, input().split()))\nbucket = [0] * 10 ** 5\nfor i in range(n):\n a, b = list(map(int, input().split()))\n bucket[a - 1] += b\n\nsum_b = 0\nfor i in range(len(bucket)):\n sum_b += bucket[i]\n if sum_b >= k:\n print((i + 1))\n break\n", "N,K = map(int,input().split())\nls = [list(map(int,input().split())) for _ in range(N)]\n\nls.sort(key=lambda x: x[0])\ns = 0\n\nfor i in range(N):\n s += ls[i][1]\n if s >= K: break\n \nprint(ls[i][0])", "N,K,*AB=[int(a)for a in open(0).read().split()]\nAB=sorted(zip(AB[::2],AB[1::2]))\ncnt=0\nfor a,b in AB:\n cnt+=b\n if cnt>=K:\n print(a)\n return", "f=lambda l:map(int,l.split())\nN,K=f((p:=input)());c=[0]*(l:=10**5+1);s=0\nfor i in (r:=range)(N):a,b=f(p());c[a]+=b\nfor i in r(l):\n s+=c[i]\n if s>=K: print(i);break", "from collections import defaultdict\n\nN, K, *ab = list(map(int, open(0).read().split()))\ncnt = defaultdict(int)\n\nfor a, b in zip(*[iter(ab)] * 2):\n cnt[a] += b\nli = [(k, v) for k, v in list(cnt.items())]\nli.sort()\n\nfor a, b in li:\n if K - b > 0:\n K -= b\n else:\n print(a)\n break\n", "n,k = map(int, input().split())\na = []\nfor i in range(n):\n\ta.append(list(map(int, input().split())))\n\na = sorted(a, key = lambda x:x[0])\n\nx = 0\nfor i in a:\n\tx += i[1]\n\tif x >= k:\n\t\tbreak\nprint(i[0])", "n, k = map(int, input().split())\nal = [0]*(10**5+1)\n\nfor _ in range(n):\n a, b = map(int, input().split())\n al[a] += b\n\ncnt = 0\ni = 0\nwhile cnt < k:\n cnt += al[i]\n i += 1\n\nprint(i-1)", "N,K,*l=map(int,open(0).read().split())\nfor a,b in sorted(zip(l[::2],l[1::2])):\n\tif(K:=K-b)<=0:break\nprint(a)", "n,k=map(int,input().split())\ns=[0]*10**5\nfor i in range(n):\n a,b=map(int,input().split())\n s[a-1]+=b\ni=0\nwhile k>0:\n k-=s[i]\n i+=1\nprint(i)", "n,k,*x=list(map(int, open(0).read().split()))\nfor a,b in sorted(zip(x[0::2],x[1::2])):\n k-=b\n if k < 1:\n print(a);break\n", "N,K = list(map(int,input().split()))\nA = []\nfor i in range(N):\n a,b = list(map(int,input().split()))\n A.append([a,b])\nA.sort()\n\nfor i in range(N):\n K = K - A[i][1]\n if K <= 0:\n print((A[i][0]))\n return\n", "def main():\n N, K = list(map(int, input().split()))\n lis = []\n for i in range(N):\n a, b = list(map(int, input().split()))\n lis.append((a, b))\n\n lis = sorted(lis)\n\n for i in range(N):\n K -= lis[i][1]\n if K <= 0:\n print((lis[i][0]))\n break\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "from collections import defaultdict\nn,k = map(int, input().split())\nans = 0\nal = []\nd = defaultdict(int)\nfor i in range(n):\n a,b = map(int, input().split())\n al.append(a)\n d[a] += b\nal = list(set(al)) \nal.sort()\nfor i in al:\n if k > d[i]:\n k -= d[i]\n else:\n print(i)\n break", "# ABC 061: C \u2013 Big Array\nN, K = [int(i) for i in input().split()]\na, b = [], []\nfor _ in range(N):\n tmp = input().split()\n a.append(int(tmp[0]))\n b.append(int(tmp[1]))\n\ncnt = [0] * (100000 + 1)\n\nfor i in range(N):\n cnt[a[i]] += b[i]\n\nfor j in range(100000 + 1):\n if K <= cnt[j]:\n print(j)\n break\n K -= cnt[j]", "n,k=map(int,input().split())\nl=sorted([list(map(int,input().split()))for i in range(n)])\nfor a,b in l:\n k-=b\n if k<1:\n print(a);break", "\n\ndef main():\n N, K = list(map(int, input().split()))\n box = []\n for _ in range(N):\n ab = list(map(int, input().split()))\n box.append(ab)\n\n box.sort(key= lambda x: x[0])\n ans = 0\n for b in box:\n if ans + b[1] < K:\n ans += b[1]\n else:\n print((b[0]))\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n,k=map(int,input().split())\nans=[0]*(10**5+1)\nfor i in range(n):\n a,b=map(int,input().split())\n ans[a]+=b\n \nfor i in range(len(ans)):\n k-=ans[i]\n if k<=0:\n print(i)\n break", "N, K = map(int, input().split())\na = []\nb = []\nSum = 0\nfor i in range(N):\n x, y = map(int, input().split())\n a.append(x)\n b.append(y)\ns = [*range(len(a))]\nsort_s = sorted(s, key = lambda i: a[i])\nsort_a = [a[i] for i in sort_s]\nsort_b = [b[i] for i in sort_s]\nfor i in range(N):\n Sum += sort_b[i]\n if Sum >= K:\n print(sort_a[i])\n break", "from xml.dom import minidom\n\n\nn, k = list(map(int, input().split()))\n\nAB = [list(map(int, input().split())) for _ in range(n)]\nAB.sort()\n\nnow = -1\nidx = 0\nwhile k > 0:\n if idx >= n:\n break\n a, b = AB[idx]\n k -= b\n now = a\n idx += 1\nprint(now)\n", "n,k=map(int,input().split())\ncount=0\nba=[0]*(10**5+1)\nfor i in range(n):\n a,b=map(int,input().split())\n ba[a]+=b\n \nfor i in range(len(ba)):\n k-=ba[i]\n if k<=0:\n print(i)\n break", "n,k=[int(i) for i in input().split()]\n\nclass Number:\n def __init__(self,number,times):\n self.number=number\n self.times=times\n\n def __eq__(self, other):\n if self.number==other.number:\n return True\n return False\n def __le__(self, other):\n if self.number<=other.number:\n return True\n return False\n def __lt__(self, other):\n if self.number<other.number:\n return True\n return False\n def __ge__(self, other):\n if self.number>=other.number:\n return True\n return False\n def __gt__(self, other):\n if self.number>other.number:\n return True\n return False\n\nnumber_list=[]\nfor i in range(n):\n number,times=[int(i) for i in input().split()]\n number_list.append(Number(number,times))\n\nnumber_list.sort()\n\n\ndef get(number_list,k):\n i=0\n while True:\n taishou=number_list[i]\n k=k-taishou.times\n if k<=0:\n return taishou.number\n else:\n i+=1\nprint(get(number_list,k))", "N,K,*l=map(int,open(c:=0).read().split())\nd={}\nfor a,b in zip(l[0::2],l[1::2]):d[a]=d.get(a,0)+b\nfor k in sorted(d.keys()):\n\tif (c:=c+d[k])>=K:break\nprint(k)", "n, k = list(map(int, input().split()))\na = [0] * n\nb = [0] * n\nfor i in range(n):\n a[i], b[i] = list(map(int ,input().split()))\n\n\njudge = 0\ndic = {}\n\n\nfor i in range(n):\n if a[i] in dic:\n dic[a[i]] += b[i]\n else:\n dic[a[i]] = b[i]\n#print(dic)\ndic = list(dic.items())\ndic.sort()\n#print(dic)\n\n\nfor i in range(10**9):\n if judge >= k:\n print((dic[i-1][0]))\n break\n else:\n judge += int(dic[i][1])\n #print(judge)\n", "n, k = list(map(int, input().split()))\nsum_b = 0\nab_list = []\n\nfor i in range(n):\n ab_list.append(list(map(int, input().split())))\n\nab_list.sort()\nfor i in range(n):\n a, b = ab_list[i]\n sum_b += b\n if sum_b >= k:\n print(a)\n break\n", "n,k=map(int,input().split())\nab=[list(map(int,input().split())) for i in range(n)]\nres=k\nab.sort()\nfor i in range(n):\n res-=ab[i][1]\n if res<=0:\n print(ab[i][0])\n return", "N,K,*l=map(int,open(0).read().split())\nfor a,b in sorted(zip(*[iter(l)]*2)):\n\tif(K:=K-b)<1:break\nprint(a)", "N, K = map(int, input().split())\nd = {}\nkey = set([])\nfor _ in range(N):\n a, b = map(int, input().split())\n if a in key:\n d[str(a)] += b\n else:\n key.add(a)\n d[str(a)] = b\nkey = sorted(list(key))\nfor k in key:\n if d[str(k)] < K:\n K -= d[str(k)]\n else:\n print(k)\n break", "#!/usr/bin/env python\n\nn, k = list(map(int, input().split()))\na = [0 for _ in range(n)]\nb = [0 for _ in range(n)]\nfor i in range(n):\n a[i], b[i] = list(map(int, input().split()))\n\nd = {}\nfor i in range(n):\n if a[i] not in d:\n d[a[i]] = b[i]\n else:\n d[a[i]] += b[i]\n\nd = sorted(list(d.items()), key=lambda x: x[0])\n\ntmp = 0 \nfor i in range(len(d)):\n tmp += d[i][1]\n if tmp >= k:\n print((d[i][0]))\n return\n", "n, k = map(int,input().split())\n\nq = []\nfor i in range(n):\n q.append(list(map(int, input().split())))\n\nq = sorted(q, key=lambda x:x[0])\ncnt = 0\ni = 0\nwhile cnt < k:\n a, b = q[i]\n cnt += b\n i += 1\nprint(a)", "n, k = map(int, input().split(\" \"))\na = sorted([list(map(int, input().split(\" \"))) for i in range(n)])\ncount = 0\nfor x, y in a:\n count += y\n if k <= count:\n print(x)\n break\nelse:\n print(\"None\")", "l=[*map(int,open(c:=0).read().split())]\nfor a,b in sorted(zip(l[2::2],l[3::2])):\n\tif(c:=c+b)>=l[1]:break\nprint(a)", "f=lambda:map(int,input().split());N,K=f()\nfor a,b in sorted([*f()]for _ in[0]*N):\n K-=b\n if K<1:print(a);return", "N,K = map(int,input().split())\nans = []\nfor i in range(N):\n ab = list(map(int,input().split()))\n ans.append(ab)\nans.sort()\nl = 0\nfor i in range(N):\n l += ans[i][1]\n if l >= K:\n s = i\n break\nprint(ans[s][0])", "N, K = list(map(int, input().split()))\nmemory = {}\nS = []\n\nfor i in range(N):\n a, b = list(map(int, input().split()))\n try:\n memory[a] += b\n except KeyError:\n memory[a] = b\n\nA = sorted(list(memory.keys()))\nfor a in A:\n if not S:\n S.append(memory[a])\n else:\n S.append(S[-1] + memory[a])\n\nfor i in range(N):\n if S[i] >= K:\n print((A[i]))\n break\n", "N,K=list(map(int,input().split()))\nab=list(list(map(int,input().split())) for _ in range(N))\nab.sort()\n\ni=0\nwhile K>0:\n K-=ab[i][1]\n i+=1\nprint((ab[i-1][0]))\n", "n,k = map(int,input().split())\nlst = [0]*10**5\nfor i in range(n):\n a,b=map(int,input().split())\n lst[a-1] += b\n ans = 0\nfor j in range(10**5):\n ans += lst[j]\n if ans >= k:\n print(j+1)\n return", "N, K = list(map(int, input().split()))\n\ncnt = 0\n\nls = []\n\nfor i in range(N):\n ls.append(list(map(int, input().split())))\n\nls.sort(key=lambda x: x[0])\n\nfor a, b in ls:\n cnt += b\n if cnt >= K:\n break\n\nprint(a)\n", "N,K,*l=map(int,open(c:=0).read().split())\nd={}\nfor a,b in zip(l[::2],l[1::2]):d[a]=d.get(a,0)+b\nfor k in sorted(d.keys()):\n\tif (c:=c+d[k])>=K:break\nprint(k)", "n, k = map(int, input().split())\nS = set()\nD = dict()\nfor _ in range(n):\n a, b = map(int, input().split())\n if a in S:\n D[a] += b\n else:\n S.add(a)\n D[a] = b\nL = sorted(S)\ncnt = 0\nfor l in L:\n cnt += D[l]\n if cnt >= k:\n print(l)\n break", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 28 01:21:16 2020\n\n@author: liang\n\"\"\"\n\n#\u30d0\u30b1\u30c4\u30bd\u30fc\u30c8O(n)\nN, K = map(int,input().split())\nnum = [0]*(10**5+1)\nfor i in range(N):\n a, b = map(int,input().split())\n num[a] += b\n\ntmp = 0\nfor i in range(10**5+ 1):\n tmp += num[i]\n if tmp >= K:\n print(i)\n break", "def main2():\n N, K = map(int, input().split())\n limit = 10**5\n\n ins = [0 for _ in range(limit + 1)]\n\n for _ in range(N):\n a, b = map(int, input().split())\n ins[a] += b\n\n c = 0\n for i in range(1, limit + 1):\n c += ins[i]\n\n if c >= K:\n print(i)\n return\n\ndef __starting_point():\n main2()\n__starting_point()", "N,K = map(int,input().split())\nans = []\n\nfor i in range(N):\n ab = list(map(int,input().split()))\n ans.append(ab)\n\nans.sort()\n\nl = 0\n \nfor i in range(N):\n l += ans[i][1]\n if l >= K:\n s = i\n break\nprint(ans[s][0])", "n, k = list(map(int, input().split()))\nl = sorted([list(map(int, input().split()))for i in range(n)])\nfor a, b in l:\n k -= b\n if k <1:\n print(a)\n break\n", "n,k = [int(x) for x in input().split()]\na = []\nfor i in range(n):\n a.append([int(x) for x in input().split()])\na.sort()\n\nc = 0\nwhile k > 0:\n k -= a[c][1]\n c += 1\n\nprint(a[c-1][0])", "N, K = map(int, input().split())\n\nlst = [list(map(int, input().split())) for _ in range(N)]\nlst.sort(key=lambda x: x[0])\ns = 0\nfor i in range(N):\n\ts += lst[i][1]\n\tif s >= K: break\nprint(lst[i][0])", "n,k=map(int,input().split())\nab=[list(map(int,input().split())) for i in range(n)]\nab.sort()\n\ndef slv():\n cnt = 0\n for i in range(n):\n cnt += ab[i][1]\n if cnt >= k:\n return print(ab[i][0])\n\nslv()", "N,K,*L=[int(a)for a in open(0).read().split()]\nL,c=sorted(zip(L[::2],L[1::2])),1\nfor a,b in L:\n c+=b\n if c>K:print(a);return", "n, k = list(map(int, input().split()))\nli = []\nfor i in range(n):\n temp = list(map(int, input().split()))\n li.append(temp)\n#print(li)\nli.sort()\n#print(li)\ntotal=0\nfor i in range(n):\n if i==n-1:\n #print(\"here\")\n print((li[i][0]))\n break\n total+=li[i][1]\n if total<k:\n continue\n else:\n print((li[i][0]))\n break\n #print(i, total)\n", "def main():\n N, K = list(map(int, input().split()))\n l = []\n cnt = 0\n for _ in range(N):\n a, b = list(map(int, input().split()))\n l.append((a, b))\n l.sort(key=lambda x: x[0])\n for a, x in l:\n cnt += x\n if cnt >= K:\n print(a)\n return\n\ndef __starting_point():\n main()\n\n__starting_point()", "from collections import defaultdict as dd\nfrom itertools import count\nN, K = map(int, input().split())\nCnt = dd(lambda:0)\nfor _ in range(N):\n a, b = map(int, input().split())\n Cnt[a] += b\n\nnum = 0\nfor i in count(1,1):\n num += Cnt[i]\n if num >= K:\n print(i)\n break", "N, K = map(int,input().split())\nls = [0]+[0]*10**5\nfor i in range(N):\n a,b = map(int,input().split())\n ls[a] += b\nii = 0\nfor i in range(1,10**5+1):\n ii += ls[i]\n if ii >= K:\n ans = i\n break\n else:\n continue\nprint(ans)", "n,k=map(int,input().split())\nnum,count=[0]*((10**5)+1),0\nfor _ in range(n):\n a,b=map(int,input().split())\n num[a]+=b\nfor i in range(len(num)):\n count+=num[i]\n if count >= k:\n print(i)\n break", "import sys\ninput = sys.stdin.readline\n\ndef main():\n n,k = map( int , input().split() )\n A = [ 0 for i in range( 10 ** 5 + 1 ) ]\n for i in range(n):\n a,b = map( int , input().split() )\n A[ a ] += b\n \n i = 0\n sum = 0\n while( sum < k ):\n i += 1\n sum += A[i]\n print(i)\n\n\n\nmain()", "N,K=list(map(int,input().split()))\ncount=[0]*(100001)\nfor i in range(1,N+1) :\n a,b=list(map(int,input().split()))\n count[a]+=b\nfor i in range(1,100001) :\n if K<=count[i] :\n print(i)\n break\n K-=count[i]\n", "# C - Big Array\ndef main():\n n, k = map(int, input().split())\n ab = [list(map(int, input().split())) for _ in range(n)]\n ab.sort()\n\n i = 0\n\n while k > 0:\n k -= ab[i][1]\n i += 1\n else:\n print(ab[i-1][0])\n\nif __name__ == \"__main__\":\n main()", "from collections import defaultdict\nN,K = list(map(int,input().split()))\nN_List = defaultdict(int)\nfor i in range(N):\n Num,Cnt = list(map(int,input().split()))\n N_List[Num] += Cnt\n\nN_List = sorted(list(N_List.items()), key=lambda x:x[0])\n\nans = 0\nfor Key,Value in N_List:\n ans += Value\n if ans >= K:\n print(Key)\n break\n\n", "n,k=map(int,input().split())\ns=[0]*10**5\nfor i in range(n):\n a,b=map(int,input().split())\n s[a-1]+=b\ni=0\nwhile k>0:\n k-=s[i]\n i+=1\nprint(i)", "#95 C - Big Array\nN,K = map(int,input().split())\nlis = []\nfor _ in range(N):\n a,b = map(int,input().split())\n lis.append((a,b))\n\nlis = sorted(lis,reverse = False)\n\ncnt = 0\nnum = 0\nfor a,b in lis:\n cnt += b\n num = a\n if cnt >= K:\n break\nprint(num)", "N, K = list(map(int, input().split()))\n\nab = [[0, 0]] * N\nfor i in range(N):\n _a, _b = list(map(int, input().split()))\n ab[i] = [_a, _b]\nab.sort(key=lambda x:x[0])\n\nj = 0\nindex = 0\nwhile j < K:\n j += ab[index][1]\n if j < K:\n index += 1\n\nprint((ab[index][0]))\n", "#\n# abc061 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"3 4\n1 1\n2 2\n3 3\"\"\"\n output = \"\"\"3\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N, K = list(map(int, input().split()))\n D = [list(map(int, input().split())) for _ in range(N)]\n\n D.sort()\n t = 0\n for d in D:\n t += d[1]\n if t >= K:\n print((d[0]))\n break\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "N,K,*L=[int(a)for a in open(0).read().split()]\nfor a,b in sorted(zip(L[::2],L[1::2])):\n K-=b\n if K<1:print(a);return", "import heapq\n\nn, k = map(int,input().split())\n\nq = []\nfor i in range(n):\n q.append(list(map(int, input().split())))\n\nheapq.heapify(q)\n\ncnt = 0\nwhile cnt < k:\n a, b = heapq.heappop(q)\n cnt += b\n \nprint(a)", "#n = int(input())\nn, k = list(map(int, input().split()))\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\ndic = {}\nfor i in range(n):\n a, b = list(map(int, input().split()))\n dic[a] = dic.get(a, 0)+b\n\nl = sorted(dic.items())\n\nfor a, b in l:\n if k <= b:\n ans = a\n break\n k -= b\nprint(ans)\n", "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\n#import bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165g\nimport sys\nsys.setrecursionlimit(10000000)\n#mod = 10**9 + 7\n#mod = 9982443453\nmod = 998244353\ndef readInts():\n return list(map(int,input().split()))\ndef I():\n return int(input())\n#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\n#import bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165g\nimport sys\nsys.setrecursionlimit(10000000)\n#mod = 10**9 + 7\n#mod = 9982443453\nmod = 998244353\ndef readInts():\n return list(map(int,input().split()))\ndef I():\n return int(input())\nn,k = readInts()\ndic = defaultdict(int)\nd = set()\nfor i in range(n):\n a,b = readInts()\n d.add(a)\n dic[a] += b\nd = sorted(list(d))\nans = 0\nfor v in d:\n if ans + dic[v] >= k:\n print(v)\n return\n ans += dic[v]\n", "n, k = map(int, input().split())\nd = {}\nfor _ in range(n):\n a, b = map(int, input().split())\n if a in d.keys():\n d[a] += b\n else:\n d[a] = b\ncnt = 0\nsorted_d = sorted(d.items(), key=lambda x: x[0])\nfor key, val in sorted_d:\n cnt += val\n if k <= cnt:\n print(key)\n break", "n,k=map(int,input().split())\na=[]\nfor i in range(n):\n A=list(map(int,input().split()))\n a.append(A)\na = sorted(a, key=lambda x: x[0])\nb=0\nfor i in range(n):\n b+=a[i][1]\n if b>=k:\n print(a[i][0])\n return", "N,K = map(int,input().split())\nnums = []\n\nfor _ in range(N):\n a,b = map(int,input().split())\n nums.append([a,b])\n\nnums.sort()\nS = 0\n\nfor i in range(N+1):\n if S < K:\n S += nums[i][1]\n else:\n print(nums[i-1][0])\n break", "import math\nfrom math import gcd,pi,sqrt\nINF = float(\"inf\")\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return list(map(int, input().split()))\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\n\nimport string\n\ndef main():\n n,k = i_map()\n\n cnt = 0\n l = []\n for _ in range(n):\n a,b = i_map()\n l.append([a,b])\n\n l.sort()\n for i,j in l:\n cnt += j\n if cnt >= k:\n print(i)\n break\n\ndef __starting_point():\n main()\n\n__starting_point()", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 28 01:14:47 2020\n\n@author: liang\n\"\"\"\n\nN, K = list(map(int,input().split()))\nA = list()\nfor i in range(N):\n a, b = list(map(int,input().split()))\n A.append((a,b))\nA.sort(key= lambda x:x[0])\n\ntmp = 0\nfor i in range(N):\n a, b = A[i]\n tmp += b\n if tmp >= K:\n print(a)\n break\n", "li = [0]*(10**5+10)\nn,k = map(int, input().split())\nfor i in range(n):\n a,b = map(int, input().split())\n li[a] += b\ncnt = 0\nans = 0\nfor i in range(10**5+10):\n cnt += li[i]\n ans = i\n if cnt >= k:\n break\nprint(ans)", "n, k = map(int, input().split())\nquery = sorted([tuple(map(int, input().split())) for _ in range(n)])\n\ncnt = 0\ni = 0\nwhile cnt < k:\n a, b = query[i]\n cnt += b\n i += 1\nprint(a)", "# s = input()\n# n = len(s) - 1\n# ans = 0\n# for i in range(1 << n):\n# formula = s[0]\n# for j in range(n):\n# if ((i >> j) & 1):\n# formula += '+' + s[j + 1]\n# else:\n# formula += s[j + 1]\n# ans += eval(formula)\n# print(ans)\nimport sys\n\n\nstdin = sys.stdin\ndef ns(): return stdin.readline().rstrip()\ndef ni(): return int(stdin.readline().rstrip())\ndef nm(): return list(map(int, stdin.readline().split()))\ndef nl(): return list(map(int, stdin.readline().split()))\n\n\ndef main():\n n, k = nm()\n A = [0] * (10 ** 5 + 1)\n for i in range(n):\n a, b = nm()\n A[a] += b\n\n sum_num = 0\n for i, a in enumerate(A):\n sum_num += a\n if sum_num >= k:\n print(i)\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N,K=map(int,input().split());c=[0]*(l:=10**5+1);s=0\nfor i in range(N):a,b=map(int,input().split());c[a]+=b\nfor i in range(l):\n s+=c[i]\n if s>=K: print(i);break", "#!/usr/bin/env python3\n\ndef main():\n n, k = list(map(int, input().split()))\n arr = sorted([list(map(int, input().split())) for i in range(n)])\n for ab in arr:\n k -= ab[1]\n if k <= 0:\n ans = ab[0]\n break\n\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N,K,*l=list(map(int,open(0).read().split()))\nfor a,b in sorted(zip(l[::2],l[1::2])):\n\tif(K:=K-b)<1:break\nprint(a)\n", "N,K=map(int,input().split())\nl=[list(map(int,input().split()))for i in range(N)]\nl.sort(key=lambda x: x[0])\nans=0\nfor i in l:\n if K==0:\n break\n K-=min(K,i[1])\n ans=i[0]\nprint(ans)", "n,k = list(map(int,input().split()))\nA = []\nfor _ in range(n):\n A.append(list(map(int,input().split())))\nA.sort(key=lambda x: x[0])\ncnt = 0\nwhile k>0:\n k-=A[cnt][1]\n cnt+=1\nprint((A[cnt-1][0]))\n", "import sys\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\n\ndef solve():\n n, k = inl()\n v = []\n for i in range(n):\n a, b = inl()\n v.append((a, b))\n v.sort(reverse=True)\n c = k - 1\n while v:\n a, b = v.pop()\n if b > c:\n return a\n c -= b\n\n\nprint(solve())\n", "N,K=map(int,input().split())\ncnt=0\nP=[]\nfor i in range(N):\n a,b=map(int,input().split())\n P.append((a,b))\n\nP=sorted(P)\nfor i in range(N):\n cnt+=P[i][1]\n if cnt>=K:\n print(P[i][0])\n break", "N, K = list(map(int, input().split()))\n\nab = [[0, 0]] * N\nfor i in range(N):\n _a, _b = list(map(int, input().split()))\n ab[i] = [_a, _b]\nab.sort(key=lambda x:x[0])\n\n\ntotal = 0\nfor pair in ab:\n total += pair[1]\n if total >= K:\n print((pair[0]))\n break\n", "N, K = map(int, input().split())\nd = {}\nfor i in range(N):\n a, b = map(int, input().split())\n d[a] = d.get(a, 0) + b\n\ncnt = 0\nfor k in sorted(d.keys()):\n cnt += d[k]\n if cnt >= K:\n print(k)\n break", "n, k = map(int,input().split())\na_b = [ list(map(int, input().split())) for _ in range(n) ]\na_b = sorted(a_b, key=lambda x: x[0] )\n\ncount = 0\nfor i in range(len(a_b)):\n a, b = a_b[i]\n count += b\n if count >= k:\n print(a)\n break", "n, k = map(int, (input().split()))\narr = [0] * 100100\nfor i in range(n):\n a, b = map(int, input().split())\n arr[a] += b\n\ncur = 0\nfor i in range(100100):\n cur += arr[i]\n if cur >= k:\n print(i)\n break", "N, K = map(int, input().split())\n\nbucket = [0] * (10 ** 5 + 1)\nfor _ in range(N):\n a, b = map(int, input().split())\n bucket[a] += b\n\ncnt = 0\nfor i, c in enumerate(bucket):\n if c == 0:\n continue\n cnt += c\n if cnt >= K:\n print(i)\n return", "N,K=map(int,input().split())\nd={}\nfor i in range(N):\n a,b=map(int,input().split())\n if a not in d:\n d[a]=b\n else:\n d[a]+=b\nd=sorted(d.items())\nfor i in d:\n K-=i[1]\n if K<=0:\n print(i[0])\n break", "n,k = map(int, input().split())\nab = sorted([list(map(int, input().split())) for _ in range(n)])\ncnt = 0\nfor a,b in ab:\n cnt += b\n if cnt >= k: break\nprint(a)", "n, k = list(map(int, input().split()))\nar = {}\nfor i in range(n):\n a, b = list(map(int, input().split()))\n if (a in ar) == True:\n ar[a] += b\n else:\n ar[a] = b\n\nfor i in sorted(ar.keys()):\n k -= ar[i]\n if k <= 0:\n print(i)\n break\n", "N,K=map(int,input().split())\nA={}\nfor i in range(N):\n a,b=map(int,input().split())\n A[a]=A.get(a,0)+b\nA=sorted(A.items())\n\ncnt=0\nfor n,k in A:\n cnt+=k\n if cnt>=K:\n print(n)\n return", "N,K=list(map(int,input().split()))\nA=[list(map(int,input().split())) for _ in range(N)]\nA=sorted(A, key=lambda x: x[0])\n\ncnt=0\nfor i in range(N):\n a,b=A[i]\n A[i][1]+=cnt\n cnt=A[i][1]\n\nfor i in range(N):\n a,b=A[i]\n if K<=b:break\nprint(a)\n", "import bisect\n\nn,k=list(map(int,input().split()))\nhairetu=[0]*100001\n\nfor _ in range(n):\n a,b=list(map(int,input().split()))\n hairetu[a]+=b\n\nruiseki=[0]*100001\nfor i in range(1,100001):\n ruiseki[i]=ruiseki[i-1]+hairetu[i]\n\nprint((bisect.bisect_left(ruiseki,k)))\n", "N,K,*l=map(int,open(c:=0).read().split())\nfor a,b in sorted(zip(l[::2],l[1::2])):\n\tif(c:=c+b)>=K:break\nprint(a)", "xx = []\nn, k = map(int, input().split())\nab = [list(map(int, input().split())) for i in range(n)]\nxx = sorted(ab, key= lambda x:x[0])\n\nans = 0\nfor i in range(n):\n ans += xx[i][1]\n if ans >= k:\n print(xx[i][0])\n break", "from collections import Counter\n\nn, k = map(int, input().split())\n\nd = Counter()\nfor _ in range(n):\n a, b = map(int, input().split())\n d[a] += b\n\nx = sorted(d.items(), key=lambda x: x[0])\ncnt = 0\nfor a, b in x:\n cnt += b\n if cnt >= k:\n print(a)\n return", "AMAX = 10**5\ncount = [0] * (AMAX + 1)\n\nN, K = map(int, input().split())\n\nfor _ in range(N):\n a, b = map(int, input().split())\n count[a] += b\n\nfor ans in range(AMAX + 1):\n if K <= count[ans]:\n print(ans)\n break\n K -= count[ans]"] | {"inputs": ["3 4\n1 1\n2 2\n3 3\n", "10 500000\n1 100000\n1 100000\n1 100000\n1 100000\n1 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n100000 100000\n"], "outputs": ["3\n", "1\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 30,400 | |
aa4236458216d621223c54d834c89d3f | UNKNOWN | There are N balls placed in a row.
AtCoDeer the deer is painting each of these in one of the K colors of his paint cans.
For aesthetic reasons, any two adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls.
-----Constraints-----
- 1β¦Nβ¦1000
- 2β¦Kβ¦1000
- The correct answer is at most 2^{31}-1.
-----Input-----
The input is given from Standard Input in the following format:
N K
-----Output-----
Print the number of the possible ways to paint the balls.
-----Sample Input-----
2 2
-----Sample Output-----
2
We will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0. | ["n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "n, k = list(map(int, input().split()))\nprint((k*pow(k-1, n-1)))\n", "N,K = map(int,input().split())\nP = K\nfor i in range(N-1):\n P *= K-1\nprint(P)", "N, K=map(int, input().split(\" \"))\n\nprint(K*(K-1)**(N-1))", "N, K = map(int, input().split())\n\nans = K * (K - 1)**(N - 1)\nprint(ans)", "N, K = map(int, input().split())\n\nres = 1\n\nfor i in range(N):\n if i == 0:\n res *= K\n else:\n res *= (K-1)\n\nprint(res)", "N,K=list(map(int,input().split()))\nans = K\nfor i in range(N-1):\n ans *= (K-1)\nprint(ans)\n", "N, K = map(int,input().split())\nnum = K;\n\nif N != 1 :\n for i in range(1,N):\n num *= K-1\n\nprint(num)", "N, K = map(int, input().split())\nprint(K * pow(K-1,N-1))", "n, k = map(int, input().split())\n\nprint(k * ((k - 1) ** (n - 1)))", "N, K = map(int, input().split())\nprint(K * ((K - 1) ** (N - 1)))", "N,K=map(int,input().split())\nprint(K*((K-1)**(N-1)))", "n,k=list(map(int,input().split()))\n\nprint((k * (k-1)**(n-1)))\n", "n, k = map(int, input().split())\nans = k * pow(k-1, n-1)\nprint(ans)", "n, k = map(int, input().split())\nans = k\nfor _ in range(n-1):\n ans *= k-1\nprint(ans)", "N,K = map(int, input().split())\npattern = K*(K-1)**(N-1)\nprint(pattern)", "n, k = map(int, input().split())\nans = k\nfor i in range(n-1):\n ans = ans * (k -1)\n\nprint(ans)", "n,k = map(int,input().split())\nprint(k*((k-1)**(n-1)))", "n,k = map(int, input().split())\nprint(k*(k-1)**(n-1))", "N,K = map(int,input().split())\n\nans = K*(K-1)**(N-1)\nprint(ans)", "lst = input().split()\n\nN = int(lst[0])\nK = int(lst[1])\n\nprint(K * ((K-1) ** (N-1)))", "n,k=map(int,input().split())\nprint(k*((k-1)**(n-1)))", "n, k = map(int, input().split())\nprint(k*((k-1)**(n-1)))", "N,K = map(int,input().split())\n\ndef calculate(n, k):\n print(k * pow(k-1,n-1))\n\ncalculate(N, K)", "n,k = map(int,input().split())\nprint(k*((k-1)**(n-1)))", "n, k = list(map(int, input().split()))\nprint((k * (k-1) ** (n-1)))\n", "n,k=map(int,input().split())\nif n==1:\n print(k)\nelse:\n print(k*(k-1)**(n-1))", "n, k = list(map(int, input().split()))\n\nans = 0\nans += k * (k - 1) ** (n - 1)\nprint(ans)\n", "a,b=input().split()\na=int(a)\nb=int(b)\nprint(b*(b-1)**(a-1))", "a = list(map(int ,input().split()))\nsum = 0\nfor i in range(a[0]):\n if i == 0:\n sum = a[1]\n else:\n sum *= a[1]-1\n\nprint(sum)", "N, K = map(int, input().split())\nx = K*(K-1)**(N-1)\nprint(x)", "N, K = map(int, input().split())\ntotal = K\nfor i in range(N-1):\n total *= (K-1)\nprint(total)", "n,k = map(int,input().split())\nans = k\nfor i in range(n-1):\n ans *= k-1\nprint(ans)", "n,k = map(int,input().split())\n\nprint(k*(k-1)**(n-1))", "N, K = map(int,input().split())\nprint(K * (K - 1)**(N - 1))", "n,k=map(int, input().split())\nprint(k*(k-1)**(n-1))", "N, K = [int(x) for x in input().split()]\nans = (K-1)**(N-1)*K\nprint(ans)", "nk = input().split()\n\nn = int(nk[0])\nk = int(nk[1])\n\np = k * (k-1)**(n-1)\n\nprint(p)\n", "n, k = map(int, input().split())\n\nprint(k * (k - 1) ** (n - 1))", "N, K = map(int, input().split())\n\ncnt = K\nfor i in range(N - 1):\n cnt *= (K - 1)\nprint(cnt)", "N, K = list(map(int, input().split()))\n\nprint((K * pow(K-1, N-1)))\n", "N, K = map(int,input().split())\n\nans = K * ((K-1)**(N-1))\nprint(ans)", "n, k = map(int, input().split())\nans = k\nfor i in range(n-1):\n ans *= k-1\nprint(ans)", "n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "n,k=list(map(int,input().split()))\nprint((k*((k-1)**(n-1))))\n", "n, k = list(map(int, input().split()))\n\nans = k * (k-1)**(n-1)\nprint(ans)\n", "n, k = map(int, input().split())\nprint(k * pow(k - 1, n - 1))", "a,b=map(int,input().split());print(b*(b-1)**(a-1))", "\ndef resolve():\n n, k = list(map(int, input().split()))\n\n print((k * (k-1) ** (n-1)))\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "N,K = map(int,input().split())\n\nprint(K * (K - 1) ** (N - 1))", "n,k = list(map(int,input().split()))\nprint((k*((k-1)**(n-1))))\n", "n,k = map(int,input().split())\nprint(k* ((k-1)**(n-1)))", "n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "n, k = map(int, input().split())\n\nans = k * pow(k - 1, n-1)\n\nprint(ans)", "a,b=map(int,input().split())\nprint(b*(b-1)**(a-1))", "N, K = map(int, input().split())\nans = K * ((K-1) ** (N-1))\nprint(ans)", "N,K = list(map(int,input().split()))\nprint((K * (K-1)**(N-1)))\n", "n,k = map(int,input().split())\nprint(k*(k-1)**(n-1))", "N, K = list(map(int,input().split()))\nans = 1\n\nans = K * (K - 1) ** (N - 1)\n\nprint(ans)\n \n", "N,K = map(int, input().split())\n\npr = K\nfor _ in range(1,N):\n pr *= K-1\nprint(pr)", "n,k=list(map(int,input().split()))\nif(n!=1 and n!=1 ):\n print((k*(k-1)**(n-1)))\nif(n == 1):\n print(k)\n", "n,k=map(int,input().split())\na=k*(k-1)**(n-1)\nprint(a)", "n,k = list(map(int,input().split()))\nprint((k*((k-1)**(n-1))))\n", "n,k = map(int,input().split())\nif n == 1:\n print(k)\n return\nsu = k\nfor i in range(n-1):\n su *= (k-1)\nprint(su)", "N, K = list(map(int, input().split()))\nprint((K * pow(K - 1, N - 1)))\n", "MOD = 10**11\n\ndef fast_pow(x, n, MOD):\n res = 1\n while n:\n if n & 1:\n res = res * x % MOD\n x = x * x % MOD\n n >>= 1\n return res\n\n\nn, k = map(int,input().split())\nif n == 1:\n print(k)\nelse:\n print(k * fast_pow(k-1, n-1, MOD))", "n,k=list(map(int,input().split()))\nprint((k*(k-1)**(n-1)))\n", "a,b = map(int,input().split())\n\nprint((b-1)**(a-1)*b)", "N,K=map(int,input().split())\nprint(K*(K-1)**(N-1))", "N, K = map(int, input().split())\n\nprint(K*((K-1)**(N-1)))", "n,k = map(int,input().split())\nprint(k*((k-1)**(n-1)))", "\n# ABC046\nN, K = map(int, input().split())\nprint(K*(K-1)**(N-1))", "a,b = map(int,input().split())\nprint(b*(b-1)**(a-1))", "n, k = tuple([int(x) for x in input().split(\" \")])\n\nprint((k * pow(k - 1, n - 1)))\n", "N, K = list(map(int, input().split()))\nans = K\nfor i in range(N - 1):\n ans *= K - 1\n \nprint(ans) \n\n\n", "n, k = map(int, input().split())\nprint(k*(k-1)**(n-1))", "str_line = input().split(\" \")\nnum = int(str_line[0])\nkind = int(str_line[1])\nans = kind \n\nfor i in range(num-1):\n ans *=(kind - 1)\n \nprint(ans)", "n,k = map(int,input().split())\nprint(k*(k-1)**(n-1))", "import sys\ninput = sys.stdin.readline\n\ndef main():\n N, K = [int(x) for x in input().split()]\n\n print((K * (K - 1) ** (N - 1)))\n\n \n\ndef __starting_point():\n main()\n\n\n\n__starting_point()", "n,k=map(int,input().split())\nm=1\nif n==1:\n print(k)\nelse:\n m *= k\n for i in range(n-1):\n m *= (k-1)\n print(m)", "# -*- coding: utf-8 -*-\n\nN,K = map(int, input().split())\n\nans = K * ((K-1) ** (N-1)) \n\nprint(ans)", "n,k = [int(x) for x in input().split()]\nres = k\nfor i in range(1,n):\n res *= k - 1\nprint(res)", "def si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lint(): return list(map(int, input().split()))\ndef lint_dec(): return list([int(x) - 1 for x in input().split()])\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef graph_input(G, m):\n for _ in range(m):\n a, b = lint_dec()\n G[a].append(b)\n G[b].append(a)\n\n\n\n############################################################\nN, K = lint()\nprint((K * pow(K - 1, N - 1)))\n", "def answer(n: int, k: int) -> int:\n return k * (k - 1) ** (n - 1)\n\n\ndef main():\n n, k = map(int, input().split())\n print(answer(n, k))\n\n\ndef __starting_point():\n main()\n__starting_point()", "N, K = map(int, input().split(' '))\n\nanswer = (K-1)**(N-1) * K\nprint(answer)", "n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "n,k = map(int, input().split())\nans=k*((k-1)**(n-1))\nprint(ans)", "N, K = list(map(int, input().split()))\n\nprint((K * (K - 1) ** (N - 1)))\n", "n,k = list(map(int, input().split()))\np=k\nfor i in range(n-1):\n p *= k-1\nprint(p)\n", "N, K = [int(x) for x in input().split()]\nprint(K*(K-1)**(N-1))", "N, K = map(int, input().split())\nprint(K * ((K - 1) **(N - 1)))", "n, k = list(map(int, input().split()))\nprint((k * pow((k-1), (n-1))))\n", "N,K = list(map(int,input().split()))\n\nprint((K*(K-1)**(N-1)))\n", "n,k=map(int,input().split())\nans = k*(k-1)**(n-1)\nprint(ans)", "N,K=map(int,input().split())\n\ns=K*(K-1)**(N-1)\n\nprint(int(s))", "N, K = map(int, input().split())\nprint(K*(K-1)**(N-1))", "N, K =map(int, input().split())\nprint(K*((K-1)**(N-1)))", "n, k = map(int, input().split())\nprint(k*(k-1)**(n-1))", "import re\nimport copy\n\ndef accept_input():\n N,K = list(map(int,input().split()))\n return N,K\n\nN,K = accept_input()\n\n\nif K == 1:\n print(N)\nelse:\n print((K*((K-1)**(N-1))))\n"] | {"inputs": ["2 2\n", "1 10\n"], "outputs": ["2\n", "10\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 8,955 | |
4ebb83496fce134e7a8f464d5df63cf0 | UNKNOWN | There is a circular pond with a perimeter of K meters, and N houses around them.
The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.
When traveling between these houses, you can only go around the pond.
Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
-----Constraints-----
- 2 \leq K \leq 10^6
- 2 \leq N \leq 2 \times 10^5
- 0 \leq A_1 < ... < A_N < K
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
K N
A_1 A_2 ... A_N
-----Output-----
Print the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.
-----Sample Input-----
20 3
5 10 15
-----Sample Output-----
10
If you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10. | ["k, n = map(int, input().split())\npoints = list(map(int, input().split()))\n\ndist = []\nfor i in range(n):\n if i != n-1:\n distance = points[i+1] - points[i]\n else:\n distance = points[0]+k - points[i]\n dist.append(distance)\n\nmax = dist[0]\nfor j in range(1, len(dist), 1):\n if max < dist[j]:\n max = dist[j]\ndist.remove(max)\n\nans = 0\nfor k in dist:\n ans += k\nprint(ans)", "k, n = map(int, input().split())\na = list(map(int, input().split()))\n\nd = []\nfor i in range(n - 1):\n d.append(a[i + 1] - a[i])\nd.append(k - a[n - 1] + a[0])\nd.sort()\nprint(sum(d[:-1]))", "import numpy as np\nK, N = map(int, input().split())\nA = np.array(list(map(int, input().split())))\ndiff = np.append(A[1:] - A[:-1], K + A[0] - A[-1])\nprint(np.delete(diff, np.argmax(diff)).sum())", "K, N = map(int, input().split())\nA_l = sorted(map(int, input().split()))\nd_l = [K+A_l[0]-A_l[N-1]]\nfor i in range(1, N):\n d_l.append(A_l[i]-A_l[i-1])\nprint(K-max(d_l))", "k,n = map(int,input().split())\na = list(map(int,input().split()))\ntemp = 0\nfor i in range(n-1):\n temp = max(temp,a[i+1]-a[i])\ntemp = max(temp,k-a[n-1]+a[0])\nprint(k-temp)", "# import math\n# import statistics\n# import itertools\n# a=int(input())\n# b,c=int(input()),int(input())\n# c=[]\n# for i in a:\n# c.append(int(i))\nA,B= map(int,input().split())\nf = list(map(int,input().split()))\n# g = [input().split for _ in range(a)]\n# h = []\n# for i in range(a):\n# h.append(list(map(int,input().split())))\n# a = [[0] for _ in range(H)]#nizigen\nkyori=[]\nfor i in range(len(f)-1):\n an=f[i+1]-f[i]\n kyori.append(an)\n \nan2=A-f[-1]+f[0]\nans=max(max(kyori),an2)\nprint(A-ans)", "def i_input(): return int(input())\n\n\ndef i_map(): return map(int, input().split())\n\n\ndef i_list(): return list(map(int, input().split()))\n\n\ndef i_row(N): return [int(input()) for _ in range(N)]\n\n\ndef i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]\n\n\nk, n = i_map()\naa = i_list()\ndif=[]\nfor i in range(n):\n if i==n-1:\n dif.append(k-aa[-1]+aa[0])\n else:\n dif.append(aa[i+1]-aa[i])\nprint(k-max(dif))", "K,N=map(int,input().split())\nA=list(map(int,input().split()))\nB=[0]*N\nfor i in range(N-1):\n B[i]=A[i+1]-A[i]\nB[N-1]=K-A[N-1]+A[0]\nprint(K-max(B))", "k, n = list(map(int, input().split()))\na = list(map(int, input().split()))\nmx = a[0] + k - a[n - 1]\nfor i in range(n - 1):\n mx = max(mx, a[i + 1] - a[i])\nprint((k - mx))\n", "import numpy as np\n\nk, n = map(int, input().split())\na = list(map(int, input().split()))\n\ndist = [a[i+1]-a[i] if i < n-1 else k-a[i]+a[0] for i in range(n)]\nmax_index = np.argmax(dist)\n\ncost = 0\ncurr_index = max_index\nfor _ in range(n-1):\n if curr_index == 0:\n cost += a[curr_index] + k - a[curr_index-1]\n else:\n cost += a[curr_index] - a[curr_index-1]\n curr_index -= 1\nprint(cost)", "import numpy as np\nn,k = [ int(i) for i in input().split() ]\na = [ int(i) for i in input().split() ]\na = np.sort(a)\na = np.append(a, n+a[0] )\na1 = np.append( 0, a[:-1] )\nb = a-a1\nb = b[1:]\nprint(( np.sum(b) - np.max(b) ))\n\n\n", "K, N = list(map(int, input().split()))\nA_list = list(map(int, input().split()))\nA_list.append(K + A_list[0])\n\ndif_list = [0] * N\n\nfor i in range(N):\n dif_list[i] = A_list[i + 1] - A_list[i]\n\nprint(K - max(dif_list))", "k, n = map(int, input().split())\na = list(map(int,input().split()))\ntmp = 0\nansl = [] \nfor i in range(n-1):\n tmp = a[i+1] - a[i]\n ansl.append(tmp)\ntmp = k - a[-1] + a[0]\nansl.append(tmp)\nprint(k -max(ansl))", "k, n = map(int, input().split())\na = list(map(int, input().split()))\n\nm = 0\nfor i in range(n-1):\n if a[i+1]-a[i]>m:\n m = a[i+1]-a[i]\nif k-a[n-1]+a[0]>m:\n m = k-a[n-1]+a[0]\nprint(k-m)", "K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nmax_d = 0\n\nfor a in range(1, N):\n d = A[a] - A[a-1]\n if d > max_d:\n max_d = d\nlast_d = K - A[-1] + A[0]\nif last_d > max_d:\n max_d = last_d\nprint(K - max_d)", "k,n = map(int, input().split())\na = list(map(int, input().split()))\n\nans = 10000000\nfor i in range(n-1):\n ans = min(k-(a[i+1]-a[i]), ans)\nans = min(ans,a[n-1]-a[0])\nprint(ans)", "k,n = map(int,input().split())\nL = list(map(int,input().split()))\nL.append(k+L[0])\nm = 0\n\nfor i in range(n):\n m = max(m, L[i+1]-L[i])\n\nprint(k-m)", "K, N = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\na = 0\nif A[0] == 0:\n a = K - A[N - 1]\nelse:\n a = min(A[N - 1] - A[0], K - A[N - 1] + A[0])\n\n\nfor i in range(N - 1):\n b = A[i + 1] - A[i]\n a = max(a, b)\nans = K - a\nprint(ans)", "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 K , N = MI()\n L = LI()\n res = L[-1] - L[0]\n max_num = L[-1]\n for i in range(1, N):\n temp = L[i]\n past = L[i-1]\n past += K - temp\n res = min(res, past)\n \n print(res)\ndef __starting_point():\n main()\n__starting_point()", "K, N = map(int, input().split())\nAlst = list(map(int, input().split()))\nzero = Alst[0] + K\nM = 0\nnow = Alst[0]\nfor i in Alst:\n dis = i - now\n if dis > M:\n M = dis\n now = i\n\nlast = zero - now\nif last > M:\n M = last\n\nprint(K - M)", "k,n = list(map(int,input().split()))\na = list(map(int,input().split()))\n\nroute = []\nfor i in range(n-1):\n move = a[i+1] - a[i]\n route.append(move)\n\nroute.append(k-a[-1]+a[0])\n\nprint((sum(route) - max(route)))\n", "K, N = map(int, input().split())\nA = list(map(int, input().split()))\nd = [K+A[0]-A[-1]]+[b-a for a, b in zip(A, A[1:])]\nprint(K-max(d))", "k,n = list(map(int,input().split()))\na = list(map(int,input().split()))\n\nb = []\nfor i in range(n-1):\n b.append(a[i+1]-a[i])\n\nb.append(k-a[-1]+a[0])\n\nprint((sum(b)-max(b)))\n", "k, n = map(int, input().split())\na_list = list(map(int, input().split()))\nlongest = 0\n\nfor i in range(n-1):\n distance = a_list[i+1] - a_list[i]\n longest = max(longest, distance)\n\nprint(k-max(longest, k-a_list[n-1]+a_list[0]))", "k,n=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort()\nans=k-l[n-1]+l[0]\nfor i in range(n-1):\n if l[i+1]-l[i]>=ans:\n ans=l[i+1]-l[i]\nprint(k-ans)", "# coding=utf-8\n\ndef __starting_point():\n K, N = map(int, input().split())\n li = list(map(int, input().split()))\n li.append(K+li[0])\n\n l = 0\n for i in range(N):\n l = max(l, abs(li[i] - li[i+1]))\n\n print(K-l)\n__starting_point()", "k,n=map(int,input().split())\nA=list(map(int,input().split()))\na=A\nfor i in range(n):\n a.append(k+A[i])\nd=[0]*n\nfor i in range(n):\n d[i]=a[n-1+i]-a[i]\nprint(min(d))", "k, n =map(int,input().split())\na = list(map(int,input().split()))\nlongest = k - a[-1] + a [0]\nfor i in range(len(a)-1):\n longest = max(longest,a[i+1]-a[i])\nprint(k-longest)", "K,N = list(map(int,input().split()))\ndis = list(map(int,input().split()))\ndif = []\nfor i in range(N-1):\n dif.append(int(dis[i+1]-dis[i]))\n \ndif.append(int(K-dis[N-1]+dis[0]))\nprint((K-max(dif)))\n\n", "K, N = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = []\n\nfor j in range(N-1):\n B.append(A[j+1]-A[j])\n\nC = A[0]+K-A[N-1]\nB.append(C)\nB.sort()\nprint((K-B[N-1]))\n", "k, n = map(int, input().split())\na_list = list(map(int, input().split()))\n\nlongest = 0\nfor i in range(n):\n # if i==0:\n # continue\n if i==n-1:\n longest = max(longest, k-a_list[i]+a_list[0])\n else:\n distance = a_list[i+1] - a_list[i]\n longest = max(longest, distance)\n\nprint(k-longest)", "k, n = map(int, input().split())\n\na = list(map(int, input().split()))\n\na.append(a[0] + k)\n\nm = 0\n\nfor i in range(n):\n m = max(m, a[i + 1] - a[i])\n\nprint(k - m)", "K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nd = []\nfor i in range(N-1):\n d.append(A[i+1] - A[i])\nd.append(A[0] + K - A[N-1])\n\nmax_d = max(d)\n\nprint(K - max_d)", "def main():\n k, n = map(int, input().split())\n a = [int(v) for v in input().split()]\n distances = []\n for i in range(1, len(a)):\n distances.append((a[i]-a[i-1]))\n distances.append((k+a[0]) - a[-1])\n maximum = max(distances)\n return k - maximum\n\ndef __starting_point():\n print(main())\n__starting_point()", "k, n = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nb = []\nfor i in range(n - 1):\n b.append(a[i + 1] - a[i])\n\nb.append(k - a[-1] + a[0])\n\nprint((sum(b) - max(b)))\n", "#ABC160\nK,N=map(int,input().split())\nA =list(map(int,input().split()))\na=[K-(A[N-1]-A[0])]\nfor i in range(1,N):\n a.append(abs(A[i]-A[i-1]))\nprint(K-max(a))", "K, N = list(map(int, input().split()))\nAs = list(map(int, input().split()))\n\nAs += [As[0] + K]\n\nmaxDiff = 0\nfor i in range(N):\n d = As[i+1]-As[i]\n if d > maxDiff:\n maxDiff = d\n\nprint((K-maxDiff))\n", "k, n = map(int, input().split())\na = list(map(int, input().split()))\nroot = []\nans = 0\n\nfor i in range(0, n-1):\n x = a[i+1] - a[i]\n root.append(x)\n\ny = a[0] + k - a[n-1]\nroot.append(y)\n\nfor i in root:\n ans += i\n\nans -= max(root)\nprint(ans) ", "k, n = map(int,input().split())\na = list(map(int,input().split()))\n\nda =[-1] * n\nda[n-1] = k - a[n-1] + a[0]\nfor i in range(n-1):\n da[i] = a[i+1] - a[i]\n \nprint(sum(da)-max(da))", "K,N = map(int,input().split())\nA = [int(i) for i in input().split()]\nL = []\nans = 0\nfor i in range(N):\n if(i == N-1):\n L.append(K-A[N-1]+A[0])\n break\n L.append(A[i+1]-A[i])\nfor i in range(N):\n ans += L[i]\nans -= max(L)\nprint(ans)", "try:\n K, N = map(int,input().split())\n A = list(map(int, input().split()))\n\n li = []\n for i in range(N - 1):\n li.append(A[i + 1] - A[i]) \n\n li.append(abs(A[0] + (K - A[-1])))\n print(sum(li) - max(li))\nexcept:\n pass", "k, n = map(int, input().split())\nalst = list(map(int, input().split()))\nalst.append(alst[0] + k)\nminus = 0\nfor i in range(n):\n minus = max(minus, alst[i + 1] - alst[i])\nprint(k - minus)", "K, N = list(map(int, input().split()))\n\nA = list(map(int, input().split()))\n\nB = []\n\nfor i in range(len(A)-1):\n B.append(A[i+1]-A[i])\n\nB.append(A[0] - A[N-1] + K)\n\nb_max = max(B)\nb_max_index = B.index(max(B))\n\n\nB.remove(b_max)\nprint((sum(B)))\n", "import math\nimport decimal\ndef i_input(): return int(input())\n\n\ndef i_map(): return map(int, input().split())\n\n\ndef i_list(): return list(map(int, input().split()))\n\n\ndef i_row(N): return [int(input()) for _ in range(N)]\n\n\ndef i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]\n\nk,n= i_map()\naa=i_list()\ndis=[]\nfor i in range(n):\n if i == 0:\n dis.append(k-aa[-1]+aa[0])\n else:\n dis.append(aa[i]-aa[i-1])\nprint(k-max(dis))", "import sys\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\n\ndef solve():\n k, n = inl()\n A = inl()\n dmax = A[0] + (k - A[-1])\n for i in range(1, n):\n dmax = max(dmax, A[i] - A[i - 1])\n return k - dmax\n\n\nprint(solve())\n", "k, n = map(int ,input().split())\na = list(map(int,input().split()))\n\na.append(k+a[0])\n\nd = 0\nans = 0\nfor i in range(n):\n d = (a[i+1]-a[i])\n ans =max(ans,d)\n \nprint(k-ans)", "K,N=map(int,input().split())\nA=list(map(int,input().split()))\nans=K-(A[-1]-A[0])\nfor i in range(N-1):\n tmp=A[i+1]-A[i]\n ans=max(ans,tmp)\nans=K-ans\nprint(ans)", "#!/usr/local/bin/python3\n# https://atcoder.jp/contests/abc160/tasks/abc160_c\n\nK, N = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\ndist = []\nfor i in range(N-1):\n dist.append(A[i+1] - A[i])\ndist.append(K - A[-1] + A[0])\n\nprint((K - max(dist)))\n", "k,n = map(int,input().split())\na = list(map(int,input().split()))\n\na.sort()\na.append(a[0]+k)\n\nans = 0\nfor i in range(n):\n d = a[i+1] - a[i]\n ans = max(ans,d)\n\nprint(k - ans)", "K, N = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\ndif = []\n\nfor i,a in enumerate(A[:len(A)-1]):\n dif.append(A[i+1] - a)\n\ndif.append(K-A[len(A)-1] + A[0])\n\nprint((K - max(dif)))\n", "k,n=list(map(int,input().split()))\n\na=list(map(int,input().split()))\na.sort()\na.append(k+a[0])\n\nb=[0]*(n)\nfor i in range(n):\n b[i]=a[i+1]-a[i]\n\nprint((k-max(b)))\n", "k,n = list(map(int,input().split()))\na = list(map(int,input().split()))\n\nb = []\nfor i in range(n-1):\n b.append(a[i+1]-a[i])\n\nb.append(a[0]+(k-a[-1]))\n\nprint((sum(b)-max(b)))\n", "K,N = map(int,input().split())\nA1 = list(map(int,input().split()))\n\nD = [0] * (N)\n\nA2 = [A1[i]+K for i in range(len(A1)-1)]\nA1 = A1+A2\n\nfor i in range(N):\n D[i] = A1[i+N-1] - A1[i]\n #print(A1[i],A1[i+N-1])\nprint(min(D))", "k,n=map(int,input().split())\na=list(map(int,input().split()))\n\nc=[]\nfor i in range(1,n):\n c.append(a[i]-a[i-1])\nc.append(k-a[-1]+a[0])\n\nprint(k-max(c))", "k, n = map(int, input().split())\nan = list(map(int, input().split()))\n\n\nclass Solution:\n def __init__(self, k, n, an):\n self.k = k\n self.n = n\n self.an = an\n\n @staticmethod\n def __append_first():\n an.append(k + an[0])\n new_an = an\n return new_an\n\n def answer(self):\n new_an = self.__append_first()\n max_length = 0\n for i in range(n):\n max_length = max(max_length, new_an[i + 1] - new_an[i])\n print(k - max_length)\n\n\nconditions = Solution(k, n, an)\nconditions.answer()", "K,N = map(int,input().split())\nA = list(map(int,input().split()))\nsa = []\n\nfor i in range(N-1):\n sa.append(A[i+1]-A[i])\n \nsa.append((A[0]-A[N-1])%K)\n\nprint(K-max(sa))", "k, n = list(map(int, input().split()))\na = list(map(int, input().split()))\ndis = min(abs(a[0] - a[-1]), abs(k + a[0] - a[-1]))\nfor i in range(n-1):\n dis = max(dis, abs(a[i+1] - a[i]))\nans = k - dis\nprint(ans)\n", "K, N = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nA2 = [K+a for a in A]\nA3 = A + A2\n\ndist = [0] * N\nfor i in range(N):\n j = i + N - 1\n dist[i] = A3[j] - A[i]\n\nprint((min(dist)))\n\n", "def resolve():\n k,n = map(int,input().split())\n a = list(map(int,input().split()))\n l = a[0]+k-a[-1]\n for i in range(1,n):\n l = max(l,a[i]-a[i-1])\n print(k-l)\nresolve()", "# import numpy as np\n# import math\n\n# from scipy.special import perm : perm(n, r, exact=True)\n# from scipy.special import comb : comb(n, r, exact=True)\n\n# import itertools\n# for v in itertools.combinations(L, n):M.append(list(v))\n\n# from numba import njit\n# @njit('f8(i8,i8,i8,i8,f8[:,:,:])', cache=True)\n\n\n\"\"\" Definitions \"\"\"\n\ndef lcm(a, b):\n return a*b//math.gcd(a, b)\n\nMOD = 10**9+7\n\n# ============================================================\nk, n = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nm = 2*10**5\nM = [0]*n\ndist = min(A[n-1]-A[0], k-A[n-1]+A[0])\nfor i in range(n-1):\n dist = max(dist, A[i+1]-A[i])\nprint((k-dist))\n", "l,n=map(int,input().split())\na=input().split()\nfor i in range(n):\n a[i]=(int)(a[i])\n \nmin=l+a[0]-a[n-1]\nfor i in range(n-1):\n if min<a[i+1]-a[i]:\n min=a[i+1]-a[i]\nprint(l-min)", "k, n = map(int,input().split())\na = list(map(int,input().split()))\n\nda =[-1] * n\nda[n-1] = k - a[n-1] + a[0]\nfor i in range(n-1):\n da[i] = a[i+1] - a[i]\nprint(k-max(da))", "K, N = list(map(int, input().split()))\nA = list(map(int, input().split()))\nans = 10**18\n\nfor i in range(N):\n if i == 0:\n clock_distance = A[N-1] - A[i]\n reverse_distance = K - A[i+1] + A[i]\n elif i == N-1:\n clock_distance = K - A[i] + A[i-1]\n reverse_distance = A[i] - A[0]\n else:\n clock_distance = K - A[i] + A[i+1]\n reverse_distance = K - A[i+1] + A[i]\n ans = min(clock_distance, reverse_distance, ans)\n\nprint(ans)\n\n\n\n", "f=lambda:[*map(int,input().split())]\nk,n=f()\nl=f()\nl+=[l[0]+k]\na=0\nfor i in range(n):\n a=max(a,l[i+1]-l[i])\nprint(k-a)", "k, n = map(int, input().split())\na = [int(s) for s in input().split()]\n\nd = [0] * (n + 1)\nd[0] = a[0] - 0\nfor i in range(1, n):\n d[i] = a[i] - a[i - 1]\nd[n] = k - a[n - 1] + a[0]\nprint(k - max(d))", "k, n = map(int, input().split())\na_list = list(map(int, input().split()))\nlongest = 0\nfor i in range(n):\n if i==n-1:\n longest = max(longest, k-a_list[i]+a_list[0])\n else:\n distance = a_list[i+1] - a_list[i]\n longest = max(longest, distance)\nprint(k-longest)", "k,n = map(int,input().split())\na = list(map(int,input().split()))\nd= 0\nfor i in range(n-1):\n d = max(a[i+1]-a[i],d)\nprint(min((k-d),a[-1]-a[0]))", "k,n = map(int,input().split())\nan = list(map(int,input().split()))\nan.append(k + an[0])\nmax_length = 0\nfor i in range(n):\n max_length = max(max_length,an[i+1]-an[i])\n\nprint(k-max_length)", "K,N = map(int,input().split())\nA = list(map(int,input().split()))\n\nT = []\n\nfor i in range(1,N):\n T.append(A[i] - A[i-1])\n\nT.append(K - A[N-1] + A[0])\n\nprint(sum(T)-max(T))", "k,n=map(int,input().split())\na=list(map(int,input().split()))\n\nn=len(a)-1\ncnt=[a[n]-a[0]]\nfor i in range(n) :\n cnt.append(k-(a[i+1]-a[i]))\nans=min(cnt)\n\nprint(ans)", "k,n,*l=map(int,open(0).read().split())\nl+=[l[0]+k]\nprint(k-max(l[i+1]-l[i] for i in range(n)))", "\nk, n = map(int, input().split())\na = list(map(int, input().split()))\n\nc = a[0]\na.append(c + k)\nb = [a[i+1] - a[i] for i in range(n)]\n\nprint(k - max(b))", "k, n = map(int, input().split())\na = list(map(int, input().split()))\n\nd = [0]*n\nfor i in range(n):\n if i == n-1:\n d[n-1] = (k-a[n-1]) + a[0]\n \n else :\n d[i] = a[i+1] - a[i]\n\nd.sort()\nd[n-1] = 0\n\nprint(sum(d))", "K, N = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nA3 = A + [K+a for a in A]\ndist = [A3[i+N-1] - A[i] for i in range(N)]\n\nprint((min(dist)))\n\n", "k, n = list(map(int,input().split()))\na = list(map(int,input().split()))\nnew_a = sorted(a)\nnum = len(new_a) - 1\ns_a = []\nb = (k - new_a[num]) + new_a[0]\ns_a.append(b)\ncun = 0\nfor i in new_a[1::]:\n s = i - new_a[cun]\n s_a.append(s)\n cun += 1\nmax_num = max(s_a)\nprint((sum(s_a) - max_num))\n\n", "def __starting_point():\n\n k,n = list(map(int,input().split()))\n A = list(map(int,input().split()))\n\n #\u8ddd\u96e2\u306e\u5dee\u5206\u304c\u4e00\u756a\u591a\u3044\u533a\u9593\u3092\u6c42\u3081\u308b\n sbn = -1\n for i in range(n-1):\n sbn = max(sbn,A[i+1]-A[i])\n\n #\u6700\u521d\u3068\u6700\u5f8c\u3082\u6bd4\u8f03\u3059\u308b\n tmp1 = A[0] - 0\n tmp2 = k - A[n-1]\n sbn = max(sbn,tmp1+tmp2)\n\n print((k-sbn))\n\n\n__starting_point()", "K, N = map(int, input().split())\nA = list(map(int, input().split()))\nA.append(K+A[0])\n\nmax_dist = max([A[i+1] - A[i] for i in range(N)])\nprint(K - max_dist)", "k, n = list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\n\nd_max = 0\na[0] = a[n] - k\n\nfor i in range(1, n + 1):\n d = a[i] - a[i - 1]\n d_max = max(d, d_max)\n\nprint((k - d_max))\n", "k, n = map(int, input().split())\nan = [int(num) for num in input().split()]\n\ndistance =[]\nfor i in range(n-1):\n distance.append(an[i+1]-an[i])\ndistance.append(an[0]+(k-an[n-1]))\n\ndistance.sort()\nprint(k-distance[n-1])", "K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nB = []\nfor i in range(N-1):\n B.append(A[i+1] - A[i])\nB.append(K - A[N-1] + A[0])\nans = K - max(B)\nprint(ans)", "K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nsub = [0] * (N - 1)\n\nfor i in range(N - 1):\n\tsub[i] = A[i + 1] - A[i]\nsub.append(A[0] + (K - A[-1]))\n\nprint(sum(sub) - max(sub))", "import numpy as np\n\nk, n = map(int, input().split())\na_array = list(map(int, input().split()))\n\na_array.append(k + a_array[0])\n\na_diff = np.diff(a_array)\nans = np.sum(a_diff) - np.max(a_diff)\nprint(ans)", "k,n = map(int,input().split())\na = list(map(int,input().split()))\nans = k\nmx = k-a[-1]+a[0]\nfor i in range(n-1):\n mx = max(mx,abs(a[i]-a[i+1]))\nprint(ans-mx)", "k,n = map(int,input().split())\na = list(map(int,input().split()))\ndd = k-a[-1]+a[0]\nd = 0\nfor i in range(n-1):\n d = max(d,a[i+1]-a[i])\nd = max(d,dd)\nprint(k-d)", "K, N = map(int, input().split(' '))\nA_ls = list(map(int, input().split(' ')))\nrst = -1\nfor i in range(N):\n l = A_ls[(i + 1) % N] - A_ls[i]\n if l < 0:\n l = K - A_ls[i] + A_ls[(i + 1) % N]\n if rst == -1:\n rst = l\n else:\n rst = max(rst, l)\nprint(K - rst)", "K,N=list(map(int,input().split()))\nA=list(map(int,input().split()))\nans=A[0]+K-A[-1]\nfor i in range(N-1):\n ans=max(ans,A[i+1]-A[i])\nprint((K-ans))\n", "k, n = list(map(int, input().split()))\ncnt = [0] * (n + 1)\ncmb = 0\na = list(map(int, input().split()))\n\nans = 10 ** 6 + 1\nfor i in range(n):\n r_idx = ((i+1)%n)\n r_ans = a[i]+(k-a[r_idx]) if a[i] < a[r_idx] else abs(a[r_idx]-a[i])\n l_idx = (i-1+n)%n\n l_ans = (k-a[i])+a[l_idx] if a[i] > a[l_idx] else a[l_idx]-a[i]\n\n ans = min([ans, r_ans, l_ans])\n\nprint(ans)\n", "k,n=map(int,input().split());a,c=[*map(int,input().split())],[0]*n\nfor i in range(n-1):\n c[i]=a[i+1]-a[i]\nc[-1]=a[0]+k-a[-1]\nprint(k-max(c))", "K, N = map(int, input().split())\nA = [int(i) for i in input().split()]\nA.append(A[0] + K)\nmax = 0\nfor i in range(N):\n\tif max <= (A[i+1] - A[i]):\n\t\tmax = A[i+1] - A[i]\n \nprint(K - max)", "K, N = list(map(int,input().split()))\nA = list(map(int,input().split()))\nA.sort()\nd = [A[i+1]-A[i] for i in range(N-1)]\nd.append(A[0]+K-A[-1])\nprint(K-max(d))", "k,n=map(int,input().split());a=[*map(int,input().split())];d=[0]*n\nfor i in range(n-1):\n d[i]=a[i+1]-a[i]\nd[-1]=a[0]+k-a[-1]\nprint(k-max(d))", "import numpy as np\n\nk, n = map(int, input().split())\na = list(map(int, input().split()))\n\ndif = []\nfor i in range(len(a)):\n if i == 0:\n dif.append(k-a[-1]+a[0])\n else:\n dif.append(a[i]-a[i-1])\n\ndif = np.array(dif)\nmax_dif_idx = np.argmax(dif)\nprint(dif.sum() - dif[max_dif_idx])", "k, n = list(map(int, input().split()))\na = list(map(int, input().split()))\na1 = sorted(a)\ntemp = list()\nx = len(a)-1\nfor i in range(x):\n temp.append(a1[i+1]-a1[i])\ntemp.append(min(max(a)-min(a),k-max(a)+min(a)))\nans = k-max(temp)\nprint(ans)\n", "k, n = map(int, input().split())\na = list(map(int, input().split()))\n\nbef = a[0]\nmax_diff = 0\nfor i in range(1,n):\n diff = abs(bef - a[i])\n max_diff = max(diff, max_diff)\n bef = a[i]\n\nprint(k - max(max_diff, k - abs(a[n-1] - a[0])))", "K, N = list(map(int, input().split()))\nA = [int(x) for x in input().split()]\n\nmx = A[0] + K - A[-1]\n\nfor i in range(len(A) - 1):\n dis = A[i + 1] - A[i]\n if dis > mx:\n mx = dis\n\nprint((K - mx))\n", "K, N = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\n\n\nA = sorted(A)\nL = []\nANS = 0\n\nA_max = max(A)\n\nfor i in range(N-1):\n L.append(abs(A[i+1]-A[i]))\n \nL.append(K + A[0] - A_max)\n\nL = sorted(L)\n\n\nL.pop(-1)\n\nfor i in range(len(L)):\n ANS = ANS + L[i]\n \nprint(ANS)\n", "k,n = map(int, input().split())\nA = list(map(int,input().split()))\nd = 0\n\nfor i in range(n-1) :\n d = max(d, A[i+1] - A[i])\n\nd1 = (k - A[n-1]) + A[0]\nd = max(d, d1)\nprint(k-d)", "K, N = map(int, input().split())\nA = [int(a) for a in input().split()]\nA.append(A[0] + K)\nb = []\nmax = 0\nsum = 0\nfor i in range(N):\n t = A[i+1] - A[i]\n sum += t\n if max < t:\n max = t\nsum -= max\nprint(sum)", "K, N = map(int, input().split())\nA = list(map(int, input().split()))\n\nnums = [0] * N\nfor i in range(N - 1):\n nums[i] = A[i + 1] - A[i]\nnums[-1] = K + A[0] - A[-1]\n\nprint(sum(nums) - max(nums))\nreturn"] | {"inputs": ["20 3\n5 10 15\n", "20 3\n0 5 15\n"], "outputs": ["10\n", "10\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 24,906 | |
b1ed8ddad87af6e4d4a4765eaba85154 | UNKNOWN | There are two rectangles.
The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.
The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.
Print the area of the rectangle with the larger area.
If the two rectangles have equal areas, print that area.
-----Constraints-----
- All input values are integers.
- 1β€Aβ€10^4
- 1β€Bβ€10^4
- 1β€Cβ€10^4
- 1β€Dβ€10^4
-----Input-----
The input is given from Standard Input in the following format:
A B C D
-----Output-----
Print the area of the rectangle with the larger area.
If the two rectangles have equal areas, print that area.
-----Sample Input-----
3 5 2 7
-----Sample Output-----
15
The first rectangle has an area of 3Γ5=15, and the second rectangle has an area of 2Γ7=14.
Thus, the output should be 15, the larger area. | ["a,b,c,d=map(int, input().split()) \nprint(max(a*b,c*d))", "A, B, C, D = map(int, input().split())\n\nS1 = A * B\nS2 = C * D\n\nprint(max(S1, S2))", "a,b,c,d = map(int, input().split())\n\nprint(max(a*b, c*d))", "a, b, c, d = map(int, input().split())\nlist01 = [a * b, c * d]\nprint(max(list01))", "# 052\n\n# 1.\u5024\u3092\u6b63\u3057\u304f\u53d6\u5f97\na,b,c,d=(int(x) for x in input().split())\n\n# 2.\u6b63\u3057\u304f\u51e6\u7406\n\nmenseki1 = a * b\nmenseki2 = c * d\n\nif menseki1 > menseki2:\n print(menseki1)\n\nelif menseki1 < menseki2:\n print(menseki2)\n\nelse :\n print(menseki1)\n", "A,B,C,D = map(int,input().split())\n\nproduct = max(A * B,C * D)\nprint(product)", "a,b,c,d = map(int,input().split())\n\nx = a*b\ny = c*d\n\nif x>y:\n\tprint(x)\nelif y>=x:\n\tprint(y)", "A, B, C, D = map(int,input().split())\nx = A * B\ny = C * D\n\nif x > y :\n print(x)\nelse:\n print(y)", "# A - Two Rectangles\n\n# A B C D\nA, B, C, D = map(int, input().split())\n\n\nif A * B >= C * D:\n answer = A * B\nelse:\n answer = C * D\n\nprint(answer)", "a,b,c,d = map(int,input().split())\narea1 = a * b\narea2 = c * d \n\nif area1 > area2:\n print(area1)\nelse:\n print(area2)", "\na,b,c,d=list(map(int,input().split()))\n\nprint((max(a*b,c*d)))\n\n", "a,b,c,d = map(int, input().split())\nprint(max(a * b, c * d))", "a,b,c,d = map(int,input().split())\n\nprint(max(a*b,c*d))", "A, B, C, D = map(int,input().split())\n\nif A * B == C * D:\n print(A * B)\nelse:\n print(max(A * B, C * D))", "A, B, C, D = list(map(int, input().split()))\n\nif A * B > C * D:\n print((A * B))\nelse:\n print((C * D))\n", "A, B, C, D = list(map(int, input().split()))\nprint(max(A * B, C * D))", "a, b, c, d = list(map(int,input().split()))\n\nrectangles_1 = a * b\nrectangles_2 = c * d\n\nif rectangles_1 > rectangles_2:\n print(rectangles_1)\nelse:\n print(rectangles_2)\n", "A, B, C, D = map(int, input().split())\ns1 = A * B\ns2 = C * D\n\nif s1 == s2:\n print(s1)\nelif s1 > s2:\n print(s1)\nelse:\n print(s2)", "a, b, c, d = list(map(int, input().split()))\nprint((max(a * b, c * d)))\n", "# \u6570\u5024\u306e\u53d6\u5f97\nA,B,C,D = map(int,input().split())\n\n# \u9762\u7a4d\u306e\u6700\u5927\u5024\u3092\u51fa\u529b\nAB = A * B\nCD = C * D\nprint(max(AB,CD))", "'''\nABC052_a A - Two Rectangles\nhttps://atcoder.jp/contests/abc052/tasks/abc052_a\n'''\n\nclass Solver:\n \"\"\" solve ABC052_a class \"\"\"\n ans = 0\n\n def __init__(self, a, b, c, d):\n self.solve(a, b, c, d)\n\n def compare(self, s1, s2):\n return s1 if s1 > s2 else s2\n\n def calc_area(self, h, w):\n return h*w\n\n def solve(self, h1, w1, h2, w2):\n s1 = self.calc_area(h1, w1)\n s2 = self.calc_area(h2, w2)\n self.ans = self.compare(s1, s2)\n\ndef input_data():\n return list(map(int, input().split()))\n\ndef main():\n a, b, c, d = input_data()\n answer = Solver(a, b, c, d).ans\n print(answer)\n\ndef __starting_point():\n main()\n\n__starting_point()", "#!/usr/bin/env python3\n\ndef main():\n a, b, c, d = list(map(int, input().split()))\n print((max(a * b, c * d)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a,b,c,d = map(int, input().split())\nprint(max(a*b, c*d))", "a, b, c, d = list(map(int, input().split()))\nx = a * b\ny = c * d\nif x == y:\n print(x)\nelif x > y:\n print(x)\nelif y > x:\n print(y)\n", "A, B, C, D = map(int, input().split())\n\n\n\nprint(A*B if A*B == C*D else max(A*B, C*D))", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lint_dec(): return list([int(x) - 1 for x in input().split()])\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nA, B, C, D = lint()\nprint((max(A*B, C*D)))\n", "a, b, c, d = map(int, input().split())\nif a*b - c*d >= 0:\n print(a*b)\nelse:\n print(c*d)", "A, B, C, D = map(int, input().split())\n\narea = [A * B, C * D]\n\nprint(max(area))", "a,b,c,d = map(int,input().split())\n\nprint(max(a*b,c*d))", "a, b, c, d = list(map(int, input().split()))\nprint((max(a * b, c * d)))\n", "a, b, c, d= [*map(int, input().split())]\nprint(max(a*b,c*d))", "vertical1, horizontal1, vertical2, horizontal2 = map(int, input().split())\narea1 = vertical1 * horizontal1\narea2 = vertical2 * horizontal2\nif area1 < area2:\n print(area2)\nelse:\n print(area1)", "A,B,C,D = map(int,input().split(\" \"))\nprint(max(A*B,C*D))", "# 052a\n\ndef atc_052a(input_value: str) -> int:\n A, B, C, D = map(int, input_value.split(\" \"))\n return max(A * B, C * D)\n\ninput_value = input()\nprint(atc_052a(input_value))", "a,b,c,d = map(int,input().split())\n\nif a*b > c*d:\n print(a*b)\n \nelif a*b < c*d:\n print(c*d)\n \nelse:\n print(a*b)", "\n\nA, B, C, D = map(int, input().split())\n\n\n\narea_ab = A * B\narea_cd = C * D\n\nif area_ab > area_cd:\n print(area_ab)\nelse:\n print(area_cd)", "# \u9762\u7a4d\u306e\u6700\u5927\u5024\u3092\u51fa\u529b\u3059\u308b\n\nA, B, C, D = list(map(int, input().split()))\n\narea = [A * B, C * D]\n\nprint((max(area)))\n", "a, b, c, d = map(int, input().split())\n\nobj1 = a*b\nobj2 = c*d\n\nif obj1 < obj2:\n ans = obj2\nelif obj2 < obj1:\n ans = obj1\nelse:\n ans = obj1\n\nprint(ans)", "# 052a\n\ndef atc_052a(input_value: str) -> int:\n A, B, C, D = list(map(int, input_value.split(\" \")))\n return max(A * B, C * D)\n\ninput_value = input()\nprint((atc_052a(input_value)))\n", "A, B, C, D = map(int, input().split())\n\narea1 = A * B\narea2 = C * D\n\nif area1 > area2 or area1 == area2:\n print(area1)\nelse:\n print(area2)", "a, b, c, d = map(int, input().split())\n\nprint(max(a*b,c*d))", "A, B, C, D = map(int, input().split())\n\nif A * B >= C * D:\n print(A * B)\nelse:\n print(C * D)", "a,b,c,d = map(int,input().split())\nif a*b > c*d:\n print(a*b)\nelse:\n print(c*d)", "A, B, C, D = map(int, input().split())\nprint(max(A * B, C * D))", "a,b,c,d=map(int,input().split())\nprint(max(a*b,c*d))", "import sys\ninput = sys.stdin.readline\n\n\nl = list(map(int,input().split()))\n\nrecA = l[:2]\nrecB = l[2:]\n\nareaA = int(recA[0]) * int(recA[-1])\nareaB = int(recB[0]) * int(recB[-1])\n\nif(areaA > areaB):\n print(areaA)\nelif (areaB > areaA):\n print(areaB)\nelif(areaB == areaA):\n print(areaB)\n\n", "A, B, C, D = map(int, input().split())\n\n# \u4e8c\u3064\u306e\u9577\u65b9\u5f62\u304c\u3042\u308a\u307e\u3059\u3002\n# \u4e00\u3064\u76ee\u306e\u9577\u65b9\u5f62\u306f\u3001\u7e26\u306e\u8fba\u306e\u9577\u3055\u304c A\u3001\u6a2a\u306e\u8fba\u306e\u9577\u3055\u304c B\u3067\u3059\u3002\n# \u4e8c\u3064\u76ee\u306e\u9577\u65b9\u5f62\u306f\u3001\u7e26\u306e\u8fba\u306e\u9577\u3055\u304c C\u3001\u6a2a\u306e\u8fba\u306e\u9577\u3055\u304c D\u3067\u3059\u3002\n# \u3053\u306e\u4e8c\u3064\u306e\u9577\u65b9\u5f62\u306e\u3046\u3061\u3001\u9762\u7a4d\u306e\u5927\u304d\u3044\u65b9\u306e\u9762\u7a4d\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n# \u306a\u304a\u3001\u4e8c\u3064\u306e\u9577\u65b9\u5f62\u306e\u9762\u7a4d\u304c\u7b49\u3057\u3044\u6642\u306f\u3001\u305d\u306e\u9762\u7a4d\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\narea_ab = A * B\narea_cd = C * D\n\nif area_ab > area_cd:\n print(area_ab)\nelse:\n print(area_cd)", "n = [int(x) for x in input().split()]\nprint(max(n[0]*n[1],n[2]*n[3]))", "# 052_a\nA, B, C, D = list(map(int, input().split()))\nS1=A*B\nS2=C*D\n\nif (1<=A&A<=10**4)&(1<=B&B<=10**4)&(1<=C&C<=10**4)&(1<=D&D<=10**4):\n if S1>S2:\n print(S1)\n elif S1<=S2:\n print(S2)\n", "'''\n\u554f\u984c\uff1a\n \u4e8c\u3064\u306e\u9577\u65b9\u5f62\u304c\u3042\u308a\u307e\u3059\u3002\n \u4e00\u3064\u76ee\u306e\u9577\u65b9\u5f62\u306f\u3001\u7e26\u306e\u8fba\u306e\u9577\u3055\u304c A\u3001\u6a2a\u306e\u8fba\u306e\u9577\u3055\u304c B \u3067\u3059\u3002\n \u4e8c\u3064\u76ee\u306e\u9577\u65b9\u5f62\u306f\u3001\u7e26\u306e\u8fba\u306e\u9577\u3055\u304c C\u3001\u6a2a\u306e\u8fba\u306e\u9577\u3055\u304c D \u3067\u3059\u3002\n\n \u3053\u306e\u4e8c\u3064\u306e\u9577\u65b9\u5f62\u306e\u3046\u3061\u3001\u9762\u7a4d\u306e\u5927\u304d\u3044\u65b9\u306e\u9762\u7a4d\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002 \u306a\u304a\u3001\u4e8c\u3064\u306e\u9577\u65b9\u5f62\u306e\u9762\u7a4d\u304c\u7b49\u3057\u3044\u6642\u306f\u3001\u305d\u306e\u9762\u7a4d\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n'''\n\n'''\n\u5236\u7d04\uff1a\n \u5165\u529b\u306f\u5168\u3066\u6574\u6570\u3067\u3042\u308b\n 1 \u2266 A \u2266 10000\n 1 \u2266 B \u2266 10000\n 1 \u2266 C \u2266 10000\n 1 \u2266 D \u2266 10000\n'''\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 A, B, C, D \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\na, b, c, d = list(map(int, input().split()))\n\nresult = [a * b, c * d] # \u7d50\u679c\u683c\u7d0d\u7528\u30ea\u30b9\u30c8\nprint((max(result)))\n", "A,B,C,D = map(int,input().split())\nif A * B == C * D:\n print(A * B)\nelif A * B < C * D:\n print(C * D)\nelif A * B > C * D:\n print(A * B)", "vertical1, horizontal1, vertical2, horizontal2 = map(int, input().split())\nif vertical1 * horizontal1 < vertical2 * horizontal2:\n print(vertical2 * horizontal2)\nelse:\n print(vertical1 * horizontal1)", "A, B, C, D = list(map(int,input().split()))\n\nprint(max(A * B, C * D))", "A, B, C, D = list(map(int, input().split()))\nif A * B >= C * D:\n print((A * B))\nelse:\n print((C * D))\n", "a,b,c,d=map(int,input().split())\nprint(max(a*b,c*d))", "A, B, C, D = map(int, input().split())\nprint(max(A * B, C * D))", "a, b, c, d = map(int, input().split())\narea1 = a * b\narea2 = c * d\nif area1 >= area2:\n print(area1)\nelse:\n print(area2)", "a, b, c, d = map(int, input().split())\nprint(max(a*b, c*d))", "a, b, c, d = list(map(int, input().split()))\n\nrec1 = a * b\nrec2 = c * d\n\nif rec1 >= rec2:\n print(rec1)\nelse:\n print(rec2)\n", "A, B, C, D = list(map(int,input().split()))\n\ndef answer(A: int, B: int, C: int, D: int) -> int:\n return max(A * B, C * D)\n\nprint((answer(A, B, C, D)))\n", "A, B, C, D = map(int, input().split())\n\nprint(max(A * B, C * D))", "A,B,C,D=list(map(int,input().split()))\nprint((max(A*B,C*D)))\n", "a,b,c,d=map(int,input().split())\nprint(max(a*b,c*d))", "#ABC052A\na,b,c,d = map(int,input().split())\nprint(max(a*b,c*d))", "S_list = iter(list(map(int,input().split())))\narea = list()\nfor x,y in zip(S_list ,S_list):\n area.append(x*y)\nprint(max(area))", "a,b,c,d =map(int, input().split())\nif a * b > c * d:\n print(a * b)\nelse:\n print(c * d)", "A, B, C, D=map(int,input().split())\n\nif A * B >= C * D:\n print(A * B)\nif A * B < C * D:\n print(C * D)", "# A - Two Rectangles\n# https://atcoder.jp/contests/abc052/tasks/abc052_a\n\nsquare = list(map(int, input().split()))\n\nresult = [square[0] * square[1], square[2] * square[3]]\nprint((max(result)))\n", "a,b,c,d=map(int,input().split())\ne=[]\nf=a*b\ng=c*d\ne.append(f)\ne.append(g)\nif(f==g):\n print(f)\nelse:\n print(max(e))", "A, B, C, D = map(int, input().split())\n\nif A*B > C*D:\n print(A*B)\nelif A*B < C*D:\n print(C*D)\nelse:\n print(A * B)", "a, b, c, d = map(int, input().split())\nif(a*b > c*d):\n print(a*b)\nelse:\n print(c*d)", "a, b, c, d = map(int, input().split())\n\nrec1 = a * b\nrec2 = c * d\n\nif rec1 == rec2:\n print(rec1)\nelse:\n print(max(rec1, rec2))", "A,B,C,D = map(int,input().split())\n\nab = A * B\ncd = C * D\n\nif ab > cd:\n print(ab)\nelif cd > ab:\n print(cd)\nelse:\n print(ab)", "a, b, c, d = list(map(int, input().split()))\n\nprint((max(a * b, c * d)))\n", "a, b, c, d = map(int, input().split())\nprint(max(a*b, c*d))", "rectangle1_scale1, rectangle1_scale2, rectangle2_scale1, rectangle2_scale2 = list(map(int, input().split()))\n\nbig_rectangle_area = max(rectangle1_scale1 * rectangle1_scale2, rectangle2_scale1 * rectangle2_scale2)\n\nprint(big_rectangle_area)\n", "a, b, c, d = map(int,input().split())\nprint(max(a*b, c*d))", "A, B, C, D = map(int, input().split())\nprint(A * B if A * B >= C * D else C * D)", "a, b, c, d = (int(n) for n in input().split())\nprint(max(a * b, c * d))", "a, b, c, d = map(int, input().split())\nif a * b >= c * d:\n print(a * b)\nelse:\n print(c * d)", "#52\nA,B,C,D=map(int,input().split())\nif (A*B)>(C*D):\n print(A*B)\nelse:\n print(C*D)", "# 1\u3064\u76ee\u3000\u7e26A\u3001\u6a2aB\n# 2\u3064\u76ee\u3000\u7e26C\u3001\u6a2aD\na, b, c, d = list(map(int, input().split()))\n# \u9762\u7a4d\u304c\u5927\u304d\u3044\u65b9\u3092\u51fa\u529b\u3001\u7b49\u3057\u3044\u6642\u306f\u9762\u7a4d\u3092\u51fa\u529b\n\nif a * b >= c * d:\n print((a * b))\nelse:\n print((c * d))\n", "a,b,c,d = map(int,input().split())\n# 2\u3064\u306e\u9762\u7a4d\u3092\u30ea\u30b9\u30c8\u5316\narea = [a*b,c*d]\n# \u9762\u7a4d\u306e\u3046\u3061\u6700\u5927\u5024\u3092\u51fa\u529b\nprint(max(area))", "a,b,c,d=map(int,input().split())\nif a*b>=c*d:print(a*b)\nelse:print(c*d)", "A,B,C,D = map(int, input().split())\nprint(max(A*B, C*D))", "a,b,c,d=map(int,input().split())\nprint(max(a*b,c*d))", "a, b, c, d = map(int, input().split())\n\nif a * b >= c * d:\n print(a * b)\nelse:\n print(c * d)", "A,B,C,D=map(int,input().split())\nprint(max(A*B,C*D))", "a, b, c, d = list(map(int, input().split()))\nprint(max(a*b, c*d)) ", "a, b, c, d = map(int,input().split())\nprint(max(a * b, c * d))", "val = list(map(int,input().split()))\nprint(max(val[0] * val[1], val[2] * val[3]))", "A, B, C, D = map(int,input().split())\n\nareaAB = A * B\nareaCD = C * D\n\nif areaAB == areaCD:\n result = areaAB\nelif areaAB > areaCD:\n result = areaAB\nelse:\n result = areaCD\n\nprint(result)", "A, B, C, D = map(int, input().split())\nprint(max(A * B, C * D))", "A,B,C,D = map(int,input().split())\nprint(max(A*B, C*D))", "a,b,c,d=map(int, input().split())\n\nx=a*b\ny=c*d\n\nif x>=y:\n print(x)\nif y>x:\n print(y)", "# \u4e8c\u3064\u306e\u9577\u65b9\u5f62\u304c\u3042\u308a\u307e\u3059\u3002 \u4e00\u3064\u76ee\u306e\u9577\u65b9\u5f62\u306f\u3001\u7e26\u306e\u8fba\u306e\u9577\u3055\u304c A \u3001\u6a2a\u306e\u8fba\u306e\u9577\u3055\u304c B \u3067\u3059\u3002\n# \u4e8c\u3064\u76ee\u306e\u9577\u65b9\u5f62\u306f\u3001\u7e26\u306e\u8fba\u306e\u9577\u3055\u304c C \u3001\u6a2a\u306e\u8fba\u306e\u9577\u3055\u304c D \u3067\u3059\u3002 \u3053\u306e\u4e8c\u3064\u306e\u9577\u65b9\u5f62\u306e\u3046\u3061\u3001\u9762\u7a4d\u306e\u5927\u304d\u3044\u65b9\u306e\u9762\u7a4d\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n# \u306a\u304a\u3001\u4e8c\u3064\u306e\u9577\u65b9\u5f62\u306e\u9762\u7a4d\u304c\u7b49\u3057\u3044\u6642\u306f\u3001\u305d\u306e\u9762\u7a4d\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\nA,B,C,D = map(int,input().split())\n\nx = A * B\ny = C * D\nif x > y:\n print(x)\nelif x < y:\n print(y)\nelif x == y:\n print(x)", "A,B,C,D = map(int, input().split())\n\narea1 = A * B\narea2 = C * D\n\nif area1 > area2:\n print(area1)\nelif area1 < area2:\n print(area2)\nelse:\n print(area1)", "a, b, c, d = map(int, input().split())\n\nprint(max(a * b, c * d))", "A, B, C, D = map(int, input().split())\n\nX = A * B\nY = C * D\n\n\nif X > Y:\n print(X)\nelse:\n print(Y)"] | {"inputs": ["3 5 2 7\n", "100 600 200 300\n"], "outputs": ["15\n", "60000\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 15,655 | |
d5a881ec674ba6a87482d558699a9e59 | UNKNOWN | Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.
See the Output section for the output format.
-----Constraints-----
- 1 \leq N \leq 10^5
- S_i is AC, WA, TLE, or RE.
-----Input-----
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N
-----Output-----
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3
-----Sample Input-----
6
AC
TLE
AC
AC
WA
TLE
-----Sample Output-----
AC x 3
WA x 1
TLE x 2
RE x 0
We have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively. | ["c = int(input())\n\nr = [\"AC\", \"WA\", \"TLE\", \"RE\"]\na = { i:0 for i in r}\n\nfor i in range(c):\n s = input()\n a [s] += 1\n\nfor rr in r:\n print(rr + \" x \" + str(a[rr]))", "n = int(input())\nl = []\nfor i in range(n):\n l.append(input().rstrip())\n \nprint('AC x ' + str(l.count('AC')))\nprint('WA x ' + str(l.count('WA')))\nprint('TLE x ' + str(l.count('TLE')))\nprint('RE x ' + str(l.count('RE')))", "n = int(input())\nl = []\nfor i in range(n):\n l.append(str(input()))\nprint((\"AC x \"+str(l.count('AC'))))\nprint((\"WA x \"+str(l.count('WA'))))\nprint((\"TLE x \"+str(l.count('TLE'))))\nprint((\"RE x \"+str(l.count('RE'))))\n", "\nn = int(input())\nAC,WA,TLE,RE = 0,0,0,0\n\nfor x in range(n):\n s = input()\n if s == 'AC':\n AC = AC + 1\n elif s == 'WA':\n WA = WA + 1\n elif s == 'TLE':\n TLE = TLE + 1\n elif s == 'RE':\n RE = RE + 1\n\nprint(('AC x ' + str(AC)))\nprint(('WA x ' + str(WA)))\nprint(('TLE x ' + str(TLE)))\nprint(('RE x ' + str(RE)))\n\n", "n = int(input())\njudge = ['AC', 'WA', 'TLE', 'RE']\ncnt = [0] * 4\nfor _ in range(n):\n s = input()\n cnt[judge.index(s)] += 1\nfor i in range(4):\n print(judge[i], \"x\", cnt[i])", "N=int(input())\nAC=0\nWA=0\nTLE=0\nRE=0\nfor i in range(N):\n S=input()\n if S=='AC':\n AC+=1\n elif S=='WA':\n WA+=1\n elif S=='TLE':\n TLE+=1\n elif S=='RE':\n RE+=1\n\nprint('AC x ',AC)\nprint('WA x ',WA)\nprint('TLE x ',TLE)\nprint('RE x ',RE)", "n = int(input())\nac = wa = tle = re = 0\nfor i in range(n):\n st = input()\n if st == 'AC':\n ac += 1\n elif st == 'WA':\n wa += 1\n elif st == 'TLE':\n tle += 1\n else:\n re += 1\nprint(f'AC x {ac}\\nWA x {wa}\\nTLE x {tle}\\nRE x {re}')\n", "N = int(input())\n\nC0 = 0\nC1 = 0\nC2 = 0\nC3 = 0\n\nfor i in range(N):\n Si = input()\n if Si == 'AC':\n C0 += 1\n elif Si == 'WA':\n C1 += 1\n elif Si == 'TLE':\n C2 += 1\n elif Si == 'RE':\n C3 += 1\nprint('AC x ' + str(C0))\nprint('WA x ' + str(C1))\nprint('TLE x ' + str(C2))\nprint('RE x ' + str(C3))", "N = int(input())\n\nd = {\"AC\":0,\"WA\":0,\"TLE\":0,\"RE\":0}\nfor _ in range(N):\n d[input()]+=1\nfor i,v in d.items():\n print(f\"{i} x {v}\")", "n = int(input())\nlist = []\ni = 1\nwhile i <= n:\n list.append(input())\n i += 1\nprint('AC x ', list.count('AC'))\nprint('WA x ', list.count('WA'))\nprint('TLE x ', list.count('TLE'))\nprint('RE x ', list.count('RE'))", "import sys\n\n\ninputs = []\nfor input in sys.stdin:\n inputs.append(input.replace(\"\\n\", \"\"))\n\nAC = 0\nWA = 0\nTLE = 0\nRE = 0\n\nfor index, input in enumerate(inputs, 1):\n if input == \"AC\":\n AC += 1\n if input == \"WA\":\n WA += 1\n if input == \"TLE\":\n TLE += 1\n if input == \"RE\":\n RE += 1\n\nprint((\"AC x \" + str(AC) + \"\\nWA x \" + str(WA) + \"\\nTLE x \" + str(TLE) + \"\\nRE x \" + str(RE)))\n", "N = int(input())\nD = {\"AC\": 0, \"WA\": 0, \"TLE\": 0, \"RE\": 0}\nfor i in range(N):\n D[input()] += 1\nfor x, y in list(D.items()):\n print((\"{0} x {1}\".format(x, y)))\n", "N = int(input())\nAC = 0\nWA = 0\nTLE = 0\nRE = 0\nfor i in range(N):\n s = input()\n if(s=='AC'):\n AC+=1\n elif(s=='WA'):\n WA+=1\n elif(s=='TLE'):\n TLE+=1\n elif(s=='RE'):\n RE+=1\n\nprint('AC x '+str(AC))\nprint('WA x '+str(WA))\nprint('TLE x '+str(TLE))\nprint('RE x '+str(RE))", "N = int(input())\nC0 = C1 = C2 = C3 = 0\n\nfor i in range(N):\n S = str(input())\n if S == \"AC\":\n C0 += 1\n if S == \"WA\":\n C1 += 1\n if S == \"TLE\":\n C2 += 1\n if S == \"RE\":\n C3 += 1\n\nC0 = str(C0)\nC1 = str(C1)\nC2 = str(C2)\nC3 = str(C3)\n\nprint(\"AC x \" + C0)\nprint(\"WA x \" + C1)\nprint(\"TLE x \" + C2)\nprint(\"RE x \" + C3)", "N = int(input())\nAC, WA, TLE, RE = 0, 0, 0, 0\nfor i in range(N):\n S = input()\n if S == 'AC':\n AC += 1\n elif S == 'WA':\n WA += 1\n elif S == 'TLE':\n TLE += 1\n elif S == 'RE':\n RE += 1\nprint('AC x {}\\nWA x {}\\nTLE x {}\\nRE x {}\\n'.format(AC, WA, TLE, RE))", "N = int(input())\nS = [input() for i in range(N)]\n\nnac = len([s for s in S if s == \"AC\"])\nnwa = len([s for s in S if s == \"WA\"])\nntle = len([s for s in S if s == \"TLE\"])\nnre = len([s for s in S if s == \"RE\"])\n\nprint((\"AC x \" + str(nac)))\nprint((\"WA x \" + str(nwa)))\nprint((\"TLE x \" + str(ntle)))\nprint((\"RE x \" + str(nre)))\n", "dic = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}\nN = int(input())\nfor i in range(N):\n dic[input()] += 1\nfor i in dic:\n print(i, 'x', dic[i])", "N = int(input())\nS = ['' for i in range(N)]\nfor i in range(N):\n S[i] = str(input())\n\nitem = [0, 0, 0, 0]\nrslt = ['AC', 'WA', 'TLE', 'RE']\nfor i in range(N):\n if S[i] == rslt[0]:\n item[0] += 1\n elif S[i] == rslt[1]:\n item[1] += 1\n elif S[i] == rslt[2]:\n item[2] += 1\n else:\n item[3] += 1\n\nfor i in range(4):\n print(rslt[i], 'x', item[i])", "N = int(input())\nresult = [\"AC\",\"WA\",\"TLE\",\"RE\"]\nS = [input() for i in range(N)]\n\nfor i in result:\n print(i,\"x\",S.count(i))", "n = int(input())\nd = {\"AC\": 0, \"WA\": 0, \"TLE\": 0, \"RE\": 0}\nfor i in range(n):\n s = input()\n d[s] += 1\nprint(\"AC x\", d[\"AC\"])\nprint(\"WA x\", d[\"WA\"])\nprint(\"TLE x\", d[\"TLE\"])\nprint(\"RE x\", d[\"RE\"])", "n = int(input())\njudge_list = [input() for i in range(n)]\n\nac_n = judge_list.count('AC')\ntle_n = judge_list.count('TLE')\nwa_n = judge_list.count('WA')\nre_n = judge_list.count('RE')\n\nprint(f'AC x {ac_n}')\nprint(f'WA x {wa_n}')\nprint(f'TLE x {tle_n}')\nprint(f'RE x {re_n}')\n", "N = int(input())\nS = [input() for i in range(N)]\n\nprint(\"AC x\",S.count(\"AC\"))\nprint(\"WA x\",S.count(\"WA\"))\nprint(\"TLE x\",S.count(\"TLE\"))\nprint(\"RE x\",S.count(\"RE\"))", "N = int(input())\nresult = []\nfor i in range(N):\n r = input()\n result.append(r)\nAC = 0\nWA = 0\nTLE = 0\nRE = 0\nfor i in range(N):\n if result[i] == 'AC':\n AC += 1\n if result[i] == 'WA':\n WA += 1\n if result[i] == 'TLE':\n TLE += 1\n if result[i] == 'RE':\n RE += 1\nprint('AC x', AC)\nprint('WA x', WA)\nprint('TLE x', TLE)\nprint('RE x', RE)", "N = int(input())\nC0 =[]\nC1 =[]\nC2 =[]\nC3 =[]\nfor i in range(N):\n S = input()\n if S == 'AC':\n C0.append(S)\n elif S == 'WA':\n C1.append(S)\n elif S == 'TLE':\n C2.append(S)\n elif S == 'RE':\n C3.append(S)\n\nprint('AC x ', len(C0))\nprint('WA x ', len(C1))\nprint('TLE x ', len(C2))\nprint('RE x ', len(C3))", "import collections as cs\nc=cs.Counter([input() for i in range(int(input()))])\nprint(f'AC x {c[\"AC\"]}')\nprint(f'WA x {c[\"WA\"]}')\nprint(f'TLE x {c[\"TLE\"]}')\nprint(f'RE x {c[\"RE\"]}')", "n = int(input())\n\nac = 0\nwa = 0\ntle = 0\nre = 0\n\nfor i in range(n):\n result = input()\n if result == \"AC\":\n ac = ac + 1\n elif result == \"WA\":\n wa = wa + 1\n elif result == \"TLE\":\n tle = tle + 1\n elif result == \"RE\":\n re = re + 1\n\nprint(\"AC x \" + str(ac))\nprint(\"WA x \" + str(wa))\nprint(\"TLE x \" + str(tle))\nprint(\"RE x \" + str(re))", "a,w,t,r = 0,0,0,0\nfor _ in range(int(input())):\n s = input()\n if(s == \"AC\"):\n a += 1\n elif(s == \"WA\"):\n w += 1\n elif(s == \"TLE\"):\n t += 1\n else:\n r += 1\nprint(\"AC x\",a)\nprint(\"WA x\",w)\nprint(\"TLE x\",t)\nprint(\"RE x\",r)", "import collections\n\nn = int(input())\nlist = []\nfor i in range(n):\n x = input()\n list.append(x)\n \nc = collections.Counter(list)\n\nprint(\"AC x {}\".format(c['AC']))\nprint(\"WA x {}\".format(c['WA']))\nprint(\"TLE x {}\".format(c['TLE']))\nprint(\"RE x {}\".format(c['RE']))", "n = int(input())\n\ns = [input() for i in range(n)]\n\nnumAC = 0\nnumWA = 0\nnumTLE = 0\nnumRE = 0\n\nfor i in range(len(s)):\n if s[i] == \"AC\":\n numAC += 1\n elif s[i] == \"WA\":\n numWA += 1\n elif s[i] == \"TLE\":\n numTLE += 1\n elif s[i] == \"RE\":\n numRE += 1\n else:\n continue\nprint(\"AC x {}\\nWA x {}\\nTLE x {}\\nRE x {}\".format(numAC,numWA,numTLE,numRE))", "from collections import defaultdict\nkero = ['AC', 'WA', 'TLE', 'RE']\n\ntanuki = defaultdict(int)\nn = int(input())\ns = [input() for i in range(n)]\nfor res in s:\n tanuki[res] += 1\n\nfor k in kero:\n print(f'{k} x {tanuki[k]}')", "n = int(input())\nli = [input() for i in range(n)]\nac = 0\nwa = 0\ntle = 0\nre = 0\nfor i in li:\n if i == 'AC':\n ac += 1\n elif i == 'WA':\n wa += 1\n elif i == 'TLE':\n tle += 1\n elif i == 'RE':\n re += 1\nprint('AC x',ac)\nprint('WA x',wa)\nprint('TLE x',tle)\nprint('RE x',re)", "N = int(input())\nS = [input() for i in range(N)]\n \nprint(\"AC x\",S.count(\"AC\"))\nprint(\"WA x\",S.count(\"WA\"))\nprint(\"TLE x\",S.count(\"TLE\"))\nprint(\"RE x\",S.count(\"RE\"))", "def main():\n n = int(input())\n \n s = [input().rstrip('\\r') for i in range(n)]\n li = [\"AC\", \"WA\", \"TLE\", \"RE\"]\n cnt = 0\n \n for i in range(len(li)):\n for j in s:\n if li[i] == j:\n cnt += 1\n print(li[i] + \" x \" + str(cnt))\n cnt = 0\n \n \ndef __starting_point():\n main()\n__starting_point()", "count = int(input())\nlists = []\n\nfor i in range(count):\n new = input()\n lists.append(new)\n\nac_count = lists.count('AC')\nwa_count = lists.count('WA')\ntle_count = lists.count('TLE')\nre_count = lists.count('RE')\n\nprint((\"AC x \" + str(ac_count)))\nprint((\"WA x \" + str(wa_count)))\nprint((\"TLE x \" + str(tle_count)))\nprint((\"RE x \" + str(re_count)))\n\n", "import collections\nN = int(input())\na = [input() for i in range(N)]\nprint(\"AC x \"+str(a.count(\"AC\")))\nprint(\"WA x \"+str(a.count(\"WA\")))\nprint(\"TLE x \"+str(a.count(\"TLE\")))\nprint(\"RE x \"+str(a.count(\"RE\")))", "n = int(input())\ns = [input() for i in range(n)]\n\nac, wa, tle, re = 0, 0, 0, 0\n\nfor s_e in s:\n if s_e == \"AC\":\n ac += 1\n elif s_e == \"WA\":\n wa += 1\n elif s_e == \"TLE\":\n tle += 1\n elif s_e == \"RE\":\n re += 1\n\nprint(f\"AC x {ac}\")\nprint(f\"WA x {wa}\")\nprint(f\"TLE x {tle}\")\nprint(f\"RE x {re}\")\n", "count = {\"AC\":0,\"WA\":0, \"TLE\":0, \"RE\":0}\nfor i in range(int(input())):\n x = str(input())\n if x in count:\n count[x] += 1\n\nprint(\"AC x \" + str(count[\"AC\"]))\nprint(\"WA x \" + str(count[\"WA\"]))\nprint(\"TLE x \" + str(count[\"TLE\"]))\nprint(\"RE x \" + str(count[\"RE\"]))", "res = []\n\nn = int(input())\n\nfor i in range(n):\n r = input()\n res.append(r)\n\nac = res.count(\"AC\")\nwa = res.count(\"WA\")\ntle = res.count(\"TLE\")\nre = res.count(\"RE\")\n\nprint(\"AC x \"+str(ac))\nprint(\"WA x \"+str(wa))\nprint(\"TLE x \"+str(tle))\nprint(\"RE x \"+str(re))", "import collections\nn = int(input())\nres = [input() for i in range(n)]\na = collections.Counter(res)\n\nprint('{} x {}'.format('AC', a['AC']))\nprint('{} x {}'.format('WA', a['WA']))\nprint('{} x {}'.format('TLE', a['TLE']))\nprint('{} x {}'.format('RE', a['RE']))", "N=int(input())\nac=0\nwa=0\ntle=0\nre=0\nfor _ in range(N):\n s=input()\n if 'AC'==s:\n ac+=1\n elif 'WA'==s:\n wa+=1\n elif 'TLE'==s:\n tle+=1\n elif 'RE'==s:\n re+=1\nprint('AC','x',ac)\nprint('WA','x',wa)\nprint('TLE','x',tle)\nprint('RE','x',re)", "ac = 0\nwa = 0\ntle = 0\nre = 0\nfor i in range(int(input())):\n word = input()\n if word == \"AC\":\n ac += 1\n elif word == \"WA\":\n wa += 1\n elif word == \"TLE\":\n tle += 1\n elif word == \"RE\":\n re += 1\n \nprint(\"AC x \" + str(ac))\nprint(\"WA x \" + str(wa))\nprint(\"TLE x \" + str(tle))\nprint(\"RE x \" + str(re))", "N = int(input())\nc0, c1, c2, c3 = 0, 0, 0, 0\nfor i in range(N):\n r = input()\n if r == 'AC':\n c0 += 1\n elif r == 'WA':\n c1 += 1\n elif r == 'TLE':\n c2 += 1\n else:\n c3 += 1\nprint('AC x ' + str(c0))\nprint('WA x ' + str(c1))\nprint('TLE x ' + str(c2))\nprint('RE x ' + str(c3))", "n = int(input())\ns = [input() for i in range(n)]\nresults = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}\nfor res in s:\n results[res] += 1\nfor r, num in results.items():\n print(f'{r} x {num}')", "# coding: utf-8\n# Your code here!\n\nn = int(input())\n\nac = 0\nwa = 0\ntle = 0\nre = 0\n\nfor i in range(n):\n s = input()\n if s ==\"AC\":\n ac += 1\n elif s ==\"WA\":\n wa += 1\n elif s ==\"TLE\":\n tle += 1\n elif s ==\"RE\":\n re += 1\n \nprint(\"AC x \" + str(ac))\nprint(\"WA x \" + str(wa))\nprint(\"TLE x \" + str(tle))\nprint(\"RE x \" + str(re))", "N = int(input())\nac = 0\nwa = 0\ntle = 0\nre = 0\nfor i in range(N):\n s = str(input())\n if s == 'AC':\n ac += 1\n elif s == 'WA':\n wa += 1\n elif s == 'TLE':\n tle += 1\n elif s =='RE':\n re += 1\nprint('AC x',ac)\nprint('WA x',wa)\nprint('TLE x',tle)\nprint('RE x',re)", "N = int(input())\nD = {\"AC\": 0, \"WA\": 0, \"TLE\": 0, \"RE\": 0}\nfor i in range(N):\n D[input()] += 1\nfor x, y in list(D.items()):\n print((\"{0} x {1}\".format(x, y)))\n\n", "n=int(input())\nacc=0\nwac=0\ntlec=0\nrec=0\nfor i in range(n):\n s = input()\n if(s==\"AC\"):\n acc+=1\n elif(s==\"WA\"):\n wac+=1\n elif(s==\"TLE\"):\n tlec+=1\n elif(s==\"RE\"):\n rec+=1\nprint(\"AC x %d\" %(acc))\nprint(\"WA x %d\" %(wac))\nprint(\"TLE x %d\" %(tlec))\nprint(\"RE x %d\" %(rec))", "N = int(input())\nD = {\"AC\":0,\"WA\":0,\"TLE\":0,\"RE\":0}\nfor i in range(N):\n D[input()]+=1\nfor x,y in D.items():\n print(\"{0} x {1}\".format(x,y) )", "N=int(input())\n\nitem={\"AC\":0,\"WA\":0,\"TLE\":0,\"RE\":0}\n\nfor n in range(N):\n S=input()\n\n if S==\"AC\":\n item[\"AC\"]+=1\n elif S==\"WA\":\n item[\"WA\"]+=1\n elif S==\"TLE\":\n item[\"TLE\"]+=1\n else:\n item[\"RE\"]+=1\n\nprint(\"AC x\",end=\" \")\nprint(item[\"AC\"])\n\nprint(\"WA x\",end=\" \")\nprint(item[\"WA\"])\n\nprint(\"TLE x\",end=\" \")\nprint(item[\"TLE\"])\n\nprint(\"RE x\",end=\" \")\nprint(item[\"RE\"])\n", "N = int(input())\nstring = [\"AC\", \"WA\", \"TLE\", \"RE\"]\ncount = [0] * 4\nfor i in range(N):\n s = input()\n if s == \"AC\":\n count[0] = count[0] + 1\n elif s == \"WA\":\n count[1] = count[1] + 1\n elif s == \"TLE\":\n count[2] = count[2] + 1\n else:\n count[3] = count[3] + 1\nfor j in range(len(count)):\n print(string[j] + \" x \" + str(count[j]))", "n = int(input())\nac=0\nwa=0\ntle=0\nre=0\nfor i in range(n):\n s=input()\n if(s == 'AC'):\n ac += 1\n elif(s == 'WA'):\n wa += 1\n elif(s == 'TLE'):\n tle += 1\n else:\n re += 1\nprint('AC x {}'.format(ac))\nprint('WA x {}'.format(wa))\nprint('TLE x {}'.format(tle))\nprint('RE x {}'.format(re))", "N = int(input())\nS = [\"AC\", \"WA\", \"TLE\", \"RE\"]\na = []\nac = 0\nwa = 0\ntle = 0\nre = 0\nif N >= 1 and N <= 10**5:\n for x in range(N):\n a.append(input())\nfor x in a:\n if x == \"AC\":\n ac += 1\nprint (\"AC x \", ac)\nfor x in a:\n if x == \"WA\":\n wa += 1\nprint (\"WA x \", wa)\nfor x in a:\n if x == \"TLE\":\n tle += 1\nprint (\"TLE x \", tle)\nfor x in a:\n if x == \"RE\":\n re += 1\nprint (\"RE x \", re)", "n=int(input())\na=[0]*4\nb=[\"AC\",\"WA\",\"TLE\",\"RE\"]\nfor i in range(n):\n s=input()\n for j in range(4):\n if s == b[j]:\n a[j]+=1\nfor i in range(4):\n print(b[i]+\" x \"+str(a[i]))", "N = int(input())\nj = [input() for i in range(N)]\nimport collections\nc = collections.Counter(j)\ncs = c['AC']\nca = c['WA']\ncb = c['TLE']\ncc = c['RE']\nprint(f'AC x {cs}')\nprint(f'WA x {ca}')\nprint(f'TLE x {cb}')\nprint(f'RE x {cc}')\n", "n = int(input())\ns = [input() for _ in range(n)]\nac = s.count(\"AC\")\nwa = s.count(\"WA\")\ntle = s.count(\"TLE\")\nre = s.count(\"RE\")\n\nprint(f\"AC x {ac}\")\nprint(f\"WA x {wa}\")\nprint(f\"TLE x {tle}\")\nprint(f\"RE x {re}\")", "n = int(input())\nac, wa, tle, re = 0, 0, 0, 0;\n\nfor i in range(n):\n s = input()\n if s == 'AC':\n ac += 1\n elif s == 'WA':\n wa += 1\n elif s == 'TLE':\n tle += 1\n else:\n re += 1\n\nprint('AC', 'x', ac)\nprint('WA', 'x', wa)\nprint('TLE', 'x', tle)\nprint('RE', 'x', re)", "\nn = int(input())\nres = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}\n\nfor i in range(n):\n res[input()] +=1\n\nfor k in res:\n print(('{} x {}'.format(k, res[k])))\n", "n = int(input())\nac = 0\nwa = 0\ntle = 0\nre = 0\nfor i in range(n):\n s = input()\n if s == \"AC\":\n ac += 1\n elif s == \"WA\":\n wa += 1\n elif s == \"TLE\":\n tle += 1\n else:\n re += 1\nprint(\"AC\",\"x\",ac)\nprint(\"WA\",\"x\",wa)\nprint(\"TLE\",\"x\",tle)\nprint(\"RE\",\"x\",re)", "n = int(input())\n\nac = 0\nwa = 0\ntle = 0\nre = 0\n\nfor i in range(n):\n s = input()\n if s == \"AC\":\n ac += 1\n elif s == \"WA\":\n wa += 1\n elif s == \"TLE\":\n tle += 1\n elif s == \"RE\":\n re += 1\n\nprint((\"AC x {}\".format(str(ac))))\nprint((\"WA x {}\".format(str(wa))))\nprint((\"TLE x {}\".format(str(tle))))\nprint((\"RE x {}\".format(str(re))))\n\n", "N = int(input())\n\nS = []\n\nc0 = 0\nc1 = 0\nc2 = 0\nc3 = 0\n \nfor i in range(N):\n S.append(input())\n \n if S[i] == \"AC\" :\n c0 += 1\n elif S[i] == \"WA\" :\n c1 += 1\n elif S[i] == \"TLE\" :\n c2 += 1\n elif S[i] == \"RE\" :\n c3 += 1\n \nprint(\"AC x \" + str(c0))\nprint(\"WA x \" + str(c1))\nprint(\"TLE x \" + str(c2))\nprint(\"RE x \" + str(c3))", "N = int(input().split()[0])\na = [0,0,0,0]\nfor i in range(N):\n b=input().split()[0]\n if(b == 'AC'):\n a[0]+=1\n elif(b == 'WA'):\n a[1]+=1\n elif(b == 'TLE'):\n a[2]+=1\n elif(b == 'RE'):\n a[3]+=1\nprint((\"AC x {0}\\nWA x {1}\\nTLE x {2}\\nRE x {3}\".format(a[0],a[1],a[2],a[3])))\n", "N = int(input())\ncount= [0,0,0,0]\nfor _ in range(N):\n word = input()\n if word=='AC':\n count[0] += 1\n elif word=='WA':\n count[1] += 1\n elif word=='TLE':\n count[2] += 1\n elif word=='RE':\n count[3] += 1\nprint('AC x ',count[0])\nprint('WA x ',count[1])\nprint('TLE x ',count[2])\nprint('RE x ',count[3])", "n = int(input())\nresult_dict = {'AC':0,'WA':0,'TLE':0,'RE':0}\nfor i in range(n):\n s = input()\n result_dict[s] += 1\n \nprint('AC'+' x '+str(result_dict['AC']))\nprint('WA'+' x '+str(result_dict['WA']))\nprint('TLE'+' x '+str(result_dict['TLE']))\nprint('RE'+' x '+str(result_dict['RE']))", "import sys\nfrom collections import deque, defaultdict, Counter\nfrom itertools import accumulate, product, permutations, combinations\nfrom operator import itemgetter\nfrom bisect import bisect_left, bisect_right\nfrom heapq import heappop, heappush\nfrom math import ceil, floor, sqrt, gcd, inf\nfrom copy import deepcopy\nimport numpy as np\nimport scipy as sp\n\nINF = inf\nMOD = 1000000007\n\nn = int(input())\nS = [input() for j in range(n)] # n\u306f\u884c\u6570\n\ntmp = 0\nres = 0\n\ntmp = Counter(S)\nres = f\"\"\"AC x {tmp[\"AC\"]}\nWA x {tmp[\"WA\"]}\nTLE x {tmp[\"TLE\"]}\nRE x {tmp[\"RE\"]}\"\"\"\n\nprint(res)\n", "N = int(input())\nAC = 0\nWA = 0\nTLE = 0\nRE = 0\nfor i in range(N):\n value = str(input())\n if value == 'AC':\n AC += 1\n elif value == 'WA':\n WA += 1\n elif value == 'TLE':\n TLE += 1\n else:\n RE += 1\nprint(('AC x ' + str(AC)))\nprint(('WA x ' + str(WA)))\nprint(('TLE x ' + str(TLE)))\nprint(('RE x ' + str(RE)))\n", "N = int(input())\ndic = {\"AC\": 0, \"WA\": 0, \"TLE\": 0, \"RE\": 0} # \u30ad\u30fc\u3068\u521d\u671f\u5024\u3092\u8a2d\u5b9a\n\nfor i in range(N):\n S = input()\n if S == \"AC\":\n dic[\"AC\"] += 1\n elif S == \"WA\":\n dic[\"WA\"] += 1\n elif S == \"TLE\":\n dic[\"TLE\"] += 1\n else:\n dic[\"RE\"] += 1\n\nfor key in list(dic.keys()):\n print((\"{0} x {1}\".format(key, dic[key])))\n\n", "N = int(input())\nC = 0\nD = 0\nE = 0\nF = 0\nS = ''\n\nfor i in range(N):\n S = input()\n if S == 'AC':\n C += 1\n elif S == 'WA':\n D += 1\n elif S == 'TLE':\n E += 1\n elif S == 'RE':\n F += 1\nprint('AC x '+ str(C), 'WA x ' + str(D), 'TLE x ' + str(E), 'RE x ' + str(F), sep='\\n')\n", "N = int(input())\nS = [input() for S in range(N)]\nC = [0, 0, 0, 0]\n\nfor i in range(N):\n if S[i] == 'AC':\n C[0] += 1\n elif S[i] == 'WA':\n C[1] += 1\n elif S[i] == 'TLE':\n C[2] += 1\n elif S[i] == 'RE':\n C[3] += 1\n\nprint('AC x ', C[0])\nprint('WA x ', C[1])\nprint('TLE x ', C[2])\nprint('RE x ', C[3])", "n=int(input())\na,w,t,r=0,0,0,0\nfor i in range(n):\n g=input()\n if g=='AC':\n a+=1\n if g=='WA':\n w+=1\n if g=='TLE':\n t+=1\n if g=='RE':\n r+=1\nprint('AC x ' + str(a))\nprint('WA x ' + str(w))\nprint('TLE x ' + str(t))\nprint('RE x ' + str(r))", "n=int(input())\nd={\n 'AC':0,\n 'WA':0,\n 'TLE':0,\n 'RE':0\n}\n\nfor i in range(n):\n d[input()]+=1\n\nfor k,v in d.items():\n print(k,'x', v)", "def ans173(N:int, S:list):\n return (f\"\"\"AC x {(S.count(\"AC\"))}\nWA x {(S.count(\"WA\"))}\nTLE x {(S.count(\"TLE\"))}\nRE x {(S.count(\"RE\"))}\"\"\")\n\nN=int(input())\nS=[input() for i in range(N)]\nprint(ans173(N,S))", "N = int(input())\n\nS = [input() for i in range(N)]\n\nc0 = (S.count(\"AC\"))\nc1 = (S.count(\"WA\"))\nc2 = (S.count(\"TLE\"))\nc3 = (S.count(\"RE\"))\n\nprint(\"AC x \" + str(c0))\nprint(\"WA x \" + str(c1))\nprint(\"TLE x \" + str(c2))\nprint(\"RE x \" + str(c3))", "N = int(input())\nAC = 0\nWA = 0\nTLE = 0\nRE = 0\nfor i in range (N):\n S = input()\n if S == \"AC\":\n AC += 1\n elif S == \"WA\": \n WA += 1\n elif S == \"TLE\":\n TLE += 1\n elif S == \"RE\":\n RE += 1\nprint(\"AC x \",AC)\nprint(\"WA x \",WA)\nprint(\"TLE x \",TLE)\nprint(\"RE x \",RE)", "from collections import *\nc=Counter(map(lambda x:x[:-1],open(0)))\nfor s in[\"AC\",\"WA\",\"TLE\",\"RE\"]:print(s,\"x\",c[s])", "n=int(input())\na=[input() for i in range(n)]\n\nfor i in ['AC','WA','TLE','RE']:\n print(f'{i} x {a.count(i)}')", "N = int(input())\nAC = 0\nWA = 0\nTLE = 0\nRE = 0\n\nfor i in range(N):\n S = input()\n if S == \"AC\":\n AC += 1\n elif S == \"WA\":\n WA += 1\n elif S == \"TLE\":\n TLE += 1\n else:\n RE += 1\n \n \nprint(\"AC x\",AC)\nprint(\"WA x\",WA)\nprint(\"TLE x\",TLE)\nprint(\"RE x\",RE)", "n = int(input())\ns = [input().split() for i in range(n)]\na = 0\nb = 0\nc = 0\nd = 0\nfor i in range(n):\n if s[i][0] == 'AC':\n a += 1\n elif s[i][0] == 'WA':\n b += 1\n elif s[i][0] == 'TLE':\n c += 1\n else:\n d += 1\nprint('AC x '+str(a))\nprint('WA x '+str(b))\nprint('TLE x '+ str(c))\nprint('RE x '+str(d))", "from collections import Counter\nfrom typing import List\n\n\ndef answer(n: int, s: List[str]) -> List[str]:\n result = []\n judges = ['AC', 'WA', 'TLE', 'RE']\n aggregate = {i: 0 for i in judges}\n counter = Counter(s)\n\n for i in counter:\n aggregate[i] += counter[i]\n for j in aggregate:\n result.append(f'{j} x {aggregate[j]}')\n\n return result\n\n\ndef main():\n n = int(input())\n s = [input() for _ in range(n)]\n for i in answer(n, s):\n print(i)\n\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\nS_list = [input() for i in range(N)]\n\nac = S_list.count(\"AC\")\nwa = S_list.count(\"WA\")\ntle = S_list.count(\"TLE\")\nre = S_list.count(\"RE\")\n\nprint(f'AC x {ac}')\nprint(f'WA x {wa}')\nprint(f'TLE x {tle}')\nprint(f'RE x {re}')", "from typing import List\n\n\ndef answer(n: int, s: List[str]) -> List[str]:\n result = []\n judges = ['AC', 'WA', 'TLE', 'RE']\n for i in judges:\n\t result.append(f'{i} x {s.count(i)}')\n\n return result\n\n\ndef main():\n n,*s = open(0).read().split()\n for i in answer(n, s):\n print(i)\n\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\ns = []\nfor i in range(n):\n s.append(input())\nac = s.count(\"AC\")\nwa = s.count(\"WA\")\ntle = s.count(\"TLE\")\nre = s.count(\"RE\")\n\nprint(\"AC x\", ac)\nprint(\"WA x\", wa)\nprint(\"TLE x\", tle)\nprint(\"RE x\", re)", "N = int(input())\n\ndata = [input() for _ in range(N)]\n\ndef f(s):\n c = len([x for x in data if x in s])\n print(f\"{s} x {c}\")\n \nf(\"AC\")\nf(\"WA\")\nf(\"TLE\")\nf(\"RE\")\n", "n = int(input())\nAC = 0\nWA = 0\nTLE = 0\nRE = 0\nfor i in range(n):\n s = input()\n if(s == \"AC\"):\n AC += 1\n elif(s == \"WA\"):\n WA += 1\n elif(s == \"TLE\"):\n TLE += 1\n else:\n RE += 1\nprint(('AC x {}'.format(AC)))\nprint(('WA x {}'.format(WA)))\nprint(('TLE x {}'.format(TLE)))\nprint(('RE x {}'.format(RE)))\n", "N = int(input())\nC = 0\nD = 0\nE = 0\nF = 0\nS = ''\n\nfor i in range(N):\n S = input()\n if S == 'AC':\n C += 1\n elif S == 'WA':\n D += 1\n elif S == 'TLE':\n E += 1\n elif S == 'RE':\n F += 1\nprint('AC x '+ str(C), 'WA x ' + str(D), 'TLE x ' + str(E), 'RE x ' + str(F), sep='\\n')\n", "N=int(input())\nS=[]\nAC=0\nTLE=0\nWA=0\nRE=0\n\nfor i in range(0,N):\n\tS.append(input())\n\tif S[i]=='AC':\n\t\tAC+=1\n\telif S[i]=='TLE':\n\t\tTLE+=1\n\telif S[i]=='WA':\n\t\tWA+=1\n\telif S[i]=='RE':\n\t\tRE+=1\n\nprint('AC x %d'%AC)\nprint('WA x %d'%WA)\nprint('TLE x %d'%TLE)\nprint('RE x %d'%RE)", "N = int(input())\nS = []\nfor _ in range(N):\n S.append(input())\n\nAC = 0\nWA = 0\nTLE = 0\nRE = 0\n\nfor s in S:\n if(s == \"AC\"):\n AC += 1\n elif(s == \"WA\"):\n WA += 1\n elif(s == \"TLE\"):\n TLE += 1\n elif(s == \"RE\"):\n RE += 1\n\nprint(f\"AC x {AC}\")\nprint(f\"WA x {WA}\")\nprint(f\"TLE x {TLE}\")\nprint(f\"RE x {RE}\")\n", "n=int(input())\ns=[input() for i in range(n)]\nprint(\"AC x \"+str(s.count(\"AC\")))\nprint(\"WA x \"+str(s.count(\"WA\")))\nprint(\"TLE x \"+str(s.count(\"TLE\")))\nprint(\"RE x \"+str(s.count(\"RE\")))", "N = int(input())\nS = [input() for i in range(N)]\nA = 0\nW = 0\nT = 0 \nR = 0\n\nfor i in range(len(S)):\n if S[i] == 'AC':\n A += 1\n elif S[i] == 'WA':\n W += 1\n elif S[i] == 'TLE':\n T += 1\n else:\n R += 1\n\nprint('AC x ' + str(A))\nprint('WA x ' + str(W))\nprint('TLE x ' + str(T))\nprint('RE x ' + str(R))", "N = int(input())\njudge = {\"AC\":0, \"WA\":0, \"TLE\":0, \"RE\":0}\n \nfor _ in range(N):\n j_input = input()\n for j in judge.keys():\n if j_input == j:\n judge[j] += 1\n \nfor j in judge.keys():\n print(j , end = \" x \")\n print(judge[j])", "def main():\n N = int(input())\n result = {\"AC\": 0, \"WA\": 0, \"TLE\": 0, \"RE\":0}\n\n for i in range(N):\n result[input()] += 1\n\n print(( \"AC x \" + str(result[\"AC\"]) ))\n print((\"WA x \" + str(result[\"WA\"])))\n print((\"TLE x \" + str(result[\"TLE\"])))\n print((\"RE x \" + str(result[\"RE\"])))\n\nmain()\n", "# list\u3058\u3083\u306a\u304f\u3066dict\u4f7f\u3044\u305f\u3044\nn = int(input())\nj = [0] * 4\nmoji = [\"AC\", \"WA\", \"TLE\", \"RE\"]\nfor i in range(n):\n s=input()\n if s == \"AC\":\n j[0] += 1\n elif s==\"WA\":\n j[1] += 1\n elif s==\"TLE\":\n j[2] += 1\n elif s == \"RE\":\n j[3] += 1\nfor k in range(4):\n print(f\"{moji[k]} x {j[k]}\")\n", "N = int(input())\nac, wa, tle, re = 0, 0, 0, 0\nfor i in range(N):\n s = input()\n if s == \"AC\": ac += 1\n elif s == \"WA\": wa += 1\n elif s == \"TLE\": tle += 1\n else: re += 1\nprint(\"AC x {}\".format(ac))\nprint(\"WA x {}\".format(wa))\nprint(\"TLE x {}\".format(tle))\nprint(\"RE x {}\".format(re))", "def resolve():\n N = int(input())\n AC=0;WA=0;TLE=0;RE=0\n for i in range(N):\n S = input()\n if S==\"AC\":\n AC+=1\n elif S==\"WA\":\n WA+=1\n elif S==\"TLE\":\n TLE+=1\n elif S==\"RE\":\n RE+=1\n\n print(\"AC x \"+str(AC)) \n print(\"WA x \"+str(WA)) \n print(\"TLE x \"+str(TLE)) \n print(\"RE x \"+str(RE)) \n\nresolve()", "N = int(input().split()[0])\na = [0,0,0,0]\nfor i in range(N):\n b=input().split()[0]\n if(b == 'AC'):\n a[0]+=1\n elif(b == 'WA'):\n a[1]+=1\n elif(b == 'TLE'):\n a[2]+=1\n elif(b == 'RE'):\n a[3]+=1\nprint((\"AC x {0}\\nWA x {1}\\nTLE x {2}\\nRE x {3}\".format(a[0],a[1],a[2],a[3])))\n", "N = int(input())\nans_ac = 0\nans_wa = 0\nans_tle =0\nans_re =0\n\nfor i in range(N):\n S = input()\n if S == 'AC':\n ans_ac += 1\n elif S == 'WA':\n ans_wa += 1\n elif S == 'TLE':\n ans_tle += 1\n else:\n ans_re += 1\n\nprint('AC','x',ans_ac)\nprint('WA','x',ans_wa)\nprint('TLE','x',ans_tle)\nprint('RE','x',ans_re)"] | {"inputs": ["6\nAC\nTLE\nAC\nAC\nWA\nTLE\n", "10\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\nAC\n"], "outputs": ["AC x 3\nWA x 1\nTLE x 2\nRE x 0\n", "AC x 10\nWA x 0\nTLE x 0\nRE x 0\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 29,169 | |
d76b04a30f01de751c231666ff26f14b | UNKNOWN | How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?
-----Constraints-----
- 1β€Mβ€23
- M is an integer.
-----Input-----
Input is given from Standard Input in the following format:
M
-----Output-----
If we have x hours until New Year at M o'clock on 30th, December, print x.
-----Sample Input-----
21
-----Sample Output-----
27
We have 27 hours until New Year at 21 o'clock on 30th, December. | ["time=int(input())\nAns=48-time\nprint(Ans)", "#\u300012\u670830\u65e5\u306eM\u6642\u304b\u3089\u6b21\u306e\u5e74\u306b\u306a\u308b\u307e\u3067\u306f\u4f55\u6642\u9593\u304b\u3001\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\nM = int(input())\nprint(48 - M) #30\u65e531\u65e5\u306e\u5408\u8a0848\u6642\u9593\u304b\u3089\u73fe\u5728\u306e\u6642\u523b\u3092\u5f15\u304f\u3068\u3001\u6b8b\u308a\u6642\u9593\u304c\u51fa\u305b\u308b\u3002", "print(48-int(input()))", "m=int(input())\nprint(48-m)", "# 12\u6708 30\u65e5\u306e M\u6642\u304b\u3089\u6b21\u306e\u5e74\u306b\u306a\u308b\u307e\u3067\u304c x\u6642\u9593\u306e\u3068\u304d\u3001x\u3092\u51fa\u529b\nM = int(input())\n\nprint(24 + (24 - M))", "# 084a\n\nM = int(input())\n\nprint((24 + (24 - M)))\n", "print(48-int(input()))", "N = int(input())\nprint((48 - N))\n", "n = int(input())\nprint(48 - n)", "# 12\u670830\u65e5\u306e M \u6642\u304b\u3089\u6b21\u306e\u5e74\u306b\u306a\u308b\u307e\u3067\u306f\u4f55\u6642\u9593\u304b\u3001\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# 1 \u2266 M \u2266 23\n# \u5165\u529b\u306f\u5168\u3066\u6574\u6570\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 M\u306e\u5024\u3092\u53d6\u5f97\u3057\u3001\u51fa\u529b\u3059\u308b\nm = int(input())\n\n# \u6b8b\u308a\u4f55\u6642\u9593\u304b\u8a08\u7b97\u3057\u3001\u51fa\u529b\u3059\u308b\nresult = 48 - m\nprint(result)\n", "t = int(input())\nprint(24 + (24 - t))", "M = int(input())\n\nanswer = 48 - M\nprint(answer)", "m = int(input())\nprint(48-m)", "# \u5165\u529b\nM = int(input())\n\n# \u51e6\u7406\nx = 48 - M\n\n# \u51fa\u529b\nprint(x)", "# A - New Year\n\n# 12/30\u306eM\u6642\u304b\u3089\u6b21\u306e\u5e74\u306b\u306a\u308b\u306e\u306f\u4f55\u6642\u9593\u5f8c\u304b\u51fa\u529b\u3059\u308b\n\n\nM = int(input())\n\nprint(((24 - M) + 24))\n", "m = int(input())\n\nprint(48 - m)", "N = int(input())\nprint((24 - N + 24))\n", "n = int(input())\nr = 24 - n\nprint((24+r))\n", "M = int(input())\n\nprint(48-M)", "M = int(input())\n\nprint(24 + ( 24 - M))", "print(48 - int(input()))", "M = int(input())\n\nanswer = 48 - M\n\nprint(answer)", "m = int(input())\nhours = 24\nprint(24-m+24)", "print(48-int(input()))", "from datetime import datetime, date\n\ndt = datetime(date.today().year, 12, 30, int(input()), 0, 0)\ntd = abs(dt - datetime(dt.year + 1, 1, 1))\nanswer = int(td.total_seconds() / (60 * 60))\nprint(answer)", "M = int(input())\n\n# 31\u65e5\u5206\u306f+24\u300130\u65e5\u5206\u306f24-M\nprint((48 - M))\n", "m=int(input())\nprint(48-m)", "M=int(input())\nprint(48-M)", "a=int(input())\nprint(48-a)", "M = int(input())\n\nprint(48 - M)", "print(48-int(input()))", "a=int(input())\nprint((24+(24-a)))\n", "print((48-int(input())))\n", "m = int(input())\nprint((24 - m + 24))\n", "print(48-int(input()))", "m = int(input())\nprint(48 - m)", "n=int(input())\n\nprint(48-n)", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nm = int(input())\n\nprint((24-m+24))\n", "# \u6307\u5b9a\u6642\u523b\u306e\u53d6\u5f97\nM = int(input())\n \n# 12/30\u306e\u6b8b\u308a\u6642\u9593\u306812/31\u306e24\u6642\u9593\u3092\u52a0\u7b97\u3057\u7d50\u679c\u3092\u51fa\u529b\ntotal = (24 - M) + 24\nprint(total)", "print(48-int(input()))", "m = int(input())\n\nans = 24-m + 24\n\nprint(ans)", "h = int(input())\nprint(48-h)", "print((48-int(input())))\n", "M = int(input())\n\nprint( 24 +(24 - M))", "M = int(input())\n\nx = 24 - M\nprint(x + 24)", "# AtCoder abc084 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\nm = int(input())\n\n# \u51e6\u7406(m + x = 48)\nx = 48 - m\n\n# \u51fa\u529b\nprint(x)\n", "# M\u6642\u306e\u6642\u9593\u3092\u6574\u6570\u3067\u5165\u529b\nM = int(input())\n# 12\u670830\u65e5\u306eM\u6642\u304b\u30891\u67081\u65e50\u6642\u307e\u3067\u306e\u6642\u9593\u3092\u51fa\u529b\nprint(48 - M)", "M=int(input())\n\nx=24+(24-M)\n\nprint(x)", "# \u5165\u529b\nM = int(input())\n\n# 48\u6642\u9593\u304b\u308912\u670830\u65e5\u306eM\u6642\u3092\u3072\u304f\ntime_remaining = 48 - M\n\n# \u51fa\u529b\nprint(time_remaining)", "print(48 - int(input()))", "M = int(input())\nprint(48-M)", "M=int(input())\nprint(48-M)", "n=int(input())\nprint(48-n)", "M = int(input())\nprint(48 - M)", "print(48-int(input()))", "m=int(input())\nprint(24+24-m)", "M = int(input())\nprint(48 -M)", "M = int(input())\n\nx = 24 + (24 - M)\nprint(x)", "# A - New Year\n# https://atcoder.jp/contests/abc084/tasks/abc084_a\n\nM = int(input())\n\nprint((48 - M))\n", "a = int(input())\nprint(48-a)", "print(48 - int(input()))", "# \u5165\u529b\nM = int(input())\n\n# \u51fa\u529b\nif 1 <= M <=23:\n print(48 - M)", "m = int(input())\n\nprint((24 - m + 24))\n", "def main():\n time=input()\n remaining_hour = 48 - int(time)\n \n print(remaining_hour)\n\ndef __starting_point():\n main()\n__starting_point()", "a = int(input())\na = 48 - a\nprint(a)", "M = int(input())\nprint(48-M)", "m = int(input())\nprint(48-m)", "M = int(input())\nprint(48-M)", "n = int(input())\nprint(48-n)", "m = int(input())\nprint(48-m)", "M=int(input())\n\nprint((24-M)+24)", "print(48 - int(input()))", "m = int(input())\n\nx = 48 - m\n\nprint(x)", "print(48-int(input()))", "n=int(input())\nprint(48-n)", "print(48-int(input()))", "print(48-int(input()))", "print(48-int(input()))", "m=int(input())\nprint(48-m)", "n=int(input())\nprint(48-n)", "m = int(input())\nprint((48 - m))\n", "print(24-int(input()) + 24)", "S = int(input())\n\nday = 24 + (24 - S)\nprint (day)", "m=int(input())\nprint(24+(24-m))", "# 084_a\nM=int(input())\nif 1<=M and M<=23:\n result=48-M\n if result>=0:\n print(result)", "print(48-int(input()))", "def main():\n m = int(input())\n print(48 - m)\n\n\nmain()", "print(48-int(input()))", "a=int(input())\nprint(24+(24-a))", "# 12\u670830\u65e5\u306eM\u6642\u304b\u3089\u6b21\u306e\u5e74\u306b\u306a\u308b\u307e\u3067\u306f\u4f55\u6642\u9593\u304b\u3082\u3068\u3081\u308b\n\nM = int(input())\n\nM = (24 - M) + 24\nprint(M)", "n = int(input())\n\nprint(24 - n + 24)", "a = input()\nb = 24 - int(a)\nc = 24 + b \nprint(c)", "x = int(input())\nprint(48-x)", "a=int(input())\nprint(48-a)", "m = int(input())\n\nprint(24+24-m)", "m = int(input())\nprint(48-m)", "m = int(input())\nprint(24+(24-m))", "M = int(input())\n\nprint(48 - M)", "print(48-int(input()))", "n = int(input())\nprint(48-n)"] | {"inputs": ["21\n", "12\n"], "outputs": ["27\n", "36\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 6,319 | |
32b2859be298b312326531d86d356cc1 | UNKNOWN | You are given two integers A and B as the input. Output the value of A + B.
However, if A + B is 10 or greater, output error instead.
-----Constraints-----
- A and B are integers.
- 1 β€ A, B β€ 9
-----Input-----
Input is given from Standard Input in the following format:
A B
-----Output-----
If A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.
-----Sample Input-----
6 3
-----Sample Output-----
9
| ["# A - Restricted\n# https://atcoder.jp/contests/abc063/tasks/abc063_a\n\nA, B = list(map(int, input().split()))\n\nresult = A + B\nif result >= 10:\n print('error')\nelse:\n print(result)\n", "l = input().split()\n\nans = int(l[0]) + int(l[1])\n\nif 10 <= ans:\n print('error')\nelse:\n print(ans)", "a, b = map(int, input().split())\nif a+b >= 10:\n print(\"error\")\nelse:\n print(a+b)", "a,b=map(int,input().split())\nif (a+b)<=9:\n print(a+b)\nelse:\n print(\"error\")", "a,b = map(int,input().split())\nprint(a+b if a+b < 10 else 'error')", "def iroha():\n a, b = list(map(int, input().split()))\n \n ans = a+b\n\n print((ans if ans < 10 else \"error\"))\n\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "a, b= map(int, input().split())\n\nif a+b<10:\n print(a+b)\nelse:\n print('error')", "# 063a\n\nA, B = list(map(int, input().split()))\n\nif A + B >= 10:\n print('error')\nelse:\n print((A + B))\n", "A, B = map(int, input().split())\nif A + B < 10:\n print(A + B)\nelse:\n print('error')", "a,b=map(int,input().split())\nif a+b>=10:\n print(\"error\")\nelse:\n print(a+b)", "a, b=map(int, input().split())\nif a+b<10:\n print(a+b)\nelse:\n print(\"error\")", "a, b = map(int, input().split())\n\nresult = a + b\nif result >= 10:\n print('error')\nelse:\n print(result)", "a, b = map(int, input().split())\nanswer = a + b\nprint('error' if 10 <= answer else answer)", "A, B = map(int, input().split())\n\nif A + B >= 10:\n print('error')\nelse:\n print(A + B)", "# \u4e8c\u3064\u306e\u6574\u6570A,B\u306e\u548c 10\u4ee5\u4e0a\u306a\u3089error\u3068\u51fa\u529b\n\nA, B = map(int, input().split())\n\nif A + B < 10:\n print(A + B)\nelse:\n print('error')", "A, B = map(int,input().split())\n\nif A + B >= 10:\n print( \"error\" )\nelse:\n print( A + B )", "a,b = map(int,input().split())\nprint(a + b if a + b < 10 else \"error\")", "a,b = map(int,input().split())\n\nprint('error' if a+b >= 10 else a+b)", "a,b= map(int,input().split())\nif a+b >= 10:\n print(\"error\")\nelse:\n print(a+b)", "A,B=list(map(int,input().split()));print((A+B if A+B<10 else \"error\"))\n", "a, b = map(int, input().split())\nans = a + b\nif ans >= 10: print('error')\nelse: print(ans)", "a, b=map(int, input().split())\nif a+b<10:\n print(a+b)\nelse:\n print('error')", "# \u5165\u529b \nA, B = map(int, input().split()) \n \n# \u51fa\u529b \nsum = A + B \n \nif sum >= 10: \n print('error') \nelse: \n print(sum) ", "a, b = list(map(int, input().split()))\nif a + b >= 10:\n print(\"error\")\nelse:\n print((a + b))\n", "a,b = map(int,input().split())\nif a+b >= 10:\n print(\"error\")\nelse:\n print(a+b)", "A, B = map(int,input().split())\n\nif A + B >= 10:\n print(\"error\")\nelse:\n print(A + B)", "# \u5165\u529b\nA, B = map(int, input().split())\n\n# A+B\u304c10\u4ee5\u4e0a\u306a\u3089error\u3001\u305d\u308c\u4ee5\u5916\u306a\u3089\u7d50\u679c\u3092\u51fa\u529b\nif A + B >= 10:\n print('error')\nelse:\n print(A + B)", "a,b = map(int,input().split())\nif a + b < 10:\n print(a + b)\nelse:\n print('error')", "S_list = list(map(int,input().split()))\n\nadd = S_list[0] + S_list[1]\nif add >= 10:\n result = \"error\"\nelse:\n result = add \nprint(result)\n", "a,b=map(int,input().split())\nprint(a+b if a+b < 10 else \"error\")", "#!/usr/bin/env python3\n\ndef main():\n a, b = list(map(int, input().split()))\n print((a + b if a + b < 10 else 'error'))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "A,B = map(int,input().split())\n\nif A + B >= 10:\n print('error')\nelse:\n print(A + B)", "a,b = map(int, input().split())\n\nif a + b >= 10:\n print(\"error\")\nelse:\n print(a + b)", "# 063_a\nA,B=map(int,input().split())\nif 1<=A and B<=9:\n if A+B>=10:\n print('error')\n else:\n print(A+B)", "A, B = list(map(int,input().split()))\nif A+B < 10:\n print(A+B)\nelse:\n print('error')", "A,B = map(int,input().split())\nprint(A+B if A+B < 10 else \"error\")", "A,B=map(int,input().split())\nif A+B>=10 :\n print(\"error\")\nelse :\n print(A+B)", "A, B = list(map(int, input().split()))\n\nif A + B < 10:\n print((A + B))\nelse:\n print('error')\n", "a, b = map(int, input().split())\nx = a + b\nif x < 10:\n print(x)\nelse:\n print('error')", "import sys\n\ninput = sys.stdin.readline\n\na, b= list(map(int, input().split()))\n\nab = a+b\nif ab >= 10:\n print(\"error\")\nelse:\n print(ab)\n", "a, b = map(int, input().split())\n\nif a+b >= 10:\n print(\"error\")\nelse:\n print(a+b)", "a,b=map(int,input().split())\nprint(a+b if a+b <10 else \"error\")", "a,b = map(int,input().split())\nif a + b >= 10:\n print('error')\nelse:\n print(a+b)", "a,b = map(int,input().split())\nif a + b >= 10:\n print('error')\nelse:\n print(a+b)", "# AtCoder abc063 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\na, b = list(map(int, input().split()))\n\n# \u51e6\u7406\nif (a + b) >= 10:\n print(\"error\")\nelse:\n print((a + b))\n", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\nINF = float('inf')\nMOD = 10**9 + 7\n#MOD = 998244353\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lintdec(): return list(map(lambda x:int(x) - 1, input().split()))\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nA, B = lint()\nprint(A + B if A + B < 10 else 'error')", "a,b=map(int, input().split()) \nprint(\"error\" if a+b>=10 else a+b)", "a,b = [int(x) for x in input().split()]\nif a + b >= 10:\n print(\"error\")\nelse:\n print(a+b)", "x=sum(map(int,input().split()))\nif x>=10:\n print(\"error\")\nelse:\n print(x)\n", "A, B = map(int, input().split())\n\nif A + B < 10:\n print(A + B)\nelse:\n print('error')", "A, B = map(int, input().split())\n\nif A+B >= 10:\n print(\"error\")\nelse:\n print(A+B)", "a, b = map(int, input().split())\nprint(\"error\" if a + b >= 10 else a + b)", "A, B = map(int, input().split())\n\nprint(A + B if A + B < 10 else \"error\")", "n, k = map(int, input().split())\nif n + k < 10:\n print(n + k)\nelse:\n print(\"error\")", "x,y=list(map(int,input().split()))\nif x+y<10:\n print((x+y))\nelse:\n print('error')\n", "A,B = map(int,input().split())\na = A+B\nif a<10:\n print(a)\nelse:\n print(\"error\")", "A, B = map(int, input().split())\nif A+B>=10:\n print(\"error\")\nelse:\n print(A+B)", "# \u4e8c\u3064\u306e\u6574\u6570 A, B\u304c\u5165\u529b\u3055\u308c\u307e\u3059\u3002\n# A + B \u306e\u5024\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n# \u305f\u3060\u3057\u3001\n# A + B \u304c 10 \u4ee5\u4e0a\u306e\u5834\u5408\u306f\u3001\n# \u4ee3\u308f\u308a\u306b error \u3068\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# A, B \u306f\u6574\u6570\u3067\u3042\u308b\u3002\n# 1 \u2266 A, B \u2266 9\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 A, B \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\na, b = list(map(int, input().split()))\n\n# \u8a08\u7b97\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\nresult = \"error\"\n\nif a + b < 10:\n result = a + b\n\nprint(result)\n", "a, b = map(int, input().split())\nprint(a+b if a+b < 10 else \"error\")", "int_1, int_2 = map(int, input().split())\nanswer = int_1 + int_2\n\nif 10 <= answer:\n print('error')\nelse:\n print(answer)", "a,b = list(map(int,input().split()))\n\nprint((a+b if a+b < 10 else 'error'))\n", "a,b = list(map(int,input().split()))\nprint((\"error\" if a+b>=10 else a+b))\n", "a, b = map(int,input().split())\nprint('error') if a + b >= 10 else print(a+b)", "C=sum(map(int,input().split()))\nif C>=10:\n print(\"error\")\nelse:\n print(C)", "a,b=map(int,input().split())\nif a+b>=10:\n print(\"error\")\nelse:\n print(a+b)", "a,b = map(int,input().split())\nif 10<=a+b:\n print('error')\nelse:\n print(a+b)", "a,b = map(int,input().split())\nprint(a+b if a+b < 10 else \"error\")", "a, b = map(int, input().split())\n\nprint('error' if a + b >= 10 else a + b)", "a, b = map(int, input().split())\n\nif a + b >= 10:\n print('error')\nelse:\n print(a + b)", "a, b = map(int, input().split())\n\nif a + b >= 10:\n print('error')\nelse:\n print(a + b)", "A, B = map(int, input().split())\nC = A + B\nprint(C if C < 10 else \"error\")", "LI = lambda: list(map(int, input().split()))\n\nA, B = LI()\n\n\ndef main():\n ans = A + B;\n if ans >= 10:\n ans = \"error\"\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "A, B = map(int, input().split())\nprint(A+B if A+B < 10 else 'error')", "# s=int(input())\n# b=input()\n# c=[]\n# for i in range(b):\n# c.append(a[i])\na = list(map(int,input().split()))\n#b = list(map(int,input().split()))\n\nif (a[0]+a[1])<10:\n print(a[0]+a[1])\nelse:\n print(\"error\")", "'''\nabc063 A - Restricted\nhttps://atcoder.jp/contests/abc063/tasks/abc063_a\n'''\n\na, b = list(map(int, input().split()))\nans = a+b if a+b < 10 else 'error'\nprint(ans)\n", "A,B=list(map(int,input().split()))\nif A+B>=10:\n print(\"error\")\nelse:\n print((A+B))\n", "a,b=map(int, input().split())\n\nprint(a+b if a+b<10 else 'error')", "a, b = map(int, input().split())\nprint(a+b if a+b<10 else 'error')", "# A - Restricted\n\n# A+B\u306e\u5024\u3092\u51fa\u529b\u3059\u308b\n# A+B\u304c10\u4ee5\u4e0a\u306e\u5834\u5408\u306ferror\u3068\u51fa\u529b\u3059\u308b\n\n\nA,B = list(map(int,input().split()))\n\nanswer = A + B\n\nif answer < 10:\n print(answer)\nelse:\n print('error')\n", "# \u5404\u6570\u5024\u306e\u53d6\u5f97\nA,B = map(int,input().split())\n\n# \u5408\u8a08\u304c10\u4ee5\u4e0a\u304b\u5224\u5b9a\u5f8c\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\ntotal = A + B\nif total < 10 :\n print(total)\nelse:\n print(\"error\")", "a,b=map(int,input().split())\n\nif a+b>=10:\n print('error')\n \nelse:\n print(a+b)", "a,b=map(int,input().split())\nif a+b>9:\n print('error')\nelse:\n print(a+b)", "# \u5165\u529b\nA, B =map(int,input().split())\n\n# \u51e6\u7406\nanswer = A + B\nif answer < 10:\n print(answer)\nelse:\n print('error')", "A, B = map(int, input().split())\nprint(A+B if A+B < 10 else 'error')", "a,b = map(int,input().split())\nprint(a+b if a+b < 10 else \"error\")", "#n = int(input())\na, b = list(map(int, input().split()))\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\nans = a+b\nif a+b >= 10:\n ans = 'error'\nprint(ans)\n", "a,b=map(int,input().split())\nif a+b>=10:\n print(\"error\")\nelse:\n print(a+b)", "a, b = map(int, input().split())\n\nif a + b >= 10:\n print('error')\nelse:\n print(a + b)", "# \u4e8c\u3064\u306e\u6574\u6570 A , B \u304c\u5165\u529b\u3055\u308c\u307e\u3059\u3002 A + B \u306e\u5024\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n# \u305f\u3060\u3057\u3001 A + B \u304c 10 \u4ee5\u4e0a\u306e\u5834\u5408\u306f\u3001\u4ee3\u308f\u308a\u306b error \u3068\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\nA,B = map(int,input().split())\n\nif A + B <= 9:\n print(A + B)\n\nelse:\n print('error')", "a,b=map(int,input().split())\nif a+b<10:print(a+b)\nelse:print('error')", "A, B = map(int, input().split())\n \nif A + B < 10: print(A+B)\nelse: print('error')", "# coding = SJIS\n\na, b = map(int, input().split())\n\nif a + b >= 10:\n print(\"error\")\nelse:\n print(a + b)", "a,b = map(int,input().split())\n#lis = list(map(int,input().split()))\nprint(\"error\" if a+b >= 10 else a+b)", "a,b=map(int,input().split())\nif a+b>=10:\n print(\"error\")\nelse:\n print(a+b)", "a, b = map(int, input().split())\ns = a + b\nif s >= 10: print('error')\nelse: print(s)", "a,b=list(map(int,input().split()))\nif (a+b)<10:\n print((a+b))\nelse:\n print(\"error\")\n\n", "A, B = map(int, input().split())\n\nx = A + B\n\nif x >= 10:\n print(\"error\")\nelse:\n print(x)", "a, b = list(map(int, input().split()))\n\nif 10 <= a + b:\n print(\"error\")\nelse:\n print((a + b))\n"] | {"inputs": ["6 3\n", "6 4\n"], "outputs": ["9\n", "error\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 12,770 | |
407b8d9597fbfcb4a079f8163a07bddf | UNKNOWN | It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.
There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.
Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.
-----Constraints-----
- 1 β€ N β€ 100
- 0 β€ a_i β€ 1000
- a_i is an integer.
-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
-----Output-----
Print the minimum distance to be traveled.
-----Sample Input-----
4
2 3 7 9
-----Sample Output-----
7
The travel distance of 7 can be achieved by starting at coordinate 9 and traveling straight to coordinate 2.
It is not possible to do with a travel distance of less than 7, and thus 7 is the minimum distance to be traveled. | ["N=int(input())\nA=list(map(int, input().split()))\n\nprint(max(A)-min(A))", "n = int(input())\nli = list(map(int,input().split()))\nli.sort()\nprint(li[-1]-li[0])", "N = int(input())\na = list(map(int, input().split()))\nprint(max(a)-min(a))", "N = int(input())\nlist = sorted(map(int,input().split()))\n\nprint(list[N-1] - list[0])", "N = int(input())\na = list(map(int,input().split()))\nprint(max(a)-min(a))", "N = int(input())\nN_List = list(map(int,input().split()))\nprint(max(N_List)-min(N_List))", "N=input()\na=list(map(int,input().split()))\na.sort()\nprint(a[-1]-a[0])", "N=int(input())\na=list(map(int, input().split()))\nprint(max(a)-min(a))", "n = int(input())\na = list(map(int, input().split()))\nprint(max(a) - min(a))", "N = int(input())\npoints = list(map(int, input().split()))\n\nresult = max(points) - min(points)\nprint(result)", "N = int(input())\nA = list(map(int, input().split()))\nans = max(A) - min(A)\nprint(ans)", "N = int(input())\na = sorted(set(list(map(int, input().split()))))\nprint((a[-1]- a[0]))\n\n\n\n", "# B - Traveling AtCoDeer Problem\ndef main():\n _ = int(input())\n a = list(map(int, input().split()))\n\n print(max(a)-min(a))\n\n\n\nif __name__ == \"__main__\":\n main()", "N=int(input())\na=list(map(int,input().split()))\nprint(max(a)-min(a))", "input()\na = list(map(int,input().split()))\na.sort()\nprint(a[-1]-a[0])", "N = input()\nx = list(map(int,input().split()))\n\nprint(max(x) - min(x))", "#https://atcoder.jp/contests/abc064/tasks/abc064_b\nS_list = [input() for i in range(2)]\nN = map(int,S_list[0].split()) \nA_list = list(map(int,S_list[1].split()))\n\nprint(max(A_list)-min(A_list))", "n=input()\na=[int(i) for i in input().split()]\nprint(max(a)-min(a))", "N = int(input())\na = list(map(int,input().split()))\na.sort()\n\ndistance = 0\n\nfor i in range(N - 1):\n distance += a[i + 1] - a[i]\n\nprint(distance)", "n = int(input())\na = list(map(int, input().split()))\n\nprint(max(a) - min(a))", "n=int(input())\na=list(map(int,input().split()))\na.sort()\nprint(a[n-1]-a[0])", "N=int(input())\na=str(input())\n\ndef ans064(N:int, a:str):\n a_list=sorted(map(int,a.split()))\n return(a_list[-1]-a_list[0])\n\nprint(ans064(N,a))", "n = input()\ndata = list(map(int,input().split()))\ndata.sort(reverse = True)\nans = 0\nfor i in range(len(data) - 1):\n ans += data[i] - data[i + 1]\nprint(ans)", "n = input()\nlist01 = input().split()\nlist02 = [int(a) for a in list01]\n\nprint(max(list02) - min(list02))", "N=int(input())\na=list(map(int,input().split()))\nprint((max(a)-min(a)))\n", "N = map(int, input().split())\npoint = list(map(int,input().split()))\n\nmax = 0\nmin = 1000\n\nfor i in range(len(point)):\n if max < point[i]:\n max = point[i]\n if min > point[i]:\n min = point[i]\nprint(max - min)", "n = int(input())\nL = list(map(int,input().split()))\nL.sort()\nprint(L[n-1]-L[0])", "n = int(input())\narr = list(map(int, input().split()))\n\nprint(max(arr) - min(arr))", "def answer(n: int, a: []) -> int:\n return max(a) - min(a)\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n print(answer(n, a))\n\n\ndef __starting_point():\n main()\n__starting_point()", "# \u30af\u30ea\u30b9\u30de\u30b9\u3082\u3042\u3068\u534a\u5e74\u3068\u306a\u308a\u3001\u30c8\u30ca\u30ab\u30a4\u306eAtCoDeer\u541b\u306f\u30d7\u30ec\u30bc\u30f3\u30c8\u3092\u914d\u308b\u8a08\u753b\u3092\u7acb\u3066\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\n# TopCoDeer\u901a\u308a\u306b\u306fN\u500b\u306e\u5bb6\u304c\u4e26\u3093\u3067\u3044\u307e\u3059\u3002i\u500b\u76ee\u306e\u5bb6\u306f\u5ea7\u6a19ai\u306b\u3042\u308a\u307e\u3059\u3002\u5f7c\u306f\u3053\u306e\u3059\u3079\u3066\u306e\u5bb6\u306b\u30d7\u30ec\u30bc\u30f3\u30c8\u3092\u914d\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\n# \u597d\u304d\u306a\u5834\u6240\u304b\u3089\u958b\u59cb\u3057\u597d\u304d\u306a\u5834\u6240\u3067\u7d42\u4e86\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u6642\u3001\u6700\u5c0f\u306e\u79fb\u52d5\u8ddd\u96e2\u3092\u6c42\u3081\u306a\u3055\u3044\u3002\n\nN = int(input())\na = list(map(int,input().split()))\n\nprint(max(a) - min(a))", "N = int(input())\na = list(map(int, input().split()))\n\n# \u4e00\u756a\u96e2\u308c\u3066\u3044\u308b\u5ea7\u6a19\u306e\u5dee\nprint(max(a) - min(a))", "n = int(input())\nhouses = list(map(int, input().split()))\nprint(max(houses)-min(houses))", "N = int(input())\na = list(map(int, input().split()))\na.sort()\nprint(a[len(a)-1] - a[0])", "n = int(input())\ncoordinates = list(map(int, input().split()))\n\nprint((max(coordinates) - min((coordinates))))\n\n", "N = int(input())\na = list(map(int, input().split()))\n\nprint(max(a) - min(a))", "N = int(input())\na = list(map(int,input().split()))\n\ndistance = max(a)-min(a)\n\nprint(distance)", "n=int(input())\na=list(map(int,input().split()))\nprint(max(a)-min(a))", "\nn=input()\na=list(map(int, input().split()))\n\na1=max(a)\na2=min(a)\n\nprint((a1-a2))\n", "N=int(input())\nA=list(map(int,input().split()))\nans=max(A)-min(A)\nprint(ans)", "N = int(input())\nA = sorted(list(map(int,input().split())))\nprint(A[N-1]-A[0])", "n = int(input())\na = list(map(int, input().split()))\n\nprint(max(a) - min(a))", "with open(0) as f:\n N, *a = map(int, f.read().split())\nprint(max(a)-min(a))", "N = input()\na = list(map(int, input().split()))\n\nprint(max(a) - min(a))", "# 064b\n\ndef atc_064b(input_value: str) -> str:\n N = input_value[0]\n ai = [int(i) for i in input_value[1].split(\" \")]\n return max(ai) - min(ai)\n\nN = input()\nai = input()\nprint(atc_064b([N, ai]))", "N = int(input())\nS = map(int,input().split())\n\nNumber = list(S)\nNumber.sort(reverse=True)\ntotal_distance = []\n# print(Number)\n\nfor i in range(1,N):\n distance = Number[0] - Number[1]\n total_distance.append(distance)\n del Number[0]\n\nprint(sum(total_distance))", "def abc064b(n: int, a_list: int) -> int:\n return max(a_list) - min(a_list)\n\nn = int(input())\na_list = list(map(int, input().split()))\n\nprint((abc064b(n, a_list)))\n", "n = int(input())\na = list(map(int,input().split()))\n# \u30ea\u30b9\u30c8\u306e\u6700\u5927\u5024\u304b\u3089\u6700\u5c0f\u5024\u3092\u5f15\u3044\u3066\u51fa\u529b\nprint((max(a)-min(a)))\n", "def main():\n N = int(input())\n a = list(map(int,input().split()))\n a.sort()\n ans = 0\n #print(a)\n for i in range(1,N,1):\n ans += a[i] - a[i-1]\n\n return ans\n\nprint((main()))\n", "home_num = int(input())\nhouse_from = list(map(int,input().split()))\n\nprint(max(set(house_from)) - min(set(house_from)))", "N = int(input())\na = list(map(int,input().split()))\nprint(max(a)-min(a))", "N = int(input())\na = list(map(int, input().split()))\n\nprint(max(a) - min(a))", "# \u6570\u5024\u306e\u53d6\u5f97\nhomecnt = int(input())\nhomeplace = list(map(int,input().split()))\n\n# \u6700\u77ed\u8ddd\u96e2\u3092\u8a08\u7b97\u3057\u51fa\u529b\ndist = max(homeplace) - min(homeplace)\nprint(dist)", "n = int(input())\na = list(map(int, input().split()))\na.sort()\nprint((a[-1] - a[0]))\n", "def atc_064b(input_value: str) -> str:\n N = input_value[0]\n ai = [int(i) for i in input_value[1].split(\" \")]\n return max(ai) - min(ai)\n\nN = input()\nai = input()\nprint((atc_064b([N, ai])))\n", "n = int(input())\nx = list(map(int,input().split()))\nprint(max(x)-min(x))", "num_house = int(input())\na = list(map(int, input().split()))\nhouse_list = list(a)\n\nprint((max(house_list) - min(house_list)))\n", "n = int(input())\na = list(map(int, input().split()))\nprint(max(a)-min(a))", "N = int(input())\na = list(map(int,input().split()))\n\nprint(max(a)-min(a))", "N = int(input())\nA =list(map(int, input().split()))\n\nMAX = max(A)\nMIN = min(A)\n\nprint(MAX-MIN)", "n=input()\na=list(map(int, input().split()))\n\ndef answer(n:int, a:list)->int:\n return max(a)-min(a)\n\nprint(answer(n,a))", "total_house = int(input())\nhouse_coordinate = sorted(list(map(int, input().split())))\nprint(house_coordinate[total_house - 1]- house_coordinate[0])", "N = int(input())\nA = list(map(int,input().split()))\n\nA.sort()\n\nprint(A[-1] - A[0] if N > 1 else 0)", "n = int(input())\na = [int(x) for x in input().split()]\nprint(max(a) - min(a))", "#ABC064B\nn = int(input())\na = sorted(list(map(int,input().split())))\nans = 0 \nfor i in range(n-1):\n ans += a[i+1]-a[i]\nprint(ans)", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\nINF = float('inf')\nMOD = 10**9 + 7\n#MOD = 998244353\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lintdec(): return list(map(lambda x:int(x) - 1, input().split()))\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nN = ii()\nma = 0\nmi = INF\n\nfor a in lint():\n ma = max(ma, a)\n mi = min(mi, a)\n\nprint(ma - mi)", "n = int(input())\na = sorted(list(map(int, input().split())))\nprint(a[-1]-a[0])", "N=input()\nNi=list(map(int,input().split()))\n\nprint(max(Ni)-min(Ni))", "a = int(input())\nlis = list(map(int,input().split()))\nprint(max(lis)-min(lis))", "N = int(input())\nhouse = list(map(int, input().split()))\n\nprint(max(house) - min(house) )", "N = int(input())\na = list(map(int,input().split()))\n\nprint(max(a) - min(a))", "total_house = int(input())\nhouse_coordinate = sorted(list(map(int, input().split())))\nprint(house_coordinate[total_house - 1] - house_coordinate[0])", "N = int(input())\na = list(map(int, input().split()))\na.sort()\n\ndistance = 0\n\nfor i in range(N - 1):\n distance += a[i + 1] - a[i]\n\nprint(distance)", "# B - Traveling AtCoDeer Problem\n\n# N\nN = int(input())\nmy_list = list(map(int, input().split(maxsplit=N)))\n\nmy_list_sort = sorted(my_list)\nanswer = my_list_sort[-1] - my_list_sort[0]\n\nprint(answer)\n", "N = int(input())\nlst = input().split()\n\nfor i in range(N):\n lst[i] = int(lst[i])\n\nprint(max(lst) - min(lst))", "from sys import stdin\nrs = lambda : stdin.readline().strip()\nri = lambda : int(rs())\nril = lambda : list(map(int, rs().split()))\n\ndef main():\n N = ri()\n a = ril()\n print((max(a) - min(a)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int, input().split()))\nprint(max(a)-min(a))", "n = input()\na = list(map(int, input().split()))\nprint(max(a) - min(a))", "import sys\n\ninput = sys.stdin.readline\nN = int(input())\nA = list(map(int, input().split()))\nA.sort()\nprint(A[N-1] - A[0])", "N = int(input())\nhouse = list(map(int, input().split()))\n\n# \u30d7\u30ec\u30bc\u30f3\u30c8\u3092\u5c4a\u3051\u308b\u305f\u3081\u306e\u3001\u6700\u5927\u5024\u304b\u3089\u6700\u5c0f\u5024\u3092\u5f15\u3044\u3066\u3001\u6700\u5c0f\u306e\u79fb\u52d5\u8ddd\u96e2\u3092\u51fa\u529b\n\nprint(max(house)-min(house))", "# \u6700\u5c0f\u306e\u79fb\u52d5\u8ddd\u96e2\u306f\u3001\u4e00\u756a\u7aef\u304b\u3089\u53cd\u5bfe\u5074\u307e\u3067\u4e00\u76f4\u7dda\u306b\u79fb\u52d5\u3059\u308b\u4e8b\u3002\n# \u884c\u3063\u305f\u308a\u6765\u305f\u308a\u3059\u308b\u53ef\u80fd\u6027\u306f\u306a\u3044\nn = int(input())\na = list(map(int, input().split()))\n# \u5ea7\u6a19\u306f\u6b63\u306e\u6574\u6570\u306e\u307f\u306a\u306e\u3067max-min\u3067\u8a08\u7b97\u3067\u304d\u305d\u3046\u3002\n# print(mix-min)\nprint(max(a)-min(a))", "n = int(input())\na = list(map(int, input().split()))\nprint(max(a) - min(a))", "N = int(input())\na = list(map(int, input().split()))\na.sort()\nprint(a[-1]-a[0])", "n = int(input())\nstreet = sorted(list(map(int, input().split())))\nprint((street[-1]-street[0]))\n", "n = int(input())\na = [int(i) for i in input().split()]\n\nprint(max(a) - min(a))", "n = int(input())\na = [int(s) for s in input().split()]\n\nprint(max(a) - min(a))", "N = int(input())\na = list(map(int, input().split()))\n\nprint(max(a) - min(a))", "def minimum_dist(l1: list) -> int:\n return max(l1) - min(l1)\n\n\ndef __starting_point():\n n = int(input())\n list_coordinate = list(map(int, input().split()))\n print((minimum_dist(list_coordinate)))\n\n__starting_point()", "N = int(input())\na = sorted([int(x) for x in input().split()])\n\nprint(max(a) - min(a))", "N = int(input())\na = [ int(v) for v in input().split(\" \") ]\n\nmax_v = max(a)\nmin_v = min(a)\n\nprint((max_v - min_v))\n", "# list\u3092\u4e26\u3073\u66ff\u3048\u3066\u79fb\u52d5\u8ddd\u96e2\u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u308b\n\nN = int(input())\na = list(map(int, input().split()))\n\n# \u964d\u9806\u306b\u4e26\u3073\u66ff\u3048\u308b\ndescending_a = sorted(a, reverse=True)\n# print(descending_a)\n\n# \u5ea7\u6a19\u306e\u6700\u5927\u5024\u304b\u3089\u6700\u5c0f\u5024\u3092\u5f15\u304f\u2192\u79fb\u52d5\u8ddd\u96e2\u3092\u6c42\u3081\u308b\nprint((descending_a[0] - descending_a[-1]))\n", "input()\na = list(map(int,input().split()))\nprint(max(a)-min(a))", "n = int(input())\nli = list(map(int, input().split()))\nprint(max(li)-min(li))", "n,*a=map(int,open(0).read().split())\na.sort()\nprint(a[-1]-a[0])", "N = input()\na = list(map(int, input().split()))\nprint(max(a)-min(a))", "N = int(input())\nA = list(map(int, input().split()))\nx = max(A)\ny = min(A)\nprint(x - y)", "n = int(input())\nA = list(map(int, input().split()))\n\nprint(max(A)-min(A))", "n = int(input())\na = list(map(int, input().split()))\na.sort()\nans = a[-1] - a[0]\nprint(ans)", "N = int(input())\nhome = list(map(int,input().split()))\n\nprint((max(home))-(min(home)))", "N = int(input())\na = list(map(int, input().split()))\na.sort()\nprint(a[N - 1] - a[0])"] | {"inputs": ["4\n2 3 7 9\n", "8\n3 1 4 1 5 9 2 6\n"], "outputs": ["7\n", "8\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 13,837 | |
5bc1217e35f47c6d6d25513f5f9d66bf | UNKNOWN | Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.
Given two integers x and y (1 β€ x < y β€ 12), determine whether they belong to the same group.
-----Constraints-----
- x and y are integers.
- 1 β€ x < y β€ 12
-----Input-----
Input is given from Standard Input in the following format:
x y
-----Output-----
If x and y belong to the same group, print Yes; otherwise, print No.
-----Sample Input-----
1 3
-----Sample Output-----
Yes
| ["n1 = [1, 3, 5, 7, 8, 10, 12]\nn2 = [4, 6, 9, 11]\n\na, b = list(map(int, input().split()))\nprint((\"Yes\" if a in n1 and b in n1 or a in n2 and b in n2 else \"No\"))\n", "lst1 = [4,6,9,11]\nlst2 = [2]\nlst3 = [1,3,5,7,8,10,12]\nx,y = map(int,input().split())\nif x in lst1 and y in lst1:\n print('Yes')\nelif x in lst2 and y in lst2:\n print('Yes')\nelif x in lst3 and y in lst3:\n print('Yes')\nelse:\n print('No')", "x,y=map(int,input().split())\nA=[2]\nB=[4,6,9,11]\nC=[1,3,5,7,8,10,12]\nif x in B and y in B:\n print(\"Yes\")\nelif x in C and y in C:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c=[1,3,5,7,8,10,12],[4,6,9,11],[2]\nprint('YNeos'[len(set([0 if i in a else [1,2][i in b] for i in list(map(int,input().split()))]))!=1::2])", "X,Y=map(int,input().split())\nA=1,3,5,7,8,10,12\nB=4,6,9,11\nC=2\nans=\"No\"\nif X in A and Y in A:\n ans=\"Yes\"\nelif X in B and Y in B:\n ans=\"Yes\"\nelif X==Y==2:\n ans=\"Yes\"\nprint(ans)", "x,y=map(int,input().split())\ngrp1=[1,3,5,7,8,10,12]\ngrp2=[4,6,9,11]\n\nif x in grp1 and y in grp1: print(\"Yes\")\nelif x in grp2 and y in grp2: print(\"Yes\")\nelse: print(\"No\")", "a = map(int, input().split())\ninput_list = list(a)\n\ngroup_a = [1, 3, 5, 7, 8, 10, 12]\ngroup_b = [4, 6, 9, 11]\ngroup_c = [2]\nlist_of_list = [group_a, group_b, group_c]\n\ncount_match = 0\n\nfor list_i in list_of_list:\n if input_list[0] in list_i and input_list[1] in list_i:\n count_match += 1\n break\n\nif count_match == 1:\n print('Yes')\nelse:\n print('No')", "data_1 =[1,3,5,7,8,10,12]\ndata_2 =[4,6,9,11]\nx,y = map(int,input().split())\nif x in data_1 and y in data_1:\n print('Yes')\nelif x in data_2 and y in data_2:\n print('Yes')\nelse:\n print('No')", "#!/usr/bin/env python3\nx, y = list(map(int, input().split()))\n\na = [1, 3, 5, 7, 8, 10, 12]\nb = [4, 6, 9, 11]\nc = [2]\n\nif x in a and y in a:\n print('Yes')\nelif x in b and y in b:\n print('Yes')\nelif x in c and y in c:\n print('Yes')\nelse:\n print('No')\n", "a,b = map(int,input().split())\n\nx = [1,3,5,7,8,10,12]\ny = [4,6,9,11]\n\nif a in x and b in x or a in y and b in y:\n print('Yes')\n \nelse:\n print('No')", "x,y=map(int,input().split())\ns1 = [1,3,5,7,8,10,12]\ns2 = [4,6,9,11]\ns3 = [2]\nif x in s1 and y in s1:\n print('Yes')\nelif x in s2 and y in s2:\n print('Yes')\nelif x in s3 and y in s3:\n print('Yes')\nelse:\n print('No')", "x,y = map(int, input().split())\na = [1,3,5,7,8,10,12]\nb = [4,6,9,11]\nc = [2]\nif (x in a and y in a) or (x in b and y in b) or (x in c and y in c):\n print('Yes')\nelse:\n print('No')", "x, y = map(int, input().split())\n\nA = [1, 3, 5, 7, 8, 10, 12]\nB = [4, 6, 9, 11]\nC = [2, ]\n\nif x in A and y in A:\n print('Yes')\nelif x in B and y in B:\n print('Yes')\nelse:\n print('No')", "x,y=map(int,input().split())\n\nn=[0,1,3,1,2,1,2,1,1,2,1,2,1]\n\nif n[x]==n[y]:\n ans=\"Yes\"\nelse:\n ans=\"No\"\n \nprint(ans)", "A=[1,3,5,7,8,10,12]\nB=[4,6,9,11]\nC=[2]\nx,y = map(int,input().split())\nif x in A and y in A:\n print('Yes') \nelif x in B and y in B:\n print('Yes')\nelse:\n print('No') ", "x, y = map(int,input().split())\nS1 = [1, 3, 5, 7, 8, 10, 12]\nS2 = [4, 6, 9, 11]\nans = False\nfor i in range(len(S1)):\n for j in range(len(S1)):\n if S1[i] == x and S1[j] == y:\n ans = True\nfor i in range(len(S2)):\n for j in range(len(S2)):\n if S2[i] == x and S2[j] == y:\n ans = True\nif ans:\n print(\"Yes\")\nelse:\n print(\"No\")", "c = [['1', '3', '5', '7', '8', '10', '12'], ['4', '6', '9', '11'], ['2']]\n\na, b = input().split(' ')\n\nif a in c[0] and b in c[0]:\n print(\"Yes\")\nelif a in c[1] and b in c[1]:\n print(\"Yes\")\nelif a in c[2] and b in c[2]:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "x, y = map(int, input().split())\ngroup1 = [1, 3, 5, 7, 8, 10, 12]\ngroup2 = [4, 6, 9, 11]\n\nflag = False\nif x in group1 and y in group1:\n flag = True\nelif x in group2 and y in group2:\n flag = True\n \nif flag:\n print('Yes')\nelse:\n print('No')", "x, y = list(map(int, input().split()))\na = [1, 3, 5, 7, 8, 10, 12]\nb = [4, 6, 9, 11]\nc = [2]\n\nif x in a and x not in b and x not in c and y in a and y not in b and y not in c:\n print('Yes')\nelif x not in a and x in b and x not in c and y not in a and y in b and y not in c :\n print('Yes')\nelse:\n print('No')\n", "x,y = map(int,input().split())\ngr_a = [1,3,5,7,8,10,12]\ngr_b = [4,6,9,11]\ngr_c = [2]\n\nif x in gr_a and y in gr_a:\n print(\"Yes\")\nelif x in gr_b and y in gr_b:\n print(\"Yes\")\nelse:\n print(\"No\")", "g1 = [4, 6, 9, 11]\ng2 = [2]\n\nx, y = list(map(int, input().split()))\ngx = 1 if x in g1 else 2 if x in g2 else 0\ngy = 1 if y in g1 else 2 if y in g2 else 0\nprint((\"Yes\" if gx == gy else \"No\"))\n", "a = map(int, input().split())\ninput_set = set(a)\n\ngroup_a = {1, 3, 5, 7, 8, 10, 12}\ngroup_b = {4, 6, 9, 11}\ngroup_c = {2}\n\nlist_of_list = [group_a, group_b, group_c]\n\ncount_match = 0\n\nfor set_i in list_of_list:\n if set_i.issuperset(input_set):\n count_match += 1\n print('Yes')\n break\n\nif not count_match >= 1:\n print('No')", "a=[1,3,5,7,8,10,12]\nb=[4,6,9,11]\nc=list(map(int,input().split(\" \")))\nprint(\"Yes\") if (c[0] in a and c[1] in a) or (c[0] in b and c[1] in b) else print(\"No\")", "x, y = list(map(int,input().split()))\n\na= [1,3,5,7,8,10,12]\nb= [4,6,9,11]\nc= [2]\n\nif (x in a and y in a) or (x in b and y in b) or (x in c and y in c):\n print('Yes')\nelse:\n print('No')", "x,y=map(int,input().split())\na=[1,3,5,7,8,10,12]\nb=[4,6,9,11]\nc=[2]\n\nif (x in a and y in a) or (x in b and y in b) or (x in c and y in c):\n print(\"Yes\")\nelse:\n print(\"No\")", "l = ((1,3,5,7,8,10,12),(4,6,9,11),(0,2))\nx,y = map(int, input().split())\np = 0\nfor i in l:\n\tif x in i and y in i:\n\t\tp = 1\n\t\tbreak\nans = 'Yes' if p == 1 else 'No'\nprint(ans)", "group1 = [1, 3, 5, 7, 8, 10, 12]\ngroup2 = [4, 6, 9, 11]\n\nx, y = map(int, input().split())\n\nif (x in group1 and y in group1) or (x in group2 and y in group2) or (x == y == 2):\n print(\"Yes\")\nelse:\n print(\"No\")", "print('YNeos'[len(set([0 if i==2 else [1,2][i in [4,6,9,11]] for i in [*map(int,input().split())]]))!=1::2])", "G1 = [1,3,5,7,8,10,12]\nG2 = [4,6,9,11]\nx,y = map(int, input().split())\n\nif x in G1 and y in G1:\n print('Yes')\nelif x in G2 and y in G2:\n print('Yes')\nelse:\n print('No')", "x,y=map(int,input().split())\na=[1,3,5,7,8,10,12]\nb=[4,6,9,11]\nif x in a and y in a :\n print(\"Yes\")\nelif x in b and y in b :\n print(\"Yes\")\nelse :\n print(\"No\")", "x,y=list(map(int,input().split()))\nfor l in [[1,3,5,7,8,10,12],[4,6,9,11],[2]]:\n if x in l and y in l:\n print('Yes')\n return\nprint('No')\n", "x, y = map(int, input().split())\n\ng1 = [1, 3, 5, 7, 8, 10, 12]\ng2 = [4, 6, 9, 11]\ng3 = [2]\n\nif (x in g1 and y in g1) or (x in g2 and y in g2) or (x in g3 and y in g3):\n print('Yes')\nelse:\n print('No')", "a, b = list(map(int, input().split()))\n\nlis = [4, 6, 9, 11]\nlis2 = [1, 3, 5, 7, 8, 10, 12]\n\nif a == b == 2:\n print('Yes')\nelif a in lis and b in lis:\n print('Yes')\nelif a in lis2 and b in lis2:\n print('Yes')\nelse:\n print('No')\n", "def solve():\n x, y = list(map(int, input().split()))\n a = [1, 3, 5, 7, 8, 10, 12]\n b = [4, 6, 9, 11]\n c = [2]\n\n if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef __starting_point():\n solve()\n\n__starting_point()", "array1 = [1,3,5,7,8,10,12]\narray2 = [4,6,9,11]\narray3 = [2]\nx,y = map(int,input().split())\nif (x in array1 and y in array1) or (x in array2 and y in array2) or (x in array3 and y in array3):\n print(\"Yes\")\nelse:\n print(\"No\")", "x,y=map(int,input().split())\na=[1,3,5,7,8,10,12]\nb=[4,6,9,11]\nif x in a and y in a:\n print(\"Yes\")\nelif x in b and y in b:\n print(\"Yes\")\nelse:\n print(\"No\")", "s1 =set([1,3,5,7,8,10,12])\ns2 =set([4,6,9,11])\ns3 =set([2])\na,b =map(int,input().split())\nfor i in [s1,s2,s3]:\n if a in i and b in i:\n print(\"Yes\")\n break\nelse:\n print(\"No\")", "a = [1, 3, 5, 7, 8, 10, 12]\nb = [4, 6, 9, 11]\nc = [2]\nx, y = map(int, input().split())\nif a.count(x) * a.count(y) > 0 or b.count(x) * b.count(y) > 0 or c.count(x) * c.count(y) > 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b = [int(x) for x in input().split()]\ng = [[] for x in range(3)]\ng[0] = [1,3,5,7,8,10,12]\ng[1] = [4,6,9,11]\ng[2] = [2]\nres = \"No\"\nfor i in range(3):\n if a in g[i] and b in g[i]:\n res = \"Yes\"\n \nprint(res)", "a, b = map(int, input().split())\n\nif a == 4 or a == 6 or a == 9 or a == 11:\n if b == 1 or b == 2 or b == 3 or b == 5 or b == 7 or b == 8 or b == 10 or b == 12:\n print(\"No\")\n else:\n print(\"Yes\")\n \nelif a == 2:\n print(\"No\")\n \nelse:\n if b == 2 or b == 4 or b == 6 or b == 9 or b == 11:\n print(\"No\")\n else:\n print(\"Yes\")", "a=[1,3,5,7,8,10,12]\nb=[4,6,9,11]\nc=[2]\np=0\nq=0\n\ns=list(map(int,input().split()))\n\nfor i in a:\n if s[0]==i:\n p=0\n elif s[0]==2:\n p=2\n else:\n p=1\n\nfor i in a:\n if s[1]==i:\n q=0\n elif s[1]==2:\n q=2\n else:\n q=1\n\nif p==q:\n print('Yes')\nelse:\n print('No')\n", "a,b=map(int,input().split())\nl1=[1,3,5,7,8,10,12]\nl2=[4,6,9,11] \nif a==2 or b==2:\n print(\"No\")\nelif a in l1 and b in l1:\n print(\"Yes\")\nelif a in l2 and b in l2:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b = map(int, input().split())\ns = {1, 3, 5, 8, 7, 10, 12}\nt = {4, 6, 9, 11}\nu = {2}\nif a in s and b in s:\n print(\"Yes\")\nelif a in t and b in t:\n print(\"Yes\")\nelif a in u and b in u:\n print(\"Yes\")\nelse:\n print(\"No\")", "x, y = list(map(int, input().split()))\na = [1, 3, 5, 7, 8, 10, 12]\nb = [4, 6, 9, 11]\nc = [2]\n\nif (x in a and y in a) or (x in b and y in b) or (x in c and y in c):\n print('Yes')\nelse:\n print('No')\n", "x, y=map(int, input().split())\nA=set([1, 3, 5, 7, 8, 10, 12])\nB=set([4, 6, 9, 11])\nif x in A and y in A:\n print('Yes')\nelif x in B and y in B:\n print('Yes')\nelse:\n print('No')", "x,y=map(int,input().split())\n \nA=[1,3,5,7,8,10,12]\nB=[4,6,9,11]\n \nif x==2 or y==2:\n print('No')\nelif (x in A and y in A) or (x in B and y in B):\n print('Yes')\nelse:\n print('No')", "x,y=map(int, input().split()) \ng=[[1,3,5,7,8,10,12],[4,6,9,11]]\nprint(\"Yes\" if any(x in g[i] and y in g[i] for i in range(2)) else \"No\")", "gr = [0,1,3,1,2,1,2,1,1,2,1,2,1]\nx, y = map(int, input().split())\nans = 'Yes' if gr[x] == gr[y] else 'No'\nprint(ans)", "x,y = map(int,input().split())\n\ngrp1=[1,3,5,7,8,10,12]\ngrp2=[4,6,9,11]\n\nif x in grp1 and y in grp1: print('Yes')\nelif x in grp2 and y in grp2: print('Yes')\nelse: print('No')", "a=[1,3,5,7,8,10,12]\nb=[4,6,9,11]\nx,y=map(int,input().split())\nif (x in a and y in a) or (x in b and y in b):print('Yes')\nelse:print('No')", "x,y=map(int,input().split())\ngroup_A=[1,3,5,7,8,10,12]\ngroup_B=[4,6,9,11]\nif x in group_A and y in group_A :\n print(\"Yes\")\nelif x in group_B and y in group_B :\n print(\"Yes\")\nelse:\n print(\"No\")", "L=[1,0,1,2,1,2,1,1,2,1,2,1]\na,b=map(int,input().split())\nif L[a-1]==L[b-1]:\n print(\"Yes\")\nelse:\n print(\"No\")", "a = [1, 3, 5, 7, 8, 10, 12]\nb = [4, 6, 9, 11]\nc = [2]\nx, y = map(int, input().split())\nif (x in a and y in a) or (x in b and y in b) or (x in c and y in c):\n print('Yes')\nelse:\n print('No')", "x,y=list(map(int,input().split()))\nA={1,3,5,7,8,10,13}\nB={4,6,9,11}\nC={2}\n\nif (x in A and y in A) or (x in B and y in B) or (x in C and y in C):\n print(\"Yes\")\nelse:\n print(\"No\")\n", "g = [-1, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]\nx, y = map(int, input().split())\nif g[x] == g[y]: print('Yes')\nelse: print('No')", "x, y = list(map(int, input().split()))\n\nga = [4,6,9,11]\ngb = [1,3,5,7,8,10,12]\ngc = [2]\n\nxg = yg = \"\"\ndef group(x):\n if x in ga:\n return \"ga\"\n if x in gb:\n return \"gb\"\n if x in gc:\n return \"gc\"\nxg = group(x)\nyg = group(y)\nif xg == yg:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "x, y = map(int, input().split())\n\ng1 = [1, 3, 5, 7, 8, 10, 12]\ng2 = [4, 6, 9, 11]\n\n\nif x == 2 and y == 2:\n print(\"Yes\")\nelif x in g1 and y in g1:\n print(\"Yes\")\nelif x in g2 and y in g2:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b=map(int,input().split())\ns=[1,3,5,7,8,10,12]\nt=[4,6,9,11]\nif a in s:\n a = 0\nelif a in t:\n a = 1\nelse:\n a = 2\nif b in s:\n b = 0\nelif b in t:\n b = 1\nelse:\n b = 2\nprint(\"Yes\" if a==b else \"No\")", "N = 12\nParent = [I for I in range(N+1)]\nRank = [0]*(N+1)\ndef FindParent(X):\n if Parent[X]==X:\n return X\n else:\n Parent[X] = FindParent(Parent[X])\n return Parent[X]\n\ndef CheckParent(X,Y):\n return FindParent(X)==FindParent(Y)\n\ndef UniteParent(X,Y):\n X = FindParent(X)\n Y = FindParent(Y)\n if X==Y:\n return 0\n if Rank[X]<Rank[Y]:\n Parent[X] = Y\n else:\n Parent[Y] = X\n if Rank[X]==Rank[Y]:\n Rank[X] += 1\n \nfor GA in [3,5,7,8,10,12]:\n UniteParent(1,GA)\nfor GB in [6,9,11]:\n UniteParent(4,GB)\nX,Y = (int(T) for T in input().split())\nprint(['No','Yes'][CheckParent(X,Y)])", "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n x, y = LI()\n d = {1: 0, 2: 2, 3: 0, 4: 1, 5: 0, 6: 1, 7: 0, 8: 0, 9: 1, 10: 0, 11: 1, 12: 0}\n\n if d[x] == d[y]:\n print('Yes')\n else:\n print('No')\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "a = [1,3,5,7,8,10,12]\nb = [4,6,9,11]\nc = [2]\nx,y=map(int,input().split())\nif x in a and y in a:\n print(\"Yes\")\nelif x in b and y in b:\n print(\"Yes\")\nelse:\n print(\"No\")", "x,y=map(int,input().split())\ns1={1,3,5,7,8,10,12}\ns2={4,6,9,11}\nprint([\"No\",\"Yes\"][(x in s1 and y in s1) or (x in s2 and y in s2)]) ", "x, y = map(int, input().split())\na = [1, 3, 5, 7, 8, 10, 12]\nb = [4, 6, 9, 11]\nc = [2]\n\nif (x in a and y in a) or (x in b and y in b) or (x in c and y in c):\n print('Yes')\nelse:\n print('No')", "g = [0,1,3,1,2,1,2,1,1,2,1,2,1]\nx, y = map(int,input().split())\n\nprint('Yes') if g[x] == g[y] else print('No')", "x,y=map(int,input().split())\ndata=[1,3,1,2,1,2,1,1,2,1,2,1]\nif data[x-1]==data[y-1]:\n print('Yes')\nelse:\n print('No')", "x,y=list(map(int,input().split()))\na=[1,3,5,7,8,10,12]\nb=[4,6,9,11]\nc=[2]\nif x in a and y in a:\n print(\"Yes\")\nelif x in b and y in b:\n print(\"Yes\")\nelif x in c and y in c:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a = [1,3,5,7,8,10,12]\nb = [4,6,9,11]\nx,y = list(map(int,input().split()))\nprint((\"Yes\" if (x in a and y in a) or (x in b and y in b) else \"No\"))\n", "x, y = map(int, input().split())\na=[1,3,5,7,8,10,12]\nb=[4,6,9,11]\nif (x==y or (x in a and y in a) or (x in b and y in b)):\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b = map(int,input().split())\nx = [1,3,5,7,8,10,12]\ny = [4,6,9,11]\nif a == 2 or b == 2:\n print(\"No\")\nelse:\n if a in x and b in x:\n print(\"Yes\")\n elif a in y and b in y:\n print(\"Yes\")\n else:\n print(\"No\")", "x,y = map(int,input().split())\nA = [1,3,5,7,8,10,12]\nB = [4,6,9,11]\nC = [2]\n\nif x in A and y in A:\n check = True\nelif x in B and y in B:\n check = True\nelif x in C and y in C:\n check = True\nelse:\n check = False\n \nprint(\"Yes\" if check else \"No\")", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\nINF = float('inf')\nMOD = 10**9 + 7\n#MOD = 998244353\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lintdec(): return list(map(lambda x:int(x) - 1, input().split()))\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nc = set(lint())\na = set([1, 3, 5, 7, 8, 10, 12])\nb = set([4, 6, 9, 11])\n\nif c & a == c or c & b == c:\n print('Yes')\nelse:\n print('No')", "x,y = list(map(int,input().split()))\n\na = [1,3,5,7,8,10,12]\nb = [4,6,9,11]\n\nif x == 2 or y == 2:\n print('No')\nelif x in a and y in a:\n print('Yes')\nelif x in b and y in b:\n print('Yes')\nelse:\n print('No')\n", "x, y = map(int, input().split())\na = [1, 3, 5, 7, 8, 10, 12]\nb = [4, 6, 9, 11]\nc =[2]\nif x in a and y in a:\n print(\"Yes\")\nelif x in b and y in b:\n print(\"Yes\")\nelif x in c and y in c:\n print(\"Yes\")\nelse:\n print(\"No\")", "x, y = map(int, input().split())\na = [4, 6, 9, 11]\nb = 0\nc = 0\nif x == 2 or y == 2:\n print(\"No\")\nelse:\n if x in a:\n b = 1\n if y in a:\n c = 1\n if (b + c) % 2 == 0:\n print(\"Yes\")\n else:\n print(\"No\")", "x, y = list(map(int, input().split()))\n\ngroup_1 = {1, 3, 5, 7, 8, 10, 12}\ngroup_2 = {4, 6, 9, 11}\n\nif (x in group_1) and (y in group_1):\n print('Yes')\nelif (x in group_2) and (y in group_2):\n print('Yes')\nelse:\n print('No')\n", "x,y=map(int,input().split())\nG=\"121313113131\"\nprint([\"No\",\"Yes\"][G[x-1]==G[y-1]])", "x, y = map(int, input().split())\nd = {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1, 4:2, 6:2, 9:2, 11:2, 2:3}\nif d[x]==d[y]:\n print(\"Yes\")\nelse:\n print(\"No\")", "s = \"0131212112121\"\nx,y = map(int,input().split())\nprint(\"Yes\" if s[x]==s[y] else \"No\")", "x,y = map(int,input().split())\ng = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]\ns = 0\nfor i in range(3):\n if x in g[i] and y in g[i]:\n print(\"Yes\")\n s = 1\nif s == 0:\n print(\"No\")", "x,y = map(int, input().split())\na = [1,3,5,7,8,10,12]\nb = [4,6,9,11]\nif (x in a and y in a) or (x in b and y in b):\n print(\"Yes\")\nelse:\n print(\"No\")", "print('YNeos'[len(set([0 if i==2 else [1,2][i in [4,6,9,11]] for i in list(map(int,input().split()))]))!=1::2])", "group = [0,2,0,1,0,1,0,0,1,0,1,0]\nx,y = map(int, open(0).readline().split())\nprint('Yes' if group[x-1] == group[y-1] else 'No')", "a, b = list(map(int, input().split()))\ns = {1, 3, 5, 8, 7, 10, 12}\nt = {4, 6, 9, 11}\nu = {2}\nif a in s and b in s:\n print(\"Yes\")\nelif a in t and b in t:\n print(\"Yes\")\nelif a in u and b in u:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "x,y = list(map(int,input().split()))\n\ns = [1,3,5,7,8,10,12]\ns1 = [4,6,9,11]\ns2 = [2]\n\nif x in s:\n if y in s:\n print('Yes')\n return\nelif x in s1:\n if y in s1:\n print('Yes')\n return\nelif x in s2:\n if y in s2:\n print('Yes')\n return\n\nprint('No')\n", "G = [set([1,3,5,7,8,10,12]), set([4,6,9,11]), set([2])]\ndef check(x, y):\n for g in G:\n if x in g and y in g:\n return True\n return False\nx, y = list(map(int, input().split()))\nprint((\"Yes\" if check(x, y) else \"No\"))\n", "lst = input().split()\n\nx = int(lst[0])\ny = int(lst[1])\n\nA = [1, 3, 5, 7, 8, 10, 12]\nB = [4, 6, 9, 11]\nC = [2]\n\ndef judge(L):\n if (x in L) and (y in L):\n return True\n else:\n return False\n\nif judge(A) or judge(B) or judge(C):\n print('Yes')\nelse:\n print('No')", "r = list(map(int,input().split()))\na=[1,3,5,7,8,10,12]\nb=[4,6,9,11]\nc=[2]\nif r[0]==2 or r[0]==2:\n print('No')\nelif len(list(set(r) & set(a))) == 2:\n print('Yes')\nelif len(list(set(r) & set(b))) == 2:\n print('Yes')\nelse:\n print('No')", "lisa=[1,3,5,7,8,10,12]\nlisb=[4,6,9,11]\nlisc=[2]\nx,y=map(int,input().split())\nif (x in lisa)and(y in lisa):\n print(\"Yes\")\nelif (x in lisb)and(y in lisb):\n print(\"Yes\")\nelif (x in lisc)and(y in lisc):\n print(\"Yes\")\nelse:\n print(\"No\")", "x, y = map(int, input().split())\n\ng1 = [1, 3, 5, 7, 8, 10, 12]\ng2 = [4, 6, 9, 11]\n\nprint(\"Yes\" if (x in g1 and y in g1) or (x in g2 and y in g2) else \"No\")", "a = [1, 3, 5, 7, 8, 10, 12]\nb = [4, 6, 9, 11]\nc = [2]\nacount = 0\nbcount = 0\nccount = 0\n\nx, y = input().split()\n\nfor i in range(0, 7):\n if int(x) == a[i] or int(y) == a[i]:\n acount += 1\n\nfor i in range(0, 4):\n if int(x) == b[i] or int(y) == b[i]:\n bcount += 1\n\nif int(x) == c[0]:\n ccount += 1\nif int(y) == c[0]:\n ccount += 1\n\n\nif acount == 2 or bcount == 2 or ccount == 2:\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\n", "g = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]\nx, y = map(int, input().split())\nfor i in range(len(g)):\n if x in g[i]:\n xg = i\n if y in g[i]:\n yg = i\nif xg == yg:\n print('Yes')\nelse:\n print('No')", "x, y = map(int, input().split())\n\ngr1=[1,3,5,7,8,10,12]\ngr2=[4,6,9,11]\ngr3=[2]\n\nif x in gr1 and y in gr1:\n print('Yes')\nelif x in gr2 and y in gr2:\n print('Yes')\nelif x in gr3 and y in gr3:\n print('Yes')\nelse:\n print('No')", "x, y =map(int, input().split())\nif x in {1,3,5,7,8,10,12}:\n x= 1\nelif x in {4,6,9,11}:\n x =2\nelse:\n x = 3\nif y in {1,3,5,7,8,10,12}:\n y= 1\nelif y in {4,6,9,11}:\n y =2\nelse:\n y = 3\nprint(\"Yes\" if x == y else \"No\")", "x,y=map(int,input().split())\ng1 = {1,3,5,7,8,10,12}\ng2 = {4,6,9,11}\ng3 = {2}\n\ndef group(z):\n if z in g1:return 1\n elif z in g2:return 2\n else: return 3\n \nif group(x)==group(y):print('Yes')\nelse:print('No')", "'''\nabc062 A - Grouping\nhttps://atcoder.jp/contests/abc062/tasks/abc062_a\n'''\n\ndirs = [{1, 3, 5, 7, 8, 10, 12}, {4, 6, 9, 11}, {2}]\n\ni = list(map(int, input().split()))\n\nfor dir in dirs:\n if i[0] in dir and i[1] in dir:\n print('Yes')\n return\nelse:\n print('No')\n", "a,b=input().split()\na=int(a)\nb=int(b)\nl1=[1,3,5,7,8,10,12]\nl2=[4,6,9,11]\nif a in l1 and b in l1:\n print(\"Yes\")\nelif a in l2 and b in l2:\n print(\"Yes\")\nelse:\n print(\"No\")", "#k = int(input())\n#s = input()\n#a, b = map(int, input().split())\n#s, t = map(str, input().split())\n#l = list(map(int, input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n#a = [list(input()) for _ in range(n)]\n\nx,y = list(map(int, input().split()))\n\ng1 = [1,3,5,7,8,10,12]\ng2 = [4,6,9,11]\ng3 = [2]\n\n\nif (x in g1 and y in g1):\n print(\"Yes\")\nelif (x in g2 and y in g2):\n print(\"Yes\")\nelif (x in g3 and y in g3):\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\n"] | {"inputs": ["1 3\n", "2 4\n"], "outputs": ["Yes\n", "No\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 23,058 | |
ce290302ac9b6d6322d087637cdb1d56 | UNKNOWN | AtCoDeer the deer found two positive integers, a and b.
Determine whether the product of a and b is even or odd.
-----Constraints-----
- 1 β€ a,b β€ 10000
- a and b are integers.
-----Input-----
Input is given from Standard Input in the following format:
a b
-----Output-----
If the product is odd, print Odd; if it is even, print Even.
-----Sample Input-----
3 4
-----Sample Output-----
Even
As 3 Γ 4 = 12 is even, print Even. | ["a, b = map(int, input().split())\nif a*b %2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\nif a % 2 == 0:\n print('Even')\nelif b % 2 == 0:\n print('Even')\nelse:\n print('Odd')", "a,b=map(int, input().split())\n\nif a*b%2==0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "# -*- coding: utf-8 -*-\n \na, b = map(int, input().split())\n \nmul = a * b\n \nresult = 'Even' if (mul % 2 == 0) else 'Odd'\n \nprint(result)", "a, b = map(int, input().split())\nprint([\"Even\", \"Odd\"][a * b % 2])", "a,b=(int(x) for x in input().split())\n \nif a*b%2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\nprint('Odd' if a*b % 2 == 1 else 'Even')", "a, b = map(int,input().split())\n\nadd = (a * b)\n\nif add % 2 != 0:\n print(\"Odd\")\nelse:\n print(\"Even\")", "a,b = list(map(int, input().split())) \nc =a*b\nif c%2==0:\n print('Even')\nelse:\n print('Odd')\n", "a,b=input().split()\nif int(a)*int(b)%2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "import bisect,collections,copy,heapq,itertools,math,string\nimport sys\ndef I():\n #1 line 1 int\n return int(sys.stdin.readline().rstrip())\ndef LI():\n #1 line n int\n return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S():\n #1 line 1 string\n return sys.stdin.readline().rstrip()\ndef LS():\n #1 line n strings\n return list(sys.stdin.readline().rstrip().split())\n\na,b,=LI()\n\nif (a*b)%2==0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\n\nprint(\"Even\" if a * b % 2 == 0 else \"Odd\")", "a, b = list(map(int, input().split()))\nif a * b % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")\n", "a,b = map(int,input().split())\nc=a*b\n\nif c % 2 ==1:\n print('Odd')\n\nelse:\n print('Even')", "a, b = map(int, input().split())\nif (a * b) % 2 == 0:\n print(\"Even\")\nelif (a * b) % 2 != 0:\n print(\"Odd\")", "a,b = list(map(int,input().split()))\nc = a * b\nif c%2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\n\nif (a*b)%2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a,b=list(map(int,input().split()))\n\nif(a*b)%2==0:\n print('Even')\nelse:\n print('Odd')\n", "a, b = map(int,input().split())\nif a * b % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "numbers = input().split(\" \")\nif (int(numbers[0])*int(numbers[1])) % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")\n", "a, b = map(int, input().split())\nc = a * b\nif(c % 2):\n print(\"Odd\")\nelse:\n print(\"Even\")", "a,b = map(int,input().split())\nprint([\"Odd\",\"Even\"][a*b%2==0])", "a, b = map(int, input().split())\nif a * b % 2: print('Odd')\nelse: print('Even')", "a, b = input().split(' ')\n\nc = int(a)*int(b)\nif c % 2 == 0:\n print('Even')\nelse:\n print('Odd')", "a,b = map(int, input().split())\nif a * b % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "x,y = map(int,input().split())\n\nseki = x * y\n\nif seki % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\nif a*b%2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int,input().split())\nif (a*b)%2==0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\nc = a * b\nprint(\"Even\" if c % 2 == 0 else \"Odd\")", "a,b = map(int, input().split())\n \nif (a*b) % 2 == 0:\n print(\"Even\")\n \nelse :\n print(\"Odd\")", "a, b = map(int, input().split())\nif (a*b)%2 == 0:\n print('Even')\nelse:\n print('Odd')", "a, b = map(int, input().split())\nif a * b % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a,b = list(map(int,input().split()))\nprint((\"Odd\" if a*b%2!=0 else \"Even\"))\n", "a, b = map(int, input().split())\nc = (a*b)%2\n\nif c ==1:\n print('Odd')\nelse:\n print('Even')", "a,b=map(int, input().split())\nprint(\"Odd\" if a*b%2 else \"Even\")", "a,b=(int(xx) for xx in input().split())\nif (a*b)%2==0:\n print('Even')\nelse:\n print(\"Odd\")\n", "def mapt(fn, *args):\n return tuple(map(fn, *args))\n\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\n\ndef main():\n a, b = Input()\n print(\"Even\" if (a*b)%2==0 else \"Odd\")\n\n\nmain()", "a,b = map(int,input().split())\nanswer = a * b\n\nif answer % 2 == 0 :\n print('Even')\nelse : \n print('Odd')", "a,b = map(int,input().split())\nc = (a * b) % 2\nif c == 0:\n print('Even')\nelse:\n print('Odd')", "a,b = map(int,input().split())\nmul = a*b\nif mul%2==1:\n print(\"Odd\")\nelse:\n print(\"Even\")", "a,b=map(int,input().split())\n\nif (a*b)%2==0:print('Even')\nelse:print('Odd')", "a,b = list(map(int, input().split()))\nprint('Odd' if a&1 and b&1 else 'Even')", "a, b = map(int, input().split())\n\nif a * b % 2 == 0:\n print('Even')\nelse:\n print('Odd')", "a,b = map(int,input().split())\nif a % 2 == 1 and b % 2 == 1:\n print('Odd')\nelse:\n print('Even')", "a, b = map(int, input().split())\n\nif a * b % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\n\nS = a*b\n\nif S % 2 == 1:\n print(\"Odd\")\nelse:\n print(\"Even\")", "a,b = map(int,input().split())\nc = a*b\nif c % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "def isEven(a, b):\n if a % 2 == 0:\n return True\n if b % 2 == 0:\n return True\n return False\n\ni = input().split()\na = int(i[0])\nb = int(i[1])\nif isEven(a, b):\n print('Even')\nelse:\n print('Odd')", "# coding: utf-8\n# Your code here!\nnum=input().split()\nnum2=int(num[0])*int(num[1])\n\nif num2%2==0:\n\tprint(\"Even\")\nelse:\n \tprint(\"Odd\")", "a, b = map(int, input().split())\n\nprint('Even') if a*b % 2 == 0 else print('Odd')", "a, b = map(int, input().split())\nprint(\"Even\" if a*b % 2 == 0 else \"Odd\")", "#!/bin/env python3\n# -*- coding: utf-8 -*-\n\nIS = lambda: int(input())\nIA = lambda: [int(x) for x in input().split()]\n\na, b = IA()\nprint((\"Odd\" if (a * b) % 2 else \"Even\"))\n", "a, b = map(int, input().split())\n\nflag = (a*b %2 ==0)\nif flag:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a,b=map(int,input().split())\nprint('EOvdedn'[a*b%2::2])", "a,b=map(int,input().split(\" \"))\nprint([\"Even\",\"Odd\"][(a*b)%2])", "a, b = map(int, input().split())\nprint('Even' if (a*b % 2) == 0 else 'Odd')", "p = input().split()\n\nprint (\"Even\" if int(p[0]) * int(p[1]) % 2 == 0 else \"Odd\")", "def solve(a, b):\n if a * b % 2 == 0:\n print('Even')\n else:\n print('Odd')\n\n\ndef __starting_point():\n a, b = list(map(int, input().split()))\n solve(a, b)\n\n__starting_point()", "a, b = map(int,input().split())\nif a*b % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "lst = input().split()\n\nif (int(lst[0]) * int(lst[1])) % 2 == 0:\n print('Even')\nelse:\n print('Odd')", "a, b = map(int, input().split())\n\nif a%2 == 0 or b%2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\nif a * b % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "[a, b] = input().split()\n\nif (int(a) % 2 == 0) or (int(b) % 2 == 0):\n print(\"Even\")\nelse:\n print(\"Odd\")\n", "a, b = map(int, input().split())\nprint(\"Even\" if a * b % 2 == 0 else \"Odd\" )", "a, b = [int(i) for i in input().split()]\n\nprint(('Odd' if a * b % 2 == 1 else 'Even'))\n", "a,b=map(int,input().split())\nif a*b%2==0:\n print('Even')\nelse:\n print('Odd')", "a, b = map(int, input().split(' '))\n\nmod_ab = (a*b)%2\n\nif(mod_ab==0) :\n print(\"Even\")\nelse :\n print(\"Odd\")", "a, b = map(int, input().split())\nprint(\"Odd\" if a*b%2==1 else \"Even\")", "import numpy as np\ns=list(map(int,input().split()))\n\np=np.prod(s)\nif(p%2==0):\n print('Even')\nelse:\n print('Odd')", "print(\"Odd\" if all(map(lambda x:int(x)%2, input().split())) else \"Even\")", "a,b = map(int,input().split())\n\nif a*b%2 == 0:\n print('Even')\n \nelse:\n print('Odd')", "a, b = map(int, input().split())\nif (a*b) % 2:\n print(\"Odd\")\nelse:\n print(\"Even\")", "a, b = map(int, input().split())\nc = (a * b) % 2\n\nif c == 0:\n print('Even')\nelif c == 1:\n print('Odd')", "a,b = map(int, input().split())\nif (a * b) %2 == 0:\n print('Even')\nelif(a * b) %2 == 1:\n print('Odd')", "a, b = map(int, input().split())\nprint(\"Odd\" if a * b % 2 == 1 else \"Even\")", "a,b = map(int, input().split())\nif a*b%2 == 1:\n print(\"Odd\")\nelse:\n print(\"Even\")", "#85A\na,b=map(int,input().split())\nif a*b%2==0:\n print('Even')\nelse:\n print('Odd')", "a, b = map(int,input().split())\nc = a * b\nif c % 2 == 0 :\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\nprint('Even' if a*b % 2 == 0 else 'Odd')", "a, b = list(map(int, input().split()))\nif (a * b) % 2 == 0:\n print('Even')\n\nelse:\n print('Odd')\n", "aa,bb=map(int,input().split())\n\nif aa * bb % 2 == 0:\n print('Even')\nelse:\n print('Odd')", "a, b = map(int,input().split())\nif (a * b) % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "getints = lambda: list(map(int, input().split()))\na, b = getints()\nif a * b % 2:\n print('Odd')\nelse:\n print('Even')\n", "# \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u306e\u6574\u6570\u306e\u5165\u529b\nb, c = map(int, input().split())\n \nif b * c % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a,b = map(int,input().split())\n\nif (a*b)%2 == 0:\n print('Even')\nelse:\n print('Odd')", "a,b=map(int,input().split())\nif 0==(a*b)%2:\n print(\"Even\")\nelse:\n print(\"Odd\")", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\na, b = list(map(int, input().split()))\n\nif a*b % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")\n", "# coding: utf-8\n# Your code here!\n\na, b = map(int, input().split())\n\nif a*b % 2 == 0 : \n print(\"Even\")\nelse : \n print(\"Odd\")", "a,b = map(int,input().split())\n\nif a*b % 2 == 0:\n print('Even')\nelse:\n print('Odd')", "x, y = map(int, input().split())\n \nl = (x*y) % 2\nif l == 0:\n\tprint('Even')\nelse:\n \tprint('Odd')", "a, b = map(int,input().split())\nif a*b % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\n\nif (a * b) % 2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a,b=map(int,input().split())\nif a*b%2==0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a,b = (int(x) for x in input().split())\n\nmulti = a * b\n\nif multi %2 == 0:\n print(\"Even\")\nelse:\n print(\"Odd\")\n", "a, b = map(int, input().split())\nif (a*b) % 2 ==0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a,b = list(map(int,input().split()))\nprint((\"Even\" if a*b%2 == 0 else \"Odd\"))\n\n", "a,b=map(int,input().split())\nif a*b%2==0:\n print(\"Even\")\nelse:\n print(\"Odd\")", "a, b = map(int, input().split())\n\nif a % 2 == 1 and b % 2 == 1:\n print('Odd')\nelse:\n print('Even')", "a, b = map(int, input().split())\n\nprint('Even') if a*b % 2 == 0 else print('Odd')", "a,b = map(int,input().split())\nif (a * b) % 2 == 1:\n print(\"Odd\")\nelse:\n print(\"Even\")"] | {"inputs": ["3 4\n", "1 21\n"], "outputs": ["Even\n", "Odd\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 11,169 | |
532f892ae42b4d4be34bd9cbe2b0de4e | UNKNOWN | Snuke loves puzzles.
Today, he is working on a puzzle using S- and c-shaped pieces.
In this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:
Snuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.
Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.
-----Constraints-----
- 1 β€ N,M β€ 10^{12}
-----Input-----
The input is given from Standard Input in the following format:
N M
-----Output-----
Print the answer.
-----Sample Input-----
1 6
-----Sample Output-----
2
Two Scc groups can be created as follows:
- Combine two c-shaped pieces into one S-shaped piece
- Create two Scc groups, each from one S-shaped piece and two c-shaped pieces | ["n, m = [int(x) for x in input().split()]\nans = min(n, m // 2)\nans += (m - ans * 2) // 4\nprint(ans)", "N,M=map(int,input().split())\nans=0\nif 2*N<=M:\n ans+=N\n M-=2*N\nelse:\n ans+=(M//2)\n M-=(M//2)*2\nans+=(M//4)\nprint(ans)", "def main():\n n, m = map(int, input().split())\n\n if m - 2 * n >= 0:\n m -= 2 * n\n ans = n\n n = 0\n\n if (m - 2 * n) % 4 == 0:\n tmp = (m - 2 * n) // 4\n else:\n tmp = (m - 2 * n) // 4 + 1\n\n ans += (m - 2 * tmp) // 2\n\n else:\n ans = m // 2\n\n print(ans)\n\n\ndef __starting_point():\n main()\n__starting_point()", "s, c = map(int, input().split())\nc = c//2\n\nif s == c:\n print(s)\nelif s > c:\n print(c)\nelif s < c:\n t = c - s\n print(s + t//2)", "N, M = list(map(int, input().split()))\n\nif N <= M/2:\n ans = N + (M - 2*N)//4\nelse:\n ans = M//2\nprint(ans)\n", "n, m = map(int, input().split())\n\nif n >= (m // 2):\n print(m // 2)\nelse:\n total = n * 2 + m\n print(total // 4)", "n,m = map(int,input().split())\n\nans = 0\nif m-n*2>0:\n ans += n\n tmp = m-n*2\n \n ans += tmp//4\nelse:\n ans += m//2\nprint(ans)", "n,m=map(int,input().split())\nif n<m:\n print(n+(m-2*n)//4)\nelse:\n print(m//2)", "N,M = map(int,input().split())\nif N >= M // 2:\n ans = M//2\nelse:\n ans = N + (M-2*N)//4\nprint(ans)", "n,m = map(int, input().split())\nif 0 <= 2*n-m:\n num = m//2\nelse:\n num = n\n num += (m-2*n)//4\nprint(num)", "#!/usr/bin/env python\n\nn, m = list(map(int, input().split()))\n\ncc = m//2\nans = min(n, cc) \nres = cc-min(n, cc) \nif res > 0:\n ans += res//2\nprint(ans)\n", "import math\nN,M = (int(T) for T in input().split())\nif M-2*N>0:\n Convert = int(math.floor((M-2*N)/4))\n N += Convert\n M -= 2*Convert\n print(N)\nelse:\n print(M//2)", "N, M = map(int, input().split())\nprint(M//2 if 2*N > M else N + (M-2*N)//4)", "n,m = map(int,input().split())\nprint(min(n,m//2)+(m//2-min(n,m//2))//2)", "# C - Scc Puzzle\ndef main():\n n, m = map(int, input().split())\n\n\n if m-n*2 >= 0:\n print(n+((m-n*2)//4))\n else:\n print(m//2)\n \n \ndef __starting_point():\n main()\n__starting_point()", "N, M = map(int, input().split())\nif 2*N < M:\n extra = (M - 2*N) // 4\n ans = N + extra\nelse:\n ans = M // 2\nprint(ans)", "N,M = (int(T) for T in input().split())\nif 2*N<M:\n print(N+(M-2*N)//4)\nelse:\n print(M//2)", "N,M=map(int,input().split())\nM//=2\nprint(min(M,(N+M)//2))", "n,m=list(map(int,input().split()))\nif m<2:\n print((0))\n return\nif n>m//2:\n print((m//2))\n return\nc=n%(m//2)\nd=m-2*c\nc+=d//4\nprint(c)\n", "s, c = map(int, input().split())\n\nif 2 * s <= c:\n ans = s\n c = c - 2 * s\nelse:\n ans = c // 2\n c = 0\nif c >= 4:\n ans += c // 4\nprint(ans)", "n, m = [int(i) for i in input().split()]\n\nif 2*n >= m:\n print(m // 2)\nelse:\n print(n + (m - 2 * n) // 4)", "N, M = map(int, input().split())\n\nif 2 * N >= M:\n print(M // 2)\nelse:\n print(N + (M - 2 * N) // 4)", "n, m = list(map(int, input().split()))\nres = min(n, m // 2) + (m - min(n, m // 2) * 2) // 4\nprint(res)\n", "N, M = list(map(int, input().split()))\ntotal = 2 * N + M\nans = total // 4\nif ans*2 > M:\n ans = M//2\nprint(ans)\n", "import sys\nN,M = map(int,input().split())\nif not ( 1 <= N <= 10**12 and 1 <= M <= 10**12 ): return\n\ncount_SCC=0\nif M > 2*N : #M\u304c\u3042\u307e\u308b\n M = M - 2*N\n count_SCC = N + M//4\nelif M < 2*N : #N\u304c\u3042\u307e\u308b\n count_SCC = M//2\nprint(count_SCC)", "n,m = [int(x) for x in input().split()]\nres = 0\nif 2 * n >= m:\n res = m // 2\nelse:\n res = n\n m -= 2 * n\n res += m // 4\n\nprint(res)", "N,M = [int(a) for a in input().split()]\n\na1 = min(N,M//2)\na2 = 0\nif M//2 > N:\n a2 = (M - N*2)//4\n \na3 = a1+a2\nprint(a3)", "n, m = list(map(int, input().split()))\n\nif 2 * n >= m:\n print(m // 2)\nelse:\n print(n + (m-(2*n))//4)", "n,m=map(int,input().split())\nif 2*n>=m:\n print(m//2)\nelse:\n ans=n\n ans+=(m-2*n)//4\n print(ans)", "n, m = map(int, input().split())\nans = min(n, m // 2)\nm -= ans * 2\nans += max(0, m // 4)\nprint(ans)", "N,M=map(int,input().split())\n \nif N>=M//2:\n print(M//2)\nelse:\n print(N+(M-2*N)//4)", "n,m=list(map(int,input().split()))\nif n*2>=m:\n ans=m//2\nelse:\n ans=n\n m-=n*2\n ans+=m//4\nprint(ans)\n", "S, C = list(map(int, input().split()))\nans = 0\n\n# \u521d\u671f\u306eS\u3067\u53ef\u80fd\u306a\u9650\u308aSCC\u3092\u4f5c\u308b\nif S*2 <= C:\n C = C - S*2\n ans += S\n ans += C // 4\nelse:\n ans += C // 2\n\nprint((int(ans)))\n", "import sys\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 9)\nINF = 1 << 60\nMOD = 1000000007\n\n\ndef main():\n N, M = list(map(int, readline().split()))\n\n if N >= M // 2:\n ans = M // 2\n else:\n ans = N\n L = M - 2 * N\n ans += L // 4\n\n print(ans)\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s,c=map(int,input().split())\nif 2*s<=c: print((s+c//2)//2)\nelse: print(c//2)", "N, M = [int(i) for i in input().split()]\nif 2 * N >= M:\n print((M // 2))\nelse:\n print((N + (M - N - N) // 4))\n", "import sys;input = lambda : sys.stdin.readline()\nn,m = list(map(int,input().split()))\nif m-2*n>=0:\n print((n+(m-2*n)//4))\nelse:\n print((m//2))\n", "s,c=map(int,input().split())\np=s*2\nif p <= c:\n print(s + (c-p)//4)\nelse:\n print(c//2)", "n,m=map(int,input().split())\nif n*2>=m:\n print(m//2)\nelse:\n print(n+(m-2*n)//4)", "n, m = map(int, input().split())\n\nc = m - n * 2\nif c > 0:\n print(n + c // 4)\nelse:\n print(m // 2)", "a,b=map(int, input().split())\n\nif a*2 <= b:\n c = (b-a*2)//4\n print(a+c)\nif a*2 > b:\n print(b//2)", "N, M = list(map(int ,input().split()))\n\n# N + x : M - 2x = 1 : 2\n# M - 2x = 2N + 2x\n# x = (M - 2N) / 4\n\nif N * 2 >= M:\n print((int(M / 2)))\nelse:\n x = (M - 2 * N) / 4\n N += int(x)\n M -= 2 * int(x)\n print(N)\n \n \n", "N,M=list(map(int,input().split()))\nif 2*N>M:\n print((M//2))\nelse:\n print(((2*N+M)//4))\n", "import sys\nn,m = list(map(int,input().split()))\nif m < 2:\n print((0))\n return\nif(1 < m < n) or 2*n > m >= n:\n print((m//2))\n return\nm -= 2*n\nprint((n+(m//4)))\n", "n,m = map(int,input().split())\nif n*2 <= m:\n m += n*2\n print(m//4)\nelse:\n print(m//2)", "import sys\nimport math\n\nN, M = list(map(int, input().split()))\n\ncount = min(M//2, N)\nM -= count*2\nprint(count + M//4)", "import sys\nn,m = map(int,input().split())\nif m < 2:\n print(0)\n return\nif 1 < m < n:\n print(m//2)\n return\nif 2*n > m >= n:\n print(m//2)\n return\nm -= 2*n\nprint(n+(m//4))", "s, c = map(int,input().split())\n\ncnt = 0\nif 2*s <= c:\n cnt += s\n c -= 2*s\nelse:\n cnt += c // 2\n c = 0\n\ncnt += c//4\nprint(cnt)", "S, C = map(int, input().split())\n\nans = min(S, C // 2)\nS -= ans\nC -= ans * 2\nif C >= 4:\n ans += C // 4\nprint(ans)", "n,m = map(int, input().split())\nans = 0\n\nif m >= 2 and n > 0:\n ans += min(n, m // 2)\n m -= 2*ans\n\nif m > 0:\n ans += m // 4\nprint(ans)", "n,m = list(map(int,input().split()))\nif m//2 >=n:\n print((n+(m//2-n)//2))\nelse:\n print((m//2))\n", "N, M = list(map(int, input().split()))\nif N*2 >= M:\n print((M // 2))\n return\nans = N + (M - N*2) // 4\nprint(ans)\n", "n,m = map(int, input().split())\n\nif m - 2*n <0:\n print(m//2)\nelse:\n ans = n\n m -= 2*n\n ans += m//4\n print(ans)", "n,m = list(map(int,input().split()))\n\nif(2*n>=m):\n\tprint((m//2))\nelse:\n\tremaining = m- n*2\n\tans = remaining//4 + n\n\tprint(ans)\n", "N, M= map(int, input().split())\n\nif N >= M // 2:\n print(M // 2)\n\nelse:\n m = M - N * 2\n s = m // 4\n print(N + s)", "n,m = map(int, input().split())\n\nans = 0\nif n*2 <= m:\n ans += n\n m -= n*2\nelse:\n ans += m//2\n print(ans)\n return\n \nif 4 <= m: ans += m//4\nprint(ans)", "n,m = map(int,input().split())\nif 2*n >= m:\n print(m // 2)\nelse:\n print(n+((m-2*n) // 4))", "N,M = map(int,input().rstrip().split(\" \"))\nk = N * 2 + M\nprint(min(k // 4,M//2))", "n,m=map(int,input().split())\n\nif 2*n<m:\n ans=n+(m-(2*n))//4\nelse:\n ans=m//2\n\nprint(ans)", "N, M = list(map(int, input().split()))\nA = 0\nif 2 * N <= M:\n A += N\n M -= 2 * N\n print((A + M // 4))\nelse:\n print((M // 2))\n", "s, c = list(map(int, input().split()))\n\nif (2 * s == c):\n ans = s\n\nelif (2 * s > c):\n ans = c // 2\n\nelse:\n ans = s\n tar = c - 2 * s\n\n ans += tar // 4\n\n\nprint((int(ans)))\n", "N,M=map(int,input().split())\n\nif N >= 2*M:\n print(M//2)\n return\n \ndef f(x):\n return max(min(N+x, (M-2*x)//2),0)\n \ndelta = [-3,-2,-1,0,1,2,3]\nx = (M-2*N)//4\n\nans = 0\nfor i in range(7):\n x_ = max(0,x+delta[i])\n ans = max(ans,f(x_))\n\nprint(ans)", "n, m = list(map(int, input().split()))\n\nans = 0\nif n < m:\n if 2*n <= m:\n m = m -2*n\n ans += n\n \n ans += m//4\nelse:\n ans += m//2\n\nprint(ans)\n\n", "S, C = [int(n) for n in input().split(\" \")]\n\nif 2 * S >= C:\n print(min([S, int(C/2)]))\nelse:\n print(S + int((C - 2 * S) / 4))", "N, M = map(int, input().split())\n\nn = N\nm = M // 2\n\nans = 0\nif n >= m:\n ans += m\nelse:\n ans += n\n m -= n\n ans += m // 2\n \nprint(ans)", "s,c=map(int,input().split())\n\nif c>=s*2:\n ans=s+(c-s*2)//4\n \nelse:\n ans=c//2\n \nprint(ans)", "n, m = list(map(int, input().split()))\nres = 0\nif n > m // 2:\n res = m // 2\n print(res)\nelse:\n res = n\n n -= res\n m -= res * 2\n # \u3053\u3053\u3067n\u306f0\n res += m // 4\n print(res)\n", "#n = int(input())\nn, m = list(map(int, input().split()))\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n\nif n >= m//2:\n ans = m//2\nelse:\n m -= n*2\n ans = n + m//4\n\nprint(ans)\n", "n, m = map(int, input().split())\nans = 0\n\nif m < n * 2:\n ans = m//2\nelse:\n ans = n + (m-n*2)//4\n\nprint(ans)", "n, m = list(map(int, input().split()))\nif m >= 2*n:\n rem = m - 2*n\n print((n+rem//4))\nelse:\n print((m//2))\n", "n,m=map(int,input().split())\nans = 0\nif 2*n >= m:\n print(m//2)\nelse:\n ans += n\n m -= 2*n\n ans += m//4\n print(ans)", "s, c = map(int, input().split())\nprint((s + (c - s * 2) // 4, c // 2)[s * 2 >= c])", "N,M = list(map(int,input().split()))\nif 2*N >= M:\n ans = M//2\nelse:\n ans = N\n M = M - 2*N\n ans += M//4\nprint(ans)\n", "n,m=map(int, input().split())\nans=0\nif n>=m//2:\n ans=m//2\nelse:\n ans=n\n m-=n*2\n ans+=m//4\nprint(ans)", "n, m = map(int, input().split())\nm = (m//2) * 2\nif n > m//2:\n print(m//2)\nelse:\n print(n+(m-n*2)//4)", "n,m = map(int, input().split())\n\nif 2*n <= m: print(n + (m-2*n)//4)\nelse: print(m//2)", "N,M=map(int,input().split())\nprint(min(N,M//2)+max(M-N*2,0)//4)", "N,M = map(int,input().split())\nans = 0\n\nif 2*N >= M:\n ans = M//2\nelse:\n ans += N\n C = M-2*N\n ans += C//4\n \nprint(ans)", "n,m = map(int,input().split())\nans=0\nif m >= 2 and n >= 1:\n if m//2 >= n:\n ans+=n\n m = m - n*2\n ans+= m//4\n else:\n ans+= m//2\nprint(ans)", "N,M=list(map(int,input().split()))\nif 2*N>=M :\n print((M//2))\n return\nprint((N+(M-2*N)//4))\n", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 30 00:56:12 2020\n\n@author: liang\n\"\"\"\n\nN, M = map(int, input().split())\n\nif N*2 >= M:\n print(M//2)\nelse:\n print( N + (M-2*N)//4)", "n, m = list(map(int, input().split()))\n\nif n * 2 < m:\n print(n + (m - n * 2) // 4)\nelse:\n print(m // 2)", "#\n# abc055 c\n#\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"1 6\"\"\"\n output = \"\"\"2\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"12345 678901\"\"\"\n output = \"\"\"175897\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N, M = list(map(int, input().split()))\n\n if M >= 2*N:\n print((N+(M-2*N)//4))\n else:\n print((M//2))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "#!/usr/bin/env python\n\nn, m = list(map(int, input().split()))\n\nans = 0 \ncc = m//2\nif n >= cc: \n ans = cc\nelse:\n ans = (n+cc)//2\nprint(ans)\n", "def main():\n n, m = list(map(int, input().split()))\n ans = 0\n if m >= 2*n:\n ans += n\n m -= 2*n\n n = 0\n else:\n ans += m // 2\n m -= ans * 2\n ans += m // 4\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n, m = map(int, input().split())\nif n * 2 >= m:\n print(m // 2)\n return\nres = n\nm -= (2 * n)\nres += (m // 4)\nprint(res)", "N,M = map(int,input().split())\nif N <= M // 2:\n print(N + (M - 2 * N) // 4)\nelse:\n print(M // 2)", "N,M=map(int,input().split())\nans=0\nif M>=2*N:\n ans+=N\nelse:\n ans+=M//2\n print(ans)\n return\n\nM-=2*N\nans+=M//4\nprint(ans)", "N,M = map(int,input().split())\nprint(min(M//2,(2*N+M)//4))", "n,m=map(int,input().split())\nprint(min(n,m//2)+(m//2-min(n,m//2))//2)", "N, M = list(map(int, input().split()))\n\nif N * 2 > M:\n print((M // 2))\nelif N * 2 == M:\n print(N)\nelse:\n count = N\n M -= 2 * N\n count += (M // 4)\n print(count)\n", "s, c = list(map(int, input().split()))\ni = min(s, c//2)\nm = i\ns -= i\nc -= i*2\nif s == 0:\n m += c//4\n# print(s,c)\nprint(m)\n", "N,M=map(int,input().split())\n#S=N,C=M\nprint(min(((2*N)+M)//4,M//2))", "N,M = map(int,input().split())\nif N*2 > M:\n print(M//2)\nelse:\n M -= N*2\n print(N+M//4)", "import sys\n\nN, M=list(map(int,input().split()))\nMh=M//2\n\nif N>Mh:\n print(Mh)\n return\nelse:\n rem=M-2*N\n print((rem//4+N))\n", "n, m = list(map(int, input().split()))\nif 2 * n >= m:\n print((m // 2))\nelse:\n print((n + (m-(2*n))//4))\n", "N, M = map(int, input().split())\n\nif N < M:\n print(N + (M - 2 * N) // 4)\nelse:\n print(M // 2)", "s, c = map(int, input().split())\nans = 0\nans += min(s,c//2)\nres = c-min(s,c//2)*2\nans += res//4\nprint(ans)", "N, M = map(int, input().split())\n\nans = 0\nif(M//2 >= N):\n ans += N\n M = M - N*2 \n ans += M//4\n \nelse:\n ans += M//2\n\nprint(ans)"] | {"inputs": ["1 6\n", "12345 678901\n"], "outputs": ["2\n", "175897\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 14,930 | |
5e916720978e3ef223e6f7d423cd6741 | UNKNOWN | Joisino is about to compete in the final round of a certain programming competition.
In this contest, there are N problems, numbered 1 through N.
Joisino knows that it takes her T_i seconds to solve problem i(1β¦iβ¦N).
Also, there are M kinds of drinks offered to the contestants, numbered 1 through M.
If Joisino takes drink i(1β¦iβ¦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.
It does not affect the time to solve the other problems.
A contestant is allowed to take exactly one of the drinks before the start of the contest.
For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.
Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.
Your task is to write a program to calculate it instead of her.
-----Constraints-----
- All input values are integers.
- 1β¦Nβ¦100
- 1β¦T_iβ¦10^5
- 1β¦Mβ¦100
- 1β¦P_iβ¦N
- 1β¦X_iβ¦10^5
-----Input-----
The input is given from Standard Input in the following format:
N
T_1 T_2 ... T_N
M
P_1 X_1
P_2 X_2
:
P_M X_M
-----Output-----
For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.
-----Sample Input-----
3
2 1 4
2
1 1
2 3
-----Sample Output-----
6
9
If Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.
If Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds. | ["N = int(input())\nT = [int(TN) for TN in input().split()]\nSumT = sum(T)\nM = int(input())\nPX = [[] for TM in range(0,M)]\nfor TM in range(0,M):\n PX[TM] = [int(TPX) for TPX in input().split()]\nfor TM in range(0,M):\n print(SumT-T[PX[TM][0]-1]+PX[TM][1])", "n = int(input())\nli = list(map(int,input().split()))\nm = int(input())\nc = sum(li)\nfor i in range(m):\n a,b = map(int,input().split())\n print(c-li[a-1]+b)", "N=int(input())\nT=list(map(int,input().split()))\nM=int(input())\nP=[list(map(int, input().split())) for i in range(M)]\ntmp=0\nans=0\n\nfor i in range(M):\n tmp=0\n for j in range(len(T)):\n if j == P[i][0]-1:\n tmp +=P[i][1]\n else:\n tmp +=T[j]\n print(tmp)", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\ndr = [None] * m\ntime = sum(t)\nfor i in range(m):\n p, x = list(map(int, input().split()))\n p -= 1\n ans = time - t[p] + x\n print(ans)\n", "n = int(input())\na = list(map(int, input().split()))\nnum_drink = int(input())\n\nfor i in range(num_drink):\n P,X = map(int,input().split())\n A = a.copy()\n A[P-1] = X\n print(sum(A))", "N = int(input())\nT = list(map(int,input().split()))\nM = int(input())\nfor i in range(M):\n Pi,Xi=map(int,input().split())\n a = T[Pi-1]\n T[Pi-1] = Xi\n b = 0\n for j in range(N):\n b = b + T[j]\n print(b)\n T[Pi-1] = a", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\np = [list(map(int,input().split())) for i in range(m)]\nans = []\nfor num in p:\n print(sum(t) - t[num[0]-1] + num[1])", "n=int(input())\nl=[0]+list(map(int,input().split()))\nans=sum(l)\nfor i in range(int(input())):\n a,s=list(map(int,input().split()))\n print((ans-l[a]+s))\n", "n = int(input())\ndata_1 = list(map(int,input().split()))\nm = int(input())\ndata_2 = [input().split() for i in range(m)]\n\n\nfor i in range(m):\n sum = 0\n b = int(data_2[i][0]) - 1\n a = data_1[b]\n data_1[b] = int(data_2[i][1])\n for j in range(n):\n sum += data_1[j]\n print(sum)\n data_1[b] = a", "n = int(input())\nT = list(map(int, input().split()))\nm = int(input())\n\nsum_T = sum(T)\n\nfor i in range(m):\n p,x = list(map(int, input().split()))\n ans = sum_T - T[p-1] + x\n print(ans)\n\n", "num_problems = int(input())\nt = [int(n) for n in input().split()]\ntotal = sum(t)\nnum_drinks = int(input())\n\nfor i in range(num_drinks):\n m_id, m_val = [int(n) for n in input().split()]\n ans = total - t[m_id-1] + m_val\n print(ans)\n", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\n\nfor i in range(m):\n p, x = map(int, input().split())\n a = t[p-1]\n t[p-1] = x\n print(sum(t))\n t[p-1] = a", "N = int(input())\nT = list(map(int,input().split()))\nM = int(input())\n\nfor m in range(M):\n P,X = list(map(int,input().split()))\n T_ans = T.copy()\n T_ans[P-1] = X\n print((sum(T_ans)))\n", "n = int(input())\nt = list(map(int,input().split()))\nm = int(input())\ns = sum(t)\nfor i in range(m):\n p,x = map(int,input().split())\n print(s-t[p-1]+x)", "N = int(input())\ntimes = list(map(int, input().split()))\n\nM = int(input())\ndrinks = [tuple(map(int, input().split()))\n for _ in range(M)]\n\ntime_sum_raw = sum(times)\nfor pi, xi in drinks:\n print((time_sum_raw - times[pi - 1] + xi))\n", "import copy\nn = int(input())\nt = [int(x) for x in input().split()]\nm = int(input())\nfor i in range(m):\n p, x = map(int, input().split())\n t_temp = copy.copy(t)\n t_temp[p - 1] = x\n print(sum(t_temp))", "n = int(input())\ntimes = list(map(int, input().split()))\nm = int(input())\ndrinks = []\nfor _ in range(m):\n drink = list(map(int, input().split()))\n drinks.append(drink)\n\nfor drink in drinks:\n time = 0\n copy = times.copy()\n copy[drink[0]-1] = drink[1]\n for i in copy:\n time += i\n print(time)", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\nfor i in range(m):\n p,x = map(int, input().split())\n print(sum(t)-t[p-1]+x)", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\npx = [list(map(int, input().split())) for _ in range(m)]\nfor i in range(m):\n p, x = px[i][0], px[i][1]\n p -= 1\n cnt = 0\n for j in range(n):\n if p == j:\n cnt += x\n else :\n cnt += t[j]\n print(cnt)\n", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\np = [0 for _ in range(m)]\nx = [0 for _ in range(m)]\nfor i in range(m):\n p[i], x[i] = map(int, input().split())\n\ntemp = sum(t)\n\nfor i in range(m):\n print(temp + (x[i] - t[p[i]-1]))", "import sys\nimport math\nimport itertools\nimport collections\nimport heapq\nimport re\nimport numpy as np\nfrom functools import reduce\n\nrr = lambda: sys.stdin.readline().rstrip()\nrs = lambda: sys.stdin.readline().split()\nri = lambda: int(sys.stdin.readline())\nrm = lambda: list(map(int, sys.stdin.readline().split()))\nrl = lambda: list(map(int, sys.stdin.readline().split()))\ninf = float('inf')\nmod = 10**9 + 7\n\nn = ri()\nt = rl()\nsum_ = sum(t)\nm = ri()\nfor _ in range(m):\n p, x = rm()\n p -= 1\n print((sum_ - t[p] + x))\n\n\n\n\n\n\n\n\n\n\n\n", "n = int(input())\nt = list(map(int, input().split()))\ns = sum(t)\nm = int(input())\nfor i in range(m):\n p, x = list(map(int, input().split()))\n print((s - t[p -1] + x))\n", "n = int(input())\nt_lst = list(map(int, input().split()))\nm = int(input())\n\nfor i in range(m):\n p, x = list(map(int, input().split()))\n count = 0\n for j in range(n):\n if j == p-1:\n count += x\n else:\n count += t_lst[j]\n print(count)\n\n", "n = int(input())\nt = list(map(int, input().split()))\ntotal = sum(t)\nm = int(input())\nfor i in range(m):\n p, x = map(int, input().split())\n p -= 1\n print(total - t[p] + x)", "N=int(input())\nT=input()\nM=int(input())\nP=[input() for i in range(M)]\n\ndef ans050(N:int, T:str, M:int, P:list):\n T_list=list(map(int,T.split()))\n ans_list=[]\n for i in range(M):\n T_list = list(map(int, T.split()))\n P_list=list(map(int,P[i].split()))\n del T_list[P_list[0]-1]\n T_list.append(P_list[1])\n ans_list .append(sum(T_list))\n return ans_list\nfor i in range(M):\n print((ans050(N,T,M,P))[i])", "n=int(input())\nt=list(map(int,input().split()))\nm=int(input())\nfor j in range(m):\n ans=0\n p,x=map(int,input().split())\n for k in range(n):\n if p==k+1:\n ans += x\n else:\n ans += t[k]\n print(ans)", "N = int(input())\nT = list(map(int, input().split()))\nM = int(input())\nfor i in range(M):\n P, X = list(map(int, input().split()))\n Y = T[P-1]\n T[P-1] = X\n print((sum(T)))\n T[P-1] = Y\n", "n = int(input())\narr = list(map(int, input().split()))\nm = int(input())\n\nfor _ in range(m):\n p, x = list(map(int, input().split()))\n print((sum(arr[0:p - 1]) + sum(arr[p:]) + x))\n", "import sys,bisect\n\nfrom sys import stdin,stdout\n\nfrom bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right\n\nfrom math import gcd,ceil,floor,sqrt\n\nfrom collections import Counter,defaultdict,deque,OrderedDict\n\nfrom queue import Queue,PriorityQueue\n\nfrom string import ascii_lowercase\n\n\nsys.setrecursionlimit(10**6)\nINF = float('inf')\nMOD = 998244353\nmod = 10**9+7\n\ndef isPrime(n):\n if (n <= 1) :return False\n if (n <= 3) :return True\n if (n%2 == 0 or n%3 == 0):return False\n for i in range(5,ceil(sqrt(n))+1,6):\n if (n%i==0 or n%(i+2)==0):\n return False\n return True\n\ndef st():\n return list(stdin.readline().strip())\n\ndef inp():\n return int(stdin.readline())\n\ndef li():\n return list(map(int,stdin.readline().split()))\n\ndef mp():\n return list(map(int,stdin.readline().split()))\n\ndef pr(n):\n stdout.write(str(n)+\"\\n\")\n \ndef DFS(dictionary,vertex,visited):\n visited[vertex]=True\n stack=[vertex]\n print(vertex)\n while stack:\n a=stack.pop()\n for i in dictionary[a]:\n if not visited[i]:\n print(i)\n visited[i]=True\n stack.append(i)\n\n\ndef BFS(dictionary, vertex,visited):\n visited[vertex]=True\n q=deque()\n q.append(vertex)\n while q:\n a=q.popleft()\n for i in dictionary[a]:\n if not visited[i]:\n visited[i]=True\n q.append(i)\n print(i)\n\n \n\n\ndef soe(limit):\n l=[1]*(limit+1)\n l[0]=0\n l[1]=0\n prime=[]\n for i in range(2,limit+1):\n if l[i]:\n for j in range(i*i,limit+1,i):\n l[j]=0\n \n for i in range(2,limit+1):\n if l[i]:\n prime.append(i)\n return prime\n\ndef segsoe(low,high):\n limit=int(high**0.5)+1\n prime=soe(limit)\n n=high-low+1\n l=[0]*(n+1)\n for i in range(len(prime)):\n lowlimit=(low//prime[i])*prime[i]\n if lowlimit<low:\n lowlimit+=prime[i]\n if lowlimit==prime[i]:\n lowlimit+=prime[i]\n for j in range(lowlimit,high+1,prime[i]):\n l[j-low]=1\n for i in range(low,high+1):\n if not l[i-low]:\n if i!=1:\n print(i)\n \ndef gcd(a,b):\n while b:\n a=a%b\n b,a=a,b\n return a\n\ndef power(a,n):\n r=1\n while n:\n if n&1:\n r=(r*a)\n a*=a\n n=n>>1\n return r\n \n \ndef solve():\n n=inp()\n l=li()\n s=sum(l)\n d={i+1:l[i] for i in range(n)}\n m=inp()\n for i in range(m):\n x=s\n a,b=mp()\n x-=d[a]\n x+=b\n pr(x)\n\n\nfor _ in range(1):\n solve()\n \n", "N = int(input())\nT = list(map(int, input().split()))\nM = int(input())\nP = []\nX = []\nfor i in range(M):\n p, x = list(map(int, input().split()))\n P.append(p)\n X.append(x)\n\nSum = sum(T)\nfor i in range(M):\n print((Sum - T[P[i] - 1] + X[i]))\n", "input();t=list(map(int,input().split()));T=sum(t)\nprint(*[T-t[i-1]+j for i,j in [list(map(int,input().split())) for _ in range(int(input()))]],sep='\\n')", "n = int(input())\ntl = list(map(int, input().split()))\ntime = sum(tl)\nm = int(input())\n\nfor _ in range(m):\n p, x = list(map(int, input().split()))\n print((time - (tl[p-1]-x)))\n", "#!/usr/bin/env python3\nn=int(input())\nt=list(map(int,input().split()))\nm=int(input())\nfor _ in range(m):\n p,x=map(int,input().split())\n t_true=t[p-1]\n t[p-1]=x\n print(sum(t))\n t[p-1]=t_true", "N = input()\nT = [int(x) for x in input().split()]\nM = int(input())\nDrink = [tuple(map(int,input().split())) for _ in range(M)]\nsumT = sum(T)\nfor p,x in Drink:\n print(sumT-T[p-1]+x)", "n=int(input())\nl=list(map(int,input().split()))\nm=int(input())\n\nsum_l=sum(l)\n\nfor i in range(m):\n p,x=list(map(int,input().split()))\n ans=sum_l-l[p-1]+x\n print(ans)\n", "n = int(input())\nt_lst = list(map(int, input().split()))\nm = int(input())\npx_lst = [list(map(int, input().split())) for _ in range(m)]\n\ntime_lst = []\nfor i in range(m):\n problem = px_lst[i][0] - 1\n time = px_lst[i][1]\n before = t_lst[problem]\n t_lst[problem] = time\n time_lst.append(sum(t_lst))\n t_lst[problem] = before\n\nfor i in range(m):\n print(time_lst[i])", "import copy\n\ndef main():\n N = int(input())\n T = list(map(int, input().split()))\n M = int(input())\n PX = []\n for i in range(M):\n P, X = list(map(int, input().split()))\n tmp = copy.copy(T)\n tmp[P-1] = X\n print((sum(tmp)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "import copy\nn = int(input())\nli = list(map(int,input().split()))\nlis = copy.copy(li)\nm = int(input())\ndri = [list(map(int,input().split())) for i in range(m)]\nfor i in range(len(dri)):\n lis = copy.copy(li)\n lis[dri[i][0]-1] = dri[i][1]\n print(sum(lis))", "a=int(input())\nb=list(map(int,input().split()))\nc=int(input())\nd=[input().split() for i in range(c)]\nfor i in range(c):\n print(sum(b)-b[int(d[i][0])-1]+int(d[i][1]))", "#!/usr/bin/env python3\nN = int(input())\nT = list(map(int, input().split()))\nM = int(input())\nP = [0] * M\nX = [0] * M\nfor i in range(M):\n P[i], X[i] = list(map(int, input().split()))\n\nfor i in range(M):\n ans = 0\n ans += sum(T[:P[i] - 1])\n ans += X[i]\n ans += sum(T[P[i]:])\n print(ans)\n", "N = int(input())\nT = list(map(int,input().split()))\n\nt_sum = sum(T)\n\nM = int(input())\nfor _ in range(M):\n P,X = map(int,input().split())\n print(t_sum - (T[P-1] - X))", "N = int(input())\nT = list(map(int, input().split()))\nM = int(input())\nfor n in range(M):\n P, X = map(int, input().split())\n T_copied = T.copy()\n T_copied[P-1] = X\n print(sum(T_copied))", "n = int(input())\nt = list(map(int,input().split()))\nm = int(input())\na,b = 0,0\nfor _ in range(m):\n a,b = map(int,input().split())\n print(sum(t) - t[a-1] + b)", "n = int(input())\nt = tuple(map(int,input().split()))\nm = int(input())\nx = [list(map(int,input().split())) for _ in range(m)]\n\ni = 0\nfor x[i] in x:\n l = list(t)\n j = x[i][0] - 1 #\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\n k = x[i][1] #\u7f6e\u63db\u5143\n i += i\n l[j] = k\n print(sum(l))", "n = int(input())\nt = [int(i) for i in input().split()] #\u5206\u5272\u3057\u305f\u6587\u5b57\u5217\u3092\u9806\u7e70\u308a\u306bint\u306b\u5909\u63db\u3057\u3066\u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\nm = int(input())\n\nfor i in range(m):\n sum = 0\n count = 1\n p, x = list(map(int, input().split()))\n for j in t:\n if(p == count):\n sum += x\n else:\n sum += j\n count += 1\n print(sum)\n", "n = int(input())\nt = [int(s) for s in input().split()]\nm = int(input())\ntotal = sum(t)\nans = []\nfor i in range(m):\n p, x = map(int, input().split())\n ans.append(total - t[p - 1] + x)\n\nfor a in ans:\n print(a)", "a=int(input())\nb=list(map(int,input().split()))\nc=int(input())\nd=[]\nfor i in range(c):\n d.append(list(map(int,input().split())))\n\nfor i in range(c):\n f=b.copy()\n p=d[i][0]-1\n f[p]=d[i][1]\n print((sum(f)))\n", "n = int(input())\nt = list(map(int, input().split()))\nst = sum(t)\nm = int(input())\nfor i in range(m):\n p, x = list(map(int, input().split()))\n print((st - t[p - 1] + x))\n", "import copy\nn = int(input())\nT = list(map(int,input().split()))\nm = int(input())\n\nfor _ in range(m):\n A = copy.copy(T)\n a,b = map(int,input().split())\n A[a-1] = b\n print(sum(A))", "# N\u554f\u306e\u554f\u984c\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u308b\nN = int(input())\n# \u554f\u984c\u3092\u89e3\u304f\u306e\u306b\u304b\u304b\u308b\u6642\u9593\nT = list(map(int, input().split()))\n\n# \u30c9\u30ea\u30f3\u30af\u306e\u7a2e\u985eM\nM = int(input())\n# \u30c9\u30ea\u30f3\u30af\u3092\u98f2\u3093\u3060\u5834\u5408\u306e\u6642\u9593\u3092\u30ea\u30b9\u30c8\u306b\u683c\u7d0d\u3059\u308b\nX = []\n\n# \u307e\u305a\u306f\u30c9\u30ea\u30f3\u30af\u3092\u98f2\u3093\u3060\u5834\u5408\u306e\u6642\u9593\u3092X\u306b\u683c\u7d0d\u3059\u308b\nfor i in range(M):\n X.append(list(map(int,input().split())))\n X[i][0] = X[i][0]-1\n\nY = []\n# \u305d\u308c\u305e\u308c\u306e\u554f\u984c\u306e\u89e3\u304f\u6642\u9593\u3092\u53d6\u5f97\u3059\u308b\nfor i in range(N):\n Y.append(T[i])\n \nfor i in range(len(X)):\n Y_copy = Y.copy()\n Y_copy[X[i][0]] = X[i][1]\n print(sum(Y_copy))", "n = int(input())\np = list(map(int, input().split()))\nk = int(input())\nfor i in range(k):\n a, b = list(map(int, input().split()))\n c = p[a-1]\n p[a-1] = b\n print((sum(p)))\n p[a-1] = c\n", "quiznum=int(input())\ntimeline=input().split(\" \")\ntimeline=[int(n) for n in timeline]\n#print(timeline)\ntime_0=0\nfor i in range(quiznum):\n time_0+=timeline[i]\n#print(time_0)\n\nmedinum=int(input())\nfor i in range(medinum):\n temp_line=input().split(\" \")\n a=int(temp_line[0])\n b=int(temp_line[1])\n time=time_0 - timeline[a-1] + b\n print(time)", "n = int(input())\nts = list(map(int, input().split()))\nm = int(input())\nfor i in range(m):\n p, x = map(int, input().split())\n print(sum(ts) - ts[p-1] + x)", "n=int(input())\nt=list(map(int,input().split()))\nm=int(input())\nfor i in range(m):\n p,x=map(int,input().split())\n print(sum(t)-(t[p-1]-x))", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\n\nfor i in range(m):\n p,x = list(map(int, input().split()))\n print((sum(t) - t[p-1] + x))\n", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\nimport copy\n\ndef main():\n questions=[]\n dp=[]\n n = int(input())\n questions=list(map(int,input().split()))\n m = int(input())\n drinks=[list(map(int,input().split())) for _ in range(m)]\n for drink in drinks:\n dp=copy.deepcopy(questions)\n dp[drink[0]-1]=drink[1]\n print(sum(dp))\n \ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\nt = [0] + list(map(int, input().split()))\ns = sum(t)\nm = int(input())\nfor _ in range(m):\n p,x = list(map(int, input().split()))\n print((s - t[p] + x))\n", "N = int(input())\nT = list(map(int, input().split()))\nM = int(input())\nP, X = [0] * M, [0] * M\nfor i in range(M):\n P[i], X[i] = map(int, input().split())\n\nfor i in range(M):\n t_sum = X[i]\n for j in range(N):\n if j == P[i] - 1:\n continue\n t_sum += T[j]\n print(t_sum)", "n=int(input())\ntl=list(map(int,input().split()))\nm=int(input())\npxl=[list(map(int,input().split())) for _ in range(m)]\ns=sum(tl)\nfor p,x in pxl:\n print((s-tl[p-1]+x))\n", "n=int(input())\nt=list(map(int,input().split()))\nfor _ in range(int(input())):\n p,x=map(int,input().split())\n ans=0\n for i in range(n):\n if p-1==i:\n ans+=x\n else:\n ans+=t[i]\n print(ans)", "n=int(input())\nt=list(map(int,input().split()))\nm=int(input())\nfor i in range(m):\n p,x=map(int,input().split())\n y=t[p-1]\n t[p-1]=x\n print(sum(t))\n t[p-1]=y", "input();t=[*map(int,input().split())];T=sum(t)\nprint(*[T-t[i-1]+j for i,j in [[*map(int,input().split())] for _ in range(int(input()))]],sep='\\n')", "N = int(input())\nT = list(map(int, input().split()))\nM = int(input())\nfor i in range(M):\n p, x = list(map(int, input().split()))\n s = sum(T) - T[p-1] + x\n print(s)\n \n", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\nfor i in range(m):\n p, x = map(int, input().split())\n s = t[p-1]\n t[p-1] = x\n print(sum(t))\n t[p-1] = s", "N = int(input())\nT = list(map(int, input().split()))\nans = sum(T)\nM = int(input())\nfor i in range(M):\n P, X = map(int, input().split())\n print(ans - T[P-1] + X)", "N=int(input())\nT=list(map(int,input().split()))\nM=int(input())\ndrink=[]\nfor i in range(M):\n P,X=map(int,input().split())\n drink.append([P,X])\n \nfor j in range(len(drink)):\n P,X=drink[j]\n time=X+sum(T)-T[P-1]\n print(time)", "import copy\n\nn = int(input())\nt = [int(x) for x in input().split()]\nm = int(input())\np = []\nfor i in range(m):\n p.append([int(x) for x in input().split()])\n\nfor i in range(m):\n r = copy.copy(t)\n r[p[i][0]-1] = p[i][1]\n print(sum(r))", "import copy\nn=int(input())\nt=list(map(int,input().split()))\nm=int(input())\nfor i in range(m):\n a,b=map(int,input().split())\n total=copy.copy(t)\n total[a-1]=b\n print(sum(total))", "n = int(input())\nt = list(map(int,input().split()))\nm = int(input())\nfor i in range(m):\n p,x = list(map(int,input().split()))\n save = t[p-1]\n t[p-1] = x\n print((sum(t)))\n t[p-1] = save\n", "n=int(input())\nt =list(map(int, input().split()))\nm=int(input())\nfor i in range(m):\n p,x=map(int,input().split())\n q = sum(t) - (t[p-1] - x)\n print(q)", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\nfor i in range(m):\n p, x = map(int, input().split())\n print(sum(t) - t[p-1] + x)", "N=int(input())#\u554f\u984c\u306e\u6570\nT=list(map(int,input().split()))#\u554f\u984c\u3092\u89e3\u304f\u306e\u306b\u304b\u304b\u308b\u6642\u9593\nM=int(input())#\u30c9\u30ea\u30f3\u30af\u306e\u7a2e\u985e\u306e\u6570\nfor i in range(1,M+1):\n tmp=list(map(int,input().split()))\n tmp2=T[tmp[0]-1]\n T[tmp[0]-1]=tmp[1]\n print(sum(T))\n T[tmp[0]-1]=tmp2", "N = int(input())\nT = list(map(int, input().split()))\nsumT = sum(T)\nM = int(input())\nfor i in range(M):\n P, X = map(int, input().split())\n ans = sumT-T[P-1]+X\n print(ans)", "N = int(input())\nT = input().split()\nM = int(input())\n\nfor i in range(N):\n T[i] = int(T[i])\n\nS = sum(T)\n\nfor i in range(M):\n l = input().split()\n print(S - (T[int(l[0]) - 1] - int(l[1])))", "N = int(input())\nT = list(map(int, input().split()))\nM = int(input())\nL = []\nres = []\nfor i in range(M):\n P, X = list(map(int, input().split()))\n buf = []\n for j in range(len(T)):\n if P == j+1:\n buf.append(X)\n else:\n buf.append(T[j])\n res.append(sum(buf))\n\nfor i in res:\n print(i)\n", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\na = []\nfor _ in range(m):\n p, x = map(int, input().split())\n u = t[:]\n u[p - 1] = x\n a.append(sum(u))\nfor i in range(m):\n print(a[i])", "n=int(input())\nt=list(map(int,input().split()))\nm=int(input())\npx=[]\nfor _ in range(m):\n p,x=map(int,input().split())\n px.append((p-1,x))\nfor i in range(m):\n ans=0\n p,x=px[i]\n for j in range(n):\n if j==p:\n ans+=x\n else:\n ans+=t[j]\n print(ans)", "n,t=int(input()),list(map(int,input().split()));T=sum(t)\nprint(*[T-t[i-1]+j for i,j in [list(map(int,input().split())) for _ in range(int(input()))]],sep='\\n')", "n = input()\nt_raw = list(map(int, input().split()))\nm = int(input())\nfor _ in range(m):\n t = t_raw.copy()\n p, x = map(int, input().split())\n t[p-1] = x\n print(sum(t))", "N = int(input())\n*T, = map(int, input().split())\nM = int(input())\npx = [list(map(int, input().split())) for _ in range(M)]\n\nfor i in range(M):\n pi = px[i][0] - 1\n print(sum(T) - T[pi] + px[i][1])", "N = int(input())\ntimes = list(map(int,input().split()))\nM = int(input())\ndrinks = []\nfor _ in range(M):\n drinks.append(list(map(int,input().split())))\n\nfor drink in drinks:\n total = 0\n for j in range(N):\n if drink[0] == j+1:\n total += drink[1]\n else:\n total += times[j]\n print(total)", "n=int(input())\nt=list(map(int,input().split()))\nm=int(input())\ns=sum(t)\nfor i in range(m):\n p,x=map(int,input().split())\n print(s+x-t[p-1])", "n = int(input())\nt = list(map(int, input().split()))\nm = int(input())\ndrink = [list(map(int, input().split())) for _ in range(m)]\nfor p, x in drink:\n print((sum(t) - t[p - 1] + x))\n", "N = int(input())\nT = list(map(int, input().split()))\nM = int(input())\nL = []\nfor _ in range(M):\n p, x = list(map(int, input().split()))\n L.append([p, x])\n\nfor i in range(M):\n sum_num = 0\n for j in range(N):\n if L[i][0] - 1 == j:\n sum_num += L[i][1]\n else:\n sum_num += T[j]\n print(sum_num)\n", "N = int(input())\nT = list(map(int,input().split()))\nM =int(input())\npx = [list(map(int,input().split())) for i in range(M)]\n\nsumTime = sum(T)\n\nfor i in range(M):\n print(sumTime-T[px[i][0]-1]+px[i][1])", "n = int(input())\ntimeList = list(map(int, input().split()))\nm = int(input())\nargList = [list(map(int, input().split())) for _ in range(m)]\n\n#\u666e\u901a\u306b\u3084\u308b\u3068\nres_time = sum(timeList)\n\nfor a in argList:\n\n #a[0]\u554f\u76ee\u3092\u89e3\u304f\u306e\u306b\u3000a[1]\u79d2\u304b\u304b\u308b\u3088\n print((res_time - timeList[a[0]-1] + a[1]))\n\n", "n = int(input())\n\nt = list(map(int,input().split()))\n\nm = int(input())\n\nfor i in range(m):\n\tp,x = list(map(int,input().split()))\n\ttmpt = t[p-1] \n\tt[p-1] = x\n\tprint((sum(t)))\n\tt[p-1] = tmpt\n\t\n", "N = int(input())\nli = list(map(int, input().split()))\nM = int(input())\nan = sum(li)\nfor i in range(M):\n p,x = map(int, input().split())\n h = x - li[p-1]\n print(sum(li) + h)", "N=int(input())\nT=list(map(int,input().split()))\nM=int(input())\nx=sum(T)\nfor _ in range(M):\n P,X=list(map(int,input().split()))\n print((x+X-T[P-1]))\n", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lint_dec(): return list(map(lambda x:int(x) - 1, input().split()))\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nN = ii()\nT = lint()\nM = ii()\ntotal = sum(T)\n\nfor _ in range(M):\n P, X = lint()\n print(total - T[P - 1] + X)", "n = int(input())\nt_l = list(map(int, input().split()))\nm = int(input())\nimport copy\nfor _ in range(m):\n k, v = map(int, input().split())\n tmp_t = copy.deepcopy(t_l)\n tmp_t[k-1] = v\n print(sum(tmp_t))", "n = int(input())\nt = list(map(int,input().split()))\nm = int(input())\npx = [list(map(int,input().split())) for _ in range(m)]\nfor i in px:\n print((sum(t) - t[i[0]-1] + i[1]))\n", "n = int(input())\nt = list(map(int,input().split()))\nm = int(input())\nfor i in range(m):\n a,b = map(int,input().split())\n T = sum(t) - t[a-1] + b\n print(T)", "N = int(input())\nT = list(map(int,input().split()))\nM = int(input())\nans = sum(T)\ncopy = ans\nfor i in range(M):\n p,x = list(map(int,input().split()))\n p -= 1\n ans -= T[p]\n ans += x\n print(ans)\n ans = copy\n\n \n", "N = int(input())\n\nT = list(map(int, input().split()))\nM = int(input())\n\nfor _ in range(M):\n p, x = tuple(map(int, input().split()))\n tmp_num = T[p-1]\n T[p-1] = x\n print(sum(T))\n T[p-1] = tmp_num", "N = int(input())\nT = list(map(int,input().split()))\nsum = 0\nfor _ in range(N):\n sum += T[_] \nM = int(input())\nfor i in range(M):\n a,b = list(map(int,input().split()))\n print((sum + b - T[a - 1]))\n \n", "n = int(input())\nt = list(map(int,input().split()))\ns = sum(t)\nm = int(input())\nfor i in range(m):\n p,x = map(int,input().split())\n print(s+(x-t[p-1]))", "from typing import List\n\n\ndef answer(n: int, t: List[int], m: int, pxs: List[List[int]]) -> str:\n result = []\n for px in pxs:\n t_copy = t.copy()\n t_copy[px[0] - 1] = px[1]\n result.append(str(sum(t_copy)))\n\n return '\\n'.join(result)\n\n\ndef main():\n n = int(input())\n t = list(map(int, input().split()))\n m = int(input())\n pxs = [list(map(int, input().split())) for _ in range(m)]\n print((answer(n, t, m, pxs)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nT = list(map(int, input().split()))\nm = int(input())\nD = [tuple(map(int, input().split())) for _ in range(m)]\n\nsum_T = sum(T)\nfor i in range(m):\n print((sum_T - T[D[i][0] - 1] + D[i][1]))\n"] | {"inputs": ["3\n2 1 4\n2\n1 1\n2 3\n", "5\n7 2 3 8 5\n3\n4 2\n1 7\n4 13\n"], "outputs": ["6\n9\n", "19\n25\n30\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 27,620 | |
c7aed97e00cd42ba6e04b491ddc81328 | UNKNOWN | Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.
She is shopping, and now paying at the cashier.
Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).
However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.
Find the amount of money that she will hand to the cashier.
-----Constraints-----
- 1 β¦ N < 10000
- 1 β¦ K < 10
- 0 β¦ D_1 < D_2 < β¦ < D_Kβ¦9
- \{D_1,D_2,...,D_K\} β \{1,2,3,4,5,6,7,8,9\}
-----Input-----
The input is given from Standard Input in the following format:
N K
D_1 D_2 β¦ D_K
-----Output-----
Print the amount of money that Iroha will hand to the cashier.
-----Sample Input-----
1000 8
1 3 4 5 6 7 8 9
-----Sample Output-----
2000
She dislikes all digits except 0 and 2.
The smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000. | ["import itertools\n\ndef cal(N, target_num, keta):\n answer = float('inf')\n for p in itertools.product(target_num, repeat=keta):\n temp = 0\n for i, num in enumerate(p):\n temp += num * 10**i\n \n if temp >= N:\n answer = min(answer, temp)\n\n return answer\n\ndef __starting_point():\n N, K = map(int, input().split()) # N\u5186\u306e\u54c1\u7269\u3001K\u500b\u306e\u5acc\u3044\u306a\u6570\u5b57\n D = set(list(map(int, input().split()))) # \u5acc\u3044\u306a\u6570\u5b57\u306e\u30ea\u30b9\u30c8\n base = set(range(10))\n\n target_num = base - D\n keta = len(str(N))\n\n answer = min(cal(N, target_num, keta), cal(N, target_num, keta+1))\n\n print(answer)\n__starting_point()", "import sys\nimport numpy as np\nread = sys.stdin.readline\n\n\ndef main(n, k, a):\n for i in np.arange(n, 100000):\n ok = True\n j = i\n while j:\n ok &= j % 10 not in a\n j //= 10\n if ok:\n print(i)\n break\n\n\ndef __starting_point():\n n, k = np.fromstring(read(), dtype=np.int32, sep=' ')\n a = np.fromstring(read(), dtype=np.int32, sep=' ')\n main(n, k, a)\n\n__starting_point()", "N, K = map(int, input().split())\nunlike_list = set(map(str, input().split()))\n\ndef judge(num):\n for i in str(num):\n if i in unlike_list:\n return False\n return True\n\nans = False\nwhile not ans:\n if judge(N):\n ans = True\n else:\n N += 1\n\nprint(N)", "n, k = list(map(int,input().split()))\nd = list(map(int,input().split()))\n\nwhile n < 10**5:\n x = str(n)\n if all(int(i) not in d for i in x):\n print(n)\n return\n n += 1\n", "n, k = list(map(int, input().split()))\nd = list(input().split())\nans = n\nfind = False\nwhile find == False:\n p = str(ans)\n find = True\n for i in range(len(p)):\n if p[i] in d:\n find = False\n break\n if find == False:\n ans += 1\n\nprint(ans)\n", "import sys\n\nN,K=list(map(int,input().split()))\nD=list(map(int,input().split()))\n\n\nwhile True:\n for x in [int(n) for n in str(N)]:\n if x in D:\n break\n else:\n print(N)\n return\n N+=1\n", "total, k = list(map(int, input().split()))\n\nd = list(map(int, input().split()))\n\ndef total_to_digits(total):\n return list(map(int, list(str(total))))\n\ndef find_lowest_denomination(total, d):\n res = None\n for i in range(total, 99999):\n digits = list(total_to_digits(i))\n if not (set(digits) & set(d)):\n print(i)\n return\n\n\nfind_lowest_denomination(total, d)\n", "n, k = list(map(int,input().split()))\na = list(map(str,input().split()))\n\n\nwhile True:\n \n for j in str(n):\n \n if j in a:\n break\n else:\n break\n n += 1 \n \nprint(n)", "def dfs(A: list):\n if len(A) > len(str(n))+1:\n return\n if len(A) and (x := int(\"\".join(A))) >= n and ans[0] > x:\n ans[0] = x\n return\n\n for v in d:\n if v == \"0\" and len(A) == 0:\n next\n A.append(v)\n dfs(A)\n A.pop()\n\n\nn, k = list(map(int, input().split()))\nd = sorted(list(set([str(i) for i in range(10)]) - set(input().split())))\nans = [10**10]\ndfs([])\nprint((ans[0]))\n", "n, k= input().split()\nl = list(map(int,input().split()))\ncheckNum=[i for i in range(11)]\n\ndef find(x):\n while x!=checkNum[x]:\n checkNum[x]=checkNum[checkNum[x]]\n x=checkNum[x]\n return x\n\nfor i in l:\n checkNum[find(i)]=checkNum[find(i+1)]\n\nfin=\"\"\nfor i in range(len(n)):\n first=int(n[i])\n k=find(first)\n if k==first:\n fin+=str(k)\n else:\n if k!=10:\n fin=str(k)+str(find(0))*(len(n)-i-1)\n else:\n fin=str(find(1))+str(find(0))*len(n)\n break\n\nprint(fin)\n", "N,K=list(map(int,input().split()))\nD=[int(x) for x in input().split()]\nD=set(D)\nkouho=N\nwhile(1):\n lenkouho=len(str(kouho))\n flag=1\n for i in range(lenkouho):\n if int(str(kouho)[i]) in D:\n flag=0\n if flag==1:\n print(kouho)\n break\n kouho+=1\n", "#\n# abc042 c\n#\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"1000 8\n1 3 4 5 6 7 8 9\"\"\"\n output = \"\"\"2000\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"9999 1\n0\"\"\"\n output = \"\"\"9999\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N, K = list(map(int, input().split()))\n D = list(input().split())\n\n for i in range(N, 10*N+1):\n for d in D:\n if str(i).count(d) != 0:\n break\n else:\n print(i)\n break\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "N, K = map(int, input().split())\nD = list(map(int, input().split()))\nnum = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\nnum = str(list(set(num) ^ set(D)))\n\nans = str(N)\nclear = 0\n\nwhile clear == 0:\n for i in range(len(ans)):\n if not ans[i] in num:\n break\n if i == len(ans) - 1:\n clear += 1 \n ans = str(int(ans) + 1)\n\nprint(int(ans) - 1)", "N, K = map(int, input().split())\nD = list(input().split())\n\nwhile True:\n n = str(N)\n for i in range(K):\n f = 0\n if D[i] in n:\n N += 1\n f = 1\n break\n if f == 0:\n break\n\nprint(N)", "N, K = map(int, input().split())\nD = list(map(int, input().split()))\n\n\ndef f(n, x):\n if n==0:\n if x >= N:\n print(x)\n return\n return\n \n for i in range(10):\n if i in D:\n continue\n f(n-1, x*10+i)\n\nf(len(str(N)), 0)\nans = \"\"\nfor i in range(1, 10):\n if i not in D:\n ans = str(i)\n break\nfor i in range(10):\n if i not in D:\n ans += str(i)*len(str(N))\n break\nprint(ans)", "#\u5024\u6bb5\u3001\u5acc\u3044\u306a\u6570\u5b57\u306e\u6570\nN, K = map(int, input().split())\n#\u5acc\u3044\u306a\u6570\u5b57\nhate_num = list(map(int, input().split()))\n#\u30eb\u30fc\u30d7\u7528\ni = N\n\nwhile 1:\n #\u652f\u6255\u3046\u91d1\u984d\u306b\u5165\u3063\u3066\u3044\u308b\u6570\u5b57\u306e\u629c\u304d\u51fa\u3057\n ans = list({int(i) for i in list(str(i))})\n #\u652f\u6255\u3046\u91d1\u984d\u306b\u5acc\u3044\u306a\u6570\u5b57\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d\n for j in ans:\n #\u5acc\u3044\u306a\u6570\u5b57\u304c\u3042\u3063\u305f\u6642\n if j in hate_num: \n break\n #\u5acc\u3044\u306a\u6570\u5b57\u304c\u306a\u304b\u3063\u305f\u6642\n else:\n print(i)\n break\n i += 1", "n, k = input().split()\nd = list(map(int, input().split()))\n\na = []\n\nfor i in range(10):\n if i not in d:\n a.append(i)\n\nn = list(map(int, list(n)))\n\nfor i in range(len(n)):\n if n[i] in d:\n ind = i\n\n done = False\n while not done:\n for j in range(n[ind]+1, 10):\n if j in a:\n n[ind] = j\n done = True\n break\n\n if not done:\n ind -= 1\n\n if ind < 0:\n n.insert(0, a[1] if a[0] == 0 else a[0])\n ind = 0\n done = True\n\n for j in range(ind+1, len(n)):\n n[j] = a[0]\n\n break\n\nprint(\"\".join(list(map(str, n))))", "n,k = list(map(int,input().split()))\nif k == 0:\n print(n)\n return\ndislike = list(input().split())\n \nans = n-1\nflag = 1\nwhile flag == 1:\n ans+=1\n flag = 0\n for i in str(ans):\n if i in dislike:\n flag = 1\n break\nprint(ans)\n", "def testa(n,d):\n for i in d:\n if str(i) in str(n): return 0\n return 1\n\nn,k = [int(i) for i in input().split()]\nd = [int(i) for i in input().split()]\n\nwhile not testa(n,d): n+=1\nprint(n)\n", "N, K = map(int, input().split())\nbl = set(input().split())\n\nwhile True:\n if len(set(str(N)) & bl) != 0:\n N += 1\n else:\n print(N)\n break", "N, K = list(map(int,input().split()))\nD = set(input().split())\n\nfor k in range(N,10**9):\n f = 1\n for e in str(k):\n if e in D:\n f = 0\n break\n if f == 1:\n print(k)\n return\n", "def dfs(i,num_str):\n nonlocal ans_list\n if i==len(str(n)):\n ans_list.append(int(num_str))\n if len(num_list)==1:\n ans_list.append(int(num_list[0]+num_str))\n else:\n if num_list[0]=='0':\n ans_list.append(int(num_list[1]+num_str))\n else: \n ans_list.append(int(num_list[0]+num_str))\n return\n else:\n for j in num_list:\n dfs(i+1,num_str+j)\n\nn,k = map(int,input().split())\nd = list(map(int,input().split()))\n\nans_list = []\nnum_list = []\nfor i in range(10):\n if i not in d:\n num_list.append(str(i))\n \n#print(num_list)\n\ndfs(0,'')\nsort_list = sorted(ans_list)\n#print(sort_list[10:])\n\nfor i in sort_list:\n if n<=i:\n print(int(i))\n break", "n, k = map(int, input().split())\nD = set(input())\nfor i in range(n, 10**5):\n if set(str(i)) & D == set():\n print(i)\n return", "#\u5024\u6bb5\u3001\u5acc\u3044\u306a\u6570\u5b57\u306e\u6570\nN, K = map(int, input().split())\n#\u5acc\u3044\u306a\u6570\u5b57\nhate_num = list(map(int, input().split()))\n#\u30eb\u30fc\u30d7\u7528\ni = N\n\nwhile 1:\n #\u652f\u6255\u3046\u91d1\u984d\u306b\u5165\u3063\u3066\u3044\u308b\u6570\u5b57\u306e\u629c\u304d\u51fa\u3057\n ans = list({int(x) for x in list(str(i))})\n #\u652f\u6255\u3046\u91d1\u984d\u306b\u5acc\u3044\u306a\u6570\u5b57\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u304b\u78ba\u8a8d\n for j in ans:\n #\u5acc\u3044\u306a\u6570\u5b57\u304c\u3042\u3063\u305f\u6642\n if j in hate_num: \n break\n #\u5acc\u3044\u306a\u6570\u5b57\u304c\u306a\u304b\u3063\u305f\u6642\n else:\n print(i)\n break\n i += 1", "i3=lambda : map(int,input().split())\n\nN,K=i3()\n*D,=i3()\n\nD=set(D)\n\nfor i in range(N,10**5):\n ans=1\n for s in str(i):\n if int(s) in D:\n ans=0\n break\n if ans : break\nprint(i)", "import sys\n\n\ndef check(pay, like):\n str_pay = str(pay)\n like = ''.join(like)\n for p in str_pay:\n for lk in like:\n if p == lk:\n return False\n\n return True\n\nN, K = list(map(int, input().split()))\n\nD = []\nD = list(map(int, input().split()))\nstr_D = []\n\nfor s in D:\n str_D.append(str(s))\n\npay = N\n\nwhile True:\n if check(pay, str_D):\n print(pay)\n return\n pay += 1\n", "def dfs(A: list):\n if len(A) > nn:\n return\n if len(A) and (x := int(\"\".join(A))) >= n and ans[0] > x:\n ans[0] = x\n return\n\n for v in d:\n if v == \"0\" and len(A) == 0:\n next\n A.append(v)\n dfs(A)\n A.pop()\n\n\nn, k = list(map(int, input().split()))\nd = sorted(list(set([str(i) for i in range(10)]) - set(input().split())))\nnn = len(str(n))+1\nans = [10**7]\ndfs([])\nprint((ans[0]))\n", "n, k = list(map(int, input().split()))\nd = list(input().split())\n#n = 1000\nflag = True\nwhile flag:\n flag2 = True\n for si in str(n):\n if si in d:\n n += 1\n flag2 = False\n break\n if flag2:\n break\n else:\n flag = True\n \nprint(n)\n", "def check(n, D):\n N = []\n while n != 0:\n N.append(n % 10)\n n //= 10\n for d in D:\n if d in N:\n return False\n return True\n\ndef __starting_point():\n n, k = [int(x) for x in input().split(' ')]\n D = [int(x) for x in input().split(' ')]\n res = n\n while True:\n if check(res, D):\n break\n else:\n res += 1\n print(res)\n\n__starting_point()", "def is_dislike(N, ds):\n num = N\n while(True):\n if (num % 10) in ds:\n return True\n else:\n num = int(num / 10)\n if num == 0:\n break\n return False\n\n\nnk = list(map(int,input().split()))\nN = nk[0]\nK = nk[1]\nds = list(map(int,input().split()))\nwhile(True):\n if is_dislike(N, ds):\n N = N+1\n else:\n print(N)\n break", "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom math import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\nimport bisect\nimport heapq\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165g\n#\n# \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7cfb\n# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);\n# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\n#mod = 998244353\nINF = float('inf')\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n return list(map(int,readline().split()))\ndef readTuples():\n return tuple(map(int,readline().split()))\ndef I():\n return int(readline())\n\n#dic = defaultdict(int)\nn,k = readInts()\nD = Counter(readInts())\ndef ok(n):\n while n:\n v = n%10\n if D[v]:\n return False\n n //= 10\n return True\nans = n\nfor i in range(n, 100000):\n if ok(i):\n ans = i\n break\nprint(ans)\n", "import sys\nimport numpy as np\nread = sys.stdin.readline\n\n\ndef main(n, k, a):\n for i in range(n, 100000):\n s = np.array(list(map(int, str(i))), dtype=np.int64)\n ok = True\n for j in s:\n ok &= j not in a\n if ok:\n print(i)\n break\n\n\ndef __starting_point():\n n, k = np.fromstring(read(), dtype=np.int64, sep=' ')\n a = np.fromstring(read(), dtype=np.int64, sep=' ')\n main(n, k, a)\n\n__starting_point()", "n, k = map(int, input().split())\narr = list(map(int, input().split()))\n\ninf = float('inf')\nmin_cost = inf\nfor amount in range(n, 100000):\n for i, e in enumerate(arr):\n if str(e) in str(amount):\n break\n if i == len(arr)-1:\n min_cost = min(min_cost, amount)\n\nprint(min_cost)", "#\n# abc042 c\n#\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"1000 8\n1 3 4 5 6 7 8 9\"\"\"\n output = \"\"\"2000\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"9999 1\n0\"\"\"\n output = \"\"\"9999\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N, K = list(map(int, input().split()))\n D = list(input().split())\n\n for i in range(100000):\n if i < N:\n continue\n for d in D:\n if str(i).count(d) != 0:\n break\n else:\n print(i)\n break\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "n,k = input().split()\nhate = list(input().split())\nexi = True\nt = True\n\nwhile True:\n for c in hate:\n t = True\n if c in list(n):\n t = False\n break\n if t:\n print(n)\n break\n\n intN = int(n) + 1\n n = str(intN)", "import itertools\n\ndef main():\n\tN, K = [int(n) for n in input().split(\" \")]\n\tD = [1] * 10\n\tfor d in input().split(\" \"):\n\t\tD[int(d)] = 0\n\tL = [str(i) for i, v in enumerate(D) if v == 1]\n\n\tdigit = len(str(N))\n\tcand = []\n\tfor n in list(itertools.product(L, repeat=digit)):\n\t\tp = int(\"\".join(list(n)))\n\t\tif p >= N:\n\t\t\tcand.append(p)\n\tif len(cand):\n\t\tprint(min(cand))\n\telse:\n\t\tif L[0] == \"0\":\n\t\t\tprint(str(L[1]) + \"0\" * digit)\n\t\telse:\n\t\t\tprint(str(L[0]) * (digit + 1))\n\n\nmain()", "import sys\ninput = sys.stdin.readline\n\ndef find_ok( x , Oks ):\n for i in Oks:\n if int(i) > int(x):\n break\n return i\n\ndef main():\n n,k = map( int , input().split() )\n Nos = set(map( int , input().split() ))\n while(1):\n x = str(n)\n set_n= set()\n for digit in x:\n set_n.add( int(digit) )\n if len(set_n & Nos) == 0:\n break\n n += 1\n print(n)\n\n\n\nmain()", "n,k=list(map(int,input().split()))\nd=set(input().split())\n\nwhile True:\n if len(set(str(n))&d) != 0:\n n+=1\n \n else:\n print(n)\n break\n", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[21]:\n\n\nimport itertools\n\ndef main():\n\tN, K = [int(n) for n in input().split(\" \")]\n\tD = [1] * 10\n\tfor d in input().split(\" \"):\n\t\tD[int(d)] = 0\n\tL = [str(i) for i, v in enumerate(D) if v == 1]\n\n\tdigit = len(str(N))\n\tcand = []\n\tfor n in list(itertools.product(L, repeat=digit)):\n\t\tp = int(\"\".join(list(n)))\n\t\tif p >= N:\n\t\t\tcand.append(p)\n\tif len(cand):\n\t\tprint((min(cand)))\n\telse:\n\t\tif L[0] == \"0\":\n\t\t\tprint((str(L[1]) + \"0\" * digit))\n\t\telse:\n\t\t\tprint((str(L[0]) * (digit + 1)))\n\n\nmain()\n\n\n# In[ ]:\n\n\n\n\n", "N,K = map(int,input().split())\nD = list(map(int,input().split()))\nE = []\nfor i in range(10):\n if i not in D:\n E.append(i)\nE = sorted(E)\nN = str(N)\nind = len(N)\nfor i in range(len(N)):\n if int(N[i]) not in E:\n ind = i\n break\nif ind==len(N):\n print(N)\nelse:\n flag = 0\n x = \"\"\n for i in range(ind,-1,-1):\n n = int(N[i])\n for e in E:\n if e>n:\n x = N[:i]+str(e)+str(E[0])*(len(N)-i-1)\n flag = 1\n break\n if flag==1:break\n if flag==0:\n if E[0]>0:\n a = E[0]\n else:\n a = E[1]\n x = str(a)+str(E[0])*len(N)\n print(x)", "n, k = map(int, input().split())\nds = [d for d in input().split()]\nwhile any(c in ds for c in str(n)): n += 1\nprint(n)", "n,k = map(int,input().split())\nd = list(input().split())\nflg = True\nwhile flg:\n flg = False\n m = list(str(n))\n for i in m:\n if i in d:\n flg = True\n break\n if flg:\n n += 1\nprint(n)", "n,k = map(int,input().split())\na = list(map(int,input().split()))\nb = set()\nfor i in range(10):\n if i in a:\n b.add(str(i))\nwhile n > 0:\n c = set(list(str(n)))\n if c.isdisjoint(b):\n print(n)\n return\n n += 1", "# coding:UTF-8\nimport sys\n\n\ndef resultSur97(x):\n return x % (10 ** 9 + 7)\n\ndef __starting_point():\n # ------ \u5165\u529b ------#\n nk = list(map(int, input().split())) # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n\n x = nk[1]\n dList = list(map(int, input().split())) # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n\n # ------ \u51e6\u7406 ------#\n f = 0\n n = nk[0]\n while f == 0:\n nList = [int(c) for c in str(n)] # \u6570\u5b57\u2192\u5358\u6570\u5b57\u30ea\u30b9\u30c8\u5909\u63db\n b = 1\n for i in nList:\n for j in dList:\n if i == j:\n b = 0\n break\n if b == 1:\n break\n else:\n n += 1\n\n # ------ \u51fa\u529b ------#\n print((\"{}\".format(n)))\n # if flg == 0:\n # print(\"YES\")\n # else:\n # print(\"NO\")\n\n__starting_point()", "import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef v(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return list(map(int,input().split()))\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 9)\nmod = 10**9+7\ncnt = 0\nans = 0\ninf = float(\"inf\")\nal = \"abcdefghijklmnopqrstuvwxyz\"\nAL = al.upper()\n\nn,k = I()\nd = l()\nuse = [i for i in range(11) if i not in d ]\na = True\nprice = n\n\nwhile a:\n cnt = 0\n for i in str(price):\n a = len(str(price))\n if int(i) not in d:\n cnt += 1\n else:\n cnt = inf\n if a == cnt:\n print(price)\n return\n price += 1\n \n \n \n\n", "n,k=map(int,input().split())\nd=list(map(str,input().split()))\ne=set(d)\nfor i in range(n,100001):\n v = set(str(i))&e\n if len(v)== 0:\n print(i);return", "import itertools\nn,k = map(int, input().split())\nd = list(map(int, input().split()))\nsafe = [i for i in range(10) if i not in d]\n\nn_l = list(map(int, list(str(n))))\nif len(set(safe)&set(n_l)) == len(set(n_l)):\n print(n)\n return\n\nfor v in itertools.product(safe, repeat=len(str(n))):\n if v[0] == 0: continue\n x = int(\"\".join(list(map(str, v))))\n if int(x) >= n:\n print(x)\n return\n\nfor v in itertools.product(safe, repeat=len(str(n))+1):\n if v[0] == 0: continue\n x = int(\"\".join(list(map(str, v))))\n if int(x) >= n:\n print(x)\n return", "import sys\nimport numpy as np\nread = sys.stdin.readline\n\n\ndef main(n, k, a):\n for i in np.arange(n, 100000):\n ok = True\n for j in str(i):\n ok &= j not in a\n if ok:\n print(i)\n break\n\n\ndef __starting_point():\n n, k = np.fromstring(read(), dtype=np.int32, sep=' ')\n a = set(read().split())\n main(n, k, a)\n\n__starting_point()", "n,k=map(int,input().split())\nd=set(input().split())\n \nwhile True:\n if len(set(str(n))&d) != 0:\n n+=1\n \n else:\n print(n)\n break", "N, K = map(int, input().split())\nD = set(input().split())\n\nfor i in range(N, 100001):\n for d in str(i):\n if d in D:\n break\n else:\n print(i)\n break", "n, k = list(map(int, input().split()))\nd = list(map(int, input().split()))\n\nv = n\nwhile True:\n f = True\n for t in list(str(v)):\n if int(t) in d:\n f = False\n continue\n if f:\n print(v)\n return\n v+=1\n", "n,k = [int(x) for x in input().split()]\na = input().split()\n\ndef check(p):\n p = list(str(p))\n for i in range(len(p)):\n if p[i] in a:\n return False\n return True\n\nfor i in range(n,n * 10000):\n if check(i):\n print(i)\n break", "N,K=map(int,input().split())\n*D,=input().split()\nok=1\nwhile ok:\n ans=list(str(N))\n ok=0\n for a in ans:\n if a in D:\n ok=1\n N+=1\nprint(''.join(ans))", "n, k = map(int, input().split())\nD = list(map(int, input().split()))\n\nfor i in range(n, 100000):\n m = str(i)\n count = 0\n for j in range(len(m)):\n if int(m[j]) in D:\n break\n else:\n count += 1\n if count == len(m):\n print(i)\n return\n \nprint(0)", "n,k=list(map(int,input().split()))\nl=list(map(int,input().split()))\nfor v in range(n,10**5):\n for c in str(v):\n if int(c) in l:\n break\n else:\n print(v)\n return\n", "N, K = map(int,input().split())\nmat = input().split()\nwhile True:\n FIN = 0\n for i in range(len(str(N))):\n for j in range(K):\n if mat[j] == str(N)[i]:\n FIN += 1\n break\n if FIN == 0:\n break \n else:\n N += 1\nprint(N)", "n,k = [int(x) for x in input().split()]\nds = {int(x) for x in input().split()}\nns = {0,1,2,3,4,5,6,7,8,9} -ds\n#print(ds)\n#print(ns-ds)\ntemp=0\nd ={}\na=1\nb = {}\nm = len(str(n)) +1 \nover=False\nwhile(a<=m and not over ):\n c = []\n d = 10**(a-1) \n for v in ns:\n if a>1:\n for bv in b[a-1]:\n t = v*d + bv\n c += [t]\n if t >= n:\n print(t)\n over=True\n break\n if over:\n break\n else:\n t = v*d\n c += [t]\n if t >= n:\n print(t)\n over=True\n break\n \n b[a] = c\n a+=1\n \n#for j in b: \n# print(j,b[j])\n\n", "# N, K\u306e\u5165\u529b\u53d7\u4ed8\nN, K = map(int, input().split())\n# D\u306e\u5165\u529b\u53d7\u4ed8\nD = set(input().split())\n# 0-9\u3068D\u306e\u5dee\u96c6\u5408\u4f5c\u6210\u3001\u30ea\u30b9\u30c8\u5316\u3057\u3066E\u306b\u4ee3\u5165\nE = {\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\"} - D\n# N\u306b1\u305a\u3064\u8db3\u3057\u3066\u6761\u4ef6\u306b\u5408\u3046\u6700\u521d\u306e\u6570\u5b57\u3092\u7279\u5b9a\u3059\u308b\nresult = False\nwhile result == False:\n for i in str(N):\n if not i in E:\n N = N + 1\n result = False\n break\n else:\n result = True\nprint(N)", "n, k = map(int,input().split())\na = list(input().split())\n\nfor i in range(n, 100001):\n flg = True\n s = str(i)\n for j in range(len(s)):\n if s[j] in a:\n flg = False\n break\n if flg:\n break\nprint(i)", "# bsdk idhar kya dekhne ko aaya hai, khud kr!!!\n# import math\n# from itertools import *\n# import random\n# import calendar\nimport datetime\n# import webbrowser\n\n# f = open(\"input.txt\", 'r')\n# g = open(\"output.txt\", 'w')\n# n, m = map(int, f.readline().split())\n\nn, k = list(map(int, input().split()))\ndislike = list(map(int, input().split()))\nwhile True:\n for i in str(n):\n if int(i) not in dislike:\n continue\n else:\n break\n else:\n break\n n += 1\nprint(n)\n", "n,k=list(map(int,input().split()))\nd = list(map(int,input().split()))\n#print(d)\nfor i in range(n,10**5):\n count=0\n for j in range(k):\n u = str(d[j])\n if(str(i).count(u)==0):\n count+=1\n #print(\"count:\"+str(count))\n if(count==k):\n print(i)\n break\n", "def is_bad_nums(j: int, d: []) -> bool:\n while j:\n if j % 10 in d:\n return True\n j //= 10\n return False\n\n\ndef answer(n: int, k: int, d: []) -> int:\n for i in range(n, 100000):\n if is_bad_nums(i, d):\n continue\n return i\n\n\ndef main():\n n, k = map(int, input().split())\n d = list(map(int, input().split()))\n print(answer(n, k, d))\n\n\ndef __starting_point():\n main()\n__starting_point()", "N, K = map(int, input().split())\nD = list(map(int, input().split()))\ns = set(D)\n\nfor i in range(N, 10**6+1):\n l = [j for j in str(i)]\n flag = True\n for n in l:\n if int(n) in s:\n flag = False\n break\n if flag:\n ans = i\n break\nprint(ans)", "n, k = map(int, input().split())\nd = list(input().split())\nwhile True:\n flag2 = True\n for si in str(n):\n if si in d:\n n += 1\n flag2 = False\n break\n if flag2:\n break \nprint(n)", "def price(N,K):\n Kn = input().split()\n Flag = False\n\n for i in range(N,10*N,1):\n value = str(i)\n for j in range(K):\n if(Kn[j] not in value):\n Flag = True\n elif(Kn[j] in value):\n Flag = False\n break\n\n if(Flag == True):\n print(i)\n break\n\nN,K = (int(x) for x in input().split())\nprice(N,K)", "n, k = list(map(int, input().split()))\ndl = list(map(int, input().split()))\n\ni = n\nwhile True:\n money = list(map(int, str(i)))\n for m in money:\n if dl.count(m) != 0:\n break\n else:\n print(i)\n break\n i += 1\n \n", "import sys\nsys.setrecursionlimit(10**7)\narr = [\"a\",\"b\",\"c\"]\nsavelis = [0]*10\ndef main():\n N,K = list(map(int,input().split()))\n Flis = list(map(int,input().split()))\n Tlis = [i for i in range(10)]\n Tlis = [i for i in Tlis if i not in Flis]\n str_flis = [str(i) for i in Flis]\n ANS = []\n for i in range(N*10):\n stri = str(i)\n TF = True\n for j in stri:\n if j in str_flis:\n TF = False\n break\n if(TF):ANS.append(i)\n for item in ANS:\n if(item>=N):\n print(item)\n break\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import itertools\n\nN, K = map(int, input().split()) # N\u5186\u306e\u54c1\u7269\u3001K\u500b\u306e\u5acc\u3044\u306a\u6570\u5b57\nD = set(list(map(int, input().split()))) # \u5acc\u3044\u306a\u6570\u5b57\u306e\u30ea\u30b9\u30c8\nbase = set(range(10))\n\ntarget_num = base - D\nketa = len(str(N))\n\nanswer = float('inf')\nfor p in itertools.product(target_num, repeat=keta):\n temp = 0\n for i, num in enumerate(p):\n temp += num * 10**i\n \n if temp >= N:\n answer = min(answer, temp)\n\nfor p in itertools.product(target_num, repeat=keta+1):\n temp = 0\n for i, num in enumerate(p):\n temp += num * 10**i\n \n if temp >= N:\n answer = min(answer, temp)\n\nprint(answer)", "n,k = list(map(int,input().split()))\n\na = list(input().split())\n\nwhile not set(list(str(n)[0:k])).isdisjoint(a):\n\tn += 1\n\nprint(n)\n", "n, k = map(int, input().split())\nD = list(input().split())\n\nans = str(n)\nwhile not all([c not in D for c in ans]) and int(ans) >= n:\n ans = str(int(ans) + 1)\nprint(ans)", "n, k = map(int, input().split())\nd = list(map(int, input().split()))\nng = [False] * 10\nfor i in d:\n ng[i] = True\ndef ok(n):\n nonlocal ng\n while n > 0:\n if ng[n%10]:\n return False\n n //= 10\n return True\nwhile not ok(n):\n n += 1\nprint(n)", "n, k = list(map(int, input().split()))\nd = set(map(int, input().split()))\n\nwhile True:\n tmp_str = set(str(n))\n for i in tmp_str:\n if int(i) in d:\n n += 1\n break\n else:\n print(n)\n break\n", "n,k=map(int,input().split())\nd=list(map(int,input().split()))\nx=list(range(1,100001))\ny=[0]*100000\nfor i in range(100000):\n s=str(i)\n S=len(s)\n for j in range(S):\n if int(s[j]) in d:\n y[i-1]=1\n break\nfor i in range(100000):\n if i>=n-1:\n if y[i]==0:\n print(i+1)\n break", "n, k = map(int, input().split())\nD = set(map(int, input().split()))\nfrom itertools import count\nfor ans in count(n,1):\n for c in str(ans):\n if int(c) in D:\n break\n else:\n print(ans)\n break", "def iparse():\n return list(map(int, input().split()))\n\nn, k = iparse()\nd = iparse()\n\nfor i in range(n, 5000000):\n tmp = i\n f = True\n while tmp > 0:\n x = tmp % 10\n if x in d:\n f = False\n break\n tmp //= 10\n if f:\n print(i)\n return\n\n", "from sys import stdin\ninput = stdin.readline\n\nN, K = map(int, input().split())\nD = set(map(int, input().split()))\n\nwhile True:\n tmp = set(str(N))\n b = True\n for x in tmp:\n if int(x) in D:\n b = False\n break \n if b == True:\n break\n else:\n N += 1\n\nprint(N)", "N,K = input().split()\nD =list(map(int,input().split()))\nans = []\na = int(N[0])\nx = 0\nb = 0\nwhile b in D:\n b += 1\nc = 2\nwhile c in D:\n c += 1\ny = 0\nwhile a == int(N[x]) and x <= len(N)-1:\n while a in D and a <= 9:\n a += 1\n if a == 10:\n y = x\n if 0 in D:\n a += b\n if 1 in D:\n if b != 0:\n a += (b-1)*10\n else:\n a += (c-1)*10\n ans.append(str(a))\n if a != int(N[x]):\n for i in range(len(N)-1-x):\n ans.append(str(b))\n elif x <= len(N)-2:\n x += 1\n a = int(N[x])\n else:\n a = int(N[x])-1\nwhile y > 0:\n s = ans[y][0]\n t = ans[y][1]\n r = ans[y]\n ans[y] = t\n ans[y-1] = str(int(ans[y-1]) + 1)\n if int(ans[y-1]) in D:\n u = int(ans[y-1])\n while u in D:\n u += 1\n ans[y-1] = str(u)\n if ans[y-1] != \"10\":\n y = 0\n else:\n y -= 1\n ans[y] = r\nprint(\"\".join(ans))", "n, k = map(int, input().split())\nd = list(input().split())\nnum = [str(i) for i in range(10)]\nfor i in range(k):\n num.remove(d[i])\n \nimport itertools, heapq\nans = []\nheapq.heapify(ans)\nfor i in itertools.product(num, repeat=len(str(n))):\n s = int(''.join(i))\n if s >= n:\n heapq.heappush(ans, s)\n \nif len(ans) == 0:\n for i in itertools.product(num, repeat=len(str(n)) + 1):\n s = int(''.join(i))\n if s >= n:\n heapq.heappush(ans, s)\n print(heapq.heappop(ans))\n \nelse:\n print(heapq.heappop(ans))", "n, k = list(map(int, input().split()))\nd = list(map(int, input().split()))\ns = {'0','1','2','3','4','5','6','7','8','9'} - set(str(d))\nans = n\n\nwhile (s >= set(str(n))) == False:\n n += 1\n if (s >= set(str(n))) == True:\n ans = n\n break\n \nprint(ans)\n", "def main():\n N, K = map(int, input().split())\n A_list = list(map(str, input().split()))\n use_list = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"]\n list_A = list(set(use_list) - set(A_list))\n #print(\"list_A\", list_A)\n for i in range(100000) :\n ans = N + i\n #print(\"ans\", ans)\n ans_str = str(ans)\n frag = 0\n for val in ans_str :\n #print(\"val\", val)\n if str(val) in list_A :\n pass\n #print(\"frag\", frag)\n else :\n frag = 1\n break\n\n if frag == 0 :\n break\n print(ans)\n\n\ndef __starting_point():\n main()\n__starting_point()", "def main():\n N, K = list(map(int, input().split()))\n D = set(map(int, input().split()))\n numset = set(range(0,10))\n d = numset.difference(D)\n\n for n in range(N, pow(10, 6) + 10):\n check = set(list(str(n)))\n ngflag = False\n for i in check:\n if int(i) in D:\n ngflag = True\n break\n if not ngflag:\n break\n print(n)\n\ndef __starting_point():\n main()\n\n__starting_point()", "N, K = [int(x) for x in input().split()]\nD = input().split()\n\nfor payment in range(N, 10*N+1):\n if all(char not in D for char in str(payment)):\n print(payment)\n break", "n, k = map(int, input().split())\nd = list(input().split())\nnum = [str(i) for i in range(10)]\nfor i in range(k):\n num.remove(d[i])\n \nimport itertools\nans = []\nfor i in itertools.product(num, repeat=len(str(n))):\n s = int(''.join(i))\n if s >= n:\n ans.append(s)\n \nif len(ans) == 0:\n for i in itertools.product(num, repeat=len(str(n)) + 1):\n s = int(''.join(i))\n if s >= n:\n ans.append(s)\n print(min(ans))\n \nelse:\n print(min(ans))", "N, K = map(int, input().split())\nS = set(input().split())\nwhile True:\n L = list(str(N))\n for i in L:\n if i in S:\n break\n else:\n break\n N += 1\nprint(N)", "n, k = map(int, input().split())\nd = list(map(int, input().split()))\n\nwhile True:\n for i in str(n):\n if int(i) in d:\n n += 1\n break\n \n else:\n print(n)\n break", "N, K, *D = list(map(int, open(0).read().split()))\nD = set(str(d) for d in D)\nfor i in range(N, 100_000):\n if set(str(i)) & D:\n continue\n print(i)\n break\n", "n,t = [int(x) for x in input().split()]\nd = [int(x) for x in input().split()]\n\ndef check(x) -> bool:\n while x>0:\n a = x%10\n if a in d:\n return False\n x//=10\n return True\n\nwhile check(n)==False:\n n+=1\nprint(n)", "n,k = map(int,input().split())\nd=set(input().split())\nwhile True:\n if len(set(str(n))&d)!=0:\n n+=1\n else:\n break\nprint(n)", "def minN(N:int, usable:list, restrict=True):\n usable.sort()\n keta = False\n if restrict:\n for i in usable:\n if i >= N:\n return str(i)\n # \u6841\u304c\u5897\u3048\u308b\n return '1'+str(usable[0])\n else:\n return str(usable[0])\n\ndef rote(N:list, D:set, d:set):\n ans = []\n flag = True\n lenNstr = len(N)\n for i, n in enumerate(N):\n n = int(n)\n keta = 10**(len(N) - i - 1)\n if flag:\n if n in D:\n ans.append(int(minN(n, d)) * keta)\n flag = False\n else:\n ans.append(keta * n)\n else:\n ans.append(keta * min(d))\n return sum(ans)\n\ndef main():\n N, K = list(map(int, input().split()))\n D = set(map(int, input().split()))\n numset = set(range(0,10))\n d = list(numset.difference(D))\n d.sort()\n for _ in range(10):\n Nstr = list(str(N))\n ans = rote(Nstr, D, d)\n N = ans \n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "N,K = list(map(int,input().split()))\n\nD = list(map(int,input().split()))\n\ndef ok(x):\n while x:\n if x % 10 in D:\n return False\n x //= 10\n return True\n\nfor i in range(N,100000):\n if ok(i):\n print(i)\n return\n", "N,K=map(int,input().split())\nD=list(map(int,input().split()))\n\nwhile True:\n S=str(N)\n flag=True\n for x in S:\n if int(x) in D:\n flag=False\n if flag==True:\n break;\n N+=1\nprint(N)", "n,k=map(int,input().split());a=set(input().split())\nwhile True:\n if not set(str(n))&a: print(n);break\n n+=1", "N, K = list(map(int, input().split()))\nkirai = list(map(int, input().split()))\nwhile True:\n bara = [int(x) for x in list(str(N))]\n diff = set(kirai) & set(bara)\n if diff == set():\n print(N)\n break\n else:\n N = N + 1\n"] | {"inputs": ["1000 8\n1 3 4 5 6 7 8 9\n", "9999 1\n0\n"], "outputs": ["2000\n", "9999\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 39,229 | |
813c53d8b5eea7cc38d171f30a3d1590 | UNKNOWN | There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.
Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.
Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.
How many good observatories are there?
-----Constraints-----
- 2 \leq N \leq 10^5
- 1 \leq M \leq 10^5
- 1 \leq H_i \leq 10^9
- 1 \leq A_i,B_i \leq N
- A_i \neq B_i
- Multiple roads may connect the same pair of observatories.
- All values in input are integers.
-----Input-----
Input is given from Standard Input in the following format:
N M
H_1 H_2 ... H_N
A_1 B_1
A_2 B_2
:
A_M B_M
-----Output-----
Print the number of good observatories.
-----Sample Input-----
4 3
1 2 3 4
1 3
2 3
2 4
-----Sample Output-----
2
- From Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.
- From Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.
- From Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.
- From Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.
Thus, the good observatories are Obs. 3 and 4, so there are two good observatories. | ["N,M = map(int,input().split())\nhigh = list(map(int,input().split()))\nans = [0]*N\ncnt = 0\nfor i in range(M):\n a,b = map(int,input().split())\n ans[a-1] = max(high[b-1],ans[a-1])\n ans[b-1] = max(ans[b-1],high[a-1])\n\nfor j in range(N):\n if ans[j] < high[j]:\n cnt += 1\nprint(cnt)", "N, M = list(map(int, input().split()))\nH = [int(a) for a in input().split()]\nX = [1] * N\nfor _ in range(M):\n a, b = list(map(int, input().split()))\n a, b = a-1, b-1\n if H[a] <= H[b]:\n X[a] = 0\n if H[b] <= H[a]:\n X[b] = 0\nprint((sum(X)))\n", "n,m=map(int,input().split())\nh=list(map(int,input().split()))\nc=0\nd=[0]*n\nfor i in range(m):\n a,b=map(int,input().split())\n d[a-1]=max(d[a-1],h[b-1])\n d[b-1]=max(d[b-1],h[a-1])\nfor i in range(n):\n if h[i]>d[i]:\n c+=1\nprint(c)", "from collections import deque\nn,m = map(int,input().split())\nh=list(map(int,input().split()))\ng = [[] for _ in range(n)]\nfor _ in range(m):\n a,b = map(int,input().split())\n a-=1\n b-=1\n g[a].append(b)\n g[b].append(a)\nans=0\nfor j in range(n):\n for i in g[j]:\n if h[j]<=h[i]:\n break\n else:\n ans+=1\nprint(ans)", "n, m = list(map(int, input().split()))\nheights = list(map(int, input().split()))\n\nneighbors = [[] for i in range(n)]\n\nfor i in range(m):\n a, b = list(map(int, input().split()))\n neighbors[a - 1].append(b - 1)\n neighbors[b - 1].append(a - 1)\n\ncount = 0\nfor i in range(n):\n hanamaru = True\n for j in neighbors[i]:\n if heights[i] > heights[j]:\n continue\n else:\n hanamaru = False\n break\n if hanamaru is True:\n count += 1\n\nprint(count)\n", "n, m = [int(i) for i in input().split()]\nh = [int(i) for i in input().split()]\nedges = [[] for i in range(n)]\nfor _ in range(m):\n edge = [int(i)-1 for i in input().split()]\n edges[edge[0]].append(edge[1])\n edges[edge[1]].append(edge[0])\ncnt = 0\n\nfor i in range(n):\n flg = True\n for j in edges[i]:\n if h[i] <= h[j]:\n flg = False\n break\n if flg:\n cnt += 1\nprint(cnt)", "N, M = list(map(int, input().split()))\nH = list(map(int, input().split()))\n\ngood = [1] * N\nfor i in range(M):\n A, B = list(map(int, input().split()))\n A, B = A - 1, B - 1\n HA = H[A]\n HB = H[B]\n if HA == HB:\n if good[A]:\n good[A] = 0\n if good[B]:\n good[B] = 0\n elif HA < HB and good[A]:\n good[A] = 0\n elif HB < HA and good[B]:\n good[B] = 0\n\nprint((sum(good)))\nreturn\n", "N,M=list(map(int,input().split()))\nH=list(map(int,input().split()))\ncnt=[1 for _ in range(N)]\nfor _ in range(M):\n A,B=list(map(int,input().split()))\n A-=1\n B-=1\n if H[A]>H[B]:\n cnt[B]=0\n elif H[A]<H[B]:\n cnt[A]=0\n else:\n cnt[A]=0\n cnt[B]=0\nprint((cnt.count(1)))\n", "N,M=map(int,input().split())\nHlist=list(map(int,input().split()))\nABlist=[]\nfor _ in range(M):\n ABlist.append(list(map(int,input().split())))\nflaglist=[1]*N\nfor row in ABlist:\n one=row[0]-1 #index\u3068\u756a\u53f7\u306e\u8abf\u6574\n two=row[1]-1\n if Hlist[one]<=Hlist[two]:\n flaglist[one]=0\n if Hlist[one]>=Hlist[two]:\n flaglist[two]=0\nprint(sum(flaglist))", "N, M = map(int,input().split())\nH = list(map(int,input().split()))\nA, B = [], []\nfor _ in range(M):\n a, b = map(int,input().split())\n A.append(a)\n B.append(b)\n\nL = [1] * N\n\nfor i in range(M):\n ai = A[i] - 1\n bi = B[i] - 1\n if H[ai] > H[bi]:\n L[bi] = 0\n elif H[bi] > H[ai]:\n L[ai] = 0\n else:\n L[ai], L[bi] = 0, 0\n\nprint(L.count(1))", "n, m = list(map(int,input().split()))\n\nh = list(map(int,input().split()))\n\ncnt = [0] * n\n\nfor i in range(m):\n a,b = list(map(int,input().split()))\n cnt[a-1] = max(cnt[a-1], h[b-1])\n cnt[b-1] = max(cnt[b-1], h[a-1])\n\n\n \nres = sum([h[i] > cnt[i] for i in range(n)])\n\n\nprint(res)\n", "N,M = list(map(int, input().split()))\n\nH=list(map(int,input().split()))\n\ngraph=[[0] for _ in range(N)]\n\nfor i in range(M):\n A, B = list(map(int, input().split()))\n graph[A-1].append(H[B-1])\n graph[B-1].append(H[A-1])\n\nans=0\n\nfor i in range(N):\n if H[i]>max(graph[i]):\n ans+=1\n \nprint(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n \n \n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n\n\n\n\n\n \n\n \n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n \n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n \n\n\n \n\n\n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n", "n,m = map(int,input().split())\nh = list(map(int,input().split()))\n\ng = [[] for _ in range(n)]\nfor _ in range(m):\n a,b = map(int,input().split())\n g[a-1].append(b-1)\n g[b-1].append(a-1)\n\ncnt = n\nfor i in range(n):\n for j in g[i]:\n if h[i] <= h[j]:\n cnt -= 1\n break\nprint(cnt)", "N, M = list(map(int, input().split()))\nheight_list = list(map(int, input().split()))\nroad_list_1 = [list(map(int, input().split())) for i in range(M)]\nroad_list = [[road_list_1[j][i] - 1 for i in range(2)] for j in range(M)]\nobservation_deck = list(range(N))\n\nfor i in range(M):\n if height_list[road_list[i][0]] >= height_list[road_list[i][1]]:\n observation_deck[road_list[i][1]] = -1\n if height_list[road_list[i][0]] <= height_list[road_list[i][1]]:\n observation_deck[road_list[i][0]] = -1\n\nanswer = 0\n\nfor i in range(N):\n if observation_deck[i] != -1:\n answer += 1\n\nprint(answer)", "N,M=map(int,input().split())\nH=list(map(int,input().split()))\nA=[0]*M;B=[0]*M\nC=[0]*N\nfor i in range(M):\n A[i],B[i]=map(int,input().split())\n\nfor i in range(M):\n if H[A[i]-1]<H[B[i]-1]:C[A[i]-1]+=1\n elif H[A[i]-1]>H[B[i]-1]:C[B[i]-1]+=1\n else:C[A[i]-1]+=1;C[B[i]-1]+=1\nprint(C.count(0))", "\nn, m = list(map(int, input().split()))\nl = list(map(int, input().split()))\ncor = [[] for i in range(n)]\n\nfor i in range(m):\n a, b = list(map(int, input().split()))\n a -= 1\n b -= 1\n cor[a].append(b)\n cor[b].append(a)\n\nans = 0\nfor i in range(n):\n max_h = l[i]\n cnt = 1\n co = list(set(cor[i]))\n for j in range(len(co)):\n if l[co[j]] >= max_h:\n cnt = 0\n break\n ans += cnt\n\nprint(ans)\n\n\n\n", "n,m=map(int, input().split())\nh=list(map(int, input().split()))\nnear=[[0] for i in h]\nfor i in range(m):\n a,b=map(int, input().split())\n near[a-1].append(h[b-1])\n near[b-1].append(h[a-1])\ncnt=0\nfor i in range(n):\n if max(near[i])<h[i]:\n cnt+=1\nprint(cnt)", "def main() -> None:\n n, m = list(map(int, input().split()))\n heights = tuple(map(int, input().split()))\n\n good = [1] * n\n for _ in range(m):\n a, b = list(map(int, input().split()))\n height_a, height_b = heights[a-1], heights[b-1]\n if height_a == height_b:\n good[a-1], good[b-1] = 0, 0\n elif height_a < height_b:\n good[a-1] = 0\n else:\n good[b-1] = 0\n print((good.count(1)))\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N,M=map(int,input().split())\nH=list(map(int,input().split()))\nroad=[[] for i in range(N)]\nfor i in range(M):\n a,b=map(int,input().split())\n road[a-1].append(b)\n road[b-1].append(a)\nc=0\nfor i in range(N):\n T=True\n for j in road[i]:\n if H[i]<=H[j-1]:\n T=False\n if T:\n c+=1\nprint(c)", "import sys\ninput = sys.stdin.readline\n\ndef main():\n n , m = map( int , input().split() )\n h = list( map( int , input().split() ) )\n goods = [ 1 for i in range(n) ]\n for i in range( m ):\n a , b = map( lambda x : int(x) - 1 , input().split() )\n if ( h[a] > h[b] ):\n goods[ b ] = 0\n if ( h[a] < h[b] ):\n goods[ a ] = 0\n if ( h[a] == h[b] ):\n goods[ a ] = 0\n goods[ b ] = 0\n print( sum(goods) )\nmain()", "n, m = map(int,input().split())\nh = list(map(int,input().split()))\nl = [1]*n\nfor i in range(m):\n a, b = map(int,input().split())\n if h[a-1] == h[b-1]:\n l[a-1] = 0\n l[b-1] = 0\n if h[a-1] > h[b-1]:\n l[b-1] = 0\n if h[a-1] < h[b-1]:\n l[a-1] = 0\nprint(l.count(1))", "N, M = list(map(int, input().split()))\nH = list(map(int, input().split()))\n\ngood = [1] * N\nfor i in range(M):\n A, B = list(map(int, input().split()))\n HA = H[A - 1]\n HB = H[B - 1]\n if HA == HB:\n if good[A - 1]:\n good[A - 1] = 0\n if good[B - 1]:\n good[B - 1] = 0\n elif HA < HB and good[A - 1]:\n good[A - 1] = 0\n elif HB < HA and good[B - 1]:\n good[B - 1] = 0\n\nprint((sum(good)))\nreturn\n", "N,M = map(int,input().split())\nHlist = list(map(int,input().split()))\n\nanslist = [1]*N\nfor i in range(M):\n A,B = map(int,input().split())\n #print (Hlist[A-1])\n #print (Hlist[B-1])\n if Hlist[A-1]<Hlist[B-1]:\n anslist[A-1]=0\n elif Hlist[A-1]>Hlist[B-1]:\n anslist[B-1]=0\n elif Hlist[A-1]==Hlist[B-1]:\n anslist[A-1]=0\n anslist[B-1]=0\n \n#print (anslist)\nprint (sum(anslist))", "import sys\n#import time\nfrom collections import deque, Counter, defaultdict\n#from fractions import gcd\nimport bisect\nimport heapq\n#import math\nimport itertools\nimport numpy as np\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**8)\ninf = 10**18\nMOD = 1000000007\nri = lambda : int(input())\nrs = lambda : input().strip()\nrl = lambda : list(map(int, input().split()))\nmod = 998244353\n\nn,m = rl()\nh = rl()\nans = [1]*n\nfor i in range(m):\n a,b = rl()\n a -= 1\n b -= 1\n if h[a]>h[b]:\n ans[b]=0\n elif h[a]<h[b]:\n ans[a]=0\n else:\n ans[a], ans[b] = 0, 0\nprint(sum(ans))", "import sys\npin=sys.stdin.readline\n\ndef main():\n N,M=map(int,pin().split())\n H=list(map(int,pin().split()))\n d=[True]*N\n ans=0\n for _ in [0]*M:\n A,B=map(int,pin().split())\n if H[A-1]>H[B-1]:\n d[B-1]=False\n elif H[B-1]>H[A-1]:\n d[A-1]=False\n else:\n d[A-1]=False\n d[B-1]=False\n for i in d:\n if i:\n ans+=1\n print(ans)\n return\nmain()", "import sys\nn,m=map(int,sys.stdin.readline().split())\n\ndata={}\nh=[int(i) for i in sys.stdin.readline().split()]\nfor i in range(1,n+1):\n data[i]=set()\n\nfor i in range(1,m+1):\n a,b=map(int,sys.stdin.readline().split())\n data[a].add(b)\n data[b].add(a)\n\n\nans=0\nfor i in data:\n if len(data[i])==0:\n ans+=1\n elif all(h[i-1]>h[j-1] for j in data[i]):\n ans+=1\nprint(ans)", "n, m = map(int,input().split())\nH = list(map(int,input().split()))\nAB = []\nans = 0\nfor i in range(m):\n AB.append(list(map(int,input().split())))\n AB[-1][0] -= 1\n AB[-1][1] -= 1\nok = [1]*n\nfor i in range(m):\n if H[AB[i][0]] >= H[AB[i][1]]:\n ok[AB[i][1]] = 0\n if H[AB[i][0]] <= H[AB[i][1]]:\n ok[AB[i][0]] = 0\nfor i in ok:\n if i:\n ans += 1\nprint(ans)", "N, M = list(map(int, input().split()))\nlist_h = list(map(int, input().split()))\ntable = [1] * N\n\nfor i in range(M):\n A, B = list(map(int, input().split()))\n if list_h[B-1] < list_h[A-1]:\n table[B-1] = 0\n elif list_h[A-1] < list_h[B-1]:\n table[A-1] = 0\n else:\n table[A-1] = 0\n table[B-1] = 0\n\nprint(str(sum(table)))", "N,M = map(int,input().split())\narray = list(map(int,input().split()))\nans = [1]*N\nfor i in range (M):\n A,B = map(int,input().split())\n if array[A - 1] < array[B - 1]:\n ans[A - 1] = 0\n elif array[A - 1] > array[B - 1]:\n ans[B - 1] = 0\n else:\n ans[A-1],ans[B-1] = 0,0\nprint( sum(ans) )", "import sys\nfrom collections import deque, defaultdict, Counter\nfrom itertools import accumulate, product, permutations, combinations\nfrom operator import itemgetter\nfrom bisect import bisect_left, bisect_right\nfrom heapq import heappop, heappush\nfrom math import ceil, floor, sqrt, gcd, inf\nfrom copy import deepcopy\nimport numpy as np\nimport scipy as sp\n\nINF = inf\nMOD = 1000000007\n\nn, m = [int(i) for i in input().split()]\nH = [int(i) for i in input().split()]\nA = [[int(i) for i in input().split()]for j in range(m)] # n\u306f\u884c\u6570\n\ntmp = [True for i in range(n + 1)]\nres = 0\n\nfor i in range(m):\n a, b = A[i]\n if H[a - 1] <= H[b - 1]:\n tmp[a] = False\n if H[a - 1] >= H[b - 1]:\n tmp[b] = False\nfor i in range(1, n + 1):\n if tmp[i]:\n res += 1\n\nprint(res)\n", "n,m=list(map(int,input().split()))\nH=list(map(int,input().split()))\nans = [1]*n\nfor i in range(m):\n a,b=list(map(int,input().split()))\n if H[a-1]>=H[b-1]:\n ans[b-1] = 0\n if H[a-1]<=H[b-1]:\n ans[a-1] = 0\nprint((sum(ans)))\n", "n,m = map(int,input().split())\nH = list(map(int,input().split()))\nL = [1]*n\nfor _ in range(m):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n if H[a] == H[b]:\n L[a] = 0\n L[b] = 0\n elif H[a] < H[b]:\n L[a] = 0\n elif H[a] > H[b]:\n L[b] = 0\nprint(sum(L))", "N, M = list(map(int, input().split()))\n\nh = list(map(int, input().split()))\nall_dict = {}\nfor m in range(M):\n a, b = list(map(int, input().split()))\n \n a -= 1\n b -= 1\n \n all_dict.setdefault(a, [])\n all_dict.setdefault(b, [])\n\n all_dict[a].append(b)\n all_dict[b].append(a)\n\ntotal_good = 0\n\nfor i in range(N):\n is_good = 1\n all_dict.setdefault(i, [])\n for around_h in all_dict[i]:\n if h[around_h] >= h[i]:\n is_good = 0\n total_good += is_good\n\nprint(total_good)\n\n\n", "N,M = map(int, input().split())\n\nH=list(map(int,input().split()))\n\ngraph=[[0] for _ in range(N)]\n\nfor i in range(M):\n A, B = map(int, input().split())\n graph[A-1].append(H[B-1])\n graph[B-1].append(H[A-1])\n\nans=0\n\nfor i in range(N):\n if H[i]>max(graph[i]):\n ans+=1\n \nprint(ans)", "def main():\n import collections\n n, m = list(map(int, input().split()))\n hs = list(map(int, input().split()))\n nmap = [0] * n\n cnt = 0\n\n for j in range(m):\n v = input().split()\n v0 = int(v[0]) - 1\n v1 = int(v[1]) - 1\n if hs[v0] < hs[v1]:\n nmap[v0] += 1\n elif hs[v0] == hs[v1]:\n nmap[v0] += 1\n nmap[v1] += 1\n else:\n nmap[v1] += 1\n for i in nmap:\n if i == 0:\n cnt += 1\n return cnt\n\n\ndef __starting_point():\n print((main()))\n\n__starting_point()", "import copy\nN,M=list(map(int, input().split()))\nnum_list = list(map(int, input().split()))\nlist1=copy.copy(num_list)\nfor i in range(M):\n A,B=list(map(int, input().split()))\n if num_list[A-1]<num_list[B-1]:\n list1[A-1]=0\n elif num_list[A-1]>num_list[B-1]:\n list1[B-1]=0\n else:\n list1[A-1]=0\n list1[B-1]=0\n\ns=0\nfor j in list1:\n if j>0:\n s=s+1\n\nprint(s)\n", "n, m = list(map(int, input().split()))\nh = [int(s) for s in input().split()]\nab = []\n\nfor i in range(m):\n ab.append([int(s) for s in input().split()])\n\nh2 = []\nfor p in ab:\n if h[p[0] - 1] <= h[p[1] - 1]:\n h2.append(p[0] - 1)\n if h[p[0] - 1] >= h[p[1] - 1]:\n h2.append(p[1] - 1)\n\nprint((len(h) - len(list(set(h2)))))\n", "N,M = map(int,input().split())\nH = list(map(int,input().split()))\n\nmiti = []\nfor i in range(M):\n miti.append(list(map(int,input().split())))\n\ncount = []\nfor i in range(N):\n count.append(1)\n\nfor i in range(M):\n if H[miti[i][0]-1] < H[miti[i][1]-1]:\n count[miti[i][0]-1]=0\n\n if H[miti[i][0]-1] > H[miti[i][1]-1]:\n count[miti[i][1]-1]=0\n\n if H[miti[i][0]-1] == H[miti[i][1]-1]:\n count[miti[i][0]-1]=0\n count[miti[i][1]-1]=0\n\nans = 0\nfor i in range(N):\n ans += count[i]\n\nprint(ans)", "n,m = list(map(int,input().split()))\nh = [0]+list(map(int,input().split()))\n\nroute = [[0] for _ in range(n+1)]\nfor _ in range(m):\n a,b = list(map(int,input().split()))\n route[a].append(h[b])\n route[b].append(h[a])\n\ncnt=0\nfor i in range(1,n+1):\n if h[i]>max(route[i]):\n cnt+=1\nprint(cnt)\n", "N, M = map(int, input().split())\nH = list(map(int, input().split()))\nH.insert(0, 0)\nt = [True] * (N+1)\n\nfor i in range(M):\n a, b = map(int, input().split())\n if H[a] <= H[b]:\n t[a] = False\n if H[b] <= H[a]:\n t[b] = False\n\nc = 0\nfor i in range(1, N+1, 1):\n if t[i]:\n c += 1\n\nprint(c)", "n, m = map(int, input().split())\n\nh = list(map(int, input().split()))\n\nans = [0] * n\n\nfor i in range(m):\n a, b = map(int, input().split())\n ans[a - 1] = max(ans[a - 1], h[b - 1])\n ans[b - 1] = max(ans[b - 1], h[a - 1])\n\nanser = 0\n\nfor i in range(n):\n if ans[i] < h[i]:\n anser += 1\n\nprint(anser)", "N, M = list(map(int, input().split()))\nH = list(map(int, input().split()))\nadj_max = [0]*N\nans = 0\nfor _ in range(M):\n tmp1, tmp2 = list(map(int, input().split()))\n adj_max[tmp1-1] = max(adj_max[tmp1-1], H[tmp2-1])\n adj_max[tmp2-1] = max(adj_max[tmp2-1], H[tmp1-1])\nfor num in range(N):\n if H[num] > adj_max[num]:\n ans += 1\nprint(ans)\n\n", "#ABC166\nN,M=map(int,input().split())\nH =list(map(int,input().split())) #\u5c55\u671b\u53f0\u306e\u6a19\u9ad8\nA = list(range(1,N+1))\nfor i in range(M):\n a, b = map(int, input().split())\n if H[a-1] > H[b-1]:\n A[b-1] = 0\n elif H[a-1] < H[b-1]:\n A[a-1] = 0\n else:\n A[a-1] = 0\n A[b-1] = 0\nprint(N-A.count(0))", "n,m = list(map(int,input().split()))\nh = list(map(int,input().split()))\nab = [list(map(int,input().split())) for _ in range(m)]\n\ngood = [True]*n\n\nfor i in range(m):\n if h[ab[i][0]-1] < h[ab[i][1]-1]:\n good[ab[i][0]-1] = False\n elif h[ab[i][0]-1] > h[ab[i][1]-1]:\n good[ab[i][1]-1] = False\n else:\n good[ab[i][0]-1] = False\n good[ab[i][1]-1] = False\n\n#print(good)\nprint((good.count(True)))\n", "N, M = map(int, input().split())\nH = list(map(int, input().split()))\n\n# N,M=O(10^5)\u306a\u306e\u3067\u3001O(N+M)\u3067\u89e3\u304f\n# \u5404\u30ce\u30fc\u30c9\u306b\u3064\u3044\u3066\u3001\u96a3\u63a5\u3059\u308b\u5c55\u671b\u53f0\u306e\u9ad8\u3055\u306e\u6700\u5927\u5024\u3092\u66f4\u65b0\u3059\u308b\nneighbor_max = [0] * N\nfor _ in range(M):\n A, B = map(int, input().split())\n neighbor_max[A - 1] = max(neighbor_max[A - 1], H[B - 1])\n neighbor_max[B - 1] = max(neighbor_max[B - 1], H[A - 1])\n\n# \u5404\u30ce\u30fc\u30c9\u306b\u3064\u3044\u3066\u3001\u81ea\u8eab\u306e\u9ad8\u3055\u3068\u3001\u96a3\u63a5\u3059\u308b\u5c55\u671b\u53f0\u306e\u9ad8\u3055\u306e\u6700\u5927\u5024\u3092\u6bd4\u8f03\u3059\u308b\n# \u63a5\u7d9a\u3092\u4e00\u3064\u3082\u6301\u305f\u306a\u3044\u30ce\u30fc\u30c9\u306b\u3064\u3044\u3066\u3082\u3001\u8a08\u7b97\u306f\u6b63\u3057\u3044\nans = 0\nfor i in range(N):\n if H[i] > neighbor_max[i]: ans += 1\n \nprint(ans)", "n, m = map(int, input().split())\nheight = [0] + list(map(int, input().split()))\nmawari = [0] * (n+1) \nans = 0\n\nfor _ in range(m):\n a, b = map(int, input().split())\n mawari[a] = max(mawari[a], height[b])\n mawari[b] = max(mawari[b], height[a])\n \n\nfor i in range(1,n+1):\n if height[i]> mawari[i]:\n ans += 1\nprint(ans)", "def i_input(): return int(input())\n\n\ndef i_map(): return list(map(int, input().split()))\n\n\ndef i_list(): return list(map(int, input().split()))\n\n\ndef i_row(N): return [int(input()) for _ in range(N)]\n\n\ndef i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]\n\n\nn,m= i_map()\nhh=i_list()\nab=i_row_list(m)\nt=[1]*n\nfor a,b in ab:\n if hh[a-1]<=hh[b-1]:\n t[a-1]=0\n if hh[b-1]<=hh[a-1]:\n t[b-1]=0\nprint((sum(t)))\n\n", "\ndef main():\n n, m = map(int, input().split(\" \"))\n ls=[{} for _ in range(n)]\n h = list(map(int, input().split(\" \")))\n for i in range(n):\n ls[i] = [h[i]]\n ab = []\n for i in range(m):\n ab.append(list(map(lambda i:int(i)-1, input().split(\" \"))))\n for i in range(m):\n if ls[ab[i][0]][0] >= ls[ab[i][1]][0]:\n ls[ab[i][1]].append(ls[ab[i][0]][0]+1)\n if ls[ab[i][1]][0] >= ls[ab[i][0]][0]:\n ls[ab[i][0]].append(ls[ab[i][1]][0] + 1)\n cnt = 0\n for i in range(n):\n if ls[i][0] == max(ls[i]):\n cnt += 1\n print(cnt)\n\n \n\n \n\ndef __starting_point():\n main()\n__starting_point()", "n,m=map(int,input().split())\nway=[[] for i in range(n)]\nH = list(map(int,input().split()))\nfor i in range(m):\n a,b=map(int,input().split())\n way[a-1].append(b-1)\n way[b-1].append(a-1)\n\nfor i in range(n):\n way[i]=list(set(way[i]))\n\nans=0\nfor i in range(n):\n high=True\n for j in way[i]:\n if H[i]<=H[j]:\n high=0\n break\n if high:\n ans+=1\nprint(ans)", "N, M = map(int, input().split())\nH = list(map(int, input().split()))\n\ngraph = [[] for _ in range(N)]\n\nfor query in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n graph[a].append(b)\n graph[b].append(a)\n\nans = 0\n\nfor now in range(N):\n good = True\n for neighbor in graph[now]:\n if H[now] <= H[neighbor]:\n good = False\n if good:\n ans += 1\n #print(now)\n\nprint(ans)", "N, M = map(int, input().split())\nH = list(map(int, input().split()))\nways = [list(map(int, input().split())) for i in range(M)]\nobservatoryList = [1] * N\nfor i in range(M):\n if H[ways[i][0] - 1] <= H[ways[i][1] - 1]:\n observatoryList[ways[i][0] - 1] = 0\n if H[ways[i][0] - 1] >= H[ways[i][1] - 1]:\n observatoryList[ways[i][1] - 1] = 0\ngoodObservatoryCount = observatoryList.count(1)\nprint(goodObservatoryCount)", "# n\u306f\u5c55\u671b\u53f0\u306e\u6570\u3000m\u306f\u9053\u306e\u6570\nn,m = list(map(int,input().split()))\nhigh = list(map(int,input().split()))\n\na = []\n\nfor x in range(m):\n b = list(map(int,input().split()))\n a.append(b)\n\n\nloser = []\n\nfor y in a:\n high1 = high[y[0]-1]\n high2 = high[y[1]-1]\n if high1 > high2:\n loser.append(y[1])\n elif high1 == high2:\n loser.append(y[0])\n loser.append(y[1])\n else:\n loser.append(y[0])\n\nnew_loser = list(set(loser))\nprint((n-len(new_loser)))\n", "n, m = map(int, input().split())\nh = list(map(int, input().split()))\nc = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n c[a].append(b)\n c[b].append(a)\n\nans = 0\nfor i in range(n):\n high = h[i]\n for j in c[i]:\n if h[j] >= high:\n break\n else:\n ans += 1\nprint(ans)", "n,m = map(int,input().split())\nh = list(map(int,input().split()))\nflg = [1]*n\nfor _ in range(m):\n a,b = map(int,input().split())\n if h[a-1] > h[b-1]:\n flg[b-1] = 0\n elif h[a-1] == h[b-1]:\n flg[a-1],flg[b-1] = 0,0\n else:\n flg[a-1] = 0\nprint(flg.count(1))", "n,m = [int(x) for x in input().split()]\nh = [int(x) for x in input().split()]\na,b = [],[]\nfor i in range(m):\n a1,b1 = [int(x) for x in input().split()]\n a.append(a1-1)\n b.append(b1-1)\nans = [1] * n\nfor i in range(m):\n if h[a[i]] < h[b[i]]:\n ans[a[i]] = 0\n elif h[a[i]] > h[b[i]]:\n ans[b[i]] = 0\n else:\n ans[a[i]] = 0\n ans[b[i]] = 0\nc = 0\nfor i in range(n):\n if ans[i] == 1:\n c += 1\n#print(ans)\nprint(c)", "n,m=map(int,input().split()) \nh =list(map(int,input().split()))\ncnt = 0\nl = [[] for i in range(n)]\nfor i in range(m):\n a,b=map(int,input().split()) \n l[a-1].append(h[b-1])\n l[b-1].append(h[a-1])\n\nfor i in range(n):\n if l[i] == []:\n cnt+=1\n\n elif h[i] > max(l[i]):\n cnt +=1\n \n\nprint(cnt)", "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, M = MI()\n H = LI()\n G = [[] for i in range(N)]\n for i in range(M):\n a, b = MI()\n G[a-1].append(b-1)\n G[b-1].append(a-1)\n res = [-1] * N\n for i in range(N):\n if res[i] != -1:\n continue\n h = H[i]\n ans = True\n for index in G[i]:\n temp_H = H[index]\n if h > temp_H:\n res[index] = 0\n else:\n ans = False\n break\n if ans:\n res[i] = 1\n else:\n res[i] = 0\n ans = 0\n for i in res:\n if i != 0:\n ans+=1\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "N,M = map(int,input().split())\n\nH = list(map(int,input().split()))\n\nans = 0\n\nH2 = []\nfor i in range(N):\n H2.append([0])\n\nfor i in range(M):\n A,B = map(int,input().split())\n \n H2[A-1].append(H[B-1])\n H2[B-1].append(H[A-1])\n\nfor i in range(N):\n H2[i] = max(H2[i])\n\nfor i in range(N):\n if H2[i] < H[i]:\n ans += 1\n\nprint(ans)", "n,m=map(int,input().split())\nh=list(map(int,input().split()))\nl=[1]*n\nfor i in range(m):\n a,b=map(int,input().split())\n if h[a-1]==h[b-1]:\n l[a-1]=0\n l[b-1]=0\n if h[a-1]>h[b-1]:\n l[b-1]=0\n if h[a-1]<h[b-1]:\n l[a-1]=0\nprint(l.count(1))", "n,m = map(int, input().split())\nH = list(map(int, input().split()))\ng = [1]*n\n\nfor i in range(m):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n if H[a]<H[b]:\n g[a] = 0\n elif H[a]>H[b]:\n g[b] = 0\n else:\n g[a] = g[b] = 0\nprint(sum(g))", "N, M = map(int, input().split())\nH = list(map(int, input().split()))\nA = [True for i in range(N)]\nfor i in range(M) :\n a,b = map(int, input().split())\n a -= 1\n b -= 1\n if(H[a] <= H[b]) :\n A[a] = False\n if(H[b] <= H[a]) :\n A[b] = False\n\nans = 0\nfor i in range(N) :\n if(A[i]) :\n ans += 1\nprint(ans)", "N,M = map(int,input().split())\nH = list(map(int,input().split()))\nglaph = [[] for _ in range(N)]\n\nfor i in range(M):\n A,B = map(int,input().split())\n A -= 1\n B -= 1\n glaph[A].append(B)\n glaph[B].append(A)\n \nans = 0\nfor j in range(N):\n check = True\n for k in glaph[j]:\n if H[j] <= H[k]:\n check = False\n break\n if check:\n ans += 1\n \nprint(ans)", "[N, M] = [int(i) for i in input().split()]\nH = [int(i) for i in input().split()]\ndic = {}\nfor i in range(M):\n [a, b] = [int(i) for i in input().split()]\n if a in dic:\n dic[a].append(b)\n else:\n dic[a] = [b]\n if b in dic:\n dic[b].append(a)\n else:\n dic[b] = [a]\n\nans = 0\nfor i in range(1, N+1):\n s = H[i-1]\n t = 0\n if i in dic:\n for j in range(len(dic[i])):\n if s <= H[dic[i][j]-1]:\n t += 1\n break\n if t == 0:\n ans += 1\n else:\n ans += 1\n\nprint(ans)", "n,m = list(map(int,input().split()))\nh = list(map(int,input().split()))\nab = [list(map(int,input().split())) for _ in range(m)]\n\nplace = [True]*n\n\nfor i in range(m):\n a,b = ab[i][0],ab[i][1]\n if h[a-1] < h[b-1]:\n place[a-1] = False\n elif h[a-1] == h[b-1]:\n place[a-1] = False\n place[b-1] = False\n else:\n place[b-1] = False\n\nprint((place.count(True)))\n", "N, M = map(int, input().split())\nH = list(map(int, input().split()))\narray = [0] * N\nans = 0\n\nfor i in range(M):\n A, B = map(int, input().split())\n A -= 1\n B -= 1\n array[A] = max(array[A], H[B])\n array[B] = max(array[B], H[A])\n\nfor j in range(N):\n if array[j] < H[j]:\n ans += 1\n\nprint(ans)", "n, m = list(map(int, input().split()))\nh = list(map(int, input().split()))\nab = [list(map(int, input().split())) for _ in range(m)]\na, b = [list(i) for i in zip(*ab)]\nl = [1 for _ in range(n)]\n\nfor i in range(m):\n if h[a[i]-1] < h[b[i]-1]:\n l[a[i]-1] = 0\n elif h[a[i]-1] > h[b[i]-1]:\n l[b[i]-1] = 0\n else:\n l[b[i]-1] = 0\n l[a[i]-1] = 0\n\nprint((l.count(1))) \n", "N,M = map(int,input().split())\nH = [int(i) for i in input().split()]\nA = []\nB = []\nfor i in range(M):\n a,b = map(int,input().split())\n A.append(a)\n B.append(b)\nI = []\nans = 0\nfor i in range(1,N+1):\n I.append([i])\nfor i in range(M):\n I[A[i]-1].append(B[i])\n I[B[i]-1].append(A[i])\nfor i in range(N):\n count = 0\n a = H[i]\n if(count < 2):\n for j in range(len(I[i])):\n if(H[I[i][j]-1] >= a):\n count += 1\n if(count < 2):\n ans += 1\nprint(ans)", "def __starting_point():\n\n #\u96a3\u63a5\u30ea\u30b9\u30c8(graph)\n n,m = list(map(int,input().split()))\n H = [int(h) for h in input().split()]\n\n graph = [[]for _ in range(n)]\n\n for _ in range(m):\n a,b = list(map(int,input().split()))\n graph[a-1].append(b-1)\n graph[b-1].append(a-1)\n\n #\u3053\u306e\u30ea\u30b9\u30c8\u304b\u3089\u76f8\u624b\u3068\u306e\u95a2\u4fc2\u3092\u8abf\u3079\u3066\u3088\u3044\u5c55\u671b\u53f0\u304b\u3069\u3046\u304b\u8abf\u3079\u308b\uff1f\n good = 0\n for i,g in enumerate(graph):\n moto = H[i]\n flg = True\n for sk in g:\n saki = H[sk]\n if moto <= saki:\n flg = False\n break\n if flg:\n good += 1\n print(good)\n\n\n__starting_point()", "# C - Peaks\n\nn,m = list(map(int, input().split()))\nh = list(map(int,input().split()))\nab = []\nfor i in range(m):\n ab.append(list(map(int,input().split())))\n\npeak = [1]*n\nfor i in range(m):\n if h[ab[i][0]-1] >= h[ab[i][1]-1]:\n peak[ab[i][1]-1] = 0\n if h[ab[i][0]-1] <= h[ab[i][1]-1]:\n peak[ab[i][0]-1] = 0\nprint((sum(peak)))\n", "n,m = map(int,input().split())\nh = list(map(int,input().split()))\nla = [0] * n\nfor i in range(m):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n la[a] = max(la[a],h[b])\n la[b] = max(la[b],h[a])\n\nans = 0\n \nfor i in range(n):\n if la[i] < h[i]:\n ans += 1\n \nprint(ans)", "n, m = list(map(int, input().split()))\nh = list(map(int, input().split()))\nab = [list(map(int, input().split())) for _ in range(m)]\nans = [1]*n\nfor i in range(m):\n if h[ab[i][0]-1] == h[ab[i][1]-1]:\n ans[ab[i][0]-1] = 0\n ans[ab[i][1]-1] = 0\n elif h[ab[i][0]-1] > h[ab[i][1]-1]:\n ans[ab[i][1]-1] = 0\n else:\n ans[ab[i][0]-1] = 0\nprint((sum(ans)))\n", "N, M = list(map(int,input().split()))\nH = list(map(int,input().split()))\nAB = [list(map(int,input().split())) for _ in range(M)]\n\npath = [[] for _ in range(N)]\nfor a,b in AB:\n a,b = a-1, b-1\n path[a].append(b)\n path[b].append(a)\n \nans = 0\nfor i,p in enumerate(path):\n h = H[i]\n tmp = 0\n for pp in p:\n tmp = max(tmp, H[pp])\n if tmp<h:\n ans+=1\n \nprint(ans)\n", "#!/usr/bin/env python3\n\nN, M = list(map(int, input().split()))\nh_list = list(map(int, input().split()))\nh_dict = {i + 1: h for i, h in enumerate(h_list)}\nh_set = set(h_dict.keys())\nno_list = []\n\nfor _ in range(M):\n a, b = list(map(int, input().split()))\n if h_dict[a] == h_dict[b]:\n no_list.append(a)\n no_list.append(b)\n elif h_dict[a] > h_dict[b]:\n no_list.append(b)\n else:\n no_list.append(a)\n\nno_set = set(no_list)\nans = len(h_set - no_set)\n\nprint(ans)\n", "n, m = map(int, input().split())\nh = list(map(int, input().split()))\nD = dict()\nfor i in range(1, n+1):\n D[i] = h[i-1]\nL = [1 for i in range(n)]\nfor _ in range(m):\n a, b =map(int, input().split())\n if D[a] > D[b]:\n L[b-1] = 0\n elif D[a] == D[b]:\n L[a-1] = 0\n L[b-1] = 0\n else:\n L[a-1] = 0\nans = 0\nfor e in L:\n ans += e\nprint(ans)", "\n\nN, M = map(int,input().split())\nH = list(map(int, input().split()))\nA = [0]*M\nB = [0]*M\nLists = [[] for _ in range(N)]\nfor i in range(M):\n A[i], B[i] = map(lambda x: int(x)-1, input().split())\n Lists[A[i]].append(B[i]) \n Lists[B[i]].append(A[i]) \n\n#print(Lists)\nans = 0\nfor i in range(N):\n Heighest = 0\n #print(Lists[i])\n #print(\"H[i]:\", H[i])\n for j in range(len(Lists[i])):\n #print(\"H[List[i][j]]:\", H[Lists[i][j]]) \n Heighest = max(Heighest, H[ Lists[i][j] ])\n #print(Heighest)\n #print(H[i])\n if Heighest <H[i]:\n #print(\"Heighest = \", Heighest)\n ans += 1\n\nprint(ans)", "n,m=map(int,input().split())\nh=list(map(int,input().split()))\nr=[]\n\nt=['W']*n\n\nfor i in range(m):\n a,b=list(map(int,input().split()))\n if h[a-1]>=h[b-1]:\n t[b-1]='L'\n if h[a-1]<=h[b-1]:\n t[a-1]='L'\nprint(t.count('W'))", "n, m = list(map(int,input().split()))\nlst = list(map(int,input().split()))\nlst2 = []\nfor i in range(n):\n lst3 = [lst[i]]\n lst2.append(lst3)\n\nfor i in range(m):\n a, b = list(map(int,input().split()))\n a = a - 1\n b = b - 1\n lst2[a].append(lst2[b][0])\n lst2[b].append(lst2[a][0])\n\nans = 0\nfor i in range(n):\n x = lst2[i][0]\n lst2[i].sort()\n lst2[i].reverse()\n if (len(lst2[i]) == 1):\n ans = ans + 1\n elif (x == lst2[i][0]):\n lst2[i].pop(0)\n y = lst2[i][0]\n if (x != y):\n ans = ans + 1\n\nprint(ans)\n", "n,m = list(map(int, input().split()))\nh = list(map(int, input().split()))\nhoge = [[] for _ in range(n)]\nfor i in range(m):\n a,b = list(map(int, input().split()))\n hoge[a - 1].append(b - 1)\n hoge[b - 1].append(a - 1)\n \ncnt = 0\nfor i in range(n):\n if hoge[i]:\n flag = True\n for j in hoge[i]:\n if h[i] <= h[j]:\n flag = False\n if flag:\n cnt += 1\n else:\n cnt += 1\n \nprint(cnt)", "import copy\n\nn,m = list(map(int, input().split()))\nh = [0] + list(map(int, input().split()))\n\ntowers = [[] for _ in range(n + 1)]\n\nfor i in range(m):\n a, b = list(map(int, input().split()))\n towers[a].append(b)\n towers[b].append(a)\n\ncnt = 0\nfor i in range(1, n + 1):\n for j in towers[i]:\n if h[i] <= h[j]:\n break\n else:\n cnt += 1\n\nprint(cnt)\n \n", "n,m=list(map(int,input().split()))\nh=list(map(int,input().split()))\nA=[[] for i in range(n)]\nfor i in range(m) :\n a,b=list(map(int,input().split()))\n A[a-1].append(h[b-1])\n A[b-1].append(h[a-1])\n\ncount=0\nfor i in range(n) :\n if A[i]==[] :\n count+=1\n elif max(A[i])<h[i] :\n count+=1\n else :\n continue\n\nprint(count) \n\n", "n, m = list(map(int, input().split()))\nh = list(map(int, input().split()))\nneighbor = [[] for _ in range(n)]\n\nfor i in range(m):\n a, b = list(map(int, input().split()))\n neighbor[a - 1].append(b - 1)\n neighbor[b - 1].append(a - 1)\n\ncnt = 0\nfor i in range(n):\n if all([h[i] > h[j] for j in neighbor[i]]):\n cnt += 1\nprint(cnt)", "N, M = list(map(int, input().split()))\nH = list(map(int, input().split()))\npeaks = [1] * N\nfor i in range(M):\n A, B = list(map(int, input().split()))\n if H[A - 1] > H[B - 1]:\n peaks[B - 1] = 0\n elif H[B - 1] > H[A - 1]:\n peaks[A - 1] = 0\n else:\n peaks[A - 1] = 0\n peaks[B - 1] = 0\n\nprint((sum(peaks)))\n", "n,m = map(int,input().split())\nH = list(map(int,input().split()))\nL = [1]*n\nfor _ in range(m):\n a,b = map(int,input().split())\n if H[a-1] == H[b-1]:\n L[a-1] = 0\n L[b-1] = 0\n elif H[a-1] < H[b-1]:\n L[a-1] = 0\n elif H[a-1] > H[b-1]:\n L[b-1] = 0\nprint(sum(L))", "from collections import defaultdict\n\nN, M = map(int, input().split())\nH = list(map(int, input().split()))\n\nedge = defaultdict(list)\n\nfor i in range(M):\n a, b = map(int, input().split())\n edge[a - 1].append(H[b - 1])\n edge[b - 1].append(H[a - 1])\n\nans = 0\nfor i in range(N):\n if len(edge[i]) == 0 or H[i] > max(edge[i]):\n ans += 1\n\nprint(ans)", "def main():\n n, m = list(map(int, input().split()))\n h = list(map(int, input().split()))\n hf = [0] * n\n for i in range(m):\n a, b = list(map(int, input().split()))\n if h[a-1] > h[b-1]:\n hf[b-1] = 1\n elif h[a-1] == h[b-1]:\n hf[a-1] = 1\n hf[b-1] = 1\n else:\n hf[a-1] = 1\n print(hf.count(0))\n\ndef __starting_point():\n main()\n__starting_point()", "#!/usr/bin/env python3\nimport sys\nfrom itertools import chain\n\n\ndef solve(\n N: int, M: int, H: \"List[int]\", A: \"List[int]\", B: \"List[int]\"\n):\n ok = [1 for _ in range(N)]\n for a, b in zip(A, B):\n if H[a - 1] <= H[b - 1]:\n ok[a - 1] = 0\n if H[b - 1] <= H[a - 1]:\n ok[b - 1] = 0\n\n return sum(ok)\n\n\ndef main():\n tokens = chain(*(line.split() for line in sys.stdin))\n N = int(next(tokens)) # type: int\n M = int(next(tokens)) # type: int\n H = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n A = [int()] * (M) # type: \"List[int]\"\n B = [int()] * (M) # type: \"List[int]\"\n for i in range(M):\n A[i] = int(next(tokens))\n B[i] = int(next(tokens))\n answer = solve(N, M, H, A, B)\n print(answer)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n,m=map(int,input().split())\nway=[[] for i in range(n)]\nH = list(map(int,input().split()))\nfor i in range(m):\n a,b=map(int,input().split())\n way[a-1].append(b-1)\n way[b-1].append(a-1)\nans=0\nfor i in range(n):\n high=True\n for j in way[i]:\n if H[i]<=H[j]:\n high=0\n break\n if high:\n ans+=1\nprint(ans)", "N, M = map(int, input().split())\nH = [0] + list(map(int, input().split()))\n\ng = [[] for _ in range(N+1)]\nfor i in range(M):\n a, b = map(int, input().split())\n g[a].append(b)\n g[b].append(a)\n\nans = 0\nfor j in range(1, N+1):\n for k in g[j]:\n if H[j] <= H[k]:\n break\n else:\n ans += 1\nprint(ans)", "# coding=utf-8\n\ndef __starting_point():\n N, M = list(map(int, input().split()))\n Hli = list(map(int, input().split()))\n\n #road = [[0] * 2 for i in range(M)]\n\n ans = [0] * N\n\n for i in range(M):\n A, B = list(map(int, input().split()))\n\n if Hli[A-1] < Hli[B-1]:\n ans[A-1] += 1\n\n elif Hli[A-1] == Hli[B-1]:\n ans[A - 1] += 1\n ans[B - 1] += 1\n \n else:\n ans[B-1] +=1\n\n #print(ans)\n print((ans.count(0)))\n\n__starting_point()", "N, M = map(int, input().split())\nH = list(map(int, input().split()))\nOK = [True] * N\nfor _ in range(M):\n A, B = map(lambda x: int(x)-1, input().split())\n if H[A] < H[B]:\n OK[A] = False\n elif H[A] > H[B]:\n OK[B] = False\n else:\n OK[A] = False\n OK[B] = False\n\nans = sum(OK)\nprint(ans)", "n, m = list(map(int, input().split()))\narr = [0] + list(map(int, input().split()))\ng = [[] for _ in range(n + 1)]\nfor _ in range(m):\n a, b = list(map(int, input().split()))\n g[a].append(b)\n g[b].append(a)\n\nans = 0\nfor i in range(1, n + 1):\n for j in g[i]:\n if arr[j] >= arr[i]:\n break\n else:\n ans += 1\n\nprint(ans)\n", "N,M = map(int,input().split())\nH = list(map(int,input().split()))\nmx = [0 for i in range(N)]\nfor _ in range(M):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n mx[a] = max(mx[a], H[b])\n mx[b] = max(mx[b], H[a])\nans = 0\nfor i in range(N):\n if H[i] > mx[i]:\n ans += 1\nprint(ans)", "n,m = map(int,input().split())\nh = list(map(int,input().split()))\nl = list({i} for i in range(n+1))\nfor i in range(m):\n a,b = map(int,input().split())\n l[a].add(b)\n l[b].add(a)\n \nfor i in range(len(l)):\n l[i] = list(l[i])\ngood = set()\nfor i in range(1,len(l)):\n l[i].remove(i)\n for j in range(len(l[i])):\n if h[l[i][j]-1] >= h[i-1]:\n break\n else:\n good.add(i)\nprint(len(good))", "n,m=list(map(int,input().split()))\nl=list(map(int,input().split()))\nans=[1]*n\nfor i in range(m):\n a,b=list(map(int,input().split()))\n if l[a-1]<l[b-1]:\n ans[a-1]=0\n elif l[a-1]>l[b-1]:\n ans[b-1]=0\n else:\n ans[a-1]=0\n ans[b-1]=0\nprint((sum(ans)))\n", "n,m=map(int,input().split())\nh=list(map(int,input().split()))\n\nt=['W']*n\n\nfor i in range(m):\n a,b=map(int,input().split())\n if h[a-1]>=h[b-1]:\n t[b-1]='L'\n if h[a-1]<=h[b-1]:\n t[a-1]='L'\nprint(t.count('W'))", "n,m = map(int, input().split())\nh = list(map(int, input().split()))\nab = [map(int, input().split()) for _ in range(m)]\na,b = [list(i) for i in zip(*ab)]\nMax = []\nfor i in range(n):\n Max.append(0)\n# print(Max)\nans = 0\nfor i in range(m):\n Max[a[i]-1] = max(Max[a[i]-1],h[b[i]-1])\n Max[b[i]-1] = max(Max[b[i]-1],h[a[i]-1])\n\nfor i in range(n):\n if h[i] > Max[i]:\n ans += 1\nprint(ans)", "_,H,*P=open(0);*H,=map(int,[0]+H.split());T=[1]*len(H)\nfor p in P:\n a,b=map(int,p.split());T[min(a,b,key=lambda x:H[x])]=0\n if H[a]==H[b]:T[b]=0\nprint(sum(T)-1)", "N, M = map(int, input().split())\nH = list(map(int, input().split())) #\u5c55\u671b\u53f0i\u306e\u6a19\u9ad8\nassert len(H) == N\npaths = [[] for i in range(N)]\nfor m in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n paths[a].append(b)\n paths[b].append(a) # \u5c55\u671b\u53f0A\u304b\u3089B\u3078\u306e\u9053\u3001\u305d\u306e\u9006\n\ncount = 0\nfor a in range(N):\n for b in paths[a]:\n if H[b] >= H[a]:\n break\n else:\n count += 1\nprint(count)"] | {"inputs": ["4 3\n1 2 3 4\n1 3\n2 3\n2 4\n", "6 5\n8 6 9 1 2 1\n1 3\n4 2\n4 3\n4 6\n4 6\n"], "outputs": ["2\n", "3\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 42,609 | |
b33ab3376c5f160ec1831bf64e6293b0 | UNKNOWN | Square1001 has seen an electric bulletin board displaying the integer 1.
He can perform the following operations A and B to change this value:
- Operation A: The displayed value is doubled.
- Operation B: The displayed value increases by K.
Square1001 needs to perform these operations N times in total.
Find the minimum possible value displayed in the board after N operations.
-----Constraints-----
- 1 \leq N, K \leq 10
- All input values are integers.
-----Input-----
Input is given from Standard Input in the following format:
N
K
-----Output-----
Print the minimum possible value displayed in the board after N operations.
-----Sample Input-----
4
3
-----Sample Output-----
10
The value will be minimized when the operations are performed in the following order: A, A, B, B.
In this case, the value will change as follows: 1 β 2 β 4 β 7 β 10. | ["#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\nk = int(input())\n\nans = 1\nfor i in range(n):\n if ans*2 <= (ans+k):\n ans *= 2\n else:\n ans += k\n # print(ans)\nprint(ans)\n", "N = int(input())\nK = int(input())\n\nvalue = 1\n\nfor i in range(N):\n if(value * 2 <= value + K):\n value = value * 2\n else:\n value = value + K\n\nprint(value)", "n = int(input())\nk = int(input())\n\ncnt = 1\nfor _ in range(n):\n cnt = min(cnt*2, cnt+k)\nprint(cnt)", "N = int(input())\nK = int(input())\nans = 1\nfor _ in range(N):\n if ans * 2 <= ans + K:\n ans *= 2\n else:\n ans += K\nprint(ans)\n", "n=int(input())\nk=int(input())\nans=1\nfor _ in range(n):\n if(ans*2 < ans+k):\n ans=ans*2\n else:\n ans=ans+k\n \nprint(ans)", "N = int(input())\nK = int(input())\n\nstart = 1\n\nfor n in range(N):\n start = min(start*2, start+K)\n\nprint(start)\n", "N = int(input())\nK = int(input())\n\nans = 1\nfor _ in range(N):\n ans = min(ans * 2, ans + K)\nprint(ans)", "a=int(input())\nb=int(input())\nc=1\nfor i in range(a):\n if 2*c<=c+b:\n c=2*c\n else:\n c=c+b\nprint(c)", "N = int(input())\nK = int(input())\n\nans = 1\nfor _ in range(N):\n ans = min(ans*2,ans+K)\nprint(ans)", "n = int(input())\nk = int(input())\nref = 1\n\nfor i in range(n):\n if ref * 2 < ref + k:\n ref *= 2\n else:\n ref += k\n\nprint(ref)", "n=int(input())\nk=int(input())\ndis = 1\nfor i in range(n):\n if dis*2 <= dis+k:\n dis *= 2\n else:\n dis += k\nprint(dis)", "n = int(input())\nk = int(input())\n\ntmp = 1\nfor i in range(n):\n tmp = min(tmp * 2, tmp + k)\nprint(tmp)\n", "n = int(input())\nk = int(input())\na = 1\nfor i in range(n):\n if a <= k:\n a *= 2\n else:\n a += k\nprint(a)", "n = int(input())\nk = int(input())\na = 1\nfor i in range(n):\n a = min(2*a,a+k)\nprint(a)", "N=int(input())\nK=int(input())\n\nans=1\nfor i in range(N):\n if ans<=K:\n ans*=2\n else:\n ans+=K\n\nprint(ans)", "N=int(input())\nK=int(input())\nstart=1\nfor i in range(N):\n start_a=start*2\n start_b=start+K\n if start_a<=start_b:\n start=start_a\n else:\n start=start_b\n\nprint(start)", "# -*- coding: utf-8 -*-\nn = int(input())\nk = int(input())\nans = 1\nfor i in range(n):\n ans = min(ans*2, ans+k)\n\nprint(ans)\n", "n = int(input())\nk = int(input())\nc = 1\nfor i in range(n):\n if c > k:\n c += k\n else:\n c *= 2\nprint(c)", "N,K = [int(input()) for _ in range(2)]\n\nans = 1\n\nfor _ in range(N):ans = min(ans+K,ans*2)\n\nprint(ans)\n", "N = int(input())\nK = int(input())\nans = 1\nfor i in range(N):\n ans = min(ans*2, ans+K)\nprint(ans)\n", "n = int(input())\nk = int(input())\nnum = 1\n\nfor i in range(n):\n num = min(num + k, num * 2)\n \nprint(num)", "N = int(input())\nK = int(input())\n\nans = 1\n\ndef A(n):\n return 2 * n\n\ndef B(n):\n return n + K\n\nfor i in range(N):\n if A(ans) <= B(ans):\n ans = A(ans)\n else:\n ans = B(ans)\n\nprint(ans)", "n=int(input())\nk=int(input())\na=1\nfor _ in range(n):\n if a<k:\n a*=2\n else:\n a+=k\nprint(a)", "n = int(input())\nk = int(input())\n\nx = 1\nfor i in range(n):\n x = min(x * 2, x + k)\nprint(x)\n", "n = int(input())\nk = int(input())\n\nans = 1\nfor i in range(n):\n if ans >= k:\n ans += k\n else:\n ans *= 2\nprint(ans)", "n=int(input())\nk=int(input())\nans=1\nfor _ in range(n):\n if ans<k:ans*=2\n else:ans+=k\nprint(ans)", "n,k=int(input()),int(input());a=1\nwhile a<=k:\n if n==0:\n print(a)\n return\n a*=2\n n-=1\nwhile n>0:\n a+=k\n n-=1\nprint(a)", "n=int(input())\nk=int(input())\ngiven_integer=1\n#Option A:-To Increase The Value By double\n#Option B:-To Increase Value By K\n\nfor i in range(0,n):\n\tgiven_integer=min(given_integer*2,given_integer+k)\n\nprint((int(given_integer)))\n", "n,k = int(input()),int(input())\n# Greedy\nans = 1\nfor i in range(n):\n ans = min(ans+k, ans*2)\nprint(ans)", "n = int(input())\nk = int(input())\nans = 1\nfor _ in range(n):\n if ans < k:\n ans *= 2\n else:\n ans += k\nprint(ans)\n", "n = int(input())\nk = int(input())\n\ncnt = 1\ntmp = 0\nfor i in range(n):\n cnt = min(cnt*2, cnt + k)\nprint(cnt)", "n = int(input())\nk = int(input())\nans = 1\nfor i in range(n):\n ans = min(ans*2,ans+k)\nprint(ans)", "n, k = [int(input()) for _ in range(2)]\n\nresult = 10 ** 9\n\nfor bit in range(2 ** n):\n \n tmp = 1\n for i in range(n):\n if bit & (1 << i):\n tmp *= 2\n else:\n tmp += k\n \n result = min(result, tmp)\n \nprint(result)", "n=int(input())\nk=int(input())\na=1\nfor i in range(n):\n if a<=k:\n a*=2\n else:\n a+=k\n\nprint(a)", "n, k = (int(input()) for i in range(0, 2))\nans = 1\nfor i in range(0, n):\n if ans * 2 <= ans + k: ans *= 2\n else: ans += k\nprint(ans)", "n,k = [int(input()) for i in range(2)]\n\nnumber=1\n\nfor i in range(n):\n number = min(2*number, number+k)\nprint(number)", "n = int(input())\nk = int(input())\nans = 1\nfor _ in range(n):\n if ans * 2 > ans + k:\n ans += k\n else:\n ans *= 2\nprint(ans)", "N = int(input())\nK = int(input())\n\nres = 1\nfor i in range(N):\n if(K >= res):\n res *= 2\n else:\n res += K\nprint(res)\n", "n = int(input())\nk = int(input())\nnum = 1\nfor i in range(n):\n if num*2 <= num+k:\n num *= 2\n else:\n num += k\n\nprint(num)", "n = int(input())\nk = int(input())\n\na = 1\nfor i in range(n):\n if a <= k:\n a *= 2\n else:\n a += k\nprint(a)", "N = int(input())\nK = int(input())\nX = 1\nfor i in range(N):\n if X<K:\n X += X\n else:\n X += K\n\nprint(X)\n", "# coding: utf-8\nimport math\n\nans = 1\ncount = 0\nnum1 = int(input())\nnum2 = int(input())\nfor i in range(num1):\n if ans < num2:\n ans *= 2\n else:\n ans += num2\nprint(ans)", "ans=float('inf')\nn,k=int(input()),int(input())\nfor i in range(2**n):\n ans=min(ans,eval('('*n+'1'+\"\".join('*2)'if (i>>j)%2 else '+'+str(k)+')' for j in range(n))))\nprint(ans)", "n = int(input())\nk = int(input())\na = 1\nfor i in range(n):\n if a<k:\n a = a*2\n else:\n a+=k\nprint(a)", "n = int(input())\nk = int(input())\nx = 1\nfor i in range(n):\n if x + k <= 2*x:\n x += k\n else:\n x *= 2\nprint(x)", "N = int(input())\nK = int(input())\n\nstart = 1\nfor i in range(N):\n start = min(start * 2, start + K)\n\nprint(str(start))", "N = int(input())\nK = int(input())\nj = 1\ndef func(x, y):\n r = (x * 2) if (x * 2) < (x + y) else (x + y)\n return r\n\nfor i in range(N):\n j = func(j, K)\nprint(j)", "n = int(input())\nk = int(input())\n\nans = 1\n\nfor i in range (0 , n):\n ans = min(2 * ans, ans + k)\nprint(ans)", "n = int(input())\nk = int(input())\nnumb = 1\nfor i in range(n):\n if 2*numb < numb+k:\n numb *= 2\n else:\n numb += k\nprint(numb)", "N=int(input())\nK=int(input())\nx=1\nfor _ in range(N):\n x=min(2*x,x+K)\nprint(x)\n", "N = int(input())\nK = int(input())\n\nout = 1\nflg = 0\nfor i in range(N):#A\u306e\u56de\u6570\u3092\u6570\u3048\u308b\u305f\u3081\u306e\u30eb\u30fc\u30d7\n if not flg:#\u30d5\u30e9\u30b0\u304c\u7acb\u3063\u3066\u306a\u304b\u3063\u305f\u3089\u64cd\u4f5cA\n out *= 2\n if out > K:\n flg = 1\n else:#\u30d5\u30e9\u30b0\u304c\u7acb\u3063\u305f\u3089\u64cd\u4f5cB\n out += K\n\nprint(out)", "def main():\n n = int(input())\n k = int(input())\n\n ans = 1\n for i in range(n):\n ans = min(2*ans, ans+k)\n print(ans)\n\n\nmain()", "n=int(input())\nk=int(input())\ns=1\nfor i in range(n):\n s=min(s*2,s+k)\nprint(s)", "N=int(input())\nK=int(input())\nans=1000\nfor i in range(N+1):\n num=1\n for s in range(i):\n num = num*2\n \n for t in range(N-i):\n num += K\n \n if num < ans:\n ans = num\n\nprint(ans)", "#76B\nn=int(input())\nk=int(input())\nf=1\nfor i in range(0,n):\n if f*2<f+k:\n f=f*2\n else:\n f=f+k\nprint(f)", "n,k=int(input()),int(input())\nans=1\ni=0\nwhile i!=n:\n if ans>=k:\n ans+=k\n else:\n ans*=2\n i+=1\nprint(ans)", "#!/usr/bin/env python3\n\nN = int(input())\nK = int(input())\n\nans = 1\nfor i in range(N):\n a = ans * 2\n b = ans + K\n ans = min(a, b)\nprint(ans)\n", "N=int(input())\nK=int(input())\na=1\nfor i in range(N):\n if a < K:\n a *= 2\n else:\n a += K\nprint(a)", "N = int(input())\nK = int(input())\n\nx = 1\nfor _ in range(N):\n x += min(x, K)\n\nprint(x)", "n, k = [int(input()) for i in range(2)]\na = 1\nfor i in range(n):\n if a * 2 > a + k:\n a += k\n else:\n a *= 2\nprint(a)", "n,k = int(input()),int(input())\nans = 1\nfor i in range(n):\n ans = min(ans+k,ans*2)\nprint(ans)\n", "n = int(input())\nk = int(input())\n\nans = 1\n\nfor i in range(n):\n ans = min(ans*2, ans+k)\n\nprint(ans)", "N = int(input())\nK = int(input())\nstart = 1\nfor i in range(N):\n start = min(start*2, start+K)\nprint(start)", "def answer(n: int, k: int) -> int:\n current_num = 1\n for _ in range(n):\n current_num = min(current_num * 2, current_num + k)\n\n return current_num\n\n\ndef main():\n n =int(input())\n k = int(input())\n print((answer(n, k)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nk = int(input())\n\nres = 1\nfor i in range(n):\n if res >= k:\n res += k\n else:\n res *= 2\nprint(res)\n", "N=int(input())\nK=int(input())\n\n#A+B=N\n#A:C[i]*2 \n#B:C[i]+K\n \nC=1\nfor i in range(N):\n if C*2>C+K:\n C=C+K\n else:\n C=C*2\n \nprint(C)\n \n\n", "def solve():\n n = int(input())\n k = int(input())\n ans = 1\n for i in range(n):\n if ans < k:\n ans *= 2\n else:\n ans += k\n\n print(ans)\n\n\ndef __starting_point():\n solve()\n\n__starting_point()", "n = int(input())\nk = int(input())\n \nnum = 1\ncount = 0\n \nwhile count < n:\n num = min(num * 2, num + k)\n count += 1\n \nprint(num)", "n = int(input())\nk = int(input())\n\nans = 1\nfor r in range(n):\n if ans <= k:\n ans *= 2\n else:\n ans += k\n\nprint(ans)", "N = int(input())\nK = int(input())\ninit = 1\nfor i in range(N):\n init = min(init*2, init + K)\nprint(init)", "N = int(input())\nK = int(input())\n\na = 1\nfor _ in range(N):\n if a*2 < a+K:\n a *= 2\n else:\n a += K\nprint(a)", "n=int(input())\nk=int(input())\n\nnum=1\nfor i in range(n):\n num=min(num*2,num+k)\n\nprint(num)", "n=int(input())\nk=int(input())\nans=1\nfor i in range(n):\n if ans<k:\n ans*=2\n else:\n ans+=k\nprint(ans)", "N = int(input())\nK = int(input())\n\nans = 1\nfor _ in range(N):\n if ans + K < 2 * ans:\n ans += K\n else:\n ans *= 2\nprint(ans)", "n = int(input())\nk = int(input())\ni=1\nfor _ in range(n):\n i = i+min(i,k)\nprint(i)", "n=int(input())\nk=int(input())\n\nfrom itertools import product\n\npr = list(product([0,1],repeat=n))\n\nans=float('inf')\nfor p in pr:\n\n tmp=1\n for i in p:\n if i==0:\n tmp*=2\n else:\n tmp+=k\n\n ans= min(ans,tmp)\n\n\nprint(ans)\n\n", "n = int(input())\nk = int(input()) \nmn = 1\nfor i in range(n):\n if mn + k <= mn *2:\n mn += k\n else:\n mn = mn * 2\nprint(mn)\n", "N = int(input())\nK = int(input())\ns = 1\nfor _ in range(N):\n s = min(s * 2, s + K)\nprint(s)", "n = int(input())\nk = int(input())\n\ncnt = 1\nfor _ in range(n):\n if cnt <= k:\n cnt *= 2\n else:\n cnt += k\nprint(cnt)", "N = int(input())\nK = int(input())\n\nans = float(\"inf\")\nfor i in range(N+1):\n num = 1 * (2 ** i) + K * (N - i)\n ans = min(ans, num)\n \nprint(ans)", "from functools import reduce\n\ndef operator(x, K, N):\n res = (lambda x: 2*x if x < K else x+K)(x)\n return res if N == 1 else operator(res, K, N-1)\n\ndef main():\n with open(0) as f:\n N, K = list(map(int, f.read().split()))\n ans = operator(1, K, N)\n print(ans)\n\nmain() \n", "N = int(input())\nK = int(input())\nans = 1\nfor i in range(N):\n ans = min(2*ans,ans+K)\nprint(ans)", "N = int (input ())\nK = int (input ())\ns = 1\nfor i in range (N):\n if s < K:\n s = s*2\n else:\n s += K\nprint (s)", "N = int(input())\nK = int(input())\na = 1\nfor _ in range(N):\n a = min(a*2, a+K)\nprint(a)", "N = int(input())\nK = int(input())\nx = 1\nfor _ in range(N):\n\tx = min(x * 2, x + K)\nprint(x)", "n = int(input())\nk = int(input())\nans = 1\nfor _ in range(n):\n ans = min(ans*2, ans+k)\nprint(ans)", "N = int(input())\nK = int(input())\ndisplay = 1\n\nfor i in range(N):\n display = min(display*2, display + K)\nprint(display)\n", "n = int(input())\nk = int(input())\n\nans = 1\nfor i in range(n):\n ans = min(ans * 2, ans + k)\n \nprint(ans)", "import sys\n\ninput = sys.stdin.readline\nN = int(input())\nK = int(input())\n\nc = 0\ntmp = 1\nwhile c < N:\n if tmp < K:\n tmp *= 2\n else:\n tmp += K\n c += 1\n # print(tmp)\n\nprint(tmp)", "a = int(input())\nb = int(input())\nx = 1\nfor i in range(a):\n if x + b > x * 2:\n x = x * 2\n else:\n x = x + b\nprint(x)", "n,k=int(input()),int(input());a=1\nfor _ in range(n): a=min(2*a,k+a)\nprint(a)", "N=int(input())\nK=int(input())\nres=1\nfor i in range(N) :\n if res*2<=res+K :\n res*=2\n else :\n res+=K\nprint(res)", "n = int(input())\nk = int(input())\nans = 1\nfor i in range(n):\n ans = min(ans*2,ans+k)\nprint(ans)", "n=int(input())\nk=int(input())\nans=1\nfor i in range(n):\n ans=min(ans+k,ans*2)\nprint(ans)", "N=int(input())\nK=int(input())\nnow=1\nfor i in range(N):\n now=min(now*2,now+K)\nprint(now)", "n = int(input())\nk = int(input())\nc = 1\nfor i in range(n):\n c = min(2*c, c+k)\nprint(c)", "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n N = I()\n K = I()\n\n ans = 1\n while ans < K and N > 0:\n ans *= 2\n N -= 1\n ans += N * K\n\n print(ans)\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "N = int(input())\nK = int(input())\nans = 1\n\nfor i in range(N):\n if ans > K:\n ans += K\n else:\n ans *= 2\nprint(ans)\n", "N = int(input())\nK = int(input())\nv = 1\nfor _ in range(N):\n if v <= K:\n v *= 2\n else:\n v += K\nprint(v)", "n=int(input())\nk=int(input())\nans=1\nfor i in range(n):\n if ans*2 >= ans+k:\n ans=ans+k\n else:\n ans=ans*2\nprint(ans)"] | {"inputs": ["4\n3\n", "10\n10\n"], "outputs": ["10\n", "76\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 15,067 | |
d11ff4ddcbc1f5c61c36cce91a28be02 | UNKNOWN | Given is an integer x that is greater than or equal to 0, and less than or equal to 1.
Output 1 if x is equal to 0, or 0 if x is equal to 1.
-----Constraints-----
- 0 \leq x \leq 1
- x is an integer
-----Input-----
Input is given from Standard Input in the following format:
x
-----Output-----
Print 1 if x is equal to 0, or 0 if x is equal to 1.
-----Sample Input-----
1
-----Sample Output-----
0
| ["X=int(input())\nprint(1-X)", "x = int(input())\nprint(1 if x == 0 else 0)", "num = int(input())\nif num == 0:\n print(1)\nelif num == 1:\n print(0)", "x=int(input())\n\nif x==0:\n print((1))\nelse:\n print((0))\n\n", "x=int(input())\nprint(1 if x==0 else 0)", "x=int(input())\nif x==0:\n print(1)\nelse:\n print(0)", "X = int(input())\n\nprint(1-X)", "x = int(input())\nif x==1:\n print((0))\nif x==0:\n print((1))\n", "print(1-int(input()))", "x = int(input())\nif x == 1:\n print(0)\nelse :\n print(1)", "x = int(input())\n\nif x == 0:\n x = 1\nelse:\n x = 0\n\nprint(x)", "x = int(input())\nif x == 0 :\n print(\"1\")\nelse :\n print(\"0\")", "print(int(input())^1)", "a=input()\nprint(0) if a=='1' else print(1)", "a = int(input())\n\nif a == 0:\n print(1)\nelse:\n print(0)", "print(1 if int(input()) == 0 else 0)", "x=int(input())\nprint(1 if x==0 else 0)", "x = int(input())\n\nif x == 0:\n print(1)\nif x == 1:\n print(0)", "x = int(input())\nprint(1 - x)", "x = input()\nans = 1 if x == '0' else 0\nprint(ans)", "print(int(not int(input())))", "print(int(input())^1)", "print(1-int(input()))", "x = int(input())\nif x == 0:\n print(1)\nelif x == 1:\n print(0)", "x = int(input())\n\nif x == 1:\n print(0)\nelse:\n print(1)", "a=int(input())\n\nif a == 1:\n ans = 0\nelse:ans = 1\n\nprint(ans)\n", "n = input()\nif n == '0':\n print('1')\nelse:\n print('0')", "x = int(input())\n\nif x==0:\n print(1)\nelse:\n print(0)", "n=int(input())\nif n==0:\n print('1')\nelif n==1:\n print('0')", "x = int(input())\n\nif x == 0:\n print(\"1\")\nelse:\n print(\"0\")", "x = input()\nif x == '0': print((1))\nelse: print((0))\n", "x = int(input())\nif(x == 0):\n print(1)\nelse:\n print(0)", "x=int(input())\nif x==0:\n print(1)\nelse:\n print(0)", "x=int(input())\nif x==1:\n print(0)\nelse:\n print(1)", "print(\"0\" if input() == \"1\" else \"1\")", "A = int(input())\n\nif A == 0:\n print(\"1\")\nelse :\n print(\"0\")", "x = int(input())\nif x ==0:\n print(1)\nelse:\n print(0)", "x = int(input())\n\nif x == 1:\n print(0)\nelse:\n print(1)", "inp = input()\nif(inp == '0'):\n print('1')\nelse:\n print('0')", "A = input()\nA = int(A)\nif A == 1:\n print(\"0\")\nelse:\n print(\"1\")\n", "i = int (input())\nif i == 1:\n print(0)\nelse:\n print(1)", "x = int(input())\nprint((1 if x == 0 else 0))", "print(int(input())^1)", "x=int(input())\nif x==0:\n print(1)\nif x==1:\n print(0)", "x=int(input())\nif x==0:\n\tprint(1)\nelse:\n\tprint(0)", "x = int(input())\nif x == 0:\n print(1)\nelif x == 1:\n print(0)", "def __starting_point():\n x = int(input())\n if x == 1:\n print(0)\n elif x == 0:\n print(1)\n__starting_point()", "print(int(input()) ^ 1)", "x = int(input())\n\nif (x == 0):\n print(1)\nelse:\n print(0)", "x=int(input())\nif x ==0:\n print(1)\nelse:\n print(0)", "x = input()\nif x == '1':\n print(\"0\")\nelif x == '0': \n print(\"1\")", "a=int(input())\nif a==1:\n print(0)\nelse:\n print(1)", "x = int(input())\nprint(1-x)", "print('10'[int(input())])", "import sys\nimport heapq\nimport math\nimport fractions\nimport bisect\nimport itertools\nfrom collections import Counter\nfrom collections import deque\nfrom operator import itemgetter\ndef input(): return sys.stdin.readline().strip()\ndef mp(): return map(int,input().split())\ndef lmp(): return list(map(int,input().split()))\n\nx = int(input())\nif x == 0:\n print(1)\nelse:\n print(0)", "n = int(input())\nif n == 1:\n print((0))\nelse:\n print((1))\n", "if int(input()) == 0:\n print((1))\nelse:\n print((0))\n", "print(int(input())^1)", "print(int(input())^1)", "print(1-int(input()))", "print(int(input())^1)", "x=int(input())\nprint(1 if x==0 else 0)", "from sys import stdin\nx = int(stdin.readline().rstrip())\nif x == 1:\n print(0)\nelse:\n print(1)", "x=int(input())\nprint((1-x))\n \n", "x=input()\nif int(x) == 0:\n print(1) \nelse :\n print(0)", "x = int(input())\n\nif x == 1:\n print(0)\nelif x == 0:\n print(1)", "print((1+(int(input())))%2)", "x = int(input())\nif x == 0:\n print(1)\nelif x == 1:\n print(0)", "print(1 if input()==\"0\" else 0)", "print(1 - int(input()))", "N, =map(int,input().split())\nprint(1^N)", "x=int(input())\nif x==0:\n print(1)\nelif x==1:\n print(0)", "x = int(input())\nprint(int(x == 0))", "x=int(input())\nx=(1 if x == 0 else 0)\nprint(x)\nprint('\\n')", "x=int(input())\nprint(1-x)", "x = int(input())\n\nprint(1 if x == 0 else 0)", "x = input()\nprint(0 if x == \"1\" else 1)", "a = int(input())\nif a == 0:\n print(a+1)\nelse:\n print(a-1)", "a = int(input())\nif a == 1:\n print(0)\nelse:\n print(1)", "x = int(input())\n\nans = 1 - x\n\nprint(ans)", "x = int(input())\nprint((x+1)%2)", "print(int(input()) ^ 1)", "x = int(input())\nif x == 1:\n print(\"0\")\nelif x == 0:\n print(\"1\")\nelse:\n print(\"error\")", "print(1-int(input()))", "x = int(input())\nif x == 1:\n print(\"0\")\nelse:\n print(\"1\")", "x = int(input())\n\nif x == 0:\n print((1))\nelse:\n print((0))\n", "x = int(input())\n\nif x == 0:\n print(\"1\")\nelse :\n print(\"0\")", "x = int(input())\nif x == 0:\n print(1)\nelse:\n print(0)", "x = int(input())\nif x == 0:\n print(1)\nelse:\n print(0)", "if int(input())==1:\n print(0)\nelse:\n print(1)", "x = int(input())\n\nif x:\n print((0))\nelse:\n print((1))\n", "x = int(input())\nif x == 0:\n print(1)\nelif x == 1:\n print(0)", "x = int(input())\n\nif x == 0:\n print(1)\n \nelse:\n print(0)", "print(abs(int(input())-1))", "x =int(input())\n\nif(x == 0):\n print(1)\n return\nprint(0)", "x_str = input()\nx = int(x_str)\n\nif x == 1:\n print(0)\nelif x == 0:\n print(1)", "x = int(input())\n\nif(x==0):\n print(1)\nelse:\n print(0)", "# -*- coding: utf-8 -*-\nx=int(input())\nif x==0:\n print(1)\nelse:\n print(0)", "x=int(input())\nif x == 0:\n print(1)\nelse:\n print(0)", "print(1 if int(input()) == 0 else 0)"] | {"inputs": ["1\n", "0\n"], "outputs": ["0\n", "1\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 6,055 | |
0aca57b60386139fa9c0e79743be34aa | UNKNOWN | You are given a string S consisting of digits between 1 and 9, inclusive.
You can insert the letter + into some of the positions (possibly none) between two letters in this string.
Here, + must not occur consecutively after insertion.
All strings that can be obtained in this way can be evaluated as formulas.
Evaluate all possible formulas, and print the sum of the results.
-----Constraints-----
- 1 \leq |S| \leq 10
- All letters in S are digits between 1 and 9, inclusive.
-----Input-----
The input is given from Standard Input in the following format:
S
-----Output-----
Print the sum of the evaluated value over all possible formulas.
-----Sample Input-----
125
-----Sample Output-----
176
There are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,
- 125
- 1+25=26
- 12+5=17
- 1+2+5=8
Thus, the sum is 125+26+17+8=176. | ["import copy\n\ns=input()\nl=len(s)\nans=0\n\nif l==1:\n ans+=int(s)\n print(ans)\n \nelse:\n for i in range(2**(l-1)):\n t=copy.deepcopy(s)\n f=[]\n ch=0\n for j in range(l-1):\n if ((i>>j)&1):\n t=t[:j+1+ch]+'+'+t[j+1+ch:]\n ch+=1\n \n if '+' in t:\n \n y=list(map(int,t.split('+')))\n for u in y:\n ans+=u\n else:\n ans+=int(t)\n \n print(ans)", "s = input()\nL = []\nsigma = 0\ndef sprit_sum(string, sprit, num):\n nonlocal sigma\n for i in range(1,len(string)+num-sprit):\n str_front = string[:i]\n str_back = string[i:]\n L.append(int(str_front)) \n if num < sprit:\n sprit_sum(str_back, sprit, num+1)\n else:\n L.append(int(str_back))\n for x in L:\n sigma += x\n L.pop()\n L.pop()\n \nfor j in range(len(s)):\n sprit_sum(s, j+1, 1)\nsigma += int(s)\nprint(sigma)\n", "S = input()\nn = len(S)\n\ndef dfs(i, f):\n if i == n - 1:\n return sum(list(map(int, f.split('+'))))\n\n return dfs(i+1, f+S[i+1]) + dfs(i+1, f+'+'+S[i+1])\n\nprint((dfs(0, S[0])))\n", "s = input()\nl = len(s)-1\nres = 0\nfor i in range(2**l):\n t = s[0]\n for j in range(l):\n if i&(1<<j):\n t += \"+\"\n t+=s[j+1]\n res += eval(t)\nprint(res)", "S = input()\nl = len(S)\nans = 0\nfor i in range(l):\n for j in range(i+1,l+1):\n temp = int(S[i:j])\n ans += temp * max(1,pow(2,i-1)) * max(1,pow(2,l-j-1))\nprint(ans)", "import itertools\nS = input()\nnpm = len(S) - 1\nsum = eval(S)\npcomb = []\nfor i in range(npm):\n pcomb.append(list(itertools.combinations(list(range(1, npm + 1)), i + 1)))\nfor j in pcomb:\n k = 0\n for l in range(len(j)):\n pcomb2 = j[k]\n npmc = 0\n F = S\n for m in pcomb2:\n F = F[:m + npmc] + \"+\" + F[m + npmc:]\n npmc += 1\n sum += eval(F)\n k += 1\nprint(sum)\n", "S=input()\nN=len(S)\nans=0\nfor i in range(2**(N-1)):\n Bit = list(i+1 for i in range(N-1))\n for j in range(N-1):\n if (i >> j) & 1:\n Bit[j] = 0\n Bit=[b for b in Bit if b>0]\n L=0\n for b in Bit:\n ans+=int(S[L:b])\n L=b\n ans+=int(S[L:])\nprint(ans)", "def dfs(i, f):\n if i == n - 1:\n return sum(list(map(int, f.split('+'))))\n\n return dfs(i + 1, f + a[i + 1]) + dfs(i + 1, f + '+' + a[i + 1])\n\n\na = input()\nn = len(a)\n\nprint((dfs(0, a[0])))\n", "s = input()\nlen_s = len(s)\n\ntotal = int(s)\neval_s = \"\"\ninsert_list = []\nfor i in range(1, 2 ** (len_s - 1)):\n # print(i)\n for j in range(len_s):\n eval_s += s[j]\n if ((i >> j) & 1):\n # print(i, j)\n eval_s += \"+\"\n # print(eval_s)\n total += eval(eval_s)\n eval_s = \"\"\nprint(total)\n", "a=list(input())\nans=0\nfor i in range(2**(len(a)-1)):\n s=a[0]\n for j in range(len(a)-1):\n if i%2:s+='+'\n s+=a[j+1]\n i//=2\n ans+=eval(s)\nprint(ans)", "S = input()\nn = len(S)\n \nans = 0\n \nfor i in range(2**(n-1)):\n t = S[0]\n for j in range(n-1):\n if (i>>j)&1:\n t += \"+\"\n t += S[j+1]\n ans += eval(t)\n \nprint(ans)", "s=input()\nn=len(s)\nans=0\nfor i in range(2**(n-1)):\n x=[0]*(n-1)\n k=i\n for j in range(n-1):\n x[j]+=k//(2**(n-2-j))\n k-=2**(n-2-j)*(k//(2**(n-2-j)))\n a=s[0]\n for j in range(n-1):\n if x[j]==0:\n a=a+s[j+1]\n else:\n ans+=int(a)\n a=s[j+1]\n ans+=int(a)\nprint(ans)", "S=input()\nl=len(S)\nls=''\nfor i in range(1,l):ls+=str(i)\nsa=['']*(2*l-1)\nfor i in range(len(sa)):\n if i%2==0:\n sa[i]=S[i//2]\n\nimport copy\nimport itertools as it\nans=0\nfor i in range(l):\n for j in list(it.combinations(ls, i)):\n sx=copy.copy(sa)\n for k in j:\n k=int(k)\n sx[2*k-1]='+'\n ans+=eval(''.join(sx))\nprint(ans)", "s = input()\nn = len(s) - 1\nres = 0\nfor i in range(1 << n):\n num_str = s[0]\n for j in range(n):\n if i >> j & 1 == 0:\n num_str += s[j + 1]\n else:\n res += int(num_str)\n num_str = s[j + 1]\n res += int(num_str)\n\nprint(res)\n", "import copy\n\ns=list(input())\na=[]\nfor i in range(len(s)):\n a.append(s[i])\n if i !=len(s)-1:\n a.append(\"\")\n\nans=0\n\nfor i in range(2**(len(s)-1)):\n l=copy.deepcopy(a)\n for j in range(len(s)-1):\n if (i>>j&1):\n l[2*j+1]=\"+\"\n ans+=eval(\"\".join(l))\n\nprint(ans)", "s = input()\nl = len(s)\n\n\ndef dfs(i, x):\n if i == l - 1:\n return eval(x)\n rep0 = dfs(i + 1, x + s[i + 1])\n rep1 = dfs(i + 1, x + \"+\" + s[i + 1])\n return rep0 + rep1\n\n\nans = dfs(0, s[0])\nprint(ans)\n", "s = input()\nn = len(s)\n\nans = 0\nfor bit in range(1 << n-1):\n tmp = s[0]\n for i in range(n-1):\n if bit & (1 << i):\n tmp += \"+\"\n tmp += s[i+1]\n \n ans += sum(map(int,tmp.split(\"+\")))\n\nprint(ans)", "S = input()\nn = len(S)\nans = 0\nfor i in range(n):\n a = int(S[i])\n for j in range(n-i):\n ans += a * 10**j * 2**i * 2**(max(0,n-i-j-2))\nprint(ans)", "N = str(int(input()))\ntotal = 0\nl = len(N)-1\nif l == 0:\n print(N)\nelse:\n for i in range(2**l):\n b = format(i, '0'+str(l)+'b')\n subtotal = 0\n s = N[0]\n for j in range(len(b)):\n if int(b[j]):\n subtotal += int(s)\n s = N[j+1]\n else:\n s += N[j+1]\n\n subtotal += int(s)\n total += subtotal\n\n print(total)", "s = input()\ns_sum = []\nfor i in range(2**(len(s)-1)):\n sj = 0\n a = 0\n for j in range(len(s)-1):\n if ((i>>j) & 1):\n a += int(s[sj:j+1])\n sj = j+1\n a += int(s[sj:])\n s_sum.append(a)\nprint(sum(s_sum)) ", "from itertools import product\ns=input()\na=0\nfor p in product((0,1),repeat=len(s)-1):\n t=s[0]\n for i,b in enumerate(p,start=1):\n if b==1:\n t+='+'+s[i]\n else:\n t+=s[i]\n a+=eval(t)\nprint(a)\n", "s = list(input())\nn = len(s)\nans = 0\n\nfor i in range(2**(n-1)):\n temp = s[0]\n for j in range(n-1):\n if i>>j & 1:\n temp += \"+\" + s[j+1]\n else:\n temp += s[j+1]\n ans += eval(temp)\n\nprint(ans)\n", "s = input()\nans = ''\nfor i in range(1 << (len(s) - 1)):\n ans += s[0]\n for j in range(len(s) - 1):\n if i >> j & 1:\n ans += ' '\n ans += s[j+1]\n ans += ' '\nprint(sum(map(int, ans.split())))", "#\n# abc045 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"125\"\"\"\n output = \"\"\"176\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"9999999999\"\"\"\n output = \"\"\"12656242944\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n S = input()\n L = len(S)\n\n ans = 0\n for bit in range(1 << L-1):\n s = \"\"\n for i in range(L):\n if 1 << i & bit:\n s += S[i]\n s += \"+\"\n else:\n s += S[i]\n ans += eval(s)\n\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "s = input()\nn = len(s)\nans = 0\nfor i in range(2**(n-1)):\n t = []\n x = i\n for j in range(n-1):\n t.append(s[j])\n if x % 2 != 0:\n t.append('+')\n x = x // 2\n t.append(s[-1])\n m = 0\n for i in t:\n if i != '+':\n m *= 10\n m += int(i)\n else:\n ans += m\n m = 0\n ans += m\nprint(ans)", "S = input()\nf = lambda x: 2**(x-1) if x > 0 else 1\nlenS = len(S)\nans = 0\nfor i in range(1,lenS+1):\n for j in range(lenS-i+1):\n ans += int(S[j:j+i]) * f(j) * f(lenS-j-i) \nprint(ans)", "s = input()\nans = 0\n\nfor bit in range(1 << len(s)-1):\n f = s[0]\n\n for i in range(len(s)-1):\n if (bit & (1 << i)):\n f += '+'\n f += s[i+1]\n ans += sum(map(int, f.split('+')))\n \nprint(ans)", "S = input()\nans = 0\n\nfor i in range(2**(len(S)-1)):\n tmp = S[0]\n for j in range(len(S)-1):\n if i & (1 << j):\n tmp += '+'\n tmp += S[j+1]\n ans += eval(tmp)\nprint(ans)\n", "s = input()\nn = len(s)\n\n\ndef dfs(now, total, i):\n if i == n:\n return total + now\n else:\n res = 0\n res += dfs(now * 10 + int(s[i]), total, i + 1)\n res += dfs(int(s[i]), total + now, i + 1)\n return res\n\n\nprint((dfs(int(s[0]), 0, 1)))\n", "from itertools import product\nS = input()\nif len(S)==1:\n print(int(S))\nelse:\n Sum = 0\n for TR in product([0,1],repeat=(len(S)-1)):\n Op = ['+' if TO==1 else '' for TO in TR]+['']\n Sum += eval(''.join([TS+TO for TS,TO in zip(S,Op)]))\n print(Sum)", "s = input()\nn = len(s)-1\nans = 0\nfor i in range(2**n):\n op = [0]*n\n for j in range(n):\n if ((i >> j) & 1):\n op[j] = 1\n t = s[0]\n for j in range(1,n+1):\n if op[j-1] == 1:\n t += '+' + s[j:j+1]\n else:\n t += s[j:j+1]\n ans += sum(list(map(int,t.split('+'))))\nprint(ans)", "def hojyu(a):\n if len(a)!=N:\n return \"0\"*(N-len(a))+a\n else:\n return a\nS=input()\nN=len(S)-1\nR=list()\nans=0\nfor i in range(2**N):\n s=str(bin(i)[2:])\n s=hojyu(s)\n b=0\n mae=0\n for k in range(len(s)):\n if s[k]==\"1\":\n b+=int(S[mae:k+1])\n mae=k+1\n b+=int(S[mae:])\n ans+=b\nprint(ans)", "s = input()\nall_s = []\ndef ss(index, perm):\n if index == len(s):\n all_s.append(perm)\n else:\n perm1 = [i for i in perm]\n perm1[-1] += s[index]\n ss(index+1, perm1)\n\n perm2 = [i for i in perm]\n perm2.append(s[index])\n ss(index+1, perm2)\n\nss(1, [s[0]])\nall_sum = 0\nfor way in all_s:\n tmp = 0\n for n in way:\n tmp += int(n)\n all_sum += tmp\nprint(all_sum)\n", "from itertools import product\nS = input()\ntotal = 0\nlength = len(S)\nList = list(product([0,1],repeat=length -1))\nformula = \"\"\nfor item in List:\n formula = S[0]\n for i in range(length-1):\n if item[i] == 0:\n formula += S[i+1]\n else:\n formula += '+'+S[i+1]\n total += eval(formula)\nprint(total)", "S = input()\n\nn = len(S)\n\nans = 0\nfor i in range(2**(n-1)):\n tmp = 0\n t = 0\n for j in range(n-1):\n if (i>>j)&1: \n tmp += int(S[t:j+1])\n t = j+1\n tmp += int(S[t:])\n ans += tmp\nprint(ans)\n", "S=input()\nl=len(S)\n\nls=[i for i in range(1,l)]\n \nsa=[]\nfor i in range(len(S)):sa+=[S[i],'']\nsa=sa[:-1]\n\nimport copy\nimport itertools as it\nans=0\nfor i in range(l):\n for j in it.combinations(ls, i):\n sx=copy.copy(sa)\n for k in j:sx[2*k-1]='+'\n ans+=eval(''.join(sx))\nprint(ans)", "s = input()\nl = len(s)\nans = 0\nfor i in range(2 ** (l-1)):\n tmp = ''\n sum = 0\n for j in range(l-1):\n tmp += s[j]\n if i >> j & 1:\n sum += int(tmp)\n tmp = ''\n sum += int(tmp + s[-1])\n\n ans += sum\nprint(ans)", "S=input()\nl=len(S)\n\nimport itertools as it\na=0\nfor i in range(l):\n for j in it.combinations(range(1,l), i):\n t='';p=0\n for k in j:\n t+=S[p:k]+'+'\n p=k\n t+=S[p:]\n a+=eval(''.join(t))\nprint(a)", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[3]:\n\n\nfrom itertools import product\n\n\n# In[16]:\n\n\nS = input()\n\n\n# In[17]:\n\n\nlength = len(S)\nans = 0\nfor lst in product([\"+\",\"\"], repeat=length-1):\n mystr = \"\"\n for i in range(length-1):\n mystr += S[i]+lst[i]\n mystr += S[-1]\n mylist = [int(x) for x in mystr.split(\"+\")]\n ans += sum(mylist)\nprint(ans)\n\n\n# In[ ]:\n\n\n\n\n", "S = str(input())\nans = 0\nfor i in range(2**(len(S)-1)):\n s = S[0]\n for j in range(len(S)-1):\n if (i>>j) & 1:\n s += '+'\n s += S[j+1]\n ans += eval(s)\nprint(ans)", "s = str(input())\nans = 0\nfor i in range(2**(len(s) - 1)):\n l = s[0]\n for j in range(len(s)-1):\n if (i >> j) & 1:\n l += \"+\"\n l += s[j+1]\n ans += eval(l)#eval\u95a2\u6570\u306f\u6587\u5b57\u5217\u3092\u6570\u5f0f\u3068\u3057\u3066\u305d\u306e\u89e3\u3092\u8fd4\u3059\nprint(ans)", "S=input()\nn=len(S)\nans=0\n \nfor paint in range(2**(n-1)):\n\ttemp_S=S[0]\n \n\tfor i in range(n-1):\n\t\tif (paint>>i)&1==1:\n\t\t\ttemp_S+=\"+\"\n\t\ttemp_S+=S[i+1]\n \n\tans+=sum(map(int, temp_S.split(\"+\")))\nprint(ans)", "s = input()\n\ntotal = 0\n\nfor i in range(len(s)):\n for j in range(len(s) - i):\n n = int(s[j:j+i+1])\n if j == 0 or j == len(s) - i - 1:\n total += n * max([(2 ** (len(s) - i - 2)), 1])\n else:\n total += n * max([(2 ** (len(s) - i - 3)), 1])\n \nprint(total)", "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\n\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165g\n#\n# \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7cfb\n# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);\n# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\n#mod = 998244353\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n return list(map(int,readline().split()))\ndef readTuples():\n return tuple(map(int,readline().split()))\ndef I():\n return int(readline())\ns = input()\nans = 0\nfor bit in range(1 << len(s)-1):\n st = s[0]\n wa = 0\n for i in range(len(s)-1):\n if bit & (1 << i):\n wa += int(st)\n st = s[i+1]\n else:\n st += s[i+1]\n ans += wa + int(st)\nprint(ans)\n", "s = input()\nn = len(s)\nans = 0\n\nfor i in range(2 ** (n - 1)):\n k = 0\n num_list = []\n for j in range(n):\n if (i >> j) & 1:\n num = s[k : j + 1]\n# print(num)\n k = j + 1\n num_list.append(int(num))\n# print(num_list)\n num = s[k : n +1]\n num_list.append(int(num))\n ans += sum(num_list)\nprint(ans)", "s = input()\nn = len(s)\ndef dfs(i, f):\n if i == n-1:\n return sum(list(map(int,f.split('+'))))\n return dfs(i+1, f+s[i+1]) + dfs(i+1, f+'+'+s[i+1])\nprint(dfs(0, s[0]))", "s = input()\n\nn = len(s)-1\nans = 0\nfor i in range(2**n):\n t = s[0]\n for j in range(n):\n if i >> j & 1: t += \"+\" # \u8a72\u5f53\u3059\u308b\u5834\u5408\u306e\u307f\"+\"\u3092\u8ffd\u52a0\u3059\u308b\n t += s[j+1] # \u6b21\u306e\u6587\u5b57\u3092\u8ffd\u52a0\n ans += eval(t) # \u751f\u6210\u3057\u305f\u6587\u5b57\u5217\u3092\u8a08\u7b97\nprint(ans)", "def dfs(i, f):\n if i == n-1:\n return sum(list(map(int, f.split(\"+\"))))\n\n return dfs(i+1, f + \"+\" + s[i+1]) + dfs(i+1, f + s[i+1])\n\n\ns = input()\nn = len(s)\n\nprint(dfs(0, s[0]))", "S=(input())\nlen_S=len(S)\nans=0\nleft=0\nis_plus=[0]*(len_S-1)\nfor i in range(2**(len_S-1)):\n left=0\n for j in range(len_S-1):\n i,mod=divmod(i,2)\n if mod==1:\n #print(left,j)\n ans+=int(S[left:j+1])\n left=j+1\n ans+=int(S[left:len_S])\nprint(ans)", "s = input()\nn = len(s)\n\nans = 0\n\nfor bit in range(1 << (n - 1)):\n # \u5404\u5834\u5408\u3067\u5f0f f \u3092\u751f\u6210\u3059\u308b\n f = s[0]\n\n for i in range(n - 1):\n if bit & (1 << i):\n # \u30d5\u30e9\u30b0\u304c\u7acb\u3063\u3066\u3044\u308b\u306a\u3089\u3070 \"+\" \u3092\u5f0f\u306e\u672b\u5c3e\u306b\u8ffd\u52a0\u3059\u308b\n f += \"+\"\n f += s[i + 1]\n\n ans += sum(map(int, f.split(\"+\")))\n\nprint(ans)", "# \u6bce\u56de\u633f\u308c\u308b\u304b\u633f\u308c\u306a\u3044\u304b\u306e\u4e8c\u629e\u306e\u63a2\u7d22\u3092\u3057\u3066\u307f\u308b\n# 2\u5024\u306a\u306e\u3067bit\u5168\u63a2\u7d22\u3092\u3084\u3063\u3066\u307f\u308b\n# \u9006\u30dd\u30fc\u30e9\u30f3\u30c9\u5fc5\u8981\u304b\uff1f\u3068\u601d\u3063\u305f\u3051\u3069\u52a0\u7b97\u3060\u3051\u3060\u3057\u3044\u3089\u3093\u304b\u3063\u305f\u308f\u52a9\u304b\u308b\ns = input()\nans = 0\nfor bit in range(0, 1 << len(s) - 1):\n opr = []\n for i in range(len(s) - 1):\n opr.append(\"\u6c34\u7740\" if bit >> i & 1 == 1 else \"\u30ef\u30f3\u30d4\u30fc\u30b9\")\n exp = [s[0]]\n for i in range(len(opr)):\n if opr[i] == \"\u30ef\u30f3\u30d4\u30fc\u30b9\":\n exp[-1] += s[i + 1]\n elif opr[i] == \"\u6c34\u7740\":\n exp.append(s[i + 1])\n ans += sum(list(map(int, exp)))\nprint(ans)\n", "S = input()\nans = 0\n\nfor i in range(0,2**(len(S)-1)):\n tmp = S\n cnt = 0\n for j in range(0,len(S)):\n if ( i >> j ) & 1:\n cnt += 1\n tmp = tmp[0:j+cnt] + '+' + tmp[j+cnt:]\n ans += eval(tmp)\nprint(ans)", "S = input()\n\nn = len(S)\n\ndef dfs(i,f):\n if i == n-1:\n return sum(list(map(int, f.split(\"+\"))))\n\n return dfs(i+1, f+S[i+1]) + dfs(i+1, f+\"+\"+S[i+1])\nprint(dfs(0, S[0]))", "s = input()\nnums = []\n\nf = \"0\"+str(len(s)-1)+\"b\"\n\nfor i in range(2**(len(s)-1)):\n m = format(i, f)\n\n l = 0\n r = 0\n while r < len(m):\n if m[r] == \"1\":\n nums.append(s[l:r+1])\n l = r+1\n r += 1\n\n nums.append(s[l:r+1])\n\nprint(sum(map(int, nums)))", "n = input()\nopr = len(n) - 1\ncal_sum = 0\nfor i in range(2**opr):\n op = [\"\"] * opr\n for j in range(opr):\n if((i>>j)&1):\n op[opr-1-j] = \"+\"\n cal = \"\"\n for x,y in zip(n,op+[\"\"]):\n cal += x+y\n cal_sum += eval(cal)\nprint(cal_sum)", "def dfs(i,sall):\n if i == lenS:\n return (sall)\n #return sum(map(int,(s[0]+sall).split(\"+\")))\n return dfs(i + 1,sall+\"+\"+s[i])+\"+\"+dfs(i + 1,sall+s[i])\n\ns = input()\nlenS = len(s)\nprint(sum(map(int,dfs(1,s[0]).split(\"+\"))))", "# n-1\u7b87\u6240\u306b+\u3092\u3044\u308c\u308b\u304b\u3044\u308c\u306a\u3044\u304b\u306a\u306e\u3067bit\u5168\u63a2\u7d22\u304c\u53ef\u80fd\ns = list(input())\nans = 0\nfor bit in range(1 << len(s) - 1):\n a = [int(s[0])]\n for i in range(len(s) - 1):\n if (bit >> i) & 1 == 1:\n a.append(int(s[i + 1]))\n else:\n a[-1] = 10 * a[-1] + int(s[i + 1])\n ans += sum(a)\nprint(ans)\n", "s = input()\nn = len(s)\n\nans = 0\n\nfor i in range(2**(n-1)):\n f = s[0]\n \n for j in range(n-1):\n if i & (1<<j):\n f += '+'\n f += s[j+1]\n \n ans += sum(map(int, f.split('+')))\n \nprint(ans)", "def dfs(i, f):\n if i == n-1: #\u3082\u3057\u679d\u304c\u6700\u5f8c\u306e\u3051\u305f\u306b\u5230\u9054\u3057\u305f\u3089\u3001\u3068\u3044\u3046\u6761\u4ef6\u5f0f\n return sum (list(map(int, f.split('+'))))\n \n #\u5f0ff\u306e\u672b\u5c3e\u306b'+'\u3092\u8ffd\u52a0\u3059\u308b/\u8ffd\u52a0\u3057\u306a\u3044\u3092\u3057\u3066\u6b21\u306e\u6570\u5b57\u3092\u8ffd\u52a0\n return dfs(i+1, f+s[i+1]) + dfs(i+1, f+'+'+s[i+1])\ns = input()\nn = len(s)\nprint((dfs(0, s[0])))\n", "S = list(input())\nN = len(S)-1\nans = 0\nfor i in range(1 << N):\n a = S[0]\n for j in range(N):\n if(i >> j) & 1 == 0:\n a += S[j+1]\n else:\n x = int(a)\n ans += x\n a = S[j+1]\n x = int(a)\n ans += x\nprint(ans)\n", "S = input()\nn = len(S)\n\nans = 0\n\nfor i in range(2**(n-1)):\n t = S[0]\n for j in range(n-1):\n if (i>>j)&1:\n t += \"+\"\n t += S[j+1]\n ans += eval(t)\n\nprint(ans)", "a = input()\n\nn = len(a)\nans = 0\nfor i in range(2**(n-1)):\n f = a[0]\n for j in range(n-1):\n if ((i >> j) & 1):\n f += '+'\n f += a[j+1]\n\n ans += sum(map(int, f.split('+')))\n\nprint(ans)", "from itertools import product\n\nS = list(input())\nN = len(S)\n\nans = 0\nfor adds in product([0, 1], repeat=N - 1):\n eqn = [\"\"] * (2 * N - 1)\n eqn[::2] = S[:]\n for i, has_add in enumerate(adds):\n if has_add:\n eqn[2 * i + 1] = \"+\"\n else:\n eqn[2 * i + 1] = \"\"\n ans += eval(\"\".join(eqn))\nprint(ans)\n", "s = input()\nn = len(s)\n\ndef dfs(i, tmp):\n if i == n-1:\n return sum(list(map(int,tmp.split(\"+\"))))\n \n return dfs(i+1, tmp + s[i+1]) + dfs(i+1, tmp + \"+\" + s[i+1])\n\nprint(dfs(0,s[0]))", "s = input()\n\nans = 0\n\nfor i in range(1<<(len(s)-1)):\n t = list(s)\n for b in range(len(s)-1):\n if((i>>b)&1):\n t[b] = t[b] + '+'\n ans += eval(''.join(t))\nprint(ans)\n\n\n\n\n\n", "import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep=\"\\n\")\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef SI(): return sys.stdin.readline()[:-1]\n\ns=SI()\nans=0\nfor b in range(1<<(len(s)-1)):\n f=\"\"\n for i,c in enumerate(s):\n f+=c\n if b>>i&1:f+=\"+\"\n ans+=eval(f)\nprint(ans)\n", "S = input()\nans = 0\nfor i in range(2**(len(S)-1)):\n tmp = int(S[0])\n for j in range(1, len(S)):\n if i & 1 == 1:\n ans += tmp\n tmp = int(S[j])\n else:\n tmp = tmp*10+int(S[j])\n i = i >> 1\n ans += tmp\nprint(ans)\n\n\n", "s = input()\nans = 0\nfor i in range(2**(len(s)-1)):\n t = 0\n for j in range(len(s)-1):\n if (i >> j)&1:\n ans += int(s[t:j+1])\n t = j+1\n ans += int(s[t:])\nprint(ans)", "#from collections import deque,defaultdict\nprintn = lambda x: print(x,end='')\ninn = lambda : int(input())\ninl = lambda: list(map(int, input().split()))\ninm = lambda: map(int, input().split())\nins = lambda : input().strip()\nDBG = True # and False\nBIG = 10**18\nR = 10**9 + 7\n#R = 998244353\n\ndef ddprint(x):\n if DBG:\n print(x)\n\ns = ins()\nn = len(s)\nans = 0\nfor i in range(2**(n-1)):\n z = []\n head = 0\n for j in range(n-1):\n if (i>>j)%2>0:\n z.append(int(s[head:j+1]))\n head = j+1\n z.append(int(s[head:]))\n ans += sum(z)\nprint(ans)\n", "def dfs(i,sum1):\n nonlocal ss\n #print(i,sum1)\n if i == len(s):\n return sum(list(map(int,sum1.split(\"+\"))))\n return dfs(i + 1, sum1 + s[i]) + dfs(i + 1, sum1 + \"+\" +s[i])\n\n\ns = input()\nss = 0\nprint(dfs(1,s[0]))", "def dfs(i,sum1):\n if i == len(s):\n return sum(list(map(int,sum1.split(\"+\"))))\n return dfs(i+1,sum1 + \"+\" + s[i])+dfs(i+1,sum1 + s[i])\ns = input()#\u4e00\u4ee5\u4e0a9\u4ee5\u4e0b\nprint(dfs(1,s[0]))", "s=input()\nimport itertools\nl=[*itertools.accumulate(s)]\no=[]\nfor b in range(1<<len(s)-1):\n q=[]\n p=0\n for i in range(len(s)-1):\n if b&(1<<i):\n q+=int(l[i][p::]),\n p=i+1\n c=l[-1][p::]\n c=c if c else 0\n q+=int(c),\n o+=sum(q),\nprint(sum(o))", "s = input()\nn = len(s)\n\nans = 0\n\nfor i in range(2**(n-1)):\n f = s[0]\n for j in range(n-1):\n if i & (1<<j):\n f += '+'\n f += s[j+1]\n \n ans += sum(map(int, f.split('+')))\n \nprint(ans)", "from itertools import product\n\nS=input()\nN=len(S)\nS2=S[0]\nfor i in range(N-1):\n S2 += '{}'+S[i+1]\n\nans=0\nfor p in product(['','+'],repeat=N-1):\n ans += eval(S2.format(*p))\n \nprint(ans)", "S = input()\nn = len(S)\n\nans = 0\nfor bit in range(1 << (n-1)):\n tmp = S[0]\n for i in range(n-1):\n if bit & (1 << i):\n tmp += \"+\"\n tmp += S[i+1]\n \n ans += sum(map(int, tmp.split(\"+\")))\n\nprint(ans)", "from functools import reduce\n\ndef original_sum(X, init):\n goukei = 0\n if(len(X) == 0):\n #print(\"aaa\")\n #print(sum(init))\n return sum(init)\n else:\n for i in range(len(X)):\n lstm = init.copy()\n #print(len(X))\n num = int(reduce(lambda x, y: x + y, [str(x) for x in X[0:i+1]]))\n #print(num)\n #init = num\n lstm.append(num)\n Y = X[i+1:len(X)].copy()\n #print(len(Y))\n #if(len(X)-i-1 != 0):\n goukei = goukei + original_sum(Y, lstm)\n #else:\n #sum = sum + (len(X)-i-1)num + original_sum(Y)\n #print(sum)\n\n return goukei\n\n\nnumber = list(input())\ninit = []\nprint(original_sum(number, init))", "num = int(input())\n\ndef the_algorithm(num):\n ary = list(str(num))\n sum = 0\n\n for bit in range(1 << (len(ary) - 1)):\n tmp = [ary[0]]\n for i in range((len(ary) - 1)):\n mask = 1 << i\n\n if bit & mask:\n tmp.append(ary[i + 1])\n else:\n tmp[-1] = tmp[-1] + ary[i + 1]\n\n for i in tmp:\n sum += int(i)\n\n return sum\n\nprint(the_algorithm(num))", "import sys\ndef input(): return sys.stdin.readline().rstrip()\ndef ii(): return int(input())\ndef mi(): return map(int, input().split())\ndef li(): return list(mi())\n\n\ndef main():\n s= input()\n n = len(s)\n ans = 0\n for i in range(1<<(n-1)):\n idx = [0]\n for j in range(n-1):\n if (i>>j)&1:\n idx.append(j+1)\n idx.append(n)\n for j in range(1, len(idx)):\n ans += int(s[idx[j-1]:idx[j]])\n print(ans)\n\n\ndef __starting_point():\n main()\n__starting_point()", "from itertools import product\ns=input()\nn=len(s)\nans=0\nfor p in product([0,1], repeat=n-1):\n wk=s[0]\n index=0\n for i in p:\n index+=1\n if i==0:\n wk+=s[index]\n else:\n ans+=int(wk)\n wk=s[index]\n if wk!=\"\":\n ans+=int(wk)\nprint(ans)", "S = input()\nn = len(S)-1\nresult = 0\nfor i in range(2 ** n):\n sum = 0\n temp = ''\n for j in range(n):\n temp += S[j]\n if (i >> j) & 1:\n sum += int(temp)\n temp = ''\n sum += int(temp+S[-1])\n result += sum\nprint(result)", "ss=input()\nl=len(ss)-1\nans=0\nfor i in range(2**l):\n s=ss\n for j in reversed(range(l)):\n if i&(2**j)>0:\n s=s[:j+1]+\" \"+s[j+1:]\n num=list(map(int,s.split(\" \")))\n ans+=sum(num)\nprint(ans)", "class Combination:\n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1 for i in range(self.n + 1)]\n self.finv = [1 for i in range(self.n + 1)]\n for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n def comb(self, n, m):\n return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod\ndef iparse():\n return list(map(int, input().split()))\n\ndef __starting_point():\n s = input()\n ans = 0\n for i in range(1 << (len(s) - 1)):\n prev = 0\n for j in range(len(s) - 1):\n if (i >> j) & 1 == 1:\n tmp = s[prev:j + 1]\n ans += int(tmp)\n prev = j+1\n ans += int(s[prev:])\n print(ans)\n \n \n \n\n__starting_point()", "\nn = str(input())\n\nlen_n = len(n)-1\n\nans = 0\ntotal = 0\n\nfor i in range(2**len_n):\n temp = n[0]\n for j in range(len_n):\n if (i >> j) & 1:\n temp += '+'\n temp += n[j+1]\n total = list(map(int, temp.split('+')))\n ans += sum(total)\n\nprint(ans)", "S=input()\nl=len(S)\nls=[i for i in range(1,l)]\n \nimport itertools as it\na=0\nfor i in range(l):\n for j in it.combinations(ls, i):\n t='';p=0\n for k in j:\n t+=S[p:k]+'+'\n p=k\n t+=S[p:]\n a+=eval(''.join(t))\nprint(a)", "S=input()\nN=len(S)\n\nans=2**(N-1)*int(S[-1])\nfor i in range(1<<(N-1)):\n res=1\n for j in range(N-1):\n if (i>>j)%2==1:\n res*=10\n else:\n res=1\n ans+=res*int(S[N-2-j])\nprint(ans)\n", "s = input()\nn = len(s) - 1\n\nans = 0\nfor i in range(2 ** n):\n first = ''\n for j in range(n):\n if ((i >> j) & 1):\n ans += int(first + s[j])\n first = ''\n else:\n first += s[j]\n ans += int(first + s[-1])\nprint(ans)", "S = input()\nans = 0\nfor i in range(2**(len(S)-1)):\n ls = []\n index = 0\n for j in range(len(S)-1):\n if ((i >> j) & 1):\n ls.append(int(S[index:j+1]))\n index = j+1\n ls.append(int(S[index:]))\n ans += sum(ls)\nprint(ans)", "s = input()\nn = len(s)\n\ndef dfs(i,tmp):\n if i == n-1:\n return sum(list(map(int,tmp.split(\"+\"))))\n \n return dfs(i+1, tmp+s[i+1]) + dfs(i+1,tmp+\"+\"+s[i+1])\n\nprint(dfs(0,s[0]))", "from itertools import product\ns = input()\nn = len(s)\nans = 0\nfor lst in product(['x', ' '], repeat=n-1):\n ss = ''\n for i in range(n-1):\n ss += (s[i] + str(lst[i]))\n ss += s[-1]\n ss = ss.replace('x', '')\n temp = [int(x) for x in ss.split()]\n ans += sum(temp)\nprint(ans)", "import math\nimport collections\nfrom itertools import product\n\nii = lambda : int(input())\nmi = lambda : map(int,input().split())\nli = lambda : list(map(int,input().split()))\n\ns = list(input())\nn = len(s)\nans = 0\nfor p in product((0,1), repeat=n):\n total = 0\n for i in range(n):\n if p[i] == 1:\n ans += total\n total = 0\n else:\n total = total*10 + int(s[i])\n ans += total\nprint(ans)", "def cal():\n s = input()\n num, ans = len(s)-1, 0\n for i in range(2**num):\n count0, count1 = 0, 0\n for j in range(num):\n count1 += 1\n if (i>>j)&1:\n ans += int(s[count0:count1])\n count0 = count1\n ans += int(s[count0:count1+1])\n print(ans)\ncal()\n\n", "import itertools\nn = input()\nl = len(n)\nans = 0\nfor ope in itertools.product(\"_+\", repeat = l - 1):\n num = n[0]\n for i in range(l - 1):\n if ope[i] == \"+\":\n num += n[i + 1]\n else:\n ans += int(num)\n num = n[i + 1]\n ans += int(num)\nprint(ans)", "s = input()\nn = len(s)\nans = 0\n\nfor bit in range(1 << (n-1)):#n-1\u500b+\u3092\u5165\u308c\u308b\u5834\u6240\u304c\u3042\u308b\u3002\n f = s[0]\n\n for i in range(n-1):\n if bit & (1<<i):\n f += \"+\" #\u30d5\u30e9\u30b0\u304c\u7acb\u3063\u3066\u3044\u308b\u306e\u306a\u3089\uff0b\u3092\u633f\u5165\n f +=s[i+1]\n\n ans += sum(map(int, f.split(\"+\")))\n\nprint(ans)", "s = input()\nn = len(s)\nans = 0\nfor i in range(n):\n a = int(s[i])\n for j in range(n-i):\n ans += a * 10**j * 2**(max(0,n-i-j-2)) * 2**(i)\nprint(ans)", "import itertools\ns = input()\nn = len(s)-1\nans = 0\nfor v in itertools.product([\"+\", \"\"], repeat=n):\n x = s[0]\n for i in range(n):\n x += v[i] + s[i+1]\n ans += eval(x)\nprint(ans)", "S = input()\nL = []\nfor i in range(len(S)):\n L.append(S[i])\n\nn = len(S)\nans = []\nfor i in range(2 ** (n - 1)):\n obj = []\n for j in range(n - 1):\n if (i >> j) & 1:\n obj.append(j)\n else:\n obj.append(-1)\n # print(obj)\n s = ''\n s += L[0]\n for j in range(len(obj)):\n if obj[j] == -1:\n s += L[j + 1]\n continue\n else:\n s += '+'\n s += L[j + 1]\n # print(s)\n idx = 0\n now = 0\n\n while True:\n if now == len(s) - 1:\n ans.append(int(s[idx:]))\n break\n if s[now] == '+':\n ans.append(int(s[idx:now]))\n idx = now + 1\n now = idx\n else:\n now += 1\nprint((sum(ans)))\n", "s=input()\nans=0\nfor i in range(2**(len(s)-1)):\n num=s[0]\n for j in range(len(s)-1):\n if (i>>j) & 1:\n ans+=int(num)\n num=\"\"\n num+=s[j+1]\n if len(num)!=0:\n ans+=int(num)\nprint(ans)\n"] | {"inputs": ["125\n", "9999999999\n"], "outputs": ["176\n", "12656242944\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 33,039 | |
d3a020479c388f23e227d8005fd3bca7 | UNKNOWN | Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.
They will share these cards.
First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.
Here, both Snuke and Raccoon have to take at least one card.
Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.
They would like to minimize |x-y|.
Find the minimum possible value of |x-y|.
-----Constraints-----
- 2 \leq N \leq 2 \times 10^5
- -10^{9} \leq a_i \leq 10^{9}
- a_i is an integer.
-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_{N}
-----Output-----
Print the answer.
-----Sample Input-----
6
1 2 3 4 5 6
-----Sample Output-----
1
If Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value. | ["import sys\nimport itertools\n\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninl = lambda: [int(x) for x in sys.stdin.readline().split()]\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\nN = ini()\nA = inl()\n\n\ndef solve():\n B = list(itertools.accumulate(A, initial=0))\n s = 0\n ans = 10 ** 12\n for i in range(N - 1, 0, -1):\n s += A[i]\n ans = min(ans, abs(s - B[i]))\n\n return ans\n\n\nprint(solve())\n", "import sys\nimport re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import accumulate, permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom fractions import gcd\nfrom heapq import heappush, heappop\nfrom functools import reduce\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return list(map(int, input().split()))\ndef LIST(): return list(map(int, input().split()))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nN = INT()\nA = LIST()\n\nif N == 2:\n print((abs(A[0] - A[1])))\nelse:\n ans = INF\n\n x = A[0]\n y = sum(A[1:])\n\n for i in range(1, N-2):\n x = x + A[i]\n y = y - A[i]\n\n tmp = abs(x - y)\n if tmp < ans:\n ans = tmp\n print(ans)\n", "n=int(input())\na=list(map(int,input().split()))\n\nt=sum(a)\nm=10**9\nflag=0\nfor i in range(len(a)-1):\n t-=2*a[i]\n if i==0:\n m=abs(t)\n else:\n m=min(abs(t),m)\nprint(m)", "n = int(input())\na = list(map(int, input().split()))\n\nlsum = a[0]\nrsum = sum(a[1:])\nans = abs(lsum - rsum)\n\nfor i in range(1, n-1):\n lsum += a[i]\n rsum -= a[i]\n res = abs(lsum - rsum)\n\n if res < ans:\n ans = res\n\nprint(ans)", "def main():\n n = int(input())\n a_lst = list(map(int, input().split()))\n x = a_lst[0]\n y = sum(a_lst) - x\n\n minimum = abs(x - y)\n for i in range(1, n - 1):\n a = a_lst[i]\n x += a\n y -= a\n minimum = min(minimum, abs(x - y))\n\n print(minimum)\n\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\na = [int(x) for x in input().split()]\nans = 10**9*N\nfront = 0\nback = sum(a)\nfor i in range(N-1):\n front += a[i]\n back -= a[i]\n ans = min(ans, abs(front-back))\nprint(ans)", "N = int(input())\nA = [0]+list(map(int,input().split()))\nfor i in range(1,N+1):\n A[i] = A[i]+A[i-1]\nans = float('inf')\nfor i in range(1,N):\n ans = min(ans, abs(A[N]-2*A[i]))\nprint(ans)", "import itertools\nn = int(input())\na = list(map(int, input().split(\" \")))\n#print(a)\nmini = 10 ** 10\nsuma = list(itertools.accumulate(a))\nfor i in range(0, n-1):\n #print(suma[i],(suma[-1]))\n mini = min(mini, abs(suma[-1]-suma[i]*2))\nprint(mini)", "n = int(input())\nA = list(map(int, input().split()))\nr = sum(A)-A[0]\nl = A[0]\nans = abs(r-l)\nfor i in range(1,len(A)-1):\n r -= A[i]\n l += A[i]\n ans = min(ans, abs(l-r))\nprint(ans)", "import sys, re, os\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import permutations, combinations, product, accumulate\nfrom operator import itemgetter, mul, add\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom functools import reduce\nfrom bisect import bisect_left, insort_left\nfrom heapq import heapify, heappush, heappop\n\nINPUT = lambda: sys.stdin.readline().rstrip()\nINT = lambda: int(INPUT())\nMAP = lambda: list(map(int, INPUT().split()))\nS_MAP = lambda: list(map(str, INPUT().split()))\nLIST = lambda: list(map(int, INPUT().split()))\nS_LIST = lambda: list(map(str, INPUT().split()))\n\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef main():\n N = INT()\n A = LIST()\n\n if N == 2:\n print((abs(A[1] - A[0])))\n return\n\n t = list(accumulate(A, add))\n r = list(accumulate(reversed(A), add))\n\n ans = INF\n for i in range(N-2):\n ans = min(ans, abs(t[i] - r[-2-i]))\n\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\na=[int(i) for i in input().split()]\n\nsum_a=sum(a)\nans = 10**11\nx=0\nfor i in range(N-1):\n x += a[i]\n diff = abs(sum_a - 2 * x)\n if diff<ans:\n ans=diff\n\n\nprint(ans)\n", "N = int(input())\na = list(map(int,input().split()))\ns = sum(a)\nsu = a[0]\nar = s - su\nans = abs(su-ar)\nfor i in range(1,N-1):\n su += a[i]\n ar = s - su\n if ans > abs(su-ar):\n ans = abs(su-ar)\nprint(ans)", "n = int(input())\nL = list(map(int,input().split()))\n\nli = [0]\n\nfor i in range(n):\n li.append(li[i]+ L[i])\n\nsumL = sum(L)\n#print(sumL)\nans = 10**10\nfor i in range(1,n):\n diff = abs(li[i] - (sumL - li[i]))\n #print(diff,li[i],sumL-li[i])\n ans = min(ans,diff) \nprint(ans)", "import sys\nfrom itertools import accumulate\n\nsys.setrecursionlimit(10 ** 7)\ninput = sys.stdin.readline\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n n = int(input())\n A = list(map(int, input().split()))\n\n res = f_inf\n R = [0] + list(accumulate(A))\n for i in range(1, n):\n s = R[i] - R[0]\n a = R[-1] - R[i]\n diff = abs(s - a)\n res = min(res, diff)\n print(res)\n\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "n = int(input())\na = list(map(int, input().split()))\nsa = sum(a) # sum a\ncs = 0 # cards sunuke\narr = []\n\nfor i in range(n-1):\n cs += a[i]\n ca = sa -cs #cards araiguma\n arr.append(abs(cs-ca))\n \nprint(min(arr))", "n = int(input())\nA = list(map(int, input().split()))\n\nsum_A = [0 for _ in range(n + 1)]\nfor i in range(1, n + 1):\n sum_A[i] = sum_A[i - 1] + A[i - 1]\n\nans = float('inf')\nfor i in range(1, n):\n ans = min(abs(sum_A[i] - (sum_A[-1] - sum_A[i])), ans)\nprint(ans)", "from itertools import accumulate\n\nn = int(input())\nA = list(map(int, input().split()))\n\nif n == 2:\n print(abs(A[0]-A[1]))\n return\n\nB = list(accumulate(A))\n\nans = float(\"inf\")\ny = 0\nfor i in range(n-1, 0, -1):\n x = B[i-1]\n y += A[i]\n ans = min(ans, abs(x-y))\nprint(ans)", "N = int(input())\na = list(map(int, input().split()))\ns = sum(a)\ndata = [a[0]]\nm = abs(s - 2 * a[0])\n\nfor i in range(1, N - 1):\n data.append(a[i] + data[i - 1])\n\nfor i in range(0, N - 1):\n if abs(s - 2 * data[i]) < m:\n m = abs(s - 2 * data[i])\n\nprint(m)\n\n", "N=int(input())\na=list(map(int,input().split()))\ny=sum(a)\nx=0\nB=[]\nfor i in range(N-1):\n x+=a[i]\n y-=a[i]\n B.append(abs(x-y))\n\nprint(min(B))", "n=int(input())\na=list(map(int,input().split()))\nsnuke=sum(a)\narai=0\nans=10**20\nfor i in range(n-1):\n snuke-=a[i]\n arai+=a[i]\n ans=min(ans,abs(snuke-arai))\nprint(ans)\n", "n = int(input())\n#a, b = map(int,input().split())\nal = list(map(int, input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n\ntotal = sum(al)\nmn = abs(total-2*al[0])\nx = 0\nfor i in range(1, n-1):\n x += al[i-1]\n y = total-x\n mn = min(mn, abs(x-y))\n\nprint(mn)\n", "n=int(input());a=list(map(int,input().split()));f,b,c=0,sum(a),float('inf')\nfor i in range(n-1):\n f,b=f+a[i],b-a[i]\n c=min(c,abs(f-b))\nprint(c)", "n=int(input())\na=[0]+list(map(int,input().split()))\nimport itertools\na=list(itertools.accumulate(a))\nans=1e15\nfor i in range(1,n):\n ans=min(ans,abs(a[n]-2*a[i]))\nprint(ans)", "n=int(input())\na=list(map(int,input().split()))\n\nt=sum(a)\nm=10**9\nflag=0\nfor i in range(len(a)-1):\n t-=2*a[i]\n if i==0:\n m=abs(t)\n else:\n m=min(abs(t),m)\nprint(m)", "n = int(input())\na = list(map(int, input().split()))\nval = 0\nl = []\ns = sum(a)\nhlf = s/2\nfor i in range(n-1):\n val += a[i]\n l.append(abs(hlf - val))\n\nval = min(l)\nprint((int(val*2)))\n", "N=int(input())\na=list(map(int,input().split()))\nans=10000000000000000000\nc=0\ns=sum(a)\nfor i in range(N-1):\n c+=a[i]\n s-=a[i]\n if abs(c-s)<ans:\n ans=abs(c-s)\nprint(ans)\n", "n = int(input())\na = list(map(int,input().split()))\nx = 0\ny = sum(a)\nans = 10**10\nfor i in range(n-1):\n x += a[i]\n y -= a[i]\n ans = min(ans,abs(x-y))\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\n\ns = [0]*(n+1)\nfor i in range(n):\n s[i+1] += a[i] + s[i]\n#print(s)\nans = float(\"inf\")\nfor i in range(1, n):\n x = s[i]\n y = s[n]-s[i]\n ans = min(ans, abs(x-y))\nprint(ans)", "n = int(input())\na = list(map(int,input().split()))\nsnuke = 0\narai = sum(a)\nans = 2*(10**9)\nfor i in range(n-1):\n snuke += a[i]\n arai -= a[i]\n ans = min(ans,abs(snuke-arai))\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\nimport math\nsunuke = 0\nkuma = sum(a)\n\nmemo = abs(2*a[0] - sum(a))\nans = abs(2*a[0] - sum(a))\n\nfor i in range(n):\n sunuke += a[i]\n kuma -= a[i]\n if abs(sunuke-kuma) > memo:\n ans = memo\n else:\n memo = abs(sunuke-kuma)\n\nprint(ans)\n", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sun Sep 27 02:27:51 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nA = [int(x) for x in input().split()]\n\ntmp = sum(A)\ntmp -= 2*A[0]\nans = abs(tmp)\nfor i in range(1,N-1):\n tmp -= 2*A[i]\n ans = min(abs(tmp),abs(ans))\nprint(ans)", "#\n# abc067 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"6\n1 2 3 4 5 6\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"2\n10 -10\"\"\"\n output = \"\"\"20\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n A = list(map(int, input().split()))\n\n ans = float(\"inf\")\n S = sum(A)\n T = []\n T.append(A[0])\n for i in range(1, N):\n T.append(T[i-1]+A[i])\n\n if N == 2:\n ans = abs(A[0]-A[1])\n else:\n for i in range(1, N-1):\n ans = min(ans, abs(S-2*T[i]))\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "#\n# abc067 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"6\n1 2 3 4 5 6\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"2\n10 -10\"\"\"\n output = \"\"\"20\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n A = list(map(int, input().split()))\n\n ans = float(\"inf\")\n S = sum(A)\n T = []\n T.append(A[0])\n for i in range(1, N-1):\n T.append(T[i-1]+A[i])\n for t in T:\n ans = min(ans, abs(S-2*t))\n\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "N = int(input())\na = list(map(int,input().split()))\nans = float(\"inf\")\nsnuke = 0\narai = sum(a)\nfor i in range(N-1):\n snuke += a[i]\n arai -= a[i]\n ans = min(abs(snuke-arai), ans)\nprint(ans)", "from itertools import accumulate\nn = int(input())\na = list(map(int, input().split()))\na = list(accumulate(a))\nans = 10**10\nfor i in range(n-1):\n ans = min(ans, abs(a[i]-a[-1]+a[i]))\nprint(ans)", "from itertools import accumulate\nINF = float('inf')\nN = int(input())\nA = [int(x) for x in input().split()]\n\ncumA = list(accumulate(A))\nans = INF\nfor i in range(N - 1):\n x = cumA[i]\n y = cumA[N - 1] - cumA[i]\n ans = min(ans, abs(x - y))\n\nprint(ans)", "n=int(input())\na=list(map(int,input().split()))\nans=2*(10**14)+1\ns=sum(a)\nx=0\ny=s\nfor i in range(n-1):\n x+=a[i]\n y-=a[i]\n ans=min(ans,abs(x-y))\nprint(ans)", "import numpy as np\nn = int(input())\nal = list(map(int, input().split()))\nbl = list(np.cumsum(al))\n\nans = 1001001001001\nfor i in range(n-1):\n ans = min(ans, abs(bl[i] - (bl[-1]-bl[i])))\nprint(ans)", "N = int(input())\na = list(map(int, input().split()))\nsa = a[:]\nfor i in range(N-1):\n sa[i+1] += sa[i]\n\ndiff = float('inf')\nfor i in range(N-1):\n if abs(sa[i] - (sa[-1] - sa[i])) < diff:\n diff = abs(sa[i] - (sa[-1] - sa[i]))\n\nprint(diff)", "n=int(input())\na=list(map(int, input().split()))\ns1=sum(a)\ns2=0\nans=10**18\nfor i in range(n - 1):\n s1-=a[i]\n s2+=a[i]\n ans=min(ans,abs(s1-s2))\nprint(ans)", "N=int(input())\na=list(map(int,input().strip().split()))\n#\u7d2f\u7a4d\u548c\ns_l=[]\ns=0\n\nfor n in range(N):\n s+=a[n]\n s_l.append(s)\n\nMIN=10**15\nfor n in range(N-1):\n MIN=min(MIN,abs(s-s_l[n]*2))\n\nprint(MIN)", "n = int(input())\na = list(map(int,input().split()))\n\ncumsum = [0 for _ in range(n)]\ncumsum[0] = a[0]\n\nfor i in range(1,n):\n cumsum[i] = a[i] + cumsum[i-1]\n\nresult = [0 for _ in range(n-1)]\nlast = cumsum[-1]\n#print(last)\nfor i in range(n-1):\n result[i] = abs(last - 2 * cumsum[i])\n\nprint((min(result)))\n\n\n\n\n", "n=int(input())\na=[int(i) for i in input().split()]\n\nsunuke=0\naraiguma=sum(a)\n\nmin_sa=100000000000000\n\nfor i in range(n-1):\n sunuke+=a[i]\n araiguma-=a[i]\n min_sa=min(min_sa,abs(araiguma-sunuke))\nprint(min_sa)", "N = int(input())\nA = [int(a) for a in input().split(\" \")]\n\nsA = []\nfor i in range(len(A)):\n if i == 0:\n sA.append(A[0])\n else:\n sA.append(sA[i - 1] + A[i])\n\ns = sum(A)\ndA = [abs(2 * sA[j] - s) for j in range(len(sA) - 1)]\n\nprint(min(dA))", "from fractions import gcd\nfrom collections import Counter, deque, defaultdict\nfrom heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge\nfrom bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort\nfrom itertools import product, combinations,permutations\nfrom copy import deepcopy\nimport sys\nsys.setrecursionlimit(4100000)\n\n\n\ndef __starting_point():\n N = int(input())\n A = list(map(int, input().split()))\n\n acc_A = []\n acc = 0\n for a in A:\n acc += a\n acc_A.append(acc)\n\n minv = 10e10\n for i in range(0, N-1):\n minv = min(abs(acc_A[i]-(acc_A[-1]-acc_A[i])), minv)\n print(minv)\n__starting_point()", "from itertools import accumulate\nN = int(input())\nA = tuple(accumulate(map(int, input().split())))\nx = A[-1]\ny = A[0]\nans = abs(x - y - y)\nfor a in A[:-1]:\n ans = min(ans, abs(x - a - a))\nprint(ans)", "N = int(input())\nlsa = list(map(int,input().split()))\nsunu = lsa[0]\nara = sum(lsa)- lsa[0]\nans = abs(ara-sunu)\nfor i in range(1,N-1):\n sunu += lsa[i]\n ara -= lsa[i]\n ans = min(ans,abs(ara-sunu))\nprint(ans)", "import sys\nimport numpy as np\n\nstdin = sys.stdin\ndef ns(): return stdin.readline().rstrip()\ndef ni(): return int(stdin.readline().rstrip())\ndef nm(): return list(map(int, stdin.readline().split()))\ndef nl(): return list(map(int, stdin.readline().split()))\n\n\ndef main():\n n = ni()\n A = nl()\n cumA = np.cumsum(A)\n total = cumA[-1]\n ans = 10 ** 10000\n for a in cumA[:-1]:\n ans = min(ans, abs(a - (total - a)))\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nA = list(map(int, input().split()))\n\ns = A[0]\ns_ = sum(A[1:])\ngap = abs(s-s_)\nfor i in range(1, n-1):\n s += A[i]\n s_ -= A[i]\n if gap > abs(s-s_):\n gap = abs(s-s_)\nprint(gap)", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, a: \"List[int]\"):\n from itertools import accumulate\n s = sum(a)\n return min(abs(s-2*aa) for aa in accumulate(a[:-1]))\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n a = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n print((solve(N, a)))\n\ndef test():\n import doctest\n doctest.testmod()\n\ndef __starting_point():\n #test()\n main()\n\n__starting_point()", "\nN=int(input())\nA=list(map(int,input().split()))\ntotal = sum(A)\narai = 0\nsunuke = 0\nans = float('inf')\n\nfor i in range(N-1):\n sunuke += A[i]\n arai = total - sunuke\n ans = min(ans,abs(sunuke-arai))\n\nprint(ans)\n", "#!/usr/bin/env python\n\nn = int(input())\na = list(map(int, input().split()))\n\nl = a[0]\nr = sum(a)-l\nans = abs(l-r)\n\nfor i in range(1, n-1):\n l += a[i]\n r -= a[i]\n if abs(l-r) <= ans:\n ans = abs(l-r)\n\nprint(ans)\n", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tC_fix\n# CreatedDate: 2020-10-10 15:17:07 +0900\n# LastModified: 2020-10-10 15:25:36 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\nfrom itertools import accumulate\n\n\ndef main():\n N = int(input())\n A = list(map(int, input().split()))\n A_ac = list(accumulate(A))\n ans = A_ac[-1]\n for i, ac in enumerate(A_ac):\n if i == 0:\n ans = abs(2*ac-A_ac[-1])\n if i == N-1:\n break\n if abs(2*ac-A_ac[-1]) < ans:\n ans = abs(2*ac-A_ac[-1])\n print(ans)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "# C - Splitting Pile\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n a_sum = sum(a)\n cnt = 0\n ans = float('inf')\n\n for i in range(n-1):\n cnt += a[i]\n ans = min(ans, abs(a_sum-cnt*2))\n else:\n print(ans)\n\n\nif __name__ == \"__main__\":\n main()", "n = int(input())\nA = list(map(int, input().split()))\n\nif n == 2:\n print(abs(A[0]-A[1]))\n return\n\ncum_sum = [0]\nfor a in A:\n cum_sum.append(cum_sum[-1]+a)\n\nans = 10**9+1\nfor x in cum_sum[1:-1]:\n y = cum_sum[-1] - x\n ans = min(ans, abs(x-y))\nprint(ans)", "n = int(input())\na = [int(x) for x in input().split()]\ns = [0] * (n+2)\nfor i in range(n):\n s[i+1] = s[i] + a[i]\n\nres = 10 ** 10\n\nfor i in range(1,n):\n res = min(res,abs(s[i] - (s[n] - s[i])))\n\nprint(res)", "import math\nN = int(input())\na = list(map(int,input().split()))\n\ns = sum(a)\nt = 0\nminimum = math.inf\nfor i in range(N-1):\n t += a[i]\n s -= a[i]\n minimum = min(minimum,abs(s-t))\nprint(minimum)", "a = int(input())\nb = [int(s) for s in input().split()]\nsu = sum(b) - b[a-1]\nar = b[a-1]\nans = abs(su - ar)\n\nfor i in range(2, a-1):\n su = su - b[a-i]\n ar = ar + b[a-i]\n tmp = abs(su - ar)\n if tmp < ans:\n ans = tmp\n tmp = 0\n\nprint(ans)\n", "N = int(input())\nA = list(map(int,input().split()))\n\nsunuke = [0] * (N)\nguma = [0] * (N)\n\nfor i in range(N-1):\n if i == 0:\n sunuke[i] += A[i]\n continue \n sunuke[i] += sunuke[i-1] + A[i]\n\nfor j in range(N-1,0,-1):\n if j == N - 1:\n guma[j] += A[j]\n continue\n guma[j] += guma[j+1] + A[j]\n \nans = float(\"inf\")\nfor k in range(N-1):\n ans = min(ans, abs(sunuke[k] - guma[k+1]))\n\nprint(ans)", "with open(0) as f:\n N, *a = list(map(int, f.read().split()))\nscore = -sum(a[1:]) + a[0]\nans = abs(score)\nfor x in a[1:N-1]:\n score += 2*x\n ans = min(ans, abs(score))\nprint(ans)\n", "N = int(input())\nA = list(map(int,input().split()))\nS = sum(A)\nT = [0]*(N+1)\nfor i in range(N):\n T[i+1] = T[i] + A[i]\nprint(min(abs(S-2*T[i]) for i in range(1, N)))", "n = int(input())\nmain = list(map(int, input().split()))\n\ntotal = sum(main)\nbeg = 0\nfinal = float('inf')\nfor i in range(len(main) - 1):\n beg += main[i]\n total -= main[i]\n final = min(final, abs(beg - total))\n\nprint(final)\n", "n=int(input())\na=list(map(int,input().split()))\nans=float(\"inf\")\nx=0\nb=sum(a)\nfor i in range(n):\n x+=a[i]\n if i+1<n:\n ans=min(ans,abs(b-2*x)) \nprint(ans)", "N=int(input())\na=list(map(int,input().split()))\nl,r=a.pop(0),sum(a)\nans=10**10\nfor i in a:\n ans=min(ans,abs(l-r))\n l,r=l+i,r-i\nprint(ans)", "N = int(input())\nA = list(map(int,input().split()))\nS1 = A[0]\nS2 = sum(A)-A[0]\nB = [abs(S1-S2)]\n\nfor i in range(N-2):\n S1 += A[i+1]\n S2 -= A[i+1]\n B.append(abs(S1-S2))\n\nprint(min(B))", "N=int(input())\n*A,=map(int,input().split())\nt=sum(A)\n\nx=0\nans=float('inf')\nfor i in range(N-1):\n x+=A[i]\n ans=min(ans, abs(2*x-t))\nprint(ans)", "import numpy as np\nN = int(input())\na = list(map(int, input().split()))\n\na = np.array(a)\ncum = np.cumsum(a)[:-1]\nrcum = np.cumsum(a[::-1])[:-1]\nans = abs(cum - rcum[::-1])\n\nprint((np.min(ans)))\n", "n = int(input())\na = list(map(int, input().split()))\n\ns = sum(a)\n\nx = a[0]\nans = abs(x - (s - x))\nfor i in a[1:-1]:\n ans = min(ans, abs(x - (s - x)))\n x += i\nprint(ans)", "n=int(input())\nA=list(map(int,input().split()))\nS=sum(A)\nx=A[0]\ny=S-x\nxy_min=abs(x-y)\nfor i in range(1,n-1):\n x+=A[i]\n y=S-x\n xy=abs(x-y)\n if xy<xy_min:\n xy_min=xy\nprint(xy_min)", "from itertools import accumulate\n\nn = int(input())\nA = list(map(int, input().split()))\nAA = list(accumulate([0] + A))\nans = 10 ** 20\nfor i in range(1, n):\n temp1 = AA[i]\n temp2 = AA[-1] - temp1\n delta = abs(temp1 - temp2)\n ans = min(delta, ans)\nprint(ans)\n", "n = int(input())\na = list(map(int, input().split()))\nl = []\n\ns = sum(a)\ncnt = 0\nfor i in range(n - 1):\n cnt += a[i]\n rem = s - cnt\n l.append(abs(cnt - rem))\n \nprint(min(l))", "n=int(input()) \nc=list(map(int, input().split()))\ns = sum(c)\nl = []\nx = 0\ny = s\n\nfor i in c[:n-1]:\n x += i\n y -= i\n l += [abs(x-y)]\nprint(min(l))", "import math\nfrom math import gcd,pi,sqrt\nINF = float(\"inf\")\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return list(map(int, input().split()))\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\n\nimport string\n\ndef main():\n n = i_input()\n a = i_list()\n\n total = sum(a)\n\n ans = INF\n trial = 0\n for i in a[:-1]:\n trial += i\n left = total - trial\n ans = min(ans,abs(trial-left))\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int,input().split()))\nnums = []\ntotal = 0\nfor num in a:\n total += num\n nums.append(total)\nminVal = 10 ** 9 * 2 + 1\nfor i in range(n - 1):\n sub = total - nums[i]\n minVal = min(abs(sub - nums[i]), minVal)\nprint(minVal)", "N=int(input())\na=list(map(int,input().split()))\nsum=[0]\nfor i in range(0,N):\n sum.append(sum[-1]+a[i])\nans=abs(sum[N]-2*sum[1])\nfor i in range(1,N):\n ans=min(ans,abs(sum[N]-2*sum[i]))\nprint(ans)\n", "n = int(input())\na = list(map(int,input().split()))\ny = sum(a) - a[0]\nx = a[0]\nans = abs(x-y)\nfor i in range(1,n-1):\n x += a[i]\n y -= a[i]\n ans = min(ans,abs(x-y))\nprint(ans)", "# C - Splitting Pile\nN = int(input())\nA = list(map(int,input().split()))\n\ns = [0]*(N+1)\nfor i in range(N-1):\n s[i+1] = s[i] + A[i]\n\nans = 10**10\nfor i in range(1,N):\n diff = abs((s[N-1] + A[-1] - s[i]) - s[i])\n ans = min(ans,diff)\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\nsum_a = sum(a)\nres = 10 ** 10\ntmp_sum = 0\nfor i in range(n - 1):\n tmp_sum += a[i]\n res = min(res, abs(tmp_sum - (sum_a - tmp_sum)))\n\nprint(res)\n", "with open(0) as f:\n N, *a = map(int, f.read().split())\nscore = -sum(a[1:]) + a[0]\nans = abs(score)\nfor x in a[1:N-1]:\n score += 2*x\n ans = min(ans, abs(score))\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\n\ns = A[0]\na = sum(A[1:])\n\nans = abs(s - a)\n\nfor i in range(1, N-1):\n s += A[i]\n a -= A[i]\n ans = min(ans, abs(s - a))\n\nprint(ans)", "n=int(input())\na=list(map(int,input().split()))\n\nrui=[]\nrui.append(a[0])\nfor x in range(1,n):\n b=rui[-1]+a[x]\n rui.append(b)\n\nans=[]\nfor y in range(n-1):\n ans.append(abs((rui[n-1]-rui[y])-rui[y]))\n \nprint(min(ans))", "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom fractions import gcd\nfrom itertools import combinations,permutations,accumulate # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\n#import bisect\n#\n# d = m - k[i] - k[j]\n# if kk[bisect.bisect_right(kk,d) - 1] == d:\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n#mod = 9982443453\ndef readInts():\n return list(map(int,input().split()))\ndef I():\n return int(input())\nn = I()\nA = readInts()\nleft = 0\nright = sum(A)\nMIN = float('inf')\nfor i in range(n-1):\n left += A[i]\n right -= A[i]\n #print(left, right)\n MIN = min(MIN,abs(left - right))\nprint(MIN)\n", "import itertools\nn = int(input())\na = list(map(int, input().split()))\n\nn_acc = itertools.accumulate(a)\n#r_acc = itertools.accumulate(a[::-1])\n# 1, 3, 6, 10, 15 ,21\n# 1 vs 20\n# 3 vs\n#print(n_acc, r_acc)\n\n\nsigma = sum(a)\nans = 10 ** 16\n\nfor i, val in enumerate(n_acc):\n if (i == len(a) - 1):\n break\n\n rest = sigma - val\n ans = min(abs(val - rest), ans)\n\n\nprint(ans)\n", "\n\n\n\n\n\n\n\n\n#!/usr/bin/env python3\n\n# from numba import njit\n\n# input = stdin.readline\nINF = pow(10,10)\n# @njit\ndef solve(n,a):\n res = INF\n x = 0\n y = sum(a)\n for i in range(n-1):\n x += a[i]\n y -= a[i]\n res = min(res,abs(x-y))\n return res\n\n\n\ndef main():\n N = int(input())\n # N,M = map(int,input().split())\n a = list(map(int,input().split()))\n print((solve(N,a)))\n return\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int, input().split()))\n\ns = sum(a)\nx = 0\nans = abs(2 * a[0] - s)\nsnuke = a[0]\n\nfor i in range(1, n-1):\n snuke += a[i]\n if abs(2 * snuke - s) < ans:\n ans = abs(2 * snuke - s)\n\nprint(ans)\n", "n=int(input())\na=list(map(int,input().split()))\nb=[]\nc=[]\ns=sum(a)\nt=0\nfor i in range(n-1):\n b.append(t+a[i])\n t=b[i]\nfor i in range(n-1):\n c.append(abs(2*b[i]-s))\nc.sort()\nprint(c[0])", "n = int(input())\na = list(map(int,input().split()))\ns = sum(a)\ntemp,ans = 0,float('inf')\nfor v in a[:-1]:\n temp += v\n s -= v\n ans = min(ans,abs(temp-s))\nprint(ans)", "n = int(input())\nal = list(map(int, input().split()))\nbl = [0]*(n+1)\ncl = [0]*(n-1)\n\nfor i in range(n):\n bl[i+1] = al[i] + bl[i]\n\nfor j in range(1, n):\n cl[j-1] = abs(bl[j] - (bl[n] - bl[j]))\n\nprint(min(cl))", "n=int(input())\na=list(map(int,input().split()))\nsm=sum(a)\ns=a.pop(0)\nmn=abs(sm-s*2)\nfor i in a[:-1]:\n s+=i\n mn=min(mn,abs(sm-s*2))\n \nprint(mn)", "n = int(input())\na = list(map(int,input().split()))\nasum = [0]*(n+1)\n\nfor i in range(n):\n asum[i+1] = asum[i] + a[i]\n\nans = 10**12\nfor i in range(1,n):\n snu = asum[i]\n arai = asum[-1] - asum[i]\n ans_ = abs(snu - arai)\n if ans >ans_:\n ans = ans_\n \nprint(ans)", "n = int(input())\narr = list(map(int, input().split()))\nsum1 = 0\nsum2 = sum(arr)\nmin_ = 1<<60\n\nfor i in range(n-1):\n sum1 += arr[i]\n sum2 -= arr[i]\n min_ = min(min_, abs(sum1 - sum2))\nprint(min_)", "n = int(input())\na = list(map(int,input().split()))\n\ns = a[0]\nt = sum(a) - a[0]\n\ni = 0\nans = abs(s - t)\nfor i in range(1, n-1):\n s += a[i]\n t -= a[i]\n ans = min(ans, abs(s - t))\n i += 1\nprint(ans)\n", "N=int(input())\na=list(map(int,input().split()))\n\ncum=[0]\nfor i in range(N):\n cum.append(cum[-1]+a[i])\n \nans=10**20\nfor i in range(1,N):\n tmp = abs(cum[-1]-cum[i]-cum[i])\n ans = min(ans, tmp)\n \nprint(ans)", "n = int(input())\na = list(map(int,input().split()))\nli = [a[0]]\nfor i in range(n-1):\n li.append(li[i]+a[i+1])\n\nb = []\nfor i in range(n-1):\n b.append(abs(li[-1]-li[i]*2))\nprint(min(b))", "n=int(input())\na=list(map(int,input().split()))\nb=[a[0]]\nfor i in range(1,n):\n b.append(b[-1]+a[i])\ns=sum(a)\nans=10**20\nfor i in range(n-1):\n ans=min(ans,abs(s-2*b[i]))\nprint(ans)\n", "N=int(input())\nL=list(map(int,input().split()))\nsums=0\na=sum(L)\nmina=10**10\nfor i in range(N-1):\n a-=2*L[i]\n mina=min(mina,abs(a))\nprint(mina)", "n = int(input())\na = list(map(int, input().split()))\n\nsa = [0 for i in range(n)]\nsc = sum(a)\nc = 0\nfor i in range(n):\n c += a[i]\n sa[i] = c\nans = 10**10\n\nfor i in range(1,n):\n x = sc-sa[i-1]\n v = abs(x-sa[i-1])\n ans = min(ans,v)\nprint (ans)\n", "N = int(input())\nA = list(map(int, input().split()))\nx = A[0]\ny = sum(A[1:])\nans = abs(x - y)\nfor i in range(1, N - 1):\n a = A[i]\n x += a\n y -= a\n dif = abs(x - y)\n if dif < ans:\n ans = dif\nprint(ans)", "n=int(input())\na=[int(x) for x in input().rstrip().split()]\n\nruiseki=[0]\nfor i in range(n):\n ruiseki.append(ruiseki[i]+a[i])\n\nans=float('inf')\nlast=ruiseki[len(ruiseki)-1]\n# print(last)\n# print(ruiseki)\nfor i in range(1,len(ruiseki)-1):\n now=(last-ruiseki[i])\n ans=min(ans,abs(ruiseki[i]-now))\nprint(ans)\n \n\n\n", "N = int(input())\nA = list(map(int,input().split()))\n\nS = sum(A)\n\nsnk = 0\narigm = S\n\nans = 1e20\n\nfor i in range(N-1):\n snk += A[i]\n arigm -= A[i]\n #print(snk,arigm)\n ans = min(abs(snk-arigm),ans)\nprint(ans)"] | {"inputs": ["6\n1 2 3 4 5 6\n", "2\n10 -10\n"], "outputs": ["1\n", "20\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 31,045 | |
2340c5e77ed9a853b2c045bf7f600fec | UNKNOWN | Snuke has a favorite restaurant.
The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.
So far, Snuke has ordered N meals at the restaurant.
Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.
Find x-y.
-----Constraints-----
- 1 β€ N β€ 100
-----Input-----
The input is given from Standard Input in the following format:
N
-----Output-----
Print the answer.
-----Sample Input-----
20
-----Sample Output-----
15800
So far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800. | ["# \uff11\u98df\uff18\uff10\uff10\u5186\u3092N\u98df\u98df\u3079\u305f\nN = int( input() )\nx = int( 800 * N )\n\n# \uff11\uff15\u98df\u98df\u3079\u308b\u3054\u3068\u306b\uff12\uff10\uff10\u5186\u3082\u3089\u3048\u308b\n\ny = N // 15 * 200\n\nprint( x - y )", "N = int(input())\nprint(N * 800 - N // 15 * 200)", "N = int(input())\n\nx = N * 800\ny = (N // 15) * 200\nprint(x-y)", "n = int(input())\n\nx = 800 * n # \u6255\u3063\u305f\u91d1\u984d\n\n# \u30ec\u30b9\u30c8\u30e9\u30f3\u304b\u3089\u3082\u3089\u3046\u91d1\u984d\ny = 0\nif n >= 15:\n y = 200 * (n//15)\n\n# \u6255\u3063\u305f\u91d1\u984d - \u30ec\u30b9\u30c8\u30e9\u30f3\u304b\u3089\u3082\u3089\u3046\u304a\u91d1\nans = x - y\nprint(ans)", "N = int(input())\n\nx = N * 800\n\ny = ( N // 15 ) * 200\n\ntotle = x - y\n\nprint(totle)", "n = int(input())\nprint(n*800-200*(n//15))", "#55\nN=int(input())\nx=N*800\ny=int((N//15)*200)\nprint((x-y))\n\n", "n = int(input())\n\nif n >= 15:\n x = n * 800\n y = ( n // 15 ) * 200\n print(x - y)\nelse:\n print(n * 800)", "N = int(input())\nprint(800 * N - 200 * (N // 15))", "# A,Restaurnat\n# \u3059\u306c\u3051\u304f\u3093\u306f\u30ec\u30b9\u30c8\u30e9\u30f3\u306b\u901a\u3046\u306e\u304c\u597d\u304d\u3067\u3059\u3002\n# \u3059\u306c\u3051\u304f\u3093\u306e\u884c\u304d\u3064\u3051\u306e\u30ec\u30b9\u30c8\u30e9\u30f3\u306f\u4f55\u3092\u98df\u3079\u3066\u30821\u98df800\u5186\u3067\u300115\u98df\u98df\u3079\u308b\u6bce\u306b\u305d\u306e\u5834\u3067200\u5186\u3082\u3089\u3048\u307e\u3059\u3002\n# \u3059\u306c\u3051\u304f\u3093\u306f\u4eca\u307e\u3067\u5408\u8a08N\u98df\u98df\u3079\u307e\u3057\u305f\u3002\u4eca\u307e\u3067\u306b\u6255\u3063\u305f\u91d1\u984d\u3092\uff58\u5186\u3001\u30ec\u30b9\u30c8\u30e9\u30f3\u306b\u3082\u3089\u3063\u305f\u91d1\u984d\u3092\uff59\u3068\u3057\u3066\u3001x - y\u3092\u6c42\u3081\u306a\u3055\u3044\u3002\n# 1 <= N <= 100\n\n# N = \u98df\u6570\n\nN = int(input())\n\n# x:\u4eca\u307e\u3067\u306b\u652f\u6255\u3063\u305f\u91d1\u984d\nx = 800 * N\n# print(x)\n\n# y:\u30ec\u30b9\u30c8\u30e9\u30f3\u306b\u3082\u3089\u3063\u305f\u91d1\u984d\ny = int((N // 15) * 200)\n\nanswer = int(x - y)\nprint(answer)", "N = int(input())\nprint(800*N - N//15*200)", "N = int(input())\n\n# \u305d\u306e\u307e\u307e\u5b9f\u88c5\u3059\u308b\u3060\u3051\nprint(N*800 - (N//15)*200)", "n = int(input())\nans = 800*n - 200*(n//15)\nprint(ans)", "n=int(input())\nprint(n*800-n//15*200)", "N = int(input())\nprint(N * 800 - (N // 15) * 200 )", "n = int(input())\na = n // 15\nprint(n * 800 - 200 * a)", "n=int(input())\nprint(800*n-200*(n//15))", "input_num = int(input())\n\n# x - y \uff08\u5186\uff09\u3092\u8a08\u7b97\u3057\u51fa\u529b\u3059\u308b\u3002\nx = input_num * 800 # x\uff1a\u4eca\u307e\u3067\u306b\u6255\u3063\u305f\u91d1\u984d\ny = int(input_num / 15) * 200 # y\uff1a\u30ec\u30b9\u30c8\u30e9\u30f3\u304b\u3089\u3082\u3089\u3063\u305f\u91d1\u984d\nresult = x - y # \u5dee\u984d\n\nprint(result)", "a = int(input())\n\nprint((a*800)-(a//15*200))", "n = int(input())\nprint(800 * n - 200 * (n // 15))", "N = int(input())\nprint(N*800 - ((N//15)*200))", "import math\n\nN=int(input())\n\nx=800*N\ny=(math.floor(N/15))*200\n\nprint(x-y)", "N = int(input())\nprint((N*800)-(N//15*200))", "N = int(input())\nx = 800 * N\ny = 200 * (N // 15)\nprint(x-y)", "n=int(input())\n\nx=800*n\ny=200*(n//15)\n\nprint(x-y)", "n=int(input())\nx=800*n\ny=200*(n//15)\nprint(x-y)", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nnum=int(input())\nquo=num//15\n\nx=800*num\ny=200*quo\n\nprint((x-y))\n", "number = int(input())\n\nx = number * 800\ny = (number // 15) * 200\n\nanswer = x - y\n\nprint(answer)", "n=int(input())\nprint(800*n-200*int(n//15))", "n = int(input())\n\nif n >= 15:\n print(n * 800 - ( n // 15 ) * 200)\nelse:\n print(n * 800)", "n = int(input())\n#a, b = map(int,input().split())\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\nprint((n*800-(n//15)*200))\n", "n = int(input())\ny = n//15 * 200\nprint(n*800 -y)", "# \u5b9a\u7fa9 1 <= N <= 100\n\nN = int(input())\n\nx = 800 * N\ny = (N // 15) * 200\n\npayment = x - y\nprint(payment)\n", "n = int(input())\nprint((n * 800 - n // 15 * 200))\n", "n=int(input())\nprint(n*800-(n//15)*200)", "N = int(input())\nprint(800*N-200*(N//15))", "'''\n055 abc055_a Restaurant\nhttps://atcoder.jp/contests/abc055/tasks/abc055_a\n'''\n\nprice = 800\nbonus = 200\nn = int(input())\n\nprint((price*n - bonus*(n//15)))\n", "n = int(input())\ndiv = n // 15\nprint(n*800 - div*200) ", "n = int(input())\n\nx = 800 * n\ny = 200 * (n // 15)\nprint(x - y)", "input_num = int(input())\nX = input_num * 800\nY = int(input_num / 15) * 200\nresult = X - Y\n\nprint(result)", "N = int(input())\n\nx = 800 * N\n\ny = (N // 15) * 200\n\nprint(x - y) ", "x = int(input())\n\nprint((800 * x - 200 * (x//15)))\n", "n = int(input())\n\nprint(800 * n - 200 * (n // 15))", "n = int(input())\nprint(n*800 - n//15*200)", "n = int(input())\nprint(800*n - 200*(n//15))", "n = int(input())\n\nif n >= 15:\n print(800 * n - ( n // 15) * 200)\nelse:\n print(800 * n )", "N=int(input())\nprint((800*N-N//15*200))\n", "N = int(input())\nprint(N*800-N//15*200)", "n = int(input())\nprint(n*800 - (n // 15) * 200)", "n=int(input())\nprint(n*800-n//15*200)", "n=int(input())\nprint(n*800-n//15*200)", "n=int(input())\nprint(800*n-200*(n//15))", "n=int(input())\nprint((n*800-n//15*200))\n", "n = int(input())\n\nx = 800 * n\ny = (n // 15) *200\n\nprint(x-y)", "eat_N = int(input())\n\nx = eat_N * 800\n\ny = (eat_N // 15) * 200\n\nprint( x - y)", "N = int(input())\n\nx = N * 800\ny = N // 15 * 200\n\nanswer = x - y\n# print(x, y)\nprint(answer)", "a = int(input())\nb = a * 800\nc = a // 15 * 200\nprint(b - c)", "N=int(input())\nx=N*800\ny=N//15*200\nprint((x-y))\n", "N = int(input())\nprint(N*800-(N//15)*200)", "N = int(input())\nprint((N * 800 - (N//15)*200))\n", "N = int (input())\n\nx = 800 * N\ny = 200 * int (N/15)\n\nprint(x - y)", "n = int(input())\nprint(n*800-n//15*200)", "# \u5168\u30661\u98df800\u5186\u306e\u30ec\u30b9\u30c8\u30e9\u30f3\n# 15\u98df\u98df\u3079\u308b\u3054\u3068\u306b\u305d\u306e\u5834\u3067200\u5186\u3082\u3089\u3048\u308b\n# \u5408\u8a08N\u98df\u305f\u3079\u305f\u3002\u6255\u3063\u305f\u91d1\u984d=x\u5186\u3001\u3082\u3089\u3063\u305f\u91d1\u984d\u3092y\u5186\u3068\u3057\u3066x-y\u3092\u6c42\u3081\u308b\n\n# \u5165\u529b\u3055\u308c\u305fN\u3092\u6570\u5024\u306b\u5909\u63db\nN = int(input())\n\n# \u6255\u3063\u305f\u91d1\u984d=x\u5186\u3092\u6c42\u3081\u308b\nx = 800 * N\n\n# \u3082\u3089\u3063\u305f\u91d1\u984d=y\u5186\u3092\u6c42\u3081\u308b\n# 200\u5186 * \u56de\u6570N\u309215\u3067\u5272\u3063\u305f\u6642\u306e\u6574\u6570\u306e\u5546\ny = 200 * (N // 15)\n\nprint(x-y)", "# \u3059\u306c\u3051\u304f\u3093\u306f\u30ec\u30b9\u30c8\u30e9\u30f3\u306b\u901a\u3046\u306e\u304c\u597d\u304d\u3067\u3059\u3002\n# \u3059\u306c\u3051\u304f\u3093\u884c\u304d\u3064\u3051\u306e\u30ec\u30b9\u30c8\u30e9\u30f3\u306f\u4f55\u3092\u98df\u3079\u3066\u30821\u98df 800\u5186\u3067\u300115\u98df\u98df\u3079\u308b\u6bce\u306b\u305d\u306e\u5834\u3067 200\u5186\u3082\u3089\u3048\u307e\u3059\u3002\n# \u3059\u306c\u3051\u304f\u3093\u306f\u4eca\u307e\u3067\u3067\u5408\u8a08 N\u98df\u98df\u3079\u307e\u3057\u305f\u3002 \u4eca\u307e\u3067\u306b\u6255\u3063\u305f\u91d1\u984d\u3092x\u5186\u3001\u30ec\u30b9\u30c8\u30e9\u30f3\u304b\u3089\u3082\u3089\u3063\u305f\u91d1\u984d\u3092 y\u5186\u3068\u3057\u3066\u3001x\u2212y\u3092\u6c42\u3081\u306a\u3055\u3044\u3002\n\nN = int(input())\n\nprint(N *800 - (N // 15 *200))", "N = int( input() )\nx = int( 800 * N )\n\ny = N // 15 * 200\n \nprint( x - y )", "N=int(input())\nprint(800*N-200*(N//15))", "N = int(input())\n\ncount = 0\ny = 0\nx = 0\nwhile count != N:\n count += 1\n if count % 15 == 0:\n y += 200\n x += 800\n\nprint((x - y))\n", "eat = int(input())\npay = 0\ndiscount = 0\ncount = 0\n\nfor i in range(eat):\n pay += 800\n count += 1\n\n if count % 15 == 0:\n discount += 200\n\n\nprint(pay - discount)", "N = int(input())\nx = N * 800\ny = N // 15 * 200\n\nprint(x - y)", "n = int(input())\nx = 800*n\ny = 200*(n//15)\nprint(x-y)", "N=int(input())\nx=N*800\ny=N//15*200\nprint(x-y)", "n=int(input())\nprint(800*n-200*(n//15))", "#!/usr/bin/env python3\nn=int(input())\nx=800*n\ny=n//15*200\nprint(x-y)", "N = int(input())\n\nprint(N * 800 - (N // 15) * 200 )", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lint_dec(): return list([int(x) - 1 for x in input().split()])\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nN = ii()\nprint((800 * N - 200 * (N // 15)))\n", "n=int(input());print(n*800-n//15*200)", "a=int(input())\nprint(800*a-(a//15)*200)", "n = int(input())\nx = n * 800\ny = n//15 * 200\nprint(x-y)", "n = int(input())\nprint(n*800 - (n//15)*200)", "n = int(input())\n\nprint(800 * n - 200 * (n//15))", "a=int(input())\nprint(a*800-a//15*200)", "import math\n\nN = int(input())\n\nx = N * 800\n\ny = math.floor((N /15)) * 200\n\nprint(x-y)", "n = int(input())\n\nx = n * 800\ny = (n // 15) * -200\nprint((x + y))\n", "# A - Restaurant\n\nN = int(input())\n\nx = 800 * N\ny = N // 15 * 200\n\nanswer = x - y\n\nprint(answer)", "# A - Restaurant \ndef main():\n n = int(input())\n\n print(n*800-(n//15*200))\n \n \ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\nprint((800*n-200*(n//15)))\n\n", "N = int(input())\n\nx = N * 800\ny = (N // 15) * 200\n\nprint((x - y))\n", "N = int(input())\n\nx = N * 800\ny = (N // 15) * 200\n\nprint(x - y)", "number = int(input())\n \nx = number * 800\ny = number // 15 * 200\n \nprint(x-y)", "#055A\n\n#1.\u5165\u529b\u3092\u3061\u3083\u3093\u3068\u53d7\u3051\u53d6\u308b\u3053\u3068\nx=input()\nsyoku=int(x)\n\n#2.\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\ngokei=syoku*800\n\nif syoku // 15 != 0 :\n print(gokei-200*(syoku//15))\nelse :\n print(gokei)", "n = int(input())\nb = n//15\nprint((800*n)-(200*b))", "# 055A\n\n# N\u98df(\u6570\u5024\uff09\uff1a\u6a19\u6e96\u5165\u529b\nN = int(input())\n\n# \u4eca\u307e\u3067\u306b\u6255\u3063\u305f\u91d1\u984d\uff1ax\u5186\nx = 800 * N\n\n# 15\u98df\u3054\u3068\u306b\u8cb0\u3048\u308b\u91d1\u984d\uff1ay\u5186\n# // \u2192 \u5207\u308a\u6368\u3066\u9664\u7b97\u5c0f\u6570\u70b9\u90e8\u5206\u3092\u7701\u3044\u3066\u6574\u6570\u90e8\u5206\u3060\u3051\u8fd4\u3059\uff08\uff09\ny = N // 15 * 200\n\nprint(x - y)", "n = int(input())\nprint(800*n - (n//15)*200)", "N = int(input())\nx = 800*N\ny = 200*(N//15)\nprint(x-y)", "N = int(input())\nX = 800 * N\nY = 200 * (N // 15)\nprint(X - Y)", "n = int(input())\nx = 800 * n\ny = n // 15 * 200\nprint(x - y)", "N = int(input())\n\nbonus = 0\npay = 0\n\nfor i in range(1,N+1):\n if i % 15 == 0:\n bonus += 200\n \n pay += 800\n \nsum = pay - bonus\n\nprint(sum)", "N = int(input())\nprint(N*800-N//15*200)", "n = int(input())\n\nprint(800*n - n//15*200)", "n = int(input())\nprint(n*800-round(n//15)*200)"] | {"inputs": ["20\n", "60\n"], "outputs": ["15800\n", "47200\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 11,409 | |
969780f91c2674a8876b88577ffc9fdc | UNKNOWN | We have a 3Γ3 square grid, where each square contains a lowercase English letters.
The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.
Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
-----Constraints-----
- Input consists of lowercase English letters.
-----Input-----
Input is given from Standard Input in the following format:
c_{11}c_{12}c_{13}
c_{21}c_{22}c_{23}
c_{31}c_{32}c_{33}
-----Output-----
Print the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.
-----Sample Input-----
ant
obe
rec
-----Sample Output-----
abc
The letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc. | ["cij = [list(input()) for _ in range(3)]\n\nprint(cij[0][0] + cij[1][1] + cij[2][2])", "def resolve():\n matrix = []\n for i in range(3):\n line = input()\n matrix.append(line)\n ans = \"\"\n for i in range(3):\n ans += matrix[i][i]\n print(ans)\nresolve()", "print(\"\".join(input()[i]for i in(0,1,2)))", "c1=str(input())\nc2=str(input())\nc3=str(input())\nprint(c1[0]+c2[1]+c3[2])", "c = [input() for _ in range(3)]\nprint(c[0][0]+c[1][1]+c[2][2])", "S1,S2,S3 = [input() for _ in range(3)]\nprint(S1[0]+S2[1]+S3[2])", "print(*[input()[i] for i in range(3)],sep='')", "a = input()[0]\ns = input()[1]\nd = input()[2]\nprint(a+s+d)", "ans = ''\n\nfor i in range(3):\n ans += input()[i]\n\nprint(ans)", "ans = []\nfor i in range(3):\n c = input()\n ans.append(c[i])\nprint(\"\".join(ans))", "c=[input() for i in range(3)]\nprint(*[c[i][i] for i in range(3)],sep=\"\")", "S1 = input()\nS2 = input()\nS3 = input()\nprint((S1[0] + S2[1] + S3[2]))\n", "s = [list(input()) for _ in range(3)]\nprint(\"\".join([s[i][i] for i in range(3)]))", "c=[input() for _ in range(3)]\nprint((c[0][0]+c[1][1]+c[2][2]))\n", "c=[input() for _ in range(3)]\nprint(c[0][0]+c[1][1]+c[2][2])", "a=input()\nb=input()\nc=input()\nprint(a[0]+b[1]+c[2])", "x = [input() for i in range(3)]\nprint(x[0][0]+x[1][1]+x[2][2])", "C = [input() for _ in range(3)]\nprint(C[0][0] + C[1][1] + C[2][2])", "a=input()\nb=input()\nc=input()\nprint(a[0]+b[1]+c[2])", "res = \"\"\nfor i in range(3):\n line = input()\n res += line[i]\n\nprint(res)\n", "print(input()[0] + input()[1] + input()[2])", "x=[input() for _ in range(3)]\nfor i in range(3):\n print(x[i][i],end=\"\")", "A = []\nfor i in range(3):\n A.append(input())\nprint(A[0][0]+A[1][1]+A[2][2])", "ans = \"\"\nfor i in range(3):\n ans += input()[i]\nelse:\n print(ans)", "#k = int(input())\n#s = input()\n#a, b = map(int, input().split())\n#s, t = map(str, input().split())\n#l = list(map(int, input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n#a = [list(input()) for _ in range(n)]\n#a = [int(input()) for _ in range(n)]\n\nc1 = input()\nc2 = input()\nc3 = input()\n\nprint((c1[0]+c2[1]+c3[2]))\n\n\n\n\n\n", "c=[list(input()) for i in range(3)]\nprint(c[0][0]+c[1][1]+c[2][2])", "a = input()\nb = input()\nc = input()\nprint(a[0] + b[1] + c[2])", "a = input()\nb = input()\nc = input() \nprint((a[0] + b[1] + c[2]))\n", "a = map(str, input().split())\nline_a = ''.join(a)\n\nb = map(str, input().split())\nline_b = ''.join(b)\n\nc = map(str, input().split())\nline_c = ''.join(c)\n\nprint('{}{}{}'.format(line_a[0], line_b[1], line_c[2]))", "c = [input() for _ in range(3)]\nfor i in range(3):\n print(c[i][i], end=\"\")", "#!/usr/bin/env python3\n\n\nc1 = str(input())\nc2 = str(input())\nc3 = str(input())\n\n\nprint((c1[0]+c2[1]+c3[2]))\n", "a,b,c=input(),input(),input()\nprint(a[0]+b[1]+c[2])", "c = []\n\nfor i in range(3):\n tmp = input()\n c.append(tmp)\n\nans = \"\"\nfor i in range(3):\n ans += c[i][i]\n\nprint(ans)", "a = list(input())\nb = list(input())\nc = list(input())\n\nprint(a[0] + b[1] + c[2])", "str1 = input()\nstr2 = input()\nstr3 = input()\n\nprint(str1[0]+str2[1]+str3[2])", "a = input()\nb = input()\nc = input()\nprint(a[0] + b[1] + c[2])", "c1 = list(input())\nc2 = list(input())\nc3 = list(input())\n\nprint(c1[0]+c2[1]+c3[2])", "a = input()\nb = input()\nc = input()\nprint(a[0] + b[1] + c[2])", "a = input()\nb = input()\nc = input()\nprint((a[0] + b[1] + c[2]))\n", "a = input()\nb = input()\nc = input()\nprint(a[0]+b[1]+c[2])", "print(''.join([input()[i] for i in range(3)]))", "c = [list(input()) for i in range(3)]\n\nprint(c[0][0]+c[1][1]+c[2][2])", "N_list = []\n\nfor i in range(3):\n N = input()\n N_i = N[0:3]\n N_list.append(N_i)\n i += 1\n \nprint(N_list[0][0] + N_list[1][1] + N_list[2][2])", "print(input()[0]+input()[1]+input()[2])", "cs=[input() for i in range(3)]\nprint(cs[0][0]+cs[1][1]+cs[2][2])", "l = []\nfor i in range(3):\n l.append(input())\nprint(l[0][0]+l[1][1]+l[2][2])", "c1 = str(input())\nc2 = str(input())\nc3 = input()\nprint(c1[0]+c2[1]+c3[2])", "print(''.join([input()[i] for i in range(3)]))", "a=input()\nb=input()\nc=input()\nprint(a[0]+b[1]+c[2])", "\nc1=list(map(str,input()))\nc2=list(map(str,input()))\nc3=list(map(str,input()))\nprint(c1[0]+c2[1]+c3[2])", "s = \"\"\nfor i in range(3):\n s += input()\nprint(s[0] + s[4] + s[8])", "ls = []\nfor i in range(3):\n ls.append(input())\nans = ''\nfor i in range(3):\n ans += ls[i][i]\nprint(ans)", "def main():\n cat = \"\".join\n data = cat(input() for _ in range(3))\n print((cat([data[0], data[4], data[8]])))\n\n\nmain()\n", "a = input()\nb = input()\nc = input()\n\nprint((a[0] + b[1] + c[2]))\n", "#\n# abc090 a\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"ant\nobe\nrec\"\"\"\n output = \"\"\"abc\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"edu\ncat\nion\"\"\"\n output = \"\"\"ean\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n C1 = input()\n C2 = input()\n C3 = input()\n\n print((C1[0]+C2[1]+C3[2]))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "n = input()\nn1 = input()\nn2 = input()\n\nprint(n[0],n1[1],n2[2], flush=True,sep='')\n\n", "c = [str(input()) for i in range(3)]\nw = c[0][0]+c[1][1]+c[2][2]\nprint(w)", "moji1 = str(input())\nmoji2 = str(input())\nmoji3 = str(input())\n\nprint(moji1[0]+moji2[1]+moji3[2])", "a=input()\nb=input()\nc=input()\nprint(a[0]+b[1]+c[2])", "c1 = input()\nc2 = input()\nc3 = input()\n\nprint(c1[0]+c2[1]+c3[2])", "for i in range(3):\n s = input()\n print(s[i], end='')", "A = list(input())\nB = list(input())\nC = list(input())\n\nprint(f\"{A[0]}{B[1]}{C[2]}\")", "print(input()[0]+input()[1]+input()[2])", "a = str(input())\nb = str(input())\nc = str(input())\nprint(a[0]+b[1]+c[2])", "c1=input()\nc2=input()\nc3=input()\nprint(c1[0],end=\"\")\nprint(c2[1],end=\"\")\nprint(c3[2])", "a = input()\nb = input()\nc = input()\nprint(a[0]+b[1]+c[2])", "l=input()[0]\nl+=input()[1]\nl+=input()[2]\nprint(l)", "a = input()\nb = input()\nc = input()\n\nprint(a[0]+b[1]+c[2])", "import sys\ns = sys.stdin.read().split()\nprint(s[0][0] + s[1][1] + s[2][2])", "a = input()\nb = input()\nc = input()\nprint(a[0]+b[1]+c[2])", "[print(input()[i],end='') for i in range(3)]", "print(input()[0]+input()[1]+input()[2])", "s = input()\nt = input()\nu = input()\nprint(s[0]+t[1]+u[2])", "c_lst = [str(input()) for _ in range(3)]\nans = ''\nfor i in range(3):\n ans += c_lst[i][i]\nprint(ans)", "c = []\nfor i in range(3):\n c += [input()]\n \nprint(c[0][0] + c[1][1] + c[2][2])", "cs=[\"\"]*3\nfor i in range(3):\n cs[i]=input()\nprint(cs[0][0]+cs[1][1]+cs[2][2])", "c1 = input()\nc2 = input()\nc3 = input()\n\nprint(c1[0] + c2[1] + c3[2])", "a = [input() for _ in range(3)]\nprint(a[0][0] + a[1][1] + a[2][2])", "import sys\nC = sys.stdin.readlines()\nprint(C[0][0]+C[1][1]+C[2][2])", "c1 = input()\nc2 = input()\nc3 = input()\nprint(\"\".join(c1[0]+c2[1]+c3[2]))", "c1 = str(input())\nc2 = str(input())\nc3 = str(input())\n\nans = c1[0] + c2[1] + c3[2]\nprint(ans)", "ans = ''\nans += input()[0]\nans += input()[1]\nans += input()[2]\nprint(ans)\n", "i1=input()\ni2=input()\ni3=input()\nprint(str(i1[0])+str(i2[1])+str(i3[2]))", "c1 = list(input())\nc2 = list(input())\nc3 = list(input())\n\nprint(c1[0] + c2[1] + c3[2])", "a = input()[0]\nb = input()[1]\nc = input()[2]\nprint(a+b+c)", "a=input()\nb=input()\nc=input()\nprint(a[0]+b[1]+c[2])", "S = [input() for i in range(3)]\nprint(S[0][0]+S[1][1]+S[2][2])", "a = [list(input()) for i in range(3)]\n\nprint(a[0][0]+a[1][1]+a[2][2])", "l1 = input ()\nl2 = input ()\nl3 = input ()\nprint (l1[0]+l2[1]+l3[2])", "c1=str(input())\nc2=str(input())\nc3=str(input())\n\nprint(c1[0]+c2[1]+c3[2])", "n = list(input())\nn1 = list(input())\nn2 = list(input())\n\nprint(n[0]+n1[1]+n2[2])", "c1 = input()[0]\nc2 = input()[1]\nc3 = input()[2]\nprint((c1+c2+c3))\n", "a=input()\nb=input()\nc=input()\nprint(a[0]+b[1]+c[2])", "\ndef main():\n c = [input() for _ in range(3)]\n print((c[0][0] + c[1][1] + c[2][2]))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "c1 = input()\nc2 = input()\nc3 = input()\nprint(c1[0]+c2[1]+c3[2])", "cs=[]\nfor i in range(3):\n cs.append(input())\nprint(cs[0][0]+cs[1][1]+cs[2][2])", "a=input()\nb=input()\nc=input()\nprint(a[0]+b[1]+c[2])", "S = [input() for _ in range(3)]\nprint(S[0][0]+S[1][1]+S[2][2])", "a=input()\nb=input()\nc=input()\nprint(a[0]+b[1]+c[2])", "a = input()\nb = input()\nc = input()\nprint(a[0]+b[1]+c[2])"] | {"inputs": ["ant\nobe\nrec\n", "edu\ncat\nion\n"], "outputs": ["abc\n", "ean\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 9,133 | |
413b521961a05e54d9386e1e125d047d | UNKNOWN | Snuke has a grid consisting of three squares numbered 1, 2 and 3.
In each square, either 0 or 1 is written. The number written in Square i is s_i.
Snuke will place a marble on each square that says 1.
Find the number of squares on which Snuke will place a marble.
-----Constraints-----
- Each of s_1, s_2 and s_3 is either 1 or 0.
-----Input-----
Input is given from Standard Input in the following format:
s_{1}s_{2}s_{3}
-----Output-----
Print the answer.
-----Sample Input-----
101
-----Sample Output-----
2
- A marble will be placed on Square 1 and 3. | ["s=input()\ncount=0\nfor i in range(len(s)):\n if(s[i]==\"1\"):\n count+=1\nprint(count)", "a=input()\nprint((a.count('1')))\n", "# -*- coding: utf-8 -*-\n# \u6574\u6570\u306e\u5165\u529b\ns = input()\nnumber = \"1\"\n\ncount = s.count(number)\nprint(count)", "print(input().count(\"1\"))", "cnt = 0\nfor s in input():\n if int(s) == 1:\n cnt += 1\nprint(cnt)", "import bisect,collections,copy,heapq,itertools,math,string\nimport sys\ndef I():\n #1 line 1 int\n return int(sys.stdin.readline().rstrip())\ndef LI():\n #1 line n int\n return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S():\n #1 line 1 string\n return sys.stdin.readline().rstrip()\ndef LS():\n #1 line n strings\n return list(sys.stdin.readline().rstrip().split())\n\nx=S()\ncount=0\nfor s in x:\n if s == \"1\":\n count += 1\n \nprint(count)", "s = input()\nprint(s.count(\"1\"))", "s = list(input())\ncount = 0\nfor i in range(0, len(s)):\n if s[i] == \"1\":\n count += 1\n\nprint(count)", "import bisect,collections,copy,heapq,itertools,math,string\nimport sys\ndef I():\n # 1 line 1 int\n return int(sys.stdin.readline().rstrip())\ndef LI():\n # 1 line n ints\n return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S():\n # 1 line 1 string\n return sys.stdin.readline().rstrip()\ndef LS():\n # 1 line n strings\n return list(sys.stdin.readline().rstrip().split())\n\nx = S()\n\ncount = 0\nfor s in x:\n if s == \"1\":\n count += 1\n\nprint(count)", "s=input()\nprint(s.count('1'))", "s = list(map(int, input()))\ncount = 0\nfor i in range(len(s)):\n if s[i] == 1:\n count +=1\nprint(count)", "a = input()\ncount = 0\nfor i in a:\n if i == '1':\n count += 1\n else:\n pass\nprint(count)\n", "print(sum([int(ss) for ss in input()]))", "s1,s2,s3 = list(map(str, input()))\ncounter = 0\nif s1 == \"1\":\n counter += 1\nif s2 == \"1\":\n counter += 1\nif s3 == \"1\":\n counter += 1\nprint(counter)\n", "m = 0\nfor s in list(input()):\n if int(s) == 1:\n m += 1\nprint(m)\n", "s=input()\nprint(s.count(\"1\"))", "S = input()\ncount = 0\n\nif S[0] == '1':\n count += 1\nif S[1] == '1':\n count += 1\nif S[2] == '1':\n count += 1\n \nprint(count)", "s = input()\n \nprint(s.count(\"1\"))", "S =input()\nprint(S.count('1'))", "s = list(input())\n\nans = 0\n\nfor i in range(len(s)):\n if s[i] == '1':\n ans += 1\nelse:\n print(ans)", "print(input().count('1'))", "st_list = list(input())\nnu_list = [int(v) for v in st_list]\ncount = 0\nfor i in range(len(nu_list)):\n if nu_list[i] == 1:\n count += 1\nprint(count)", "n = input()\nresult = sum(list(map(int,str(n))))\nprint(result)", "s=input()\ncount=0\n\nfor i in range(0,3,1):\n if s[i]=='1':\n count = count + 1\n\nprint(count) ", "s=input()\nprint(s.count(\"1\"))", "# coding: utf-8\n# Your code here!\n\ncnt_1 = 0\n\nlist_S = input()\n\nfor i in list_S : \n if i == \"1\" : \n cnt_1 += 1\n \nprint(cnt_1)", "s = input()\nprint(s.count('1'))", "s = input()\nprint(s.count(\"1\"))", "s = input().count('1')\nprint(s)", "s = input()\ns_c = s.count(\"1\")\nprint(s_c)", "s = input()\ns1 = int(s[0])\ns2 = int(s[1])\ns3 = int(s[2])\nprint(s1+s2+s3)", "s = input()\nprint(s.count('1'))", "a=str(input())\ncount=0\nfor i in range(3):\n if a[i-1]==\"1\":\n count+=1\nprint(count)", "s = input()\nans = 0\nfor i in range(3):\n if s[i] == \"1\":\n ans += 1\n\nprint(ans)\n", "s = input()\nans = 0\nfor i in s:\n ans += int(i)\nprint(ans)", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\ns = list(str(input()))\n\nans = [1 if i == \"1\" else 0 for i in s]\n\nprint((sum(ans)))\n", "print(input().count('1'))", "s = input()\n\nprint(s.count(\"1\"))", "a=input()\nx=0\nfor i in range(3):\n if a[i]==\"1\":\n x=x+1\nprint(x)", "print((input().count('1')))\n", "b = input()\na = str(b)\ni = 0\nif a[0] == '1':\n i += 1\nif a[1] == '1':\n i += 1\nif a[2] == '1':\n i += 1\nprint(i)\n", "print(input().count(\"1\"))", "print(input().count('1'))", "print(input().count(\"1\"))", "s = list(map(int,input()))\ncount = 0\n\nfor n in s:\n if n == 1:\n count+=1\n \nprint(count)", "print(input().count(\"1\"))", "s = input()\na, b, c = int(s[0]), int(s[1]), int(s[2])\ncount = 0\nif a == 1:\n count+=1\nif b == 1:\n count+=1\nif c == 1:\n count+=1\nprint(count)", "#\u7b2c2\u554f\u3000ABC081A\nnumber = list(map(int,input()))\na = 0\nfor i in number:\n if i == 1:\n a = a+1\nprint(a)", "s = input()\n\nif s == '111':\n print(3)\nelif s == '110' or s == '101' or s == '011':\n print(2)\nelif s == '100' or s == '010' or s == '001':\n print(1)\nelse:\n print(0)", "print(input().count('1'))", "n = input()\nprint(n.count(\"1\"))", "s = str(input())\nprint(s.count('1'))", "a=input()\ncount=0\n\nfor i in range(3):\n if a[i]=='1':\n \tcount+=1\n\nprint(count)\n", "print(input().count('1'))", "print(input().count(\"1\"))", "getints = lambda: list(map(int, input().split()))\ns = input()\nans = 0\nfor c in s:\n if c == '1':\n ans += 1\nprint(ans)\n", "s = map(int, list(input()))\nprint(sum(s))", "s = input()\nprint(s.count('1'))", "print(input().count('1'))", "a = int(input())\n\ncount = 0\n\n# print(int(a/100))\nif int(a / 100) == 1:\n count += 1\n\n#print(int(a/10 % 10))\nif int(a / 10 % 10) == 1:\n count += 1\n\n#print(int(a % 100 % 10))\nif int(a % 100 % 10) == 1:\n count += 1\n\nprint(count)\n", "li = list(input())\nc = 0\nfor i in li:\n if i == '1':\n c += 1\n\nprint(c)", "s = str(input())\nans = int(s[0])+int(s[1])+int(s[2])\nprint(ans)", "a = input()\nprint(a.count('1'))", "a = input()\nprint((a.count('1')))\n", "print(input().count(\"1\"))", "s=list(input())\nres=0\nfor i in s:\n if (i=='1'):\n res+=1\nprint(res)", "s = input()\nprint(s.count(\"1\"))", "A = input()\n\nans=int(0)\n\nif A[0] == \"1\":\n ans = ans + 1\n\nif A[1] == \"1\":\n ans = ans + 1\n\nif A[2] == \"1\":\n ans = ans + 1\n\nprint(ans)", "s=input()\nprint(s.count(\"1\"))", "s = list(input())\ncnt = 0\nfor item in s:\n if (int(item) == 1):\n cnt = cnt + 1\nprint(cnt)", "i = str(input())\ns1, s2, s3 = int(i[0]), int(i[1]), int(i[2])\nprint(int(s1+s2+s3))", "D = input()\n\nA=\"1\"\nB=\"11\"\nC=\"101\"\nF=\"111\"\n\nif F == D:\n print((3))\n \nelif B in D:\n print((2))\n\nelif C == D:\n print((2))\n\nelif A in D:\n print((1))\n\nelse:\n print((0))\n", "s = input()\ncnt = 0\n\nif s[0] == '1' : cnt += 1\nif s[1] == '1' : cnt += 1\nif s[2] == '1' : cnt += 1\n\nprint(cnt)\n", "s1,s2,s3 = map(int, input())\n\nnumber_list = [s1,s2,s3]\n\ncounter = 0\n\nfor i in range(len(number_list)):\n if number_list[i] == 1:\n counter += 1\nprint(counter)", "s = input()\n\nprint(s.count(\"1\"))", "s=input()\nprint(s.count(\"1\"))", "s = list(input())\nprint(s.count(\"1\"))", "\n\n# Press the green button in the gutter to run the script.\ndef __starting_point():\n s = input()\n\n count = 0\n for n in range(3):\n if s[n] == '1':\n count = count + 1\n\n print(count)\n\n__starting_point()", "s = input()\nprint(s.count(\"1\"))", "a = input()\n\nb = a.count('1')\nprint(b)", "area = input()\nprint(area.count(\"1\"))", "print(input().count(\"1\"))", "def main():\n s = input()\n print(s.count(\"1\"))\n\n\nmain()", "s = list(input())\n\nprint(s.count('1'))", "def iroha():\n num = input()\n count = 0\n\n for i in num:\n if i == '1':\n count+=1\n \n print(count)\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "a = input()\nprint((a.count('1')))\n", "s = input()\nans = 0\n\nfor i in s:\n if i == \"1\":\n ans += 1\n\nprint(ans)", "s = input()\nprint((s.count('1')))\n", "s = input()\nans = 0\nfor i in s:\n ans += int(i)\nprint(ans)", "s = input()\ncount = 0\nif s[0] == '1':\n count += 1\nif s[1] == '1':\n count +=1\nif s[2] == '1':\n count += 1\nprint(count)", "# \u6587\u5b57\u5217\u306e\u5165\u529b\ns = input()\n\nprint(int(s[0]) + int(s[1]) + int(s[2]))", "print(input().count('1'))", "def solve(s):\n count = 0\n if s[0] == '1':\n count += 1\n if s[1] == '1':\n count += 1\n if s[2] == '1':\n count += 1\n print(count)\n\n\ndef __starting_point():\n solve(input())\n\n__starting_point()", "a = input()\nprint(a.count(\"1\"))", "#81\ndata=list(input())\nc=0\nfor i in range(0,len(data)):\n if data[i]=='1':\n c=c+1\nprint(c)", "print(input().count('1'))", "print(input().count(\"1\"))", "s = input()\n\nprint(s.count(\"1\"))", "s = input()\n \ncnt = sum([int(c) for c in s])\nprint(cnt)"] | {"inputs": ["101\n", "000\n"], "outputs": ["2\n", "0\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 8,734 | |
35e00c74f4ee02f5b342b7ac245f8bbf | UNKNOWN | There is a hotel with the following accommodation fee:
- X yen (the currency of Japan) per night, for the first K nights
- Y yen per night, for the (K+1)-th and subsequent nights
Tak is staying at this hotel for N consecutive nights.
Find his total accommodation fee.
-----Constraints-----
- 1 \leq N, K \leq 10000
- 1 \leq Y < X \leq 10000
- N,\,K,\,X,\,Y are integers.
-----Input-----
The input is given from Standard Input in the following format:
N
K
X
Y
-----Output-----
Print Tak's total accommodation fee.
-----Sample Input-----
5
3
10000
9000
-----Sample Output-----
48000
The accommodation fee is as follows:
- 10000 yen for the 1-st night
- 10000 yen for the 2-nd night
- 10000 yen for the 3-rd night
- 9000 yen for the 4-th night
- 9000 yen for the 5-th night
Thus, the total is 48000 yen. | ["\nN = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\nif K < N:\n ans = K*X + (N-K)*Y\nelse:\n ans = N*X\nprint(ans)", "N, K, X, Y = [int(input()) for _ in range(4)]\nprint(X * min(K, N) + Y * max(0, N - K))", "n,k,x,y = [int(input()) for _ in range(4)]\n\nif k <= n:\n sum = (x * k) + (y * (n-k))\nelse:\n sum = x * n\n\nprint(sum)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n > k :\n print(k*x + (n-k)*y)\nelif n <= k:\n print(n*x)", "import math\nfrom datetime import date\n\ndef main():\n\t\n\tn = int(input())\n\tk = int(input())\n\tx = int(input())\n\ty = int(input())\t\n\t\n\tans = max(0, n - k) * y + min(n, k) * x;\n\tprint(ans)\n\nmain()\n", "n,k,x,y=[int(input()) for i in range(4)]\nif n<=k:\n print(n*x)\nelse:\n print(k*x+(n-k)*y)", "N,K,x,y = [int(input()) for i in range(4)]\n\nif K<N:\n print((N-K)*y + K*x)\n \nelse:\n print(N*x)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n > k:\n print(k*x+(n-k)*y)\nelse: \n print(n*x)", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\nif N > K:\n print(K*X+(N-K)*Y)\nelse:\n print(N*X)", "a,b,c,d = [int(input()) for i in range(4)]\nif a<b:\n\tprint(a*c)\nelse:\n\tprint((b*c) +((a-b) * d) )", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\nif N <= K:\n print(N * X)\nelse:\n print(K * X + (N - K) * Y)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nprint(x * min(n, k) + y * max(n-k, 0))", "# 044_a\n# A - \u9ad8\u6a4b\u541b\u3068\u30db\u30c6\u30eb\u30a4\u30fc\u30b8\u30fc\n\nN = int(input()) # \u9023\u6cca\u6570\nK = int(input()) # \u6599\u91d1\u5909\u52d5\u6cca\u6570\nX = int(input()) # \u901a\u5e38\u4fa1\u683c\nY = int(input()) # \u5909\u52d5\u4fa1\u683c\n\nif ((1 <= N & N <= 10000) & (1 <= K & K <= 10000)) \\\n & (1 <= X & X <= 10000) & (1 <= Y & Y <= 10000):\n if (X > Y):\n price = 0\n if (N < K):\n for i in range(1, N + 1):\n price += X\n if (N >= K):\n for i in range(1, K + 1):\n price += X\n for j in range(K + 1, N + 1):\n price += Y\n print(price)", "n,k,x,y = [int(input()) for i in range(4)]\ncost = (min(n,k)*x+max(0,n-k)*y)\nprint(cost)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nans = 0\nif n <= k:\n ans = n*x\nelse:\n ans = k*x + (n-k)*y\nprint(ans)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n > k:\n ans = k * x + (n - k) * y\n \nelse:\n ans = n * x\n \nprint(ans)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nprint((min(k, n)*x + max(n-k, 0)*y))\n", "n=int(input())\nk=int(input())\nx=int(input())\ny=int(input())\nfirst=min(n,k)\nre=first*x\nre+=max((n-first),0)*y\nprint(re)", "def main():\n n = int(input())\n k = int(input())\n x = int(input())\n y = int(input())\n\n if n <= k :\n ans = x * n\n else :\n ans = x * k + y * (n - k)\n\n print(ans)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "# \u6700\u521d\u306eK\u6cca\u307e\u3067\u306f\u30011\u6cca\u3042\u305f\u308aX\u5186\n# K+1\u6cca\u76ee\u4ee5\u964d\u306f\u30011\u6cca\u3042\u305f\u308aY\u5186\n# N\u6cca\u3057\u305f\u3068\u304d\u306e\u5bbf\u6cca\u8cbb\n\nN = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\n\nif N <= K:\n print(X * N)\nelse:\n print(X * K + Y * (N - K))", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\n\nans = 0\n\nfor i in range(1,N+1):\n if i<=K:\n ans += X\n else:\n ans += Y\n \nprint(ans)\n", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nif n > k:\n print(x * k + y * (n - k))\nelse:\n print(x * n)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nif n >= k:\n print(k*x + (n-k)*y)\nelse:\n print(n*x)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n > k:\n print((k*x+(n-k)*y))\nelse:\n print((n*x))\n", "# \u6570\u5024\u306e\u53d6\u5f97\nN = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\n\n# \u5bbf\u6cca\u8cbb\u306e\u8a08\u7b97\u5f8c\u7d50\u679c\u3092\u51fa\u529b\nif N <= K:\n account = N * X\nelse:\n account = (K * X) + (max(N - K,0) * Y) \n \nprint(account)", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\nans = 0\n\nif N > K:\n for i in range(0, K):\n ans += X\n for i in range(K, N):\n ans += Y\nelif N <= K:\n for i in range(0, N):\n ans += X\n\nprint(ans)", "from sys import stdin\ninput = stdin.readline\n\nN = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\n\nif N <= K:\n cost = N * X\nelse:\n cost = K * X + (N - K) * Y\n\nprint(cost)", "N=int(input())\nK=int(input())\nX=int(input())\nY=int(input())\n\nif N<=K:\n print(X*N)\nelse:\n print(X*K+Y*(N-K))", "n=int(input())\nk=int(input())\nx=int(input())\ny=int(input())\n\nprint(min(k,n)*x+max(0,n-k)*y)", "\"\"\"\nABC044 A \u9ad8\u6a4b\u541b\u3068\u30db\u30c6\u30eb\u30a4\u30fc\u30b8\u30fc\nhttps://kenkoooo.com/atcoder/#/table/Tsukumo\n\"\"\"\n\nn = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n > k:\n ans = k*x + (n-k)*y\nelse:\n ans = n*x\nprint(ans)\n", "n= int(input())\nk= int(input())\nx= int(input())\ny= int(input())\nprint((x*n if k>=n else (n-k)*y+x*k))\n", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nprint((min(k, n)*x + max((n-k)*y, 0)))\n", "def solve():\n n = int(input())\n k = int(input())\n x = int(input())\n y = int(input())\n print((x * min(n, k) + y * max(n-k,0)))\n\n\ndef __starting_point():\n solve()\n\n__starting_point()", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nif n <= k:\n print(n*x)\nelse:\n print(k*x + (n-k)*y)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nif n < k: print(x * n)\nelse: print(x * k + y * (n - k))", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\nif N > K:\n SUM = X*K + Y*(N - K)\nelse:\n SUM = X*N\nprint(SUM)\n", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n < k:\n print(n * x)\nelse:\n print(k * x + (n - k) * y)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n > k:\n print(k * x + (n - k) * y)\nelse:\n print(n * x)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n <= k:\n print(n*x)\nelse:\n print(k*x+(n-k)*y)", "# abc044_a\n# https://atcoder.jp/contests/abc044/tasks/abc044_a\n\n# \u6700\u521d\u306eK\u6cca\u307e\u3067\u306f\u3001X\u5186\n# K\uff0b1\u6cca\u76ee\u4ee5\u964d\u306f\u3001Y\u5186\n\n# N\u6cca\u9023\u7d9a\u3067\u5bbf\u6cca\u3057\u305f\u969b\u306e\u5bbf\u6cca\u8cbb\n\n# \u5165\u529b\nn = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\n# \u51e6\u7406\n\n# x\u5186\u3068y\u5186\nif n > k:\n answer = k * x + (n - k) * y\n# x\u5186\u306e\u307f\nelse:\n answer = n * x\n\nprint(answer)\n", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nans = min(n,k)*x + max(n-k,0)*y\nprint(ans)", "N, K, X, Y = [int(input()) for _ in range(4)]\nresult = min(N, K)\nN -= result\nresult *= X\n\nif N >= 0:\n result += N * Y\nprint(result)", "n,k,x,y=[int(input()) for _ in range(4) ]\nans=k*x+(n-k)*y\nprint(ans if n>k else n*x)", "n,k,x,y=[int(input()) for i in range(4)]\nprint(n*x+min(0,(k-n)*(x-y)))", "N=int(input())\nK=int(input())\nX=int(input())\nY=int(input())\nif K<N:\n print((X*K+Y*(N-K)))\nelse:\n print((X*N))\n\n", "n,k,x,y = [int(input()) for _ in range(4)]\nprint((min(n,k)*x + max(0,n-k)*y))\n", "n,k,x,y=int(input()),int(input()),int(input()),int(input())\nif n<k:print(x*n)\nelse:print(x*k+y*(n-k))", "import sys\nimport math\n\n#https://atcoder.jp/contests/agc008/submissions/15248942\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninm = lambda: map(int, sys.stdin.readline().split())\ninl = lambda: list(inm())\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\nN = ini()\nK = ini()\nX = ini()\nY = ini()\n\nif N > K:\n print(K*X+(N-K)*Y)\nelse:\n print(N*X)\n", "N, K, X, Y = [int(input()) for i in range(4)]\nprint(K * X + (N - K) * Y if N > K else N * X)", "n=int(input())\nk=int(input())\nx=int(input())\ny=int(input())\nans=0\nif n>=k:\n ans+=x*k\n n-=k\n ans+=y*n\nelse:\n ans+=x*n\nprint(ans)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nif k <= n:\n print(k*x+(n-k)*y)\nelse:\n print(n*x)", "total=int(input()) #\u5bbf\u6cca\u65e5\u6570\ndisc=int(input()) #\u521d\u3081\u306e\u5272\u5f15\u306a\u3057\u65e5\u6570\npriceX=int(input()) #\u5272\u5f15\u306a\u3044\u5024\u6bb5\npriceY=int(input()) #\u5272\u5f15\u5f8c\u306e\u5024\u6bb5\n\nans=()\nif total<=disc:\n ans=total*priceX\nelse:\n ans=disc*priceX+(total-disc)*priceY\nprint(ans)", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\n\nans = 0\n\nfor i in range(N):\n if i + 1 <= K:\n ans += X\n else:\n ans += Y\nprint(ans)", "N = int(input()) # N\u6cca\nK = int(input()) # \u6700\u521d\u306eK\u6cca\u307e\u3067\u306f1\u6cca\u5f53\u305f\u308aX\u5186\nX = int(input())\nY = int(input()) # K+1\u6cca\u76ee\u4ee5\u964d\u306f1\u6cca\u5f53\u305f\u308aY\u5186\n\nif N - K > 0:\n total = (K * X) + ((N - K) * Y)\nelse:\n total = N * X\n\nprint(total)\n", "n,k,x,y=[int(input()) for _ in range(4)];print([n*x,k*x+(n-k)*y][n-k>0])", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\n\nif N <= K:\n ans = X * N\nelse:\n ans = X * K + (N - K) * Y\nprint(ans)", "import sys\n\ndef I(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef main():\n n = I()\n k = I()\n x = I()\n y = I()\n if n <= k:\n print(n*x)\n else:\n print(k*x + (n-k)*y)\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\ns = 0\nfor i in range(1, n+1, 1):\n if i <= k:\n s += x\n else:\n s += y\nprint(s)\n", "n=int(input())\nk=int(input())\nx=int(input())\ny=int(input())\n\nif n <= k:\n print(n*x)\n \nelse:\n print(k*x+(n-k)*y)", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\nif K < N:\n print(K * X + (N - K) * Y)\nelse:\n print(N * X)", "#!/usr/bin/env python3\n\ndef main():\n n = int(input())\n k = int(input())\n x = int(input())\n y = int(input())\n print((n * x - (x - y) * max(n - k, 0)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\n\nif n <= k:\n print((n*x))\nelse:\n print((k*x+(n-k)*y))", "N=int(input())\nK=int(input())\nX=int(input())\nY=int(input())\nprint((K*X+(N-K)*Y if N>=K else X*N))\n", "n=int(input())\nk=int(input())\nx=int(input())\ny=int(input())\nfees=0\nif(k>n or n==k):\n\tfor i in range(0,n):\n\t\tfees+=x\nelif(k<n):\n\tdiff=n-k\n\tfor j in range(0,k):\n\t\tfees+=x\n\tfor k in range(0,diff):\n\t\tfees+=y\n\t\t\nprint(fees)\n", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nif n<=k:\n print(n*x)\nelse:\n tmp = (n-k) * y + k * x\n print(tmp)", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\n \nif N<=K:\n print(X*N)\nelse:\n print(K * X + (N - K) * Y)", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\nif N > K:\n print(K * X + (N - K) * Y)\nelse:\n print(N * X)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nans = min(n, k) * x\nn -= min(n, k)\n\nans += n * y\n\nprint(ans)\n", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\ncost = 0\nif n > k:\n for i in range(k):\n cost += x\n\n for j in range(k, n):\n cost += y\n print(cost)\n\nelif n <= k:\n for i in range(n):\n cost += x\n print(cost)\n\n\n", "n=int(input())\nk=int(input())\nx=int(input())\ny=int(input())\nif k<n:\n print(k*x+(n-k)*y)\nelse:\n print(n*x)", "N,K,X,Y=[int(input()) for i in range(4)]\n\nif(K>=N):\n Z=N*X\n print(Z)\nelse:\n Z=K*X+(N-K)*Y\n print(Z)", "n, k, x, y = [int(input()) for _ in range(4)]\nif n <= k:\n print(x * n)\nelse:\n print(x * k + y * (n - k))", "n=int(input())\nk=int(input())\nx=int(input())\ny=int(input())\nif n<k:\n print(n*x)\nelse:\n print(k*x+(n-k)*y)", "class Combination:\n def __init__(self, n, mod):\n self.n = n\n self.mod = mod\n self.fac = [1 for i in range(self.n + 1)]\n self.finv = [1 for i in range(self.n + 1)]\n for i in range(2, self.n+1):\n self.fac[i] = (self.fac[i - 1] * i) % self.mod\n self.finv[i] = (self.finv[i-1] * pow(i, -1, self.mod)) % self.mod\n\n def comb(self, n, m):\n return self.fac[n] * (self.finv[n-m] * self.finv[m] % self.mod) % self.mod\ndef iparse():\n return list(map(int, input().split()))\n\ndef __starting_point():\n n = int(input())\n k = int(input())\n x = int(input())\n y = int(input())\n\n print((min(k,n)*x + max(0,n-k)*y))\n \n\n__starting_point()", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\n\nif N <= K:\n print(N * X)\nelif N >= K:\n k_stay = K * X\n k_plus_stay = (N - K) * Y\n print(k_plus_stay + k_stay)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nn1 = n - k\nif n > k:\n print((k*x)+(y*n1))\nelse:\n print(n*x)", "N=int(input())\nK=int(input())\nX=int(input())\nY=int(input())\n\nif N<=K:\n print((X*N))\nelse:\n print((X*K+Y*(N-K)))\n", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nif n >= k:\n print((k * x) + (n - k) * y)\nelse:\n print(n * x)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nans = 0\nfor i in range(n):\n if i < k:\n ans += x\n else:\n ans += y\n \nprint(ans)", "N = int(input())\nK = int(input())\nX = int(input())\nY = int(input())\nprice = 0\nif N <= K:\n for i in range(N):\n price += X\n print(price)\nelse:\n for i in range(K):\n price += X\n for i in range(N-K):\n price += Y\n print(price)", "import sys\nfrom heapq import heappush, heappop, heapify\nimport math\nfrom math import gcd\nimport itertools as it\nfrom collections import deque \n\ninput = sys.stdin.readline\n\ndef inp():\n return int(input())\ndef inpl():\n return list(map(int, input().split()))\n\nINF = 1001001001\n\n# ---------------------------------------\n\ndef main():\n n = inp()\n k = inp()\n x = inp()\n y = inp()\n if n > k:\n print((x * k + y * (n - k)))\n else:\n print((x * n))\n\nmain()\n", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nif n<k:\n print(n*x)\nelse:\n print((n-k)*y + k*x)", "L = [int(input()) for _ in range(4)]\nprint(L[2]*min(L[0],L[1])+L[3]*max(0,L[0]-L[1]))", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n \nn1 = n - k\nif n > k:\n print((k*x)+(y*n1))\nelse:\n print(n*x)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n <= k:\n print(x*n)\nelse:\n print((x*k) + (y*(n-k)))", "def iroha():\n n, k, price, special = [int(input()) for i in range(4)]\n result = 0\n for i in range(n):\n if i < k:\n result += price\n else:\n result += special\n print(result)\n\ndef __starting_point():\n iroha()\n\n__starting_point()", "a,b,c,d=[int(input()) for i in range(4)]\nprint(min(a,b)*c+max(0,(a-b))*d)", "n,k,x,y = [int(input()) for i in range(4)]\ncost=(min(n,k)*x+max(0,n-k)*y)\nprint(cost)", "val = [int(input()) for i in range(4)]\nif val[0] > val[1] :\n print(val[1] * val[2] + (val[0] - val[1]) * val[3])\nelse:\n print(val[0] * val[2])", "import sys\nN, K, X, Y = map(int, sys.stdin.readlines())\nprint(N*X if N <= K else K*X +Y*(N-K))", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n > k:\n total = (k * x) + (n - k) * y\n print(total)\nelse:\n total = n * x\n print(total)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nans = 0\nif n>k:\n ans = (k*x) + (n-k)*y\nelse:\n ans = n*x\nprint(ans)", "N=int(input())\nK=int(input())\nX=int(input())\nY=int(input())\n#print(type(N))\n\nif N<=K:\n daikin = X*N\nelse:\n daikin = X*K+Y*(N-K)\nprint(daikin)", "\nn = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\nif n <= k:\n print(n*x)\nelse:\n print(k*x + (n-k)*y)", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n <= k:\n print((n*x))\nelse:\n print((k*x + (n-k)*y))\n", "total = int(input())\ninitial = int(input())\nif initial > total:\n initial = total\na = int(input())\nb = int(input())\ncount = 0\nfor i in range(initial):\n count+= a\nfor c in range(total - initial):\n count+=b\n\nprint(count)\n", "from sys import stdin\ninput = stdin.readline\n\nn, k, x, y = list(map(int, stdin.read().split()))\n\nprint((min(k, n) * x + max(0, n - k) * y))\n", "n=int(input())\nk=int(input())\nx=int(input())\ny=int(input())\nans =0\nfor i in range(n):\n if(i+1<=k):\n ans += x\n if(i+1>k):\n ans += y\nprint(ans)\n \n", "n = int(input())\nk = int(input())\nx = int(input())\ny = int(input())\n\nif n > k:\n print(k*x+(n-k)*y)\nelse: \n print(n*x)"] | {"inputs": ["5\n3\n10000\n9000\n", "2\n3\n10000\n9000\n"], "outputs": ["48000\n", "20000\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 17,817 | |
c5077d9fefc8421e171cbad2042edd66 | UNKNOWN | Joisino wants to evaluate the formula "A op B".
Here, A and B are integers, and the binary operator op is either + or -.
Your task is to evaluate the formula instead of her.
-----Constraints-----
- 1β¦A,Bβ¦10^9
- op is either + or -.
-----Input-----
The input is given from Standard Input in the following format:
A op B
-----Output-----
Evaluate the formula and print the result.
-----Sample Input-----
1 + 2
-----Sample Output-----
3
Since 1 + 2 = 3, the output should be 3. | ["a, o, b = input().split()\nif o == '+':\n print((int(a) + int(b)))\nelse:\n print((int(a) - int(b)))\n", "a, op, b = input().split()\n\na = int(a)\nb = int(b)\n\nif op == \"+\":\n S = a + b\nelse:\n S = a - b\n\nprint(S)\n", "A, op, B = input().split()\nif op == '-':\n print((int(A) - int(B)))\nelse:\n print((int(A) + int(B)))\n", "A, op, B = input().split()\nprint(int(A) + int(B) if op == \"+\" else int(A) - int(B))", "a, op , b = input().split()\nif op == '+':\n print(int(a) + int(b))\nelse:\n print(int(a) - int(b))", "a, op, b = input().split()\na, b = int(a), int(b)\n\nif op == '+':\n print((a + b))\nelse:\n print((a - b))\n", "# \u5165\u529b\nA, op, B = list(map(str, input().split()))\n\n# +\u306a\u3089\u8db3\u3059\u3001-\u306a\u3089\u5f15\u304f\nif op == '+':\n print((int(A) + int(B)))\nelif op == '-':\n print((int(A) - int(B)))\n", "A,op,B=input().split()\nA,B=int(A),int(B)\nif op==\"+\":\n print(A+B)\nelse:\n print(A-B)", "a,op,b=map(str,input().split())\na=int(a)\nb=int(b)\nif op==\"+\":\n print(a+b)\nelse:\n print(a-b)", "# A op B\u3068\u3044\u3046\u5f0f\u306e\u5024\u3092\u8a08\u7b97\n\nA, op, B = map(str, input().split())\nA = int(A)\nB = int(B)\n\nif op == '+':\n print(A + B)\nelse:\n print(A - B)", "A, op, B=input().split()\nA = int(A)\nB = int(B)\n\nif op == '+':\n print(A+B)\nelse:\n print(A-B)", "A, op, B = input().split()\nA, B = int(A), int(B)\n\nif op == \"+\":\n ans = A + B\nelse:\n ans = A - B\n\nprint(ans)", "A, op, B = input().split()\nA, B = int(A), int(B)\nprint(A+B if op == '+' else A-B)", "a,op,b=input().split()\nif op==\"+\":\n print(int(a)+int(b))\nelse:\n print(int(a)-int(b))", "s = input()\n\nif '+' in s:\n index = s.index('+')\n print((int(s[:index])+int(s[index+1:])))\nelse:\n index = s.index('-')\n print((int(s[:index])-int(s[index+1:])))\n", "a = input().split()\nif a[1] == '+':\n print(int(a[0])+int(a[2]))\nelse:\n print(int(a[0])-int(a[2]))", "# 050_a\nA, op, B = input().split()\nA = int(A)\nB = int(B)\nif (1 <= A & A <= 10 ** 9) & (1 <= B & B <= 10 ** 9) & ((op == '+') | (op == '-')):\n if op == '+':\n result = A + B\n elif op == '-':\n result = A - B\n print(result)", "a, op, b = input().split()\nif op == '+':\n ans = int(a) + int(b)\nelse:\n ans = int(a) - int(b)\nprint(ans)", "a, b, c = input().split()\nif b == \"+\":\n print(int(a) + int(c))\nelse:\n print(int(a) - int(c))", "a,op,b=input().split()\nif op==\"+\":\n print(int(a)+int(b))\nelse:\n print(int(a)-int(b))", "s = list(input().split())\nprint(eval(\"\".join(s)))", "a,b,c = map(str,input().split())\na = int(a)\nc = int(c)\nif b == '+':\n print(a+c)\nelse:\n print(a-c)", "# joisino\u304a\u59c9\u3061\u3083\u3093\u306f\u3001A op B \u3068\u3044\u3046\u5f0f\u306e\u5024\u3092\u8a08\u7b97\u3057\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002\n# \u3053\u3053\u3067\u3001A, B\u306f\u6574\u6570\u3067\u3001op \u306f\u3001+ \u307e\u305f\u306f - \u306e\u8a18\u53f7\u3067\u3059\u3002\n# \u3042\u306a\u305f\u306e\u4ed5\u4e8b\u306f\u3001joisino\u304a\u59c9\u3061\u3083\u3093\u306e\u4ee3\u308f\u308a\u306b\u3053\u308c\u3092\u6c42\u3081\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u308b\u3053\u3068\u3067\u3059\u3002\n\n# \u5236\u7d04\n# 1 \u2266 A, B \u2266 1000000000\n# op \u306f\u3001+ \u307e\u305f\u306f - \u306e\u8a18\u53f7\u3067\u3042\u308b\u3002\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 A op B \u3092\u53d6\u5f97\u3059\u308b\na, op, b = list(map(str,input().split()))\n\ninput_a = int(a)\ninput_b = int(b)\n\n# op\u306b\u5f93\u3044\u3001\u8a08\u7b97\u3057\u3066\u51fa\u529b\u3059\u308b\nresult = 0\nif op == \"+\":\n result = input_a + input_b\nelif op == \"-\":\n result = input_a - input_b\nelse:\n result = \"Error\"\n\nprint(result)\n", "a,op,b = input().split()\n\nprint(int(a)+int(b) if op == '+' else int(a)-int(b))", "a,b,c=map(str,input().split())\na=int(a)\nc=int(c)\nif b==\"+\":\n print(a+c)\nelse:\n print(a-c)", "s=input()\nprint(eval(s))", "a,b,c=list(map(str,input().split()))\na=int(a)\nc=int(c)\nif(b==\"+\"):\n print((a+c))\nelif(b==\"-\"):\n print((a-c))\n", "a, b, c = map(str, input().split())\n\na = int(a)\nc = int(c)\n\nif b == '+':\n print(a + c)\nelse:\n print(a - c)", "s = input()\nprint(eval(s))", "a, op, b = input().split()\nif op == '+':\n print(int(a) + int(b))\nelse:\n print(int(a) - int(b))", "#50\ndata= list(input().split())\nif data[1]=='+':\n print(int(data[0])+int(data[2]))\nelif data[1]=='-':\n print(int(data[0])-int(data[2]))", "A, op, B = input().split()\nif op == '+':\n print(int(A) + int(B))\nelse:\n print(int(A) - int(B))", "s, o, t = input().split()\nif o == '+':\n a = int(s) + int(t)\nelse:\n a = int(s) - int(t)\nprint(a) ", "# \u6570\u5024\u3068\u7b26\u53f7\u306e\u53d6\u5f97\nA,op,B = map(str,input().split())\n\n# \u8a08\u7b97\u3057\u3066\u51fa\u529b\ncalc = eval(A + op + B)\nprint(int(calc))", "A, op, B = input().split()\nA = int(A)\nB = int(B)\nprint([A + B, A - B][op == '-'])", "a, op, b = map(str, input().split())\na = int(a)\nb = int(b)\n\nif op == \"+\":\n result = a + b\nelse:\n result = a - b\n\nprint(result)", "A, op, B = input().split()\nA = int(A)\nB = int(B)\n\nif op == \"+\":\n print(A + B)\nif op == \"-\":\n print(A - B)", "a,x,b = input().split()\nif x == '+':\n print(int(a)+int(b))\nelse:\n print(int(a)-int(b))", "A, op, B = input().split()\nif op == \"+\":\n print(int(A)+int(B))\nelse:\n print(int(A)-int(B))", "a,b,c=input().split()\nif b==\"+\":\n print(int(a)+int(c))\nelse:\n print(int(a)-int(c))", "a, op, b = input().split()\na, b = int(a), int(b)\nprint(a+b if op=='+' else a-b)", "def calculate(a, b, op):\n if op == '+':\n return a + b\n else:\n return a - b\n\n\nlst = list(map(str, input().split()))\nprint(calculate(int(lst[0]), int(lst[2]), lst[1]))", "A,op,B = map(str,input().split())\n\nA = int(A)\nB = int(B)\n\nif op == '+':\n print(A + B)\n\nelif op == '-':\n print(A - B)", "L = list(map(str, input().split()))\n\nif L[1] == '+':\n print((int(L[0]) + int(L[2])))\nelse:\n print((int(L[0]) - int(L[2])))\n", "def iroha():\n a, op, b = list(map(str, input().split()))\n a = int(a)\n b = int(b)\n\n if op == \"+\":\n result = a + b\n else:\n result = a - b\n\n print(result)\n\n\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "a,b,c = input().split()\nprint(int(a)+int(c) if b == \"+\" else int(a) - int(c))", "#!/usr/bin/env python3\na,op,b=input().split()\nif op==\"+\":\n print(int(a)+int(b))\nelse:\n print(int(a)-int(b))", "A,c,B=input().split()\nA=int(A)\nB=int(B)\nif c==\"+\":\n print((A+B))\nelif c==\"-\":\n print((A-B))\n \n", "a, op, b = list(map(str, input().split()))\nif op == '+':\n print((int(a) + int(b)))\nelse:\n print((int(a) - int(b)))\n", "A, op, B = list(map(str, input().split()))\n\nif op == '+':\n print(int(A) + int(B))\nelse:\n print(int(A) - int(B))", "'''\nABC050 A - Addition and Subtraction Easy\nhttps://atcoder.jp/contests/abc050/tasks/abc050_a\n'''\ndef main():\n a, op, b = input().split()\n a, b = int(a), int(b)\n\n if op == '+':\n ans = a+b\n elif op == '-':\n ans = a-b\n print(ans)\n\n\nmain()\n", "a = list(input().split())\na[0] = int(a[0])\na[2] = int(a[2])\nif a[1] == \"+\":\n print((a[0]+a[2]))\nelse:\n print((a[0]-a[2]))\n", "a, op, b = list(map(str, input().split()))\na = int(a)\nb = int(b)\n\nif op == '+':\n print((a + b))\nelif op == '-':\n print((a - b))\n", "# \u5165\u529b\nA, op, B = map(str,input().split())\n\n# \u51e6\u7406\nA = int(A)\nB = int(B)\nif op == '+':\n print(A + B)\nelse:\n print(A - B)", "A,op,B=input().split()\nif op=='+':\n print((int(A)+int(B)))\nelse:\n print((int(A)-int(B)))\n", "a, b, c = input().split()\na = int(a)\nc = int(c)\nif b == '+':\n print(a + c)\nelse:\n print(a - c)", "'''\nABC050 A - Addition and Subtraction Easy\nhttps://atcoder.jp/contests/abc050/tasks/abc050_a\n'''\ndef main():\n a, op, b = input().split()\n a, b = int(a), int(b)\n\n if op == '+':\n ans = a+b\n elif op == '-':\n ans = a-b\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "S_list = list(input().split())\n\nif S_list[1] == \"+\" :\n result = int(S_list[0]) + int(S_list[2])\nelse :\n result = int(S_list[0]) - int(S_list[2])\nprint(result)\n", "A,op,B = input().split()\nA = int(A)\nB = int(B)\nif op == '+':\n print(A+B)\nelse:\n print(A-B)", "a,b,c = input().split()\nif b == \"+\":\n print(int(a) + int(c))\nelse:\n print(int(a) - int(c))", "a, op, b = input().split()\nif op == \"+\":\n print((int(a) + int(b)))\nelse:\n print((int(a) - int(b)))\n", "# A - Addition and Subtraction Easy\n# https://atcoder.jp/contests/abc050/tasks/abc050_a\n\na, op, b = list(map(str, input().split()))\n\nresult = eval(a + op + b)\n\nprint((int(result)))\n", "a,x,b = map(str,input().split())\nif x == \"+\":\n print(int(a)+int(b))\nelse:\n print(int(a)-int(b))", "a = input().split()\n\n\nif a[1] == \"+\":\n print((int(a[0])+int(a[2])))\n\nelse:\n print((int(a[0])-int(a[2])))\n", "a,b,c = input().split()\n\na = int(a)\nc = int(c)\n\nif b == \"+\":\n print(int(a)+c)\nelse:\n print(a-c)", "A, op, B = input().split()\nA = int(A)\nB = int(B)\n\nif op == '+':\n print(A + B)\nelse:\n print(A - B)", "s = input()\na, op, b = s.split()\na = int(a)\nb = int(b)\nif op == \"+\":\n c = a + b\nelse:\n c = a - b\n \nprint(c)", "a,op,b = input().split()\n\nprint(int(a) + int(b) if op == '+' else int(a) - int(b))", "a, op, b = map(str, input().split())\n\nif op == '+':\n print(int(a) + int(b))\nelif op == '-':\n print(int(a) - int(b))", "# \u5165\u529b\nA, op, B = input().split()\nA, B = int(A), int(B)\n\n# \u51e6\u7406\nif op == '+':\n S = A + B\nelse:\n S = A - B\n# \u51fa\u529b\nprint(S)", "print(eval(\"\".join(list(input().split()))))", "a,b,c=map(str,input().split())\na=int(a)\nc=int(c)\nif b=='+':print(a+c)\nelse:print(a-c)", "# \u5165\u529b\nA, op, B = input().split()\n\nA = int(A)\nB = int(B)\n\n# \u51fa\u529b\nif op == '+':\n print((A + B))\nelif op == '-':\n print((A - B))\n\n", "'''\nABC050 A - Addition and Subtraction Easy\nhttps://atcoder.jp/contests/abc050/tasks/abc050_a\n'''\na, op, b = input().split()\na, b = int(a), int(b)\n\nif op == '+':\n ans = a+b\nelif op == '-':\n ans = a-b\nprint(ans)\n", "# A - Addition and Subtraction Easy\n\n# A, op, B \u306e\u5165\u529b\u3092\u53d7\u3051\u53d6\u308a\u3001\u6f14\u7b97\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\n\n\nA, op, B = input().split()\n\nif op == '+':\n print((int(A) + int(B)))\nelif op == '-':\n print((int(A) - int(B)))\n", "A, op, B = input().split()\n\nif op == \"+\":\n print(int(A)+int(B))\nelse:\n print(int(A)-int(B))", "A,op,B = input().split()\nA,B = int(A),int(B)\nprint(A + B if op == \"+\" else A - B)", "s = input()\nprint(eval(s))", "A,op,B = map(str,input().split())\nA = int(A)\nB = int(B)\nif op == '+':\n print(A + B)\nelif op == '-':\n print(A - B)", "a,b,c = input().split()\nif b == \"+\":\n print(int(a)+int(c))\nelse:\n print(int(a)-int(c))"] | {"inputs": ["1 + 2\n", "5 - 7\n"], "outputs": ["3\n", "-2\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 11,252 | |
b72cdbdc6caaedb1dd40f7476065507a | UNKNOWN | Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.
You are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.
-----Constraints-----
- 1 β¦ x β¦ 3{,}000
- x is an integer.
-----Input-----
The input is given from Standard Input in the following format:
x
-----Output-----
Print the answer.
-----Sample Input-----
1000
-----Sample Output-----
ABC
Smeke's current rating is less than 1200, thus the output should be ABC. | ["x = int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "print('ABC' if int(input())<1200 else 'ARC')", "x = int(input())\nif x<1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x = int(input())\n\nif x < 1200 :\n print( \"ABC\" )\nelse:\n print( \"ARC\" )", "print(\"ABC\" if int(input()) < 1200 else \"ARC\")", "x = int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "a = int(input())\n\nprint('ABC') if a < 1200 else print('ARC')", "r = int(input())\n\nprint('ABC' if r < 1200 else 'ARC')", "#\n# abc053 a\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"1000\"\"\"\n output = \"\"\"ABC\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"2000\"\"\"\n output = \"\"\"ARC\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n x = int(input())\n\n if x < 1200:\n print(\"ABC\")\n else:\n print(\"ARC\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "a = int(input())\nif a < 1200:\n print('ABC')\nelse:\n print('ARC')", "if int(input()) < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x=int(input())\nif x<1200:print('ABC')\nelse:print('ARC')", "x = int(input())\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "# A - ABC/ARC\ndef main():\n x = int(input())\n\n if x < 1200:\n print('ABC')\n else:\n print('ARC')\n \n \ndef __starting_point():\n main()\n__starting_point()", "# \u3059\u3081\u3051\u304f\u3093\u306f\u73fe\u5728\u306e\u30ec\u30fc\u30c8\u304c 1200 \u672a\u6e80\u306a\u3089\u3070 AtCoder Beginner Contest (ABC) \u306b\u3001\n# \u305d\u3046\u3067\u306a\u3051\u308c\u3070 AtCoder Regular Contest (ARC) \u306b\u53c2\u52a0\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002 \u3059\u3081\u3051\u304f\u3093\u306e\u73fe\u5728\u306e\u30ec\u30fc\u30c8 x \u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n# \u3059\u3081\u3051\u304f\u3093\u304c\u53c2\u52a0\u3059\u308b\u30b3\u30f3\u30c6\u30b9\u30c8\u304c ABC \u306a\u3089\u3070 ABC \u3068\u3001\u305d\u3046\u3067\u306a\u3051\u308c\u3070 ARC \u3068\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\nx = int(input())\n\nif x < 1200:\n print('ABC')\n\nelse:\n print('ARC')", "x = int(input())\n\nprint('ABC' if x < 1200 else 'ARC')", "S =int(input())\n\nif S < 1200 :\n result = \"ABC\"\nelse:\n result = \"ARC\"\nprint(result)", "print('ABC' if int(input()) < 1200 else 'ARC')", "x = int(input())\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "x=int(input())\nprint(\"ABC\" if x<1200 else \"ARC\")", "x = int(input())\nprint(\"ABC\" if x < 1200 else \"ARC\")", "x = int(input())\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "print(\"ABC\" if int(input())<1200 else \"ARC\")", "x = int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')\n", "r=[\"ABC\",\"ARC\"]\nprint(r[int(input())>=1200])", "x = int(input())\n\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "if int(input())>=1200:\n print('ARC')\n \nelse:\n print('ABC')", "x=int(input())\nif x<1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x = int(input())\n\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x=int(input())\nif x<1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "r = int(input())\nprint('ARC') if r >= 1200 else print('ABC')", "# \u5165\u529b\nx = int(input())\n\n# \u51e6\u7406\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "x = int(input())\nif x<1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x = int(input())\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "# 053_a\nx = int(input())\nif (1 <= x & x <= 3000):\n if x < 1200:\n print('ABC')\n else:\n print('ARC')\n", "x = int(input())\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "# A - ABC/ARC\n\n# x=1200\u672a\u6e80\u306a\u3089\u3070'ABC'\u3092\u3001\u305d\u3046\u3067\u306a\u3051\u308c\u3070'ARC'\u3092\u51fa\u529b\u3059\u308b\n\n\nx = int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')\n", "if int(input()) < 1200:\n print('ABC')\nelse:\n print('ARC')\n", "x = int (input ())\nif x>=1200:\n print ('ARC')\nelse:\n print ('ABC')", "if int(input()) < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x = int(input())\n\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "rate = int(input())\nif rate < 1200:\n print('ABC')\nelse:\n print('ARC')", "a=int(input())\nif a<1200:print(\"ABC\")\nelse:print(\"ARC\")", "print(\"ABC\" if int(input())<1200 else \"ARC\")", "x = int(input())\n\nif x >= 1200:\n print(\"ARC\")\nelse:\n print(\"ABC\")", "x=int(input())\nif x<1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "if int(input())<1200:\n\tprint('ABC')\nelse:\n\tprint(\"ARC\")", "a=int(input())\nif(a<1200):\n print('ABC')\nelse:\n print('ARC')", "x=int(input())\n\nif x>=1200:\n ans=\"ARC\"\nelse:\n ans=\"ABC\"\nprint(ans)\n", "print(\"ABC\" if int(input()) < 1200 else \"ARC\")", "x = int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')\n", "x = int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "print('ABC' if int(input()) < 1200 else 'ARC')", "num = int(input())\nif num < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "# \u30ec\u30fc\u30c8\u3092\u53d6\u5f97\nx = int(input())\n\n# \u30ec\u30fc\u30c8\u306b\u6cbf\u3063\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x = int(input())\n\nif 1200 > x:\n print(\"ABC\")\nelse:\n print(\"ARC\")\n", "# \u5165\u529b\nx = int(input())\n\n# \u51e6\u7406\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "x = int(input())\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "x=int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "# 053a\n\nx = int(input()) # \u30ec\u30fc\u30c8x\u3092\u4ee3\u5165\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')\n", "X = int(input())\n\nif X < 1200:\n print('ABC')\nelse:\n print('ARC')", "x = int(input())\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x = int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "# A - ABC/ARC\n# https://atcoder.jp/contests/abc053/tasks/abc053_a\n\nx = int(input())\n\nresult = 'ARC'\nif x < 1200:\n result = 'ABC'\n\nprint(result)\n", "#53\nx=int(input())\nif x<1200:\n print('ABC')\nelse:\n print('ARC')\n", "X= int(input())\nif X<1200:\n print(\"ABC\")\nelse :\n print(\"ARC\")", "a = int(input())\nif a < 1200:\n print('ABC')\nelse:\n print('ARC')", "x = int(input())\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "print(\"ABC\" if int(input())<1200 else \"ARC\")", "x=int(input())\nif x>=1200:\n print(\"ARC\")\nelse:\n print(\"ABC\")", "x = int(input())\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "if int(input())//1200:\n print(\"ARC\")\nelse:\n print(\"ABC\")\n", "x = int(input())\nif(x >= 1200):\n print(\"ARC\")\nelse:\n print(\"ABC\")", "x = int(input())\nprint('ARC' if x >= 1200 else 'ABC')", "x = int(input())\nprint('ABC' if x < 1200 else 'ARC')", "print((\"ABC\" if int(input()) < 1200 else \"ARC\"))\n", "x = int(input())\nprint(\"ABC\" if x < 1200 else \"ARC\")", "def solve():\n x = int(input())\n if x < 1200:\n print('ABC')\n else:\n print('ARC')\n\n\ndef __starting_point():\n solve()\n__starting_point()", "# \u5165\u529b\nx = int(input())\n\n# x\u304c1200\u672a\u6e80\u306a\u3089ABC\u3001\u305d\u3046\u3067\u306a\u3051\u308c\u3070ARC\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "x = int(input())\n\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")\n", "#\u5165\u529b\nx = int(input())\n\n# \u51fa\u529b\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "# \u30ec\u30fc\u30c8\u306b\u3088\u3063\u3066\u51fa\u529b\u3092\u5909\u66f4\n\nx = int(input())\n\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')", "x = int(input())\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")\n", "# \u3059\u3081\u3051\u304f\u3093\u306f\n# \u73fe\u5728\u306e\u30ec\u30fc\u30c8\u304c 1200\u672a\u6e80\u306a\u3089\u3070 AtCoder Beginner Contest (ABC) \u306b\u3001\n# \u305d\u3046\u3067\u306a\u3051\u308c\u3070 AtCoder Regular Contest (ARC) \u306b\u53c2\u52a0\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\n# \u3059\u3081\u3051\u304f\u3093\u306e\u73fe\u5728\u306e\u30ec\u30fc\u30c8 x\u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n# \u3059\u3081\u3051\u304f\u3093\u304c\u53c2\u52a0\u3059\u308b\u30b3\u30f3\u30c6\u30b9\u30c8\u304c ABC \u306a\u3089\u3070 ABC \u3068\u3001\u305d\u3046\u3067\u306a\u3051\u308c\u3070 ARC \u3068\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# 1 \u2266 x \u2266 3,000\n# x \u306f\u6574\u6570\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 x \u3092\u53d6\u5f97\u3059\u308b\nx = int(input())\n\n# \u30ec\u30fc\u30c8\u3092\u5224\u5b9a\u3057\u3066\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\nresult = \"ret\"\n\nif x < 1200:\n result = \"ABC\"\nelse:\n result = \"ARC\"\n\nprint(result)\n", "x = int(input())\nif x < 1200:\n print('ABC')\nelse:\n print('ARC')\n", "print('ABC' if int(input()) < 1200 else 'ARC')", "# AtCoder abc053 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\nx = int(input())\n\n# \u5224\u5b9a\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")\n", "x = int(input())\nprint(['ABC','ARC'][1200<=x])", "n = int(input())\n\nif (n < 1200):\n print(\"ABC\")\nelse:\n print(\"ARC\")\n\n", "print('ABC' if int(input()) < 1200 else 'ARC')", "s = int(input())\n\nif s < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "print('AARBCC'[int(input())<1200::2])", "x = int(input())\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "print('ABC' if int(input()) < 1200 else 'ARC')", "x = input()\nx = int(x)\nif x < 1200:\n print('ABC')\nelse:\n print(\"ARC\")", "x = int(input())\nprint('ABC' if x < 1200 else 'ARC')", "x = int(input())\n\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "x = input()\nx = int(x)\n\nif x < 1200:\n print(\"ABC\")\nelse:\n print(\"ARC\")", "def main():\n x = int(input())\n print('ARC') if x >= 1200 else print('ABC')\n \n \ndef __starting_point():\n main()\n__starting_point()"] | {"inputs": ["1000\n", "2000\n"], "outputs": ["ABC\n", "ARC\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 10,889 | |
019054178ba33f359df65db2fbc2d25d | UNKNOWN | Snuke is buying a bicycle.
The bicycle of his choice does not come with a bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for each hand.
The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.
Find the minimum total price of two different bells.
-----Constraints-----
- 1 \leq a,b,c \leq 10000
- a, b and c are integers.
-----Input-----
Input is given from Standard Input in the following format:
a b c
-----Output-----
Print the minimum total price of two different bells.
-----Sample Input-----
700 600 780
-----Sample Output-----
1300
- Buying a 700-yen bell and a 600-yen bell costs 1300 yen.
- Buying a 700-yen bell and a 780-yen bell costs 1480 yen.
- Buying a 600-yen bell and a 780-yen bell costs 1380 yen.
The minimum among these is 1300 yen. | ["# A - ringring\n# https://atcoder.jp/contests/abc066/tasks/abc066_a\n\na = list(map(int, input().split()))\n\na.sort()\nprint((a[0] + a[1]))\n", "a, b, c = map(int, input().split())\n\nprint(min(a+b, b+c, c+a))", "# A - ringring\ndef main():\n abc = list(map(int, input().split()))\n abc.sort()\n cnt = 0\n\n for _ in range(2):\n cnt += abc.pop(0)\n else:\n print(cnt)\n\n\nif __name__ == \"__main__\":\n main()", "l = list(map(int, input().split()))\n\n\nl.sort()\n\nprint(l[0] + l[1])", "a,b,c = sorted(map(int,input().split()))\nprint(a+b)", "data = list(map(int,input().split()))\ndata.sort()\nprint(data[0]+data[1])", "a,b,c = list(map(int,input().split()))\n\nprint((min(a+b,a+c,b+c)))\n", "a, b, c = map(int, input().split())\n\nprint(min(a + b, b + c, c + a))", "a,b,c=(int(x) for x in input().split())\n\nX=[a,b,c]\nX.sort()\n\nY=X[0]+X[1]\n\nprint(Y)", "# 066a\n\ndef atc_066a(abc: str) -> int:\n abc_int = [int(ai) for ai in abc.split(\" \")]\n abc_int.sort()\n return abc_int[0] + abc_int[1]\n\nabc = input()\nprint(atc_066a(abc))", "\na,b,c=list(map(int,input().split()))\n\nprint((min(a+b,b+c,a+c)))\n\n", "'''\n\u554f\u984c\uff1a\n snuke \u541b\u306f\u81ea\u8ee2\u8eca\u3092\u8cb7\u3044\u306b\u6765\u307e\u3057\u305f\u3002\n snuke \u541b\u306f\u3059\u3067\u306b\u8cb7\u3046\u81ea\u8ee2\u8eca\u3092\u6c7a\u3081\u305f\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u81ea\u8ee2\u8eca\u306b\u306f\u30d9\u30eb\u304c\u4ed8\u3044\u3066\u3044\u306a\u3044\u305f\u3081\u3001 \u81ea\u8ee2\u8eca\u3068\u306f\u5225\u306b\u30d9\u30eb\u3082\u8cb7\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\n snuke \u541b\u306f\u5b89\u5168\u610f\u8b58\u304c\u9ad8\u3044\u306e\u3067\u3001\u30d9\u30eb\u3092\u3069\u3061\u3089\u306e\u624b\u3067\u3082\u9cf4\u3089\u305b\u308b\u3088\u3046\u3001\n \u4e21\u65b9\u306e\u30cf\u30f3\u30c9\u30eb\u306b 1 \u3064\u305a\u3064 \u4ed8\u3051\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\n\n \u304a\u5e97\u306b\u3042\u308b\u30d9\u30eb\u306f 3 \u7a2e\u985e\u3067\u3001\u305d\u308c\u305e\u308c a\u5186\u3001b\u5186\u3001c\u5186\u3067\u3059\u3002\n \u3053\u306e 3\u3064\u306e\u3046\u3061\u3001\u7570\u306a\u308b 2\u3064\u306e\u30d9\u30eb\u3092\u9078\u3093\u3067\u8cb7\u3046\u3068\u304d\u306e\u3001\u5024\u6bb5\u306e\u5408\u8a08\u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u3066\u4e0b\u3055\u3044\u3002\n'''\n\n'''\n\u5236\u7d04\uff1a\n 1 \u2264 a,b,c \u2264 10000\n a,b,c\u306f\u6574\u6570\n'''\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 a, b, c \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\na, b, c = list(map(int, input().split()))\n\nresult = [a + b, b + c, a + c] # \u7d50\u679c\u51fa\u529b\u7528\u30ea\u30b9\u30c8\n\nprint((min(result)))\n", "bell=[a, b, c]=list(map(int, input().split(\" \")))\ncandidate=sorted(bell)\nprint(candidate[0]+candidate[1])", "cost = list(map(int, input().split()))\nprint(sum(sorted(cost)[:2]))", "a, b, c = list(map(int,input().split()))\n\nbell_price = [a, b, c]\n\nprint((sum(bell_price) - max(bell_price)))\n", "li=a,b,c=list(map(int,input().split()))\nprint(sorted(li)[0]+sorted(li)[1])", "a,b,c = map(int,input().split())\n# \u30d9\u30eb\u306e\u4fa1\u683c\u3092\u30ea\u30b9\u30c8\u5316\nbell_price = (a,b,c)\n# \u30ea\u30b9\u30c8\u306e\u5408\u8a08\u5024\u304b\u3089\u6700\u9ad8\u5024\u306e\u30d9\u30eb\u306e\u5024\u6bb5\u3092\u9664\u5916\nprint(sum(bell_price)-max(bell_price))", "a, b, c, = list(map(int, input().split()))\n\nring=[]\nring.append(a)\nring.append(b)\nring.append(c)\n\nring.sort()\nprint((ring[0] + ring[1]))\n", "lst = input().split()\n\nfor i in range(3):\n lst[i] = int(lst[i])\n\nlst.sort()\nprint(lst[0] + lst[1])", "a,b,c=map(int,input().split())\n\nprint(a+b+c-max(a,b,c))", "# 066a\n\ndef atc_066a(abc: str) -> int:\n abc_int = [int(ai) for ai in abc.split(\" \")]\n abc_int.sort()\n return abc_int[0] + abc_int[1]\n\nabc = input()\nprint((atc_066a(abc)))\n", "a=list(map(int,input().split()))\na.sort()\nprint(sum(a[:2]))", "a, b, c = map(int,input().split())\n\nbell_list = []\nbell_list.append(a + b)\nbell_list.append(b + c)\nbell_list.append(a + c)\n\nprint(min(bell_list))", "a,b,c = map(int,input().split())\nbell = [a + b, a + c, b + c]\nprint(min(bell))", "a, b, c = map(int, input().split())\nmin_price = min(a + b, b + c, a + c)\nprint(min_price)", "a=list(map(int,input().split()))\nprint((sum(a)-max(a)))\n", "a, b, c = map(int,input().split())\n\nprint(min(a + b, b + c, c + a))", "bell=[a, b, c]=list(map(int, input().split(\" \")))\n\nprint(sorted(bell).pop(0)\\\n +sorted(bell).pop(1))", "a, b, c = map(int, input().split())\nprint(min(a + b, b + c, a + c))", "a,b,c = map(int,input().split())\nprint(min(a+b,a+c,b+c))", "l = sorted(list(map(int, input().split())))\nprint(sum(l[:2]))", "a,b,c=map(int,input().split())\nx=[a,b,c]\nprint(sum(x)-max(x))", "print(sum(sorted(map(int, input().split()))[:2]))", "a,b,c=map(int,input().split())\ns=[]\ns.append(a+b)\ns.append(a+c)\ns.append(b+c)\n\n\nprint(min(s))", "a,b,c=map(int,input().split())\nx=min(a,b,c)\nz=max(a,b,c)\ny=a+b+c-x-z\nprint(x+y)", "A = list(map(int, input().split()))\n\nprint(sum(sorted(A)[:2]))", "a,b,c = list(map(int,input().split()))\n\nprice = min(a + b,b + c,a + c)\nprint(price)\n", "\n\na, b, c = map(int, input().split())\n\n\n\nprint(min(a+b, b+c, a+c))", "a,b,c = map(int,input().split())\n\nprint(min(a+b,a+c,b+c))", "a, b, c = map(int, input().split())\n\ndef answer(a: int, b: int, c: int) -> int:\n return min(a + b, a + c, b + c)\n\nprint(answer(a, b, c))", "a,b,c = map(int,input().split())\n\nprint(min(a+b,a+c,b+c))", "a, b, c = map(int, input().split())\nprint(min(a + b, a + c, c + b))", "S_list = list(map(int,input().split()))\nsum_bell=sum(S_list)\nhantei = list()\nfor i in S_list:\n hantei.append(sum_bell - i)\nprint(min(hantei))", "kingaku = list(map(int, input().split()))\nkingaku.sort()\n\nprint((kingaku[0] + kingaku[1]))\n\n", "a, b, c = map(int,input().split())\n\nmax_bell = max(a,b,c)\nprint(a + b + c - max_bell)", "# snuke \u541b\u306f\u81ea\u8ee2\u8eca\u3092\u8cb7\u3044\u306b\u6765\u307e\u3057\u305f\u3002 snuke \u541b\u306f\u3059\u3067\u306b\u8cb7\u3046\u81ea\u8ee2\u8eca\u3092\u6c7a\u3081\u305f\u306e\u3067\u3059\u304c\u3001\u305d\u306e\u81ea\u8ee2\u8eca\u306b\u306f\u30d9\u30eb\u304c\u4ed8\u3044\u3066\u3044\u306a\u3044\u305f\u3081\u3001\n# \u81ea\u8ee2\u8eca\u3068\u306f\u5225\u306b\u30d9\u30eb\u3082\u8cb7\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 snuke \u541b\u306f\u5b89\u5168\u610f\u8b58\u304c\u9ad8\u3044\u306e\u3067\u3001\u30d9\u30eb\u3092\u3069\u3061\u3089\u306e\u624b\u3067\u3082\u9cf4\u3089\u305b\u308b\u3088\u3046\u3001\u4e21\u65b9\u306e\u30cf\u30f3\u30c9\u30eb\u306b 1 \u3064\u305a\u3064 \u4ed8\u3051\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\u3002\n# \u304a\u5e97\u306b\u3042\u308b\u30d9\u30eb\u306f 3 \u7a2e\u985e\u3067\u3001\u305d\u308c\u305e\u308c a \u5186\u3001 b \u5186\u3001 c \u5186\u3067\u3059\u3002 \u3053\u306e 3 \u3064\u306e\u3046\u3061\u3001\u7570\u306a\u308b 2 \u3064\u306e\u30d9\u30eb\u3092\u9078\u3093\u3067\u8cb7\u3046\u3068\u304d\u306e\u3001\u5024\u6bb5\u306e\u5408\u8a08\u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u3066\u4e0b\u3055\u3044\u3002\n\na,b,c = map(int,input().split())\n\nif a >= b and a >= c :\n print(b + c)\nelif b >= a and b >= c:\n print(a + c)\nelif c >= a and c >= b:\n print(a + b)", "a, b, c = map(int, input().split())\n\nplan1 = a + b\nplan2 = b + c\nplan3 = c + a\n\nprint(min(plan1, plan2, plan3))", "l=sorted(map(int,input().split()))\nprint(l[0]+l[1])", "\n# 066a\n\ndef atc_066a(abc: str) -> int:\n abc_int = [int(ai) for ai in abc.split(\" \")]\n abc_int.sort()\n return abc_int[0] + abc_int[1]\n\nabc = input()\nprint(atc_066a(abc))", "a, b, c = list(map(int,input().split()))\nbell = [a, b, c]\nbell.sort()\nanswer = bell[0] + bell[1]\nprint(answer)\n", "# A - ringring\n\n# a b c\na, b, c = list(map(int, input().split()))\nmy_list = [a, b, c]\nmy_list.sort()\nprint((my_list[0] + my_list[1]))\n", "a, b, c = map(int, input().split())\ntotal_price = min(a+b, a+c, b+c)\nprint(total_price)", "a,b,c = map(int,input().split())\nprint(min(a+b, b+c, a+c))", "a, b, c = sorted([int(n) for n in input().split()])\nprint(a + b)", "m=list(map(int,input().split()))\nprint(sum(m)-max(m))", "def iroha():\n lists = list(map(int, input().split()))\n lists.sort()\n print((lists[0]+lists[1]))\n\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "n=sorted(list(map(int, input().split())))\nprint((n[0]+n[1]))\n", "D=list(map(int,input().split()))\nD.sort()\nprint(D[0]+D[1])", "#066A\n# 1.\u5024\u3092\u6b63\u3057\u304f\u53d6\u5f97\na, b, c = (int(x) for x in input().split())\n\n# 2.\u6b63\u3057\u304f\u51e6\u7406\ngokei1 = a + b\ngokei2 = a + c\ngokei3 = b + c\n\nresalt=[gokei1,gokei2,gokei3]\n\nprint(min(resalt))", "a, b, c = list(map(int, input().split()))\nprint((min(a + b, a + c, c + b)))\n", "with open(0) as f:\n a, b, c = map(int, f.read().split())\nprint(a+b+c-max(a,b,c))", "a, b, c = map(int, input().split())\nx = a + b\ny = b + c\nz = c + a\nif x <= y and x <= z:\n print(x)\nelif y <= x and y <= z:\n print(y)\nelse:\n print(z)", "a = list(map(int,input().split()))\nprint(sum(a)-max(a))", "# \u7570\u306a\u308b\u4e8c\u3064\u306e\u7d44\u307f\u5408\u308f\u305b\u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u308b\n\na, b, c = list(map(int, input().split()))\n\nvales = [a + b, a + c, b + c]\n\nprint((min(vales)))\n", "a, b, c = map(int, input().split())\nprint(min(a + b, a + c, b + c))", "bells = sorted(list(map(int, input().split())))\nprint(bells[0]+bells[1])", "p = sorted(map(int, input().split()))\n\nprint(p[0]+p[1])", "bell = sorted(list(map(int, input().split())))\n\nprint((bell[0] + bell[1]))", "a = list(map(int, input().split()))\na.sort()\nprint(a[0] + a[1])", "A = list(map(int, input().split()))\nA = sorted(A)\nprint((A[0] + A[1]))\n", "'''\nABC066 A - ringring\nhttps://atcoder.jp/contests/abc066/tasks/abc066_a\n'''\nnums = list(map(int, input().split()))\nans = sum(nums) - max(nums)\nprint(ans)\n", "a = list(map(int,input().split()))\nprint(sum(a)-max(a))", "a = list(map(int, input().split()))\nprint(sum(a)-max(a))", "a, b, c = map(int, input().split())\nlist01 = [a + b, b + c, a + c]\nprint(min(list01))", "a=sorted(map(int,input().split(\" \")))\nprint(a[0]+a[1])", "a, b, c = [int(i) for i in input().split()]\n\nprint((sum([a, b, c]) - max(a, b, c)))\n", "a,b,c = map(int,input().split())\n\nA = a + b\nB = b + c\nC = c + a\n\nprint(min(A,B,C))", "#ABC066\na = sorted(list(map(int,input().split())))\nprint(a[0]+a[1])", "a = list(map(int,input().split()))\na = sorted(a)\nprint((a[0]+a[1]))\n", "l = list(map(int, input().split()))\n\nans = sum(l) - max(l)\nprint(ans)\n", "a,b,c = sorted(map(int, input().split()))\n\nprint(a + b)", "a,b,c=map(int,input().split())\nprint(a+b+c-max(a,b,c))", "with open(0) as f:\n a, b, c = map(int, f.read().split())\nprint(a+b+c-max(a,b,c))", "a, b, c = map(int, input().split())\n\nprices = [a + b, a + c, b + c]\n\nprint(min(prices))", "a = list(map(int,input().split()))\na.sort()\n\nprint(a[0]+a[1])", "a = [int(x) for x in input().split()]\nprint(sum(a) - max(a))", "a, b, c = map(int, input().split())\nprint(min(a + b, b + c, a + c))", "with open(0) as f:\n a, b, c = map(int, f.read().split())\nprint(a+b+c-max(a,b,c))", "a,b,c = map(int,input().split())\nprint(min(a+b,b+c,a+c))", "a = list(map(int,input().split()))\nprint(sum(a)-max(a))", "a,b,c=map(int, input().split())\n\nprint(min(a+b,b+c,c+a))", "a, b, c=map(int, input().split())\nprint(a+b+c-max(a, b, c))", "price = list(map(int, input().split()))\nprice.sort()\n\nprint((price[0]+price[1]))\n", "a,b,c = map(int, input().split())\n\nkei = a + b + c\n\nif a >= b and a >= c:\n kei -= a\n print(kei)\n\nelif b >= a and b >= c:\n kei -= b\n print(kei)\nelse:\n kei -= c\n print(kei)", "abc = list(map(int, input().split()))\nabc.sort()\nprint((abc[0] + abc[1]))\n", "a, b, c = map(int, input().split())\n\nsums = [a + b, b + c, c + a]\n\nprint(min(sums))", "# \u6570\u5024\u306e\u53d6\u5f97\np_list = list(map(int,input().split()))\n\n# \u5024\u6bb5\u306e\u5b89\u30442\u3064\u3092\u52a0\u7b97\u3057\u51fa\u529b\np_list = sorted(p_list)\npare = p_list[0] + p_list[1]\nprint(pare)", "bell_cost = list(map(int, input().split()))\nbell_cost.sort()\nminimum_cost = bell_cost[0] + bell_cost[1]\nprint(minimum_cost)"] | {"inputs": ["700 600 780\n", "10000 10000 10000\n"], "outputs": ["1300\n", "20000\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 12,405 | |
614ce4c391dff612a14b1de94273f921 | UNKNOWN | You are given a image with a height of H pixels and a width of W pixels.
Each pixel is represented by a lowercase English letter.
The pixel at the i-th row from the top and j-th column from the left is a_{ij}.
Put a box around this image and output the result. The box should consist of # and have a thickness of 1.
-----Constraints-----
- 1 β€ H, W β€ 100
- a_{ij} is a lowercase English letter.
-----Input-----
Input is given from Standard Input in the following format:
H W
a_{11} ... a_{1W}
:
a_{H1} ... a_{HW}
-----Output-----
Print the image surrounded by a box that consists of # and has a thickness of 1.
-----Sample Input-----
2 3
abc
arc
-----Sample Output-----
#####
#abc#
#arc#
#####
| ["H, W = map(int, input().split())\ns = '#' * (W + 2)\ndata = []\ndata.append(s)\nfor i in range(H):\n data.append('#' + str(input()) + '#')\ndata.append(s)\n \nfor i in range(H + 2):\n print(data[i])", "h, w = map(int, input().split())\na = [input() for _ in range(h)]\nfor i in range(h+2):\n if i == 0 or i == h+1:\n print(\"#\"*(w+2))\n else:\n print(\"#\" + a[i-1] + \"#\")", "#!/usr/bin/env python3\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools\ndef main():\n H, W = list(map(int, input().split()))\n print((\"#\"*(W+2)))\n for _ in range(H):\n print((\"#{}#\".format(input())))\n print((\"#\"*(W+2)))\n\ndef test():\n import doctest\n doctest.testmod()\n\ndef __starting_point():\n #test()\n main()\n\n__starting_point()", "h, w = map(int, input().split())\nfor i in range(h+1):\n if i == 0 or i == h:\n print(\"#\"*(w +2))\n if i == h:\n return\n print(\"#\", end = \"\")\n print(input(), end = \"\")\n print(\"#\")\n", "h,w = map(int,input().split())\nl=[]\n[l.append(input()) for _ in range(h)]\n\nprint(\"#\"*(w + 2))\nfor s in l:\n print(\"#\",s,\"#\",sep='')\n\nprint(\"#\"*(w + 2))", "h, w = map(int, input().split())\nprint('#'*-~-~w)\nfor _ in [0]*h:\n print('#'+input()+'#')\nprint('#'*-~-~w)", "h, w = list(map(int, input().split()))\n\nprint(('#' * (w+2)))\nfor i in range(h):\n data = list(map(str, input().split()))\n data2 = ['#'] + data + ['#']\n print((''.join(data2)))\n\n\nprint(('#' * (w + 2)))\n", "h,w = map(int, input().split())\na = list(list(input().split()) for _ in range(h))\nprint(\"#\"*(int(w)+2))\nfor i in range(h):\n print(\"#\",*a[i],\"#\",sep=\"\")\nprint(\"#\"*(int(w)+2))", "H, W = map(int, input().split())\nprint(\"#\"*(W+2))\nfor i in range(H):\n a = input()\n print(\"#\" + a + \"#\")\nprint(\"#\"*(W+2))", "h,w=map(int,input().split())\na=[list(input()) for i in range(h)]\n\nd=[['#']*(w+2) for i in range(h+2)]\nfor i in range(h):\n for j in range(w):\n d[i+1][j+1]=a[i][j]\nfor i in range(h+2):\n print(*d[i],sep='')", "H, W = map(int, input().split())\nL = ['#' + input() + '#' for _ in range(H)]\nL = ['#' * (W + 2)] + L + ['#' * (W + 2)]\n[print(i) for i in L]", "n,m=map(int,input().split())\nprint(*['#'*-~-~m]+['#'+input()+'#' for _ in range(n)]+['#'*-~-~m],sep='\\n')", "h, w = map(int, input().split())\nprint(\"#\"*(w+2))\nfor i in range(h):\n a = str(input())\n a = \"#\" + a + \"#\"\n print(a)\nprint(\"#\"*(w+2))", "h, w = list(map(int, input().split()))\na = [input() for x in range(h)]\nprint(('#' * (w + 2)))\nfor s in a:\n print(('#' + s + '#'))\nprint(('#' * (w + 2)))\n", "h, w = list(map(int, input().split()))\na = [input() for _ in range(h)]\nans = ['#'*(w+2)]\n# print(ans)\nfor i in range(h):\n ans.append('#' + a[i] + '#')\n\nans.append('#'*(w+2))\nfor i in range(h+2):\n print((ans[i]))\n", "H,W=list(map(int,input().split()))\na=[input() for _ in range(H)]\nfor i in range(0,H):\n a[i]='#'+a[i]+'#'\n\nprint(('#'*(W+2)))\nfor i in range(H):\n print((a[i]))\nprint(('#'*(W+2)))\n", "# https://atcoder.jp/contests/abc152/tasks/abc152_c\n\nh, w = list(map(int, input().split()))\n\nrow = '#' * (w + 2)\n\nprint(row)\nfor _ in range(h):\n print(('#' + input() + '#'))\n\nprint(row)\n", "h,w = map(int,input().split())\ns = []\ns.append(\"#\"*(w+2))\nfor i in range(h):\n t = input()\n t = \"#\" + t + \"#\"\n s.append(t)\ns.append(\"#\"*(w+2))\nfor ss in s:\n print(\"\".join(ss))", "h,w = map(int,input().split())\n[print(\"#\",end=\"\") for j in range(w+2)]\nprint()\nfor i in range(h):\n print(\"#\" + input() + \"#\")\n[print(\"#\",end=\"\") for j in range(w+2)]", "from typing import List\n\n\ndef answer(h: int, w: int, a: List[str]) -> List[str]:\n top_bottom_line = '#' * (w + 2)\n\n result = [top_bottom_line]\n for line in a:\n result.append(f'#{line}#')\n result.append(top_bottom_line)\n\n return result\n\n\ndef main():\n h, w = list(map(int, input().split()))\n a = [input() for _ in range(h)]\n for i in answer(h, w, a):\n print(i)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "h,w = map(int,input().split())\nli = [list(input().split()) for i in range(h)]\n#\u6a2a\u6cb3\nfor i in range(len(li)):\n st = li[i][0]\n li[i] = '#'+st+'#'\n#\u4e0a\u5074\nlis = '#'*(w+2)\nli.append(lis)\nli.insert(0,lis)\nfor i in li:\n print(i)", "h, w = map(int, input().split())\na = [[]]\nprint(\"#\"*(w+2))\nfor _ in range(h):\n print(\"#\", input().strip(),\"#\",sep=\"\")\nprint(\"#\"*(w+2))\n", "H, W = list(map(int, input().split()))\nans = []\nfor _ in range(H):\n a = input()\n ans.append(\"#\" + a + \"#\")\n\nprint((\"#\" * (W + 2)))\nfor i in range(H):\n print((ans[i]))\nprint((\"#\" * (W + 2)))\n", "h,w=map(int,input().split())\nprint('#'*(w+2))\nfor i in range(h): \n print('#'+input()+'#')\nprint('#'*(w+2))", "H, W = [int(x) for x in input().split()]\npic = [list(input()) for _ in range(H)]\nans = [['#' for i in range(W+2)] for j in range(H+2)]\nfor i in range(H):\n for j in range(W):\n ans[i+1][j+1] = pic[i][j]\nlow = ''\nfor i in range(H+2):\n for j in range(W+2):\n low += ans[i][j]\n print(low)\n low = ''", "h, w = map(int, input().split())\np = [input() for _ in range(h)]\n\nprint('#' * (w + 2))\nfor s in p:\n print('#' + s + '#')\nprint('#' * (w + 2))", "h, w = map(int,input().split())\n\nprint(\"#\" * (w + 2))\nfor i in range(h):\n print(\"#\" + input() + \"#\")\nprint(\"#\" * (w + 2))", "n,m=map(int,input().split())\nprint(*['#'*(m+2)]+['#'+input()+'#' for _ in range(n)]+['#'*(m+2)],sep='\\n')", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n strings=[]\n h,w = map(int,input().split())\n strings=[input().rstrip() for _ in range(h)]\n output=\"\"\n\n for i in range(h+2):\n if i==0 or i==h+1:\n igeta=\"#\"*(w+2)\n print(\"{}\".format(igeta))\n else:\n output=\"#\"+strings[i-1]+\"#\"\n print(output)\n\ndef __starting_point():\n main()\n__starting_point()", "h,w= map(int,input().split())\na = [input() for _ in range(h)]\ns = ''\nfor i in range(w+2):\n s+='#'\nprint(s)\nfor i in a:\n t = list(i)\n t.insert(0,'#')\n t.append('#')\n print(''.join(t))\nprint(s)", "H, W = [int(x) for x in input().split()]\n\nfor i in range(H):\n if i == 0:\n print((''.join(['#'] * (W + 2))))\n\n print(('#' + input() + '#'))\n\nprint((''.join(['#'] * (W + 2))))\n", "h, w = list(map(int, input().split()))\npixel = [[] for i in range(h+2)]\nfor i in range(h+2):\n if i == 0:\n pixel[i].append('#'*(w+2))\n elif i == h+1:\n pixel[i].append('#'*(w+2))\n else :\n pixel[i].append('#')\n s = input()\n pixel[i].append(s)\n pixel[i].append('#')\nfor i in range(h+2):\n print((\"\".join(pixel[i])))\n\n", "import sys\n\nH, W = map(int, sys.stdin.readline().split())\nprint(\"#\" * (W + 2))\nfor _ in range(H):\n s = sys.stdin.readline().strip()\n print(\"#\" + s + \"#\")\nprint(\"#\" * (W + 2))", "h,w = map(int,input().split())\nfor i in range(w+1):\n print(\"#\",end = \"\")\nprint(\"#\")\nfor i in range(h):\n print(\"#\"+input()+\"#\")\nfor i in range(w+1):\n print(\"#\",end = \"\")\nprint(\"#\")", "h,w = map(int, input().split())\nprint(\"#\" * (w + 2))\nfor i in range(h):\n s = input()\n print(\"#\" + s + \"#\")\n \nprint(\"#\" * (w + 2))", "h,w=map(int,input().split())\nhuta=['#' for _ in range(w+2)]\nhuta=''.join(huta)\nprint(huta)\nfor _ in range(h):\n a=input()\n print('#{}#'.format(a))\nprint(huta)", "h, w = list(map(int, input().split()))\na = [input() for i in range(h)]\nprint((\"#\" * (w + 2)))\nfor i in a:\n print((\"#\" + i + \"#\"))\nprint((\"#\" * (w + 2)))\n", "H,W = map(int,input().split())\nls = [[\"#\" for _ in range(W+2)]]\n\nfor _ in range(H):\n A = [\"#\"] + list(input()) + [\"#\"]\n ls.append(A)\n \nls.append([\"#\" for _ in range(W+2)])\n\nfor i in range(H+2):\n print(\"\".join(ls[i]))", "h,w=map(int,input().split())\n \nprint(\"#\"*(w+2))\n \nfor i in range(h):\n num=input()\n print(\"#\"+num+\"#\")\n \nprint(\"#\"*(w+2))", "def inpl(): return list(map(int, input().split()))\nH, W = inpl()\nans = [[\"#\"]*(W+2) for _ in range(H+2)]\n\nfor h in range(H):\n A = input()\n for w in range(W):\n ans[h+1][w+1] = A[w]\n\nprint(*[\"\".join(a) for a in ans], sep=\"\\n\")", "H, W = list(map(int, input().split()))\nres = []\n\nfor i in range(H+2):\n if i == 0 or i == H+1:\n l = '#'*(W+2)\n res.append(l)\n else:\n a = input()\n a = '#' + a + '#'\n res.append(a)\n\nfor i in res:\n print(i)\n", "h,w = map(int,input().split())\nprint(\"#\"*(w+2))\nfor _ in range(h):\n print(\"#\" + input() + \"#\")\nprint(\"#\"*(w+2))", "with open(0) as f:\n H, W, *a = f.read().split()\nW = int(W)\na.insert(0,'#'*W)\na.append('#'*W)\nfor x in a:\n print(('#' + x.rstrip('\\n') + '#'))\n", "h, w = map(int, input().split())\nprint(\"#\" * w + \"#\" * 2)\nfor _ in range(h):\n line = \"#\" + input() + \"#\"\n print(line)\n\nprint(\"#\" * w + \"#\" * 2)", "h, w = map(int, input().split())\nwords = [0]*(h+2)\nfor i in range(1, h+1, 1):\n s = input()\n words[i] = s\n\nfor j in range(len(words)):\n if words[j] == 0:\n words[j] = '#'*(w+2)\n else:\n words[j] = '#'+words[j]+'#'\n\nfor ans in words:\n print(ans)", "h, w = map(int, input().split())\nprint(\"#\" * (w + 2))\nfor _ in range(h):\n print(\"#\" + input() + \"#\")\nprint(\"#\" * (w + 2))", "#ABC062 B:PictureFrame\n\nH,W = map(int, input().split())\npic = []\nfor _ in range(H):\n a = input()\n pic.append(a)\nprint('#'*(W+2))\nfor i in range(H):\n print('#' + pic[i] + '#')\nprint('#'*(W+2))", "h, w = map(int, input().split())\ngrid = [[\"#\"] * (w + 2) for _ in range(h + 2)]\n\nfor i in range(h):\n grid[i + 1] = [\"#\"] + list(map(str, input().rstrip())) + [\"#\"]\n\nfor i in range(h + 2):\n print(\"\".join(grid[i]))", "h,w = list(map(int, input().split()))\nprint('#' * (w + 2))\nfor _ in range(h):\n print('#' + input() + \"#\")\nprint('#' * (w + 2))", "H,W=map(int,input().split())\nanslist = [[\"#\" for i in range(W+2)]for j in range(H+2)]\nfor i in range(H):\n a=input()\n for j in range(W):\n anslist[i+1][j+1]=a[j]\nfor i in range(H+2):\n for j in range(W+2):\n print(anslist[i][j],end=\"\")\n print()", "h, w = map(int,input().split())\na = [input() for _ in range(h)]\nprint(\"#\"*(w+2))\nfor i in range(h):\n print(\"#\" + a[i] + \"#\")\nprint(\"#\"*(w+2))", "HW = input().split()\n\nH = int(HW[0])\nW = int(HW[1])\n\nlst = []\n\nfor i in range(H):\n lst.append('#' + input() + '#')\n\nprint('#' * (W+2))\n\nfor s in lst:\n print(s)\n\nprint('#' * (W+2))", "H, W = map(int, input().split())\n\n\nframe = [['#' for _ in range(W+2)] for _ in range(H+2)]\n\nmat = [['#' for _ in range(W)] for _ in range(H)]\nfor i in range(H):\n line = input()\n for j in range(W):\n mat[i][j] = line[j]\n\nfor i, row in enumerate(mat):\n for j, char in enumerate(row):\n frame[i+1][j+1] = char\n\nfor i in frame:\n for j in i:\n print(j, end=\"\")\n print()\n", "h,w=map(int, input().split())\n\nprint(\"#\"*(w+2))\nfor i in range(h):\n print(\"#{}#\".format(input()))\nprint(\"#\"*(w+2))", "h,w = map(int,input().split())\n\nprint('#'*(w+2))\nfor i in range (h):\n print('#' + input() + '#')\nprint('#'*(w+2))", "H, W = map(int, input().split())\nprint(\"#\"* (W + 2) )\nfor i in range(H):\n print(\"#\" + input() + \"#\")\nprint(\"#\"* (W + 2) )", "h,w = list(map(int, input().split()))\nprint((\"#\"*(w+2)))\nfor i in range(h):\n s = input()\n print((\"#\" + s + \"#\"))\nprint((\"#\"*(w+2)))\n", "H,W=map(int,input().split())\na=[\"\" for i in range(H)]\nfor i in range(H):\n a[i]=list(str(input()))\n\nfor s in range(-1,H+1):\n for t in range(-1,W+1): \n if s==-1 or s==H:\n print(\"#\"*(W+2))\n break\n else:\n if t==-1:\n print(\"#\",end=\"\")\n elif t==W:\n print(\"#\")\n else:\n print(a[s][t],end=\"\")", "h,w = map(int,input().split())\nprint(\"#\"*(w+2))\nfor i in range(h):\n print(\"#\"+input()+\"#\")\nprint(\"#\"*(w+2))", "a,b=map(int,input().split())\ns=[]\nfor i in range(a):\n s.append(input())\nprint(\"#\"*(b+2))\nfor i in range(a):\n print(\"#\",end=\"\")\n print(s[i],end=\"\")\n print(\"#\")\nprint(\"#\"*(b+2))", "N, W = list(map(int, input().split()))\nl = [input() for _ in range(N)]\n\nprint(('#'*(W+2)))\nfor i in l:\n print(('#' + i + '#'))\nprint(('#'*(W+2)))\n", "H,W = map(int, input().split())\nH += 2\nW += 2\nfor i in range(H):\n\tif i == 0 or i == H-1:\n\t\tout = '#'*W\n\telse:\n\t\ta = input()\n\t\tout = '#{}#'.format(a)\n\tprint(out)", "H, W = map(int, input().split())\nprint('#' * (W + 2) ) # head\nfor _ in range(H):\n print('#', input(), '#', sep='')\n\nprint('#' * (W + 2) ) # tail", "h, w = map(int, input().split())\na_l = [ ['#'] + list(map(str, input().split())) + ['#'] for i in range(h) ]\n\nprint(''.join(['#']*(w+2)))\nfor a in a_l:\n print(''.join(a))\nprint(''.join(['#']*(w+2)))", "from collections import Counter,defaultdict,deque\nfrom heapq import heappop,heappush\nfrom bisect import bisect_left,bisect_right \nimport sys,math,itertools,fractions\nsys.setrecursionlimit(10**8)\nmod = 10**9+7\nINF = float('inf')\ndef inp(): return int(sys.stdin.readline())\ndef inpl(): return list(map(int, sys.stdin.readline().split()))\n\nh,w = inpl()\ns = [input() for _ in range(h)]\nres = []\nfor i in range(h+2):\n if i == 0 or i == h+1:\n res.append('#' * (w+2))\n else:\n res.append('#' + s[i-1] + '#')\nfor x in res:\n print(x)", "h, w = map(int, input().split())\na = ['#' * (w + 2)]\nfor i in range(h):\n a.append('#' + input() + '#')\na += ['#' * (w + 2)]\n\nfor i in range(h + 2):\n print(a[i])", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\nINF = float('inf')\nMOD = 10**9 + 7\n#MOD = 998244353\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lintdec(): return list(map(lambda x:int(x) - 1, input().split()))\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nH, W = lint()\n\nans = ['#' * (W + 2)]\nfor _ in range(H):\n ans.append('#' + input() + '#')\nans.append('#' * (W + 2))\n\nprint('\\n'.join(ans))", "h, w = list(map(int, input().split()))\nprint(('#'*(w + 2)))\nfor _ in range(h):\n print(('#' + input() + '#'))\nprint(('#'*(w + 2)))\n", "with open(0) as f:\n H, W, *a = f.read().split()\nW = int(W)\na.insert(0,'#'*W)\na.append('#'*W)\nfor x in a:\n print(('#' + x.rstrip('\\n') + '#'))\n", "h,w=map(int, input().split())\nprint(\"#\"*(w+2))\n\nfor i in range(h):\n s=input()\n print(\"#\"+s+\"#\")\n\nprint(\"#\"*(w+2))", "def main():\n h,w= list(map(int, input().split()))\n a = []\n for i in range(h):\n a.append(input())\n cnt = len(a[0])+2\n print((\"#\" * cnt))\n for _ in a:\n print(f'#{_}#')\n print((\"#\" * cnt))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "h,w=map(int,input().split())\n\nprint(\"#\"*(w+2))\n\nfor i in range(h):\n num=input()\n print(\"#\"+num+\"#\")\n \nprint(\"#\"*(w+2))", "h,w=map(int,input().split())\ns=[\"\"]*h\nfor i in range(h) :\n s[i]=input()\nprint(\"#\"*(w+2))\nfor i in range(h) :\n print(\"#\"+s[i]+\"#\")\nprint(\"#\"*(w+2))", "h,w = map(int,input().split())\na = []\nfor _ in range(h):a.append(input())\nfor _ in range(w + 2):print(\"#\",end=\"\")\nprint()\nfor i in range(h):\n print(\"#\",end=\"\")\n print(a[i],end=\"\")\n print(\"#\")\nfor _ in range(w + 2):print(\"#\",end=\"\")", "H,W = map(int,input().split())\nA = [input() for i in range(H)]\nprint('#'*(W+2))\nfor a in A:\n print('#' + a + '#')\nprint('#'*(W+2))", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\nl = [int(c) for c in input().split()]\nH = l[0]\nW = l[1]\na = [input() for c in range(H)]\n\n\nprint(\"#\"*(W+2))\nfor i in range(H):\n print(\"#\"+a[i]+\"#\")\nprint(\"#\"*(W+2))", "h,w = map(int,input().split())\na = [\"#\"*(w+2)]\nfor i in range(h):\n a.append('#'+input()+\"#\")\na.append(\"#\"*(w+2))\nfor i in range(h+2):\n print(a[i])", "H, W=map(int, input().split())\nout=['#'*(W+2)]+['#'+input()+'#' for _ in range(H)]+['#'*(W+2)]\nprint(*out, sep='\\n')\n", "x,y=input().split()\nx=int(x)\ny=int(y)\na=[input() for i in range(x)]\nc=\"\"\nfor i in range(y+2):\n c=c+\"#\"\nprint(c)\nfor i in range(x):\n print(\"#\"+a[i]+\"#\")\nprint(c)", "h,w=list(map(int,input().split()))\ntop = \"#\"\ntop *=(w + 2)\nprint(top)\nfor i in range(h):\n tmp = input()\n print((\"#\"+tmp+\"#\"))\nprint(top)\n", "H, W = map(int, input().split())\nA = [input() for _ in range(H)]\n\nW += 2\nf = '#'\nprint(f * W)\nfor a in A:\n print(f'#{a}#')\nprint(f * W)", "h, w = map(int, input().split())\na = []\nfor _ in range(h):\n a.append('#' + input() + '#')\nsharp = '#' * (w + 2)\nprint(sharp)\nfor j in range(0, h):\n print(a[j])\nprint(sharp)", "h,w = map(int,input().split())\n\nprint('#'*(w+2))\nfor i in range(h):\n s = input()\n print('#'+s+'#')\nprint('#'*(w+2))", "h, w = map(int, input().split())\n\ns = \"#\" * (w+2)\n\nprint(s)\nfor i in range(h):\n t = input()\n print(\"#\", end=\"\")\n print(t, end=\"#\\n\")\nprint(s)\n", "H, W = map(int, input().split())\n\nscr_list = [input() for _ in range(H)]\n\nprint('#' * (W+2))\nfor i in scr_list:\n print('#' + i + '#')\nprint('#' * (W+2))", "# coding: utf-8\n\nheight, width = map(int, input().split())\n\nfor i in range(width+2):\n print(\"#\", end='')\n \nprint(\"\")\n\nfor j in range(height):\n print(\"#\", end='')\n str = input()\n print(str, end='')\n print(\"#\")\n\n\nfor l in range(width+2):\n print(\"#\", end='')", "def resolve():\n '''\n code here\n '''\n H, W = [int(item) for item in input().split()]\n grid = [input() for _ in range(H)]\n \n print(('#'*(W+2)))\n for line in grid:\n print(('#' + line + '#'))\n print(('#'*(W+2)))\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "h, w = map(int, input().split())\na = []\nfor _ in range(h):\n a.append(input())\nprint('#' * (w + 2))\nfor i in range(h):\n print('#' + a[i] + '#')\nprint('#' * (w + 2))", "h, w = map(int, input().split())\nprint(\"#\"*(w+2))\nfor i in range(h):\n s=input()\n print(\"#\" + s + \"#\")\nprint(\"#\"*(w+2))", "H, W = list(map(int, input().split()))\nA = [list(input()) for _ in range(H)]\n\n# \u4e00\u6bb5\u76ee\nprint((\"#\"*(W+2)))\nfor a in A:\n print((\"#\" + \"\".join(a) + \"#\"))\n# \u6700\u7d42\u6bb5\nprint((\"#\"*(W+2)))\n", "h,w = [int(x) for x in input().split()]\nprint(\"#\" * (w + 2))\nfor i in range(h):\n print(\"#\" + input() + \"#\")\nprint(\"#\" * (w + 2))", "with open(0) as f:\n H, W, *a = f.read().split()\nW = int(W)\na.insert(0,'#'*W)\na.append('#'*W)\nfor x in a:\n print(('#' + x.rstrip('\\n') + '#'))\n", "h,w = map(int, input().split())\nal = []\nfor _ in range(h):\n row = input()\n row = '#' + row + '#'\n al.append(row)\n\ntop = '#'*(w+2)\nprint(top)\nfor a in al:\n print(a)\nprint(top)", "H,W = list(map(int,input().split()))\na = ''\nfor i in range(W + 2):\n a += '#'\nL = []\nL.append(a)\nfor j in range(H):\n b = str(input())\n c = '#' + b + '#'\n L.append(c)\nL.append(a)\nfor k in range(H + 2):\n print((L[k]))\n", "h, w = map(int, input().split())\n\nprint(\"#\" * (w+2))\n\nfor i in range(h):\n s = input()\n print(\"#\" + s + \"#\")\n\nprint(\"#\" * (w+2))", "h,w = map(int, input().split())\nprint(\"#\"*(w+2))\nfor i in range(h):\n s = input()\n print(\"#\"+s+\"#\")\nprint(\"#\"*(w+2))", "h,w = map(int, input().split())\na = [input() for i in range(h)]\n\nprint(\"#\"*(w+2))\nfor i in range(h):\n print(\"#\" + a[i] + \"#\")\nprint(\"#\"*(w+2))", "x,y = map(int,input().split())\nL = [list(input()) for _ in range(x)]\nF = [['#']*(y+2) for _ in range(x+2)]\nfor i in range(x):\n for j in range(y):\n F[i+1][j+1] = L[i][j]\nfor f in F:\n print(''.join(f))"] | {"inputs": ["2 3\nabc\narc\n", "1 1\nz\n"], "outputs": ["#####\n#abc#\n#arc#\n#####\n", "###\n#z#\n###\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 20,667 | |
8771505050a8aeee118055085b333a44 | UNKNOWN | You have an integer variable x.
Initially, x=0.
Some person gave you a string S of length N, and using the string you performed the following operation N times.
In the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.
Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).
-----Constraints-----
- 1β€Nβ€100
- |S|=N
- No characters except I and D occur in S.
-----Input-----
The input is given from Standard Input in the following format:
N
S
-----Output-----
Print the maximum value taken by x during the operations.
-----Sample Input-----
5
IIDID
-----Sample Output-----
2
After each operation, the value of x becomes 1, 2, 1, 2 and 1, respectively. Thus, the output should be 2, the maximum value. | ["N = int(input())\nS = input()\nres = 0\ntmp = 0\nfor s in S:\n if s == 'I':\n tmp += 1\n elif s == 'D':\n tmp -= 1\n \n res = max(res, tmp)\n\nprint(res)\n", "n=int(input())\ns=input()\nx=0\nans=0\nfor i in range(n):\n if s[i]==\"I\":\n x+=1\n else:\n x-=1\n ans=max(ans,x)\nprint(ans)", "n = int(input())\ns = list(input())\nmax = x = 0\n\nfor i in s:\n if i=='I':\n x += 1\n else:\n x -= 1\n if max < x :\n max = x\nprint(max)", "n = int(input())\ns = input()\nx = 0\nxl = [0]\nfor i in range(n):\n if s[i] == \"I\":\n x += 1\n xl.append(x)\n else:\n x -= 1\n xl.append(x)\nprint(max(xl))", "n = int(input())\ns = input()\n\nx = 0\nans = 0\nfor a in s:\n if a == 'I':\n x += 1\n else:\n x -= 1\n ans = max(ans, x)\nprint(ans)", "N = int(input())\nS = input()\nx = 0\nans = 0\n \nfor i in S:\n if i == \"I\":\n x += 1\n elif i == \"D\":\n x -= 1\n ans = max(ans,x)\n \nprint(ans)", "n = int(input())\ns = input()\n\nans = 0\nx = 0\nfor i in range(n):\n if s[i] == 'I':\n x += 1\n else:\n x -= 1\n ans = max(ans, x)\n \nprint(ans)", "n=int(input())\ns=input()\nx=[0]\nfor i in s:\n if i==\"I\":\n x.append(x[-1]+1)\n else:\n x.append(x[-1]-1)\nprint(max(x))", "N = int(input())\nS = input()\n\nx = 0\nlst = [0]\n\nfor i in range(N):\n if S[i] == 'I':\n x += 1\n else:\n x -= 1\n lst.append(x)\n\nprint(max(lst))", "n = int(input())\ns = input()\nres = x = 0\nfor s_ in s:\n if s_==\"I\":\n x+=1\n else:\n x-=1\n res = max(res, x)\nprint(res)", "n = int(input())\ns = list(input())\n\nx = 0\nmx = 0\n\nfor a in s:\n if a == \"I\":\n x +=1\n else:\n x -=1\n if x > mx:\n mx = x\n \nprint(mx)\n", "n = int(input())\ns = input()\n\nx, ans = 0, 0\nfor o in s:\n if o == 'I':\n x += 1 \n else:\n x -= 1\n ans = max(ans, x)\n\nprint(ans)", "N = int(input())\nS = input()\nx = 0\nans = [0]\nfor i in range(N):\n if S[i] == 'I':\n x += 1\n else:\n x -= 1\n ans.append(x)\nprint(max(ans))", "N = int(input())\nS = input()\n\ntmp = 0\nans = 0\nfor i in range(N):\n if 'I' == S[i]:\n tmp += 1\n else:\n tmp -= 1\n ans = max(tmp, ans)\nprint(ans)\n", "input();x,r=0,0\nfor i in input():\n if i=='I': x+=1\n else: x-=1\n r=max(r,x)\nprint(r)", "n = int(input())\na = list(input())\nxlist = [0]\nx = 0\nfor i in range(n):\n if a[i]==\"D\":\n x-=1\n elif a[i]==\"I\":\n x+=1\n xlist.append(x)\nprint(max(xlist))", "x=0\nn=int(input())\ns=input()\nl=[0]\nfor i in s:\n if i==\"I\":\n x+=1\n l.append(x)\n else:\n x-=1\n l.append(x)\nprint(max(l))", "N = int(input())\nS = input()\n\nans = 0\nhighest = 0\nfor i in S:\n if i == \"I\":\n ans += 1\n else:\n ans -= 1\n if highest <= ans:\n highest = ans \n\nprint(highest)", "N = int(input())\nS = input()\n\nmax_num = 0\nidx = 0\nx = 0\nwhile idx < N:\n if S[idx] == 'I':\n x += 1\n else:\n x -= 1\n max_num = max(x, max_num)\n idx += 1\n\nprint(max_num)\n", "N=int(input())\nS=input()\nans=0\ncnt=0\nfor i in range(len(S)):\n if S[i]=='I':\n cnt+=1\n else:\n cnt-=1\n ans=max(ans,cnt)\nprint(ans)", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\n\n\ndef si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lstr(): return input().split()\ndef lint(): return list(map(int, input().split()))\ndef lint_dec(): return list(map(lambda x:int(x) - 1, input().split()))\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef lint_list(n): return [lint() for _ in range(n)]\n\n\n\n############################################################\nN = ii()\nS = si()\nx = 0\nans = 0\n\nfor s in S:\n if s == 'I':\n x += 1\n else:\n x -= 1\n ans = max(x, ans)\n\nprint(ans)", "n=int(input())\nx=0\nb=[]\ns=input()\nfor S in s:\n if S=='I':\n x += 1\n b.append(x)\n else:\n x -= 1\n b.append(x)\nprint((max(max(b),0)))\n", "cnt = int(input())\nstring = input()\nx = [0]\n\ni = 0\nfor _ in string:\n if _ == \"I\":\n i += 1\n x.append(i)\n else:\n i -= 1\n x.append(i)\n\nprint(max(x))", "n = int(input())\ns = input()\nx = 0\nm = 0\nfor i in range(n):\n if s[i] == \"I\":\n x += 1\n m = max(m, x)\n else:\n x -= 1\nprint(m)", "n = int(input())\ns = str(input())\nx = 0\nmaximum = 0\n\nfor i in range(n):\n if s[i] == 'I':\n x += 1\n elif s[i] == 'D':\n x -= 1\n maximum = max(maximum, x)\n\nprint(maximum)", "n = int(input())\ns = input()\nx = ans = 0\nfor i in s:\n if i == \"I\":\n x += 1\n else:\n x -= 1\n ans = max(ans,x)\nprint(ans)", "N = int(input())\nS = list(input())\n\ncounter = 0\nli = [0]\nfor i in range(N):\n if S[i] == 'I':\n counter +=1\n else:\n counter -= 1\n li.append(counter)\nprint(max(li))", "N=int(input())\nS=input()\nx=0\nans=0\nfor c in S:\n if c=='I':\n x+=1\n ans=max(ans,x)\n else:\n x-=1\nprint(ans)\n", "N = int(input())\nS = str(input())\n\nans = 0\ntmp = 0\nfor i in S:\n if i == 'I':\n tmp += 1\n ans = max(ans, tmp)\n else:\n tmp -= 1\nprint(ans)", "n = int(input())\ns = input()\n\nnum_list = [0]\nsum = 0\nfor w in s:\n if w == 'I':\n sum += 1\n else:\n sum -= 1\n num_list.append(sum)\n\nnum_list.sort()\nans = num_list[-1]\n\nprint(ans)", "N = int(input())\nS = input()\nx = 0\nans = 0\nfor s in S:\n if s == \"I\":\n x += 1\n else:\n x -= 1\n ans = max(ans, x)\nprint(ans)", "a,b=[input() for i in range(2)]\np=0\nans=0\n\nfor i in b:\n if i =='I':\n p+=1\n elif i =='D' and p>0:\n p-=1\n else:\n p-=1\n \n if ans<p:\n ans=p\n \nprint(ans)", "n = int(input())\ns = input()\n\nx = 0\nans = 0\nfor i in s:\n if i == 'I':\n x += 1\n elif i == 'D':\n x -= 1\n ans = max(ans, x)\n\nprint(ans)", "n = int(input())\ns = input()\nx = 0\nl = [0]\nfor a in s:\n if a == \"I\":\n x = x + 1\n l.append(x)\n else:\n x = x - 1\n l.append(x)\n\nprint(max(l))", "N, S = input(), input()\nx, xmax = 0, 0\nfor s in S:\n x = (lambda a:x+1 if a=='I' else x-1)(s)\n xmax = max(x,xmax)\nprint(xmax)", "# coding: utf-8\n\nnum = input()\ncount = 0\nmax = 0\nmessage = input()\ntable = list(message)\nfor i in table:\n if i == \"I\":\n count += 1\n elif i == \"D\":\n count -= 1\n if max <= count:\n max = count\nprint(max)", "n = int(input())\ns = list(input())\ncnt = 0\n\nfor i in range(n):\n cnt = max(cnt, s[0:i+1].count(\"I\") - s[0:i+1].count(\"D\"))\n\nprint(cnt)", "n = int(input())\ns = input()\nx = 0\nans = 0\nfor i in range(n):\n ans = max(ans, x)\n if s[i] == 'I':\n x += 1\n else :\n x -= 1\n ans = max(ans, x)\nprint(ans)\n", "x = int(input())\ns = input()\nli = [0]\nc = 0\nfor i in range(x):\n if s[i] == \"I\":\n c += 1\n li.append(c)\n else:\n c -= 1\n li.append(c)\nprint(max(li))", "N = int(input())\nS = input()\nx = 0\nmax = 0\nfor i in S:\n if i == 'I':\n x += 1\n else:\n x -= 1\n if x > max:\n max = x\nprint(max)", "n=int(input())\ns=input()\nans=0\nx=0\nfor i in range(n):\n if s[i]=='I':\n x+=1\n else:\n x-=1\n ans=max(ans,x)\nprint(ans)", "n = int(input())\ns = input()\n\nm = 0\nx = 0\nfor w in s:\n\tif w == \"I\":\n\t\tx += 1\n\telse:\n\t\tx -= 1\n\t\n\tif x > m:\n\t\tm = x\n\t\t\nprint(m)", "n = int(input())\ns = list(input())\nx = 0\ntmp = 0\nfor i in s:\n if i == \"I\":\n x += 1\n else:\n x -= 1\n tmp = max(x, tmp)\nprint(tmp)", "N = int(input())\nS = input()\n\nx = 0\nx_list= [0]\nfor s in S:\n if s == 'I':\n x += 1\n x_list.append(x)\n else:\n x -= 1\n x_list.append(x)\n\nprint(max(x_list))", "n = int(input())\ns = input()\nx = 0\nc = 0\nfor i in s:\n if i == \"I\":\n x += 1\n else:\n x -= 1\n c = max(x,c)\nprint(c)", "def answer(n: int, s: str) -> int:\n while 'DI' in s:\n s = s.replace('DI', '')\n\n return s.count('I')\n\n\ndef main():\n n = int(input())\n s = input()\n print(answer(n, s))\n\n\ndef __starting_point():\n main()\n__starting_point()", "N=int(input())\nS=input()\na=[]\ntotal=0\nfor i in range(len(S)):\n if S[i]==\"I\":\n total+=1\n a.append(total)\n else:\n total-=1\n a.append(total)\nprint(max(max(a),0))", "n = int(input())\ns = input()\n\nans = 0\nx = 0\nfor c in s:\n if c == 'I':\n x += 1\n else:\n x -= 1\n ans = max(ans, x)\nprint(ans)", "N = int(input())\nS = str(input())\nmax_int = 0\ncount = 0\nfor i in S:\n if i == 'I':\n count +=1\n max_int = max(max_int, count)\n elif i == 'D':\n count -= 1\nprint(max_int)", "N = int(input())\nS = input()\nans = 0\ncnt = 0\nfor i in range(N):\n if S[i] == 'I':\n cnt += 1\n ans = max(ans, cnt)\n else:\n cnt -= 1\nprint(ans)", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n answers=[0]\n n = int(input())\n S = input()\n x=0\n\n for s in S:\n if \"I\" in s:\n x+=1\n answers.append(x)\n elif \"D\" in s:\n x-=1\n answers.append(x)\n print(max(answers))\n\ndef __starting_point():\n main()\n__starting_point()", "n=int(input())\ns=input()\nx=0\nm = 0\nfor i in range(n):\n if s[i] == \"I\":\n x += 1\n m = max(x, m)\n else:\n x -= 1\nprint(m) ", "N = int(input())\nS = input()\n\nans = 0\ncnt = 0\n\nfor i in range(N):\n if S[i] == \"I\":\n cnt += 1\n elif S[i] == \"D\":\n cnt -= 1\n \n ans = max(ans, cnt)\n \nprint(ans)", "N = int(input())\nS = list(input())\nans = 0\nn_ans = 0\nfor i in range(N):\n if(S[i]=='I'):\n n_ans += 1\n ans = max(ans, n_ans)\n else:\n n_ans -= 1\n ans = max(ans, n_ans)\nprint(ans)", "N = int(input())\nS = input()\nx = 0\nans = 0\n\nfor i in range(len(S)):\n if S[i] == 'I':\n x += 1\n ans = max(x, ans)\n else:\n x -= 1\nprint(ans)\n", "N = int(input())\nS = input()\nx = 0\nans = x\n\nfor i in range(N):\n if S[i]==\"I\":\n x += 1\n ans = max(ans, x)\n else:\n x -= 1\nprint(ans)", "n = int(input())\ns = input()\nx = 0\ny = 0\n\nfor i in range(n):\n\tif s[i] == 'I':\n\t\tx += 1\n\t\tif x>y:\n\t\t\ty = x\n\telse:\n\t\tx -= 1\n\nprint(y)", "N = int(input())\nS = input()\n\nresult = 0\nx = 0\nfor i in S:\n if i == 'I':\n x += 1\n else:\n x -= 1\n result = max(result, x)\n\nprint(result)", "n = int(input())\ns = input()\n\nc = 0\nans = 0\nfor i in list(s):\n if i == 'I':\n c+=1\n else:\n c-=1\n ans = max(ans, c)\nprint(ans)", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\n\nN = int(input())\nS = input()\nx = 0\nmax = 0\nfor i in range(N):\n if S[i] == \"I\":\n x+=1\n elif S[i] == \"D\":\n x-=1\n \n if max < x:\n max = x\n\nprint(max)", "n = int(input())\ns = list(map(str, input()))\nmx = 0\nsm = 0\n\nfor char in s:\n if char == \"I\":\n sm += 1\n mx = max(mx, sm)\n elif char == \"D\":\n sm -= 1\n else:\n continue\n\nprint(mx)", "n = int(input())\ns = input()\nx = 0\nans = x\nfor i in range(n):\n if s[i] == 'I':\n x += 1\n else:\n x -= 1\n ans = max(ans,x)\nprint(ans)", "n = int(input())\ns = input()\nmaxnum = 0\ncnt = 0\nfor i in range(len(s)):\n if s[i] == 'I':\n cnt += 1\n if cnt >= maxnum:\n maxnum = cnt\n elif s[i] == 'D':\n cnt -= 1\nprint(maxnum)", "n = int(input())\ns = list(input())\ncount = 0\nmax = 0\nfor i in range(n):\n \n if s[i] == \"I\":\n count += 1\n if max < count:\n max = count\n elif s[i] == \"D\":\n count -= 1\nprint(max)", "# 31\nN = int(input())\nS = str(input())\n\nans = 0\ncount = 0\nfor i in S:\n if i == 'I': count += 1\n elif i == 'D': count -= 1\n ans = max(ans, count)\n\nprint(ans)", "a=int(input())\nb=input()\nc=0\nd=[0]\nfor i in b:\n if(i==\"I\"):\n c+=1\n d.append(c)\n elif(i==\"D\"):\n c-=1\n d.append(c)\nprint(max(d))", "N = int(input())\nS = input()\nans = 0\nx = 0\nfor i in S:\n if i == 'I':\n x += 1\n ans = max(ans, x)\n else:\n x -= 1\nprint(ans)", "N = int(input())\nS = list(input())\nx = 0\na = [0]\n\nfor s in S:\n if s == 'I':\n x += 1\n else:\n x -= 1\n a.append(x)\n\nprint(max(a))", "n = int(input())\ns = input()\nans = 0\nx = 0\nfor i in s:\n if i == 'I':\n x += 1\n else:\n x -= 1\n if x > ans:\n ans = x\nprint(ans)", "n = int(input())\ns = input()\nx = 0\nmaxx = 0\nfor i in range(n):\n if s[i] == \"I\":\n x += 1\n if maxx < x:\n maxx = x\n else:\n x -= 1\nprint(maxx)", "N = int(input())\nS = input()\n\nm = 0\nx=0\nfor i in range(N):\n if S[i] == 'I':\n x+=1\n \n else:\n x-=1\n \n m=max(m,x)\n \nprint(m)\n", "N = int(input())\nS = input()\nx = 0\nX = [0]*(N+1)\n\nfor i in range(1, N+1):\n if S[i-1] == \"I\":\n x += 1\n X[i] = x\n else:\n x -= 1\n X[i] = x\nprint((max(X)))\n", "N = int(input())\nS = list(input())\nx = 0\nmax = 0\nfor i in range(N):\n if S[i] == \"I\":\n x += 1\n else:\n x -= 1\n if x > max:\n max = x\nprint(max)", "n=int(input())\ns=input()\n\nans=0\nnum=0\nfor i in s:\n if i==\"I\":\n num+=1\n ans=max(ans,num)\n elif i==\"D\":\n num-=1\n ans=max(ans,num)\n \nprint(ans)\n", "N = int(input())\nS = str(input())\nx = 0\nL = [x]\nfor i in S:\n if i == 'I':\n x += 1\n if i == 'D':\n x -= 1\n L.append(x)\nprint((max(L)))\n", "n = int(input())\ns = str(input())\n\nmax_result = 0\nresult = 0\n\n\nfor i in s:\n if i == \"I\":\n result += 1\n if result > max_result:\n max_result = result\n else:\n result -= 1\n\n\nprint(max_result)", "n = int(input())\ns = input()\nx = 0\nres = 0\n\nfor i in range(n):\n if s[i] == \"I\":\n x += 1\n else:\n x -= 1\n res = max(res, x)\n\nprint(res)\n", "N = int(input())\nS = input()\nx = 0\nans = 0\nfor i in range(N):\n if S[i] == 'I':\n x += 1\n else:\n x -= 1\n ans = max(ans, x)\nprint(ans)", "n = int(input())\nans = list(input())\ncount = 0\na = set()\nfor i in range(n):\n if ans[i] == 'I':\n count += 1\n a.add(count)\n elif ans[i] == 'D':\n count -= 1\n a.add(count)\n\nprint(max(max(a), 0))", "N=int(input())\nS=input()\n\ndef ans052(N:int, S:str):\n x=0\n x_list=[0]\n for i in range(N):\n if S[i]==\"I\":\n x+=1\n x_list.append(x)\n elif S[i]==\"D\":\n x-=1\n x_list.append(x)\n x_list.sort()\n return x_list[-1]\n\nprint(ans052(N,S))", "a=int(input())\nb=input()\nc=0\nd=0\nfor i in range(a):\n if b[i]==\"D\":\n c=c-1\n if b[i]==\"I\":\n c=c+1\n if c>d:\n d=c\nprint(d)", "N = int(input())\nS = input()\n\nx = 0\nx_max = x\n\nfor c in S:\n if c == \"I\":\n x += 1\n if x > x_max:\n x_max = x\n elif c == \"D\":\n x -= 1\n\nprint(x_max)", "n = int(input())\ns = input()\ncount = 0\nx = 0\nfor i in range(n):\n if s[i] == \"I\":\n x += 1\n else:\n x -= 1\n count = max(count, x)\nprint(count)", "n=int(input())\ns=str(input())\nans=0\nm=0\nfor i in range(n):\n if s[i]==\"I\":\n ans+=1\n m=max(m,ans)\n else:\n ans-=1\n\nprint(m)\n", "N=int(input())\nS=input()\nx=0\nans=0\nfor i in range(N):\n if S[i]=='I':\n x+=1\n else:\n x-=1\n ans=max(ans,x)\nprint(ans)", "n = int(input())\ns = input()\nres = 0\nans = 0\nfor i in range(n):\n if s[i] == \"D\":\n res -= 1\n else:\n res += 1\n ans = max(res,ans)\n\nprint(ans)", "# -*- coding:utf-8 -*-\nN = int(input())\nS = input()\n\nans = 0\nmax = 0\n\nfor s in S:\n if s == 'I':\n ans += 1\n else:\n ans -= 1\n \n if max < ans:\n max = ans\n\nprint(max)", "x = 0\nmx = 0\nn = int(input())\ns = input()\n\nfor c in s:\n if c == 'I':\n x += 1\n else:\n x -= 1\n mx = max(mx, x)\n\nprint(mx)\n", "N = int(input())\nS = input()\nans = 0\nans_tmp = 0\nfor s in S:\n if s==\"I\":\n ans_tmp += 1\n ans = max(ans_tmp, ans)\n else:\n ans_tmp -= 1\nprint(ans)", "N,S=int(input()),input()\nprint(max([(t:=S[:m+1]).count(\"I\")-t.count(\"D\") for m in range(N)]+[0]))", "n = int(input())\ns = input()\nx = 0\nans = 0\nfor i in s:\n if i == 'I':\n x+=1\n elif i == 'D':\n x-=1\n ans = max(ans,x)\nprint(ans)", "n = int(input())\ns = str(input())\nx = 0\na = 0\nfor i in s:\n if i == 'I':\n x += 1\n if x > a:\n a = x\n else:\n x -= 1\nprint(a)", "N = int(input())\nS = input()\n\nx = 0\nans = 0\nfor i in S:\n if i == 'I':\n x += 1\n elif i == 'D':\n x -= 1\n ans = max(x, ans)\nprint(ans)", "n = int(input())\ns = input()\nmax = 0\nsum = 0\nfor i in s:\n if(i == 'I'):\n sum += 1\n if(max < sum):\n max = sum\n else:\n sum -= 1\nprint(max)", "def main():\n input()\n s = input()\n tmp = 0\n ans = 0\n for v in s:\n if v == \"I\":\n tmp += 1\n else:\n tmp -= 1\n ans = max(ans, tmp)\n print(ans)\n\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\ns = input()\nx = 0\nans = [0]\n\nfor c in s:\n if c == 'I':\n x += 1\n else:\n x -= 1\n ans.append(x)\nprint(max(ans))", "N = int(input())\nS = str(input())\n\nM = 0\nSum = 0\n\nfor x in S:\n if x == 'I':\n Sum += 1\n else:\n Sum -= 1\n M = max(M, Sum)\n\nprint(M)\n", "N = int(input())\nS = list(input())\n\nx = 0\nmaxi = 0\n\nfor i in S:\n if i == 'I':\n x += 1\n else:\n x -= 1\n\n if x > maxi:\n maxi = x\n\nprint(maxi)", "input()\n\ncur = 0\nmax_value = 0\nfor c in input():\n x = 1 if c == 'I' else -1\n cur += x\n max_value = max(max_value, cur)\n \nprint(max_value)"] | {"inputs": ["5\nIIDID\n", "7\nDDIDDII\n"], "outputs": ["2\n", "0\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 18,479 | |
fbdcabff2e729c8396767090bb1a5624 | UNKNOWN | Find the number of palindromic numbers among the integers between A and B (inclusive).
Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.
-----Constraints-----
- 10000 \leq A \leq B \leq 99999
- All input values are integers.
-----Input-----
Input is given from Standard Input in the following format:
A B
-----Output-----
Print the number of palindromic numbers among the integers between A and B (inclusive).
-----Sample Input-----
11009 11332
-----Sample Output-----
4
There are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311. | ["a,b = map(int,input().split())\nans = 0\nfor i in range(a,b+1):\n c = str(i)\n l = len(c)\n d = l // 2\n cnt = 0\n for i in range(d):\n if c[i] == c[-i-1]:\n cnt += 1\n if cnt == d:\n ans += 1\nprint(ans)", "A,B = list(map(str,input().split()))\nLa = [int(A[:3]),int(A[3:])]\nLb = [int(B[:3]),int(B[3:])]\nL = 900 - (La[0] - 100) - (999 - Lb[0])\nch1 = int(A[1] + A[0])\nch2 = int(B[1] + B[0])\nif Lb[1] < ch2:\n L -= 1\nif ch1 < La[1]:\n L -= 1\nprint(L)\n \n", "A, B = [int(x) for x in input().split()]\nans = 0\nfor i in range(A, B+1):\n s = str(i)\n S = list(s)\n if(S[0]==S[4] and S[1]==S[3]):\n ans += 1\nprint(ans)", "A, B = map(int, input().split())\n\ncount = 0\n\nfor i in range(A, B+1):\n check = 0\n str_i = str(i)\n for j in range(0, (len(str_i)//2)+1):\n if int(str_i[j]) != int(str_i[-1-j]):\n check += 1\n if check == 0:\n count += 1\n\nprint(\"{}\".format(count))", "A,B = map(int,input().split())\n\nans = 0\n\nfor i in range(1,10):\n for j in range(10):\n for k in range(10):\n if A <= i*10000+j*1000+k*100+j*10+i <= B:\n ans += 1\nprint(ans)", "a, b = list(map(int, input().split()))\ncnt = 0\n\nfor i in range(a, b+1):\n l = []\n while (i > 0):\n l.append(i%10)\n i//=10\n if (l[0] == l[4] and l[1] == l[3]):\n cnt+=1\nprint(cnt)\n", "a,b=map(int,input().split())\ncount=0\nfor i in range(a,b+1):\n i=str(i)\n if i[0]==i[4] and i[1]==i[3]:\n count+=1\n \nprint(count)", "A, B = map(int, input().split())\n\ncount = 0\nfor i in range(A, B+1):\n num = str(i)\n if num[0] == num[4]:\n if num[1] == num[3]:\n count += 1\n\nprint(count)", "A, B = map(int,input().split())\n\ncount = 0\nfor i in range(A, B+1):\n if str(i) == str(i)[::-1]:\n count += 1\n\nprint(count)", "A, B = map(int, input().split())\n\ncount = 0\nfor i in range(A, B+1):\n if(str(i) == str(i)[::-1]):\n count += 1\n else: continue\nprint(count)", "# import math\n# import statistics\n# a=input()\n#b,c=int(input()),int(input())\n# c=[]\n# for i in a:\n# c.append(i)\ne1,e2 = map(str,input().split())\n# f = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\n# h = []\n# for i in range(e1):\n# h.append(list(map(int,input().split())))\nc=[]\ncount=0\nans=0\nfor i in range(int(e1),int(e2)+1):\n count=0\n for k in range(len(str(i))//2):\n if str(i)[k]==str(i)[-(k+1)]:\n count+=1\n if len(str(i))//2 == count:\n ans+=1\n\nprint(ans)", "a, b = map(int, input().split())\nans = 0\nfor i in range(a,b+1):\n num = 0\n j = i\n while j > 0:\n r = j % 10\n j //= 10\n num = num * 10 + r\n if i == num:\n ans += 1\n\n\nprint(ans)", "a,b=input().split()\na=int(a)\nb=int(b)\nc=0\nfor i in range(a,b+1):\n i=str(i)\n if i[0]==i[4] and i[1]==i[3]:\n c+=1\nprint(c)", "A, B = map(int, input().split())\ncount = 0\n\nfor i in range(A, B+1):\n if str(i)[0] == str(i)[4]:\n if str(i)[1] == str(i)[3]:\n count += 1\n \nprint(count)", "A,B=list(map(int,input().split()))\ndef ans090(A:int,B:int):\n ans_count = 0\n for i in range(A,B+1):\n if str(i) == str(i)[::-1]:\n ans_count+=1\n return ans_count\nprint((ans090(A,B)))\n", "A, B = map(int,input().split())\n\ncnt = 0\nfor i in range(A, B + 1):\n i = str(i)\n x = len(i) // 2\n left = i[0: x]\n right = i[x + 1 :]\n reverse_right = right[::-1]\n if left == reverse_right:\n cnt += 1\nprint(cnt)", "A, B = map(int,input().split())\n\nNumbers = []\n\nfor i in range(A,B+1):\n number = str(A)\n # print(number)\n if number[0] == number[4] and number[1] == number[3]:\n Numbers.append(number)\n A += 1\n\nprint(len(Numbers))", "A, B = list(map(int, input().split()))\ncnt = 0\nfor i in range(A, B + 1):\n\tif str(i) == str(i)[::-1]:\n\t\tcnt += 1\nprint(cnt)\n", "a, b = map(int, input().split())\ncount = 0\nfor i in range(a, b + 1):\n s = str(i)\n if s[0] == s[4] and s[1] == s[3]:\n count += 1\nprint(count)", "a, b = map(int, input().split())\n\nans = 0\nfor i in range(a, b+1):\n i = list(str(i))\n t_size = len(i)\n if t_size%2 == 0:\n if i[:t_size//2] == list(reversed(i[t_size//2:])):\n ans+=1\n else:\n if i[:t_size//2] == list(reversed(i[t_size//2+1:])):\n ans+=1\nprint(ans)", "ab = list(map(int, input().split()))\na, b = ab[0], ab[1]\ncount = 0\n\nfor num in range(a, b + 1):\n str_num = str(num)\n str_num_reversed = \"\".join(list(reversed(str_num)))\n if str_num == str_num_reversed:\n count += 1\n\nprint(count)\n", "lst = input().split()\n\ncount = 0\n\ndef judge(n):\n if str(n) == str(n)[::-1]:\n return True\n else:\n return False\n\nfor i in range(int(lst[0]), int(lst[1]) + 1):\n if judge(i):\n count += 1\n\nprint(count)", "A,B = map(int,input().split())\n\ncnt = 0\nfor i in range(A,B+1):\n s = str(i)\n half = len(s) // 2\n add = len(s) % 2\n #print(s,-1, s[0:half],-1, s[half+add:][::-1])\n if s[0:half] == s[half+add:][::-1]:\n cnt += 1\n \nprint(cnt)", "a, b = map(int, input().split())\nanswer = 0\n\nfor k in range(a, b + 1):\n kk = str(k)\n if kk == kk[::-1]:\n answer += 1\n\nprint(answer)", "a, b = (int(i) for i in input().split())\nans = 0\nfor i in range(a, b + 1):\n str_i = str(i)\n if str_i[0] == str_i[-1] and str_i[1] == str_i[-2]: ans += 1\nprint(ans)", "a, b = input().split()\n\ncount = 0\nfor i in range(int(a), int(b) + 1):\n mylist = list(str(i))\n if mylist[0] == mylist[4] and mylist[1] == mylist[3]:\n count +=1\n\nprint(count)\n", "A, B = list(map(int, input().split()))\nans = 0\n\nfor nums in range(A, B + 1):\n nums = str(nums)\n if nums == nums[::-1]:\n ans += 1\n\nprint(ans)\n", "a, b = map(int, input().split())\nans = 0\nfor i in range(a, b+1):\n if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]:\n ans += 1\nprint(ans)", "A,B = map(int,input().split())\n\ncnt = 0\nfor i in range(A,B+1):\n i = str(i)\n if i == i[::-1]:\n cnt += 1\n \nprint(cnt)", "A, B = map(int, input().split())\n\nans = 0\nfor i in range(A, B+1):\n if str(i) == str(i)[::-1]:\n ans += 1\nprint(ans)", "#from statistics import median\n#import collections\n#aa = collections.Counter(a) # list to list || .most_common(2)\u3067\u6700\u5927\u306e2\u500b\u3068\u308a\u3060\u305b\u308b\u304a a[0][0]\nfrom math import gcd\nfrom itertools import combinations,permutations,accumulate, product # (string,3) 3\u56de\n#from collections import deque\nfrom collections import deque,defaultdict,Counter\nimport decimal\nimport re\nimport math\nimport bisect\nimport heapq\n#\n#\n#\n# python\u3067\u7121\u7406\u306a\u3068\u304d\u306f\u3001pypy\u3067\u3084\u308b\u3068\u6b63\u89e3\u3059\u308b\u304b\u3082\uff01\uff01\n#\n#\n# my_round_int = lambda x:np.round((x*2 + 1)//2)\n# \u56db\u6368\u4e94\u5165g\n#\n# \u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u7cfb\n# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);\n# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);\n#\n#\nimport sys\nsys.setrecursionlimit(10000000)\nmod = 10**9 + 7\n# mod = 9982443453\n# mod = 998244353\nINF = float('inf')\nfrom sys import stdin\nreadline = stdin.readline\ndef readInts():\n return list(map(int,readline().split()))\ndef readTuples():\n return tuple(map(int,readline().split()))\ndef I():\n return int(readline())\na,b = readInts()\nans = 0\nfor num in range(a,b+1):\n s = str(num)\n if s == s[::-1]:\n ans += 1\nprint(ans)\n", "a,b=list(map(int,input().split()))\n\nc=0\nfor i in range(a,b+1):\n s=str(i)\n if s==s[::-1]:\n c+=1\nprint(c)\n", "#!/usr/bin/env python3\n\na, b = list(map(int, input().split()))\n\nans = 0\nfor i in range(a, b+1):\n i = str(i)\n if i[0] == i[-1] and i[1] == i[-2]:\n ans += 1\n\nprint(ans)\n", "a,b=map(int, input().split()) \ncnt=0\nfor i in range(a,b+1):\n if i//10000==i%10 and (i//1000)%10==(i%100)//10:\n cnt+=1\nprint(cnt)", "A, B =list(map(int, input().split()))\nnum_palin = [0] * (B+1)\nfor i in range(1,B+1):\n if str(i) == str(i)[::-1]:\n num_palin[i] = num_palin[i-1] + 1\n else:\n num_palin[i] = num_palin[i-1]\nprint((num_palin[B]-num_palin[A-1]))\n", "a,b = input().split()\ncnt = 0\nfor n in range(int(a),int(b)+1):\n if str(n) == str(n)[::-1]:\n cnt += 1\nprint(cnt)", "a, b = map(int, input().split())\n\nresult = 0\nfor x in range(a, b+1):\n if str(x) == ''.join(reversed(str(x))):\n result += 1\nprint(result)", "A, B = map(str, input().split())\nl = list(range(int(A), int(B)+1))\nc = 0\nfor i in l:\n t = str(i)\n if t[0] == t[4] and t[1] == t[3]:\n c += 1\nprint(c)", "a,b = map(int,input().split())\nans = 0\nfor i in range(a,b+1):\n s = str(i)\n if s[0] == s[4] and s[1] == s[3]:\n ans += 1\nprint(ans)", "a,b = map(int,input().split())\ncnt = 0\nfor i in range(a,b+1):\n if str(i)==str(i)[::-1]:\n cnt += 1\nprint(cnt)", "a,b = map(int,input().split())\nans = 0\nfor i in range(a,b+1):\n c = str(i)\n if c[0] == c[4] and c[1] == c[3]:\n ans += 1\nprint(ans)", "A,B=list(map(int,input().split()))\nans=0\nfor x in range(A,B+1):\n S=str(x)\n if S==S[::-1]:\n ans+=1\nprint(ans)\n", "a, b = list(map(int, input().split()))\n\nans = 0\nfor x in range(a, b + 1):\n if x // 10000 == x % 10 and (x // 1000) % 10 == (x // 10) % 10:\n ans += 1\nprint(ans)\n", "a,b = list(map(int,input().split()))\ncnt = 0\n\nfor i in range(a,b+1):\n lis_i = list(str(i))\n lis_i.reverse()\n rev_i = int(''.join(lis_i))\n if rev_i == i:\n cnt += 1\n \nprint(cnt)\n", "a,b = list(map(int,input().split()))\nc = \"\"\nd = \"\"\nans = 0\nfor i in range(a,b+1):\n c = str(i)\n d = c[::-1]\n if c == d:\n ans += 1\nprint(ans)\n\n\n\n", "a,b = list(map(int,input().split()))\ncnt = 0\n\nfor i in range(b-a+1):\n r = str(a+i)[::-1]\n if a+i == int(r):\n cnt += 1\nprint(cnt)\n", "A, B = list(map(int, input().split()))\nans = 0\nfor i in range(A, B + 1):\n S = str(i)\n N = len(S)\n if all(S[i] == S[-i - 1] for i in range(N // 2)):\n ans += 1\nprint(ans)\n", "def mapt(fn, *args):\n return tuple(map(fn, *args))\n\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\n\ndef main():\n a, b = Input()\n ans = 0\n for i in range(a, b + 1):\n str_i = list(str(i))\n if str_i[0] == str_i[-1] and str_i[1] == str_i[-2]:\n ans += 1\n print(ans)\n\n\nmain()", "A,B=map(int,input().split())\n\ndef ans090(A:int, B:int):\n count=0\n for i in range(A,B+1):\n if str(i)[0]==str(i)[-1] and str(i)[1]==str(i)[-2]:\n count+=1\n return count\n\nprint(ans090(A,B))", "a,b=map(int,input().split())\nans=0\nfor i in range(a,b+1):\n i=str(i)\n if i==i[::-1]:\n ans+=1\nprint(ans)", "a,b = list(map(int, input().split()))\n\nans = 0\nfor i in range(a, b+1):\n s = str(i)\n ok = True\n for j in range(2):\n ok = ok and s[j] == s[4-j]\n if ok:\n ans += 1\n\nprint(ans)\n", "def isPal(s):\n s = str(s)\n n = len(s)\n f = 1\n for i in range(n//2):\n f &= s[i] == s[n-i-1]\n return f\n\na, b = list(map(int, input().split()))\n\nans = 0\nfor i in range(a, b+1):\n if(isPal(i)):\n ans += 1\n\nprint(ans)\n\n", "A,B=map(int,input().split())\nresult=0\nfor i in range(A,B+1):\n i=str(i)\n for j in range(int(((len(i))-1)/2)+1):\n if not i[j]==i[-j-1]:\n break\n else:\n result+=1\nprint(result)", "A, B = list(map(int, input().split()))\n\nans = 0\n\nfor i in range(A, B+1, 1):\n x = list(str(i))\n if x[0] == x[4] and x[1] == x[3]:\n ans += 1\nelse:\n print(ans)\n", "a, b = map(int, input().split())\n\ncnt = 0\nfor i in range(a, b+1, 1):\n i = str(i)\n if i[0] == i[4] and i[1] == i[3]:\n cnt += 1\n else:\n continue\n\nprint(cnt)", "a, b = list(map(int, input().split()))\nres = 0\nfor i in range(a, b + 1):\n str_i = str(i)\n if str_i[0] == str_i[-1] and str_i[1] == str_i[-2]:\n res += 1\n\nprint(res)\n", "def reverse(num):\n test_num = 0\n while (num > 0):\n remainder = num % 10\n test_num = (test_num * 10) + remainder\n num = num // 10\n return test_num\n\na,b = list(map(int,input().split()))\nc = 0\nfor i in range(a,b+1):\n if i == reverse(i):\n c+=1\nprint(c)", "a,b=map(int,input().split())\ncount = 0\nfor i in range(a,b+1):\n if str(i)[0]==str(i)[4] and str(i)[1]==str(i)[3]:\n count+=1\nprint(count)", "a, b = map(int, input().split())\ncnt = 0\nfor i in range(a, b+1):\n i = str(i)\n if i[0] == i[-1] and i[1] == i[-2]:\n cnt += 1\nprint(cnt)", "a, b = map(int, input().split())\nans = 0\n\nfor i in range(a//10000, b//10000+1):\n for j in range(0,10):\n for k in range(0,10):\n x = i*10001 + j*1010 + k*100\n if a<=x<=b:\n ans+=1\nprint(ans, flush=True)\n\n", "A, B = list(map(int, input().split()))\ncnt = 0\nfor num in range(A, B+1):\n num = list(str(num))\n for i in range(len(num)//2):\n if num[i] != num[len(num)-i-1]:\n break\n else:\n cnt += 1\nprint(cnt)\n", "a, b = map(int, input().split())\nprint(sum(num == num[::-1] for num in map(str,range(a, b+1))))", "A,B= map(int,input().split())\n\nans=0\n\nfor i in range(A,B+1):\n for j in range(len(str(i))):\n zen = j\n kou = len(str(i))-1-j\n if zen >= kou:\n ans+=1\n break\n if str(i)[zen] != str(i)[kou]:\n break\n \nprint(ans)", "A, B = map(int,input().split())\nans_cou = 0\nfor i in range(A, B + 1):\n str_i = str(i)\n reverse_str_i = ''.join(list(reversed(str_i)))\n reverse_int_i = int(reverse_str_i)\n if i == reverse_int_i:\n ans_cou += 1\nprint(ans_cou)", "a, b = map(int, input().split())\nans = []\nfor i in range(a, b + 1):\n c = [j for j in str(i)]\n if c[0] == c[-1] and c[1] == c[-2]:\n ans.append(i)\nprint(len(ans))", "A,B=map(int,input().split())\ncount=0\nfor i in range(A,B+1):\n if str(i)[0:2] == str(i)[::-1][:2]: count += 1\nprint(count)", "def kaibun(n):\n if str(n)[0]==str(n)[-1] and str(n)[1]==str(n)[-2]:\n return True\n else:\n return False\n\na,b=map(int,input().split())\nans=0\nfor i in range(a,b+1):\n if kaibun(i):\n ans+=1\nprint(ans)", "def answer(a: int, b: int) -> int:\n count = 0\n for i in range(a, b + 1):\n i_str = str(i)\n if i_str[0] == i_str[-1] and i_str[1] == i_str[-2]:\n count += 1\n\n return count\n\n\ndef main():\n a, b = list(map(int, input().split()))\n print((answer(a, b)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a, b = map(int, input().split())\nans = 0\nfor i in range(a, b+1):\n s = str(i)\n if s == s[::-1]:\n ans += 1\nprint(ans)", "a,b=map(int,input().split())\n\ncnt=0\nfor i in range(1,10):\n for j in range(0,10):\n for k in range(0,10):\n num=int(str(i)+str(j)+str(k)+str(j)+str(i))\n if a<=num<=b:\n cnt+=1\n \nprint(cnt)", "a, b = list(map(int, input().split()))\nans = 0\nfor i in range(a,b+1):\n key = str(i)\n #print(key)\n if key[:2] == key[4]+key[3]:\n ans += 1\nprint(ans)\n", "a, b = map(int, input().split())\ncnt = 0\nfor i in range(a, b+1):\n\ts = str(i)\n\tif s[0] == s[4] and s[1] == s[3]:\n\t\tcnt += 1\nprint(cnt)", "a, b = list(map(int, input().split()))\nk = 0\n\nfor i in range(a,b+1):\n if str(i) == ''.join(list(reversed(str(i)))):\n k += 1\n\nprint(k)\n", "a,b=map(int,input().split())\ntotal=0\nfor i in range(a,b+1):\n x=str(i)\n y=int(x[::-1])\n if i==y:\n total+=1\nprint(total)", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\nl = [int(c) for c in input().split()]\nA = l[0]\nB = l[1]\ncnt=0\nfor i in range(A,B+1):\n if str(i)[0]==str(i)[4] and str(i)[1]==str(i)[3]:\n cnt+=1\nprint(cnt)", "a,b=map(int,input().split())\ncnt = 0\nfor i in range(a,b+1):\n i = str(i)\n if i == i[::-1]:\n cnt +=1\nprint(cnt)", "a,b = map(int, input().split())\ncnt = 0\nfor i in range(a, b+1):\n l,r = list(str(i))[:3], list(str(i))[2:][::-1]\n if l == r: cnt += 1\nprint(cnt)", "a,b = map(int,input().split())\nc = 0\nfor i in range(a,b+1):\n if str(i)[0] == str(i)[-1] and str(i)[1] == str(i)[-2]:\n c += 1\nprint(c)", "N = {} #10000\u4ee5\u4e0akey\u4ee5\u4e0b\u306e\u56de\u6587\u6570\u306e\u500b\u6570\ncnt = 0\nfor i in range(10000, 100000):\n L = list(str(i))\n if L == list(reversed(L)):\n cnt += 1\n N[i] = cnt\nA, B = map(int, input().split())\nprint(N[B]-N[A-1] if A > 10000 else N[B])", "a,b = map(int,input().split())\nans = 0\nfor i in range(a,b+1):\n x = str(i)\n y = x[::-1]\n if x == y:\n ans += 1\nprint(ans)", "a, b = map(int, input().split())\nc = 0\nfor i in range(a, b+1):\n s = str(i)\n if s == s[::-1]:\n c += 1\nprint(c)", "a,b = list(map(int,input().split()))\ncount = 0\nfor i in range(a,b+1):\n s = str(i)\n if s == s[::-1]:\n count += 1\nprint(count)\n", "# -*- coding: utf-8 -*-\n\ndef judege_palindromic(val_str):\n length = len(val_str)\n match = True\n for i in range(length//2):\n if val_str[i] != val_str[length-i-1]:\n match = False\n break\n\n return match \n\n\nA, B = map(int, input().split())\n\ncnt = 0\nfor i in range(A, B+1, 1):\n if judege_palindromic(str(i)):\n cnt += 1\n\nprint(cnt)", "A, B = map(int, input().split())\n\ncnt = 0\nfor i in range(A, B + 1):\n if str(i) == str(i)[::-1]:\n cnt += 1\nprint(cnt)", "a,b = [int(x) for x in input().split()]\n\ndef check(p):\n p = str(p)\n if p[0] == p[4] and p[1] == p[3]:\n return True\n return False\n\nres = 0\nfor i in range(a,b+1):\n if check(i):\n res += 1\nprint(res)", "a, b = list(map(int, input().split()))\ncnt = 0\nl = []\nnewl = []\n\nfor i in range(a, b+1):\n l = []\n while (i > 0):\n l.append(i%10)\n i//=10\n newl = l[::-1]\n if (l == newl):\n cnt+=1\nprint(cnt)\n", "a,b=map(int,input().split())\nans=0\nfor i in range(a,b+1):\n if str(i)==str(i)[::-1]:\n ans += 1\nprint(ans)", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n numbers=[]\n a,b = map(int,input().split())\n numbers=list(range(a,b+1))\n count=0\n\n for number in numbers:\n if str(number)[0]==str(number)[-1] and str(number)[1]== str(number)[3]:\n count+=1\n print(count)\n\ndef __starting_point():\n main()\n__starting_point()", "A, B = map(int, input().split())\n\ncnt = 0\n\nfor i in range(A, B+1):\n l = list(str(i))\n if l[0] == l[4] and l[1] == l[3]:\n cnt += 1\n\nprint(cnt)", "a,b=input().split()\na=int(a)\nb=int(b)\nc=0\nfor i in range(a,b+1):\n if (i//10000)==(i-(i//10)*10) and (i//1000-(i//10000)*10) ==(i//10-(i//100)*10):\n c=c+1\nprint(c)", "A,B = map(int, input().split())\ncount = 0\nfor i in range(A,B+1):\n i = str(i)\n if i == i[::-1]:\n count += 1\nprint(count)", "a, b = map(int, input().split())\n\nres = 0\nfor n in range(a, b+1):\n s = str(n)\n if(s == s[::-1]): res += 1\n\nprint(res)", "a, b = list(map(int, input().split()))\n\ncnt = 0\n\nfor i in range(a, b + 1):\n if str(i) == str(i)[::-1]:\n cnt += 1\n\nprint(cnt)\n", "A, B = map(int,input().split())\nans = 0\n\nfor i in range(A, B+1):\n num = str(i)\n #print(i,num[0:2],num[::-1][0:2])\n if num[0:2] == num[::-1][0:2]:\n ans += 1\nprint(ans)", "a, b = map(int, input().split())\ncount = 0\nfor i in range(a,b+1):\n if list(map(int, list(str(i)))) == list(reversed(list(map(int, list(str(i)))))):\n count += 1\nprint(count)", "a, b = map(int,input().split())\ncount = 0\nfor i in range(1,10):\n for j in range(10):\n for k in range(10):\n if a <= 10000*i+1000*j+100*k+10*j+i <= b:\n count += 1\nprint(count)", "A, B = map(int, input().split())\nres = 0\nfor i in range(A, B+1):\n if str(i) == str(i)[::-1]:\n res += 1\n \nprint(res)", "a, b = map(int, input().split())\n\ncnt = 0\nfor i in range(a, b+1):\n str_i = str(i)\n if str_i[0] == str_i[4] and str_i[1] == str_i[3]:\n cnt += 1\nprint(cnt)", "a,b = map(int, input().split())\ncnt = 0\n\nfor i in range(a,b+1):\n if str(i) == str(i)[::-1]:\n cnt += 1\nprint(cnt)", "a, b = list(map(int, input().split()))\ncnt = 0\nfor i in range(a, b+1):\n s = str(i)\n if s[0] == s[4] and s[1] == s[3]:\n cnt += 1\n\nprint(cnt)\n"] | {"inputs": ["11009 11332\n", "31415 92653\n"], "outputs": ["4\n", "612\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 20,774 | |
e9c2fea75c616c1078b54c5fd1836387 | UNKNOWN | AtCoDeer the deer recently bought three paint cans.
The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.
Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.
Since he is forgetful, he might have bought more than one paint can in the same color.
Count the number of different kinds of colors of these paint cans and tell him.
-----Constraints-----
- 1β¦a,b,cβ¦100
-----Input-----
The input is given from Standard Input in the following format:
a b c
-----Output-----
Print the number of different kinds of colors of the paint cans.
-----Sample Input-----
3 1 4
-----Sample Output-----
3
Three different colors: 1, 3, and 4. | ["a=list(map(int,input().split()))\nprint(len(set(a)))", "s = list(map(int,input().split()))\nprint(len(set(s)))", "lst = input().split()\nif len(lst) == len(set(lst)):\n\tprint('3')\nif len(lst)-1 == len(set(lst)):\n\tprint('2')\nif len(lst)-2 == len(set(lst)):\n\tprint('1')\n", "l = input().split()\nprint((len(set(l))))\n", "print(len(set(input().split())))", "L=set(list(map(int,input().split())))\nprint(len(L))", "paint_list = set(map(int,input().split()))\nprint(len(paint_list))", "paint_list = map(int,input().split())\nprint(len(set(paint_list)))", "print(len(set(input().split())))", "a,b,c=input().split()\nls=[a,b,c]\nls.sort()\nif ls[0]==ls[1]==ls[2]:\n print(\"1\")\nelse:\n if ls[0]==ls[1]:\n print(\"2\")\n else:\n if ls[1]==ls[2]:\n print(\"2\")\n else:\n print(\"3\")", "print(len(set(input().split())))", "print(len(set(map(int, input().split()))))", "abc =list(input().split())\n\nprint(len(set(abc)))", "#!/usr/bin/env python3\nl = list(map(int, input().split()))\nl = set(l)\nprint((len(l)))\n", "a, b, c = map(int, input().split())\nif a == b == c: print(1)\nelif a == b or b == c or c == a: print(2)\nelse: print(3)", "s = set()\nl = list(input().split())\nfor e in l:\n s.add(e)\nprint(len(s))", "a, b, c = list(map(int, input().split()))\ndata = [a]\nif not b in data:\n data.append(b)\nif not c in data:\n data.append(c)\nprint(len(data))", "print(len(set(input().split())))", "print(len(set(map(int, input().split()))))", "#\n# abc046 a\n#\n\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"3 1 4\"\"\"\n output = \"\"\"3\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"3 3 33\"\"\"\n output = \"\"\"2\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n a, b, c = list(map(int, input().split()))\n\n ans = 0\n if a == b == c:\n print(\"1\")\n elif a == b or b == c or c == a:\n print(\"2\")\n else:\n print(\"3\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "print((len(set(input().split()))))\n", "abc=list(map(int,input().split()))\nprint(len(set(abc)))", "a, b, c = map(int, (input().split()))\nprint(len(set([a, b, c])))", "a,b,c=map(int,input().split())\n\nif a==b and b==c:\n ans=1\nelif a==b and b!=c:\n ans=2\nelif a!=b and b==c:\n ans=2\nelif a==c and a!=b:\n ans=2\nelse:\n ans=3\nprint(ans)", "abc=list(map(int , input().split()))\ncount=0\nfor i in range(0,len(abc)-1):\n abc.sort()\n if(abc[i] != abc[i+1]):\n count+=1\n \n \n \n \nprint(count+1)", "a = list(input().split())\nans = len(set(a))\nprint(ans)", "a,b,c=map(int,input().split())\nans=1\nif b!=a:ans+=1\nif a!=c and b!=c:ans+=1\nprint(ans)", "s=set(map(int,input().split()))\nprint(len(s))", "A = list(map(int, input().split()))\nNum = [0]*101\ncnt = 0\nfor i in A:\n Num[i] += 1\n if Num[i] == 1:\n cnt +=1\n \nprint(cnt)", "print(len(set([int(i) for i in input().split()])))", "print(len(set(input().split())))", "a, b, c = map(int, input().split())\nm = set([a, b, c])\nprint(len(m))", "arr = list(map(int, input().split()))\nprint(len(set(arr)))", "l = list(map(int, input().split()))\nprint(len(set(l)))", "abc = list(map(int,input().split()))\nset_abc = set(abc)\nprint(len(set_abc))", "print(len(set(input().split())))", "def main():\n c = list(map(int, input().split()))\n\n c_set = set(c)\n print((len(c_set)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "print((len(set(map(int, input().split())))))\n", "a, b, c = map(int, input().split())\n\nif a == b and b == c:\n print(1)\nelif a == b and b != c:\n print(2)\nelif a != b and b == c:\n print(2)\nelif a == c and a != b:\n print(2)\nelif a != b and b != c:\n print(3)", "a, b, c = map(int,input().split())\nif a == b == c:\n print(1)\nelif a == b or b == c or c == a:\n print(2)\nelse:\n print(3)", "a,b,c = map( int, input().split())\nif a == b == c :\n print(1)\nelif a!=b==c or b!=c==a or c!=a==b :\n print(2)\nelse:\n print(3)", "a,b,c=map(int,input().split())\nprint(len(set([a,b,c])))", "print(len(set(map(int, input().split()))))", "print(len(set(map(int,input().split()))))", "a=set(map(int,input().split()))\nprint(len(a))", "a=set(map(int,input().split()))\nprint(len(a))", "a=list(map(int, input().split())) \nprint(len(set(a)))", "a = list(map(int, input().split()))\nprint(len(set(a)))", "print((len(set(map(int, input().split())))))\n", "a = list(map(int, input().split()))\n\ns = set(a)\nprint(len(s))", "a = input().split()\nif a[0] == a[1] == a[2]:\n print(1)\nelif a[0] == a[1] or a[1] == a[2] or a[2] == a[0]:\n print(2)\nelse:\n print(3)", "li=a,b,c=list(map(int,input().split()))\nprint(len(set(li)))", "a, b, c = list(map(int, input().split()))\n\nif a == b == c:\n print((1))\nelif a == b or b == c or a == c:\n print((2))\nelse:\n print((3))\n", "a = list(map(int, input().split()))\na = set(a)\nprint(len(a))", "a, b, c = map(int, input().split())\n\nprint(len(set([a, b, c])))", "a = list(map(int,input().split()))\n\nprint(len(set(a)))", "a,b,c=map(int,input().split())\nprint(len(set([a,b,c])))", "print(len(set(list(map(int,input().split())))))", "#ABC046\ns = input().split()\nprint(len(set(s)))", "a,b,c = map(int,input().split())\nprint(len(set([a,b,c])))", "al = list(map(int, input().split()))\nprint((len(set(al))))\n\n", "def solve():\n print(len(set(input().split())))\n\n\ndef __starting_point():\n solve()\n__starting_point()", "C=list(map(int,input().split()))\nC=set(C)\nprint(len(C))", "print(len(set(input().split())))", "import collections\n\nn = list(input().split())\n\nc = collections.Counter(n)\n\nprint(len(c))", "a = set(map(int,input().split()))\n\nprint((len(a)))\n\n", "import numpy as np\narray = list(map(int, input().split(' ')))\nprint(len(np.unique(array)))", "\ns = input().split()\ns = set(s)\n\nprint(len(s))", "a,b,c=map(int,input().split())\n\nif a==b==c:\n print(\"1\")\nelif a==b or b==c or c==a:\n print(\"2\")\nelse:\n print(\"3\")", "a=set(input().split())\nprint(len(a))", "a, b, c = map(int, input().split())\nif a == b and b == c:\n print(1)\nelif a != b and b != c and c != a:\n print(3)\nelse:\n print(2)", "a,b,c=map(int,input().split())\nif a==b==c:\n print(\"1\")\nelif a!=b and a!=c and b!=c:\n print(\"3\")\nelse:\n print(\"2\")", "a = list(input().split())\nif a[0] == a[1] and a[1] == a[2]:\n print(1)\nelif a[0] == a[1] or a[1] == a[2] or a[2] == a[0]:\n print(2)\nelse:\n print(3)", "data=list(input().split())\ns=1\nfor i in range(1,len(data)):\n for j in range(0,i):\n if data[i]==data[j]:\n data[i]=-1\n if data[i]!=-1:\n s=s+1 \nprint(s)\n\n", "a = list(input().split())\nprint(len(set(a)))", "a = list(map(int, input().split()))\nprint(len(set(a)))", "import collections\ncolor = map(int, input().split())\nprint(len(collections.Counter(color)))", "def iroha():\n a, b, c = list(map(int, input().split()))\n if a == b and b == c and a == c:\n print((1))\n elif a != b and b != c and a != c:\n print((3))\n else:\n print((2))\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "a, b, c=map(int, input().split(\" \"))\nink=[a, b, c]\nprint(len(set(ink)))", "N = map(int,input().split())\nprint(len(set(N)))", "penki=list(map(int,input().split()))\nans=len(set(penki))\nprint(ans)", "import numpy as np\na = list(map(int, input().split()))\n\n\nprint((len(set(a))))\n", "print(len(set(map(int, input().split()))))", "a = [*map(int,input().split())]\nprint(len(set(a)))", "paint_list = input().split()\nprint(len(set(paint_list)))", "ary = list(map(int, input().split()))\nprint(len(set(ary)))", "paint = map(int,input().split())\nprint(len(set(paint)))", "print(len(set(map(int,input().split()))))", "a,b,c = map(int,input().split())\nif a == b == c:\n print(1)\nelif a == b or b == c or c == a:\n print(2)\nelse:\n print(3)", "l = list(map(int, input().split()))\nprint(len(set(l)))", "a,b,c=map(int,input().split())\ns={a,b,c}\nprint(len(s))", "a = list(map(int, input().split()))\n\nprint(len(set(a)))", "a, b, c = map(int, input().split())\ncount = 3\n\nif a == b == c:\n print(1)\n return\nif a == b:\n count -=1\nif a == c:\n count -=1\nif b == c:\n count -=1\nprint(count)", "a = map(int, input().split())\npaint_list = list(a)\n\nif paint_list[0] == paint_list[1] == paint_list[2]:\n print(1)\nelif paint_list[0] == paint_list[1] and paint_list[0] != paint_list[2]:\n print(2)\nelif paint_list[0] == paint_list[2] and paint_list[0] != paint_list[1]:\n print(2)\nelif paint_list[1] == paint_list[2] and paint_list[0] != paint_list[1]:\n print(2)\nelse:\n print(3)", "def si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lint(): return list(map(int, input().split()))\ndef lint_dec(): return list(map(lambda x:int(x) - 1, input().split()))\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef dfs_input(G, m):\n for _ in range(m):\n a, b = lint_dec()\n G[a].append(b)\n G[b].append(a)\n\n\n###################################\nprint(len(set(lint())))", "str_line = input().split(\" \")\nnum_line = [int(n) for n in str_line]\n\nnum_line.sort()\nnum_list = [num_line[0]]\nfor i in range(1,len(num_line)):\n if num_line[i] != num_line[i-1]:\n num_list.append(num_line[i])\n\n#print(num_list)\nprint(len(num_list))", "import sys\ninput = lambda: sys.stdin.readline().rstrip()\n\ndef main():\n x = list(map(int, input().split()))\n print(len(set(x)))\n \ndef __starting_point():\n main()\n__starting_point()", "a, b, c = map(int, input().split())\nst = set()\nst.add(a)\nst.add(b)\nst.add(c)\nprint(len(st))", "a, b, c = list(map(int, input().split()))\nL = []\nL.append(a)\nL.append(b)\nL.append(c)\n\nL = list(set(L))\n\nprint((len(L)))\n", "a, b, c = list(map(int, input().split()))\n\nif a == b:\n if b == c:\n print((1))\n else:\n print((2))\nelif b == c:\n print((2))\nelif a == c:\n print((2))\nelse:\n print((3))\n"] | {"inputs": ["3 1 4\n", "3 3 33\n"], "outputs": ["3\n", "2\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 10,658 | |
eb44ed541080f4b81506c1c2e9cb8399 | UNKNOWN | Snuke has N sticks.
The length of the i-th stick is l_i.
Snuke is making a snake toy by joining K of the sticks together.
The length of the toy is represented by the sum of the individual sticks that compose it.
Find the maximum possible length of the toy.
-----Constraints-----
- 1 \leq K \leq N \leq 50
- 1 \leq l_i \leq 50
- l_i is an integer.
-----Input-----
Input is given from Standard Input in the following format:
N K
l_1 l_2 l_3 ... l_{N}
-----Output-----
Print the answer.
-----Sample Input-----
5 3
1 2 3 4 5
-----Sample Output-----
12
You can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length. | ["N,K=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort(reverse=True)\nsum=0\nfor i in range(K) :\n sum+=l[i]\nprint(sum)", "n,k=map(int,input().split())\ndata=list(map(int,input().split()))\ny=sorted(data)\ns=0\nfor i in range(0,k):\n s=s+y[n-1-i]\nprint(s)", "n,k=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort()\nal=sum(l)\nfor i in range(n-k):\n al -= l[i]\nprint(al)", "n, k = map(int, input().split())\nl = list(map(int, input().split()))\n\nl = sorted(l, reverse=True)\nprint(sum(l[:k]))", "n, k = map(int, input().split())\nl = [int(s) for s in input().split()]\n\nl.sort(reverse=True)\nlength = 0\nfor i in range(k):\n length += l[i]\nprint(length)", "n,k=list(map(int,input().split()))\nL=list(map(int,input().split()))\nL.sort()\ns=0\nfor i in range(n-k):\n s+=L[i]\n\nprint((sum(L)-s))\n", "n,k=map(int, input().split())\nl=list(map(int, input().split()))\nl.sort(reverse=True)\nprint(sum(l[:k]))", "a, b = list(map(int, input().split()))\nfinal = list(map(int, input().split()))\n\nfinal.sort(reverse = True)\nprint((sum(final[:b])))\n", "n,k=list(map(int,input().split()))\nl=list(map(int,input().split()))\n\nL=sorted(l)\n\nprint((sum(L[(n-k):])))\n\n", "# \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u306e\u6574\u6570\u306e\u5165\u529b\nn, k = map(int, input().split())\n# \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u306e\u6574\u6570\u306e\u5165\u529b\ndata = list(map(int, input().split()))\nl = sorted(data, reverse=True)\nans = 0\n\nfor i in range(k):\n ans += l[i]\n\nprint(ans)", "a,b=input().split()\na=int(a)\nb=int(b)\nc=list(map(int,input().split()))\nc.sort()\nd=0\nfor i in range(b):\n d=d+c[-i-1]\nprint(d)", "N, K = map(int, input().split())\nl = list(map(int, input().split()))\nl.sort()\nprint(sum(l[-K:]))", "n,k = map(int,input().split())\nl = list(map(int,input().split()))\nl.sort(reverse = True)\nans = 0\nfor i in range(k):\n ans += l[i]\nprint(ans)", "N, K = map(int, input().split())\nls = list(map(int, input().split()))\nprint(sum(sorted(ls, reverse=True)[:K]))", "N, K = list(map(int, input().split()))\nprint((sum(sorted(map(int, input().split()), reverse=True)[:K])))\n", "from typing import List\n\n\ndef answer(n: int, k: int, l: List[int]) -> int:\n l.sort(reverse=True)\n return sum(l[:k])\n\n\ndef main():\n n, k = list(map(int, input().split()))\n l = list(map(int, input().split()))\n print((answer(n, k, l)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "# -*- coding: utf-8 -*-\n\nN, K = map(int, input().split())\nl = list(map(int, input().split()))\n\nl_sorted = sorted(l, reverse=True)\ntotal = 0\nfor i in range(K):\n total += l_sorted[i]\n\nprint(total)", "lst = input().split()\nN = int(lst[0])\nK = int(lst[1])\n\nL = input().split()\nfor i in range(N):\n L[i] = int(L[i])\n\nL.sort(reverse=True)\n\nans = 0\n\nfor i in range(K):\n ans += L[i]\n\nprint(ans)", "n,k = map(int,input().split())\ndata = list(map(int,input().split()))\ndata.sort(reverse = True)\nans = 0\nfor i in range(k):\n ans += data[i]\nprint(ans)", "n, k = list(map(int, input().split()))\nL = list(map(int,input().split()))\nprint((sum(sorted(L, reverse=True)[:k])))\n", "N, K = map(int, input().split())\nl = [int(l_) for l_ in input().split()]\nl.sort(reverse=True)\nprint(sum(l[0:K]))", "N,K = map (int, input ().split ())\nl = [int (x) for x in input().split()]\nlist.sort (l)\nx = 0\nfor i in range (K):\n x += l[-i-1]\nprint (x)", "N, K = map(int,input().split())\nl = list(map(int,input().split()))\n\nl.sort(reverse=True)\nl_max3 = l[0 : K]\nprint(sum(l_max3))", "n, k = map(int, input().split())\nl = sorted(list(map(int, input().split())), reverse=True)\nprint(sum(l[:k]))", "with open(0) as f:\n N, K, *l = map(int, f.read().split())\nl.sort(reverse=True)\nprint(sum(l[:K]))", "def abc067b_snake_toy():\n n, k = map(int, input().split())\n l = sorted(list(map(int, input().split())), reverse=True)\n print(sum(l[0:k]))\n\nabc067b_snake_toy()", "n,k = list(map(int, input().split()))\nli = list(map(int, input().split()))\nli.sort(reverse=True)\nsum = 0\nfor i in range(k):\n sum += li[i]\nprint(sum)\n\n", "_,k,*l=map(int,open(0).read().split())\nl.sort(reverse=True)\nprint(sum(l[:k]))", "n, k = map(int, input().split())\nl = list(map(int, input().split()))\nl.sort()\nprint(sum(l[-k:]))", "n,k = map(int, input().split())\na = list(map(int, input().split()))\na.sort()\nprint(sum(a[-k:]))", "N, K = list(map(int, input().split()))\nL = sorted(list(map(int, input().split())), reverse=True)\nans = 0\nfor i in range(K):\n ans += L[i]\nprint(ans)\n", "N, K = map(int, input().split())\nl = sorted(list(map(int, input().split())))\nl.reverse()\n\n\nprint(sum(l[:K]))", "n, k = map(int,input().split())\na = list(map(int,input().split()))\na.sort(reverse=True)\n\nans = 0\nfor i in range(k):\n ans += a[i]\nprint(ans)", "n, k = map(int, input().split())\nl = list(map(int, input().split()))\nl.sort(reverse = True)\ncnt = 0\nfor i in range(k):\n cnt += l[i]\nprint(cnt)", "n, k = map(int, input().split())\nL = sorted(list(map(int, input().split())), reverse=True)\n\nprint(sum(L[0:k]))", "n,k=list(map(int ,input().split()))\nl=list(map(int ,input().split()))\nans=0\nsorted_l=l.sort()\nl.reverse()\nfor i in range(0,k):\n\tans+=l[i]\n\t\nprint(ans)\n", "N, K = list(map(int, input().split()))\nL = sorted(list(map(int, input().split())), reverse=True)\n\nprint((sum(L[:K])))\n\n\n", "n,k=map(int, input().split())\nl=list(map(int,input().split()))\nl.sort()\nl.reverse()\nassert l.__len__()==n\nans=0\nfor i in range(k):\n ans+=l[i]\nprint(ans)", "n,k = map(int, input().split())\nl = list(map(int, input().split()))\nl.sort(reverse=True)\nprint(sum(l[0:k]))", "N, K = map(int, input().split())\nl = sorted(map(int, input().split()))[::-1]\nsum = 0\ncount = 0\n\nfor L in l:\n count += 1\n sum += L\n if count == K:\n break\n \nprint(sum)", "N_hon, K_part = map(int, input().split())\nlength = list(map(int, input().split()))\n\nlength.sort()\nans = sum(length[-K_part:])\n\nprint(ans)", "N, K = map(int, input().split())\nnum_list = list(map(int, input().split()))\n\nprint(sum(sorted(num_list, reverse=True)[:K]))", "import sys\nfrom typing import List\n\nn, k = list(map(int, input().split()))\nll = list(map(int, input().split()))\n\nbar = sorted(ll)[::-1]\n#bar2 = bar[::-1]\nans = sum(bar[0:k])\n\nprint(ans)\n", "n,k = map(int,input().split())\nl = sorted(list(map(int,input().split())),reverse=True)\nprint(sum(l[:k]))", "n, k = map(int, input().split())\nl = list(map(int, input().split()))\nl = sorted(l)\nx = 0\nfor i in range(-1, -1-k, -1):\n x += l[i]\nprint(x)", "N, K = map(int, input().split())\nl = list(map(int, input().split()))\nnew_l = sorted(l, reverse=True)\n\nprint(sum(new_l[0:K]))", "N, K = map(int,input().split())\nL = list(map(int,input().split()))\nL.sort(reverse=True)\n\nprint(sum(L[:K]))", "n, k = map(int, input().split())\nlst = list(map(int, input().split()))\nlst.sort(reverse = True)\nans = 0\nfor i in range(0, k):\n ans += lst[i]\n\nprint(ans)", "N, K=list(map(int, input().split()))\nl=list(map(int, input().split()))\nl.sort()\nprint((sum(l[-K:])))\n", "n, k = list(map(int, input().split()))\nl = sorted(list(map(int, input().split())), reverse=True)\nres = l[:k]\nprint((sum(res)))\n", "n,k=map(int,input().split())\nl=list(map(int,input().split()))\n\nl2=sorted(l, reverse=True)\nlength = sum(l2[0:k])\nprint(length)", "n,k = map(int,input().split())\na = sorted(map(int,input().split()))\na.reverse()\nprint(sum(a[:k]))", "# -*- coding: utf-8 -*-\n\nN,K = list(map(int, input().split()))\nj = list(map(int, input().split()))\nans = 0\n\nj.sort()\nfor i in range(K):\n ans += j.pop()\n\nprint(ans)\n", "#n = int(input())\nn, k = list(map(int, input().split()))\nl = list(map(int, input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n\nl.sort(reverse=True)\nprint((sum(l[:k])))\n", "n,k=map(int, input().split())\nl=list(map(int,input().split()))\nl.sort()\nprint(sum(l[-k:]))", "N, K = list(map(int, input().split()))\nl = sorted(map(int, input().split()), reverse=True)\n\nans = 0\nfor i in range(K):\n ans += l[i]\nprint(ans)\n", "n,k = map(int,input().split())\na = sorted(map(int,input().split()))[::-1]\nprint(sum(a[:k]))", "n,k=map(int,input().split())\nl=[int(x) for x in input().split()]\nl.sort(reverse=True)\nprint(sum(l[0:k]))", "n, k = map(int, input().split())\nl = list(map(int, input().split()))\n\n\nl.sort(reverse=True)\nans = sum(l[:k])\n\nprint(ans)", "n, k = (int(x) for x in input().split())\nL = [int(x) for x in input().split()]\nans = sum(sorted(L, reverse=True)[:k])\nprint(ans)", "N,K=map(int,input().split())\nl=list(map(int,input().split()))\nl.sort(reverse=True)\nprint(sum(l[0:K]))", "a,b=map(int,input().split())\nc=input().split()\nc=[int(i) for i in c]\nx=0\nc.sort()\nfor i in range(b):\n x+=c[len(c)-i-1]\nprint(x)", "n, k = map(int, input().split())\nl = list(map(int, input().split()))\nprint(sum(sorted(l, reverse=True)[0:k]))", "\nN, K = map(int, input().split())\nl = sorted(list(map(int, input().split())), reverse=True)\nprint(sum(l[:K]))", "n,k = map(int,input().split())\nli = list(map(int,input().split()))\nli.sort(reverse=True)\ntol = 0\nfor i in range(k):\n tol += li[i]\nprint(tol)", "N, K = map(int, input().split())\nl = [int(x) for x in input().split()]\nl.sort()\nl.reverse()\nans = 0\nfor i in range(K):\n ans += l[i]\nprint(ans)", "a,b = list(map(int,input().split()))\ni = sorted(list(map(int,input().split())))\n\nprint((sum(i[-b:])))\n\n", "N,K = map(int,input().split())\nl = list(sorted(map(int,input().split())))[::-1]\n\nprint(sum(l[:K]))", "N,K=map(int,input().split())\nL=list(map(int,input().split()))\nL.sort(reverse=True)\nprint(sum(L[:K]))", "n, k = map(int, input().split())\ns = list(map(int, input().split()))\ns.sort()\nprint(sum(s[n-k:]))", "n, k = map(int, input().split())\nl = list(map(int, input().split()))\nl_sort = sorted(l)\nprint(sum(l_sort[-k:]))", "n, k = list(map(int, input().split(' ')))\nlength = list(map(int, input().split(' ')))\nlength.sort(reverse=True)\nmax_length = sum(length[:k])\nprint(max_length)\n\n", "n, k = map(int, input().split())\na = list(map(int, input().split()))\na.sort(reverse = True)\nsum = 0\nfor i in range(k):\n sum = sum + a[i]\nprint(sum)", "N,K = list(map(int, input().split()))\nS = list(map(int, input().split()))\n\nS = sorted(S,reverse=True)\n\nprint((sum(S[:K])))\n", "#!/usr/bin/env python3\n\n\ndef main():\n N, K, *L = list(map(int, open(0).read().split()))\n L.sort()\n print((sum(L[-K:])))\n\n\nmain()\n", "n, k = map(int, input().split())\nl = sorted(list(map(int, input().split())),reverse=True)\nprint(sum(l[:k]))", "n,k = map(int,input().split())\nl = list(map(int,input().split()))\nl.sort(reverse=True)\nprint(sum(l[:k]))", "N, K = map(int,input().split())\nl = list(map(int,input().split()))\n\nl.sort(reverse=True)\nsnake = []\n\nfor i in range(K):\n snake.append(l[i])\n\nprint(sum(snake))", "n, k = list(map(int, input().split()))\na = [int(i) for i in input().split()]\n\na.sort(reverse=True)\nprint((sum(a[:k])))\n", "N, K = map(int, input().split())\nL = list(map(int, input().split()))\n\nL.sort()\nL.reverse()\n\nprint(sum(L[:K]))", "# coding: utf-8\n\nnum, choose_num = map(int, input().split())\ntotal = 0\nstick_length = input().split(\" \")\n\nstr_num = [int(n) for n in stick_length]\nlist.sort(str_num, reverse=True)\n\nfor i in range(choose_num):\n total += str_num[i]\n\nprint(total)", "n,k=map(int,input().split())\na=list(map(int,input().split()))\na.sort(reverse=True)\nans = 0\nfor i in range(k):\n ans += a[i]\nprint(ans)", "k = list(map(int, input().split()))[1]\nls = list(sorted(list(map(int, input().split()))))\nprint((sum(ls[len(ls) - k:])))\n", "n, k = map(int, input().split())\nl = list(map(int, input().split()))\n\nl_sorted = sorted(l, reverse = True)\nsnake = 0\nfor i in range(k):\n snake += l_sorted[i]\nprint(snake)", "N, K = list(map(int, input().split()))\nl = list(map(int, input().split()))\nl.sort()\nSum = 0\n\nfor i in range(K):\n Sum += l[N - i - 1]\n\nprint(Sum)\n", "N,K=list(map(int,input().split()))\nl=list(map(int,input().split()))\nl.sort()\nprint((sum(l[N-K:N])))\n", "a,b=list(map(int,input().split()))\nN = sorted(list(map(int,input().split())))[::-1]\nprint((sum(N[:b])))\n", "N, K = map(int, input().split())\nL = list(map(int, input().split()))\n\nL = sorted(L, reverse=True)\nprint(sum(L[:K]))", "a,b=map(int,input().split())\nle=list(map(int,input().split()))\nle.sort()\ngou=0\nfor i in range(b):\n gou+=le.pop()\nprint(gou)", "N, K = [int(x) for x in input().split()]\nl = [int(x) for x in input().split()]\n\ns = sorted(l)\n\nans = sum(s[N - K:])\n\nprint(ans)", "n, k = map(int, input().split())\nl = sorted(list(map(int, input().split())))[::-1]\n\nprint(sum(l[:k:]))", "N,K = list(map(int, input().split()))\nlengths_list = list(map(int, input().split()))\nlengths_list.sort()\nlengths_list.reverse()\nsum_length = 0\nfor i in range(K):\n sum_length += lengths_list[i]\n\nprint(sum_length)\n", "n, k = map(int, input().split())\nlst = list(map(int, input().split()))\n\nlst = sorted(lst)\nprint(sum(lst[(-1) * k:]))", "_,k=map(int,input().split());print(sum(sorted(map(int,input().split()))[-k:]))", "# B - Snake Toy\ndef main():\n _, k = map(int, input().split())\n l = list(map(int, input().split()))\n cnt = 0\n l.sort(reverse=True)\n\n for i in range(k):\n cnt += l[i]\n else:\n print(cnt)\n\n\n\nif __name__ == \"__main__\":\n main()", "#!/usr/bin/env python3\nN, K = list(map(int, input().split()))\nL = sorted(list(map(int, input().split())))\nprint((sum(L[-K:])))\n", "n, k = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\na.sort()\nprint(sum(a[n-k:n]))", "N, K = list(map(int, input().split()))\nL = list(map(int, input().split()))\n\nL.sort()\nprint((sum(L[-K:])))\n", "n,k=map(int,input().split())\ns=list(map(int,input().split()))\ns.sort(reverse=True)\n\nprint(sum(s[0:k]))", "n,k = map(int, input().split())\nl = list(map(int, input().split()))\nl.sort(reverse=True)\nprint(sum(l[:k]))"] | {"inputs": ["5 3\n1 2 3 4 5\n", "15 14\n50 26 27 21 41 7 42 35 7 5 5 36 39 1 45\n"], "outputs": ["12\n", "386\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 14,171 | |
9db2a84571798cd2143e07aeaa13cb68 | UNKNOWN | Snuke lives at position x on a number line.
On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B.
Find out which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented by |s-t|.
-----Constraints-----
- 1 \leq x \leq 1000
- 1 \leq a \leq 1000
- 1 \leq b \leq 1000
- x, a and b are pairwise distinct.
- The distances between Snuke's residence and stores A and B are different.
-----Input-----
Input is given from Standard Input in the following format:
x a b
-----Output-----
If store A is closer, print A; if store B is closer, print B.
-----Sample Input-----
5 2 7
-----Sample Output-----
B
The distances between Snuke's residence and stores A and B are 3 and 2, respectively.
Since store B is closer, print B. | ["x, a, b = (int(x) for x in input().split())\nif abs(a-x) < abs(b-x):\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = map(int, input().split())\nif abs(x - a) < abs(x - b): print('A')\nelse: print('B')", "x, a, b = map(int, input().split())\nprint(\"AB\"[abs(x-a)>abs(x-b)::2])", "x,a,b = map(int,input().split())\n\nif abs(x-a) < abs(x-b):\n print('A')\nelse:\n print('B')", "x,a,b = map(int,input().split())\nprint(\"A\" if abs(x-a) < abs(x-b) else \"B\")", "x,a,b = map(int,input().split())\nif abs(a-x)>abs(b-x):\n print(\"B\")\nelse:\n print(\"A\")", "a = [int(x) for x in input().split()]\nif abs(a[1] - a[0]) > abs(a[2] - a[0]):\n print(\"B\")\nelse:\n print(\"A\")", "x, a, b = map(int, input().split())\n\nprint(\"B\" if abs(x-a) > abs(x-b) else \"A\")", "x, a, b = map(int, input().split())\nprint(\"BA\"[abs(a - x) < abs(b - x)])", "x, a, b = map(int, input().split())\nif abs(x-a)>abs(x-b):\n print('B')\nelse:\n print('A')", "x,a,b=map(int,input().split(\" \"))\nprint(\"A\") if abs(a-x)<abs(b-x) else print(\"B\")", "x, a, b = list(map(int, input().split()))\nif abs(x-a) > abs(x-b):\n print('B')\nelse:\n print('A')\n\n", "x, a, b = map(int, input().split())\nprint('A' if abs(x-a) < abs(x-b) else 'B')", "def main():\n x, a, b = list(map(int, input().split()))\n print(('A' if abs(x - a) < abs(x - b) else 'B'))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "x,a,b = map(int,input().split())\nif abs(x - a) < abs(x - b):\n print('A')\nelse:\n print('B')", "x,a,b=map(int,input().split())\nprint('A' if abs(a-x)<abs(b-x) else 'B')", "x, a, b = map(int, input().split())\nprint('B' if abs(b-x) < abs(a-x) else 'A')", "x,a,b=map(int,input().split())\nif abs(x-a)<abs(x-b):\n print(\"A\")\nelse:\n print(\"B\")", "x,a,b=map(int,input().split())\nprint(\"A\") if abs(x-a)<abs(x-b) else print(\"B\")", "x,a,b=list(map(int,input().split()))\n\nif abs(x-a) >= abs(x-b):\n print('B')\nelse:\n print('A')", "x, a, b = map(int, input().split())\nif abs(x-a) < abs(x-b):\n print('A')\nelse:\n print('B')", "x,a,b=map(int,input().split())\nif abs(a-x)<abs(b-x):\n print(\"A\")\nelse:\n print(\"B\")", "x,a,b = map(int,input().split())\nprint('A' if abs(x-a) < abs(x-b) else 'B')", "x,a,b=map(int,input().split())\n\nif abs(x-a)>abs(x-b):\n ans='B'\nelse:\n ans='A'\nprint(ans)", "a,b,c = map(int,input().split())\n\nif abs(a-b) < abs(a-c):\n print('A')\nelse:\n print('B')", "x, a, b = map(int, input().split())\nif abs(x-a) < abs(x-b):\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = list(map(int, input().split()))\nif abs(x - a) > abs(x - b):\n print(\"B\")\nelse:\n print(\"A\")\n", "x,a,b=map(int,input().split())\nprint('A' if abs(x-a)<abs(x-b) else 'B')", "x,a,b = map(int,input().split())\nif abs(a-x) < abs(b-x):\n print('A')\nelse:\n print('B')", "x,a,b=map(int,input().split())\n\nif abs(x-a)>=abs(x-b):\n print('B')\n \nelse:\n print('A')", "a,b,c = map(int,input().split())\nif abs(a - b) < abs(a - c):\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = map(int, input().split())\nif abs(x - a) > abs(x - b):\n print('B')\nelse:\n print('A')", "x, a, b = list(map(int, input().split()))\nif abs(x-a) > abs(x-b):\n print(\"B\")\nelse:\n print(\"A\")\n", "x, a, b = map(int, input().split())\nar = abs(x - a)\nbr = abs(x - b)\n\nif br < ar:\n print(\"B\")\nelif br > ar:\n print(\"A\")", "x,a,b = map(int,input().split())\nif abs(a - x) > abs(b - x):\n print(\"B\")\nelse:\n print(\"A\")", "x,a,b= map(int,input().split())\nif abs(x-a)>abs(x-b):\n print(\"B\")\nelse:\n print(\"A\")", "x, a, b = map(int, input().split())\nla = abs(a - x)\nlb = abs(b - x)\nprint(\"A\" if la < lb else \"B\")", "x,a,b=map(int,input().split());print('AB'[abs(x-a)-abs(x-b)>=0])", "x,a,b=list(map(int,input().split()))\nif abs(x-a)<abs(x-b):\n print('A')\nelse:\n print('B')\n", "a, b, c = map(int, input().split())\n\nd = a-b\nif d < 0:\n d *= -1\ne = a-c\nif e < 0:\n e *= -1\n\nif d >= e:\n print(\"B\")\nelse:\n print(\"A\")", "x, a, b = map(int, input().split())\n\nA = abs(a - x)\nB = abs(b - x)\n\nif A < B:\n print('A')\nelse:\n print('B')", "x,a,b = map(int, input().split())\n\nprint(\"A\" if abs(x-a) < abs(x-b) else \"B\")", "x,a,b=map(int,input().split())\nif abs(a-x)<abs(b-x):\n print('A')\nelse:\n print('B')", "x, a, b = list(map(int, input().split()))\n\nif abs(x - a) < abs(x - b):\n print('A')\nelse:\n print('B')\n", "x,a,b = list(map(int,input().split()))\nif abs(x-a) < abs(x-b):\n print(\"A\")\nelif abs(x-a) > abs(x-b):\n print(\"B\")\n", "a,b,c=list(map(int,input().split()))\nif abs(a-b)<abs(a-c):\n print(\"A\")\nelse:\n print(\"B\")\n", "#n = int(input())\nx, a, b = list(map(int, input().split()))\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\nif abs(x-a) < abs(x-b):\n print('A')\nelse:\n print('B')\n", "x,a,b = map(int,input().split())\nif abs(x-a)<abs(x-b):\n print('A')\nelse:\n print('B')", "x, a, b = list(map(int, input().split()))\nprint((\"A\" if max(x, a) - min(x, a) < max(x, b) - min(x, b) else \"B\"))\n", "def iroha():\n x, a, b = list(map(int, input().split()))\n on = abs(x-a)\n off = abs(x-b)\n print((\"A\" if on < off else \"B\"))\n\n\n\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "X,A,B=map(int,input().split())\na=abs(X-A)\nb=abs(X-B)\nif a<b:\n ans=\"A\"\nelif b<a:\n ans=\"B\"\nprint(ans)", "x,a,b = map(int,input().split())\n\na = abs(a-x)\nb = abs(b-x)\n\nif a < b:\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = map(int, input().split())\nprint('A' if abs(x-a)<abs(x-b) else 'B')", "x, a, b = map(int, input().split())\nif abs(x - b) > abs(x - a):\n print('A')\nelse:\n print('B')", "x,a,b = map(int,input().split())\nprint(\"A\" if abs(x-a) < abs(x-b) else \"B\")", "x,a,b=map(int,input().split())\nif min(abs(x-a),abs(x-b))==abs(x-a):\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = list(map(int, input().split()))\nprint(('A' if abs(x - a) < abs(x - b) else 'B'))\n", "x, a, b = map(int, input().split())\nprint(\"A\" if abs(a - x) < abs(b - x) else \"B\")", "x, a, b = list(map(float,input().split()))\n\nif abs(x - a) < abs(x - b):\n print(\"A\")\nelse:\n print(\"B\")\n", "x,a,b = map(int,input().split())\nA = abs(x-a)\nB = abs(x-b)\n\nif A<=B:\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = list(map(int, input().split()))\nif abs(x - a) > abs(x - b):\n print('B')\nelse:\n print('A')", "x, a, b = list(map(int, input().split()))\nif abs(x-a)<abs(x-b):\n print(\"A\")\nelse:\n print(\"B\")\n", "x, a, b = map(int, input().split())\n\nif abs(x - a) < abs(x - b):\n print('A')\nelse:\n print('B')", "x, a, b = map(int, input().split())\nif abs(a-x) < abs(b-x):\n print('A')\nelse:\n print('B')", "x,a,b=map(int,input().split())\nA=abs(a-x)\nB=abs(b-x)\nprint('A' if A < B else 'B')", "x, a, b = map(int, input().split())\nif abs(x-a) > abs(x-b):\n print(\"B\")\nelse:\n print(\"A\")", "x,y,z=map(int,input().split())\nif abs(y-x) < abs(z-x):\n print(\"A\")\nelse:\n print(\"B\")", "lst = input().split()\n\nx = int(lst[0])\na = int(lst[1])\nb = int(lst[2])\n\ndef distance(p):\n return abs(p - x)\n\nif distance(a) < distance(b):\n print('A')\nelse:\n print('B')", "x,a,b=map(int,input().split())\nprint(\"A\" if abs(x-a) < abs(x-b) else \"B\")", "x,a,b=map(int,input().split())\nif abs(a-x)>abs(x-b):\n print(\"B\")\nelse:\n print(\"A\")", "x,a,b = map(int,input().split())\n\nif abs(x-a) <= abs(x-b):\n print('A')\n \nelse:\n print('B')", "x, a, b = map(int, input().split())\nif (x - a) ** 2 < (x - b) ** 2:\n print('A')\nelse:\n print('B')", "x, a, b = map(int, input().split())\nif abs(x-a) > abs(x-b):\n print(\"B\")\nelse:\n print(\"A\")", "x,a,b=map(int,input().split())\nif abs(a-x)>abs(b-x):print(\"B\")\nelse: print(\"A\")", "x,a,b = map(int,input().split())\nif abs(x-a) < abs(x-b):\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = map(int,input().split())\nprint('A') if abs(x-a) < abs(x-b) else print('B')\n", "x,a,b = map(int,input().split())\nprint(\"A\" if abs(b-x)>abs(a-x) else \"B\")", "x, a, b = (int(x) for x in input().split())\nif abs(a-x) < abs(b-x):\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = map(int, input().split())\nprint('A' if abs(x-a) < abs(x-b) else 'B')", "#ABC071A\nx,a,b = map(int,input().split())\nprint(\"A\" if abs(x-a) <= abs(x-b) else \"B\")", "x,a,b=map(int,input().split())\nif abs(x-a)>abs(x-b):print('B')\nelse:print('A')", "x,a,b=map(int,input().split())\nif abs(x-a)<abs(x-b) :\n print(\"A\")\nelse :\n print(\"B\")", "x,a,b=list(map(int,input().split()))\nif abs(x-a)<abs(x-b):\n print(\"A\")\nelse:\n print(\"B\")\n", "a, b, c = [int(x) for x in input().split()] \n\nif abs(a - b) > abs(a - c):\n print(\"B\")\nelse:\n print(\"A\")\n", "x,a,b = map(int,input().split())\nif abs(a-x)>=abs(b-x):\n print(\"B\")\nelse:\n print(\"A\")", "x,a,b = map(int, input().split())\nif abs(x-a) < abs(x-b):\n print(\"A\")\nelse:\n print(\"B\")", "x,a,b = map(int,input().split())\nif abs(x-a) > abs(x-b):\n print('B')\nelse:\n print('A')", "x,a,b = map(int,input().split())\nA = abs(x-a)\nB = abs(x-b)\n\nif A < B:\n print(\"A\")\nelse:\n print(\"B\")", "x,a,b=map(int,input().split())\nif abs(x-a)<abs(x-b):\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = list(map(int, input().split()))\n\na_x = abs(a - x)\nb_x = abs(b - x)\n\nif a_x < b_x:\n print('A')\nelse:\n print('B')\n", "x, a, b, = list(map(int, input().split()))\nprint((\"A\" if(abs(x-a) < abs(x-b)) else \"B\"))\n", "x, a, b = map(int, input().split())\nif abs(x-a) < abs(x-b):\n\tprint('A')\nelse:\n\tprint('B')", "#\n# abc071 a\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"5 2 7\"\"\"\n output = \"\"\"B\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"1 999 1000\"\"\"\n output = \"\"\"A\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n x, a, b = list(map(int, input().split()))\n if abs(x-a) > abs(x-b):\n print(\"B\")\n else:\n print(\"A\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "s_position, a_store, b_store = list(map(int, input().split()))\n\ndis_a_s = abs(a_store - s_position)\ndis_b_s = abs(b_store - s_position)\n\nif dis_b_s > dis_a_s:\n print('A')\nelif dis_a_s > dis_b_s:\n print('B')\n", "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nif abs(b-a)>abs(c-a):\n print(\"B\")\nelse:\n print(\"A\")", "x,a,b=map(int,input().split())\nif abs(x-a) <abs(x-b):\n print(\"A\")\nelse:\n print(\"B\")", "x, a, b = map(int, input().split())\nif abs(x-a)<abs(x-b):\n print('A')\nelse:\n print('B')", "x, a, b= map(int, input().split())\n\nprint('A' if abs(x - a) < abs(x - b) else 'B')", "with open(0) as f:\n x, a, b = map(int, f.read().split())\nprint('A' if abs(x-a) < abs(x-b) else 'B')", "x,a,b=map(int,input().split())\nif abs(x-a)>abs(x-b):\n print(\"B\")\nelse:\n print(\"A\")"] | {"inputs": ["5 2 7\n", "1 999 1000\n"], "outputs": ["B\n", "A\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 11,608 | |
ea7d77ce5bd5e3072020f3a086bafa1c | UNKNOWN | On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.
After finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.
-----Constraints-----
- S is a string of length 10.
- The first eight characters in S are 2017/01/.
- The last two characters in S are digits and represent an integer between 1 and 31 (inclusive).
-----Input-----
Input is given from Standard Input in the following format:
S
-----Output-----
Replace the first four characters in S with 2018 and print it.
-----Sample Input-----
2017/01/07
-----Sample Output-----
2018/01/07
| ["s=input()\nprint(\"2018\"+s[4:])", "def main():\n s = input()\n print(f\"2018{s[4:]}\")\n\n\nmain()", "print(input().replace('2017','2018'))", "y, m, d = list(map(str, input().split('/')))\nprint(('2018' + '/' + m + '/' + d))\n", "S = input()\nprint(S.replace('7', '8', 1))", "s = input()\nprint(s.replace('7', '8', 1))", "date_str = input()\n\nnew_data = date_str.replace('2017', '2018')\nprint(new_data)\n", "print((input().replace(\"2017\", \"2018\")))\n", "s = input()\nprint((s.replace('2017', '2018')))\n", "S = input()\nans = S[:3] + '8' + S[4:]\nprint(ans)", "S = input()\nprint(S.replace('2017', '2018'))", "s = input()\na = int(s[0])*1000+int(s[1])*100+int(s[2])*10+int(s[3])+1\nb = s[4]+s[5]+s[6]+s[7]+s[8]+s[9] \nprint((str(a)+b))\n\n", "s=input()\nprint(s[:3]+'8'+s[4:])", "s = input()\ns = s.replace(\"2017\",\"2018\")\nprint(s)", "s = list(input())\ns[3] = '8'\n\nprint((''.join([str(i) for i in s])))\n", "#!/usr/bin/env python3\n\n\ndef main():\n S = input()\n print((S[:3] + \"8\" + S[4:]))\n\n\nmain()\n", "print(input().replace('2017', '2018'))", "#ABC085A\ns = input()\nprint(\"2018\"+s[4:])", "S=input()\nprint(S.replace(\"2017\",\"2018\"))", "S=input()\nprint(\"2018\"+S[4:])", "S = input()\n\nprint(S.replace('2017', '2018'))", "s = input()\nprint(\"2018\"+s[4:])", "print('2018'+input()[4:])", "S = input()\n\nprint(S.replace(S[:4], \"2018\"))", "s=input()\nprint(\"2018\"+s[4:])", "print(input().replace('2017', '2018'))", "S = input()\nprint((\"2018\" + S[4:]))\n", "print((\"2018\"+input()[4:]))\n", "s=input()\nprint(s.replace(\"2017\",\"2018\"))", "s = list(input())\ns[3] = \"8\"\nprint(\"\".join(s))", "print(\"2018\"+input()[4:])", "print(f\"{2018}{input()[4:]}\")", "print('2018' + input()[4:])", "a=input()\nprint(a.replace(\"2017\",\"2018\"))", "s = input()\nprint(s[:3] + \"8\" + s[4:])", "s = list(input())\ns[3] = '8'\nprint((''.join(s)))\n", "print(\"2018\"+input()[4:])", "date = input()\n\ndate_list = list(date)\ndate_list[3] = '8'\noutput = ''.join(date_list)\n\nprint(output)", "s = str(input())\nprint(s[0:3] + \"8\" + s[4:])", "import sys\n \nS = sys.stdin.readline().strip()\nprint(\"2018\" + S[4:])", "date = list(input())\ndate[3] = \"8\"\nprint(\"\".join(map(str, date)))", "print(input().replace(\"2017\",\"2018\"))", "s=input()\nprint(\"2018\"+s[4:])", "print(input().replace(\"2017\",\"2018\"))", "S = input()\nprint(\"2018/01/\" + S[8:10])", "s=input()\nprint(s.replace(\"2017\",\"2018\"))", "S = input()\nprint(S.replace(\"2017\",\"2018\"))", "s = list(input())\ns[3] = \"8\"\nprint(\"\".join(s))", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\ns = list(str(input()))\ns[:4] = list(\"2018\")\n\nprint((\"\".join(s)))\n", "s = str(input())\nans = \"2018\" + s[4:]\nprint(ans)", "S = input()\nans = '2018/01/' + S[8:]\nprint(ans)\n", "s=input()\nprint(s.replace(\"2017\",\"2018\"))", "S = input()\n\nprint(S.replace('2017', '2018'))", "S=input()\na=S.split('/')\nb='2018/'+a[1]+'/'+a[2]\nprint(b)", "S = str(input())\n\nif S[3] == \"7\":\n S = S[:3] + \"8\" + S[4:]\nprint(S)\n", "s = input()\nprint((\"2018/01/\"+s[8:]))\n", "a = input()\nprint(a.replace('2017','2018'))", "s = input()\nprint(s[:3] + \"8\" + s[4:])", "S = str(input())\n\nprint(S.replace(S[0:4],\"2018\"))", "print(input().replace('2017', '2018'))", "s=list(input())\ns[3]=8\nfor i in s:\n print(i,end=\"\")\n", "S = input()\nS = list(S)\nS[3] = \"8\"\nprint((\"\".join(S)))\n\n", "moji = str(input())\nprint(moji.replace(\"2017\",\"2018\"))", "S = input()\nprint((S[:3]+\"8\"+S[4:]))\n", "s=str(input())\ns=s[4:]\nprint('2018'+s)", "# \u6587\u5b57\u5217\u306e\u5165\u529b\ns = input()\nprint(s.replace(\"2017\",\"2018\"))", "#85A\ns=list(input())\ns[3]='8'\nprint(''.join(s))", "s = list(input())\ns[3]=\"8\"\nprint(*s,sep=\"\")", "print(input().replace('017','018'))", "S = input()\n\n# count=1 \u306b\u3059\u308b\nprint((S.replace('7', '8', 1)))\n", "s = str(input())\n\nprint((\"2018\"+s[4:]))\n", "s = str(input())\nans = '2018' + s[4:]\nprint(ans)", "a=input().replace(\"2017\",\"2018\")\nprint(a)", "print(\"2018\"+input()[4:])", "S = str(input())\ns = \"2\"\nfor i in range(1,10):\n if i == 3:\n s+=\"8\"\n else:\n s+=S[i]\nprint(s)", "n = list(input())\n\nn[3] = \"8\"\n\nprint(\"\".join(n))", "s = input()\ns = s.replace('2017','2018')\nprint(s)", "S = input()\nanswer = S.replace(\"2017\", \"2018\")\nprint(answer)", "s=list(input())\ns[3]=8\nfor i in s:\n print(i,end=\"\")\n", "S = input()\nprint((\"2018\"+S[4:]))\n", "S=input()\nprint((S.replace(\"2017\",\"2018\")))\n", "S = input()\n \n# Python\u3067\u306f S[3]='8' \u306e\u3088\u3046\u306a\u64cd\u4f5c\u306f\u8a31\u3055\u308c\u306a\u3044\u306e\u3067\u9593\u63a5\u7684\u306a\u65b9\u6cd5\u3092\u7528\u3044\u308b\nprint(S[:3] + '8' + S[-6:])", "s = input()\nprint(s.replace('7','8',1))", "print(\"2018\"+input()[4:])", "y, m, d = input().split(\"/\")\ns = \"2018\" + \"/\" + m + \"/\" + d\nprint(s)\n", "date = str(input())\nprint((date.replace('2017', '2018')))\n", "s = input()\nprint('2018'+s[4:])", "s = input()\nprint(\"2018\" + s[4:])", "S = input()\nprint('2018' + S[4:])", "# -*- coding: utf-8 -*-\n\nS = list(input())\n\nS[3] = '8'\nS = \"\".join(S)\n\nprint(S)", "print(input().replace('2017', '2018'))", "S = input()\nprint(S.replace(\"2017\",\"2018\"))", "s = input()\nif s[0:4] == '2017':\n print(s.replace('2017', '2018'))", "a=input()\nprint('2018'+a[4:])", "year,month,day = map(str,input().split('/'))\n\nprint('2018/'+month+'/'+day)", "s=str(input())\nans='2018'+s[4:]\nprint(ans)", "s = input()\nprint(\"2018\",end='')\nprint(s[4:])", "N = list(input())\nN[3] = '8'\nN = \"\".join(N)\nprint(N)", "print(input().replace(\"017\",\"018\"))", "a = input()\nprint('2018' + a[4:])"] | {"inputs": ["2017/01/07\n", "2017/01/31\n"], "outputs": ["2018/01/07\n", "2018/01/31\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 5,735 | |
8cab75d920b04f8b66c420e6681c2a35 | UNKNOWN | Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string.
He will receive a headline which contains one of the strings S_1,...,S_n tomorrow.
He is excited and already thinking of what string he will create.
Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.
Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains.
If there are multiple such strings, find the lexicographically smallest one among them.
-----Constraints-----
- 1 \leq n \leq 50
- 1 \leq |S_i| \leq 50 for every i = 1, ..., n.
- S_i consists of lowercase English letters (a - z) for every i = 1, ..., n.
-----Input-----
Input is given from Standard Input in the following format:
n
S_1
...
S_n
-----Output-----
Print the lexicographically smallest string among the longest strings that satisfy the condition.
If the answer is an empty string, print an empty line.
-----Sample Input-----
3
cbaa
daacc
acacac
-----Sample Output-----
aac
The strings that can be created from each of cbaa, daacc and acacac, are aa, aac, aca, caa and so forth.
Among them, aac, aca and caa are the longest, and the lexicographically smallest of these three is aac. | ["# \u3072\u3063\u304f\u308a\u304b\u3048\u3059\u306e\u304b\u3068\u304a\u4fdd\u3063\u305f\u3089180\u5ea6\u53cd\u8ee2\u3060\u3063\u305f\nn = int(input())\nd = []\nfor _ in range(n):\n s = list(input())\n d.append(s)\n\nd = sorted(d, key=lambda dd: len(dd), reverse=True)\nbase = {}\nfor c in d[0]:\n if c not in base:\n base[c] = 1\n else:\n base[c] += 1\n\nfor s in d[1:]:\n tmp = {}\n for c in s:\n if c not in tmp:\n tmp[c] = 1\n else:\n tmp[c] += 1\n for k, v in base.items():\n if k in tmp and base[k] >= 1:\n base[k] = min(base[k], tmp[k])\n else:\n base[k] = -1\nans = []\nfor k, v in base.items():\n if v > 0:\n ans.append(k * v)\nans = sorted(ans)\nans = \"\".join(ans)\nprint(ans)", "n = int(input())\nans = [100]*26\nfor i in range(n):\n s =input()\n lst = [0]*26\n for j in s:\n num = ord(j)-97\n lst[num] += 1\n for k in range(26):\n ans[k] = min(ans[k],lst[k])\nfor l in range(26):\n if ans[l] > 0:\n print(chr(l+97)*ans[l],end=\"\")", "#!/usr/bin/env python3\n\n# from numba import njit\nfrom collections import Counter\n# input = stdin.readline\n\n# @njit\ndef solve(n,a):\n alphabetLst = {}\n for i in range(n):\n # i\u756a\u76ee\u306e\u6587\u5b57\u5217\u306e\u4e2d\u306e\u6587\u5b57\u3092\u6570\u3048\u308b\n d = Counter(a[i])\n for c in (chr(ord(\"a\") + i) for i in range(26)):\n if not c in d.keys():\n alphabetLst[c] = 0\n elif not c in alphabetLst.keys():\n alphabetLst[c] = d[c]\n elif d[c] < alphabetLst[c]:\n alphabetLst[c] = d[c]\n\n\n res = []\n for k,v in alphabetLst.items():\n res += [k]*v\n\n return \"\".join(res)\n\ndef main():\n N = int(input())\n a = [input() for _ in range(N)]\n print(solve(N,a))\n return\n\ndef __starting_point():\n main()\n__starting_point()", "n=int(input())\nl = [input() for i in range(n)]\nL = [[0]*26 for i in range(n)]\ns = ''\n\nfor i in range(n):\n for j in l[i]:\n L[i][ord(j)-97] += 1\n\nM = L[0]\nfor k in range(1,n):\n for g in range(26):\n M[g] = min(L[k][g],M[g])\n\nfor a in range(26):\n for b in range(M[a]):\n s += chr(a+97)\nprint(s)", "alphabet = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\", \"n\", \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\nkey = dict()\nfor a in alphabet:\n key[a] = 50\n\nn = int(input())\nfor i in range(n):\n x = input()\n for a in alphabet:\n key[a] = min(key[a], x.count(a))\n\nfor k, v in key.items():\n for _ in range(v):\n print(k, end=\"\") \nprint()", "n=int(input())\nL = [50]*26\nfor i in range(n):\n S = input()\n for i in range(26):\n L[i] = min(L[i],S.count(chr(97+i)))\nans = \"\"\nfor i in range(26):\n ans += chr(97+i)*L[i]\nprint(ans)", "n = int(input())\nS = []\nans = ''\n\nfor i in range(n):\n S.append(str(input()))\n\ndata1 = []\ndata2 = []\n\nfor i in range(len(S[0])):\n if not S[0][i] in data1:\n data1.append(S[0][i])\n data2.append(1)\n else:\n data2[data1.index(S[0][i])] += 1\n\nfor i in range(1, n):\n for j in range(len(data1)):\n data2[j] = min(data2[j], S[i].count(data1[j]))\n\nfor i in range(len(data1)):\n ans += data1[i] * data2[i]\n\nprint((''.join(sorted(ans))))\n\n", "from collections import defaultdict\nfrom collections import deque\nfrom collections import Counter\nimport itertools\nimport math\n\ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\n\nn = readInt()\nsn = [list(input()) for i in range(n)]\n\nans = \"\"\nfor i in range(97,123):\n\tm = float(\"inf\")\n\tfor j in sn:\n\t\tm = min(m,j.count(chr(i)))\n\tans+=chr(i)*m\n\nprint(ans)", "n = int(input())\nS = [input() for _ in range(n)]\n\nalp = 'abcdefghijklmnopqrstuvwxyz'\ncount = [float('inf') for _ in range(len(alp))]\n\nfor s in S:\n for i in range(len(alp)):\n count[i] = min(count[i], s.count(alp[i]))\n\nans = ''\nfor i in range(len(alp)):\n ans += alp[i] * count[i]\nprint(ans)", "from collections import defaultdict\nimport string\nn = int(input())\n\nal = defaultdict(int)\nold = defaultdict(int)\n\ns = input()\nfor j in s:\n old[j] += 1\n al[j] += 1\n\nfor i in range(n-1):\n s = input()\n d = defaultdict(int)\n for j in s:\n d[j] += 1\n for k in string.ascii_lowercase:\n al[k] = min(old[k], d[k], al[k])\n old = d\nans = \"\"\nfor k in string.ascii_lowercase:\n ans += k * al[k]\nprint(ans)", "n=int(input())\ntable=[100]*26\nfor i in range(n):\n k=[0]*26\n s=input()\n for j in s:\n k[ord(j)-97]+=1\n for j in range(26):\n table[j]=min(table[j],k[j])\nans=\"\"\nfor i in range(26):\n ans+=chr(i+97)*table[i]\nprint(ans)", "n = int(input())\nA = list(\"abcdefghijklmnopqrstuvwxyz\")\nB = [50]*26\nfor i in range(n):\n C = [0]*26\n s = input()\n s = sorted(s)\n for j in range(len(s)):\n for k in range(26):\n if s[j] == A[k]:\n C[k] += 1\n break\n for m in range(26):\n B[m] = min(B[m],C[m])\n\nD = [] \nfor i in range(26):\n D.append(A[i]*B[i])\nD.sort()\nprint(*D, sep = \"\")", "from collections import Counter\nn=int(input())\ns=[input() for _ in range(n)]\n\nls=[chr(i) for i in range(ord(\"a\"),ord(\"z\")+1)]\nli=[9999 for _ in range(ord(\"a\"),ord(\"z\")+1)]\n\nc=[]\nfor x in s:\n c.append(Counter(x))\n\nfor x in c:\n for i,y in enumerate(ls):\n li[i]=min(x[y],li[i])\n\nres=\"\"\nfor i,x in enumerate(li):\n res+=ls[i]*x\nprint(res)", "import string\nn = int(input())\n#a, b = map(int,input().split())\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\nsl = [list(input()) for i in range(n)]\n\nalpha = list(string.ascii_lowercase)\n\ndic = {si: sl[0].count(si) for si in alpha}\n\nfor s in sl:\n for ch in alpha:\n dic[ch] = min(dic[ch], s.count(ch))\nans = ''\nfor ch in alpha:\n for i in range(dic[ch]):\n ans += ch\nprint(ans)\n", "N = int(input())\nlet = [0]*26\nS = input()\nfor a in range(len(S)):\n let[ord(S[a])-ord(\"a\")] += 1\n \nfor i in range(N-1):\n S = input()\n let_S = [0]*26\n for j in range(len(S)):\n let_S[ord(S[j])-ord(\"a\")] += 1\n for k in range(26):\n if let[k] > let_S[k]:\n let[k] = let_S[k]\n\nans = \"\"\nfor l in range(26):\n ans += chr(ord(\"a\")+l)*let[l]\n\nprint(ans)", "n = int(input())\ns = [input() for _ in range(n)]\nans = set(s[0])\nfor i in range(1,n): ans = ans & set(s[i])\ncnt = [0] * len(ans)\nans = sorted(list(ans))\nfor i in range(n):\n for j in range(len(ans)):\n if cnt[j] == 0: cnt[j] = s[i].count(ans[j])\n else:cnt[j] = min(cnt[j], s[i].count(ans[j]))\n\nA = \"\"\nfor x,y in zip(ans,cnt):\n A += x*y\nprint(A)", "import numpy as np\nn = int(input())\nargList = [input() for _ in range(n)]\nkeys = list('abcdefghijklmnopqrstuvwxyz')\nnMat = []\nfor s in argList:\n nList = [0]*26\n for i, k in enumerate(keys):\n nList[i] = s.count(k)\n nMat.append(nList)\nnMat = np.array(nMat)\nminLst = nMat.min(axis=0)\nret = ''\nfor i,num in enumerate(minLst):\n for j in range(num):\n ret += keys[i]\nprint(ret)", "n = int(input())\n\ndic = {chr(97 + i): 50 for i in range(26)}\n\nfor _ in range(n):\n s = list(map(str, input()))\n for key in dic:\n dic[key] = min(dic[key], s.count(key))\n\n\nres = \"\"\nfor key in dic:\n if dic[key] != 0:\n res += key * dic[key]\n\nprint(res)", "from collections import Counter\nn = int(input())\ns = [''] * n\nfor i in range(n):\n\ts[i] = input()\n\nr = s[0]\nfor i in range(1, n):\n\tset_c = set(r) & set(s[i])\n\tif len(set_c) == 0:\n\t\tprint('')\n\t\treturn\n\tnext_r = ''\n\tcnt_r = Counter(r)\n\tcnt_s = Counter(s[i])\n\tfor c in set_c:\n\t\tnext_r += c * min(cnt_r[c], cnt_s[c])\n\tr = next_r\nprint(''.join(sorted(r)))", "n = int(input())\nS = [input() for _ in range(n)]\nC = [ [0]*26 for _ in range(n)]\nfor i in range(n):\n for x in S[i]:\n k = ord(x) - ord('a')\n C[i][k] += 1\n\ncount = C[0]\nfor i in range(1, n):\n for k in range(26):\n count[k] = min(count[k], C[i][k])\n\nans = []\nfor k in range(26):\n if count[k]:\n\t ans.append(chr(ord('a') + k) * count[k])\nprint(*ans, sep='') ", "n=int(input())\nabc='abcdefghijklmnopqrstuvwxyz'\ns=[]\nt=[51]*len(abc)\n#print(t)\nfor i in range(n):\n u=input()\n for j in range(len(abc)):\n v=u.count(abc[j])\n t[j]=min(t[j],v)\nans=''\nfor j in range(len(abc)):\n ans+=t[j]*abc[j]\nprint(ans)", "N=int(input())\nS=[input() for _ in range(N)]\n\nF = [[0]*N for _ in range(26)]\n\nf1=lambda c: ord(c) - ord('a')\nf2=lambda c: chr(c+97)\n\n\nfor i in range(N):\n for s in S[i]:\n F[f1(s)][i]+=1\n \nans=''\nfor i in range(26):\n t=min(F[i])\n if t!=0:\n ans+=t*f2(i)\nprint(ans)", "n = int(input())\nalp = [input() for _ in range(n)]\nans = ''\n\nfor i in range(97, 123):\n cnt = 1001001001\n for s in alp:\n cnt = min(cnt, s.count(chr(i)))\n ans += chr(i)*cnt\n\nprint(ans)", "from collections import Counter\nn = int(input())\ns = [input() for i in range(n)]\nsc = [Counter(list(_s)) for _s in s]\n\nans = ''\nfor i in range(26):\n cnt = float('inf')\n for _sc in sc:\n cnt = min(cnt, _sc[chr(ord('a')+i)])\n ans+=chr(ord('a')+i)*cnt\nprint(ans)\n", "from collections import Counter\n\nn = int(input())\na2z='abcdefghijklmnopqrstuvwxyz'\nC = Counter(input())\nfor _ in range(1, n):\n c = Counter(input())\n for i in a2z:\n C[i] = min(C[i], c[i])\n\nans = \"\"\nfor k, v in sorted(C.items()):\n ans += k*v\nprint(ans)", "from collections import Counter\nn = int(input())\ncl = {chr(i):0 for i in range(97,123)}\ns = input()\nfor k in Counter(s).keys():\n cl[k] = Counter(s)[k]\nfor i in range(n-1):\n s = input()\n for k in cl.keys():\n if cl[k]!=0:\n cl[k] = min(cl[k],Counter(s).get(k,0))\nans = []\nfor k,v in cl.items():\n if v!=0:\n for i in range(v):\n ans.append(k)\nprint(''.join(sorted(ans)))", "import collections\nn = int(input())\ns = list(input())\ns_cnt = collections.Counter(s)\n\nfor i in range(n-1):\n tmp = input()\n for k in s_cnt:\n s_cnt[k] = min(s_cnt[k],tmp.count(k))\n\ns_cnt=dict(sorted(s_cnt.items(), key=lambda x:x[0]))\nans = \"\" \nfor k in s_cnt:\n ans += k*s_cnt[k]\nprint(ans)", "n=int(input())\nc=list(input())\nfor i in range(n-1):\n t=[]\n s=list(input())\n for j in c:\n if j in s:\n t.append(j)\n s.remove(j)\n c=t\nc.sort()\nprint(\"\".join(c))", "import collections as c\nn=[c.Counter(input()) for _ in range(int(input()))];r=n[0]\nfor i in range(1,len(n)): r=r&n[i]\nprint(*sorted([i*j for i,j in r.items()]),sep='')", "from collections import defaultdict\nn = int(input())\nnew_d = {}\nfor i in range(ord(\"a\"), ord(\"z\") + 1):\n new_d[chr(i)] = 50\nfor _ in range(n):\n old_d = new_d\n s = input()\n d = defaultdict(int)\n for c in s:\n if c not in old_d:\n continue\n d[c] += 1\n new_d = {}\n for c in d.keys():\n new_d[c] = min(old_d[c], d[c])\nans = \"\"\nfor c, v in sorted(new_d.items()):\n ans += c * v\nprint(ans)", "n = int(input())\n\na = [99] * 26\nfor i in range(n):\n s = input()\n tmp = [0] * 26\n for c in s:\n x = ord(c) - ord('a')\n tmp[x] += 1\n for j in range(26):\n a[j] = min(a[j], tmp[j])\n\nfor i in range(26):\n c = chr(i + ord('a'))\n print(c * a[i], end='')\nprint()\n", "n = int(input())\nli = []\nfor i in range(n):\n li.append(input())\n\nfor i in [chr(ord(\"a\") + j) for j in range(26)]:\n print(i*min([li[k].count(i) for k in range(n)]), end = \"\")\n\nprint(\"\")\n", "N = int(input())\nfrom collections import Counter\nS = [Counter(input()) for _ in range(N)]\n\nx = S[0]\nfor i in range(1, N):\n x = x & S[i]\n\nans = []\nfor k, v in x.items():\n for i in range(v):\n ans.append(k)\nans = sorted(ans)\nprint(\"\".join(ans))", "from collections import Counter\nn = int(input())\nS = [input() for _ in range(n)]\n\ncount = Counter(S[0])\nfor s in S[1:]:\n c = Counter(s)\n count = count & c\n \nls = sorted(count.items())\n\nans = \"\"\nfor i, j in ls:\n ans += i * j\n \nprint(ans)", "n = int(input())\nl = []\nfor i in range(n):\n l.append(sorted(input()))\nl.sort(key=len)\nans = []\nfor i in l[0]:\n for j in range(1, n):\n if i not in l[j]:\n break\n else:\n l[j].remove(i)\n else:\n ans.append(i)\nprint(*ans, sep=\"\")", "n = int(input())\na = input()\nalphabet = {}\nfor i in a:\n alphabet.update({i: a.count(i)})\nfor i in range(n-1):\n b = input()\n for j in alphabet:\n alphabet[j] = min(alphabet[j], b.count(j))\nans = []\nfor i in alphabet:\n ans += [i]*alphabet[i]\nprint((''.join(sorted(ans))))\n \n \n \n", "# C - \u602a\u6587\u66f8\ndef main():\n n = int(input())\n ans = list(input())\n\n \n for _ in range(n-1):\n s = list(input())\n temp = []\n for j in ans:\n if j in s:\n s.remove(j)\n temp.append(j)\n else:\n ans = temp\n else:\n ans.sort()\n print((''.join(ans)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\ns = sorted([list(input()) for _ in range(n)], key=len)\n\nans = []\nfor i in s[0]:\n t = float(\"inf\")\n for j in s:\n t = min(t, j.count(i))\n ans.append(i*t)\nans = sorted(list(set(ans)))\nprint(\"\".join(ans))", "from collections import Counter\nn=int(input())\ns=Counter(input())\nfor i in range(n-1):\n s&=Counter(input())\nprint(\"\".join(sorted(s.elements())))", "n=int(input())\ns=[100]*26\nfor i in range(n):\n a=[0]*26\n for j in list(input()):\n a[ord(j)-97]+=1\n for j in range(26):\n s[j]=min(s[j],a[j])\nans=''\nfor i in range(26):\n for j in range(s[i]):\n ans=ans+chr(i+97)\nprint(ans)", "a = ord('a')\nn = int(input())\nmemory = [[0] * 26 for _ in range(n)]\n\nfor i in range(n):\n for s in input():\n memory[i][ord(s) - a] += 1\n\nans = ''\nfor i in range(26):\n ans += min(memory[j][i] for j in range(n)) * chr(a + i)\n\nprint(ans)", "import string\n\nn = int(input())\n\nd = dict()\nfor c in string.ascii_lowercase:\n d[c] = []\n\nfor _ in range(n):\n s = input()\n for c in string.ascii_lowercase:\n if s.count(c) != 0:\n d[c].append(s.count(c))\n\nans = \"\"\nfor k, v in d.items():\n if len(v) == n:\n ans += k * min(v)\n\nprint(ans)", "n = int(input())\ncnt = [[0] * n for i in range(26)]\n\nfor i in range(n):\n s = input()\n for j in range(len(s)):\n x = ord(s[j]) - 97\n cnt[x][i] += 1\n\nans = ''\nfor i in range(26):\n ans += min(cnt[i]) * chr(i+97)\nprint(ans)", "def main():\n n = int(input())\n s_lst = [str(input()) for _ in range(n)]\n alp = list('abcdefghijklmnopqrstuvwxyz')\n\n lst = []\n for i in range(n):\n count_lst = [0] * 26\n s = s_lst[i]\n for j in range(len(s)):\n s_alp = s[j]\n count_lst[alp.index(s_alp)] += 1\n\n lst.append(count_lst)\n\n minimum_lst = [0] * 26\n for i in range(26):\n minimum_count = lst[0][i]\n for j in range(n):\n minimum_count = min(minimum_count, lst[j][i])\n\n minimum_lst[i] = minimum_count\n\n answer = ''\n for i in range(26):\n alphabet = alp[i] * minimum_lst[i]\n answer += alphabet\n print(answer)\n\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\nS = [input().strip() for _ in range(n)]\nC = {chr(i):0 for i in range(97,123)}\nfor i in range(len(S[0])):\n C[S[0][i]] += 1\nfor j in range(1,n):\n C1 = {chr(i):0 for i in range(97,123)}\n for i in range(len(S[j])):\n C1[S[j][i]] += 1\n for i in range(97,123):\n C[chr(i)] = min(C[chr(i)],C1[chr(i)])\n \nA = []\nfor i in range(97,123):\n A.append(chr(i)*C[chr(i)])\nprint(\"\".join(sorted(A)))", "n=int(input())\nS=list(input() for _ in range(n))\n\nT=\"abcdefghijklmnopqrstuvwxyz\"\nfor c in T:\n x=50\n for s in S:\n x=min(x,s.count(c))\n print(c*x,end='')\nprint()\n", "N = int(input())\ns = [[0 for i in range(N)] for j in range(26)]\nfor i in range(N):\n t = input()\n for j in range(len(t)):\n s[ord(t[j])-ord('a')][i] += 1\nans = ''\nfor j in range(26):\n ans += chr(j+ord('a')) * min(s[j])\nprint(ans)", "from collections import Counter\nN = int(input())\n\ns = Counter(input())\nfor i in range(N-1):\n s &= Counter(input())\nprint((''.join(sorted(s.elements()))))\n", "n = int(input())\njisho = 'abcdefghijklmnopqrstuvwxyz'\nmoji = []\n#print(moji)\nfor i in range(n):\n dic = {}\n for i in range(len(jisho)):\n dic.setdefault(jisho[i],0)\n s = str(input())\n for j in range(len(s)):\n dic.setdefault(s[j],0)\n dic[s[j]] += 1\n moji.append(dic)\ndic = {}\nfor j in range(len(jisho)):\n tmp = 50\n for i in range(n):\n tmp = min(tmp,moji[i][jisho[j]])\n if tmp != 0:\n dic.setdefault(jisho[j],tmp)\n#print(dic)\nans = ''\nfor item in dic.items():\n while dic[item[0]]>0:\n ans += item[0]\n dic[item[0]] -= 1\nprint(ans)", "n = int(input())\ns = list(input() for _ in range(n))\n\nalphabet = [[0] * n for _ in range(26)]\n\nfor i in range(n):\n for x in s[i]:\n alphabet[ord(x) % 97][i] += 1\n\nans = ''\nfor i in range(26):\n m = min(alphabet[i])\n if m != 0:\n for _ in range(m):\n ans += chr(i + 97)\n\nprint(ans)\n", "from collections import Counter\n\nn=int(input())\n\nabc='abcdefghijklmnopqrstuvwxyz'\n\nfor i in range(n):\n if i==0:\n c=Counter(input())\n else:\n c2=Counter(input())\n for k in abc:\n c[k]=min(c[k],c2[k])\n\nans=''\nfor k,v in sorted(c.items()):\n ans+=k*v\n\nprint(ans)", "from collections import Counter\n\nn=int(input())\nINF = 10**20\n\nd={}\nfor i in range(97,123):\n d[chr(i)] = INF\n\nfor i in range(n):\n s = input()\n c = Counter(s)\n for k in d.keys():\n if c.get(k):\n d[k] = min(c[k],d[k])\n else:\n d[k] = 0\n \nkeys=list(d.keys())\nfor k in keys:\n if d[k] == INF:\n del d[k]\n \nans = []\nfor k in d.keys():\n ans.extend([k]*d[k])\n \nif len(ans)==0:\n print('')\n return\n \nans = sorted(ans)\nprint(''.join(ans))", "from collections import Counter\n\nn = int(input())\nS = [input() for _ in range(n)]\n\nans = Counter(S[0])\n\nfor s in S[1:]:\n ans = ans & Counter(s)\n\nprint(\"\".join(sorted([k * v for k, v in ans.items()])))", "import copy\nn = int(input())\ns = list(input())\n\nif n == 1:\n s.sort()\n print(*s, sep='')\nelse:\n for _ in range(n-1):\n tmp = ''\n si = list(input())\n if len(si) >= len(s):\n for i in range(len(si)):\n if si[i] in s:\n tmp += si[i]\n s[s.index(si[i])], si[i] = '', ''\n else:\n for i in range(len(s)):\n if s[i] in si:\n tmp += s[i]\n si[si.index(s[i])], s[i] = '', ''\n s = list(copy.deepcopy(tmp))\n s.sort()\n print(*s, sep='')", "n=int(input())\nd = {}\nfor i in range(26):\n d[chr(ord(\"a\")+i)]=10**9\nfor i in range(n):\n s=input()\n for j in range(26):\n d[chr(ord(\"a\")+j)]=min(d[chr(ord(\"a\")+j)], s.count(chr(ord(\"a\")+j)))\n\nans = \"\"\nfor e in list(d.items()):\n ans+=e[0]*e[1]\nprint(ans)\n \n \n", "N = int(input())\nChrL = [[] for T in range(0,26)]\nfor NT in range(0,N):\n S = input()\n for ST in range(0,26):\n ChrL[ST].append(S.count(chr(97+ST)))\nDisp = ['']*26\nfor ST in range(0,26):\n Disp[ST] = chr(97+ST)*min(ChrL[ST])\nprint(''.join(Disp))", "alf=[\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\"]\nn=int(input())\nli=[]\nans=[]\nSTR=\"\"\nfor h in range(n):\n li.append([0]*26)\n\nfor i in range(n):\n S=input()\n for j in range(len(S)):\n li[i][alf.index(S[j])]+=1\n\n\nfor k in range(26):\n temp=1000000000000000000000000000000000000000000\n for l in range(n):\n if temp>li[l][k]:\n temp=li[l][k]\n \n if temp!=1000000000000000000000000000000000000000000:\n ans.append(temp)\n\nfor m in range(26):\n STR=STR+alf[m]*ans[m]\nprint(STR)\n", "m=10**9\nn=int(input())\na='abcdefghijklmnopqrstuvwxyz'\npue=[]\nfor i in range(len(a)):\n pue.append([a[i],m])\nfor i in range(n):\n s=input()\n for j in range(26):\n pue[j][1]=min(s.count(a[j]),pue[j][1])\n\nans=''\nfor i in range(26):\n for j in range(pue[i][1]):\n ans+=a[i]\nprint(ans)", "N = int(input())\nINF = 10**12\nans = [INF] * 26\n\nfor _ in range(N):\n S = input()\n tmp = [0] * 26\n for s in S:\n tmp[ord(s)-ord('a')] += 1\n \n for i in range(26):\n ans[i] = min(ans[i],tmp[i])\n\nansS = ''\nfor i in range(26):\n ansS += chr(i+97) * ans[i]\n\nprint(ansS)", "N = int(input())\nfrom collections import Counter\nS = [Counter(list(input())) for _ in range(N)]\n\ndef intersection(X):\n Res = X[0]\n if len(X) == 1:\n return Res\n for x in X[1:]:\n Res = {k:min(Res[k],x[k]) for k in Res if k in x}\n return Counter(Res)\n\nprint((''.join(sorted(intersection(S).elements()))))\n", "import collections\nn = int(input())\nss = sorted([input() for i in range(n)], key=lambda x:len(x))\ns = ss[0]\npoplist = []\ncc = collections.Counter(s)\n\nfor i in range(1, n):\n for c in cc:\n if c in ss[i]:\n cc[c] = min(cc[c], ss[i].count(c))\n else:\n if c not in poplist:\n poplist.append(c)\n\nfor p in poplist:\n dd = cc.pop(p)\n\nans = [x[0]*x[1] for x in cc.items()]\nans = ''.join(sorted(ans))\nprint(ans)", "import collections\nn = int(input())\nS = list(input())\ncounterA = collections.Counter(S)\nfor i in range(1,n):\n counterB = collections.Counter()\n S = list(input())\n counterS = collections.Counter(S)\n for j in counterA.keys():\n if j in counterS:\n counterB[j] = min(counterA[j],counterS[j])\n else:\n counterB[j] = 0\n counterA = counterB\nls = []\nfor i in counterA.keys():\n for j in range(counterA[i]):\n ls.append(i)\nls.sort()\nans = ''.join(ls)\nprint(ans)", "#!/usr/bin/env python\n\nn = int(input())\ns = [input() for _ in range(n)]\n\nd = {}\nfor i in range(len(s[0])):\n if s[0][i] not in d:\n d[s[0][i]] = 1 \n else:\n d[s[0][i]] += 1\n\nfor i in range(n):\n for key in list(d.keys()):\n tmp = 0 \n for k in range(len(s[i])):\n if s[i][k] == key:\n tmp += 1\n if tmp <= d[key]:\n d[key] = tmp \n\n# print('d =', d)\nd = sorted(list(d.items()), key=lambda x:x[0])\nans = ''\nfor i in range(len(d)):\n for _ in range(d[i][1]):\n ans += d[i][0]\nprint(ans)\n", "n = int(input())\nlst = []\nfor i in range(n):\n lst.append(input())\nabc = [chr(ord('a') + i) for i in range(26)]\n#print(abc)###\ncnt = []\nfor s in abc:\n temp = 100\n for i in range(n):\n temp = min(temp, lst[i].count(s))\n cnt.append(temp)\n#print(cnt)###\nres = []\nfor i in range(26):\n for j in range(cnt[i]):\n res.append(abc[i])\nprint(''.join(res))", "n = int(input())\nd = {}\nfor i in range(n):\n s = input()\n for w in d:\n if s.count(w)==0:\n d[w]=0\n for c in s:\n if i==0:\n d[c] = d.get(c, 0) + 1\n else:\n d[c] = min(d.get(c, 0), s.count(c))\n\nli = []\nfor w in d:\n for i in range(d[w]):\n li.append(w)\nli.sort()\nprint(\"\".join(li))", "from collections import Counter\n\nN = int(input())\nC = [Counter(input()) for _ in range(N)]\n# print(f'{C=}')\n\nword_set = set(C[0].keys())\nfor c in C:\n word_set &= set(list(c.keys()))\n# print(f'{word_set=}')\n\nW = {key: 10**8 for key in word_set}\nfor c in C:\n for word in word_set:\n W[word] = min(W.get(word, 0), c.get(word, 0))\n# print(f'{W=}')\n\nans = ''\nfor key, value in list(W.items()):\n ans += key * value\n# print(f'{ans=}')\nprint((''.join(sorted(ans))))\n", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 29 14:54:30 2020\n\n@author: liang\n\"\"\"\n\nn = int(input())\nS = [input() for _ in range(n)]\n\nans = [100]*26\n\nfor i in range(n):\n tmp = [0]*26\n for s in S[i]:\n key = ord(s)-ord('a')\n if tmp[key] < ans[key]:\n tmp[key] += 1\n ans = tmp.copy()\n\nres = \"\"\nfor i in range(26):\n res += chr(ord('a') + i)*tmp[i]\nprint(res)", "n=int(input())\nd={}\nfor i in range(n):\n s=input()\n d[i]={}\n for c in s:\n if c in d[i]:\n d[i][c]+=1\n else:\n d[i][c]=1\n# print(d)\nk={chr(i)for i in range(97,123)}\nfor e in d:\n k&=set(d[e].keys())\n# print(k)\nfor t in sorted(k):\n m=float('inf')\n for e in d:\n m=min(m,d[e][t])\n print(t*m,end='')\nprint('')\n", "from collections import Counter\nn = int(input())\nX = input()\npreC = Counter(X)\npreS = set(X)\nfor _ in range(n - 1):\n X = input()\n C = Counter(X)\n preS = set(X) & preS\n d = {}\n for s in preS:\n d[s] = min(C[s], preC[s])\n preC = d\nans = []\nfor s in preS:\n for _ in range(preC[s]):\n ans.append(s)\nprint(\"\".join(sorted(ans)))", "from collections import Counter\n\n\ndef __starting_point():\n C = Counter()\n N = int(input())\n for c in [chr(n) for n in range(ord(\"a\"), ord(\"z\")+1)]:\n C[c] = 10**8\n for _ in range(N):\n cs = Counter(input())\n C &= cs\n for k, v in C.items():\n print(k*v, end=\"\")\n print()\n\n__starting_point()", "from collections import Counter\nfrom string import ascii_lowercase\nn = int(input())\ns = {ai:float(\"INF\") for ai in ascii_lowercase}\n\nfor i in range(n):\n si = input()\n c = Counter(si)\n for k in ascii_lowercase:\n s[k] = min(s[k],c[k])\n\nans = \"\"\nfor key in ascii_lowercase:\n ans += key*s[key]\nprint(ans)", "from collections import defaultdict\n\nN = int(input())\nS = [input() for _ in range(N)]\n\nd = defaultdict(lambda: 50+1)\n\nfor i in range(N):\n for c in range(ord(\"a\"), ord(\"z\")+1):\n d[chr(c)] = min(d[chr(c)], S[i].count(chr(c)))\n\nans = \"\"\nfor key, value in d.items():\n ans += key * value\n\nprint(ans)", "#75 C - \u602a\u6587\u66f8\nimport collections\nn = int(input())\nS = [input() for _ in range(n)]\n\ncnt = collections.Counter(S[0])\nfor s in S[1:]:#O (50)\n for a in cnt.keys():# O(26)\n if a in s:# O(50)\n cnt[a] = min(cnt[a],s.count(a))# O(50)\n else:\n cnt[a] = 0\n \nans = [key*value for key,value in cnt.items() if value > 0]\nans = sorted(ans,reverse = False)\nprint(''.join(ans))", "n=int(input())\nwords=[]\nfor i in range(n):\n words.append(input())\n \ns=words.pop()\nfor i in words:\n ns=\"\"\n l=list(i)\n for j in s:\n if j in l:\n ns+=j\n l.remove(j)\n s=ns\ns=sorted(list(s))\nout=\"\"\nfor i in s:\n out+=i\nprint(out)", "from collections import *\nN = int(input())\nC = Counter(input())\n \nfor n in range(N-1):\n C&=Counter(input())\nprint(*sorted(C.elements()),sep=\"\")", "from collections import Counter\n\nn = int(input())\nl = []\nfor i in range(n):\n l.append(dict(Counter(input())))\n\nl.sort(key=len)\n\nans = []\nfor ki, vi in l[0].items():\n tmp = vi\n for j in range(1, n):\n if ki in l[j]:\n tmp = min(tmp, l[j][ki])\n else:\n break\n else:\n ans.append(ki * tmp)\nans.sort()\nprint(*ans, sep=\"\")", "n = int(input())\ns1 = input()\nd = {}\n\nfor i in range(len(s1)):\n if s1[i] in d:\n d[s1[i]] += 1\n else:\n d[s1[i]] = 1\n\nfor i in range(n-1):\n di = {}\n s = input()\n for i in range(len(s)):\n if s[i] in di:\n di[s[i]] += 1\n else:\n di[s[i]] = 1\n\n delete = []\n for key, value in d.items():\n if key in di:\n d[key] = min(value, di[key])\n else:\n delete.append(key)\n\n for key in delete:\n del d[key]\n\nans = \"\"\n\nfor key, value in sorted(d.items()):\n ans += key*value\n\nprint(ans)", "n = int(input())\ns_l = [ input() for _ in range(n) ]\n\nd = {}\nfor i in list(s_l[0]):\n if i in d.keys():\n d[i] += 1\n else:\n d[i] = 1\nc_l = set(list(s_l[0]))\n\n\nfor s in s_l[1:]:\n for c in list(c_l):\n count = list(s).count(c)\n if d[c] > count:\n d[c] = count\n\nans = []\nfor k in list(c_l):\n for _ in range(d[k]):\n ans.append(k)\nans = sorted(ans)\nans2 = ''\nfor a in ans:\n ans2 += a\nprint(ans2)", "n = int(input())\nd = {}\ns = input()\nfor c in set(s):\n d[c] = s.count(c)\nfor _ in range(n-1):\n s = input()\n for c in d.keys():\n d[c] = min(d[c], s.count(c))\nd_sorted = sorted(d.items(), key=lambda x:x[0])\nans = ''\nfor item in d_sorted:\n ans += item[0]*item[1]\nprint(ans)", "n=int(input())\n\n\nalphabet_count={}\n\nalphabet=\"abcdefghijklmnopqrstuvwxyz\"\n\nfor alpha in alphabet:\n alphabet_count[alpha]= 1000000000\n\nmojis=[]\nfor i in range(n):\n mojis.append(input())\n\ndef get_count(moji):\n alphabet = \"abcdefghijklmnopqrstuvwxyz\"\n alphabet_count = {}\n for alpha in alphabet:\n alphabet_count[alpha] = 0\n for m in moji:\n alphabet_count[m]+=1\n return alphabet_count\n\n\n\n\nfor moji in mojis:\n each_count=get_count(moji)\n for alpha in alphabet:\n alphabet_count[alpha]=min(alphabet_count[alpha],each_count[alpha])\n\nans=\"\"\n\nfor alpha in alphabet:\n for i in range(alphabet_count[alpha]):\n ans=ans+alpha\nprint(ans)\n\n\n\n\n", "import operator\nfrom collections import defaultdict\nfrom functools import reduce\n\nn = int(input())\narr = [input() for _ in range(n)]\nl = list(reduce(operator.and_, [set(i) for i in arr]))\nd = defaultdict(lambda: 1<<60)\nl.sort()\n\nfor s in arr:\n for c in l:\n cnt = s.count(c)\n d[c] = min(d[c], cnt)\n\nres = []\nfor k, v in d.items():\n res.append(k*v)\nans = \"\".join(res)\nprint(ans)", "from collections import defaultdict\nfrom collections import deque\nfrom collections import Counter\nimport itertools\nimport math\n\ndef readInt():\n\treturn int(input())\ndef readInts():\n\treturn list(map(int, input().split()))\ndef readChar():\n\treturn input()\ndef readChars():\n\treturn input().split()\n\nn = readInt()\nsn = [list(input()) for i in range(n)]\nsnc = [Counter(sn[i]) for i in range(n)]\n\ns = set(sn[0])\nfor i in range(n):\n\ts = s & set(sn[i])\n\ns = sorted(list(s))\nans = \"\"\nfor c in s:\n\tm = float(\"inf\")\n\tfor i in range(n):\n\t\tm = min(m, snc[i][c])\n\tans+=c*m\n\nprint(ans)", "from collections import Counter\nn=int(input())\ns=Counter(input())\nfor i in range(n-1):\n s&=Counter(input())\nprint(\"\".join(sorted(s.elements())))", "n=int(input())\ndata=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\ndict={}\nfor i in range(n):\n a=input()\n for j in data:\n if j not in dict:\n dict[j]=a.count(j)\n else:\n dict[j]=min(dict[j],a.count(j))\nans=[]\nfor i in dict:\n ans.append(i*dict[i])\nprint(*ans,sep='')", "def main():\n n = int(input())\n s = [input() for i in range(n)]\n nums = [1000 for i in range(26)]\n for i in range(26):\n for j in range(n):\n nums[i] = min(nums[i],s[j].count((chr)(97 + i)))\n\n for i in range(26):\n while nums[i] > 0:\n print((chr)(97 + i),end = \"\")\n nums[i] -= 1\n print(\"\")\n\nmain()", "from collections import Counter\n\nalph = 'abcdefghijklmnopqrstuvwxyz'\nn = int(input())\nS = [input() for _ in range(n)]\ncntS = [None] * n\nfor i in range(n):\n cntS[i] = Counter(S[i])\n\nans = []\nfor c in alph:\n ans += [c * min(cntS[i][c] for i in range(n))]\n\nprint(''.join(ans))", "n = int(input())\n\nalphabet_cnt = [[0] * n for i in range(26)]\n# [listA, listB, listC, ..., listZ]\n# listA = [0, 1, 3, 2, 1, 4, ...] -> the number of A in Si (only min val is needed)\nalphabet = list(\"abcdefghijklmnopqrstuvwxyz\")\nalphabet_map = dict(zip(alphabet, list(range(26))))\n\nfor i in range(n):\n si = input()\n for j in range(len(si)):\n alphabet_cnt[alphabet_map[si[j]]][i] += 1\n\nalphabet_intersect = [min(alp) for alp in alphabet_cnt]\nprint(\"\".join([alphabet[idx] * cnt for idx, cnt in enumerate(alphabet_intersect)]))", "from collections import Counter\nn = int(input())\n\nD = Counter(list(input()))\nfor i in range(n-1):\n d = Counter(list(input()))\n key = D.keys()\n for k in key:\n D[k] = min(D[k], d[k])\n\nans = []\nkey = D.keys()\nfor k in key:\n for i in range(D[k]):\n ans.append(k)\nans.sort()\nprint(\"\".join(ans))", "ma = lambda :map(int,input().split())\nlma = lambda :list(map(int,input().split()))\ntma = lambda :tuple(map(int,input().split()))\nni = lambda:int(input())\nyn = lambda fl:print(\"Yes\") if fl else print(\"No\")\nimport collections\nimport math\nimport itertools\nimport heapq as hq\nimport sys\n\nn = ni()\ncnts = []\nfor i in range(n):\n cnts.append(collections.Counter(list(input())))\nans=\"\"\nalp = list(\"abcdefghijklmnopqrstuvwxyz\")\nfor w in alp:\n tmp=10**10\n for i in range(n):\n tmp = min(tmp,cnts[i][w])\n ans+= w*tmp\nprint(ans)\n", "n = int(input())\nalp = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']\nlist = [[] for _ in range(26)]\nans = []\n\nfor i in range(n):\n s = input()\n for j in range(26):\n list[j].append(s.count(alp[j]))\n\nfor i in range(26):\n for j in range(min(list[i])):\n ans.append(alp[i])\n\nans = sorted(ans)\n\nfor i in ans:\n print(i, end = '')", "from collections import Counter\nurl = \"https://atcoder.jp//contests/abc058/tasks/arc071_a\"\n\ndef main():\n s = [input() for _ in range(int(input()))]\n isall = Counter(s[0])\n for k in isall:\n for row in s:\n c_count = row.count(k)\n if c_count < isall[k]:\n isall[k] = c_count\n isall = sorted(isall.items())\n for k, v in isall:\n print(k*v, end=\"\")\n\n\ndef __starting_point():\n main()\n__starting_point()", "# \u8981\u7d20\u304c\u5165\u3063\u3066\u306a\u3044\u5834\u5408\u306e list.index \u306e\u5b9a\u7fa9\ndef myindex(l:list, element, default=-1):\n if element in set(l):\n return l.index(element)\n else:\n return default\n\ndef main():\n n = int(input())\n S = []\n ans = ''\n for _ in range(n):\n S.append(list(input()))\n \n S.sort()\n t = S.pop()\n for i, u in enumerate(t):\n okflag = True\n for s in S:\n if myindex(s, u) == -1:\n okflag = False\n break\n if okflag:\n for s in S:\n s.pop(s.index(u))\n ans += u\n ans = sorted(ans)\n print((''.join(ans)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "from copy import deepcopy\nn = int(input())\ns = [input() for _ in range(n)]\ncnt = []\n\nfor si in s:\n tmp = [0] * 26\n for i in range(len(si)):\n tmp[ord(si[i])-97] += 1\n if cnt == []:\n cnt = deepcopy(tmp)\n else:\n for j in range(26):\n cnt[j] = min(cnt[j], tmp[j])\n\nans = ''\nfor i in range(26):\n for j in range(cnt[i]):\n ans += chr(i+97)\nprint(ans)\n", "from collections import Counter\n\nn = int(input())\ns = Counter(input())\n\nfor i in range(n-1):\n s &= Counter(input())\n\nres = \"\"\nfor char, count in s.items():\n res += char*count\nprint(*sorted(res), sep=\"\")\n", "import collections\nn=int(input())\na=collections.Counter(input())\nfor i in range(n-1):\n s=collections.Counter(input())\n a=a&s\nans=\"\"\nk=list(a.keys())\nv=list(a.values())\nfor i,j in zip(k,v):\n ans+=i*j\nprint((\"\".join(sorted(ans))))\n", "n = int(input())\nres_map = dict()\ns = input()\ntmp_map = dict()\nfor j in s:\n if j not in tmp_map:\n tmp_map[j] = 1\n else:\n tmp_map[j] += 1\nfor j in list(tmp_map.keys()):\n res_map[j] = tmp_map[j]\n\nfor i in range(n - 1):\n s = input()\n tmp_map = dict()\n for j in s:\n if j not in tmp_map:\n tmp_map[j] = 1\n else:\n tmp_map[j] += 1\n for j in list(res_map.keys()):\n if j in tmp_map:\n res_map[j] = min(res_map[j], tmp_map[j])\n else:\n res_map[j] = 0\n\nres = \"\"\nfor i in list(res_map.keys()):\n res += i * res_map[i]\n\nres = sorted(res)\nprint((\"\".join(res)))\n", "n=int(input())\nabc='abcdefghijklmnopqrstuvwxyz'\ns=[]\nt=[51]*len(abc)\n#print(t)\nfor i in range(n):\n u=input()\n for j in range(len(abc)):\n v=u.count(abc[j])\n t[j]=min(t[j],v)\nans=''\nfor j in range(len(abc)):\n ans+=t[j]*abc[j]\nprint(ans)", "n = int(input())\nans = list(input())\nfor i in range(n-1):\n s = list(input())\n t = []\n for j in ans:\n if j in s:\n s.remove(j)\n t.append(j)\n ans = t\nans.sort()\nprint(\"\".join(ans))"] | {"inputs": ["3\ncbaa\ndaacc\nacacac\n", "3\na\naa\nb\n"], "outputs": ["aac\n", "\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 37,558 | |
5c17759f78d31f4b5277333deed147d1 | UNKNOWN | Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?
-----Constraints-----
- 1β€Nβ€1000
- 1β€l_iβ€r_iβ€100000
- No seat is occupied by more than one person.
- All input values are integers.
-----Input-----
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N
-----Output-----
Print the number of people sitting at the theater.
-----Sample Input-----
1
24 30
-----Sample Output-----
7
There are 7 people, sitting at Seat 24,25,26,27,28,29 and 30. | ["N = int(input())\nans = 0\nfor _ in range(N):\n a, b = map(int, input().split())\n ans += b - a + 1\nprint(ans)", "N = int(input())\nans = 0\nfor _ in range(N):\n l, r = map(int, input().split())\n ans += r-l+1\n\nprint(ans)", "with open(0) as f:\n N, *lr = map(int, f.read().split())\nprint(sum(lr[1::2])-sum(lr[::2])+N)", "a=int(input())\nb=[input().split() for i in range(a)]\nc=0\nfor i in range(a):\n c=c+(int(b[i][1])-int(b[i][0]))\nprint(c+a)", "N = int(input())\nseat = 0\nfor i in range(N):\n l, r = map(int, input().split())\n seat += r - l + 1\nprint(seat)", "N = int(input())\nres = 0\n\nfor i in range(N):\n l, r = map(int,input().split())\n res += r - l + 1\n \nprint(res)", "n = int(input())\nseat = [0] * (10 ** 5 + 1)\nfor i in range(n):\n l, r = list(map(int, input().split()))\n seat[l - 1] += 1\n seat[r] -= 1\n\nfor i in range(1, 10 ** 5):\n seat[i] += seat[i - 1]\n\nres = 0\nfor i in range(10 ** 5):\n if seat[i] == 1:\n res += 1\nprint(res)\n", "print(sum([r-l+1 for l,r in [list(map(int,input().split())) for _ in range(int(input()))]]))", "N = int(input())\nppl = 0\nfor i in range(N):\n tmp = input().split(\" \")\n ppl += int(tmp[1]) - int(tmp[0]) + 1\n\nprint(ppl)", "n = int(input())\nans = 0\nfor i in range(n):\n a,b = map(int,input().split())\n ans += b-a+1\nprint(ans)", "n=int(input())\nans = 0\nfor i in range(n):\n a,b=(int(x) for x in input().split())\n c = b-a+1\n ans += c\n\nprint(ans)", "n = int(input())\nans = 0\nfor i in range(n):\n l, r = map(int, input().split())\n ans += r-l+1\n\nprint(ans)", "N = int(input())\n\ncnt = 0\n\nfor _ in range(N):\n l, r = map(int,input().split())\n cnt += r - l + 1\n \nprint(cnt)", "n = int(input())\nsum = 0\nfor _ in range(n):\n a, b = map(int, input().split())\n sum += b-a+1\nprint(sum)", "N=int(input())\nans=0\nfor i in range(N):\n l,r=map(int,input().split())\n ans += r-l+1\nprint(ans)", "n = int(input())\nans = 0\nfor _ in range(n):\n l,r = list(map(int, input().split()))\n ans += r - l + 1\nprint(ans)", "def main():\n n = int(input())\n ans = 0\n for _ in range(n):\n a, b = list(map(int, input().split()))\n ans += b - a + 1\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nli = [list(map(int,input().split())) for i in range(n)]\ncnt = 0\nfor i in li:\n cnt += i[1] - i[0] +1\nprint(cnt)", "N, *_LR = map(int, open(0).read().split())\nLR = list(zip(*[map(int, iter(_LR))]*2))\n\nans = 0\n\nfor l,r in LR:\n ans += r - l + 1\n \nprint(ans)", "n=int(input())\nkei=0\nfor i in range(n):\n l,r=map(int,input().split())\n kei += r-l+1\nprint(kei)", "ans=0\nN=int(input())\nfor i in range(N):\n a,b=map(int,input().split())\n ans+=b-a+1\nprint(ans)", "N = int(input())\nans = 0\nfor i in range(N):\n l,r = map(int,input().split())\n ans += r - l + 1\nprint(str(ans))", "a=int(input())\nans=0\nfor i in range(a):\n x,y=map(int,input().split())\n ans+=y-x+1\nprint(ans)", "N=int(input())\npeople=0\nfor i in range(N):\n l,r=list(map(int,input().split()))\n people+=r-l+1\nprint(people)\n", "n = int(input())\nres = 0\nfor i in range(n):\n r, l = list(map(int, input().split()))\n res += l - r + 1\nprint(res)\n", "n = int(input())\nans = 0\nfor i in range(n):\n a, b = list(map(int, input().split()))\n ans += b - a + 1\n\nprint(ans)\n", "n = int(input())\nans = 0\nfor i in range(n):\n l, r = map(int, input().split())\n ans += (r - l + 1)\nprint(ans)", "n = int(input())\nlr = [list(map(int, input().split())) for i in range(n)]\nans = 0\nfor i in range(n):\n ans += (lr[i][1]-lr[i][0]+1)\nprint(ans)", "N = int(input())\np = 0\nfor i in range(N):\n l, r = map(int,input().split())\n p += r-l+1\nprint(p)", "n=int(input())\nans=0\nfor i in range(n):\n l,r=list(map(int,input().split()))\n ans+=r-l+1\n\nprint(ans)\n", "# -*- coding: utf-8 -*-\n\nn = int(input())\na = [0]*n\nb = [0]*n\nans = 0\n\nfor i in range(n):\n a[i],b[i] = list(map(int, input().split()))\n\nfor i in range(n):\n ans += b[i] - a[i] + 1\n\nprint(ans)\n\n", "n=int(input())\n\ncnt=0\n\nfor i in range(n):\n l,r = map(int, input().split())\n cnt += r-l+1\n\nprint(cnt)", "n = int(input())\nl = [tuple(map(int, input().split())) for i in range(n)]\n\ncnt = 0\nfor i in l:\n cnt += (i[1] - i[0] + 1)\nprint(cnt)\n", "n=int(input())\nans=0\nfor i in range(n):\n l,r=list(map(int,input().split()))\n ans+=r-l+1\nprint(ans)\n", "N = int(input())\nlr = [list(map(int,input().split())) for i in range(N)]\nans = 0\nfor i in lr:\n ans += i[1] -i[0] + 1\nprint(ans)", "N = int(input())\nans = 0\n\nfor _ in range(N):\n l, r = map(int, input().split())\n ans += r - l + 1\n\nprint(ans)", "n=int(input())\nhito=0\nfor i in range(n):\n l,r=map(int, input().split())\n hito+=r-l+1\nprint(hito)", "#!/usr/bin/env python3\n\ndef main():\n n = int(input())\n ans = 0\n for i in range(n):\n l, r = list(map(int, input().split()))\n ans += r - l + 1\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N=int(input())\nl=[0]*N\nr=[0]*N\nsum=0\nfor i in range(N) :\n l[i],r[i]=map(int,input().split())\n sum+=r[i]-l[i]+1\nprint(sum)", "# coding = SJIS\n\nn = int(input())\nmen = []\nfor i in range(n):\n l, r = map(int, input().split())\n men.append([l, r])\nans = 0\n\nfor i in range(n):\n ans += men[i][1] - men[i][0] + 1\n\nprint(ans)", "n = int(input())\nans = 0\nfor i in range(n):\n l,r = map(int,input().split())\n ans += (r-l+1)\nprint(ans)", "N = int(input())\nsum = 0\nfor i in range(N):\n l, r = map(int, input().split())\n sum += (r-l) + 1\n \nprint(sum)", "# \u5165\u529b\nN=int(input())\n\nsm=0\n\nfor i in range(N):\n l,r=map(int,input().split())\n sm+=r-l+1\n\n# \u51fa\u529b\nprint(sm)", "n = int(input())\np = 0\nfor i in range(n):\n l, r = map(int, input().split())\n p += r-l+1\n \nprint(p)", "#https://atcoder.jp/contests/abc073/tasks/abc073_b\nN = int(input())\nans = 0\nfor i in range(N):\n st,sp = map(int,input().split())\n ans += abs(sp-st+1)\nprint(ans)", "N = int(input())\ns = 0\nfor _ in range(N):\n a, b = map(int, input().split())\n s += b - a + 1\nprint(s)", "N = int(input())\nans = 0\nfor _ in range(N):\n l,r = map(int,input().split())\n ans += r - l + 1\n \nprint(ans)", "import sys\nimport math\nimport itertools\nimport collections\nimport heapq\nimport re\nimport numpy as np\nfrom functools import reduce\n\nrr = lambda: sys.stdin.readline().rstrip()\nrs = lambda: sys.stdin.readline().split()\nri = lambda: int(sys.stdin.readline())\nrm = lambda: list(map(int, sys.stdin.readline().split()))\nrl = lambda: list(map(int, sys.stdin.readline().split()))\ninf = float('inf')\nmod = 10**9 + 7\n\nn = ri()\nli = np.zeros(200000)\nfor _ in range(n):\n l, r = rm()\n li[l:r+1] = 1\nprint((int(sum(li))))\n\n\n\n\n\n\n\n", "n = int(input())\ntotal = 0\nfor i in range(n):\n l, r = map(int,input().split())\n total += r - l + 1\nprint(total)", "N = int(input())\nans = 0\n\nfor i in range(N):\n l,r = list(map(int, input().split()))\n ans += r - l + 1\nprint(ans)\n", "#k = int(input())\n#s = input()\n#a, b = map(int, input().split())\n#s, t = map(str, input().split())\n#l = list(map(int, input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n#a = [list(input()) for _ in range(n)]\n#a = [int(input()) for _ in range(n)]\n\n\nn = int(input())\n\nans = 0\n\nfor i in range(n):\n l, r = list(map(int, input().split()))\n ans += r - l + 1\nprint(ans)\n", "n = int(input())\nA = [tuple(map(int, input().split())) for _ in range(n)]\n\nans = 0\nfor l, r in A:\n ans += r - l + 1\nprint(ans)\n", "# ABC073\nN = int(input())\nL_R = [list(map(int, input().split())) for _ in range(N)]\nans = 0\nfor l, r in L_R:\n ans += r - l + 1\nprint(ans)\n", "n = int(input())\n\nnum = 0\n\nfor i in range(n):\n l,r = map(int,input().split())\n num += (r - l + 1)\n \nprint(num)", "IS = lambda: int(input())\nIA = lambda: [int(x) for x in input().split()]\nIM = lambda N: [IA() for _ in range(N)]\n\nans = 0\nfor l,r in IM(IS()):\n ans += r - l + 1\nprint(ans)", "def mapt(fn, *args):\n return tuple(map(fn, *args))\n\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\n\ndef main():\n n = int(input())\n data =[Input() for _ in range(n)]\n ans = 0\n for start, end in data:\n for _ in range(start, end+1):\n ans += 1\n print(ans)\n\n\nmain()", "n = int(input())\nans = 0\nfor i in range(n):\n l,r = map(int,input().split())\n ans += r+1-l\nprint(ans)", "N = int(input())\nans = 0\nfor i in range(N):\n l, r = list(map(int, input().split()))\n ans += r-l+1\nprint(ans)\n", "n = int(input())\ndata = [input().split() for i in range(n)]\nans = 0\nfor i in range(n):\n ans += int(data[i][1]) - int(data[i][0]) + 1\nprint(ans)", "n=int(input())\nans=0\nfor i in range(n):\n l,r=list(map(int,input().split()))\n ans+=r-l+1\nprint(ans)\n", "n = int(input())\nnum = 0\nfor i in range(n):\n l, r = map(int, input().split())\n num += (r - l) + 1\nprint(num)", "n = int(input())\nflg = [0]*100000\nfor _ in range(n):\n l,r = list(map(int,input().split()))\n for i in range(l,r+1):\n flg[i-1] = 1\nprint((flg.count(1)))\n", "N = int(input())\n\nans = 0\n\nfor i in range(N):\n L = input().split()\n ans += int(L[1]) - int(L[0]) + 1\n\nprint(ans)", "n = int(input())\ntmp = 0\nnum_person = []\nfor _ in range(n):\n l, r = map(int, input().split())\n tmp = r-l+1\n num_person.append(tmp)\n\nans = 0\nfor i in num_person:\n ans += i\n\nprint(ans)", "n = int(input())\nans = 0\nfor i in range(n):\n l, r = map(int, input().split())\n ans += r - l + 1\nprint(ans)", "n = int(input())\nans = 0\nfor i in range(n):\n l, r = map(int, input().split())\n ans += r - l + 1\nprint(ans)", "n = int(input())\nseat = [0] * 10 ** 6\nfor i in range(n):\n l, r = list(map(int, input().split()))\n for j in range(l, r + 1):\n seat[j - 1] = 1\n\nres = 0\nfor i in range(10 ** 6):\n if seat[i] == 1:\n res += 1\nprint(res)\n", "N = int(input())\nres = 0\nfor _ in range(N):\n l, r = list(map(int, input().split()))\n res += r - l + 1\n\nprint(res)\n", "n=int(input())\ncount=0\nfor _ in range(n):\n l,r=map(int,input().split())\n count+=r-l+1\nprint(count)", "N = int(input())\na = 0\nfor i in range(N):\n line = list(map(int,input().split()))\n a +=(line[-1]-line[0]+1)\nprint(a)", "N = int(input())\nans = 0\nfor _ in range(N):\n l,r = map(int,input().split())\n ans += (r-l)+1\nprint(ans)", "n = int(input())\na = 0\nfor _ in range(n):\n l, r = map(int, input().split())\n a += r - l + 1\nprint(a)", "N=int(input())\nans=0\nfor i in range(N):\n l,r=map(int,input().split())\n ans += r-l+1\nprint(ans)", "n =int(input())\n\ntotal = 0\nfor i in range(n):\n a = list(map(int, input().split()))\n total += a[1] - a[0] + 1\n\nprint(total)", "N=int(input())\nans=0\nfor i in range(N):\n L,R=map(int,input().split())\n ans+=R-L+1\nprint(ans)", "n = int(input())\nres = 0\nfor i in range(n):\n l, r = map(int, input().split())\n res += r - l + 1\nprint(res)", "N=int(input())\nans=0\nfor _ in range(N):\n l, r=map(int, input().split())\n ans+=r-l+1\nprint(ans)", "N = int (input ())\nx = 0\nfor i in range (N):\n s,g = map (int, input ().split ())\n le = g-s+1\n x += le\nprint (x)", "n = int(input())\ncnt = 0\nfor i in range(n):\n l, r = [int(x) for x in input().split()]\n cnt+=r-l+1\nprint(cnt)", "n = int(input())\nans = 0\nfor _ in range(n):\n l,r = map(int,input().split())\n ans += r-l\nprint(ans+n)", "n = int(input())\nl = [0] * n\nr = [0] * n\nfor i in range(n):\n l[i],r[i] = map(int, input().split())\nres = 0\n\nfor i in range(n):\n res += r[i]-l[i]+1\n\nprint(res)", "N = int(input())\nans = 0\nfor _ in range(N):\n l, r = (int(x) for x in input().split())\n ans += r-l+1\nprint(ans)", "a=int(input())\nx = \"\"\ny = 0\nfor i in range(a):\n x=input().split()\n y+=abs(int(x[0])-int(x[1]))+1\nprint(y)", "N=int(input())\nprint(sum(r-l+1 for l,r in (map(int,input().split()) for _ in range(N))))", "from typing import List\n\n\ndef answer(n: int, lrs: List[List[int]]) -> int:\n number_of_people_sitting = 0\n for lr in lrs:\n l, r = lr\n number_of_people_sitting += r - l + 1\n\n return number_of_people_sitting\n\n\ndef main():\n n = int(input())\n lrs = [map(int, input().split()) for _ in range(n)]\n print(answer(n, lrs))\n\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\nc = 0\nfor i in range(n):\n l,r = map(int, input().split())\n c += r-l+1\nprint(c)", "N=int(input())\nans=0\nfor _ in range(N):\n l,r=list(map(int,input().split()))\n ans+=r-l+1\nprint(ans)\n", "N = int(input())\n\nans = 0\n\nfor _ in range(N):\n l,r = map(int, input().split())\n ans += r - l + 1\n\nprint(ans)", "n = int(input())\nnum = 0\nfor i in range(n):\n l,r = map(int, input().split())\n num += (r-l+1)\nprint(num)", "N = int(input())\nl = [0] * N\nr = [0] * N\nfor i in range(N):\n l[i], r[i] = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n ans += r[i] - (l[i] - 1)\nprint(ans)\n", "n=int(input())\nlr=[list(map(int,input().split())) for i in range(n)]\nans=0\nfor i in range(n):\n ans+=(lr[i][1]-lr[i][0]+1)\nprint(ans)", "#\n# abc073 b\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"1\n24 30\"\"\"\n output = \"\"\"7\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"2\n6 8\n3 3\"\"\"\n output = \"\"\"4\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n LR = [list(map(int, input().split())) for _ in range(N)]\n\n ans = 0\n for lr in LR:\n l, r = lr\n ans += r - l + 1\n\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "n = int(input())\n# seat = [0] * 10 ** 6\nseat = [0] * 10 ** 5\nfor i in range(n):\n l, r = list(map(int, input().split()))\n for j in range(l, r + 1):\n seat[j - 1] = 1\n\nres = 0\n# for i in range(10 ** 6):\nfor i in range(10 ** 5):\n if seat[i] == 1:\n res += 1\nprint(res)\n", "N = int(input())\ncnt = 0\nfor _ in range(N):\n l, r = map(int, input().split())\n cnt += r - l + 1\nprint(cnt)", "n = int(input())\nans = 0\nfor i in range(n):\n a, b = map(int, input().split())\n ans += (b - a + 1)\nprint(ans)", "n = int(input())\n#a, b = map(int,input().split())\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\nans = 0\nfor i in range(n):\n l, r = list(map(int, input().split()))\n ans += r-l+1\nprint(ans)\n", "N = int(input())\nsum = 0\nfor i in range(N):\n l, r = map(int, input().split())\n sum += r - l + 1\nprint(sum)", "n = int(input())\nres = 0\nfor i in range(n):\n a = [int(x) for x in input().split()]\n res += a[1] - a[0] + 1\nprint(res)"] | {"inputs": ["1\n24 30\n", "2\n6 8\n3 3\n"], "outputs": ["7\n", "4\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 15,520 | |
6dac46a7ea16b113ca5d34df6c90da28 | UNKNOWN | In K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?
-----Constraints-----
- 2 β€ n, m β€ 100
-----Input-----
Input is given from Standard Input in the following format:
n m
-----Output-----
Print the number of blocks in K-city.
-----Sample Input-----
3 4
-----Sample Output-----
6
There are six blocks, as shown below: | ["a, b = map(int, input().split())\nprint((a - 1) * (b - 1))", "n,m = map(int,input().split())\n\nprint((n-1)*(m-1))", "m, n = map(int, input().split())\nprint((m - 1) * (n - 1))", "a,b = map(int,input().split())\nprint((a-1)*(b-1))", "x,y=map(int,input().split())\n\nprint((x-1)*(y-1))", "n, m = list(map(int, input().split()))\nprint(((n-1)*(m-1)))\n", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "#\n# abc069 a\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"3 4\"\"\"\n output = \"\"\"6\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"2 2\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n n, m = list(map(int, input().split()))\n print(((n-1)*(m-1)))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "nums = list(map(int, input().split()))\nprint((nums[0] - 1) * (nums[1] - 1))", "n, m = map(int, input().split())\nprint((n-1) * (m-1))", "n,m = map(int,input().split())\nprint((n-1)*(m-1))", "N,M=map(int,input().split())\nprint((N-1)*(M-1))", "n, m = list(map(int, input().split()))\nprint(((n - 1) * (m - 1)))\n", "a,b=map(int,input().split())\nprint((a-1)*(b-1))", "n,m = map(int,input().split())\nprint((n - 1)*(m - 1))", "n, m = map(int, input().split())\nprint((n-1)*(m-1))", "n, m = map(int, input().split())\nans = (n-1)*(m-1)\nprint(ans)", "n,m = map(int,input().split())\n \nprint((n-1)*(m-1)) ", "a,b=map(int,input().split())\nprint((a-1)*(b-1))", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "n, m = map(int,input().split())\n\nprint((n - 1) * (m - 1))", "a,b=map(int,input().split())\nprint((a-1)*(b-1))", "a,b = map(int,input().split())\nprint((a-1)*(b-1))", "n,m = list(map(int, input().split()))\nprint(( (n-1)*(m-1) ))\n", "n,m = map(int,input().split())\nprint((n-1)*(m-1))", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "n, m = map(int, input().split())\nans = (n - 1) * (m - 1)\n\nprint(ans)", "n, m = map(int, input().split())\nprint(~-n * ~-m)", "a,b = map(int, input().split())\nprint((a-1)*(b-1))", "n, m = map(int,input().split())\nprint((n-1)*(m-1))", "n,m = map(int,input().split())\n\nprint((n+1)*(m+1)-2*(n+1)-(m+1-2)*2)", "n,m = map(int,input().split())\nprint((n-1)*(m-1))", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "a,b=map(int,input().split(\" \"))\nprint((a-1)*(b-1))", "n,m=map(int, input().split()) \nprint((n-1)*(m-1))", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "n, m = map(int, input().split())\nprint((n-1)*(m-1))", "a,b=list(map(int,input().split()))\nprint(((a-1)*(b-1)))\n", "n, m = map(int, input().split())\nprint((n-1)*(m-1))", "n,m = map(int, input().split())\nprint((n-1)*(m-1))", "a, b = map(int, input().split())\na -= 1\nb -= 1\nprint(a * b)", "n, m = map(int, input().split())\nprint((n - 1) * (m - 1))", "N,M=list(map(int,input().split()))\nprint(((N-1)*(M-1)))\n", "n,m = map(int,input().split())\nprint((n-1)*(m-1))", "N, M = map(int, input().split())\nprint((N-1)*(M-1))", "x,y=map(int,input().split())\nprint((x-1)*(y-1))", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "a, b = map(int, input().split())\n\nprint((a - 1) * (b - 1))", "n, m = map(int, input().split())\nprint((n - 1) * (m - 1))", "n, m = list(map(int,input().split(\" \")))\nprint(((n - 1) * (m - 1)))\n", "n, m = map(int, input().split())\nprint((n-1)*(m-1))", "n, m = map(int, input().split())\n\nprint((n-1) * (m-1))", "a,b=map(int,input().split())\nprint((a-1)*(b-1))", "a, b = map(int, input().split())\na = a-1\nb = b-1\nprint(a*b)", "a, b = map(int, input().split())\nprint((a-1) * (b-1))", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "n, m = list(map(int, input().split()))\nprint(((n - 1) * (m - 1)))\n", "a,b=map(int,input().split())\nprint((a-1)*(b-1))", "n,m = map(int,input().split())\nprint((n-1)*(m-1))", "a, b = map(int, input().split())\nprint((a-1) * (b-1))", "n,m = map(int,input().split())\nprint((n-1)*(m-1))", "n,m =map(int,input().split())\nprint((n-1)*(m-1))", "N, M = map(int, input().split())\nprint((N-1)*(M-1))", "#n = int(input())\nn,m = map(int,input().split())\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\nprint((m-1)*(n-1))", "m,n = map(int,input().split())\nprint((m-1)*(n-1))", "n, m= map(int, input().split())\nprint((n-1)*(m-1))", "n,m = list(map(int,input().split()))\nprint(((n-1)*(m-1)))\n", "a = input().split()\nb,c = int(a[0]),int(a[1])\nprint((b-1)*(c-1))", "a, b = input().split()\n\nprint((int(a) - 1) * (int(b) - 1))", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "W, H = map(int, input().split())\nprint((W-1)*(H-1))", "N,M=map(int,input().split())\nprint((N-1)*(M-1))", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "n,m=map(int,input().split());print((n-1)*(m-1))", "n,m=map(int,input().split())\nprint((n-1)*(m-1))", "n, m = list(map(int, input().split()))\n\nprint(((n - 1) * (m - 1)))\n", "n, m = list(map(int, input().split()))\nprint(((n - 1) * (m - 1)))\n", "def iroha():\n a, b = list(map(int, input().split()))\n print(((a-1)*(b-1)))\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "n, m = map(int, input().split())\n\narea = (n - 1) * (m - 1)\nprint(area)", "a,b = map(int, input().split())\nprint((a-1)*(b-1))", "a,b = map(int,input().split())\nprint((a-1) * (b-1))", "a,b=input().split()\na=int(a)\nb=int(b)\nprint((a-1)*(b-1))", "a,b=map(int,input().split())\nprint((a-1)*(b-1))", "n,m = [int(x) for x in input().split()]\nprint((n-1)*(m-1))", "a,b = map(int,input().split())\nprint((a-1) * (b-1))", "a,b=map(int,input().split())\nprint((a-1)*(b-1))", "#!/usr/bin/env python3\n\ndef main():\n n, m = list(map(int, input().split()))\n print(((n - 1) * (m - 1)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n, m = list(map(int, input().split()))\nprint(((n-1)*(m-1)))\n", "n, m = map(int, input().split())\n\nif n == 1 or m == 1:\n print(0)\nelse:\n print((n - 1) * (m - 1))", "lst = input().split()\nprint((int(lst[0]) - 1) * (int(lst[1]) - 1))", "x,y =map(int,input().split())\nprint((x-1)*(y-1))", "'''\nABC069 A - K-City\nhttps://atcoder.jp/contests/abc069/tasks/abc069_a\n'''\nn, m = list(map(int, input().split()))\nans = (n-1)*(m-1)\nprint(ans)\n", "n, m = map(int, input().split())\n\nans = (n-1) * (m-1)\nprint(ans)", "with open(0) as f:\n n, m = map(int, f.read().split())\nprint((n-1)*(m-1))", "n, m = map(int, input().split())\nprint((n - 1) * (m - 1))", "N,M = map(int,input().split())\nprint((N-1)*(M-1))", "a,b=map(int,input().split())\n\nprint((a-1)*(b-1))", "n, m = map(int, input().split())\nprint((n-1)*(m-1))", "n, m = list(map(int, input().split()))\n# D = list(map(int,input().split()))\n# S = input()\n# X1_list = [int(input()) for i in range(N)]\n# X2_list = [list(map(int,input().split())) for i in range(N)]\n\nprint(((n - 1) * (m - 1)))\n", "a, b = map(int, input().split())\nprint((a-1)*(b-1))"] | {"inputs": ["3 4\n", "2 2\n"], "outputs": ["6\n", "1\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 7,397 | |
238ec6f4fd934b89e8f6b6c80c5f091d | UNKNOWN | Snuke is giving cookies to his three goats.
He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).
Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.
-----Constraints-----
- 1 \leq A,B \leq 100
- Both A and B are integers.
-----Input-----
Input is given from Standard Input in the following format:
A B
-----Output-----
If it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.
-----Sample Input-----
4 5
-----Sample Output-----
Possible
If Snuke gives nine cookies, each of the three goats can have three cookies. | ["A, B = map(int, input().split())\nC = A + B\n\nprint(\"Possible\" if A%3==0 or B%3==0 or C%3==0 else \"Impossible\")", "A, B = map(int, input().split())\n\nif A%3 and B%3 and (A+B)%3:\n print(\"Impossible\")\nelse:\n print(\"Possible\")", "A, B = map(int, input().split())\n\n# A, B, A+B \u306e\u3044\u305a\u308c\u304b\u306e\u679a\u6570\u306e\u30af\u30c3\u30ad\u30fc\u3092\u30e4\u30ae\u305f\u3061\u306b\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u308b\n# 3\u5339\u306e\u30e4\u30ae \u304c\u540c\u3058\u679a\u6570\u305a\u3064\u98df\u3079\u3089\u308c\u308b\u3088\u3046\u306b\u30af\u30c3\u30ad\u30fc\u3092\u6e21\u3059\u3053\u3068\u304c\u53ef\u80fd\u306a\u3089\u3070 'Possible' \u3068\u3001\u305d\u3046\u3067\u306a\u3051\u308c\u3070 'Impossible' \u3068\u51fa\u529b\n\nif A % 3 == 0:\n print('Possible')\nelif B % 3 == 0:\n print('Possible')\nelif (A + B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "a=list(map(int,input().split()))\nb=sum(a)\n \nif (b%3 ==0 or a[0]%3 ==0 or a[1]%3==0) :\n print('Possible')\nelse :\n print('Impossible')", "a,b = map(int,input().split())\nif a % 3 == 0:\n print(\"Possible\")\nelif b % 3 == 0:\n print(\"Possible\")\nelif (a + b) % 3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "# \u5165\u529b\nA, B = map(int,input().split())\n\n# \u51e6\u7406\nif (A + B) % 3 == 0 or A % 3 == 0 or B % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "a, b = map(int, input().split())\nprint((\"Impossible\", \"Possible\")[a % 3 * b % 3 * (a + b) % 3 == 0])", "a,b = map(int,input().split())\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "# A - Sharing Cookies\n\n# A,B,A+B\u306e\u3044\u305a\u308c\u304b\u304c3\u306e\u500d\u6570\u304b\u3069\u3046\u304b\u5224\u5b9a\u3059\u308b\n\n\nA,B = list(map(int,input().split()))\n\nif A % 3 == 0\\\nor B % 3 == 0\\\nor (A+B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')\n", "a,b=list(map(int,input().split()))\nprint((\"Possible\" if any([x % 3 == 0 for x in [a,b,a+b]]) else \"Impossible\"))\n", "A, B = list(map(int, input().split()))\n\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')\n", "a,b = map(int,input().split())\n\nif a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "a, b = map(int, input().split())\nif a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "a, b = (int(x) for x in input().split())\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0: ans = 'Possible'\nelse: ans = 'Impossible'\nprint(ans)", "A,B = map(int,input().split())\nif A%3==0 or B%3==0 or (A+B)%3==0:print(\"Possible\")\nelse : print(\"Impossible\")", "A, B = map(int, input().split())\nprint(\"Possible\" if A * B * (A + B) % 3 == 0 else \"Impossible\")", "a,b=list(map(int ,input().split()))\nif(a%3==0 or b%3==0 or (a+b)%3==0):\n\tprint(\"Possible\")\nelse:\n\tprint(\"Impossible\")\n", "A,B = map(int,input().split())\n\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 ==0: # 3\u3067\u5272\u3063\u3066\u4f59\u308a\u304c\u51fa\u306a\u3051\u308c\u3070\u30013\u5339\u5e73\u7b49\u306b\u6e21\u305b\u308b\n print('Possible')\n\nelse:\n print('Impossible')", "a,b=map(int, input().split())\nif a%3==0 or b%3==0 or a%3!=b%3:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "A,B=list(map(int,input().split()))\nC=A+B\nif ((A>=3)&(A%3==0)) | ((B>=3)&(B%3==0)) | ((C>=3)&(C%3==0)):\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n", "a, b = map(int, input().split())\nif (a + b) % 3 == 0 or b % 3 == 0 or a % 3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "S_list = list(map(int,input().split()))\n\nA, B = S_list[0], S_list[1]\nif (A * B * (A + B)) % 3 == 0 :\n result = \"Possible\"\nelse:\n result = \"Impossible\"\nprint(result)\n", "a,s=map(int,input().split())\nprint(\"Impossible\"if a%3 and s%3 and a%3==s%3 else \"Possible\")", "a, b =map(int, input().split())\n\nif a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "A,B=map(int,input().split())\nif A%3==0 or B%3==0 or (A+B)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "a,b=map(int,input().split())\n\nif a%3==0 or b%3==0 or (a+b)%3==0:\n ans=\"Possible\"\nelse:\n ans=\"Impossible\"\nprint(ans)", "a, b = map(int, input().split())\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "#n = int(input())\na, b = list(map(int, input().split()))\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n\nif a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')\n", "# 067_a\nA,B=map(int,input().split())\nif (1<=A and A<=100)and(1<=B and B<=100):\n sum=A+B\n if A%3==0 or B%3==0 or sum%3==0:\n print('Possible')\n else:\n print('Impossible')", "a, b = (int(x) for x in input().split())\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')\n", "a,b=map(int,input().split())\nif a%3 == 0:\n print(\"Possible\")\nelif b%3 == 0:\n print(\"Possible\")\nelif (a+b)%3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "a,b=map(int,input().split())\nif a%3==0 or b%3==0 or (a+b)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "a, b = map(int, input().split())\n\nif (a + b) % 3 == 0 or b % 3 == 0 or a % 3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "# A,B,A+B\u306e\u3044\u305a\u308c\u304b\u304c3\u306e\u500d\u6570\u306b\u306a\u308b\u304b\n\nA, B = list(map(int, input().split()))\n\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 ==0:\n print('Possible')\nelse:\n print('Impossible')\n", "a, b = map(int, input().split())\n\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible') ", "A_mai, B_mai = map(int, input().split())\nsumm = A_mai + B_mai\n\nif (A_mai % 3 == 0 or B_mai % 3 == 0 or summ % 3 == 0):\n print('Possible')\nelse:\n print('Impossible')", "A,B = map(int,input().split())\n\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "a, b = list(map(int, input().split()))\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n", "a,b=map(int,input().split())\nif a%3==0 or b%3==0 or (a+b)%3==0:print(\"Possible\")\nelse:print(\"Impossible\")", "a, b = list(map(int, input().split()))\nif a % 3 == 0 or b % 3 == 0:\n print(\"Possible\")\nelif a % 3 == 1 and b % 3 == 2:\n print(\"Possible\")\nelif a % 3 == 2 and b % 3 == 1:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n", "A, B = map(int, input().split())\n\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "a,b=map(int,input().split())\nif a%3==0 or b%3==0 or (a+b)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "A, B = map(int, input().split())\nprint('Possible' if (A*B%3==0) or ((A+B)%3==0) else 'Impossible')", "a,b = map(int,input().split())\nif a%3 == 0 or b % 3 == 0 or (a+b)%3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "a,b=map(int,input().split());print(['Imp','P'][a%3==0 or b%3==0 or (a+b)%3==0]+'ossible')", "a, b = map(int, input().split())\n# int\u306f\u5165\u529b\u306b\u5bfe\u3057\u3066\u306e\u95a2\u6570\u3001\u51fa\u529b\u3067\u306f\u306a\u3044\n\nif (a+b)%3 == 0:\n print(\"Possible\")\nelif a%3 == 0:\n print(\"Possible\")\nelif b%3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "# \u30af\u30c3\u30ad\u30fc\u679a\u6570\uff08A,B\uff09\u3092\u6574\u6570\u3067\u5165\u529b\nA,B = map(int,input().split())\n# A\u304bB\u304bA+B\u306e\u3069\u308c\u304b\u30923\u5339\u306b\u5206\u3051\u308c\u308c\u3070Possible\u3001\u3067\u304d\u306a\u3051\u308c\u3070Impossible\nif A%3==0 or B%3==0 or (A+B)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "a, b = map(int, input().split())\n\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "A,B=list(map(int,input().split()))\nif A%3==0 or B%3==0 or (A+B)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n", "# AtCoder abc067 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\na, b = list(map(int, input().split()))\n\n# \u5224\u5b9a\nif (a % 3 == 0) or (b % 3 == 0) or ((a + b) % 3 == 0):\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n", "a,b = list(map(int,input().split()))\nprint((\"Possible\" if a%3==0 or b%3==0 or (a+b)%3==0 else \"Impossible\"))\n", "a,b=input().split()\na=int(a)\nb=int(b)\nif ((a+b)%3)==0:\n print(\"Possible\")\nelse:\n if (a%3)==0:\n print(\"Possible\")\n else:\n if (b%3)==0:\n print(\"Possible\")\n else:\n print(\"Impossible\")", "a, b = list(map(int, input().split()))\n\nbool_a = a % 3 == 0\nbool_b = b % 3 == 0\nbool_ab = (a + b) % 3 == 0\n\nif bool_a or bool_b or bool_ab:\n print('Possible ')\nelse:\n print('Impossible ')\n", "A,B = map(int, input().split())\nprint('Possible' if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0 else 'Impossible')", "a, b = map(int,input().split())\nif a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0: \n print('Possible')\nelse:\n print('Impossible')", "a, b = list(map(int, input().split()))\nif a%3==0 or b%3==0 or (a+b)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n", "a,b = [int(x) for x in input().split()]\nif a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "lst = input().split()\n\nA = int(lst[0])\nB = int(lst[1])\n\nif (A % 3 == 0) or (B % 3 == 0) or ((A + B) % 3 == 0):\n print('Possible')\nelse:\n print('Impossible')", "A, B = map(int, input().split())\nprint('Possible' if (A*B%3==0) or ((A+B)%3==0) else 'Impossible')", "A, B = map(int,input().split())\n\nif A % 3 == 0 or B % 3 ==0 or (A + B) % 3 ==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "A, B = map(int, input().split())\nprint('Possible' if A%3==0 or B%3==0 or (A+B)%3==0 else 'Impossible')", "# \u5165\u529b\nA, B = map(int, input().split())\n\n# \u51fa\u529b\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "A, B = map(int, input().split())\n\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "A, B = map(int, input().split())\nprint('Possible' if (A*B%3==0) or ((A+B)%3==0) else 'Impossible')", "a, b=map(int, input().split())\nif a%3==0 or b%3==0 or (a+b)%3==0:\n print('Possible')\nelse:\n print('Impossible')", "a, b = map(int, input().split())\n\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "a,b = list(map(int,input().split()))\nprint((\"Possible\" if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0 else \"Impossible\"))\n", "a,b = map(int,input().split())\n\nif a%3 == 0 or b%3 == 0 or (a+b)%3 ==0:\n print('Possible')\n \nelse:\n print('Impossible')", "a,b=map(int, input().split())\nprint(\"Possible\" if a*b*(a+b)%3==0 else \"Impossible\")", "A, B = map(int, input().split())\nif A%3==0 or B%3==0 or (A+B)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "a, b = input().split()\n\nif int(a) % 3 == 0 or int(b) % 3 == 0 or (int(a) + int(b)) % 3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "x,y=map(int,input().split())\nif x%3==0 or y%3==0 or (x+y)%3==0:\n print('Possible')\nelse:\n print('Impossible')", "A, B = map(int, input().split())\n\ntotal = A + B\n\nif total % 3 == 0 or A % 3 ==0 or B % 3 ==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "a,b=list(map(int,input().split()))\nif a%3==0 or b%3==0 or (a+b)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")\n", "def iroha():\n a,b = map(int, input().split())\n aa = a % 3\n bb = b % 3\n cc = (a+b) % 3\n\n print(\"Possible\") if aa == 0 or bb == 0 or cc == 0 else print(\"Impossible\")\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "# \u5165\u529b\nA, B = map(int, input().split())\n\n# A,B,A+B\u306e\u3046\u3061\u3069\u308c\u304b1\u3064\u3067\u30823\u3067\u5272\u308a\u5207\u308c\u308c\u3070Possible\nif A % 3 == 0:\n print('Possible')\nelif B % 3 == 0:\n print('Possible')\nelif (A + B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "a,b = map(int,input().split())\nprint(\"Possible\" if a%3==0 or b%3==0 or (a+b)%3==0 else \"Impossible\")", "a,b = map(int,input().split())\nif a%3==0 or b%3==0 or (a+b)%3==0:\n print('Possible')\nelse:\n print('Impossible')", "# A - Sharing Cookies\n\n# 3\u5339\u306e\u30e4\u30ae\u306b\u30af\u30c3\u30ad\u30fc\u3092\u6e21\u3057\u305f\u3044\n# A \u679a\u5165\u3063\u305f\u30af\u30c3\u30ad\u30fc\u304c\u5165\u3063\u305f\u7f36\n# B \u679a\u5165\u3063\u305f\u30af\u30c3\u30ad\u30fc\u304c\u5165\u3063\u305f\u7f36\n# A B \u7f36\u3092\u6301\u3063\u3066\u3044\u308b\u3002\n\n# A, B, A + B \u306e\u3044\u305a\u308c\u304b\u306e\u679a\u6570\u3092\u30e4\u30ae\u306b\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u308b\n\n# 3\u5339\u306e\u30e4\u30ae\u304c\u540c\u3058\u679a\u6570\u98df\u3079\u308c\u308b\u3088\u3046\u306b\u6e21\u305b\u308b\u304b\u5224\u5b9a\u3059\u308b\n# \u53ef\u80fd\u306a\u3089 Possible \u4e0d\u53ef\u80fd\u306a\u3089 Impossible\n\n# A B \u3092\u6a19\u6e96\u5165\u529b\u3067\u53d6\u5f97\nA, B = list(map(int, input().split()))\n# print(A, B)\n\n# A \u306e\u5834\u5408 B\u306e\u5834\u5408 A + B \u306e\u5834\u5408\u3067\u5206\u3051\u308b\n# \u305d\u308c\u305e\u308c\u306e\u4f59\u308a\u304c 0 \u306e\u6642 Possible\n# \u305d\u308c\u4ee5\u5916\u306f Impossible\n\nif A % 3 == 0:\n answer = \"Possible\"\nelif B % 3 == 0:\n answer = \"Possible\"\nelif (A + B) % 3 ==0:\n answer = \"Possible\"\nelse:\n answer = \"Impossible\"\n\n# \u7d50\u679c\u3092\u51fa\u529b\nprint(answer)\n", "a,b=map(int, input().split())\nif a%3==0 or b%3==0 or (a+b)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "A, B = map(int, input().split())\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "A, B = map(int, input().split())\n\nprint(\"Possible\" if (A * B * (A+B)) % 3 == 0 else \"Impossible\")", "'''\nABC067 A - Sharing Cookies\nhttps://atcoder.jp/contests/abc067/tasks/abc067_a\n'''\n\na, b = list(map(int, input().split()))\nif a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:\n ans = \"Possible\"\nelse:\n ans = \"Impossible\"\nprint(ans)\n", "# A - Sharing Cookies\n# https://atcoder.jp/contests/abc067/tasks/abc067_a\n\nA, B = list(map(int, input().split()))\n\nresult = 'Impossible'\n\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:\n result = 'Possible'\n\nprint(result)\n", "A, B = list(map(int, input().split()))\n\nfor i in [A, B, A + B]:\n if i % 3 == 0:\n print(\"Possible\")\n return\nprint(\"Impossible\")\n", "# \u679a\u6570\u3092\u53d6\u5f97\nA,B = map(int,input().split())\nTotal = A + B\n\n# \u3044\u305a\u308c\u304b\u306e\u30d1\u30bf\u30fc\u30f3\u30673\u5206\u5272\u5747\u7b49\u306b\u3067\u304d\u308b\u304b\u3092\u5224\u5b9a\u5f8c\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\nif A % 3 == 0 \\\nor B % 3 == 0 \\\nor Total % 3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "A,B=map(int,input().split())\nif A%3==0 or B%3==0 or (A+B)%3==0 :\n print(\"Possible\")\nelse :\n print(\"Impossible\")", "a, b = map(int, input().split())\n\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "a,b=map(int,input().split())\nif a%3==0 or b%3==0 or (a+b)%3==0:print('Possible')\nelse:print('Impossible')", "A, B = map(int,input().split())\n\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0 :\n print( \"Possible\" )\nelse:\n print( \"Impossible\" )", "A, B = map(int, input().split())\nprint('Possible' if (A*B%3==0) or ((A+B)%3==0) else 'Impossible')", "#\n# abc067 a\n#\nimport sys\nfrom io import StringIO\nimport unittest\n\n\nclass TestClass(unittest.TestCase):\n def assertIO(self, input, output):\n stdout, stdin = sys.stdout, sys.stdin\n sys.stdout, sys.stdin = StringIO(), StringIO(input)\n resolve()\n sys.stdout.seek(0)\n out = sys.stdout.read()[:-1]\n sys.stdout, sys.stdin = stdout, stdin\n self.assertEqual(out, output)\n\n def test_\u5165\u529b\u4f8b_1(self):\n input = \"\"\"4 5\"\"\"\n output = \"\"\"Possible\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"1 1\"\"\"\n output = \"\"\"Impossible\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n A, B = list(map(int, input().split()))\n if A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0:\n print(\"Possible\")\n else:\n print(\"Impossible\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "a,b = map(int,input().split())\nif a%3 == 0 or b%3 == 0 or (a+b)%3 == 0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "# 067a\n\nA, B = list(map(int, input().split()))\n\nif A % 3 == 0 or B % 3 == 0 or (A + B) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')\n", "a, b = map(int, input().split())\n\ntotal = a + b\nif total % 3 == 0:\n print('Possible')\nelif a % 3 == 0:\n print('Possible')\nelif b % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "# \u3059\u306c\u3051\u304f\u3093\u306f 3\u5339\u306e\u30e4\u30ae\u306b\u30af\u30c3\u30ad\u30fc\u3092\u6e21\u3057\u305f\u3044\u3067\u3059\u3002\n# \u3059\u306c\u3051\u304f\u3093\u306f A\u679a\u306e\u30af\u30c3\u30ad\u30fc\u304c\u5165\u3063\u305f\u7f36\u3068\u3001\n# B\u679a\u306e\u30af\u30c3\u30ad\u30fc\u304c\u5165\u3063\u305f\u7f36\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002\n# \u3059\u306c\u3051\u304f\u3093\u306f A, B, A + B \u306e\u3044\u305a\u308c\u304b\u306e\u679a\u6570\u306e\u30af\u30c3\u30ad\u30fc\u3092\n# \u30e4\u30ae\u305f\u3061\u306b\u6e21\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\n# 3\u5339\u306e\u30e4\u30ae\u304c\u540c\u3058\u679a\u6570\u305a\u3064\u98df\u3079\u3089\u308c\u308b\u3088\u3046\u306b\n# \u30af\u30c3\u30ad\u30fc\u3092\u6e21\u3059\u3053\u3068\u304c\u53ef\u80fd\u304b\u3069\u3046\u304b\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# 1 \u2266 A, B \u2266 100\n# A, B \u306f\u3044\u305a\u308c\u3082\u6574\u6570\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 A, B \u3092\u53d6\u5f97\u3059\u308b\na, b = list(map(int, input().split()))\n\n\nresult = \"ret\"\n\n# \u4ee5\u4e0b\u3001\u5224\u5b9a\u51e6\u7406\nif a % 3 == 0: # A\u306e\u7f36\u3060\u3051\u3092\u6e21\u3057\u3066\u30013\u7b49\u5206\u3067\u304d\u308b\n result = \"Possible\"\nelif b % 3 == 0: # B\u306e\u7f36\u3060\u3051\u3092\u6e21\u3057\u3066\u30013\u7b49\u5206\u3067\u304d\u308b\n result = \"Possible\"\nelif (a + b) % 3 == 0: # A + B \u7f36\u3092\u6e21\u3057\u3066\u30013\u7b49\u5206\u3067\u304d\u308b\n result = \"Possible\"\nelse:\n result = \"Impossible\"\n\nprint(result)\n", "a,b=map(int,input().split())\nif a%3==0 or b%3==0 or (a+b)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")", "a,b = map(int,input().split())\n\nif a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0:\n print('Possible')\nelse:\n print('Impossible')", "a,b=map(int,input().split())\nif a*b*(a+b)%3==0:\n print(\"Possible\")\nelse:\n print(\"Impossible\")"] | {"inputs": ["4 5\n", "1 1\n"], "outputs": ["Possible\n", "Impossible\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 19,706 | |
b3dca7dd08118d9374070f5eb0ddc105 | UNKNOWN | E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with ?.
One more thing he found is a sheet of paper with the following facts written on it:
- Condition 1: The string S contains a string T as a contiguous substring.
- Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.
If such a string does not exist, print UNRESTORABLE.
-----Constraints-----
- 1 \leq |S'|, |T| \leq 50
- S' consists of lowercase English letters and ?.
- T consists of lowercase English letters.
-----Input-----
Input is given from Standard Input in the following format:
S
T'
-----Output-----
Print the string S.
If such a string does not exist, print UNRESTORABLE instead.
-----Sample Input-----
?tc????
coder
-----Sample Output-----
atcoder
There are 26 strings that satisfy Condition 1: atcoder, btcoder, ctcoder,..., ztcoder.
Among them, the lexicographically smallest is atcoder, so we can say S = atcoder. | ["# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 28 02:20:36 2020\n\n@author: liang\n\"\"\"\nS = input()\nT = input()\n\nS = S[::-1]\nT = T[::-1]\n\nres = list()\n\nfor i in range(len(S)-len(T)+1):\n flag = True\n for j in range(len(T)):\n if S[i+j] == \"?\" or S[i+j] == T[j]:\n continue\n else:\n flag = False\n if flag == True:\n ans = \"\"\n for k in range(len(S)):\n if i <= k <= i + len(T)-1:\n #print(T[k-i])\n ans += T[k-i]\n elif S[k] != \"?\":\n #print(\"B\")\n ans += S[k]\n else:\n #print(\"C\")\n ans += \"a\"\n ans = ans[::-1]\n res.append(ans)\n\nif res:\n res.sort()\n print((res[0]))\nelse:\n print(\"UNRESTORABLE\")\n#print(S)\n#print(T)\n", "s = input()\nt = input()\n\nls = len(s)\nlt = len(t)\ncheck = False\nans = 'z'*60\nfor i in range(ls-lt+1):\n u = list(s)\n flag = True\n for j in range(lt):\n if u[i+j] == '?':\n u[i+j] = t[j]\n elif u[i+j] != t[j]:\n flag = False\n break\n if flag:\n check = True\n u = ''.join(u).replace('?', 'a')\n ans = sorted([ans, u])[0]\nprint(ans if check else 'UNRESTORABLE')", "S_ = list(input())\nT = input()\n#\u5f8c\u308d\u304b\u3089\u63a2\u7d22\u3059\u308b\n\nn = len(S_)\nm = len(T)\nnonexist = 1\nfor i in range(n-1, m-2, -1):\n flg = True\n for j in range(m):\n if (S_[i-j] != T[-j-1]) and (S_[i-j] != \"?\"):\n flg = False\n break\n if flg:\n nonexist = 0\n index = i\n break\n\nif nonexist:\n print(\"UNRESTORABLE\")\n return\n\nindex -= m-1\nfor i in range(m):\n S_[index+i] = T[i]\n\nfor i in range(n):\n if S_[i] == \"?\":\n S_[i] = \"a\"\nprint((\"\".join(S_)))\n", "s = input()\nt = input()\n\nfor i in range(len(s) - len(t) + 1)[::-1]:\n cnt = 0\n q = 0\n for j in range(len(t))[::-1]:\n if s[i + j] == '?':\n q += 1\n elif s[i + j] == t[j]:\n cnt += 1\n \n if cnt == len(t) - q:\n idx = i\n s = s[:idx] + t + s[idx + len(t):]\n for k in range(len(s)):\n if s[k] == '?':\n s = s[:k] + 'a' + s[k + 1:]\n print(s)\n break\nelse:\n print('UNRESTORABLE')", "s = input()[::-1]\nt = input()[::-1]\n\ndef match(string,substring):\n for a,b in zip(string, substring):\n if a == '?':\n continue\n if a != b:\n return False\n return True\n\n# \u306a\u308b\u3079\u304f\u5f8c\u65b9\u3067\u4e00\u81f4\u3055\u305b\u308b\nLEN_S = len(s)\nLEN_T = len(t)\nans = ''\nfor i in range(LEN_S - LEN_T + 1):\n sub = s[i:i+LEN_S]\n if match(sub, t):\n ans = s[:i] + t + s[i+LEN_T:]\n ans = ans[::-1].replace('?', 'a')\n break\nelse:\n print('UNRESTORABLE')\n return\n\nprint(ans)", "s = list(input())\nt = list(input())\nnum = len(t)\n\nfail = 'UNRESTORABLE'\nflag = False\nans = []\ncount_out = 0\n\nfor i in range(len(s)):\n start = i\n end = i + len(t)\n if (end > len(s)):\n break\n tar = s[start:end]\n # print(tar)\n index = 0\n name_flag = True\n\n for a, b in zip(tar, t):\n # print(tar[index])\n if (a == b):\n pass\n elif (a == '?'):\n tar[index] = str(b)\n else:\n name_flag = False\n break\n\n index += 1\n\n if (name_flag is False):\n ans.append(['z'] * len(s))\n count_out += 1\n else:\n pre_org = s[:start]\n # pre = pre_org.replace('?', 'a')\n post_org = s[end:]\n # post = post_org.replace('?', 'a')\n\n # tar_mod = pre + tar + post\n tar_mod = pre_org + tar + post_org\n ans.append(tar_mod)\n\n# print(ans)\nif (count_out == (len(s) - len(t) + 1)):\n print(fail)\nelse:\n ans_s = sorted(ans)\n aa = ans_s[0]\n a2 = ''.join(aa)\n a3 = a2.replace('?', 'a')\n print(a3)\n", "s = input()\nt = input()\n\ns_streak = 0\ns_streak_ind = -1\n\n\nfor j in range(len(s)-1, -1, -1):\n\tfor i in range(j, -1, -1):\n\t\tif s_streak_ind == -1:\n\t\t\tif s[i] == \"?\" or s[i] == t[len(t)-1-s_streak]:\n\t\t\t\tif s_streak == len(t) - 1:\n\t\t\t\t\ts_streak_ind = i\n\t\t\t\t\ts_streak = 0\n\t\t\t\telse:\n\t\t\t\t\ts_streak += 1\n\t\t\telse:\n\t\t\t\ts_streak = 0\n\ts_streak = 0\n\n#print(s_streak_ind)\n\nif s_streak_ind == -1:\n\tprint(\"UNRESTORABLE\")\nelse:\n\tansl = []\n\tfor i in range(len(s)):\n\t\tif s[i] == \"?\":\n\t\t\tif s_streak_ind <= i < s_streak_ind+len(t):\n\t\t\t\tansl.append(t[i-s_streak_ind])\n\t\t\telse:\n\t\t\t\tansl.append(\"a\")\n\t\telse:\n\t\t\tansl.append(s[i])\n\tprint(\"\".join(ansl))", "S = list(input())\nT = list(input())\ns = len(S)\nt = len(T)\nfor i in range(s-t,-1,-1):\n ss = S[i:i+t]\n for j in range(t):\n if ss[j] != \"?\" and ss[j] != T[j]:\n break\n else:\n for j in range(t):\n if ss[j] == \"?\":\n S[i+j] = T[j]\n break\nelse:\n print(\"UNRESTORABLE\")\n return\nfor i in range(s):\n if S[i] == \"?\":\n S[i] = \"a\"\nprint(\"\".join(S))", "import copy\nS = list(input())\nT = input()\nlS = len(S)\nlT = len(T)\nans = []\nfor s in range(lS-lT+1):\n temp = copy.copy(S)\n for t in range(lT):\n if temp[s+t] != T[t] and temp[s+t] != '?':\n break\n else:\n temp[s+t] = T[t]\n else:\n temp = [temp[i] if temp[i] != '?' else 'a' for i in range(lS)]\n ans.append(''.join(temp))\nans = sorted(ans)\nif len(ans) == 0:\n print('UNRESTORABLE')\nelse:\n print(ans[0])", "S_ = input()\nT = input()\nlen_T = len(T)\nlen_S = len(S_)\n\nA = []\nfor i in range(len_S - len_T + 1):\n flg = True\n for t, s in zip(T, S_[i:i + len_T]):\n if s != '?' and s != t:\n flg = False\n if flg == True:\n S = ''\n for j in range(len_S):\n if i <= j < i + len_T:\n S += T[j - i]\n elif S_[j] == '?':\n S += 'a'\n else:\n S += S_[j]\n A.append(S)\n\nans = 'z' * (len_S + 1)\nfor S in A:\n if S < ans:\n ans = S\nif ans == 'z' * (len_S + 1):\n print('UNRESTORABLE')\nelse:\n print(ans)", "S=input()\nT=input()\nL,M=len(S),len(T)\na=-1\nfor i in range(L-M,-1,-1):\n if sum([1 for j in range(M) if S[i+j]=='?' or S[i+j]==T[j]])==M:\n a=i\n break\nprint('UNRESTORABLE' if a<0 else ''.join([T[i-a] if a<=i<a+M else 'a' if S[i]=='?' else S[i] for i in range(L)]))", "import sys\n\n\nstdin = sys.stdin\ndef ns(): return stdin.readline().rstrip()\ndef ni(): return int(stdin.readline().rstrip())\ndef nm(): return list(map(int, stdin.readline().split()))\ndef nl(): return list(map(int, stdin.readline().split()))\n\n\ndef can_replace(S, T):\n cnt = 0\n for s, t in zip(S, T):\n if s == t or s == '?':\n cnt += 1\n if cnt == len(S):\n return True\n else:\n return False\n\n\ndef main():\n S = list(ns()[::-1])\n T = list(ns()[::-1])\n for i in range(len(S) - len(T) + 1):\n if can_replace(S[i:i + len(T)], T):\n S[i:i + len(T)] = T\n S = ''.join(S)\n print((S.replace('?', 'a')[::-1]))\n return\n print('UNRESTORABLE')\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\nt = input()\nn, m = len(s), len(t)\n\nfor i in range(n - m, -1, -1):\n match = True\n for j in range(m):\n if s[i + j] != '?' and s[i + j] != t[j]:\n match = False\n break\n if match:\n print((s[:i].replace('?', 'a') + t + s[i + m:].replace('?', 'a')))\n return\nprint(\"UNRESTORABLE\")\n", "s = input()\nt = input()\n\ns_length = len(s)\nt_length = len(t)\n\nans = ''\nkeep = ''\nremind = 0\nchecker = False\nfor i in range(s_length):\n if (i + t_length) <= s_length:\n check = True\n for j in range(t_length):\n if (s[i + j] != t[j]) & (s[i + j] != '?'):\n check = False\n if check:\n checker = True\n ans = keep + t\n remind = i + t_length\n if s[i] == '?':\n keep += 'a'\n else:\n keep += s[i]\nans = ans + keep[remind:]\n\nif checker:\n print(ans)\nelse:\n print('UNRESTORABLE')\n", "Sp = str(input())\nT = list(input())\nans = []\nANS = []\nfor i in range(len(Sp)-len(T)+1):\n S = list(Sp)\n for j in range(len(T)):\n if S[i+j] == T[j] or S[i+j] == \"?\":\n S[i+j] = T[j]\n if j == len(T)-1:\n ans.append(S)\n else:\n break\nif len(ans) == 0:\n print('UNRESTORABLE')\nelse:\n for i in range(len(ans)):\n for j in range(len(Sp)):\n if ans[i][j] == \"?\":\n ans[i][j] = \"a\"\n ANS.append(\"\".join(ans[i]))\n ANS.sort()\n print(ANS[0])", "import re\n\ns = input().replace('?', '.')\nt = input()\n\nfor i in range(len(s)-len(t), -1, -1):\n if re.match(s[i:i+len(t):], t):\n s = s.replace('.', 'a')\n print(s[:i:]+t+s[i+len(t)::])\n return\nprint('UNRESTORABLE')", "s=list(input())\nls=len(s)\nt=list(input())\nlt=len(t)\ncan=[]\nfor i in range(ls-lt,-1,-1):\n ok=0\n for j in range(lt):\n if s[i+j]==t[j] or s[i+j]=='?':\n ok+=1\n if ok==lt:\n c=[0]*ls\n for k in range(ls):\n if s[k]=='?':\n if k<i or k>=i+lt:\n c[k]='a'\n else:\n c[k]=t[k-i]\n else:\n c[k]=s[k]\n can.append(''.join(c))\nif len(can)==0:\n print('UNRESTORABLE')\nelse:\n print(sorted(list(can))[0])", "s,t=input(),input()\nans='z'*len(s)\nfor i in range(len(s)-len(t)+1):\n pre=s[:i].replace(\"?\",'a')\n \n for x,y in zip(list(s[i:]),list(t)):\n if x!=\"?\"and x!=y:break\n pre+=y\n else:\n pre+=s[i+len(t):].replace(\"?\",'a')\n ans=min(ans,pre)\nprint(ans if ans!='z'*len(s) else 'UNRESTORABLE')", "s=input()\nT=input()\n\ns=''.join([x if x!='?' else '1' for x in list(s)])\n\nstart=[]\nfor i in range(len(s)-len(T)+1):\n tmp=0\n for j in range(len(T)):\n if s[i+j]==T[j] or s[i+j]=='1': tmp+=1\n if tmp==len(T): start.append(i)\n\ncandidates=[]\nt=len(T)\nans=''\nif len(start):\n for st in start:\n tmp=s[:st]+T+s[st+t:]\n candidates.append(tmp)\n candidates.sort()\n ans=candidates[0].replace('1','a')\nelse:\n ans='UNRESTORABLE'\n\nprint(ans)\n", "S = input()[::-1]\nT = input()[::-1]\n\nflag = False\nfor i in range(len(S) - len(T) + 1):\n matched = True\n\n for j in range(len(T)):\n\n if S[i + j] != \"?\" and S[i + j] != T[j]:\n matched = False\n \n if matched:\n S = S[:i] + T + S[i + len(T):]\n flag = True\n break\n\nif flag:\n print(S.replace(\"?\", \"a\")[::-1])\nelse:\n print(\"UNRESTORABLE\")", "s = input()\nn = len(s)\nt = input()\nm = len(t)\nans = []\n\nfor i in range(n-m+1):\n for j in range(m):\n if s[i+j] not in [t[j] , \"?\"]:\n break\n elif j == m-1:\n res = s[:i]+t+s[i+m:]\n ans.append(res.replace(\"?\",\"a\"))\n\nif not ans:\n ans.append(\"UNRESTORABLE\")\n\nprint(min(ans))", "S = input()[::-1]\nT = input()[::-1]\n\nflag = False\nfor i in range(len(S) - len(T) + 1):\n matched = True\n\n for j in range(len(T)):\n # \u3046\u30fc\u3093...\n if i == len(S) - len(T) + 1:\n break\n\n if S[i + j] != \"?\" and S[i + j] != T[j]:\n matched = False\n \n if matched:\n S = S[:i] + T + S[i + len(T):]\n flag = True\n break\n\nif flag:\n print(S.replace(\"?\", \"a\")[::-1])\nelse:\n print(\"UNRESTORABLE\")", "s = input()\nt = input()\nans = list(s)\n\nif len(s)>=len(t):\n for i in reversed(list(range(len(s)-len(t)+1))):\n flg=True\n for j in range(len(t)):\n if s[i+j]==\"?\":\n continue\n if s[i+j]!=t[j]:\n flg=False\n break\n if flg:\n for j in range(len(t)):\n ans[i+j]=t[j]\n\n break\nelse:\n flg=False\n\nans = \"\".join(ans)\nans = ans.replace(\"?\",\"a\")\n\nprint((ans if flg else \"UNRESTORABLE\"))\n\n", "s = input()\nt = input()\nmatch_index = 51\nfor i in range(len(s) - len(t) + 1):\n s_tmp = s[i:i + len(t)]\n for j in range(len(t)):\n if s_tmp[j] == t[j] or s_tmp[j] == \"?\":\n pass\n else:\n break\n else:\n match_index = i\n\nif match_index == 51:\n print(\"UNRESTORABLE\")\nelse:\n s_replace = \"\"\n for i in range(match_index):\n s_replace += s[i]\n s_replace += t\n for i in range(match_index + len(t), len(s)):\n s_replace += s[i]\n\n # s[match_index:match_index + len(t)] = t\n res = \"\"\n for i in s_replace:\n if i == \"?\":\n res += \"a\"\n else:\n res += i\n print(res)\n", "\ns_o = str(input().strip())\nt_o = str(input().strip())\ndic = []\n\nfor i in range(len(s_o)-len(t_o)+1):\n s = s_o\n t = t_o\n flg = 0\n for j in range(len(t_o)):\n if s[i+j] == t[j] or s[i+j] == \"?\":\n s = s[:i+j] + t[j] + s[i+j+1:]\n else:\n flg = 1\n break\n if flg:\n continue\n s = s.replace(\"?\", \"a\")\n dic.append(s)\n\nif len(dic) == 0:\n print(\"UNRESTORABLE\")\nelse:\n dic.sort()\n print(dic[0])", "import sys\nimport re\nimport queue\nimport collections\nimport math\nfrom decimal import *\nfrom copy import deepcopy\nfrom collections import Counter, deque\nimport heapq\nfrom itertools import accumulate, product, combinations, combinations_with_replacement\nfrom bisect import bisect, bisect_left, bisect_right\nfrom functools import reduce\nfrom typing import Callable\nfrom decimal import Decimal, getcontext\n# input = sys.stdin.readline\ndef i_input(): return int(input())\ndef i_map(): return map(int, input().split())\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\ndef lcm(a, b): return a * b // gcd(a, b)\nsys.setrecursionlimit(10 ** 8)\nINF = float('inf')\nMOD = 10 ** 9 + 7\nnum_list = []\nstr_list = []\n\ndef main():\n\tS_dush = s_input()\n\tT = s_input()\n\n\tanswer_list = []\n\n\tfor i in range(0,len(S_dush)-len(T)+1):\n\t\tflag = True\n\t\tcount = 0\n\t\tfor j in range(0,len(T)):\n\t\t\tif(S_dush[i+j]!=\"?\" and S_dush[i+j] != T[j]):\n\t\t\t\tcount = j\n\t\t\t\tflag = False\n\t\tif(flag):\n\t\t\ttmp = \"\"\n\t\t\tfor j in range(0,len(S_dush)):\n\t\t\t\tif(S_dush[j]==\"?\"):\n\t\t\t\t\ttmp = tmp + \"a\"\n\t\t\t\telse:\n\t\t\t\t\ttmp = tmp + S_dush[j]\n\t\t\ttmp = tmp[0:i] + T + tmp[i+len(T):len(S_dush)]\n\t\t\tanswer_list.append(tmp)\n\t\n\tif(len(answer_list) ==0):\n\t\tprint(\"UNRESTORABLE\")\n\telse:\n\t\tanswer_list.sort()\n\t\tprint(answer_list[0])\n\n\n\ndef __starting_point():\n\tmain()\n__starting_point()", "#abc076 C\nfrom copy import deepcopy\ns = list(input())\nt = list(input())\nls = len(s)\nlt = len(t)\n\nrev_s = s[::-1]\nrev_t = t[::-1]\n\nfor x in range(ls-lt+1):\n if rev_s[x:x+lt] == [\"?\"] * lt:\n for y in range(lt):\n rev_s[x+y] = rev_t[y]\n ns = rev_s[::-1]\n S = \"\".join(ns)\n ans = S.replace(\"?\", \"a\")\n print(ans)\n return\n\n\nfor i in range(lt):\n for j in range(i, ls):\n if rev_t[i] == rev_s[j]:\n flag = True\n t_temp = deepcopy(rev_t)\n s_temp = deepcopy(rev_s)\n for k in range(-i, lt-i):\n if j+k >= ls or j+k < 0:\n flag = False\n break\n elif t_temp[i+k] == s_temp[j+k]:\n pass\n elif s_temp[j+k] == \"?\":\n s_temp[j+k] = t_temp[i+k]\n elif t_temp[i+k] != s_temp[j+k]:\n flag = False\n break\n if flag:\n ns = s_temp[::-1]\n S = \"\".join(ns)\n ans = S.replace(\"?\", \"a\")\n print(ans)\n return\n\nprint(\"UNRESTORABLE\")", "sd = input()\nt = input()\n\nn = len(sd)\nm = len(t)\ns = []\n\n# sd \u3092\u5f8c\u308d\u304b\u3089\u898b\u3066\u3044\u304d\u3001 t \u306e\u5165\u308a\u305d\u3046\u306a\u5834\u6240\u3092\u63a2\u3059\nfor i in range(n - m, -1, -1):\n t_kamo = sd[i:i + m]\n for j in range(m + 1):\n # 1\u6587\u5b57\u305a\u3064\u9806\u306b\u5165\u308a\u3046\u308b\u304b\u8abf\u3079\u3001\u6700\u5f8c\u307e\u3067\u5165\u308b\u306a\u3089 \"?\" \u3092 \"a\" \u306b\u7f6e\u304d\u63db\u3048\u3066\u51fa\u529b\n if j == m:\n print((sd[:i] + t + sd[i + len(t):]).replace(\"?\", \"a\"))\n return\n if t_kamo[j] == \"?\":\n continue\n elif t_kamo[j] != t[j]:\n break\n\nprint(\"UNRESTORABLE\")", "s = input()\nt = input()\nl = []\nfor i in range(len(s)-len(t)+1):\n for j in range(i, i+len(t)):\n if s[j] != \"?\" and s[j] != t[j-i]:\n break\n else:\n l.append(s[:i]+t+s[i+len(t):])\nif len(l) == 0:\n print(\"UNRESTORABLE\")\n return\nl.sort()\nprint(l[0].replace(\"?\", \"a\"))", "s = input()\nt = input()\nn = len(s)\nm = len(t)\nans = []\nfor i in range(n-m+1):\n c = 0\n for j in range(m):\n if s[i+j] == '?' or s[i+j] == t[j]:\n c += 1\n if c == m:\n s_ = s[0:i] + t + s[i+m:]\n s_ = s_.replace('?', 'a')\n ans.append(s_)\nif len(ans)>0:\n print((sorted(ans)[0]))\nelse:\n print('UNRESTORABLE')\n", "s=input()\nt=input()\nls=len(s)\nlt=len(t)\n\nans=0\nfor i in range(ls-lt+1):\n x=s[:i]+t+s[i+lt:ls]\n f=1\n for j in range(ls):\n if s[j]=='?':\n continue\n if s[j]!=x[j]:\n f=0\n break\n if f:\n p=''\n for k in range(ls):\n if x[k]=='?':\n p+='a'\n else:\n p+=x[k]\n ans=p\n \nif ans:\n print(p)\nelse:\n print('UNRESTORABLE')\n", "S0 = input()\nT = input()\n\nn, m = len(S0), len(T)\nif n < m:\n print(\"UNRESTORABLE\")\n return\n\nstart, end = -1, -1\nfor i in reversed(range(n - m + 1)):\n ok = True\n for j in range(m):\n ok = ok and (S0[i + j] == T[j] or S0[i + j] == '?')\n if ok:\n start = i\n end = i + m - 1\n break\n\nif start >= 0:\n S = ''\n for i in range(n):\n if start <= i <= end:\n S += T[i - start]\n else:\n if S0[i] == '?':\n S += 'a'\n else:\n S += S0[i]\n print(S)\nelse:\n print(\"UNRESTORABLE\")", "a = input()\nb = input()\n\nlength = len(a) - len(b) + 1\n\nans = []\nfor i in range(length):\n A = list('?'*i+b+'?'*(length-i-1))\n flag = True\n for j in range(len(a)):\n if a[j] == '?' or a[j] == A[j]:\n pass\n elif a[j] != '?' and A[j] == '?':\n A[j] = a[j]\n else:\n flag = False\n if flag:\n ans.append(''.join(A).replace('?','a'))\n\nif ans:\n ans.sort()\n print(ans[0])\nelse:\n print('UNRESTORABLE')", "Sd = input()\nT = input()\n#Sd\u306e?\u4ee5\u5916\u306e\u6587\u5b57\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u53d6\u5f97\nindexes = []\nfor i in range(len(Sd)):\n if Sd[i] != \"?\":\n indexes.append(i)\n\nt0 = 0#t\u306e\u5148\u982d\u4f4d\u7f6e\nS_list = []\nwhile t0 <= (len(Sd)-len(T)):\n flg = 0\n tmp_S = Sd[:t0] + T + Sd[t0+len(T):]\n\n #\u6761\u4ef61\u3092\u6e80\u305f\u3059\u304b\u3069\u3046\u304b\u306e\u30c1\u30a7\u30c3\u30af\n for index in indexes:\n if Sd[index] != tmp_S[index]:#Sd\u3068\u4e00\u81f4\u3057\u3066\u3044\u306a\u304b\u3063\u305f\u3089\n flg = 1\n if flg:#flg\u304c\u7acb\u3063\u305f\u6587\u5b57\u5217\u306f\u6761\u4ef6\u3092\u6e80\u305f\u3055\u306a\u3044\u305f\u3081\u30b9\u30ad\u30c3\u30d7\n t0 += 1\n continue\n\n #?\u306ba\u3092\u7a4d\u3081\u3066\u30ea\u30b9\u30c8\u306b\u683c\u7d0d\n tmp_S = tmp_S.replace('?', 'a')\n S_list.append(tmp_S)\n t0 += 1\n\nif not S_list:\n print(\"UNRESTORABLE\")\n return\n\nS_list.sort()#\u8f9e\u66f8\u5f0f\u306b\u30bd\u30fc\u30c8\nprint(S_list[0])", "def main():\n s = input()\n t = input()\n n = len(s)\n m = len(t)\n ans = []\n for i in range(n-m+1):\n c = 0\n for j in range(m):\n if s[i+j] == '?' or s[i+j] == t[j]:\n c += 1\n if c == m:\n s_ = s[0:i] + t + s[i+m:]\n s_ = s_.replace('?', 'a')\n ans.append(s_)\n if len(ans)>0:\n print((sorted(ans)[0]))\n else:\n print('UNRESTORABLE')\n\ndef __starting_point():\n main()\n\n__starting_point()", "S = input()\nSa = S.replace(\"?\", \"a\")\nT = input()\nnt = len(T)\nans = list()\nfor i in range(len(S) - nt + 1):\n X = S[i: i + nt]\n for x, t in zip(X, T):\n if x == \"?\":\n continue\n if x != t:\n break\n else:\n ans.append(Sa[:i] + T + Sa[i + nt:])\nans.sort()\nprint((ans[0] if ans else \"UNRESTORABLE\"))\n", "\n# import itertools\n# import math\n# from functools import reduce\n# import sys\n# sys.setrecursionlimit(500*500)\n# import numpy as np\n# import heapq\n# from collections import deque\n\n# N = int(input())\nS_prime = input()\n# n, *a = map(int, open(0))\n# N, M = map(int, input().split())\n# A = list(map(int, input().split()))\n# B = list(map(int, input().split()))\n# tree = [[] for _ in range(N + 1)]\n# B_C = [list(map(int,input().split())) for _ in range(M)]\nT = input()\n\n# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])\n# all_cases = list(itertools.permutations(P))\n# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))\n# itertools.product((0,1), repeat=n)\n\n# A = np.array(A)\n# cum_A = np.cumsum(A)\n# cum_A = np.insert(cum_A, 0, 0)\n\n# def dfs(tree, s):\n# for l in tree[s]:\n# if depth[l[0]] == -1:\n# depth[l[0]] = depth[s] + l[1]\n# dfs(tree, l[0])\n# dfs(tree, 1)\n\n# def factorization(n):\n# arr = []\n# temp = n\n# for i in range(2, int(-(-n**0.5//1))+1):\n# if temp%i==0:\n# cnt=0\n# while temp%i==0:\n# cnt+=1\n# temp //= i\n# arr.append([i, cnt])\n# if temp!=1:\n# arr.append([temp, 1])\n# if arr==[]:\n# arr.append([n, 1])\n# return arr\n\n#def make_divisors(n):\n# lower_divisors , upper_divisors = [], []\n# i = 1\n# while i*i <= n:\n# if n % i == 0:\n# lower_divisors.append(i)\n# if i != n // i:\n# upper_divisors.append(n//i)\n# i += 1\n# return lower_divisors + upper_divisors[::-1]\n\n# def gcd_list(numbers):\n# return reduce(math.gcd, numbers)\n\n# if gcd_list(A) > 1:\n# print(\"not coprime\")\n# return\n\n# \u9ad8\u901f\u7d20\u56e0\u6570\u5206\u89e3\u6e96\u5099\n#MAXN = 10**6+10\n#sieve = [i for i in range(MAXN+1)]\n#p = 2\n#while p*p <= MAXN:\n# if sieve[p] == p:\n# for q in range(2*p, MAXN+1, p):\n# if sieve[q] == q:\n# sieve[q] = p\n# p += 1\n\nstart_ind = -1\nfor i in range(len(S_prime) - len(T) + 1):\n for j, c in enumerate(T):\n if S_prime[i + j] == c or S_prime[i + j] == \"?\":\n pass\n else:\n break\n else:\n start_ind = i\n \nif start_ind == -1:\n print(\"UNRESTORABLE\")\n return\n\nS = S_prime[:start_ind] + T + S_prime[start_ind + len(T):]\nprint(S.replace(\"?\", \"a\"))", "_S = list(input())\nT = list(input())\n\nN = len(_S)\nM = len(T)\n\ncandidates = []\n\nfor i in range(N - M + 1):\n if _S[i] == '?' or _S[i] == T[0]:\n S = _S.copy()\n flg = True\n for j in range(M):\n if S[i + j] == '?':\n S[i + j] = T[j]\n elif S[i + j] != T[j]:\n flg = False\n break\n if flg:\n for k in range(N):\n if S[k] == '?':\n S[k] = 'a'\n candidates.append(''.join(S))\n\nif len(candidates) == 0:\n print('UNRESTORABLE')\nelse:\n print((min(candidates)))\n", "s = list(input())\nt = list(input())\nls, lt = len(s), len(t)\n#\u30ea\u30b9\u30c8\u3092\u53cd\u8ee2\u3055\u305b\u3066\u30b1\u30c4\u304b\u3089\u8abf\u3079\u308b\u4e8b\u3067\u8f9e\u66f8\u9806\u6700\u5c0f\u3092\u6c42\u3081\u308b\ns.reverse()\nt.reverse()\nfor i in range(ls):\n for j in range(lt): #\u3053\u306efor\u6587\u304c\u5168\u90e8\u56de\u308c\u3070t in s\u3067\u3042\u308b\n if i + j >= ls:\n break\n if s[i+j] != '?' and s[i+j] != t[j]:\n break\n else: \n for j in range(lt):\n s[i+j] = t[j]\n s = [x if x != '?' else 'a' for x in s]\n s.reverse()\n ans = ''.join(s)\n break\nelse:\n ans = 'UNRESTORABLE'\nprint(ans)", "import re\ns = input().replace(\"?\",\".\")\nt = input()\nfor i in range(len(s)-len(t),-1,-1):\n if re.match(s[i:i+len(t)],t):\n s = s.replace(\".\",\"a\")\n print(s[:i]+t+s[i+len(t):])\n return\nprint(\"UNRESTORABLE\")", "ss = input()\nt = input()\n\nls = len(ss)\nlt = len(t)\n\nbefore = []\nafter = []\n\nfor i in range(ls-lt+1):\n for j in range(lt):\n if ss[i+j]!=\"?\":\n if ss[i+j]!=t[j]:\n break\n else:\n before += [ss[:i]+t+ss[i+lt:]]\n \nfor k in before:\n after += [k.replace(\"?\",\"a\")]\n\nif after:\n after = sorted(after)\n print(after[0])\nelse:\n print(\"UNRESTORABLE\")", "\ndef main():\n with open(0) as f:\n S, T = f.read().split()\n for i in reversed(range(len(S)-len(T)+1)):\n for j in reversed(range(len(T))):\n if S[i+j] == T[j] or S[i+j] == '?':\n continue\n else:\n break\n else:\n S = S[:i] + T + S[i+len(T):]\n S = S.replace('?', 'a')\n print(S)\n break\n else:\n print('UNRESTORABLE')\n\nmain()", "S = list(input())\nT = list(input())\nS.reverse()\nT.reverse()\nflag = False\nfor i in range(len(S)-len(T)+1):\n k = 0\n for t in range(i,i+len(T)):\n if S[t] != '?' and S[t] != T[k]:\n break\n k += 1\n if k == len(T):\n flag = True\n w = i\n if flag:\n break\nt = 0\nif flag:\n for i in range(w,w+len(T)):\n S[i] = T[t]\n t += 1\n S.reverse()\n an = ''\n for i in range(len(S)):\n if S[i] == '?':\n an += 'a'\n else:\n an += S[i]\n print(an)\nelse:\n print('UNRESTORABLE')", "s = input()\nt = input()\n\nans = 'z' * len(s)\ntmp = 'z' * len(s)\n\nx = False\nfor i in range(len(s)-len(t)+1):\n ok = True\n for j in range(len(t)):\n if not (s[i+j] == '?' or s[i+j] == t[j]):\n ok = False\n \n if ok:\n x = True\n tmp = s[:i] + t + s[i+len(t):]\n if ans > tmp:\n ans = tmp\n\nif x:\n ans = ans.replace(\"?\", \"a\")\n print(ans)\nelse:\n print('UNRESTORABLE')\n", "S=input()\nT=input()\n\nlt=len(T)\nls=len(S)\nS+='%'*lt\n\nif ls<lt:\n flg=0\nelse:\n for i in range(ls-lt+1,-1,-1):\n # print('***',S[i:i+lt])\n flg=1\n for j in range(i,i+lt):\n s=S[j]\n # print(s,T[j-i])\n if s=='?': continue\n if s=='%' or s!=T[j-i]:\n flg=0\n break\n if flg==1:\n break\nif flg:\n print((S[0:i]+T+S[i+lt:ls]).replace('?','a'))\nelse:\n print('UNRESTORABLE')", "s = input()\nt = input()\nans = ''\n\n# for i in range(len(s)-len(t)+1):\nfor i in range(len(s)-len(t), -1, -1):\n st = s[i:i+len(t)]\n cnt = 0\n for si, ti in zip(st, t):\n if si == '?' or si == ti:\n cnt += 1\n # print(si, ti, cnt)\n if cnt == len(t):\n ans = s[:i] + t + s[i+len(t):]\n ans = ans.replace('?', 'a')\n print(ans)\n return\nelse:\n print('UNRESTORABLE')\n\n\n", "import math\nfrom math import gcd,pi,sqrt\nINF = float(\"inf\")\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return list(map(int, input().split()))\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\n\n\ndef main():\n s = input() # \u6697\u53f7\n t = input() # \u542b\u307e\u308c\u308b\u6587\u5b57\n\n s_len = len(s)\n t_len = len(t)\n flg = False\n\n for i in range(s_len - t_len,-1,-1):\n flg = True\n for j in range(t_len):\n if s[i+j] != t[j] and s[i+j] != \"?\":\n flg = False\n break\n if flg == True:\n trial = i\n break\n\n if flg == False:\n print(\"UNRESTORABLE\")\n return\n\n ans = \"\"\n for i in s[:trial]:\n if i == \"?\":\n ans = ans + \"a\"\n else:\n ans = ans + i\n ans = ans + t\n\n for i in s[(trial+t_len):]:\n if i == \"?\":\n ans = ans + \"a\"\n else:\n ans = ans + i\n\n print(ans)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()[::-1]\nt = input()[::-1]\nx = \"\"\nfor i in range(0,len(s)-len(t)+1):\n if x == \"\": x = s[i:i+len(t)]\n else:x = x[1:] + s[i+len(t)-1]\n flag = True\n for j in range(len(t)):\n if x[j] == \"?\" or x[j] == t[j]: continue\n else: flag = False\n if flag:\n s = (s[:i] + t + s[i+len(t):])[::-1]\n print(s.replace(\"?\", \"a\"))\n return\nprint(\"UNRESTORABLE\")", "S=input()\nT=input()\n\nlt=len(T)\nls=len(S)\nif ls<lt:flg=0\nelse:\n for i in range(ls-lt,-1,-1):\n flg=1\n for s,t in zip(S[i:i+lt],T):\n if s=='?' or s==t: continue\n flg=0\n if flg:break\nprint((S[0:i]+T+S[i+lt:ls]).replace('?','a') if flg else 'UNRESTORABLE')", "#!/bin/python3\ns=list(input())\nt=list(input())\n\nlens=len(s)\nlent=len(t)\n\nfor i in reversed(list(range(lens-lent+1))):\n x=s[i:i+lent]\n ans=s\n flag=True\n #print(\"x\",x,len(x))\n for j in range(lent):\n if x[j]!=t[j] and x[j]!=\"?\":\n flag=False\n break\n #if x[j]==\"?\":\n # #t\u3068\u540c\u3058\u90e8\u5206\n # #print(\"i\",i,\"j\",j)\n # ans[i+j]=t[j]\n if flag:\n #t\u3088\u308a\u524d\u306e\u90e8\u5206\n #ans[:i]=[\"a\" if a==\"?\" else a for a in ans[:i]]\n #t\u3088\u308a\u5f8c\u308d\u306e\u90e8\u5206\n #if i+lent<=lens:\n # ans[i+lent:lens]=[\"a\" if a==\"?\" else a for a in ans[i+lent:lens]]\n ans=[\"a\" if a==\"?\" else a for a in ans[:i]]+\\\n \tt+[\"a\" if a==\"?\" else a for a in ans[i+lent:]]\n print((\"\".join(ans)))\n return\nprint(\"UNRESTORABLE\")\n#print(\"ans\",ans)\n\n", "import sys\nimport math\nimport re\n\n#https://atcoder.jp/contests/agc008/submissions/15248942\nsys.setrecursionlimit(10 ** 8)\nini = lambda: int(sys.stdin.readline())\ninm = lambda: map(int, sys.stdin.readline().split())\ninl = lambda: list(inm())\nins = lambda: sys.stdin.readline().rstrip()\ndebug = lambda *a, **kw: print(\"\\033[33m\", *a, \"\\033[0m\", **dict(file=sys.stderr, **kw))\n\ns2 = input()\nt = input()\n\n#\u8f9e\u66f8\u9806\u306e\u5c0f\u3055\u3044\u3082\u306e\u3092\u4f5c\u308b\u305f\u3081\u306b\u30d1\u30bf\u30fc\u30f3\u30de\u30c3\u30c1\u306f\u5f8c\u308d\u304b\u3089\u5b9f\u65bd\u3057\u305f\u3044\n#\u306e\u3067\u5165\u529b\u3092\u53cd\u8ee2\u3055\u305b\u308b\ns2_r = s2[::-1]\nt_r = t[::-1]\n\nans_flag = False\n#\u5168\u6587\u5b57\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u8a66\u3059\nfor i in range(len(s2)):\n for j in range(i+1,len(s2)+1):\n #t\u3068\u540c\u3058\u6587\u5b57\u6570\u306e\u6642\u3060\u3051\u90e8\u5206\u4e00\u81f4\u3059\u308b\u304b\u5224\u5b9a\u3059\u308b\n if (j-i) == len(t_r):\n flag = True\n #\u4e00\u6587\u5b57\u3054\u3068\u306b\u5224\u5b9a\u3059\u308b\n for k,l in enumerate(range(i,j)):\n if s2_r[l] != t_r[k] and s2_r[l] != '?':\n flag = False\n if flag == True:\n #\u4e00\u81f4\u3057\u305f\u4f4d\u7f6e\u3092\u7f6e\u63db\n ans = s2_r[:i] + t_r + s2_r[j:]\n #\u6b8b\u308a\u306e?\u3092\u8f9e\u66f8\u9806\u6700\u5c0f\u306ea\u306b\u7f6e\u63db\n ans = ans.replace('?','a')\n #\u5143\u306e\u9806\u756a\u306b\u53cd\u8ee2\n ans = ans[::-1]\n print(ans) \n ans_flag = True\n break\n\n #for\u3092break\u3057\u306a\u3044\u3068continue\u3059\u308b\n else:\n continue\n break\n \nif ans_flag == False:\n print('UNRESTORABLE')", "S = input()[::-1]\nT = input()[::-1]\n\nflag = False\nfor i in range(len(S) - len(T) + 1):\n matched = True\n\n for j in range(len(T)):\n\n if S[i + j] != \"?\" and S[i + j] != T[j]:\n matched = False\n break\n \n if matched:\n S = S[:i] + T + S[i + len(T):]\n flag = True\n break\n\nif flag:\n print(S.replace(\"?\", \"a\")[::-1])\nelse:\n print(\"UNRESTORABLE\")", "S=input()\nT=input()\n\nlt=len(T)\nls=len(S)\nif ls<lt:f=0\nelse:\n for i in range(ls-lt,-1,-1):\n f=1\n for s,t in zip(S[i:i+lt],T):\n if s=='?' or s==t: continue\n f=0\n if f:break\nprint((S[0:i]+T+S[i+lt:ls]).replace('?','a') if f else 'UNRESTORABLE')", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\ns = list(str(input()))\nt = list(str(input()))\n\nans = []\nfor i in range(len(s)-len(t)+1):\n # print(i)\n ans_tmp = \"\"\n for j in range(len(s)):\n if j >= i and i+len(t) > j:\n if s[j] == \"?\" or s[j] == t[j-i]:\n ans_tmp += t[j-i]\n else:\n break\n else:\n if s[j] == \"?\":\n ans_tmp += \"a\"\n else:\n ans_tmp += s[j]\n\n if len(ans_tmp) != len(s):\n continue\n else:\n ans.append(ans_tmp)\nans.sort()\n\nif len(ans) == 0:\n print(\"UNRESTORABLE\")\nelse:\n print((ans[0]))\n", "#!/usr/bin/env python3\n\n#import\n#import math\n#import numpy as np\n#= int(input())\nS = list(input())\nT = list(input())\n\nls = len(S); lt = len(T)\n\nfor i in range(ls - lt, -1, -1):\n isok = True\n for j in range(lt):\n if S[i + j] == \"?\":\n continue\n if S[i + j] != T[j]:\n isok = False\n break\n if isok:\n S[i:i+lt] = T\n ans = \"\"\n for s in S:\n if s == \"?\":\n ans += \"a\"\n else:\n ans += s\n print(ans)\n return\n\nprint(\"UNRESTORABLE\")\n", "S = input()\nT = input()\n\nn = len(S)\nl = len(T)\n\nfor i in range(n-l+1)[::-1]:\n cnt = 0\n for j in range(l):\n if S[i+j] == \"?\" or S[i+j] == T[j]:\n cnt += 1\n \n if cnt == l:\n S = list(S[:i] + T + S[i+l:])\n for k in range(n):\n if S[k] == \"?\":\n S[k] = \"a\"\n print(\"\".join(S))\n break\n \nelse:\n print(\"UNRESTORABLE\")", "def main():\n s=input()\n t=input()\n ans=[]\n for i in range(len(s)-len(t)+1):\n for j in range(len(t)):\n if len(s) <= i+j or (s[i+j] != t[j] and s[i+j] != \"?\"):\n break\n else:\n ans.append((s[:i]+t+s[i+j+1:]).replace(\"?\", \"a\"))\n ans.sort()\n print(ans[0] if len(ans) > 0 else \"UNRESTORABLE\")\n \ndef __starting_point():\n main()\n__starting_point()", "S=list(input())[::-1]\nT=list(input())[::-1]\nfor i in range(len(S)-len(T)+1):\n ans = S[:i]\n for j in range(len(T)):\n if S[i+j] != \"?\" and S[i+j] != T[j]:\n break\n else:\n ans.append(T[j])\n else:\n for j in range(i+len(T),len(S)):\n ans.append(S[j])\n print(\"\".join(map(str,ans[::-1])).replace(\"?\",\"a\"))\n break\nelse:\n print(\"UNRESTORABLE\")", "S = input()\nT = input()\n \nls = len(S)\nlt = len(T)\nleft = -1\n \nfor i in range(ls-lt+1):\n for j in range(lt):\n if S[i+j] != \"?\" and S[i+j] != T[j]:\n break\n else:\n left = i\nif left == -1:\n ans = \"UNRESTORABLE\"\nelse:\n ans = S[:left]+T+S[left+lt:]\n ans = ans.replace(\"?\", \"a\")\nprint(ans)", "s = input()\nt = input()\n\nsoln = \"\"\n\nfor i in range(len(s)-len(t)+1):\n sol = True\n for j in range(len(t)):\n if not (s[i+j] == t[j] or s[i+j] == \"?\"):\n sol = False\n break\n\n if sol:\n soln = s[:i] + t + s[i+len(t):]\n\nprint(soln.replace(\"?\", \"a\") if soln != \"\" else \"UNRESTORABLE\")", "import copy\ns = list(input())\nt = list(input())\n\nt1, t2 = copy.deepcopy(s), copy.deepcopy(s)\nok = []\nch = True\nif ch:\n for i in range(len(s)-len(t)+1):\n count = 0\n for j in range(len(t)):\n if s[i+j] == t[j] or s[i+j] == '?':\n count += 1\n if count == len(t):\n ok.append(i)\nif len(ok) == 0:\n print(\"UNRESTORABLE\")\n ch = False\nelse:\n for i in range(len(t)):\n t1[ok[0]+i] = t[i]\n for i in range(len(t)):\n t2[ok[-1]+i] = t[i]\nif ch:\n for i in range(len(t1)):\n if t1[i] == '?':\n t1[i] = 'a'\n if t2[i] == '?':\n t2[i] = 'a'\n an1, an2 = \"\", \"\"\n for i in t1:\n an1 += i\n for i in t2:\n an2 += i\n print(min(an1, an2))", "S = input()\nT = input()\n\nif len(S) < len(T):\n print('UNRESTORABLE')\n return\n \n\nind = None\nfor i in range(len(S)-len(T)+1):\n for j in range(len(T)):\n if S[i+j] == \"?\":\n continue\n elif S[i+j] == T[j]:\n continue\n else:\n break\n else:\n ind = i\n\nif ind == None:\n print('UNRESTORABLE')\nelse:\n ans = list(S)\n for i in range(ind,ind+len(T)):\n ans[i] = T[i-ind]\n for i in range(len(ans)):\n if ans[i] == \"?\":\n ans[i] = \"a\"\n print(\"\".join(ans))", "S = input()\nT = input()\n\nl = len(S)\nk = len(T)\nf = 0\n\n\nif k > l:\n f = 0\nelse:\n for i in reversed(list(range(0,l-k+1))):\n #print(i)\n for j in range(k):\n #print(S[i+j], T[j])\n if S[i + j] != T[j] and S[i + j] != \"?\":\n #print(i+j)\n break\n if j == k-1:\n f = 1\n s = i\n if f == 1:\n break\n\nif f == 0:\n print(\"UNRESTORABLE\")\nelse:\n S = S[:s] + T + S[s+k:]\n for i in range(l):\n if S[i] == \"?\":\n S = S[:i] + \"a\" + S[i+1:]\n print(S)\n", "s = input()\nt = input()\nn = len(s)\nm = len(t)\nans = []\n\nfor i in range(n-m+1):\n \t#t\u3068\u540c\u3058\u6587\u5b57\u6570\u3092s\u304b\u3089\u629c\u304d\u51fa\u3059\n c = 0\n for j in range(m):\n if s[i+j] == '?' or s[i+j] == t[j]:\n \t#s\u306e\u6587\u5b57\u304c\"?\"\u307e\u305f\u306ft[j]\u3068\u540c\u3058\u5834\u5408\n c += 1\n if c == m:\n \t#\u6587\u5b57\u306e\u5909\u63db\n s_ = s[0:i] + t + s[i+m:]\n s_ = s_.replace('?', 'a')\n ans.append(s_)\nif len(ans)>0:\n print(sorted(ans)[0])\nelse:\n print('UNRESTORABLE')", "import sys\nimport math\nfrom collections import defaultdict\nfrom collections import deque\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\ninput = lambda: sys.stdin.readline().strip()\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\n\ndef main():\n S = SI()\n T = SI()\n ls = len(S)\n lt = len(T)\n R = []\n for i in range(ls-lt+1):\n SS = S[i:i+lt]\n is_ok = True\n for s, t in zip(SS, T):\n if s != \"?\" and s != t:\n is_ok = False\n if not is_ok:\n continue\n r = \"\"\n for j, s in enumerate(S):\n if j == i:\n r += T\n elif i < j < i+lt:\n pass\n elif s == \"?\":\n r += \"a\"\n else:\n r += s\n R.append(r)\n R.sort()\n if R:\n print(R[0])\n else:\n print(\"UNRESTORABLE\")\n\n\n\ndef __starting_point():\n main()\n__starting_point()", "s = input()\nt = input()\n\nn = len(s)\nm = len(t)\n\nfor i in range(n-m, -1, -1):\n x = s[i:i+m]\n for j in range(m+1):\n if j == m:\n print(((s[:i]+t+s[i+m:]).replace(\"?\",\"a\")))\n return\n if x[j] == \"?\": continue\n elif x[j] != t[j]: break\n \nprint(\"UNRESTORABLE\")\n", "s = input()\nt: str = input()\nn = len(s)\nm = len(t)\n\nfor i in range(n-m, -1, -1): #-1\u304b\u3089n-m\u56de\u3001\uff11\u305a\u3064\u5f15\u3044\u3066\u3044\u304f\n tlike = s[i: i+m]\n if tlike[0] == t[0] or tlike[0] == \"?\":\n for j in range(m+1):\n if j == m:\n print((s[:i] + t + s[i + m:]).replace(\"?\", \"a\"))\n return\n if tlike[j] == \"?\":\n continue\n elif tlike[j] != t[j]:\n break\n\nprint(\"UNRESTORABLE\")", "# \u89e3\u8aac\u3092\u8aad\u307f\u306a\u304c\u3089\u81ea\u4f5c\n\nS = input()\nT = input()\n\ns_len = len(S)\nt_len = len(T)\n\nres = []\n\ninit_K = \"?\" * s_len\nfor i in range(s_len - t_len + 1):\n K = list(init_K[:i] + T + init_K[i + t_len:])\n # K\u3092S\u306b\u3057\u305f\u304c\u3063\u3066\u66f8\u304d\u63db\u3048\u3066\u3044\u304f\u3002\u66f8\u304d\u63db\u3048\u3089\u308c\u306a\u3044\u2192\u6b63\u89e3\u3067\u306f\u306a\u3044\n for j in range(s_len):\n if S[j] == \"?\" or S[j] == K[j]: # S\u304c\"?\"\u307e\u305f\u306fS\u3068K\u304c\u4e00\u81f4\u3001\u66f8\u304d\u63db\u3048\u308b\u5fc5\u8981\u306a\u3057\n pass\n elif K[j] == \"?\": # S\u304c\"?\"\u3067\u306f\u306a\u304f\u3066K\u304c\"?\"\u3001\u66f8\u304d\u63db\u3048\u308b\n K[j] = S[j]\n else: # \u305d\u308c\u4ee5\u5916\u3001\u66f8\u304d\u63db\u3048\u3089\u308c\u306a\u3044\n break\n else: # break\u3057\u306a\u304b\u3063\u305f\n # \u8f9e\u66f8\u9806\u3067\u6700\u5c0f\u306b\u306a\u308b\u3088\u3046\u306b\u3001\u6b8b\u3063\u305fK\u306e\"?\"\u3092\"a\"\u306b\u5909\u3048\u308b\n res.append(\"\".join(K).replace(\"?\", \"a\"))\n\nif res:\n res.sort()\n print((res[0]))\nelse:\n print(\"UNRESTORABLE\")\n", "S=str(input())\nT=str(input())\nls=len(S)\nlt=len(T)\n\nans=''\nloc=None\nfor i in range(ls-lt,-1,-1):\n flag=0\n for j in range(lt):\n if not (S[i+j] == T[j] or S[i+j] == '?'):\n flag=1\n break\n if flag==0:\n loc=i\n break\n\nif loc == None:\n print('UNRESTORABLE')\nelse:\n i=0\n while i<ls:\n if i==loc:\n ans += T\n i += lt\n elif S[i] == '?':\n ans += 'a'\n i += 1\n else:\n ans += S[i]\n i += 1\n print(ans)\n", "s = input()\nt = input()\n\nn = len(s)\nk = len(t)\nfor i in range(n - k, -1, -1):\n ok = True\n for j in range(k):\n if s[i + j] == '?' or s[i + j] == t[j]:\n continue\n else:\n ok = False\n break\n if ok:\n print((s[:i].replace('?', 'a') + t + s[i + k:].replace('?', 'a')))\n return\nprint('UNRESTORABLE')\n", "S=input()\nT=input()\nN=len(S)\nn=len(T)\nans=[]\nfor i in range(N-n+1):\n for j in range(n):\n if S[i+j]!=T[j] and S[i+j]!='?':\n break\n else:\n s=[]\n for j in range(i):\n if S[j]=='?':\n s.append('a')\n else:\n s.append(S[j])\n for j in range(i,i+n):\n s.append(T[j-i])\n for j in range(i+n,N):\n if S[j]=='?':\n s.append('a')\n else:\n s.append(S[j])\n ans.append(''.join(s))\n\nif len(ans)==0:\n print(\"UNRESTORABLE\")\nelse:\n ans.sort()\n print((ans[0]))\n", "S = input()\nT = input()\n\nfor i in range(len(S) - len(T)+1):\n target = S[len(S) - len(T) - i:len(S) - i]\n\n can_search = True\n for key in range(len(T)):\n if target[key] != '?':\n if target[key] != T[key]:\n can_search = False\n break\n\n if can_search:\n new_key = S[:len(S) - len(T) - i]\n new_key += T\n new_key += S[len(new_key):]\n print((new_key.replace('?', 'a')))\n return\n\nprint('UNRESTORABLE')\n", "S = list(input())\nT = list(input())\ns = len(S)\nt = len(T)\nfor i in range(s-t,-1,-1):\n ss = S[i:i+t]\n for j in range(t):\n if ss[j] != \"?\" and ss[j] != T[j]:\n break\n else:\n for j in range(t):\n if ss[j] == \"?\":\n S[i+j] = T[j]\n break\nelse:\n print(\"UNRESTORABLE\")\n return\nprint(\"\".join(S).replace(\"?\",\"a\"))", "S = input()\nT = input()\n\nls = len(S)\nlt = len(T)\nleft = -1\n\nfor i in range(ls-lt+1):\n for j in range(lt):\n if S[i+j] != \"?\" and S[i+j] != T[j]:\n break\n else:\n left = i\nif left == -1:\n ans = \"UNRESTORABLE\"\nelse:\n ans = S[:left]+T+S[left+lt:]\n ans = ans.replace(\"?\", \"a\")\nprint(ans)", "import sys\n\ndef accept_input():\n S = input()\n T = input()\n return S,T\n\nS,T = accept_input()\nfromhere = -1\nfor i in range(len(S)-len(T)+1):\n for j in range(len(T)):\n if S[i+j] == \"?\":\n continue\n elif S[i+j] == T[j]:\n continue\n elif S[i+j] != T[j]:\n break\n else:\n fromhere = i\nif fromhere == -1:\n print(\"UNRESTORABLE\")\n return\nsd = \"\"\nfor i in range(len(S)):\n if i < fromhere:\n if S[i] == \"?\":\n sd += \"a\"\n else:\n sd += S[i]\n elif i >= fromhere+len(T):\n if S[i] == \"?\":\n sd += \"a\"\n else:\n sd += S[i]\n else:\n sd += T[i-fromhere]\nprint(sd)\n", "s=input()\nt=input()\n\ns_l=len(s)\nt_l=len(t)\n\nans=[]\nfor i in range(s_l-t_l+1):\n judge=True\n\n ts=list(s)\n for j in range(t_l):\n if ts[i+j]==t[j]:\n pass\n elif ts[i+j]=='?':\n ts[i+j]=t[j]\n else:\n judge=False\n break\n\n if judge and j==t_l-1:\n for k in range(s_l):\n if ts[k]=='?':\n ts[k]='a'\n ans.append(ts)\n\nif ans:\n ans.sort()\n print(''.join(ans[0]))\nelse:\n print('UNRESTORABLE')", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 28 02:20:36 2020\n\n@author: liang\n\"\"\"\nS = input()\nT = input()\n\nS = S[::-1]\nT = T[::-1]\n\nres = list()\n\nfor i in range(len(S)-len(T)+1):\n flag = True\n for j in range(len(T)):\n if S[i+j] == \"?\" or S[i+j] == T[j]:\n continue\n else:\n flag = False\n if flag == True:\n ans = \"\"\n for k in range(len(S)):\n if i <= k <= i + len(T)-1:\n #print(T[k-i])\n ans += T[k-i]\n elif S[k] != \"?\":\n #print(\"B\")\n ans += S[k]\n else:\n #print(\"C\")\n ans += \"a\"\n ans = ans[::-1]\n print(ans)\n break\n #res.append(ans)\nelse:\n print(\"UNRESTORABLE\")\n\"\"\"\nif res:\n res.sort()\n print(res[0])\nelse:\n print(\"UNRESTORABLE\")\n\"\"\"\n#print(S)\n#print(T)\n", "s = list(input())\nt = list(input())\nls =len(s)\nlt = len(t)\ns.reverse()\nt.reverse()\nfor i in range(ls):\n for j in range(lt):\n if i + j >= ls:\n break\n if s[i+j] != '?' and s[i+j] != t[j]:\n break\n else:\n for j in range(lt):\n s[i+j] = t[j]\n s = [x if x != '?' else 'a' for x in s]\n s.reverse()\n ans = ''.join(s)\n break\nelse:\n ans = 'UNRESTORABLE'\nprint(ans)", "S = input()\nT = input()\nanslist = []\nfor i in range(len(S)-len(T)+1):\n kouho = [0]*len(S)\n ok = 1\n for j in range(len(T)):\n if S[i+j] == T[j] or S[i+j] == \"?\":\n kouho[i+j] = T[j]\n else:\n ok = 0\n break\n if ok == 1:\n for k in range(len(S)):\n if kouho[k] == 0:\n if S[k] != \"?\":\n kouho[k] = S[k]\n else:\n kouho[k] = \"a\"\n kouho = ''.join(kouho)\n anslist.append(kouho)\nif len(anslist) == 0:\n ans = \"UNRESTORABLE\"\nelse:\n anslist.sort()\n ans = anslist[0]\nprint(ans)\n", "import re\nSd = input()\nT = input()\nSdls = list(Sd)\nSdls.reverse()\nSdre = ''.join(Sdls)\nTls = list(T)\nTls.reverse()\nTre = ''.join(Tls)\nst = -1\nfor i in range(0,len(Sd)-len(T)+1):\n f = 1\n for j in range(len(T)):\n if Tre[j] == Sdre[i+j] or Sdre[i+j] == '?':\n continue\n else:\n f = 0\n break\n if f == 1:\n st = i\n break\nif st == -1:\n print('UNRESTORABLE')\nelse:\n Sdrels = list(Sdre)\n for j in range(len(T)):\n Sdrels[j+st] = Tre[j]\n for j in range(len(Sd)):\n if Sdrels[j] == '?':\n Sdrels[j] = 'a'\n ans = ''.join(reversed(Sdrels))\n print(ans)", "s = input()\nt = input()\nlt = len(t)\nans = []\nfor i in range(len(s)-lt+1):\n cnt = 0\n n = 0\n while n < lt:\n if s[i+n] == '?':\n cnt += 1\n else:\n if s[i+n] == t[n]:\n cnt += 1\n n += 1\n if cnt == lt:\n ans.append(list(s[:i] + t + s[i+lt:]))\n # print(ans)\n # break\n\nif len(ans) != 0:\n for a in ans:\n # print(a)\n for i in range(len(a)):\n if a[i] == '?':\n a[i] = 'a'\n ans.sort()\n print(*ans[0], sep='')\n\nelse:\n print('UNRESTORABLE')", "S=input()\nT=input()\n\nlt=len(T)\nls=len(S)\nif ls<lt:flg=0\nelse:\n for i in range(ls-lt,-1,-1):\n flg=1\n for j in range(i,i+lt):\n s=S[j]\n if s=='?' or s==T[j-i]: continue\n flg=0\n break\n if flg:break\nif flg:\n print((S[0:i]+T+S[i+lt:ls]).replace('?','a'))\nelse:\n print('UNRESTORABLE')", "import sys\n#import string\n#from collections import defaultdict, deque, Counter\n#import bisect\n#import heapq\n#import math\n#from itertools import accumulate\n#from itertools import permutations as perm\n#from itertools import combinations as comb\n#from itertools import combinations_with_replacement as combr\n#from fractions import gcd\n#import numpy as np\n\nstdin = sys.stdin\nsys.setrecursionlimit(10 ** 7)\nMIN = -10 ** 9\nMOD = 10 ** 9 + 7\nINF = float(\"inf\")\nIINF = 10 ** 18\n\ndef solve():\n s = str(stdin.readline().rstrip())\n t = str(stdin.readline().rstrip())\n #A, B, C = map(int, stdin.readline().rstrip().split())\n #l = list(map(int, stdin.readline().rstrip().split()))\n #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]\n #word = [stdin.readline().rstrip() for _ in range(n)]\n #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]\n #zeros = [[0] * w for i in range(h)]\n anss = []\n for i in range(len(s)-len(t)+1):\n test = s[i:len(t)+i]\n flag = True\n for j in range(len(t)):\n if test[j] != \"?\" and test[j] != t[j]:\n flag = False\n if flag==True:\n ans = s[0:i] + t + s[i+len(t):]\n ans = ans.replace(\"?\",\"a\")\n anss.append(ans)\n if len(anss) == 0:\n print(\"UNRESTORABLE\")\n return\n anss.sort()\n print((anss[0]))\n\n\ndef __starting_point():\n solve()\n\n__starting_point()", "S = input()\nT = input()\nlen_S, len_T = len(S), len(T)\nans = []\nfor i in range(len_S-len_T+1):\n\tf = True\n\tfor j in range(len_T):\n\t\tif S[i+j] != T[j] and S[i+j] != '?':\n\t\t\tf = False\n\t\t\tbreak\n\tif f:\n\t\ts = S[:i] + T + S[i+j+1:]\n\t\tans.append(s.replace('?', 'a'))\nif len(ans) == 0:\n\tprint('UNRESTORABLE')\nelse:\n\tans.sort()\n\tprint(ans[0])", "s = input()\nt = input()\nns = len(s)\nnt = len(t)\n\ncand = []\n\nfor i in range(ns-nt+1):\n j = 0\n temps = list(s)\n f1 = True\n while j <= nt-1:\n if temps[i+j] == '?' or temps[i+j] == t[j]:\n temps[i+j] = t[j]\n else:\n f1 = False\n break\n j += 1\n if f1:\n temps = \"\".join(temps)\n cand.append(temps.replace('?', 'a'))\n\nif len(cand) == 0:\n ans = 'UNRESTORABLE'\nelse:\n cand.sort()\n ans = cand[0]\nprint(ans)\n", "S=input()\nT=input()\n\nans_list=[]\nfor i in range(len(S)-len(T)+1):\n X=S[i:i+len(T)]\n isOK=True\n for j in range(len(T)):\n if X[j]==\"?\" or X[j]==T[j]:\n pass\n else:\n isOK=False\n break\n \n if isOK:\n ans=S[:i]+T+S[i+len(T):]\n \n ans=ans.replace('?','a')\n ans_list.append(ans)\n\nif len(ans_list)<1:\n print(\"UNRESTORABLE\")\nelse:\n ans_list.sort()\n print((ans_list[0]))\n", "s=list(input())\nt=list(input())\nnum=len(s)-len(t)\nans1=-1\nfor i in range(num+1):\n num1=0\n num2=num-i\n for j in range(len(t)):\n if s[num2+j]!=t[j] and s[num2+j]!=\"?\":\n num1=1\n break\n if num1==0:\n ans1=num2\n break\nif ans1==-1:\n print(\"UNRESTORABLE\")\nelse:\n ans=\"\"\n for i in range(len(t)):\n s[ans1+i]=t[i]\n for i in range(len(s)):\n if s[i]==\"?\":\n s[i]=\"a\"\n ans+=s[i]\n print(ans)\n", "import math\n\nsd = list(input())\nt = list(input())\n\ndic = []\n\nslen = len(sd)\ntlen = len(t)\nfor i in range(slen - tlen + 1):\n for j in range(tlen):\n if not (t[j] == sd[i + j] or sd[i + j] == \"?\"):\n break\n else:\n s = sd[:i] + t + sd[i + tlen:]\n for k in range(len(s)):\n if s[k] == \"?\":\n s[k] = \"a\"\n dic.append(\"\".join(s))\n\nif len(dic) == 0:\n print(\"UNRESTORABLE\")\n return\nprint(sorted(dic)[0])", "S = input()\nT = input()\nls = len(S)\nlt = len(T)\n\nunrestorable = 'z'*50\nans = unrestorable\nfor i in range(ls-lt+1):\n for j, t in enumerate(T):\n s = S[i+j]\n if s != t and s != '?':\n break\n else:\n key = (S[:i]+T+S[i+lt:]).replace('?', 'a')\n ans = min(ans, key)\n\nprint((ans if ans != unrestorable else 'UNRESTORABLE'))\n", "import re\nimport sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\nimport functools\ndef v(): return input()\ndef k(): return int(input())\ndef S(): return input().split()\ndef I(): return list(map(int,input().split()))\ndef X(): return list(input())\ndef L(): return list(input().split())\ndef l(): return list(map(int,input().split()))\ndef lcm(a,b): return a*b//math.gcd(a,b)\nsys.setrecursionlimit(10 ** 6)\nmod = 10**9+7\ncnt = 0\nans = 0\ninf = float(\"inf\")\nal = \"abcdefghijklmnopqrstuvwxyz\"\nAL = al.upper()\n\nS = v()\nT = v()\nlen_s = len(S)\nlen_t = len(T)\ncheck = False\nans = []\n\nif len_s<len_t:\n print(\"UNRESTORABLE\")\n return\n\nfor i in range(len_s):\n if S[i] == \"?\":\n cnt += 1\n if cnt >= len_t:\n aaa = S.replace(\"?\",\"a\")\n ans.append(aaa[:i-len_t+1]+T+aaa[i+1:])\n elif S[i] in T:\n cnt = 0\n place = T.index(S[i])\n if len_s<len_t+i-place:\n break\n for j in range(i-place,len_t+i-place):\n if T[j-(i-place)] == S[j] or S[j] == \"?\":\n check = True\n else:\n check = False\n break\n if check:\n aaa = S.replace(\"?\",\"a\")\n ans.append(aaa[:i-place]+T+aaa[len_t+i-place:])\n else:\n cnt = 0\n\nif len(ans)>0:\n ans.sort()\n print((ans[0]))\nelse:\n print(\"UNRESTORABLE\")\n \n", "s = list(input())\nt = list(input())\ns.reverse()\nt.reverse()\nl = len(t)\nld = len(s)-len(t)+1\nfor i in range(ld):\n cnt = 0\n for j in range(l):\n if s[j+i] == \"?\" or s[j+i] == t[j]:\n cnt += 1\n if cnt == l:\n ans = []\n for p in range(i):\n if s[p] == \"?\":\n ans.append(\"a\")\n else:\n ans.append(s[p])\n for p in t:\n ans.append(p)\n for p in range(ld-i-1):\n if s[l+p+i] == \"?\":\n ans.append(\"a\")\n else:\n ans.append(s[l+i+p])\n ans.reverse()\n for p in ans:\n print(p,end = \"\")\n break\n \nelse:\n print(\"UNRESTORABLE\")", "S = list(input())\nT = input()\ncandidate = []\n\nans = True\nfor i in range(len(S)):\n flag = True\n for j in range(len(T)):\n if i + j >= len(S):\n flag = False\n break\n if S[i+j] == '?' or S[i+j] == T[j]:\n pass\n else:\n flag = False\n break\n if flag:\n candidate.append(i)\n ans = False\n\nif ans:\n print('UNRESTORABLE')\n return\n\ni = candidate[-1]\nfor tmp in range(i, i + len(T)):\n S[tmp] = T[tmp-i]\n\n\nfor i in range(len(S)):\n if S[i] == '?':\n S[i] = 'a'\n\nprint(''.join(S))", "S=list(input())\nT=list(input())\n\ndef match(s,t):\n for _s, _t in zip(s, t):\n if not (_s == _t or _s == '?'):\n return False\n return True\n \ndef convert(S):\n for i in range(len(S)):\n if S[i] == '?':\n S[i] = 'a'\n return S\n\ndef replace(S,T,off):\n for i in range(len(T)):\n S[off+i] = T[i]\n return S\n\npos = -1\nfor i in reversed(range(0,len(S)-len(T)+1)):\n if match(S[i:], T):\n pos = i\n break\n \nif 0 <= pos:\n ans = S\n ans = replace(ans, T, pos)\n ans = convert(ans)\n print(*ans,sep=\"\")\nelse:\n print('UNRESTORABLE')", "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n S_ = SS()\n T = SS()\n\n len_S = len(S_)\n len_T = len(T)\n\n # T\u306fS'\u306e\u306a\u308b\u3079\u304f\u53f3\u5074\u306b\u3042\u308b\u3079\u304d\n idx = -1\n for i in range(len_S - len_T, -1, -1):\n exists = True\n for j in range(len_T):\n if S_[i+j] != '?' and S_[i+j] != T[j]:\n exists = False\n break\n if exists:\n idx = i\n break\n\n if idx == -1:\n print('UNRESTORABLE')\n else:\n ans = list(S_)\n for i in range(len_S):\n if S_[i] == '?':\n if idx <= i < idx + len_T:\n ans[i] = T[i-idx]\n else:\n ans[i] = 'a'\n\n print((''.join(ans)))\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "s_ = input()\nt_ = input()\ns = [c for c in s_]\nt = [c for c in t_] \nn = len(s)\nm = len(t)\nfor i in reversed(list(range(m-1, n))):\n replaced = 0\n if s[i]==t[-1] or s[i]==\"?\":\n k = i-1\n \"\"\"\n if k+1<m-1:\n continue\n \"\"\"\n replace = 1\n for j in reversed(list(range(m-1))):\n if s[k]==t[j] or s[k]==\"?\":\n if j==0:\n replace=1\n break\n else:\n replace = 0\n break\n k -= 1\n\n if replace:\n k = i\n for j in reversed(list(range(m))):\n s[k] = t[j]\n k -= 1\n replaced = 1\n if replaced:\n break\nif n < m:\n replaced=0\nif replaced:\n for i in range(n):\n if s[i]==\"?\":\n s[i]=\"a\"\n print((\"\".join(s)))\nelse:\n print(\"UNRESTORABLE\")\n", "S = input()\nT = input()\ndef match(s,t):\n for c,d in zip(s,t):\n if c == \"?\":\n continue\n elif c == d:\n continue\n else:\n return False\n return True\nfor i in range(len(S)-len(T), -1, -1):\n s = S[i:i+len(T)]\n if match(s, T):\n print((S[:i]+T+S[i+len(T):]).replace(\"?\",\"a\"))\n return\nprint(\"UNRESTORABLE\")", "S_p=input()\nT=input()\n\nk=[]\nfor i in range(len(S_p)-len(T)+1):\n\tS_sub = S_p[i:i+len(T)]\n\tif all(s in (t, \"?\") for s, t in zip(S_sub, T)):\n\t\tk.append(i)\n\n\nif k:\n\tS=S_p[:k[-1]]+T+S_p[k[-1]+len(T):]\n\tprint(S.replace(\"?\", \"a\"))\nelse:\n\tprint(\"UNRESTORABLE\")", "s = list(input())\nt = list(input())\nn = len(s)\nm = len(t)\nk = -1\nfor i in range(n-m+1):\n x = s[i:i+m]\n flg = True\n for j in range(m):\n if x[j] != '?' and x[j] != t[j]:\n flg = False\n break\n if flg:\n k = i\nif k != -1:\n for i in range(k,k+m):\n s[i] = t[i-k]\n for i in range(n):\n if s[i] == '?':\n s[i] = 'a'\n print(''.join(s))\nelse:\n print('UNRESTORABLE')"] | {"inputs": ["?tc????\ncoder\n", "??p??d??\nabc\n"], "outputs": ["atcoder\n", "UNRESTORABLE\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 62,187 | |
a933233a0c3be7704cad52948dbe1f7f | UNKNOWN | Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:
- Let the current rating of the user be a.
- Suppose that the performance of the user in the contest is b.
- Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.
Find the performance required to achieve it.
-----Constraints-----
- 0 \leq R, G \leq 4500
- All input values are integers.
-----Input-----
Input is given from Standard Input in the following format:
R
G
-----Output-----
Print the performance required to achieve the objective.
-----Sample Input-----
2002
2017
-----Sample Output-----
2032
Takahashi's current rating is 2002.
If his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017. | ["# \u73fe\u5728\u3068\u76ee\u6a19\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u53d6\u5f97\nR = int(input())\nG = int(input())\n\n# \u76ee\u6a19\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u306a\u308b\u305f\u3081\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u6570\u5024\u3092\u8a08\u7b97\nTarget = (G * 2) - R\n\n# \u8a08\u7b97\u7d50\u679c\u3092\u51fa\u529b\nprint(Target)", "R=int(input())\nG=int(input())\nprint((2*G-R))\n", "R = int(input())\nG = int(input())\nprint(2*G-R)", "# \u9ad8\u6a4b\u541b\u306f\u3042\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b3\u30f3\u30c6\u30b9\u30c8\u304c\u884c\u308f\u308c\u3066\u3044\u308b\u30b5\u30a4\u30c8\u306b\u53c2\u52a0\u3057\u3066\u3044\u307e\u3059\u3002\n# \u3053\u3053\u3067\u306f, \u30b3\u30f3\u30c6\u30b9\u30c8\u306b\u51fa\u5834\u3057\u305f\u6642\u306b\u3053\u306e\u9806\u4f4d\u306b\u5fdc\u3058\u3066\u300c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u300d\u3068\u3044\u3046\u3082\u306e\u304c\u3064\u304d\u3001\n# \u305d\u308c\u306b\u3088\u3063\u3066\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0 (\u6574\u6570\u3068\u306f\u9650\u3089\u306a\u3044) \u304c\u6b21\u306e\u3088\u3046\u306b\u5909\u5316\u3057\u307e\u3059\u3002\n#\n# \u73fe\u5728\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3092 a \u3068\u3059\u308b\u3002\n# \u6b21\u306e\u30b3\u30f3\u30c6\u30b9\u30c8\u3067, \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9 b\u3092\u53d6\u3063\u305f\u3068\u3059\u308b\u3002\n# \u305d\u306e\u3068\u304d, \u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u306f a \u3068 b \u306e\u5e73\u5747\u307e\u3067\u5909\u5316\u3059\u308b\u3002\n# \u4f8b\u3048\u3070, \u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u304c 1 \u306e\u4eba\u304c\n# \u6b21\u306e\u30b3\u30f3\u30c6\u30b9\u30c8\u3067\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9 1000\u3092\u53d6\u3063\u305f\u3089,\n# \u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u306f 1 \u3068 1000 \u306e\u5e73\u5747\u3067\u3042\u308b 500.5 \u306b\u306a\u308a\u307e\u3059\u3002\n#\n# \u9ad8\u6a4b\u541b\u306f, \u73fe\u5728\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u304c R \u3067,\n# \u6b21\u306e\u30b3\u30f3\u30c6\u30b9\u30c8\u3067\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u3061\u3087\u3046\u3069 G\u306b\u3057\u305f\u3044\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002\n# \u305d\u306e\u3068\u304d, \u9ad8\u6a4b\u541b\u304c\u53d6\u308b\u3079\u304d\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u6c42\u3081\u306a\u3055\u3044\u3002\n\n# \u5236\u7d04\n# 0 \u2266 R, G \u2266 4500\n# \u5165\u529b\u306f\u3059\u3079\u3066\u6574\u6570\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 R, G \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\nr = int(input())\ng = int(input())\n\n# \u9ad8\u6a4b\u541b\u304c\u53d6\u308a\u3079\u304d\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u8a08\u7b97\u3057\u3001\u51fa\u529b\u3059\u308b\n# (r + x) / 2 = G\nresult = g * 2 - r\n\nprint(result)\n", "def iroha():\n a = [int(input()) for _ in range(2)]\n print((2*a[1]-a[0]))\n \n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "R = int(input())\nG = int(input())\n\nprint(2*G-R)", "a=int(input())\nb= int(input())\nprint(b*2-a)", "R = int(input())\nG = int(input())\n\nprint(G * 2 - R)", "R = int(input())\nG = int(input())\n\nprint(G * 2 - R)", "# \u73fe\u5728\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u304c R \u3067, \u6b21\u306e\u30b3\u30f3\u30c6\u30b9\u30c8\u3067\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u3061\u3087\u3046\u3069 G \u306b\u3057\u305f\u3044\n# \u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u306f\u73fe\u5728\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3068\u6b21\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306e\u5e73\u5747\n\nR = int(input())\nG = int(input())\n\nb = 2*G - R\nprint(b)\n", "R = int(input())\nG = int(input())\n\nprint((2 * G - R))\n\n# \u9ad8\u6a4b\u541b\u304c\u53d6\u308b\u3079\u304d\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3092X\u3068\u7f6e\u304f\u3068\u3000(R + X) / 2 = G \u3068\u306a\u308b\u3002\n# \u5f0f\u3092\u5909\u5f62\u3059\u308b\u3068\u3000X = 2 * G - R \u3068\u306a\u308b\u3002\u3053\u308c\u304c\u9ad8\u6a4b\u541b\u304c\u53d6\u308b\u3079\u304d\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3002\n", "r = int(input())\ng = int(input())\n\nx = 2 * g - r\n\nprint(x)", "x=int(input())\ny=int(input())\nprint(y+(y-x))", "current_rating = int(input())\nfinal_rating = int(input())\nperformance = final_rating * 2 - current_rating\nprint(performance)", "R = int(input())\nG = int(input())\n\nprint(2* G - R)", "print((-1) * int(input()) + 2 * int(input()))", "import bisect,collections,copy,heapq,itertools,math,string\nimport sys\ndef I():\n #1 line 1 int\n return int(sys.stdin.readline().rstrip())\ndef LI():\n #1 line n int\n return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S():\n #1 line 1 string\n return sys.stdin.readline().rstrip()\ndef LS():\n #1 line n strings\n return list(sys.stdin.readline().rstrip().split())\n\nR=I()\nG=I()\n\nx=2*G-R\nprint(x)", "a=int(input())\nb=int(input())\nprint(2*b-a)", "a = int(input())\nb = int(input())\n\nprint(2*b-a)", "R, G = (int(input()) for i in range(2))\nprint(G * 2 - R)", "# \u5165\u529b\nR = int(input())\nG = int(input())\n\n# \u51fa\u529b\n\nif 0 <= R and G <= 4500:\n print(G * 2 - R)", "r = int(input())\nn = int(input())\nprint((n * 2 - r))\n", "print(-int(input()) + 2 * int(input()))", "R = int(input())\nG = int(input())\nprint((G+(G-R)))\n", "# \u5165\u529b\nr = int(input())\ng = int(input())\n\n# \u51e6\u7406\nanswer = 2 * g - r\n\nprint(answer)\n\n", "R = int(input())\nG = int(input())\nprint(2 * G - R)", "# A - Rating Goal\n\n# \u73fe\u5728\u306e\u30ec\u30fc\u30c8\u3092a, \u30b3\u30f3\u30c6\u30b9\u30c8\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092b\u3068\u3059\u308b\u3068\u3001\u30ec\u30fc\u30c8\u306fa\u3068b\u306e\u5e73\u5747\u307e\u3067\u5909\u5316\u3059\u308b\n# \u73fe\u5728\u306e\u30ec\u30fc\u30c8\u3092R, \u6b21\u306e\u30b3\u30f3\u30c6\u30b9\u30c8\u3067\u306e\u76ee\u6a19\u30ec\u30fc\u30c8\u3092G\u3068\u3057\u305f\u5834\u5408\u3001\u53d6\u308b\u3079\u304d\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u51fa\u529b\u3059\u308b\n\n\nR = int(input())\nG = int(input())\n\nprint(((G * 2) - R))\n", "r = int(input())\ng = int(input())\n\nprint(2*g-r)", "r = int(input())\ng = int(input())\nprint(2*g-r)", "a = int(input())\nb = int(input())\nprint(b + (b - a))", "R = int(input())\nG = int(input())\n\nprint(2 * G - R)", "r = int(input())\ng = int(input())\n\nans = g * 2 - r\n\nprint(ans)", "r = int(input())\ng = int(input())\nprint(g*2-r)", "R=int(input())\nG=int(input())\nprint(G*2-R)", "R = int(input()) # \u73fe\u5728\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\nG = int(input()) # \u6b21\u306e\u30b3\u30f3\u30c6\u30b9\u30c8\u3067\u3068\u308a\u305f\u3044\u3068\u601d\u3063\u3066\u308b\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\n\n# \u9ad8\u6a4b\u541b\u304c\u53d6\u308b\u3079\u304d\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u3092\u51fa\u529b\nprint(G*2 - R)", "r = int(input())\ng = int(input())\nprint(2 * g - r)", "S_list = [int(input()) for i in range(2)]\n\nmokuhyou = 2 * S_list[1] - S_list[0]\nprint(mokuhyou)\n", "R = int(input())\nG = int(input())\nprint((2 * G - R))\n", "R=int(input())\nG=int(input())\nprint(G*2-R)", "a=int(input())\nb=int(input())\nprint(2*b-a)", "r = int(input())\ng = int(input())\n\nprint(2*g-r)", "print((-int(input()) + int(input()) * 2))\n", "a,b=[int(input()) for i in range(2)]\n\nprint(2*b-a)", "r = int(input())\ng = int(input())\nprint(2*g - r)", "r = int(input())\ng = int(input())\ng = g * 2\nprint(g-r)", "R=int(input())\nG=int(input())\nprint(2*G-R)", "R = int(input())\nG = int(input())\n\nprint(2 * G - R)", "R, G = (int(input()) for i in range(2))\n\nR += (G - R) * 2\n\nprint(R)", "r=int(input())\ng=int(input())\nprint(2*g-r)", "r = int(input())\ng = int(input())\nprint((g * 2 - r))\n", "#76\nr=int(input())\ng=int(input())\nprint(2*g-r)", "a=int(input())\nb=int(input())\nprint(2*b-a)", "# 076_a\nR=int(input())\nG=int(input())\nif (0<=R and R<=4500) and (0<=G and G<=4500):\n print((2*G-R))\n", "r=int(input())\ng=int(input())\nans=2*g-r\nprint(ans)", "# \u73fe\u5728\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3092 a \u3068\u3059\u308b\u3002\n# \u6b21\u306e\u30b3\u30f3\u30c6\u30b9\u30c8\u3067, \u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9 b \u3092\u53d6\u3063\u305f\u3068\u3059\u308b\u3002\n#\u305d\u306e\u3068\u304d, \u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u306f a \u3068 b \u306e\u5e73\u5747\u307e\u3067\u5909\u5316\u3059\u308b\u3002\n\n# \u73fe\u5728\u306e\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0 R \u3068\u3000\u76ee\u6307\u3057\u305f\u3044\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0 G \u3092\u5165\u529b\nR = int(input())\nG = int(input())\n# print(R, G)\n\n# \u3068\u308b\u3079\u304d\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9 \u3092 x \u3068\u3059\u308b\u3068\u3001\n# \u76ee\u6307\u3057\u305f\u3044\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3000G = (R+x)/2\u3000\n# \u4ee5\u4e0b\u5f0f\u5909\u63db\n# 2G = R + x\n# x = 2G - R\n\nx = (2 * G) - R\n# print(x)\n\n# \u7b54\u3048\u3092\u4ee3\u5165\nanswer = x\nprint(answer)\n", "a=int(input())\nb=int(input())\nprint(b*2-a)", "def main():\n my_rate = int(input())\n avarage_rate = int(input())\n \n target_rate = (avarage_rate * 2) - my_rate\n \n print(target_rate)\n\ndef __starting_point():\n main()\n__starting_point()", "R = int(input())\nG = int(input())\nans = 2*G - R\nprint(ans)", "r = int(input())\ng = int(input())\n\nprint((int(2 * g - r)))\n", "print(-int(input()) + int(input()) * 2)", "print(-int(input())+int(input())*2)", "r=int(input())\ng=int(input())\nprint(2*g-r)", "# A - Rating Goal\n# https://atcoder.jp/contests/abc076/tasks/abc076_a\n\nR = int(input())\nG = int(input())\n\nprint((G * 2 - R))\n", "r=int(input())\ng=int(input())\nprint(2*g-r)", "r=int(input())\nc=int(input())\nprint(2*c-r)", "r = int(input())\ng = int(input())\nprint((2 * g - r))\n", "r=int(input())\ng=int(input())\nprint(g*2-r)", "R = int(input())\nG = int(input())\n\nprint(G * 2 - R)", "r = int(input())\ng = int(input())\n\nprint(2*g - r)", "def main():\n r = int(input())\n g = int(input())\n\n x = 2 * g - r\n print(x)\n \n \nmain()", "a=int(input())\nb=int(input())\n\nprint((a+(b-a)*2))\n", "R = int(input())\nG = int(input())\n\nprint(G*2-R)", "print(-int(input()) + 2*int(input()))", "R = int(input())\nG = int(input())\n\nprint((G * 2 - R))\n", "R = int(input())\nG = int(input())\n\n# (answer + R)/ 2 = G\n\nanswer = 2 * G -R\nprint(answer)", "R = int(input())\nG = int(input())\nprint((2 * G) - R)", "R = int(input())\nG = int(input())\n\nrating = G * 2 - R\nprint(rating)", "# 076a\n\nR = int(input())\nG = int(input())\n\nB = G * 2 - R\nprint(B)\n", "r = int(input())\ng = int(input())\nprint(2*g-r)", "R = int(input())\nG = int(input())\n\nprint(2*G-R)", "r=int(input())\ng=int(input())\nans=(g*2)-r\nprint((int(ans)))\n", "R = int(input())\nG = int(input())\nprint(2*G - R)", "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\ndef I(): return int(input())\ndef F(): return float(input())\ndef SS(): return input()\ndef LI(): return [int(x) for x in input().split()]\ndef LI_(): return [int(x)-1 for x in input().split()]\ndef LF(): return [float(x) for x in input().split()]\ndef LSS(): return input().split()\n\ndef resolve():\n R = I()\n G = I()\n\n ans = 2 * G - R\n print(ans)\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "# AtCoder abc076 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\n# \u30df\u30b9\u3000r, g = map(int, input().split())\nr = int(input())\ng = int(input())\n\n# \u51e6\u7406\n# G = (R + answer) / 2 -> answer = 2G - R\nanswer = 2 * g - r\n\n# \u51fa\u529b\nprint(answer)\n", "# \u73fe\u5728\u306e\u30ec\u30fc\u30c8R\u3068\u30b3\u30f3\u30c6\u30b9\u30c8\u5f8c\u306e\u76ee\u6307\u3057\u305f\u3044\u30ec\u30fc\u30c8G\u3092\u5165\u529b\nR = int(input())\nG = int(input())\n# G\u306e2\u500d\u304b\u3089\u73fe\u5728\u306e\u30ec\u30fc\u30c8R\u3092\u5f15\u3044\u3066\u3001\u6b21\u306e\u30b3\u30f3\u30c6\u30b9\u30c8\u306e\u30ec\u30fc\u30c8\u3092\u51fa\u529b\nprint(G * 2 - R)", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nr = int(input())\ng = int(input())\n\nprint((2*g-r))\n", "with open(0) as f:\n R, G = map(int, f.read().split())\nprint(2*G-R)", "R = int(input())\nG = int(input())\nprint((G + (G - R)))\n", "R = int(input())\nG = int(input())\nprint(G * 2 - R)", "r = int(input())\ng = int(input())\nprint(r+2*(g-r))", "r = int(input())\ng = int(input())\nprint(2*g-r)", "# \u5165\u529b\nR = int(input())\nG = int(input())\n\n# \u51e6\u7406\nanswer = 2 * G - R\n\n# \u51fa\u529b\nprint(answer)", "R = int(input())\nG = int(input())\n\nprint(2 * G - R)", "# \u5165\u529b\nR = int(input())\nG = int(input())\n\n# (R+G)/2=X X=2G-R\nperformance = G * 2 - R\n\n# \u51fa\u529b\nprint(performance)", "r = int(input())\ng = int(input())\n\nprint(2 * g - r)", "a=int(input())\nb=int(input())\nprint(a+(b-a)*2)", "r = int(input())\ng = int(input())\nperformance = 2 * g - r\nprint(performance)", "r,g=int(input()),int(input())\nprint(2*g-r)", "r = int(input())\ng = int(input())\nprint(g*2 - r)", "R=int(input())\nG=int(input())\nprint((G*2-R))\n"] | {"inputs": ["2002\n2017\n", "4500\n0\n"], "outputs": ["2032\n", "-4500\n"]} | INTRODUCTORY | PYTHON3 | ATCODER.JP | 13,202 | |
f6e34a6b946297e6ab2346a88f30ad63 | UNKNOWN | Given head, the head of a linked list, determine if the linked list has a cycle in it.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. Note that pos is not passed as a parameter.
Return true if there is a cycle in the linked list. Otherwise, return false.
Input: head = [3,2,0,-4], pos = 1
Output: true
Explanation: There is a cycle in the linked list, where the tail connects to the 1st node (0-indexed).
Input: head = [1,2], pos = 0
Output: true
Explanation: There is a cycle in the linked list, where the tail connects to the 0th node.
Input: head = [1], pos = -1
Output: false
Explanation: There is no cycle in the linked list.
Constraints:
The number of the nodes in the list is in the range [0, 104].
-105 <= Node.val <= 105
pos is -1 or a valid index in the linked-list. | ["class Solution:\n def hasCycle(self, head: ListNode) -> bool:\n if head == None:\n return False\n \n slow = head\n fast = head.next\n \n while slow != fast:\n if fast is None or fast.next is None:\n return False\n slow = slow.next\n fast = fast.next.next\n \n return True", "class Solution:\n def hasCycle(self, head: ListNode) -> bool:\n slow = head\n fast = head\n while fast and fast.next:\n slow = slow.next\n fast = fast.next.next\n if slow == fast:\n return True\n return False", "class Solution:\n def hasCycle(self, head: ListNode) -> bool:\n \n slow = head\n fast = head\n \n \n while fast and fast.next:\n slow = slow.next\n fast = fast.next.next\n if slow == fast:\n return True\n \n return False", "class Solution:\n def hasCycle(self, head: ListNode) -> bool:\n nodes_seen = set()\n while head is not None:\n if head in nodes_seen:\n return True\n nodes_seen.add(head)\n head = head.next\n return False", "class Solution:\n def hasCycle(self, head: ListNode) -> bool:\n cur = head\n check = set()\n while cur:\n if cur in check:\n return True\n check.add(cur)\n cur = cur.next\n return False", "class Solution:\n def hasCycle(self, head: ListNode) -> bool:\n try:\n slow = head\n fast = head.next \n while slow is not fast:\n slow = slow.next\n fast = fast.next.next\n return True\n except:\n return False", "class Solution:\n def hasCycle(self, head: ListNode) -> bool:\n if head is None:\n return False\n\n slow, fast = head, head\n while fast.next and fast.next.next:\n slow = slow.next\n fast = fast.next.next\n if slow == fast:\n return True\n return False"] | {"fn_name": "hasCycle", "inputs": [[[3,2,0,-4], 1], [[1,2], 0], [[1], -1]], "outputs": [[true], [true], [false]]} | INTRODUCTORY | PYTHON3 | LEETCODE | 2,225 |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def hasCycle(self, head: ListNode) -> bool:
|
b194f7e5e676fd7822c67b098935bcac | UNKNOWN | Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1]. | ["class Solution:\n def twoSum(self, nums, target):\n tmp = {}\n for i in range(len(nums)):\n if target - nums[i] in tmp:\n return(tmp[target - nums[i]], i)\n else:\n tmp[nums[i]] = i;\n \n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n", "class Solution:\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n d = {}\n for i, num in enumerate(nums):\n if (target - num) in d:\n return [d[target-num], i]\n d[num] = i\n \n new = sorted(nums)\n i,j = 0, -1\n for num in new:\n a, b = new[i], new[j]\n if a + b > target:\n j = j - 1\n elif a + b < target:\n i = i + 1\n elif a + b == target:\n if a != b:\n ans = [nums.index(a), nums.index(b)]\n else:\n m = nums.index(a)\n nums.remove(a)\n n = nums.index(b)\n ans =[m, n+1]\n return (ans)\n \n \n", "class Solution(object):\n def twoSum(self, nums, target):\n hashdict = {}\n for i,num in enumerate(nums):\n if target-num in hashdict:\n return [hashdict[target-num], i]\n else:\n hashdict[num] = i\n", "# Using 'dict', like hash, to find the pair number\n class Solution:\n def twoSum(self, numbers, target):\n ans = []\n dir = {}\n ll = len(numbers)\n for i in range(ll):\n dir[numbers[i]] = i\n for i in range(ll):\n o2 = target-numbers[i]\n if o2 in dir:\n if (dir[o2] != i):\n ans.append(i)\n ans.append(dir[o2])\n return ans", "class Solution:\n def twoSum(self, nums, target):\n '''\n type nums:array\n type target:integer\n rtype :List\n '''\n d = {}\n for i, num in enumerate(nums):\n if target - num in d:\n return[d[target - num], i]\n d[num] = i ", "# Using 'dict', like hash, to find the pair number\n class Solution:\n def twoSum(self, numbers, target):\n ans = []\n dir = {}\n ll = len(numbers)\n for i in range(ll):\n dir[numbers[i]] = i\n for i in range(ll):\n o2 = target-numbers[i]\n if o2 in dir:\n if (dir[o2] != i):\n ans.append(i)\n ans.append(dir[o2])\n return ans", "class Solution:\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n t=dict()\n l=len(nums)\n if l<=1: return []\n for i in range(l):\n t[nums[i]]=i\n for i in range(l):\n comp=target-nums[i]\n if comp in t and t[comp]!=i:\n return [i,t[comp]]\n return []", "class Solution(object): \n def twoSum(self, nums, target): \n \"\"\" \n :type nums: List[int] \n :type target: int \n :rtype: List[int] \n \"\"\" \n arr = {}\n length = len(nums)\n for i in range(length): \n if (target - nums[i]) in arr:\n return [arr[target - nums[i]], i]\n arr[nums[i]] = i", "class Solution:\n \n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n hashmap = {}\n x = len(nums)\n for i in range(x):\n comp = target - nums[i]\n if comp in hashmap:\n return [hashmap.get(comp), i]\n hashmap[nums[i]] = i\n \n", "class Solution:\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n sorted_nums = sorted(nums)\n start = 0\n end = len(nums) - 1\n while start < end:\n curr_sum = sorted_nums[start] + sorted_nums[end]\n if (curr_sum == target):\n break\n if (curr_sum < target):\n start += 1\n else:\n end -= 1\n first_index = nums.index(sorted_nums[start])\n second_index = nums.index(sorted_nums[end])\n if sorted_nums[start] == sorted_nums[end]:\n nums.pop(first_index)\n second_index = nums.index(sorted_nums[end]) + 1\n return [first_index, second_index]\n", "class Solution:\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n table = {}\n for i, e in enumerate(nums):\n print(\"fe\")\n if e in table:\n table[e] = [table[e][0] + 1, table[e][1] + [i]]\n else:\n table[e] = [1, [i]]\n \n sub_target = target - e\n if sub_target in table and (sub_target != e or table[sub_target][0] >= 2):\n print(table)\n first_idx = i\n second_idx = None\n for index in table[sub_target][1]:\n if index != first_idx:\n second_idx = index\n break\n \n assert(second_idx, \"got shit\")\n result = [first_idx, second_idx]\n result.sort()\n return result\n return []", "class Solution(object):\n def twoSum(self, nums, target):\n hashdict = {}\n for i,num in enumerate(nums):\n if target-num in hashdict:\n return [hashdict[target-num], i]\n else:\n hashdict[num] = i\n", "class Solution(object):\n def twoSum(self, nums, target):\n nums_index = [(v, index) for index, v in enumerate(nums)]\n nums_index.sort()\n begin, end = 0, len(nums) - 1\n while begin < end:\n curr = nums_index[begin][0] + nums_index[end][0]\n if curr == target:\n return [nums_index[begin][1], nums_index[end][1]]\n elif curr < target:\n begin += 1\n else:\n end -= 1\n", "class Solution:\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n numsMap = {}\n for i, num in enumerate(nums):\n if target - num in numsMap:\n return [i, numsMap[target-num]]\n numsMap[num] = i\n return [None, None]", "class Solution:\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n # length_nums = len(nums)\n \n # for i in range(length_nums):\n # for j in range(i+1, length_nums):\n # if nums[i] + nums[j] == target:\n # return [i, j]\n \n # dic = {}\n # for i, num in enumerate(nums):\n # if num in dic:\n # return [dic[num], i]\n # else:\n # dic[target - num] = i\n \n num_dict = {}\n for i, num in enumerate(nums):\n rem = target - num\n if rem in num_dict:\n return [num_dict[rem], i]\n num_dict[num] = i\n return None", "class Solution:\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n dict = {}\n for i in range(0,len(nums)):\n if nums[i] in dict:\n return [dict[nums[i]],i]\n else:\n dict[target-nums[i]] = i\n return []", "class Solution:\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n indexes = dict([(nums[i], i) for i in range(len(nums))])\n for i in range(len(nums)):\n if target-nums[i] in indexes and indexes[target - nums[i]] != i:\n return [i, indexes[target - nums[i]]]\n return []", "class Solution:\n def twoSum(self, nums, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n \n # record the sorted index (original position)\n nums_sorted_index = sorted(range(len(nums)), key = lambda k: nums[k])\n # sort the list\n nums.sort()\n for i in range(len(nums)):\n for j in range(i+1,len(nums)):\n if nums[i]+nums[j] > target:\n break\n elif nums[i]+nums[j] == target:\n return [nums_sorted_index[i], nums_sorted_index[j]]\n print('Can\\'t find a match!')", "class Solution:\n def twoSum(self, nums, target):\n \n \"\"\"\n dic={}\n for i,now in enumerate(nums):\n dev = target - now\n if dev in dic:\n return [dic[dev],i]\n dic[now]=i\n return None\n \"\"\"\n \n \n # old\n a=sorted(nums)\n \n for j in range(len(nums)):\n for k in range(j+1,len(nums)):\n s = a[j]+a[k]\n if s == target:\n if a[j]==a[k]:\n return [i for i,x in enumerate(nums) if x == a[k]]\n else:\n b=nums.index(a[j])\n c=nums.index(a[k])\n return [b,c]\n \n elif s>target:\n break\n \n \n \"\"\"\n :type nums: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n", "# Using 'dict', like hash, to find the pair number\n class Solution:\n def twoSum(self, numbers, target):\n ans = []\n dir = {}\n ll = len(numbers)\n for i in range(ll):\n dir[numbers[i]] = i\n for i in range(ll):\n o2 = target-numbers[i]\n if o2 in dir:\n if (dir[o2] != i):\n ans.append(i)\n ans.append(dir[o2])\n return ans"] | {"fn_name": "twoSum", "inputs": [[[2,7,11,15], [9]], [[3,2,4], [6]], [[3,3], [6]]], "outputs": [[0,1], [1,2], [0,1]]} | INTRODUCTORY | PYTHON3 | LEETCODE | 11,200 |
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
|