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
091ff1628ea76dfcb5f74b82ce37c817
UNKNOWN
You are given a positive integer $n$, it is guaranteed that $n$ is even (i.e. divisible by $2$). You want to construct the array $a$ of length $n$ such that: The first $\frac{n}{2}$ elements of $a$ are even (divisible by $2$); the second $\frac{n}{2}$ elements of $a$ are odd (not divisible by $2$); all elements of $a$ are distinct and positive; the sum of the first half equals to the sum of the second half ($\sum\limits_{i=1}^{\frac{n}{2}} a_i = \sum\limits_{i=\frac{n}{2} + 1}^{n} a_i$). If there are multiple answers, you can print any. It is not guaranteed that the answer exists. You have to answer $t$ independent test cases. -----Input----- The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) β€” the number of test cases. Then $t$ test cases follow. The only line of the test case contains one integer $n$ ($2 \le n \le 2 \cdot 10^5$) β€” the length of the array. It is guaranteed that that $n$ is even (i.e. divisible by $2$). It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$). -----Output----- For each test case, print the answer β€” "NO" (without quotes), if there is no suitable answer for the given test case or "YES" in the first line and any suitable array $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$) satisfying conditions from the problem statement on the second line. -----Example----- Input 5 2 4 6 8 10 Output NO YES 2 4 1 5 NO YES 2 4 6 8 1 3 5 11 NO
["for _ in range(int(input())):\n n=int(input())\n if(n%4!=0):\n print('NO')\n elif(n%4==0):\n print('YES')\n a=[]\n for i in range(1,n//2+1):\n a.append(i*2)\n s=sum(a)\n s1=0\n for i in range(1,n//2):\n x=i*2-1\n a.append(x)\n s1+=x\n a.append(s-s1)\n print(*a)", "t = int(input())\nfor rew in range(t):\n\tn = int(input())\n\tif n%4 == 2:\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n\t\tn//=2\n\t\tpocz = [2*(i+1) for i in range(n)]\n\t\tkon = [2*i+1 for i in range(n-1)]\n\t\tdod = sum(pocz)-sum(kon)\n\t\todp = pocz + kon + [dod]\n\t\tprint(*odp)", "for i in range(int(input())):\n\tn=int(input())\n\tk=int(n/2)\n\tif(k%2==1):\n\t\tprint(\"NO\")\n\telse:\n\t\tprint(\"YES\")\n\t\ts1=0\n\t\tfor i in range(k):\n\t\t\tprint(2*(i+1), end=\" \")\n\t\t\ts1+=2*(i+1)\n\t\ts2=0\n\t\tfor i in range(k-1):\n\t\t\tprint(2*i+1, end=\" \")\n\t\t\ts2+=2*i+1\n\t\tprint(s1-s2)", "from math import *\ntest = int(input())\nfor test_case in range(test):\n\tn = int(input())\n\tans = []\n\ts = 0\n\tfor i in range(1,n//2+1):\n\t\tans.append(i*2)\n\t\ts += i*2\n\tfor i in range(1,n//2):\n\t\tans.append(i*2-1)\n\t\ts -= i*2-1\n\tif(s%2 == 0):\n\t\tprint(\"NO\")\n\t\tcontinue\n\telse:\n\t\tans.append(s)\n\t\tprint(\"YES\")\n\t\tfor i in ans:\n\t\t\tprint(i,end = \" \")\n\t\tprint()", "t = int(input())\nfor _ in range(t):\n n = int(input())\n if (n // 2) % 2:\n print(\"NO\")\n continue\n a = []\n s = 0\n for i in range(n // 2):\n s += 2*(i + 1)\n a.append(2*(i + 1))\n for j in range(n // 2 - 1):\n s -= 2*j + 1\n a.append(2*j + 1)\n a.append(s)\n print(\"YES\")\n print(*a)\n\n\n# a = list(map(int,input().split()))\n# n,m = map(int,input().split())\n\n", "import sys\nlines = sys.stdin.readlines()\nT = int(lines[0].strip())\nfor t in range(1, T+1):\n n = int(lines[t].strip())\n if n % 4 == 2: print(\"NO\"); continue\n print(\"YES\")\n res = []\n tmp = 0\n for i in range(1, n//2+1):\n res.append(2*i)\n tmp += 2*i\n for i in range(1, n//2):\n res.append(2*i-1)\n tmp -= 2*i-1\n res.append(tmp)\n print(\" \".join(map(str, res)))\n", "from math import *\n\nfor zz in range(int(input())):\n n = int(input())\n if n % 4 != 0:\n print('NO')\n else:\n print('YES')\n a = []\n cs = 0\n ce = 2\n for i in range(n//2):\n a.append(ce)\n cs += ce\n ce += 2\n ce = 1\n for i in range(n//2, n - 1):\n a.append(ce)\n cs -= ce\n ce += 2\n a.append(cs)\n print(*a)\n", "t = int(input())\nfor tt in range(t):\n\tn = int(input())\n\tif n % 4 == 0:\n\t\tprint('YES')\n\t\ta = list(range(2, n + 1, 2)) + list(range(1, n - 1, 2)) + [sum(range(2, n + 1, 2)) - sum(range(1, n - 1, 2))]\n\t\tprint(' '.join(map(str, a)))\n\telse:\n\t\tprint('NO')\n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n if (n//2)%2 == 1:\n print(\"NO\")\n else:\n print(\"YES\")\n even = [i*2 for i in range(1, n//2 + 1)]\n odd = [(i*2 - 1) for i in range(1, n//2)]\n odd.append((sum(even) - sum(odd)))\n print(*even, *odd)\n"]
{"inputs": ["5\n2\n4\n6\n8\n10\n", "1\n199998\n", "3\n2\n4\n6\n"], "outputs": ["NO\nYES\n2 4 1 5\nNO\nYES\n2 4 6 8 1 3 5 11\nNO\n", "NO\n", "NO\nYES\n2 4 1 5\nNO\n"]}
INTRODUCTORY
PYTHON3
CODEFORCES
3,331
7fdca26a5ae00cbd42920bed248642d9
UNKNOWN
Pay attention to the non-standard memory limit in this problem. In order to cut off efficient solutions from inefficient ones in this problem, the time limit is rather strict. Prefer to use compiled statically typed languages (e.g. C++). If you use Python, then submit solutions on PyPy. Try to write an efficient solution. The array $a=[a_1, a_2, \ldots, a_n]$ ($1 \le a_i \le n$) is given. Its element $a_i$ is called special if there exists a pair of indices $l$ and $r$ ($1 \le l < r \le n$) such that $a_i = a_l + a_{l+1} + \ldots + a_r$. In other words, an element is called special if it can be represented as the sum of two or more consecutive elements of an array (no matter if they are special or not). Print the number of special elements of the given array $a$. For example, if $n=9$ and $a=[3,1,4,1,5,9,2,6,5]$, then the answer is $5$: $a_3=4$ is a special element, since $a_3=4=a_1+a_2=3+1$; $a_5=5$ is a special element, since $a_5=5=a_2+a_3=1+4$; $a_6=9$ is a special element, since $a_6=9=a_1+a_2+a_3+a_4=3+1+4+1$; $a_8=6$ is a special element, since $a_8=6=a_2+a_3+a_4=1+4+1$; $a_9=5$ is a special element, since $a_9=5=a_2+a_3=1+4$. Please note that some of the elements of the array $a$ may be equal β€” if several elements are equal and special, then all of them should be counted in the answer. -----Input----- The first line contains an integer $t$ ($1 \le t \le 1000$) β€” the number of test cases in the input. Then $t$ test cases follow. Each test case is given in two lines. The first line contains an integer $n$ ($1 \le n \le 8000$) β€” the length of the array $a$. The second line contains integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$). It is guaranteed that the sum of the values of $n$ for all test cases in the input does not exceed $8000$. -----Output----- Print $t$ numbers β€” the number of special elements for each of the given arrays. -----Example----- Input 5 9 3 1 4 1 5 9 2 6 5 3 1 1 2 5 1 1 1 1 1 8 8 7 6 5 4 3 2 1 1 1 Output 5 1 0 4 0
["for _ in range(int(input())):\n n = int(input())\n ar = list(map(int, input().split()))\n keke = dict()\n for elem in ar:\n if elem in keke:\n keke[elem] += 1\n else:\n keke[elem] = 1\n ans = 0\n for i in range(n):\n num = ar[i]\n for j in range(i + 1, n):\n num += ar[j]\n if num in keke:\n ans += keke[num]\n keke[num] = 0\n print(ans)", "def Zs(): return list(map(int, input().split()))\ndef Z(): return int(input())\n\ndef solve(N, A):\n s = [0] * (N + 1)\n for i in range(N):\n s[i + 1] = s[i] + A[i]\n aru = [False] * (N + 1)\n for i in range(N):\n for j in range(i + 1, N):\n if s[j + 1] - s[i] <= N:\n aru[s[j + 1] - s[i]] = True\n ans = 0\n for i in range(N):\n if aru[A[i]]: ans += 1\n return ans\n\nfor _ in range(Z()):\n N = Z()\n A = Zs()\n print(solve(N, A))\n\n\n", "import sys\n\n\ninput()\nfor a in sys.stdin.readlines()[1::2]:\n a = [int(s) for s in a.split()]\n n = len(a)\n\n can = [False for i in range(n)]\n \n for i in range(1, n):\n s = a[i]\n for j in range(i-1, -1, -1):\n s += a[j]\n if s > n:\n break\n\n can[s-1] = True\n\n print(sum([1 for num in a if can[num-1]]))\n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n s = list(map(int, input().split()))\n p = max(s)\n dict = {}\n for i in range(n):\n count = s[i]\n for j in range(i+1, n):\n count += s[j]\n dict[count] = 1\n if count >= p:\n break\n ans = 0\n for i in range(n):\n if dict.get(s[i]) is not None:\n ans += 1\n print(ans)\n", "t = int(input())\nspl = []\n\nfor i in range(8001):\n\tspl.append(0)\n\nfor i in range(t):\n\tn = int(input())\n\tarr = input().split(' ')\n\n\tfor j in range(n):\n\t\tarr[j] = int(arr[j])\n\n\tfor j in range(n):\n\t\tcurr = arr[j]\n\t\tfor k in range(j+1, n):\n\t\t\tcurr += arr[k]\n\t\t\tif (curr > 8000):\n\t\t\t\tbreak\n\t\t\tspl[curr] = 1\n\n\tans = 0\n\n\tfor j in range(n):\n\t\tans += (spl[arr[j]])\n\n\tfor j in range(8001):\n\t\tspl[j] = 0\n\n\tprint (ans)", "T = int(input())\nfor _ in range(T):\n n = int(input())\n arr = list(map(int, input().split(\" \")))\n prefix = []\n prefix.append(arr[0])\n mx = arr[0]\n for i in range(1, n):\n mx = max(mx, arr[i])\n prefix.append(arr[i])\n prefix[i] += prefix[i - 1]\n\n m = {}\n for i in range(0, n):\n for j in range(i + 1, n):\n if i == 0:\n s = prefix[j]\n if s <= mx:\n m[s] = 0\n else:\n s = prefix[j] - prefix[i - 1]\n if s <= mx:\n m[s] = 0\n \n ans = 0\n for i in arr:\n if i in m:\n ans += 1\n\n print(ans) ", "for t in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n special = [0] * (2 * n)\n for i in range(n - 1):\n summ = a[i]\n j = i + 1\n while j < n and summ < n:\n summ += a[j]\n j += 1\n special[summ] = 1\n cnt_spec = 0\n for i in range(n):\n cnt_spec += special[a[i]]\n print(cnt_spec)"]
{ "inputs": [ "5\n9\n3 1 4 1 5 9 2 6 5\n3\n1 1 2\n5\n1 1 1 1 1\n8\n8 7 6 5 4 3 2 1\n1\n1\n", "7\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n", "7\n2\n1 1\n2\n1 2\n2\n2 1\n2\n2 2\n12\n5 8 10 1 1 10 7 3 12 3 3 7\n5\n2 1 3 1 3\n4\n4 3 4 3\n" ], "outputs": [ "5\n1\n0\n4\n0\n", "0\n0\n0\n0\n0\n0\n0\n", "0\n0\n0\n0\n3\n2\n0\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
3,403
2ade33375ea926879e1323cf7481d03a
UNKNOWN
You are given $n$ segments on a coordinate axis $OX$. The $i$-th segment has borders $[l_i; r_i]$. All points $x$, for which $l_i \le x \le r_i$ holds, belong to the $i$-th segment. Your task is to choose the maximum by size (the number of segments) subset of the given set of segments such that each pair of segments in this subset either non-intersecting or one of them lies inside the other one. Two segments $[l_i; r_i]$ and $[l_j; r_j]$ are non-intersecting if they have no common points. For example, segments $[1; 2]$ and $[3; 4]$, $[1; 3]$ and $[5; 5]$ are non-intersecting, while segments $[1; 2]$ and $[2; 3]$, $[1; 2]$ and $[2; 2]$ are intersecting. The segment $[l_i; r_i]$ lies inside the segment $[l_j; r_j]$ if $l_j \le l_i$ and $r_i \le r_j$. For example, segments $[2; 2]$, $[2, 3]$, $[3; 4]$ and $[2; 4]$ lie inside the segment $[2; 4]$, while $[2; 5]$ and $[1; 4]$ are not. You have to answer $t$ independent test cases. -----Input----- The first line of the input contains one integer $t$ ($1 \le t \le 1000$) β€” 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 3000$) β€” the number of segments. The next $n$ lines describe segments. The $i$-th segment is given as two integers $l_i$ and $r_i$ ($1 \le l_i \le r_i \le 2 \cdot 10^5$), where $l_i$ is the left border of the $i$-th segment and $r_i$ is the right border of the $i$-th segment. Additional constraint on the input: there are no duplicates in the list of segments. It is guaranteed that the sum of $n$ does not exceed $3000$ ($\sum n \le 3000$). -----Output----- For each test case, print the answer: the maximum possible size of the subset of the given set of segments such that each pair of segments in this subset either non-intersecting or one of them lies inside the other one. -----Example----- Input 4 4 1 5 2 4 2 3 3 4 5 1 5 2 3 2 5 3 5 2 2 3 1 3 2 4 2 3 7 1 10 2 8 2 5 3 4 4 4 6 8 7 7 Output 3 4 2 7
["import sys\nfrom collections import deque\n\ninput=sys.stdin.readline\n\nt=1\nt=int(input())\nfor _ in range(t):\n n=int(input())\n val=set([0,2*10**5+1])\n seg=[(0,2*10**5+1)]\n for i in range(n):\n l,r=list(map(int,input().split()))\n val.add(l)\n val.add(r)\n seg.append((l,r))\n val=list(val)\n val.sort()\n comp={i:e+1 for e,i in enumerate(val)}\n for i in range(n+1):\n l,r=seg[i]\n seg[i]=(comp[l],comp[r])\n\n deg=[0]*(n+1)\n out=[[] for i in range(n+1)]\n for i in range(n+1):\n for j in range(i+1,n+1):\n l,r=seg[i]\n L,R=seg[j]\n if L<=l and r<=R:\n out[j].append(i)\n deg[i]+=1\n elif l<=L and R<=r:\n out[i].append(j)\n deg[j]+=1\n\n ans=[0]\n deq=deque(ans)\n\n while deq:\n v=deq.popleft()\n for nv in out[v]:\n deg[nv]-=1\n if deg[nv]==0:\n deq.append(nv)\n ans.append(nv)\n\n dp=[0]*(n+1)\n\n def solve(v):\n query=[[] for i in range(2*n+3)]\n for nv in out[v]:\n l,r=seg[nv]\n query[r].append((l,dp[nv]))\n subdp=[0]*(2*n+3)\n for i in range(1,2*n+3):\n res=subdp[i-1]\n for l,val in query[i]:\n test=subdp[l-1]+val\n res=max(test,res)\n subdp[i]=res\n\n dp[v]=subdp[-1]+1\n\n for v in ans[::-1]:\n solve(v)\n\n print(dp[0]-1)\n", "import sys\nfrom collections import deque\n\ninput=sys.stdin.readline\n\nt=1\nt=int(input())\nfor _ in range(t):\n n=int(input())\n val=set([0,2*10**5+1])\n seg=[(0,2*10**5+1)]\n for i in range(n):\n l,r=map(int,input().split())\n val.add(l)\n val.add(r)\n seg.append((l,r))\n val=list(val)\n val.sort()\n comp={i:e+1 for e,i in enumerate(val)}\n for i in range(n+1):\n l,r=seg[i]\n seg[i]=(comp[l],comp[r])\n\n deg=[0]*(n+1)\n out=[[] for i in range(n+1)]\n for i in range(n+1):\n for j in range(i+1,n+1):\n l,r=seg[i]\n L,R=seg[j]\n if L<=l and r<=R:\n out[j].append(i)\n deg[i]+=1\n elif l<=L and R<=r:\n out[i].append(j)\n deg[j]+=1\n\n ans=[0]\n deq=deque(ans)\n\n while deq:\n v=deq.popleft()\n for nv in out[v]:\n deg[nv]-=1\n if deg[nv]==0:\n deq.append(nv)\n ans.append(nv)\n\n dp=[0]*(n+1)\n\n def solve(v):\n query=[[] for i in range(2*n+3)]\n for nv in out[v]:\n l,r=seg[nv]\n query[r].append((l,dp[nv]))\n subdp=[0]*(2*n+3)\n for i in range(1,2*n+3):\n res=subdp[i-1]\n for l,val in query[i]:\n test=subdp[l-1]+val\n res=max(test,res)\n subdp[i]=res\n\n dp[v]=subdp[-1]+1\n\n for v in ans[::-1]:\n solve(v)\n\n print(dp[0]-1)", "import sys\nfrom collections import deque\n\nt=1\nfor _ in range(int(input())):\n n=int(input())\n val=set([0,2*10**5+1])\n seg=[(0,2*10**5+1)]\n for i in range(n):\n l,r=map(int,input().split())\n val.add(l)\n val.add(r)\n seg.append((l,r))\n val=list(val)\n val.sort()\n comp={i:e+1 for e,i in enumerate(val)}\n for i in range(n+1):\n l,r=seg[i]\n seg[i]=(comp[l],comp[r])\n\n deg=[0]*(n+1)\n out=[[] for i in range(n+1)]\n for i in range(n+1):\n for j in range(i+1,n+1):\n l,r=seg[i]\n L,R=seg[j]\n if L<=l and r<=R:\n out[j].append(i)\n deg[i]+=1\n elif l<=L and R<=r:\n out[i].append(j)\n deg[j]+=1\n\n ans=[0]\n deq=deque(ans)\n\n while deq:\n v=deq.popleft()\n for nv in out[v]:\n deg[nv]-=1\n if deg[nv]==0:\n deq.append(nv)\n ans.append(nv)\n\n dp=[0]*(n+1)\n\n def solve(v):\n query=[[] for i in range(2*n+3)]\n for nv in out[v]:l,r=seg[nv];query[r].append((l,dp[nv]))\n subdp=[0]*(2*n+3)\n for i in range(1,2*n+3):\n res=subdp[i-1]\n for l,val in query[i]:test=subdp[l-1]+val;res=max(test,res)\n subdp[i]=res\n\n dp[v]=subdp[-1]+1\n\n for v in ans[::-1]:solve(v)\n\n print(dp[0]-1)", "from collections import deque\n\nt=1\nfor _ in range(int(input())):\n n=int(input())\n val=set([0,2*10**5+1])\n seg=[(0,2*10**5+1)]\n for i in range(n):\n l,r=map(int,input().split())\n val.add(l)\n val.add(r)\n seg.append((l,r))\n val=list(val)\n val.sort()\n comp={i:e+1 for e,i in enumerate(val)}\n for i in range(n+1):\n l,r=seg[i]\n seg[i]=(comp[l],comp[r])\n\n deg=[0]*(n+1)\n out=[[] for i in range(n+1)]\n for i in range(n+1):\n for j in range(i+1,n+1):\n l,r=seg[i];L,R=seg[j]\n if L<=l and r<=R:out[j].append(i);deg[i]+=1\n elif l<=L and R<=r:out[i].append(j);deg[j]+=1\n\n ans=[0]\n deq=deque(ans)\n\n while deq:\n v=deq.popleft()\n for nv in out[v]:\n deg[nv]-=1\n if deg[nv]==0:deq.append(nv);ans.append(nv)\n\n dp=[0]*(n+1)\n\n def solve(v):\n query=[[] for i in range(2*n+3)]\n for nv in out[v]:l,r=seg[nv];query[r].append((l,dp[nv]))\n subdp=[0]*(2*n+3)\n for i in range(1,2*n+3):\n res=subdp[i-1]\n for l,val in query[i]:test=subdp[l-1]+val;res=max(test,res)\n subdp[i]=res\n\n dp[v]=subdp[-1]+1\n\n for v in ans[::-1]:solve(v)\n\n print(dp[0]-1)", "from collections import deque\n\nt=1\nfor _ in range(int(input())):\n n=int(input())\n val=set([0,2*10**5+1])\n seg=[(0,2*10**5+1)]\n for i in range(n):l,r=map(int,input().split());val.add(l);val.add(r);seg.append((l,r))\n val=sorted(list(val))\n comp={i:e+1 for e,i in enumerate(val)}\n for i in range(n+1):l,r=seg[i];seg[i]=(comp[l],comp[r])\n\n deg=[0]*(n+1);out=[[] for i in range(n+1)]\n for i in range(n+1):\n for j in range(i+1,n+1):\n l,r=seg[i];L,R=seg[j]\n if L<=l and r<=R:out[j].append(i);deg[i]+=1\n elif l<=L and R<=r:out[i].append(j);deg[j]+=1\n\n ans=[0]\n deq=deque(ans)\n\n while deq:\n v=deq.popleft()\n for nv in out[v]:\n deg[nv]-=1\n if deg[nv]==0:deq.append(nv);ans.append(nv)\n\n dp=[0]*(n+1)\n\n def solve(v):\n query=[[] for i in range(2*n+3)]\n for nv in out[v]:l,r=seg[nv];query[r].append((l,dp[nv]))\n subdp=[0]*(2*n+3)\n for i in range(1,2*n+3):\n res=subdp[i-1]\n for l,val in query[i]:test=subdp[l-1]+val;res=max(test,res)\n subdp[i]=res\n\n dp[v]=subdp[-1]+1\n\n for v in ans[::-1]:solve(v)\n\n print(dp[0]-1)", "from collections import deque\n\nfor _ in range(int(input())):\n n=int(input());val=set([0,2*10**5+1]);seg=[(0,2*10**5+1)]\n for i in range(n):l,r=map(int,input().split());val.add(l);val.add(r);seg.append((l,r))\n val=sorted(list(val));comp={i:e+1 for e,i in enumerate(val)}\n for i in range(n+1):l,r=seg[i];seg[i]=(comp[l],comp[r])\n\n deg=[0]*(n+1);out=[[] for i in range(n+1)]\n for i in range(n+1):\n for j in range(i+1,n+1):\n l,r=seg[i];L,R=seg[j]\n if L<=l and r<=R:out[j].append(i);deg[i]+=1\n elif l<=L and R<=r:out[i].append(j);deg[j]+=1\n\n ans=[0]\n deq=deque(ans)\n\n while deq:\n v=deq.popleft()\n for nv in out[v]:\n deg[nv]-=1\n if deg[nv]==0:deq.append(nv);ans.append(nv)\n\n dp=[0]*(n+1)\n\n def solve(v):\n query=[[] for i in range(2*n+3)]\n for nv in out[v]:l,r=seg[nv];query[r].append((l,dp[nv]))\n subdp=[0]*(2*n+3)\n for i in range(1,2*n+3):\n res=subdp[i-1]\n for l,val in query[i]:test=subdp[l-1]+val;res=max(test,res)\n subdp[i]=res\n\n dp[v]=subdp[-1]+1\n\n for v in ans[::-1]:solve(v)\n\n print(dp[0]-1)", "from collections import deque\nfor _ in range(int(input())):\n n=int(input());val=set([0,2*10**5+1]);seg=[(0,2*10**5+1)]\n for i in range(n):l,r=map(int,input().split());val.add(l);val.add(r);seg.append((l,r))\n val=sorted(list(val));comp={i:e+1 for e,i in enumerate(val)};deg=[0]*(n+1);out=[[] for i in range(n+1)]\n for i in range(n+1):l,r=seg[i];seg[i]=(comp[l],comp[r]) \n for i in range(n+1):\n for j in range(i+1,n+1):\n l,r=seg[i];L,R=seg[j]\n if L<=l and r<=R:out[j].append(i);deg[i]+=1\n elif l<=L and R<=r:out[i].append(j);deg[j]+=1\n ans=[0];deq=deque(ans);dp=[0]*(n+1)\n while deq:\n v=deq.popleft()\n for nv in out[v]:\n deg[nv]-=1\n if deg[nv]==0:deq.append(nv);ans.append(nv) \n def solve(v):\n query=[[] for i in range(2*n+3)];subdp=[0]*(2*n+3)\n for nv in out[v]:l,r=seg[nv];query[r].append((l,dp[nv])) \n for i in range(1,2*n+3):\n res=subdp[i-1]\n for l,val in query[i]:test=subdp[l-1]+val;res=max(test,res)\n subdp[i]=res\n dp[v]=subdp[-1]+1\n for v in ans[::-1]:solve(v)\n print(dp[0]-1)", "# Fast IO (only use in integer input)\n\n# import os,io\n# input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n\nt = int(input())\nfor _ in range(t):\n n = int(input())\n pointList = []\n pointOrderDict = {}\n interval = [] # (l,r) tuple\n intervalOrder = [] # interval list compressed as an order\n for _ in range(n):\n l,r = map(int,input().split())\n pointList.append(l)\n pointList.append(r)\n interval.append((l,r))\n pointList.sort()\n cnt = 0\n for i in range(2 * n):\n if i == 0 or pointList[i] != pointList[i-1]:\n pointOrderDict[pointList[i]] = cnt\n cnt += 1\n\n for elem in interval:\n intervalOrder.append((pointOrderDict[elem[0]],pointOrderDict[elem[1]]))\n \n intervalList = []\n dp = []\n\n for i in range(cnt):\n dp.append([])\n intervalList.append([])\n for j in range(cnt):\n dp[i].append(-1)\n\n for elem in intervalOrder:\n intervalList[elem[0]].append(elem[1])\n\n for i in range(cnt): # r - l\n for j in range(cnt - i): # l\n ans1 = 0 # is there [l,r]\n ans2 = 0 # max of [l+1,r] and [l,nr] + [nr + 1,r]\n if i != 0:\n ans2 = dp[j + 1][i + j]\n for elem in intervalList[j]:\n if elem == i + j:\n ans1 += 1\n elif elem < i + j and ans2 < dp[j][elem] + dp[elem + 1][i + j]:\n ans2 = dp[j][elem] + dp[elem + 1][i + j]\n dp[j][i+j] = ans1 + ans2\n \n print(dp[0][cnt - 1])", "import sys\nfor _ in range(int(input())):\n M = int(input())\n LR_raw = []\n val = set()\n for _ in range(M):\n l, r = list(map(int, input().split()))\n LR_raw.append((l, r))\n val.add(l)\n val.add(r)\n val = sorted(list(val))\n val2idx = {x: i for i, x in enumerate(val)}\n LR = []\n N = len(val)\n segment = [set() for _ in range(N)]\n for l_, r_ in LR_raw:\n l = val2idx[l_]\n r = val2idx[r_]\n LR.append((l, r))\n segment[l].add(r)\n \n dp = [[0] * N for _ in range(N)]\n for d in range(1, N+1):\n for l in range(N):\n r = l + d - 1\n if r < N:\n if l+1 <= r:\n dp[l][r] = dp[l+1][r]\n for rr in segment[l]:\n if rr >= r:\n continue\n dp[l][r] = max(dp[l][r], dp[l][rr] + dp[rr+1][r])\n if r in segment[l]:\n dp[l][r] += 1\n print(dp[0][-1])\n \n", "import sys\ndef rs(): return sys.stdin.readline().rstrip()\ndef ri(): return int(sys.stdin.readline())\ndef ria(): return list(map(int, sys.stdin.readline().split()))\ndef ws(s): sys.stdout.write(s); sys.stdout.write('\\n')\ndef wi(n): sys.stdout.write(str(n)); sys.stdout.write('\\n')\ndef wia(a, sep=' '): sys.stdout.write(sep.join([str(x) for x in a])); sys.stdout.write('\\n')\n\n\ndef solve(n, segs):\n vals = set()\n for l, r in segs:\n vals.add(l)\n vals.add(r)\n vals = sorted(list(vals))\n d = {x: i for i, x in enumerate(vals)}\n m = len(vals)\n\n c_segs = []\n r_segs = [[] for _ in range(m)]\n for l, r in segs:\n ll = d[l]\n rr = d[r]\n c_segs.append((ll, rr))\n r_segs[ll].append(rr)\n\n dp = [[0] * m for _ in range(m)]\n for ln in range(1, m + 1):\n for l in range(m):\n r = l + ln - 1\n if r >= m: continue\n if l + 1 <= r:\n dp[l][r] = dp[l + 1][r]\n for rr in r_segs[l]:\n if rr >= r:\n continue\n dp[l][r] = max(dp[l][r], dp[l][rr] + dp[rr + 1][r])\n if r in r_segs[l]:\n dp[l][r] += 1\n\n return dp[0][-1]\n\n\ndef main():\n for _ in range(ri()):\n n = ri()\n segs = []\n for i in range(n):\n l, r = ria()\n segs.append((l, r))\n wi(solve(n, segs))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "from bisect import bisect_left as lower\nimport sys\ninput = sys.stdin.readline\n\ndef put():\n return list(map(int, input().split()))\n\ndef func(size,seg):\n dp = [[0]*size for i in range(size)]\n for k in range(1, size+1):\n for l in range(size):\n r = l+k-1\n if r<size:\n if l+1<=r:\n dp[l][r] = dp[l+1][r]\n same = 0\n for i in seg[l]:\n if i==r:\n same=1\n if i<r:\n dp[l][r] = max(dp[l][r], dp[l][i]+ dp[i+1][r])\n dp[l][r]+=same\n return dp[0][-1]\n\n\ndef solve():\n t = int(input())\n for _ in range(t):\n n = int(input())\n l,r,m = [],[],set()\n for i in range(n):\n x,y = put()\n l.append(x);r.append(y)\n m.add(x);m.add(y)\n m = sorted(m)\n size = len(m)\n seg = [[] for i in range(size)]\n for i in range(n):\n l[i] = lower(m, l[i])\n r[i] = lower(m, r[i])\n seg[l[i]].append(r[i])\n print(func(size, seg))\n\nsolve()\n"]
{ "inputs": [ "4\n4\n1 5\n2 4\n2 3\n3 4\n5\n1 5\n2 3\n2 5\n3 5\n2 2\n3\n1 3\n2 4\n2 3\n7\n1 10\n2 8\n2 5\n3 4\n4 4\n6 8\n7 7\n", "1\n1\n1 200000\n", "1\n1\n100000 100001\n" ], "outputs": [ "3\n4\n2\n7\n", "1\n", "1\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
14,785
bff65cffd0fd7ee6a59a00536323aa9f
UNKNOWN
New Year is coming and you are excited to know how many minutes remain before the New Year. You know that currently the clock shows $h$ hours and $m$ minutes, where $0 \le hh < 24$ and $0 \le mm < 60$. We use 24-hour time format! Your task is to find the number of minutes before the New Year. You know that New Year comes when the clock shows $0$ hours and $0$ minutes. You have to answer $t$ independent test cases. -----Input----- The first line of the input contains one integer $t$ ($1 \le t \le 1439$) β€” the number of test cases. The following $t$ lines describe test cases. The $i$-th line contains the time as two integers $h$ and $m$ ($0 \le h < 24$, $0 \le m < 60$). It is guaranteed that this time is not a midnight, i.e. the following two conditions can't be met at the same time: $h=0$ and $m=0$. It is guaranteed that both $h$ and $m$ are given without leading zeros. -----Output----- For each test case, print the answer on it β€” the number of minutes before the New Year. -----Example----- Input 5 23 55 23 0 0 1 4 20 23 59 Output 5 60 1439 1180 1
["a = int(input())\nfor i in range(a):\n x, y = map(int, input().split())\n t = x * 60 + y\n print(24*60 - t)", "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 h, m = getVars()\n print(60*24 - h*60 - m)\n\n", "q = int(input())\nfor z in range(q):\n a, b = map(int, input().split())\n s = (23 - a) * 60 + (60 - b)\n print(s)", "n = int(input())\nfor i in range(n):\n a, b = map(int, input().split())\n print(24 * 60 - a * 60 - b)", "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\tj, m = list(map(int, input().split()))\n\tprint(60 * 24 - j * 60 - m)\n", "q=int(input())\nfor i in range(q):\n w,e=map(int,input().split())\n print((23-w)*60+60-e)", "#!/usr/bin/env python3\n# coding: utf-8\n# Last Modified: 28/Dec/19 10:36:05 PM\n\n\nimport sys\n\n\ndef main():\n x = 24 * 60\n for tc in range(int(input())):\n h, m = get_ints()\n y = h * 60 + m\n print(x - y)\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()", "for __ in range(int(input())):\n a, b = list(map(int, input().split()))\n print(24 * 60 - a * 60 - b)", "s = int(input())\nfor i in range(s):\n hh,mm = list(map(int, input().split()))\n ms = hh*60+mm\n print(24*60-ms)\n", "def ii(): return int(input())\ndef si(): return input()\ndef mi(): return map(int,input().split())\ndef li(): return list(mi()) \n\nimport math\n\n\nfor i in range(ii()):\n h,m=mi()\n ans=1440-(h*60+m)\n print(ans)", "for _ in range(int(input())):\n h, m = list(map(int,input().split()))\n print(1440 - (h*60 + m))", "#list(map(int, input().split()))\nfor _ in range(int(input())):\n\th, m = list(map(int, input().split()))\n\tprint(24 * 60 - h * 60 - m)", "t = int(input())\nfor i in range(t):\n\tn, s = list(map(int, input().split()))\n\tprint(24 * 60 - n * 60 - s)\n", "import sys\ninput = sys.stdin.readline\n\nt=int(input())\nfor test in range(t):\n h,w=list(map(int,input().split()))\n\n print(24*60-h*60-w)\n\n", "t = int(input())\nfor i in range(t):\n\thh = 23\n\tmm = 60\n\th, m = list(map(int, input().split()))\n\tprint((hh - h) * 60 + mm - m)\n", "for _ in range(int(input())):\n h, m = tuple(map(int, input().split()))\n print(1440 - h*60 - m)", "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\ta, b = mints()\n\tprint(24*60-a*60-b)\n\nfor i in range(mint()):\n\tsolve()\n", "\n\nfor _ in range(int(input())):\n\th,m=map(int,input().split())\n\n\th=60*h+m\n\n\tprint(1440-h)", "for nt in range(int(input())):\n\th,m=map(int,input().split())\n\tprint ((23-h)*60+(60-m))", "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 \n", "q = int(input())\nfor i in range(q):\n h, m = list(map(int, input().split()))\n print(24 * 60 - h * 60 - m)\n", "for i in range(int(input())):\n h, m = [int(a) for a in input().split()]\n print(24*60 - h*60 - m)\n", "from sys import stdin,stdout\nn=int(stdin.readline().strip())\nfor t in range(n):\n h,c=list(map(int,stdin.readline().strip().split()))\n ans=0\n if c!=0:\n ans+=60-c\n h+=1\n ans+=(24-h)*60\n print(ans)\n \n\n", "t = int(input())\nfor i in range(t):\n h, m = list(map(int, input().split()))\n print(24 * 60 - h * 60 - m)\n", "t = int(input())\n\nfor i in range(t):\n h , m = map(int , input().split())\n \n total = 24*60 - h*60 - m\n \n print(total)", "t = int(input())\n\nfor i in range(t):\n\ta, b = list(map(int, input().split()))\n\tans = (23 - a) * 60 + (60 - b)\n\tprint(ans)\n", "N = int(input())\n\n\nfor _ in range(N):\n\th, m = [int(x) for x in input().split()]\n\n\tprint(24*60- (h*60+m))"]
{ "inputs": [ "5\n23 55\n23 0\n0 1\n4 20\n23 59\n", "5\n23 55\n22 30\n21 10\n20 21\n19 59\n", "1\n1 2\n" ], "outputs": [ "5\n60\n1439\n1180\n1\n", "5\n90\n170\n219\n241\n", "1378\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
7,742
e1cd3c68cd33acd928eb7e57b2f952a5
UNKNOWN
There is a robot on a coordinate plane. Initially, the robot is located at the point $(0, 0)$. Its path is described as a string $s$ of length $n$ consisting of characters 'L', 'R', 'U', 'D'. Each of these characters corresponds to some move: 'L' (left): means that the robot moves from the point $(x, y)$ to the point $(x - 1, y)$; 'R' (right): means that the robot moves from the point $(x, y)$ to the point $(x + 1, y)$; 'U' (up): means that the robot moves from the point $(x, y)$ to the point $(x, y + 1)$; 'D' (down): means that the robot moves from the point $(x, y)$ to the point $(x, y - 1)$. The company that created this robot asked you to optimize the path of the robot somehow. To do this, you can remove any non-empty substring of the path. But this company doesn't want their customers to notice the change in the robot behavior. It means that if before the optimization the robot ended its path at the point $(x_e, y_e)$, then after optimization (i.e. removing some single substring from $s$) the robot also ends its path at the point $(x_e, y_e)$. This optimization is a low-budget project so you need to remove the shortest possible non-empty substring to optimize the robot's path such that the endpoint of his path doesn't change. It is possible that you can't optimize the path. Also, it is possible that after the optimization the target path is an empty string (i.e. deleted substring is the whole string $s$). Recall that the substring of $s$ is such string that can be obtained from $s$ by removing some amount of characters (possibly, zero) from the prefix and some amount of characters (possibly, zero) from the suffix. For example, the substrings of "LURLLR" are "LU", "LR", "LURLLR", "URL", but not "RR" and "UL". You have to answer $t$ independent test cases. -----Input----- The first line of the input contains one integer $t$ ($1 \le t \le 1000$) β€” the number of test cases. The next $2t$ lines describe test cases. Each test case is given on two lines. The first line of the test case contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) β€” the length of the robot's path. The second line of the test case contains one string $s$ consisting of $n$ characters 'L', 'R', 'U', 'D' β€” the robot's path. It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$). -----Output----- For each test case, print the answer on it. If you cannot remove such non-empty substring that the endpoint of the robot's path doesn't change, print -1. Otherwise, print two integers $l$ and $r$ such that $1 \le l \le r \le n$ β€” endpoints of the substring you remove. The value $r-l+1$ should be minimum possible. If there are several answers, print any of them. -----Example----- Input 4 4 LRUD 4 LURD 5 RRUDU 5 LLDDR Output 1 2 1 4 3 4 -1
["for _ in range(int(input())):\n n = int(input())\n s = input()\n balance = 0\n index = {0: 1}\n ans = [10**9]\n i = 1\n for x in s:\n if x == 'U':\n balance += 10 ** 9\n elif x == 'D':\n balance -= 10 ** 9\n elif x == 'L':\n balance += 1\n else:\n balance -= 1\n if balance in index:\n ans = min(ans, [i + 1 - index[balance], index[balance], i])\n index[balance] = i + 1\n i += 1\n if ans[0] == 10 ** 9:\n print(-1)\n else:\n print(ans[1], ans[2])\n", "from sys import stdin\ninput = stdin.readline\nq = int(input())\nN = 2342379478943\nfor rwwe in range(q):\n\tn = int(input())\n\ts = input()\n\tk = []\n\tfor i in range(n):\n\t\tif s[i] == \"L\":\n\t\t\tk.append(1)\n\t\tif s[i] == \"R\":\n\t\t\tk.append(-1)\n\t\tif s[i] == \"U\":\n\t\t\tk.append(N)\n\t\tif s[i] == \"D\":\n\t\t\tk.append(-N)\n\tpref = [0] * (n+1)\n\tfor i in range(1,n+1):\n\t\tpref[i] = pref[i-1] + k[i-1]\n\t#print(pref)############\n\td = {}\n\tfor i in pref:\n\t\td[i] = []\n\tfor i in range(len(pref)):\n\t\td[pref[i]].append(i)\n\tbest = 10000000000\n\todp = [\"a\",\"a\"]\n\t#print(d)##########\n\tfor i in d:\n\t\tif len(d[i]) < 2:\n\t\t\tcontinue\n\t\telse:\n\t\t\tfor j in range(1,len(d[i])):\n\t\t\t\tif d[i][j]-d[i][j-1] < best:\n\t\t\t\t\tbest = d[i][j]-d[i][j-1]\n\t\t\t\t\todp = [d[i][j-1]+1,d[i][j]]\n\tif odp != [\"a\",\"a\"]:\n\t\tprint(*odp)\n\telse:\n\t\tprint(-1)\n", "import sys\ninput = sys.stdin.readline\nfrom collections import defaultdict\n\nt=int(input())\nfor tests in range(t):\n n=int(input())\n S=input().strip()\n\n ANS=1<<31\n D=defaultdict(list)\n\n NOW=[0,0]\n TIME=0\n D[tuple(NOW)].append(TIME)\n TIME+=1\n\n for s in S:\n if s==\"U\":\n NOW[0]+=1\n elif s==\"D\":\n NOW[0]-=1\n elif s==\"R\":\n NOW[1]+=1\n else:\n NOW[1]-=1\n\n D[tuple(NOW)].append(TIME)\n TIME+=1\n\n if len(D[tuple(NOW)])>1 and ANS>D[tuple(NOW)][-1]-D[tuple(NOW)][-2]:\n ANS=D[tuple(NOW)][-1]-D[tuple(NOW)][-2]\n ANSX=(D[tuple(NOW)][-2]+1,D[tuple(NOW)][-1])\n\n if ANS==1<<31:\n print(-1)\n else:\n print(*ANSX)\n \n \n \n \n\n \n \n", "t = int(input())\nfor _ in range(t):\n\tn = int(input())\n\ts = input()\n\n\tposition_to_step = {(0, 0): 0}\n\tlen_of_min = n+1\n\tans = (0, 0)\n\tpos = (0, 0)\n\n\tfor i in range(n):\n\t\titem = s[i]\n\t\tif item == \"U\":\n\t\t\tpos = (pos[0], pos[1]+1)\n\t\telif item == \"D\":\n\t\t\tpos = (pos[0], pos[1]-1)\n\t\tif item == \"R\":\n\t\t\tpos = (pos[0]+1, pos[1])\n\t\tif item == \"L\":\n\t\t\tpos = (pos[0]-1, pos[1])\n\n\t\tif pos in position_to_step:\n\t\t\tif i - position_to_step[pos] < len_of_min:\n\t\t\t\tlen_of_min = i - position_to_step[pos]\n\t\t\t\tans = position_to_step[pos], i\n\n\t\tposition_to_step[pos] = i+1\n\n\tif ans[0] == ans[1]:\n\t\tprint(-1)\n\telse:\n\t\tprint(ans[0]+1, ans[1]+1)\n", "import sys\n\n# inf = open('input.txt', 'r')\n# reader = (line.rstrip() for line in inf)\nreader = (line.rstrip() for line in sys.stdin)\ninput = reader.__next__\n\nt = int(input())\nfor _ in range(t):\n n = int(input())\n coms = list(input())\n pos = {(0, 0):-1}\n x = y = 0\n l = -1\n r = float('inf')\n for i, d in enumerate(coms):\n if d == 'L':\n x -= 1\n elif d == 'R':\n x += 1\n elif d == 'U':\n y += 1\n else:\n y -= 1\n \n if (x, y) in pos:\n prev = pos[(x, y)]\n if i - prev < r - l:\n r, l = i, prev\n pos[(x, y)] = i\n \n if r == float('inf'):\n print(-1)\n else:\n print(l + 2, r + 1)\n\n# inf.close()\n", "for _ in range(int(input())):\n n = int(input())\n ar = list(input())\n left, right = 0, 0\n kek = [[0, 0, 0]]\n for i in range(n):\n elem = ar[i]\n if elem == 'L':\n left -= 1\n elif elem == 'R':\n left += 1\n elif elem == 'U':\n right += 1\n else:\n right -= 1\n kek.append([left, right, i + 1])\n kek.sort()\n ans = 10 ** 9\n a, b = -1, -1\n for i in range(n + 1):\n if kek[i][0] == kek[i - 1][0] and kek[i][1] == kek[i - 1][1] and kek[i][2] - kek[i - 1][2] < ans:\n ans = kek[i][2] - kek[i - 1][2]\n a, b = kek[i - 1][2] + 1, kek[i][2]\n if a == b == -1:\n print(-1)\n else:\n print(a, b)", "from collections import Counter\nt = int(input())\ninf = 10**18\nfor _ in range(t):\n n = int(input())\n s = input()\n ans = [inf, 0, 0]\n cnt = Counter({(0, 0): 1})\n x, y = 0, 0\n\n for i, c in enumerate(s, start=1):\n if c == 'L':\n x -= 1\n elif c == 'R':\n x += 1\n elif c == 'U':\n y -= 1\n else:\n y += 1\n if (x, y) in cnt and i - cnt[(x, y)] < ans[0]:\n ans[0] = i - cnt[(x, y)]\n ans[1], ans[2] = cnt[(x, y)], i\n cnt[(x, y)] = i+1\n\n if ans[0] < inf:\n print(ans[1], ans[2])\n else:\n print(-1)\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\n\n\nt = getInt()\nfor _ in range(t):\n n = getInt()\n s = getStr()\n d = {}\n d['0/0'] = 0\n x = 0\n y = 0\n res = [0, n+1]\n for i in range(n):\n if s[i] == 'L':\n x -= 1\n if s[i] == 'R':\n x += 1\n if s[i] == 'U':\n y += 1\n if s[i] == 'D':\n y -= 1\n k = str(x) + '/' + str(y)\n if k not in d:\n d[k] = i+1\n else:\n if i+1 - d[k] < res[1] - res[0]:\n res = [d[k]+1, i+1]\n d[k] = i+1\n if res[1] == n+1:\n print(-1)\n else:\n print(*res)\n \n", "\n\n\n\n\n\n\n\nimport sys\ninput=sys.stdin.readline\n\nt=int(input())\nfor _ in range(t):\n n=int(input())\n it=list(input())\n ss={}\n x=0\n y=0\n ss[(0,0)]=-1\n mi=n+1\n ans=[]\n for i in range(n):\n if it[i]==\"L\":\n x-=1\n elif it[i]==\"R\":\n x+=1\n elif it[i]==\"U\":\n y+=1\n else:\n y-=1\n # if x==0 and y==0:\n # print(_)\n # print(x,y)\n try:\n xx=ss[(x,y)]\n if i+1-xx-2+1<mi:\n mi=i+1-xx-2+1\n ans=[xx+2,i+1]\n except:\n pass\n ss[(x,y)]=i\n if ans==[]:\n print(-1)\n continue\n print(*ans)\n", "\nt = int(input())\n\nfor loop in range(t):\n\n n = int(input())\n\n s = input()\n\n x = 0\n y = 0\n\n dic = {}\n dic[(0,0)] = -1\n\n ansl = float(\"-inf\")\n ansr = float(\"inf\")\n\n for i,S in enumerate(s):\n\n if S == \"L\":\n x -= 1\n elif S == \"R\":\n x += 1\n elif S == \"U\":\n y += 1\n elif S == \"D\":\n y -= 1\n\n if (x,y) in dic:\n nowl = dic[(x,y)]\n nowr = i\n\n if nowr - nowl < ansr - ansl:\n ansl = nowl\n ansr = nowr\n \n dic[(x,y)] = i\n\n if ansr == float(\"inf\"):\n print(-1)\n else:\n print(ansl+2,ansr+1)\n \n", "t = int(input())\nfor y in range(t):\n\tn = int(input())\n\ts = input()\n\tpre = [0 for i in range(n+1)]\n\tfor i in range(n):\n\t\tif(s[i] == 'L'): pre[i+1] = pre[i]+1\n\t\telif(s[i] == 'R'): pre[i+1] = pre[i]-1\n\t\telif(s[i] == 'U'): pre[i+1] = pre[i]+int(1e6)\n\t\telse: pre[i+1] = pre[i]-int(1e6)\n\t#print(pre)\n\td = dict()\n\tans = -1\n\tl = r = -1\n\tfor i in range(n+1):\n\t\tif pre[i] not in d:\n\t\t\td[pre[i]] = i\n\t\telse:\n\t\t\tif ans == -1 or i - d[pre[i]] < ans:\n\t\t\t\tans = i - d[pre[i]]\n\t\t\t\tl = d[pre[i]]+1\n\t\t\t\tr = i\n\t\t\td[pre[i]] = i\n\tif(ans == -1): print(ans)\n\telse: print(l,r)\n", "def one():\n return int(input())\n\n\ndef two():\n return list(map(int, input().split()))\n\n\ndef lis():\n return list(map(int, input().split()))\n\n\ndef st():\n return input()\n\n\nfor i in range(one()):\n input()\n d = {(0, 0): 0}\n s = st()\n c = [0, 0]\n r = 0\n m = float('inf')\n ans = None\n for j in s:\n if j == 'U':\n c[1] += 1\n if j == 'D':\n c[1] -= 1\n if j == 'R':\n c[0] += 1\n if j == 'L':\n c[0] -= 1\n r += 1\n if (c[0], c[1]) in d:\n if m > r - d[(c[0], c[1])] + 1:\n ans = (d[(c[0], c[1])] + 1, r)\n m = r - d[(c[0], c[1])] + 1\n d[(c[0], c[1])] = r\n else:\n d[(c[0], c[1])] = r\n if not ans:\n print(-1)\n else:\n print(*ans)\n", "from collections import defaultdict\nimport sys\ninput = sys.stdin.readline\ndef case():\n n = int(input())\n s = input().strip()\n t = 1\n x, y = 0, 0\n d = defaultdict(list)\n d[(0, 0)].append(0)\n anslen = 10**10\n ans = []\n for i in s:\n if i == 'L':\n x-=1\n elif i == 'R':\n x+=1\n elif i == 'D':\n y-=1\n elif i == 'U':\n y+=1\n if d[(x, y)] != []:\n if t-d[(x, y)][-1] < anslen:\n anslen = t-d[(x, y)][-1]\n ans = [d[(x, y)][-1], t]\n d[(x, y)].append(t)\n t+=1\n if anslen == 10**10:\n print(-1)\n else:\n print(ans[0]+1, ans[1])\nfor _ in range(int(input())):\n case()", "import sys\ninput = sys.stdin.readline\n\ndx = [-1, 1, 0, 0]\ndy = [0, 0, 1, -1]\nR = {'L' : 0, 'R' : 1, 'U' : 2, 'D' : 3}\n\nT = int(input())\n\nfor _ in range(T):\n x = y = 0\n N = int(input())\n Path = input().rstrip()\n\n vst = {(0, 0) : 0}\n ans = []\n for i in range(N):\n #print(x, y)\n r = R[Path[i]]\n x += dx[r]\n y += dy[r]\n if (x, y) in vst:\n w = i - vst[(x, y)]\n ans.append((w, vst[(x, y)] + 1, i + 1))\n\n vst[(x, y)] = i + 1\n ans.sort()\n\n if ans:\n print(ans[0][1], ans[0][2])\n else:\n print(-1)\n\n\n", "for _ in range(int(input())):\n n = int(input())\n s = list(input())\n d1 = {}\n d1[(0, 0)] = [0]\n x, y = 0, 0\n i = 1\n for c in s:\n if c ==\"L\":\n x-=1\n if c==\"R\":\n x+=1\n if c==\"U\":\n y+=1\n if c==\"D\":\n y-=1\n if (x,y) in d1:\n d1[(x, y)].append(i)\n else :\n d1[(x,y)] = [i]\n i+=1\n answer = -1\n answer_coord = [0, 0]\n for x in d1:\n if len(d1[x]) > 1:\n d1[x].sort()\n for i in range(len(d1[x]) - 1):\n if answer == -1:\n answer = d1[x][i+1] - d1[x][i]\n answer_coord = [d1[x][i+1], d1[x][i]]\n elif d1[x][i+1] - d1[x][i] < answer:\n answer = d1[x][i+1] - d1[x][i]\n answer_coord = [d1[x][i+1], d1[x][i]]\n a = answer_coord[1]\n b = answer_coord[0]\n if answer!=-1:\n print(a + 1, b)\n else :\n print(-1)", "for i in range(int(input())):\n\tn = int(input())\n\ts = input()\n\td = {}\n\tx = 0\n\ty = 0\n\td[(x,y)] = [0]\n\tm1 = -1\n\tm2 = -1\n\tc = 0\n\tfor i in s:\n\t\tc+=1\n\t\tif(i==\"L\"):\n\t\t\tx-=1\n\t\telif(i==\"R\"):\n\t\t\tx+=1\n\t\telif(i==\"U\"):\n\t\t\ty+=1\n\t\telse:\n\t\t\ty-=1\n\t\ttry:\n\t\t\td[(x, y)].append(c)\n\t\t\tif(m1==-1):\n\t\t\t\tm2 = d[(x, y)][-1]\n\t\t\t\tm1 = d[(x, y)][-2]\n\t\t\tif(d[(x, y)][-1] - d[(x, y)][-2])<(m2 - m1):\n\t\t\t\tm2 = d[(x, y)][-1]\n\t\t\t\tm1 = d[(x, y)][-2]\n\t\texcept:\n\t\t\td[(x,y)] = [c]\n\t#print(d)\n\tif(m1!=-1):\n\t\tprint(str(m1+1)+\" \"+str(m2))\n\telse:\n\t\tprint(-1)", "t = int(input())\n\nwhile t:\n t -= 1\n n = int(input())\n s = list(input())\n a = [(-1 if s[i] == 'L' else (1 if s[i] == 'R' else 0)) for i in range(n)]\n b = [(-1 if s[i] == 'D' else (1 if s[i] == 'U' else 0)) for i in range(n)]\n suma = [a[0] for _ in range(n)]\n sumb = [b[0] for _ in range(n)]\n d = dict()\n d[(0, 0)] = -1\n for i in range(1, n):\n suma[i] = suma[i - 1] + a[i]\n sumb[i] = sumb[i - 1] + b[i]\n res = n + 1\n _res = -1\n for i in range(n):\n #print(suma[i], sumb[i])\n if (suma[i], sumb[i]) in d.keys():\n if res > i - d[(suma[i], sumb[i])]:\n res = i - d[(suma[i], sumb[i])]\n _res = (d[(suma[i], sumb[i])], i)\n d[(suma[i], sumb[i])] = i\n if (_res == -1):\n print(_res)\n else:\n print(_res[0] + 2, _res[1] + 1) "]
{ "inputs": [ "4\n4\nLRUD\n4\nLURD\n5\nRRUDU\n5\nLLDDR\n", "1\n10\nRULLDRRULD\n", "1\n23\nRUURRDDLLUUURRRDDDLLLUD\n" ], "outputs": [ "1 2\n1 4\n3 4\n-1\n", "7 10\n", "22 23\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
13,133
f76f44929ef72360283b371053236157
UNKNOWN
You have $n$ students under your control and you have to compose exactly two teams consisting of some subset of your students. Each student had his own skill, the $i$-th student skill is denoted by an integer $a_i$ (different students can have the same skills). So, about the teams. Firstly, these two teams should have the same size. Two more constraints: The first team should consist of students with distinct skills (i.e. all skills in the first team are unique). The second team should consist of students with the same skills (i.e. all skills in the second team are equal). Note that it is permissible that some student of the first team has the same skill as a student of the second team. Consider some examples (skills are given): $[1, 2, 3]$, $[4, 4]$ is not a good pair of teams because sizes should be the same; $[1, 1, 2]$, $[3, 3, 3]$ is not a good pair of teams because the first team should not contain students with the same skills; $[1, 2, 3]$, $[3, 4, 4]$ is not a good pair of teams because the second team should contain students with the same skills; $[1, 2, 3]$, $[3, 3, 3]$ is a good pair of teams; $[5]$, $[6]$ is a good pair of teams. Your task is to find the maximum possible size $x$ for which it is possible to compose a valid pair of teams, where each team size is $x$ (skills in the first team needed to be unique, skills in the second team should be the same between them). A student cannot be part of more than one team. You have to answer $t$ independent test cases. -----Input----- The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) β€” 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 2 \cdot 10^5$) β€” the number of students. The second line of the test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$), where $a_i$ is the skill of the $i$-th student. Different students can have the same skills. It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$). -----Output----- For each test case, print the answer β€” the maximum possible size $x$ for which it is possible to compose a valid pair of teams, where each team size is $x$. -----Example----- Input 4 7 4 2 4 1 4 3 4 5 2 1 5 4 3 1 1 4 1 1 1 3 Output 3 1 0 2 -----Note----- In the first test case of the example, it is possible to construct two teams of size $3$: the first team is $[1, 2, 4]$ and the second team is $[4, 4, 4]$. Note, that there are some other ways to construct two valid teams of size $3$.
["from collections import defaultdict as dd\nfor _ in range(int(input())):\n n=int(input())\n a=list(map(int,input().split()))\n d=dd(int)\n for i in a:\n d[i]+=1\n ma=0\n r=len(d.keys())\n for i in d.keys():\n ma=max(ma,min(d[i]-1,r),min(d[i],r-1))\n print(ma)", "#!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 = I()\n a = LI()\n x = len(set(a))\n d = defaultdict(lambda : 0)\n for i in a:\n d[i] += 1\n y = max(d.values())\n if x < y:\n print(x)\n elif x == y:\n print(x-1)\n else:\n print(y)\n return\n\n#Solve\ndef __starting_point():\n solve()\n\n__starting_point()", "t = int(input())\nfor i in range(t):\n\tn = int(input())\n\tl = list(map(int,input().split()))\n\td = {}\n\tfor i in l:\n\t\td[i] = 0\n\tfor i in l:\n\t\td[i] += 1\n\tmyk = len(d)\n\tmaksik = 0\n\tdupa = -12131\n\tfor i in l:\n\t\tif d[i] > maksik:\n\t\t\tmaksik = min(d[i],myk-1)\n\t\tif d[i] > myk:\n\t\t\tdupa = myk\n\tprint(max(maksik,dupa))", "from collections import Counter\n\nfor _ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n\n c = sorted(Counter(a).values())\n\n maxi = 0\n\n for i in range(len(c)):\n maxi = max(maxi, min(c[i], i), min(c[i] - 1, i + 1))\n\n print(maxi)", "from operator import itemgetter\nimport sys\ninput = sys.stdin.readline\n\n\ndef compress(string):\n string.append(\"#\")\n n = len(string)\n begin, end, cnt = 0, 1, 1\n ans = []\n while end < n:\n if string[begin] == string[end]:\n end, cnt = end + 1, cnt + 1\n else:\n ans.append((string[begin], cnt))\n begin, end, cnt = end, end + 1, 1\n return ans\n\n\nt = int(input())\nfor _ in range(t):\n n = int(input())\n a = list(map(int, input().split()))\n a = sorted(a)\n comp = compress(a)\n comp = sorted(comp, key=itemgetter(1))\n same_max = comp[-1][-1]\n kind_max = len(comp)\n if same_max == kind_max:\n print(same_max - 1)\n else:\n print(min(same_max, kind_max))\n", "'''\n4\n7\n4 2 4 1 4 3 4\n5\n2 1 5 4 3\n1\n1\n4\n1 1 1 3\n'''\nfrom collections import Counter as c\nfor _ in range(int(input())):\n n = int(input())\n a = list(map(int, input().split()))\n a.sort()\n t = c(a)\n l = [[t[a], a] for a in t]\n l.sort(reverse=True)\n b = l[0][0]\n a = len(l)-1\n print (max(min(a,b), min(a+1,b-1)))", "import sys\n\n_INPUT_LINES = sys.stdin.read().splitlines()\ninput = iter(_INPUT_LINES).__next__\n\nfrom collections import Counter\n\ndef go():\n n = int(input())\n # n,a,b = map(int, input().split())\n a = list(map(int, input().split()))\n c = Counter(a)\n m = len(c)\n best=-1\n for cnt in list(c.values()):\n best = max(best,min(cnt,m-1))\n best = max(best,min(cnt-1,m))\n\n return best\n\n# x,s = map(int,input().split())\nt = int(input())\n# t = 1\nans = []\nfor _ in range(t):\n # print(go())\n ans.append(str(go()))\n#\nprint('\\n'.join(ans))\n", "from math import *\nfrom collections import *\nt = int(input())\nfor y in range(t):\n\tn = int(input())\n\ta = list(map(int,input().split()))\n\td = Counter(a)\n\tdiff = len(d)\n\tsame = 0\n\tfor i in d.values():\n\t\tsame = max(i,same)\n\tif(diff < same):\n\t\tprint(diff)\n\telif(diff == same):\n\t\tprint(diff-1)\n\telse:\n\t\tprint(same)", "t=int(input())\nwhile t:\n n=int(input())\n a=list(map(int,input().split()))\n ls=[0 for i in range(n+1)]\n for i in range(n):\n ls[a[i]]+=1\n dis=len(set(a))\n sam=max(ls)\n print(max(min(dis-1,sam),min(dis,sam-1)))\n t-=1 ", "t = int(input())\nfor q in range(0, t):\n n = int(input())\n a = list(map(int, input().split()))\n a.sort()\n number = 1\n for i in range(0, n - 1):\n if a[i] != a[i + 1]:\n number += 1\n mn = 0\n now = 1\n for i in range(0, n - 1):\n if a[i] == a[i + 1]:\n now += 1\n else:\n mn = max(mn, now)\n now = 1\n mn = max(mn, now)\n print(max(min(number - 1, mn), min(number, mn - 1)))\n", "import sys\ninput = sys.stdin.readline\nfrom collections import Counter\n\nt=int(input())\nfor tests in range(t):\n n=int(input())\n C=Counter(list(map(int,input().split())))\n\n LEN=len(C)\n MAX=max(C.values())\n\n if MAX<LEN:\n print(MAX)\n elif MAX==LEN:\n print(MAX-1)\n else:\n print(LEN)\n \n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n skills = map(int, input().split())\n d = {}\n for s in skills:\n if s in d:\n d[s] += 1\n else:\n d[s] = 1\n\n m = 0\n for k in d.keys():\n m = max(m, max(min(d[k], len(d) - 1), min(d[k] - 1, len(d))))\n print(m)", "t = int(input(''))\nfor _ in range(t):\n n = int(input(''))\n a = list(map(int,input('').split(' ')))\n d = {}\n for i in range(n):\n if(a[i] not in d):\n d[a[i]] = 0\n d[a[i]] = d[a[i]]+1\n mx = 0\n l = len(d)\n for k in d:\n if(min(d[k],l-1) > mx):\n mx = min(d[k],l-1)\n if(min(d[k]-1,l) > mx):\n mx = min(d[k]-1,l)\n print(mx)"]
{ "inputs": [ "4\n7\n4 2 4 1 4 3 4\n5\n2 1 5 4 3\n1\n1\n4\n1 1 1 3\n", "1\n9\n1 2 2 3 3 9 9 9 9\n", "5\n1\n1\n1\n1\n1\n1\n1\n1\n1\n1\n" ], "outputs": [ "3\n1\n0\n2\n", "3\n", "0\n0\n0\n0\n0\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
6,042
f4264969b3998b189acd8fcd82615215
UNKNOWN
You are given an array $a$ consisting of $n$ positive integers. Initially, you have an integer $x = 0$. During one move, you can do one of the following two operations: Choose exactly one $i$ from $1$ to $n$ and increase $a_i$ by $x$ ($a_i := a_i + x$), then increase $x$ by $1$ ($x := x + 1$). Just increase $x$ by $1$ ($x := x + 1$). The first operation can be applied no more than once to each $i$ from $1$ to $n$. Your task is to find the minimum number of moves required to obtain such an array that each its element is divisible by $k$ (the value $k$ is given). 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 first line of the test case contains two integers $n$ and $k$ ($1 \le n \le 2 \cdot 10^5; 1 \le k \le 10^9$) β€” the length of $a$ and the required divisior. The second line of the test case 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$ does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$). -----Output----- For each test case, print the answer β€” the minimum number of moves required to obtain such an array that each its element is divisible by $k$. -----Example----- Input 5 4 3 1 2 1 3 10 6 8 7 1 8 3 7 5 10 8 9 5 10 20 100 50 20 100500 10 25 24 24 24 24 24 24 24 24 24 24 8 8 1 2 3 4 5 6 7 8 Output 6 18 0 227 8 -----Note----- Consider the first test case of the example: $x=0$, $a = [1, 2, 1, 3]$. Just increase $x$; $x=1$, $a = [1, 2, 1, 3]$. Add $x$ to the second element and increase $x$; $x=2$, $a = [1, 3, 1, 3]$. Add $x$ to the third element and increase $x$; $x=3$, $a = [1, 3, 3, 3]$. Add $x$ to the fourth element and increase $x$; $x=4$, $a = [1, 3, 3, 6]$. Just increase $x$; $x=5$, $a = [1, 3, 3, 6]$. Add $x$ to the first element and increase $x$; $x=6$, $a = [6, 3, 3, 6]$. We obtained the required array. Note that you can't add $x$ to the same element more than once.
["t = int(input())\nfor _ in range(t):\n n, k = list(map(int, input().split()))\n l = list(map(int, input().split()))\n \n d = dict()\n d[0] = 0\n for v in l:\n vv = (k - v) % k\n if vv:\n if vv not in d:\n d[vv] = vv + 1\n else:\n d[vv] += k\n print(max(d.values()))\n\n", "t = int(input())\nfor _ in range(t):\n\tn, k = map(int, input().split())\n\ta = list(map(int, input().split()))\n\tb = [(k-a[i]%k)%k for i in range(n)]\n\tmx = {}\n\tmx[0] = -1\n\tfor x in b:\n\t\tif x == 0:\n\t\t\tcontinue\n\t\tif x not in mx:\n\t\t\tmx[x] = x\n\t\telse:\n\t\t\tmx[x] += k\n\n\tprint(max(mx.values())+1)", "import sys\ninput = sys.stdin.readline\nfrom collections import Counter\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\n B=[(k-a)%k for a in A]\n C=Counter(B)\n\n MAX=1\n IND=-1\n\n for c in C:\n if c==0:\n continue\n if MAX<C[c]:\n MAX=C[c]\n IND=c\n elif MAX==C[c] and IND<c:\n IND=c\n\n #print(MAX,IND)\n print(IND+1+(MAX-1)*k)\n\n \n \n", "import math\nt = int(input())\nfor _ in range(t):\n n, k = [int(i) for i in input().split()]\n a = [int(i) for i in input().split()]\n ma = -1\n d = {}\n for i in a:\n if i%k == 0:\n continue\n r = i%k\n r = k - r\n if r not in d:\n d[r] = 0\n d[r] += 1\n ma = max(ma, r + ((d[r]-1)*k))\n print(ma + 1)\n", "t=int(input())\nfor you in range(t):\n l=input().split()\n n=int(l[0])\n k=int(l[1])\n hashi=dict()\n l=input().split()\n li=[int(i) for i in l]\n maxa=[]\n for i in li:\n if(i%k):\n z=k-(i%k)\n if(z in hashi):\n hashi[z]+=1\n else:\n hashi[z]=1\n for i in hashi:\n maxa.append((hashi[i]-1)*k+i)\n if(maxa==[]):\n print(0)\n continue\n print(max(maxa)+1)\n", "t = int(input())\nfrom collections import Counter\n\nfor case in range(t):\n n, k = list(map(int, input().split()))\n a = [int(x) for x in input().split()]\n w = Counter(x % k for x in a)\n v = 0\n for x, freq in list(w.items()):\n if x == 0: continue\n if freq == 0: continue\n \n r = (-x) % k\n v = max(v, r + (freq-1)*k+1)\n\n print(v)\n", "from collections import deque\nimport sys\ndef inp():\n return sys.stdin.readline().strip()\nfor _ in range(int(inp())):\n n,k=list(map(int,inp().split()))\n a=list(map(int,inp().split()))\n d={}\n f=0\n mx=-1\n for i in a:\n if i%k==0:\n continue\n if i%k not in d:\n d[i%k]=0\n d[i%k]+=1\n if f<d[i%k]:\n f=d[i%k]\n mx=i%k \n elif f==d[i%k]:\n mx=min(mx,i%k)\n if mx==-1:\n print(0)\n continue\n print((f-1)*k+(k-mx)+1)\n", "for nt in range(int(input())):\n\tn,k = list(map(int,input().split()))\n\tnew = list(map(int,input().split()))\n\ta = []\n\tfor i in range(n):\n\t\tif new[i]%k!=0:\n\t\t\ta.append(new[i])\n\ta.sort()\n\tn = len(a)\n\tif n==0:\n\t\tprint(0)\n\t\tcontinue\n\td = {}\n\tmaxx = 0\n\tfor i in range(n):\n\t\tdiff = k - (a[i]%k)\n\t\tif diff not in d:\n\t\t\tmaxx = max(maxx,diff)\n\t\t\td[diff] = 1\n\t\telse:\n\t\t\tmaxx = max(maxx,d[diff]*k+diff)\n\t\t\td[diff] += 1\n\tprint(maxx+1)\n", "import collections\nt = int(input())\nfor _ in range(t):\n n, k = list(map(int, input().split()))\n a = list(map(int, input().split()))\n x = 0\n\n D = [k - a[i] % k for i in range(n) if a[i] % k]\n D.sort(reverse=True)\n ans = 0\n if len(D):\n C = collections.Counter(D).most_common()\n # print(C)\n ans = (C[0][1]-1)*k + C[0][0] + 1\n\n print(ans)\n", "def solve():\n n, k = list(map(int, input().split()))\n a = [int(x) for x in input().split()]\n used = {}\n ans = 0\n for i in a:\n if i % k != 0:\n if (i % k) in used:\n ans = max(ans, k * (used[i % k] + 1) - (i % k))\n used[i % k] += 1\n else:\n ans = max(ans, k - (i % k))\n used[i % k] = 1\n print(ans if ans == 0 else ans + 1)\n\n\n[solve() for i in range(int(input()))]\n", "for test_i in range(int(input())):\n n, k = map(int, input().split())\n arr = list(map(lambda el: (k - int(el) % k) % k, input().split()))\n rems = {}\n for el in arr:\n if el:\n if el in rems:\n rems[el] += 1\n else:\n rems[el] = 1\n if rems:\n max_rem_item = max([(item[1], item[0]) for item in rems.items()])\n print(k * (max_rem_item[0] - 1) + max_rem_item[1] + 1)\n else:\n print(0)", "def solve():\n n, k = list(map(int, input().split()))\n a = [int(x) for x in input().split()]\n used = {}\n ans = 0\n for i in a:\n if i % k != 0:\n if (i % k) in used:\n ans = max(ans, k * (used[i % k] + 1) - (i % k) + 1)\n used[i % k] += 1\n else:\n ans = max(ans, k - (i % k) + 1)\n used[i % k] = 1\n print(ans)\n\n\n[solve() for i in range(int(input()))]\n", "import collections\n\nt=int(input())\nfor _ in range(t):\n n,k=map(int,input().split())\n arr=list(map(int,input().split()))\n for i in range(n):\n arr[i]%=k\n cnt=collections.Counter(arr)\n ans=0\n for key in cnt.keys():\n if key==0:\n continue\n tmp=(k-key)%k+k*(cnt[key]-1)\n ans=max(ans,tmp+1)\n print(ans)", "import sys, math,os\nfrom io import BytesIO, IOBase\n#data = BytesIO(os.read(0,os.fstat(0).st_size)).readline\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\n# from decimal import Decimal\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')\n#sys.setrecursionlimit(100000 + 1)\nINF = 10**9\nmod = 998244353\n\nfor t in range(int(data())):\n n,k=mdata()\n a=mdata()\n d=dd(int)\n for i in range(n):\n if a[i]%k==0:\n continue\n d[k-a[i]%k]+=1\n m=0\n for i in d:\n m=max(m,i+k*(d[i]-1))\n if m==0:\n out(0)\n else:\n out(m+1)"]
{ "inputs": [ "5\n4 3\n1 2 1 3\n10 6\n8 7 1 8 3 7 5 10 8 9\n5 10\n20 100 50 20 100500\n10 25\n24 24 24 24 24 24 24 24 24 24\n8 8\n1 2 3 4 5 6 7 8\n", "1\n1 1000000000\n99999999\n", "1\n5 3\n20 100 50 20 1005002\n" ], "outputs": [ "6\n18\n0\n227\n8\n", "900000002\n", "11\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
6,770
1cdba08b4f5aaf06e46cb52e2a6dae55
UNKNOWN
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cookie that the child will be content with; and each cookie j has a size sj. If sj >= gi, we can assign the cookie j to the child i, and the child i will be content. Your goal is to maximize the number of your content children and output the maximum number. Note: You may assume the greed factor is always positive. You cannot assign more than one cookie to one child. Example 1: Input: [1,2,3], [1,1] Output: 1 Explanation: You have 3 children and 2 cookies. The greed factors of 3 children are 1, 2, 3. And even though you have 2 cookies, since their size is both 1, you could only make the child whose greed factor is 1 content. You need to output 1. Example 2: Input: [1,2], [1,2,3] Output: 2 Explanation: You have 2 children and 3 cookies. The greed factors of 2 children are 1, 2. You have 3 cookies and their sizes are big enough to gratify all of the children, You need to output 2.
["class Solution:\n def findContentChildren(self, g, s):\n \"\"\"\n :type g: List[int]\n :type s: List[int]\n :rtype: int\n \"\"\"\n res = 0\n heapq.heapify(g)\n s.sort()\n for num in s:\n if not g:\n break\n elif g[0] <= num:\n res += 1\n heapq.heappop(g)\n return res", "class Solution:\n def findContentChildren(self, g, s):\n \"\"\"\n :type g: List[int]\n :type s: List[int]\n :rtype: int\n \"\"\"\n g.sort()\n s.sort()\n res = 0 \n Lg,Ls = len(g),len(s)\n i=j=0 \n while i<Lg and j<Ls:\n if s[j] >= g[i]:\n res += 1\n j += 1\n i += 1\n else:\n j += 1\n return res\n", "class Solution:\n def findContentChildren(self, g, s):\n \"\"\"\n :type g: List[int]\n :type s: List[int]\n :rtype: int\n \"\"\"\n g.sort()\n s.sort()\n i,j = 0,0\n happyKids = 0\n while i < len(g) and j < len(s):\n if s[j] >= g[i]:\n happyKids += 1\n i += 1\n j += 1\n return happyKids\n \n", "class Solution:\n def findContentChildren(self, g, s):\n \"\"\"\n :type g: List[int]\n :type s: List[int]\n :rtype: int\n \"\"\"\n g.sort(), s.sort()\n count = 0\n i = 0\n while count < len(g) and i < len(s):\n if s[i] >= g[count]:\n count += 1\n i+=1\n return count\n \n \n \n \n", "class Solution:\n def findContentChildren(self, g, s):\n \"\"\"\n :type g: List[int]\n :type s: List[int]\n :rtype: int\n \"\"\"\n g = sorted(g)\n s = sorted(s)\n result = 0\n i = 0\n j = 0\n while i<len(g) and j< len(s):\n if g[i]<= s[j]:\n result = result + 1\n i = i+1\n j = j+1\n else:\n j = j+1\n return result\n \n \n", "class Solution:\n # def findContentChildren(self, g, s):\n # \"\"\"\n # :type g: List[int]\n # :type s: List[int]\n # :rtype: int\n # \"\"\"\n # total = 1\n # child_to_give = []\n # child_index = 0\n # s.sort()\n # g.sort()\n # for cookie in s:\n # for child_greed in g:\n # print(\"child_greed \" + str(child_greed))\n # print(\"cookie \" + str(cookie))\n # if child_greed <= cookie:\n # if child_index not in child_to_give:\n # child_to_give.append(child_index)\n # g.remove(child_greed) \n \n # child_index += 1 \n \n # return len(child_to_give)\n \n def findContentChildren(self, g, s):\n \"\"\"\n :type g: List[int]\n :type s: List[int]\n :rtype: int\n \"\"\"\n s.sort()\n g.sort()\n total = 1\n child_to_give = []\n child_index = 0\n \n start_i = 0\n for j in range(0, len(g)):\n for i in range(start_i, len(s)): \n if s[i] >= g[j]:\n child_to_give.append(j)\n start_i = i + 1\n break\n \n \n print(child_to_give)\n return len(child_to_give)\n \n # def findContentChildrenSlow(self, g, s):\n # \"\"\"\n # :type g: List[int]\n # :type s: List[int]\n # :rtype: int\n # \"\"\"\n # s.sort()\n # g.sort()\n # total = 1\n # child_to_give = []\n # child_index = 0\n # for child_greed in g:\n # # Find children greed less than or equal to cookie value\n # for cookie in s:\n # if child_greed <= cookie:\n # # print(cookie)\n # # print(child_greed)\n # if child_index not in child_to_give:\n # child_to_give.append(child_index)\n # # g.remove(child_greed) \n # s.remove(cookie)\n # # print(g)\n # # print(s)\n # # break\n # child_index += 1\n \n # return len(child_to_give)\n # # return 2\n", "class Solution:\n def findContentChildren(self, g, s):\n \"\"\"\n :type g: List[int]\n :type s: List[int]\n :rtype: int\n \"\"\"\n g.sort()\n s.sort()\n print(g)\n print(s)\n \n count_child = 0\n count_cookie = 0\n \n while(count_child < len(g) and count_cookie < len(s)):\n if (g[count_child] <= s[count_cookie]):\n count_child += 1\n count_cookie += 1\n \n return count_child\n \n", "class Solution:\n def findContentChildren(self, g, s):\n \"\"\"\n :type g: List[int]\n :type s: List[int]\n :rtype: int\n \"\"\"\n g.sort()\n s.sort()\n \n index, result = 0, 0\n while index < len(s) and len(g) > 0:\n if s[index] >= g[0]:\n result += 1\n index += 1\n g.remove(g[0])\n else:\n index += 1\n return result\n \n"]
{"fn_name": "findContentChildren", "inputs": [[[2, 3], [1, 1]], [[1,2,3], [1,1]], [[1,2], [1,2,3]]], "outputs": [0, 1, 2]}
INTRODUCTORY
PYTHON3
LEETCODE
5,886
class Solution: def findContentChildren(self, g: List[int], s: List[int]) -> int:
6d44a4ffbe4b97cce7f6983418ca6de7
UNKNOWN
Given a non-negativeΒ index kΒ where k ≀ 33, return the kthΒ index row of the Pascal's triangle. Note that the row index starts fromΒ 0. In Pascal's triangle, each number is the sum of the two numbers directly above it. Example: Input: 3 Output: [1,3,3,1] Follow up: Could you optimize your algorithm to use only O(k) extra space?
["class Solution:\n def getRow(self, k):\n \"\"\"\n :type k: int\n :rtype: List[int]\n \"\"\"\n res = [1]\n cur = k\n for i in range(k//2):\n res += res[-1] * cur // (i+1),\n cur -= 1\n if k % 2 == 0:\n res = res + res[:-1][::-1]\n else:\n res = res + res[::-1]\n return res\n", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n a=[1]\n i=0\n b=[1]\n while i<rowIndex:\n a.append(0)\n b=a[:]\n for j in range(i+2):\n b[j]=a[j]+a[i-j+1]\n a=b\n i+=1\n return b\n \n", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n res = [1]\n for i in range(1, rowIndex + 1):\n res += [1]\n for j in range(len(res) - 2, -1, -1):\n if j > 0:\n res[j] = res[j] + res[j -1]\n else:\n res[j] = 1\n \n return res\n", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n out = [1]\n for i in range(1,rowIndex+1):\n temp = []\n for j in range(0, i-1):\n temp.append(out[j]+out[j+1])\n out = [1]+temp+[1]\n return out", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n l = [1]\n for i in range(rowIndex):\n l = [j+k for j, k in zip([0]+l, l+[0])]\n return l\n", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n result=[]\n for n in range(rowIndex+1):\n num=1\n for i in range(n):\n num=int(num*(rowIndex-i)/(i+1))\n result=result+[num]\n return result\n \n", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n if rowIndex < 0:\n return list()\n if rowIndex == 0:\n return list([1])\n l = list([1])\n for i in range(1,rowIndex+1):\n pre_value = l[0] #1\n for j in range(1,i):#j = 3\n temp = l[j] #1\n l[j] = pre_value+l[j] #4\n pre_value = temp #1\n l.append(1)\n return l\n \n \n", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n rows = [1]\n for i in range(rowIndex):\n rows = [x+y for x, y in zip([0]+rows, rows+[0])]\n return rows", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n row = [1]\n for _ in range(rowIndex):\n row = [x + y for x, y in zip([0]+row, row+[0])]\n return row", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n if rowIndex < 0: return []\n result = [0 for _ in range(rowIndex+1)]\n result[0] = 1\n for i in range(1, rowIndex+1):\n result[i] = 1\n for j in range(i-1, 0, -1):\n result[j] = result[j] + result[j-1]\n return result", "class Solution:\n def getRow(self, rowIndex):\n \"\"\"\n :type rowIndex: int\n :rtype: List[int]\n \"\"\"\n i=1\n res = [1]\n while rowIndex >=1:\n res.append(int(res[-1]*rowIndex/i))\n rowIndex,i = rowIndex-1,i+1\n return(res)"]
{"fn_name": "getRow", "inputs": [[3], [0], [1]], "outputs": [[1,3,3,1], [1], [1,1]]}
INTRODUCTORY
PYTHON3
LEETCODE
4,231
class Solution: def getRow(self, rowIndex: int) -> List[int]:
ac70fbe8251ee3e66518b1191af2821a
UNKNOWN
Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It 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 3, the input represents the signed integer -3. Example 1: Input: n = 00000000000000000000000000001011 Output: 3 Explanation: The input binary string 00000000000000000000000000001011 has a total of three '1' bits. Example 2: Input: n = 00000000000000000000000010000000 Output: 1 Explanation: The input binary string 00000000000000000000000010000000 has a total of one '1' bit. Example 3: Input: n = 11111111111111111111111111111101 Output: 31 Explanation: The input binary string 11111111111111111111111111111101 has a total of thirty one '1' bits. Constraints: The input must be a binary string of length 32. Follow up: If this function is called many times, how would you optimize it?
["class Solution:\n def hammingWeight(self, n: int) -> int:\n count = 0\n while n!=0:\n n &= (n-1)\n count += 1\n return count", "class Solution:\n def hammingWeight(self, n: int) -> int:\n return len([x for x in bin(n) if x =='1'])", "class Solution:\n def hammingWeight(self, n: int) -> int:\n strn = str(bin(n))\n # print(strn)\n return strn.count('1')", "class Solution:\n def hammingWeight(self, n: int) -> int:\n \n onebits = 0\n while n > 0:\n if n & 1 == 1:\n onebits += 1\n n = n >> 1\n return onebits", "class Solution:\n def hammingWeight(self, n: int) -> int:\n return bin(n).count('1')", "class Solution:\n def hammingWeight(self, n: int) -> int:\n suma=0\n while(n!=0):\n suma+=1\n print(n,(n-1))\n n&=(n-1)\n return suma"]
{"fn_name": "hammingWeight", "inputs": [[11], [128], [4294967293]], "outputs": [3, 1, 31]}
INTRODUCTORY
PYTHON3
LEETCODE
952
class Solution: def hammingWeight(self, n: int) -> int:
abd6d5c6d012dee40655b47c9db4ac18
UNKNOWN
Given a non-empty array of digitsΒ representing a non-negative integer, plus one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit. You may assume the integer does not contain any leading zero, except the number 0 itself. Example 1: Input: [1,2,3] Output: [1,2,4] Explanation: The array represents the integer 123. Example 2: Input: [4,3,2,1] Output: [4,3,2,2] Explanation: The array represents the integer 4321.
["class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n carry=1\n for i in range(len(digits)-1, -1, -1):\n digits[i]+=carry\n if digits[i] > 9:\n digits[i]-=10\n carry=1\n else:\n carry=0 \n if carry == 0:\n break \n if carry == 1:\n digits.insert(0, 1)\n return digits ", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n \n l = len(digits)\n i = l-1\n while i >= 0:\n if digits[i] != 9:\n digits[i] += 1\n break\n else:\n digits[i] = 0\n i -= 1\n if i == -1:\n digits = [1] + digits\n return digits", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n i = len(digits) - 1\n carry = 1\n while carry!=0 or i >=0:\n temp = digits[i] + carry\n digits[i] = temp % 10\n carry = temp // 10\n i-=1\n if i < 0 and carry > 0: \n digits.insert(0,carry)\n carry = 0\n return digits \n", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n l = [str(i) for i in digits]\n l = int(''.join(l))\n l +=1\n l = list(str(l))\n l = [int(i) for i in l]\n return l", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n flag = 1\n i = len(digits)-1\n while i >=0:\n if digits[i]+flag <10:\n digits[i] = digits[i]+flag\n flag = 0\n else:\n digits[i] = (digits[i]+flag)%10\n i-=1\n if flag == 1:\n digits.insert(0,1)\n return digits", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n if not digits:\n return []\n \n i = len(digits) - 1\n while i >= 0:\n if digits[i] < 9:\n digits[i] += 1\n return digits\n else:\n digits[i] = 0\n i -= 1\n if digits[0] == 0:\n return [1]+digits", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n d = [str(x) for x in digits]\n num = int(''.join(d)) + 1\n \n return list(map(int, str(num)))", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n \n sum = 0\n for i in range(0, len(digits)):\n sum = sum * 10 + digits[i]\n \n return [int(i) for i in str(sum+1)]\n", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n carry = 1\n for i in range(len(digits)-1,-1,-1):\n print(i)\n if digits[i] + carry == 10:\n digits[i] = 0\n else:\n digits[i] += 1\n return digits\n digits.insert(0,1)\n return digits ", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n if not digits:\n return [1]\n carry = 1\n for i in reversed(range(len(digits))):\n if carry == 0:\n return digits\n carry, digits[i] = (digits[i] + carry) // 10, (digits[i]+carry) % 10\n if carry:\n return [1] + digits\n return digits", "class Solution:\n def plusOne(self, digits):\n plus = 1\n for i in range(len(digits)-1, -1, -1):\n if digits[i] + plus > 9:\n digits[i] = 0\n plus = 1\n else:\n digits[i] = digits[i] + plus\n plus = 0\n if plus == 1:\n digits.insert(0, 1)\n return digits", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n \n if digits[-1] != 9:\n digits[-1] += 1\n else:\n for i in range(-1, -len(digits)-1, -1):\n if digits[i] == 9:\n digits[i] = 0\n else:\n digits[i] += 1\n break\n else:\n digits.insert(0, 1)\n \n return digits", "class Solution:\n def plusOne(self, digits):\n \"\"\"\n :type digits: List[int]\n :rtype: List[int]\n \"\"\"\n num = 0\n for i in range(len(digits)):\n num += 10**i * digits[len(digits)-i-1]\n return(list(map(int, list(str(num+1)))))\n"]
{"fn_name": "plusOne", "inputs": [[[1,2,3]], [[4,3,2,1]], [[0]]], "outputs": [[1,2,4], [4,3,2,2], [1]]}
INTRODUCTORY
PYTHON3
LEETCODE
5,639
class Solution: def plusOne(self, digits: List[int]) -> List[int]:
91dc94372aba883a0c9868b3889263cc
UNKNOWN
You are given two integers A and B. Find the largest value among A+B, A-B and A \times B. -----Constraints----- - -1000 \leq A,B \leq 1000 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: A B -----Output----- Print the largest value among A+B, A-B and A \times B. -----Sample Input----- 3 1 -----Sample Output----- 4 3+1=4, 3-1=2 and 3 \times 1=3. The largest among them is 4.
["a,b=map(int,input().split(\" \"))\nprint(max(max(a+b,a*b),a-b))", "a, b = map(int, input().split())\n\nprint(max(a + b, a - b, a * b))", "a,b=map(int, input().split())\n\na_list=[a+b,a-b,a*b]\n\nprint(max(a_list))", "A, B = map(int, input().split())\nprint(max(A+B, A-B, A*B))", "a, b = map(int, input().split())\nprint(max(a+b, a-b, a*b))", "a,b = map(int,input().split())\nprint(max(a+b,a-b,a*b))", "a, b= map(int, input().split())\nprint(max(a+b, a-b, a*b))", "a,b = map(int, input().split())\nprint(max(a+b,a-b,a*b))", "import sys\n\n\ndef input(): return sys.stdin.readline().strip()\ndef I(): return int(input())\ndef LI(): return list(map(int, input().split()))\ndef IR(n): return [I() for i in range(n)]\ndef LIR(n): return [LI() for i in range(n)]\ndef SR(n): return [S() for i in range(n)]\ndef S(): return input()\ndef LS(): return input().split()\n\n\nINF = float('inf')\n\n\na, b = LI()\nprint((max(a+b, a-b, a*b)))\n", "A, B = map(int, input().split())\nprint(max(A+B, A-B, A*B))", "a,b=list(map(int,input().split()))\nprint(max(a*b,a-b,a+b))", "#ABC098\na,b = map(int,input().split())\nprint(max(a+b,a-b,a*b))", "a,b=input().split()\na=int(a)\nb=int(b)\nls=[a+b,a-b,a*b]\nls.sort()\nprint(ls[2])", "def LI():\n return list(map(int, input().split()))\n\n\nA, B = LI()\nprint((max(A+B, A-B, A*B)))\n", "a, b = map(int, input().split())\nprint(max(a + b, a - b, a * b))", "A, B = map(int, input().split())\nprint(max(A+B, A-B, A*B))", "lst = input().split()\na = int(lst[0])\nb = int(lst[1])\n\nprint(max([a + b, a - b, a * b]))", "A,B = map(int,input().split())\nprint(max(A+B,A-B,A*B))", "a,b=map(int,input().split())\nprint(int(max(a+b,a-b,a*b)))", "a,b = map(int,input().split())\nprint(max(a+b,a-b,a*b))", "A, B = map(int,input().split())\nprint(max(A+B, A-B, A*B))", "a,b=map(int,input().split())\nprint(max(a+b,a-b,a*b))", "a,b = map(int,input().split())\nprint(max(a + b, a - b, a * b))", "A,B=map(int,input().split())\nprint(max(A+B,A-B,A*B))", "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(max(a+b, a*b, a-b))\n\nmain()", "a,b=map(int,input().split())\n\nresult = max(a+b,a-b)\nresult = max(result,a*b)\nprint(result)", "a, b = list(map(int, input().split()))\nprint((max(a + b, a - b, a * b)))\n", "a, b = map(int, input().split())\nprint(max(a+b, a-b, a*b))", "A,B = map(int,input().split())\nprint(max(A+B,A-B,A*B))", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\nfrom collections import deque\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nDR = [1, -1, 0, 0]\nDC = [0, 0, 1, -1]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n \ndef main():\n A, B = LI()\n print((max(A+B, A-B, A*B)))\n\nmain()\n\n", "a, b = map(int, input().split())\nx = a + b\ny = a - b\nz = a * b\nprint(max(x, y, z))", "a, b = map(int, input().split())\nprint(max(a+b, a-b, a*b))", "A,B=list(map(int,input().split()))\nprint((max(A+B,A-B,A*B)))\n", "a, b = list(map(int, input().split()))\nprint((max(a + b, a * b, a - b)))\n", "A, B = map(int, input().split())\n\nprint(max(A + B, A - B, A * B))", "a,b = map(int, input().split())\nprint(max(a+b,a-b,a*b))", "a,b=map(int,input().split())\n\nA=[a+b,a-b,a*b]\n\nprint(max(A))", "A,B=map(int,input().split())\nprint(max(A+B,max(A*B,A-B)))", "a, b = map(int, input().split())\nc = []\nc.append(a+b)\nc.append(a-b)\nc.append(a*b)\nc = sorted(c, reverse=True)\nprint(c[0])", "a,b=map(int,input().split())\nprint(max(a+b,a-b,a*b))", "A,B = map(int,input().split())\nprint(max(A+B,A-B,A*B))", "A, B = list(map(int, input().split()))\n\nprint(max(A + B, A - B, A * B))", "a, b = list(map(int, input().split()))\n\nprint(max(a+b, a-b, a*b))", "a,b=map(int,input().split())\nprint(max(a+b,a-b,a*b))", "a=list(map(int,input().split()))\nb=a[0]*a[1]\nc=a[0]-a[1]\nd=a[0]+a[1]\nprint(max(b,c,d))", "a,b=map(int,input().split())\nans=max(a+b,a-b,a*b)\nprint(ans)", "a,b=map(int,input().split())\n\nA=[a+b,a-b,a*b]\n\nprint(max(A))", "a,b = (int (x) for x in input ().split ())\nx = a+b\ny = a-b\nz = a*b\nif x>=y and x>=z:\n print (x)\nelif y>=x and y>=z:\n print (y)\nelse:\n print (z)", "a,b = [int(x) for x in input().split()]\nprint(max(a+b,a-b,a*b))", "A, B = map(int, input().split())\nprint(max(A+B, A-B, A*B))", "a,b = list(map(int,input().split()))\nprint((max(a+b, a-b, a*b)))\n", "a, b = map(int, input().split())\nprint(max(a+b,a-b,a*b))", "a,b=map(int,input().split())\nans=max(a+b,a-b,a*b)\nprint(ans)", "a,b=map(int,input().split())\n\nprint(max(a+b,a-b,a*b))", "a,b=map(int,input().split())\nprint(max(a+b,a-b,a*b))", "a,b=map(int,input().split())\nprint(max(a+b,a-b,a*b))", "a,b = map(int,input().split())\nprint(max(a+b,a-b,a*b))", "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 main():\n a, b = nm()\n print((max(a + b, a - b, a * b)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import sys\n\nA, B = list(map(int, input().split()))\n\nprint(max(A+B, A-B, A*B))", "A, B = map(int, input().split())\nprint(max(A + B, A - B, A * B))", "a,b = map(int,input().split())\nprint(max(a+b,a-b,a*b))", "A,B = map(int,input().split())\nans = max(A+B,A-B,A*B)\nprint(ans)", "a,b = map(int, input().split())\nprint(max(a+b, a-b, a*b))", "a, b = map(int, input().split())\nprint(max(a+b, a-b, a*b))", "A, B = map(int, input().split())\nprint(max(A + B, A - B, A * B))", "a, b = map(int, input().split())\ns = a + b\nt = a - b\nw = a * b\n\nprint(max(s, t, w))", "\na,b=map(int,input().split())\nprint(max(a+b,a-b,a*b))", "a, b = list(map(int, input().split()))\nres = max(a + b, a - b, a * b)\nprint(res)\n", "a,b = map(int,input().split())\n\nprint(max(a+b,a*b,a-b))", "def main():\n A, B = list(map(int, input().split()))\n ans = max(A + B, A - B, A * B)\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a,b=map(int,input().split())\nprint(max(a+b,a-b,a*b))", "#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\na,b = list(map(int, input().split()))\n\nprint((max(a+b,a-b,a*b)))\n\n\n", "A, B = map(int, input().split())\n\nprint(max(A+B, A-B,A*B))", "a,b=map(int, input().split())\nprint(max(a+b,a-b,a*b))", "a,b=map(int,input().split())\nprint(max(a+b,a-b,a*b))", "A, B = list(map(int, input().split()))\nprint((max(A + B, A - B, A * B)))\n", "a, b = list(map(int, input().split()))\nx = max(a*b, max(a+b, a-b))\nprint(x)\n", "a,b = map(int,input().split())\nprint(max(a+b,a-b,a*b))", "A,B=map(int,input().split())\nprint(max(A+B,A-B,A*B))", "A,B=map(int,input().split())\nprint(max(A+B,A-B,A*B))", "#!/usr/bin/env python3\n\na, b = list(map(int, input().split()))\n\nans = max(a+b, a-b, a*b)\nprint(ans)\n", "#\n# abc096 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 1\"\"\"\n output = \"\"\"4\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"4 -2\"\"\"\n output = \"\"\"6\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"0 0\"\"\"\n output = \"\"\"0\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n A, B = list(map(int, input().split()))\n\n print((max(A+B, A-B, A*B)))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "a,b = map(int,input().split())\n\nprint(max(a+b,max(a-b,a*b)))", "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\nA,B = inm()\nl = []\nl.append(A+B)\nl.append(A-B)\nl.append(A*B)\nprint(max(l))\n\n", "a,b = map(int,input().split())\n\nprint(max(a+b,a-b,a*b))", "a, b=map(int, input().split())\nprint(max(a*b,a+b,a-b))", "a=input();print(max(eval(a.replace(\" \",k))for k in\"+-*\"))", "a, b = list(map(int, input().split()))\nprint((max(a+b, a-b, a*b)))\n", "a, b = list(map(int, input().split()))\nprint((max(a+b, a-b, a*b)))\n", "A,B = map(int, input().split())\nprint(max(A+B, A-B, A*B))", "a, b = map(int, input().split())\nmaximum = max(a + b, a - b, a * b)\nprint(maximum)", "a,b = list(map(int,input().split()))\nprint((max(a+b,a-b,a*b)))\n", "a,b = map(int,input().split())\nprint(max(a+b,a*b,a-b))", "A,B=list(map(int,input().split()))\n\na=A+B\nb=A-B\nc=A*B\n\nprint((max(a,b,c)))\n", "a,b = map(int,input().split())\n\nprint(max(a+b,a-b,a*b))", "a,b = map(int,input().split())\nprint(max(a+b,a-b,a*b))", "a, b = map(int,input().split())\nlist01 = [a + b, a * b, a - b]\nprint(max(list01))", "A, B = list(map(int, input().split()))\n\nprint((max([A+B, A-B, A*B])))\n", "a,b=map(int,input().split())\n\nprint(max([a+b,a-b,a*b]))"]
{"inputs": ["3 1\n", "4 -2\n", "0 0\n"], "outputs": ["4\n", "6\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
10,126
e6c4d0f99de39c534dc2db55ca775b89
UNKNOWN
We have N points in the two-dimensional plane. The coordinates of the i-th point are (X_i,Y_i). Among them, we are looking for the points such that the distance from the origin is at most D. How many such points are there? We remind you that the distance between the origin and the point (p, q) can be represented as \sqrt{p^2+q^2}. -----Constraints----- - 1 \leq N \leq 2\times 10^5 - 0 \leq D \leq 2\times 10^5 - |X_i|,|Y_i| \leq 2\times 10^5 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N D X_1 Y_1 \vdots X_N Y_N -----Output----- Print an integer representing the number of points such that the distance from the origin is at most D. -----Sample Input----- 4 5 0 5 -2 4 3 4 4 -4 -----Sample Output----- 3 The distance between the origin and each of the given points is as follows: - \sqrt{0^2+5^2}=5 - \sqrt{(-2)^2+4^2}=4.472\ldots - \sqrt{3^2+4^2}=5 - \sqrt{4^2+(-4)^2}=5.656\ldots Thus, we have three points such that the distance from the origin is at most 5.
["def main():\n\tN, D = [int(n) for n in input().split(\" \")]\n\tcnt = 0\n\tfor i in range(N):\n\t\tX, Y = [int(x) for x in input().split(\" \")]\n\t\tif X ** 2 + Y ** 2 <= D ** 2:\n\t\t\tcnt += 1\n\tprint(cnt)\n\nmain()\n", "N,D = map(int,input().split())\n\nxy = [list(map(int,input().split())) for i in range(N)]\n\ncnt = 0\n\nfor x, y in xy:\n if (x**2 + y**2)**(1/2) <= D:\n cnt += 1\n \nprint(cnt)", "n, d = map(int, input().split())\nx = [list(map(int,input().split())) for i in range(n)]\n\nans = 0\nfor i,j in x:\n if (i**2)+(j**2) <= d**2:\n ans += 1\n\nprint(ans)", "N, D = list(map(int, input().split()))\nXY = [list(map(int, input().split())) for _ in range(N)]\n\nresult = [1 if (((x ** 2 + y ** 2) ** 0.5) <= D) else 0 for x, y in XY]\nprint((sum(result)))\n", "n,d = [int(s) for s in input().split()]\nl = [[int(s) for s in input().split()] for j in range(n)]\nl1 = [i[0]*i[0] + i[1]*i[1] for i in l]\nl1.sort()\nans = -1\nfor i in range(n):\n if l1[i]>d*d:\n ans = i\n break\nelse:\n ans = n\nprint(ans)", "from math import sqrt\n\nn, d = map(int, input().split())\ncnt = 0\n\nfor _ in range(n):\n p, q = map(int, input().split())\n if sqrt(p*p+q*q) <= d:\n cnt += 1\n\nprint(cnt)", "n, d = map(int, input().split())\n\nres = 0\nfor i in range(n):\n x, y = map(int, input().split())\n if x*x+y*y <= d*d:\n res += 1\nprint(res)", "from math import *\nn,d=map(int,input().split())\nc=0\nfor i in range(n):\n p,q=map(int,input().split())\n if d>=(p**2+q**2)**0.5:\n c+=1\n \nprint(c)", "n,d = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n x1,y1 = list(map(int,input().split()))\n if(d*d >= x1*x1+y1*y1):\n ans += 1\nprint(ans)\n", "import math\nn, d = list(map(int, input().split()))\nans = 0\nfor i in range(n):\n x, y = list(map(int, input().split()))\n if d >= math.sqrt(x**2+y**2):\n ans += 1\nprint(ans)\n", "import math\nn, d = map(int, input().split())\ns = 0\nfor i in range(n):\n x, y = map(int, input().split())\n r = x**2 + y**2\n if r<=d**2:\n s += 1\n\nprint(s)", "n,d = list(map(int,input().split()))\ncount = 0\nfor i in range(n):\n x,y = list(map(int,input().split()))\n if x ** 2 + y ** 2 <= d **2:\n count += 1\nprint(count)\n", "N, D = list(map(int, input().split()))\n\nresult = 0\n\nfor _ in range(N):\n X, Y = list(map(int, input().split()))\n if X * X + Y * Y <= D * D:\n result += 1\nprint(result)\n", "N,D=map(int,input().split())\nX=[input()for i in range(N)]\n\ndef ans174(N:int, D:int, X:list):\n count=0\n import math\n for i in range(N):\n X_list=list(map(int,X[i].split()))\n if math.sqrt(X_list[0]**2+X_list[1]**2)<=D:\n count+=1\n return count\n\nprint(ans174(N,D,X))", "n,d=list(map(int,input().split()))\nans=0\nfor i in range(n):\n x,y=list(map(int,input().split()))\n if((x**2+y**2)**0.5<=d):\n ans+=1\nprint(ans)\n", "N,D = (int(x) for x in input().split())\nxy = [map(int, input().split()) for _ in range(N)]\nnum = 0\nfor x,y in xy:\n if( x**2 + y**2 <= D**2):\n num += 1\nprint(num)", "from typing import List\n\n\ndef answer(n: int, d: int, xy: List[List[int]]) -> int:\n count = 0\n dd = d ** 2\n for x, y in xy:\n if x ** 2 + y ** 2 <= dd:\n count += 1\n\n return count\n\n\ndef main():\n n, d = list(map(int, input().split()))\n xy = [list(map(int, input().split())) for _ in range(n)]\n print((answer(n, d, xy)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import math\nn, d = map(int, input().split())\ncnt = 0\nfor i in range(n):\n x, y = map(int, input().split())\n if d >= math.sqrt(x**2 + y**2):\n cnt += 1\n else:\n pass\n \nprint(cnt)", "import math\nN,D =map(int,input().split())\n\ncnt = 0\nfor i in range(N):\n x,y=map(int,input().split())\n ans =math.sqrt(x**2+y**2)\n if ans <= D:\n cnt += 1\nprint(cnt)", "N, D = map(int, input().split())\nX_list = []\nY_list = []\ncount = 0\n\nfor i in range(N):\n X, Y = map(int, input().split())\n X_list.append(X)\n Y_list.append(Y)\n\nfor i in range(N):\n if (X_list[i] ** 2) + (Y_list[i] ** 2) <= D ** 2:\n count += 1\n \nprint(count)", "N,D = map(int, input().split())\nXY = [list(map(int, input().split())) for _ in range(N)]\nD = D**2\nans = 0\nfor x,y in XY:\n if x**2 + y**2 <= D:\n ans += 1\nprint(ans)", "from math import sqrt,ceil\nn,d=map(int,input().split())\ncount=0\nfor i in range(n):\n a,b=map(int,input().split())\n if(int(ceil(sqrt(pow(a,2)+pow(b,2))))<=d):\n count+=1\nprint(count)", "n,d = map(int,input().split())\ni = 1\na = 0\nwhile i <= n:\n x,y = map(int,input().split())\n i += 1\n if x**2 + y**2 <= d**2:\n a += 1\nprint(a)", "import math\n\nN, D = map(int, input().split())\nxy = [list(map(int, input().split())) for xy in range(N)]\n\ncount = 0\nfor i in range(N):\n l = math.sqrt(xy[i][0]**2 + xy[i][1]**2)\n if l <=D:\n count += 1\n\nprint(count)", "n, dis = map(int,input().split())\nans = 0\nfor i in range(n):\n a,b = map(int,input().split())\n if (a**2 + b**2)**(1/2) <= dis:\n ans += 1\n \nprint(ans)", "import math\n\nn, d = input().split()\ncount = 0\ndn = int(d)\n\nfor i in range(int(n)):\n x = list(map(int,input().split()))\n if dn >= math.sqrt(x[0] ** 2 + x[1] ** 2):\n count += 1\n\nprint(count)", "import math\na,b = map(int,input().split())\nx = \"\"\ny = 0\nfor i in range(a):\n x = input().split()\n if math.sqrt(int(x[0]) ** 2 + int(x[1]) ** 2) <= b:\n y = y + 1\nprint(y)", "N,D = list(map(int,input().split()))\n\nans=0\n\nfor i in range(N):\n X,Y = list(map(int,input().split()))\n dis = (X*X+Y*Y) ** 0.5\n if dis <= D:\n ans += 1\nprint(ans)\n", "import math\nn, d = map(int, input().split())\n\nans = 0\nfor i in range(n):\n x, y = map(int, input().split())\n s = math.sqrt(x ** 2 + y ** 2)\n if s <= d:\n ans += 1\n\nprint(ans) ", "import math\n\nn, d = map(int, input().split())\nx = [list(map(int,input().split())) for i in range(n)]\n\nans = 0\nfor i,j in x:\n if math.sqrt((i*i)+(j*j)) <= d:\n ans += 1\n\nprint(ans)", "n,d = map(int, input().split() )\nxy = [ ]\nfor _ in range(n):\n s = [ int(i) for i in input().split() ]\n xy.append(s)\nans = 0\nfor s in xy:\n if s[0]**2+s[1]**2<= d**2:\n ans += 1\nprint(ans)", "N, D = map(int,input().split())\nX = [input()for i in range(N)]\n\nimport math\ncount = 0\nfor i in range(N):\n X_list = list(map(int,X[i].split()))\n if D >= math.sqrt(X_list[0]**2 + X_list[1]**2):\n count += 1\n\nprint(count)", "n, d = list(map(int, input().split()))\ncount = 0\nfor i in range(n):\n x, y = list(map(int, input().split()))\n if d**2 >= (x**2 + y**2):\n count += 1\nprint(count)\n", "n, d = map(int, input().split())\ncnt = 0\nfor i in range(n):\n x, y = map(int, input().split())\n if (x ** 2 + y ** 2) ** 0.5 <= d:\n cnt += 1\n\nprint(cnt)", "N,D = map(int,input().split())\ncount = 0\nimport math\nfor _ in range(N):\n X,Y = map(int,input().split())\n if D>=math.sqrt(X**2+Y**2):count+=1\nprint(count)", "N, D = map(int,input().split())\n\np = 0\n\nfor i in range(1,N+1):\n X, Y = map(int,input().split())\n import math\n c = math.sqrt(X**2 + Y**2)\n if c <= D:\n p += 1\n\nprint(p)", "N,D = map(int,input().split())\ncount = 0\n\nfor _ in range(N):\n X,Y = map(int,input().split())\n if (X**2 + Y**2)**(1/2) <= D:\n count += 1\n\nprint(count)", "import math\nn,d=map(int, input().split())\ncount=0\nfor i in range(n):\n x,y=map(int, input().split())\n if math.sqrt(x**2+y**2)<=d:\n count+=1\nprint(count)", "N, D = map(int, input().split())\nans = 0\nfor i in range(N):\n x, y = list(map(int, input().split()))\n if x**2 + y**2 <= D**2:\n ans += 1\nprint(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, d = [int(i) for i in input().split()]\nA = [[int(i) for i in input().split()]for j in range(n)] # n\u306f\u884c\u6570\n\ntmp = 0\nres = 0\n\nfor i in range(n):\n x, y = A[i]\n if x ** 2 + y ** 2 <= d ** 2:\n res += 1\n\nprint(res)\n", "n,D=list(map(int,input().split()))\ncount=0\nfor i in range(n):\n a,b=list(map(int,input().split()))\n d=(a**2+b**2)**(1/2)\n if d<=D:\n count+=1\nprint(count)\n", "import math\nN, D = map(int, input().split())\n\nans = 0\nfor i in range(N):\n X, Y = map(int, input().split())\n dis = math.sqrt(X ** 2 + Y ** 2)\n if dis <= D:\n ans += 1\n\nprint(ans)", "N, D = map(int, input().split())\nans = 0\nfor i in range(N):\n X, Y = map(int, input().split())\n if X**2 + Y**2 <= D**2:\n ans += 1\n else:\n continue\nprint(ans)", "n, d = list(map(int, input().split()))\nans = 0\nfor i in range(n):\n x, y = list(map(int, input().split()))\n if x * x + y * y <= d * d:\n ans += 1\nprint(ans)\n", "import math\nn,d=map(int,input().split())\ncount=0\nfor i in range(n):\n x,y=map(int,input().split())\n a=math.sqrt(x*x+y*y)\n if(a<=d):\n count+=1\n \nprint(count)", "n,d=map(int,input().split())\nprint(sum([x*x+y*y<=d*d for x,y in [map(int,input().split()) for i in range(n)]]))", "N, D = map(int, input().split())\nX = [0 for i in range(N)]\nY = [0 for i in range(N)]\nfor i in range(N):\n X[i], Y[i] = map(int, input().split())\ncnt = 0\n\nfor i in range(N):\n if D**2 >= (X[i]**2 + Y[i]**2):\n cnt += 1\n\nprint(cnt)", "N,D = list(map(int, input().split()))\nans = 0\n\nfor i in range(N):\n X, Y = list(map(int,input().split()))\n if X**2 + Y**2 <= D**2:\n ans += 1\n else:\n continue\n\nprint(ans)\n\n", "import math\nN, D = map(int,input().split())\nX = [0 for _ in range(N)]\nY = [0 for _ in range(N)]\nDistance = []\nans = 0\nDistance = 0\nfor i in range(N):\n X[i], Y[i] = map(int, input().split())\n Distance = math.sqrt((X[i])**2 + (Y[i])**2)\n if Distance <= D:\n ans += 1\nprint(ans)", "N, D = list(map(int, input().split()))\ncnt = 0\n\nfor i in range(N):\n x, y = list(map(int, input().split()))\n if x**2 + y**2 <= D**2:\n cnt += 1\n else:\n pass\n\nprint(cnt)\n\n", "N,D = map(int,input().split())\ncount = 0\n\nfor _ in range(N):\n X,Y = map(int,input().split())\n if (X**2 + Y**2)**(1/2) <= D:\n count += 1\n\nprint(count)", "N, D = map(int, input().split())\nzahyo = [list(map(int, input().split())) for i in range(N)]\n\ndef distance(a, b):\n return (a ** 2 + b ** 2) ** 0.5\n\nkazu = 0\nfor i in range(N):\n genzai = zahyo[i]\n if distance(genzai[0], genzai[1]) <= D:\n kazu += 1\n\nprint(kazu)", "n,d=map(int, input().split())\np=[list(map(int, input().split())) for i in range(n)]\ncount=0\nfor i in range(n):\n if p[i][0]**2+p[i][1]**2<=d**2:\n count+=1\nprint(count)", "# coding: utf-8\n# Your code here!\nimport math\n\nn,d = input().split()\nn = int(n)\nd = int(d)\n\ncount = 0\nfor i in range(n):\n x,y = input().split()\n x = int(x)\n y = int(y)\n rout = math.sqrt(x**2 + y**2)\n if rout <= d:\n count += 1\n \nprint(count)", "N,D= list(map(int, input().split()))\nL=[0]*N\ncnt = 0\nans = 0\n\nfor i in range(N):\n x,y = list(map(int, input().split()))\n L[i]= (x**2+y**2)**0.5\n\n#print(L)\n\nfor i in range(N):\n if L[i] <= D:\n cnt += 1\n else:\n cnt = cnt\n\nans = cnt\nprint(ans)\n", "num, max_num = list(map(int, input().split()))\nx = []\ny = []\ncount = 0\n\nfor i in range(num):\n x1,y1 = list(map(int, input().split()))\n x.append(x1)\n y.append(y1)\n\nfor i in range(len(x)):\n temp = (x[i]**2 +y[i]**2)**(1/2)\n if temp <= max_num:\n count += 1\n\nprint(count)\n\n", "N, D = map(int, input().split())\nans = 0\n\nfor i in range(N):\n x, y = map(int, input().split())\n d = (x**2 + y**2) ** 0.5\n if d <= D:\n ans += 1\n\nprint(ans)", "import math\n\nn, d = map(int,input().split())\n\nxy = [map(int, input().split()) for _ in range(n)]\nx, y = [list(i) for i in zip(*xy)]\n\ncount = 0\n\nfor i in range(n):\n if d >= math.sqrt(x[i]**2 + y[i]**2):\n count += 1\nprint(count)", "n,d = list(map(int, input(\"\").split()))\no=0\nfor i in range(n):\n x,y=list(map(int, input(\"\").split()))\n if x**2+y**2<=d**2:\n o+=1\nprint(o)", "##B - Distance\nN,D = list(map(int,input().split()))\nans = 0\nfor i in range(N):\n X,Y = list(map(int,input().split()))\n if X**2+Y**2 <= D**2:\n ans += 1\nprint(ans)\n", "import math\nn, d = list(map(int, input().strip().split()))\ncords = []\nwhile n:\n cords.append(list(map(int, input().strip().split())))\n n -= 1\nans = 0\nfor c in cords:\n ans += 1 if math.sqrt((c[0]**2) + (c[1]**2)) <= d else 0\nprint(ans)\n", "from math import sqrt\nn, d = list(map(int, input().split()))\nx_y = [[int(i) for i in input().split()] for i in range(n)]\n\n\ncnt = 0\nfor x, y in x_y:\n route = sqrt(x ** 2 + y ** 2)\n if route <= d:\n cnt += 1\n\nprint(cnt)\n", "\"\"\"\nsqrt(p**2 + q**2) <= D\n\"\"\"\n\n# \u5165\u529b\nN, D = map(int, input().split())\nX = list()\nY = list()\nfor i in range(N):\n x, y = map(int, input().split())\n X.append(x)\n Y.append(y)\n\n# \u8ddd\u96e2\ncount = 0\nfor i in range(N):\n distance = X[i]**2 + Y[i]**2\n if distance <= D*D:\n count += 1\n\n# \u7d50\u679c\nprint(count) ", "import math\nn, d = list(map(int, input().split()))\n\ncnt = 0\nfor i in range(n):\n x, y = list(map(int, input().split()))\n dist = math.sqrt(x**2+y**2)\n\n if dist <= d:\n cnt += 1\n\nprint(cnt)\n", "n, d = map(int, input().split( ))\ncount = 0\nfor _ in range(n):\n x, y = map(int, input().split( ))\n if (x**2 + y**2)**0.5 <= d:\n count +=1\nprint(count)", "def test():\n ans3=0\n input_ex=input()\n input_ex1=input_ex.split()\n n=int(input_ex1[0])\n d=int(input_ex1[1])\n for i in range(0,n):\n input_exa=input()\n input_ex2=input_exa.split()\n a=int(input_ex2[0])\n b=int(input_ex2[1])\n ans=(a**2+b**2)\n ans_2=ans**0.5\n if ans_2>d:\n pass\n else:\n ans3+=1\n print(ans3)\n \ntest()", "import math\n\nn,m = map(int,input().split())\nli = []\nfor i in range(n):\n li.append(list(map(int,input().split())))\n\nsum = 0\nfor i in range(n):\n n = math.sqrt(li[i][0]**2 + li[i][1]**2)\n if n <= m:\n sum += 1\n\nprint(sum)", "N, D = map(int, input().split())\ncnt = 0\nfor i in range(N):\n X, Y = map(int, input().split())\n if X**2 + Y**2 <= D**2:\n cnt += 1\nprint(cnt)", "import math\n\nn, d = list(map(int, input().split()))\n\na = 0\nans = 0\n\nn_l = []\nfor _ in range(n):\n tmp = list(map(int, input().split()))\n n_l.append(tmp)\n\nfor i in n_l:\n for j in i:\n a += j ** 2\n b = math.sqrt(a)\n if b <= d:\n ans += 1\n a = 0\n\nprint(ans)\n", "import math\nN, D = map(int, input().split())\ncount = 0\nfor i in range(N):\n x, y = map(int, input().split())\n if math.sqrt(x ** 2 + y ** 2) <= D:\n count += 1\nprint(count)", "import math\nn,d=[int(num) for num in input().split()]\nc=0\nfor i in range(n):\n x,y=[int(num) for num in input().split()]\n if math.sqrt(x**2+y**2)<=d:\n c=c+1\nprint(c)\n", "import math\nN, D = list(map(int, input().split()))\ncnt = 0\nfor i in range(N):\n\tX, Y = list(map(int, input().split()))\n\tif D >= math.sqrt(X ** 2 + Y ** 2):\n\t\tcnt += 1\nprint(cnt)\n", "n,d = map(int,input().split())\nans = 0\n\nfor i in range(n):\n x,y = map(int,input().split())\n if d >= (x**2 + y**2)**0.5:\n ans += 1\n \nprint(ans)", "import math\n\nN,D=list(map(int,input().split()))\nXY=[list(map(int,input().split())) for _ in range(N)]\ncount=0\n\nfor x,y in XY:\n if math.sqrt(x**2+y**2)<=D:\n count+=1\nprint(count)\n", "import sys\nimport math\n\nindex = 0\ncount = 0\nfor input in sys.stdin:\n formattedInput = input.replace(\"\\n\", \"\").split(\" \")\n if index == 0:\n N = int(formattedInput[0])\n D = int(formattedInput[1])\n index += 1\n continue\n root = math.sqrt(int(formattedInput[0]) ** 2 + int(formattedInput[1]) ** 2)\n if D >= root:\n count += 1\n index += 1\n\nprint(count)\n", "import math\n\nN, D = map(int, input().split())\ncnt_p = 0\nfor i in range(N):\n X, Y = map(int, input().split())\n Di = math.sqrt(X**2 + Y**2)\n if Di <= D:\n cnt_p += 1\nprint(cnt_p)", "def II(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\n\nans=0\nN,D=MI()\nD2=D*D\nfor i in range(N):\n x,y=MI()\n if x*x+y*y<=D2:\n ans+=1\nprint(ans)", "import math\nN,D=(int(x) for x in input().split())\n# 2\u6b21\u5143\u914d\u5217\ngrid = []\nfor i in range(N):\n array = list(map(int, input().strip().split()))\n grid.append(array)\n\ncount=0\n\nfor i in range(0,N):\n\tif math.sqrt(grid[i][0]**2 + grid[i][1]**2) <= D :\n\t\tcount+=1\n\nprint(count)", "n, d = map(int,input().split())\na = 0\nfor i in range(0,n):\n x, y =map(int,input().split())\n if x**2 + y**2 <= d**2:\n a += 1\nprint(a)", "n, d = list(map(int, input().split()))\nc = 0\nfor _ in range(n):\n x, y = list(map(int, input().split()))\n if (x ** 2 + y ** 2) ** 0.5 <= d:\n c += 1\nprint(c)\n", "import numpy\ncount = 0\nN, D = map(int, input().split())\n\nfor i in range(N):\n x = input().split()\n y = numpy.sqrt(int(x[0]) ** 2 + int(x[1]) ** 2)\n if float(D) >= y:\n count+= 1\n\nprint(count)", "import math\n\nN, D = list(map(int, input().split()))\ncnt = 0\nfor i in range(N):\n x, y = list(map(int, input().split()))\n distance = math.sqrt(x*x + y*y)\n\n if distance <= D:\n cnt += 1\n\nprint(cnt)\n", "import math\nN,D = map(int,input().split())\ncount = 0\nfor i in range(N):\n x,y = map(int,input().split())\n ans = math.sqrt(x**2 + y**2)\n if ans <= D:\n count = count + 1\nprint(count)", "from math import sqrt as r\nN, D = map(int, input().split())\n\nans = 0\n\nfor i in range(N):\n X, Y = map(int, input().split())\n d = r(X**2 + Y**2)\n if d <= D:\n ans += 1\n\nprint(ans)", "import math\n\nn, d = list(map(int, input().split(' ')))\nresultCnt = 0\n\nfor i in range(n):\n x, y = list(map(int, input().split(' ')))\n dis = math.sqrt((x**2) + (y**2))\n if dis <= d:\n resultCnt += 1\n\nprint(resultCnt)\n", "N, D = map(int, input().split())\nXY = [list(map(int, input().split())) for _ in range(N)]\nprint(sum((x**2+y**2)**.5<=D for x, y in XY))", "def main():\n \n n, d = map(int, input().split())\n cnt = 0\n # xy = [<>,<>,<>... ] <>\u306fmapobj\n xy = [map(int, input().split()) for i in range(n)]\n # zip(*xy) = (x1, x2, s3, s4...), (y1, y2, y3, y4...)\n x, y = [list(i) for i in zip(*xy)]\n \n for i in range(n):\n if x[i]**2 + y[i]**2 <= d**2:\n cnt += 1\n print(cnt)\n \n \n \n \ndef __starting_point():\n main()\n__starting_point()", "import math\nN = list(map(int,input().split()))\nxy = [map(int, input().split()) for _ in range(N[0])]\nX, Y = [list(i) for i in zip(*xy)]\ncnt = 0\nfor i in range(N[0]):\n if( math.sqrt(X[i]**2 + Y[i]**2) <= N[1] ):\n cnt = cnt +1\nprint(cnt)", "n, d = list(map(int, input().split()))\nxy = [list(map(int, input().split())) for _ in range(n)]\nx, y = [list(i) for i in zip(*xy)]\n\nd_2 = d**2\nans = 0\n\nfor i in range(n):\n if d_2 >= x[i]**2 + y[i]**2:\n ans += 1\n\nprint(ans)\n", "import math\n\nN, D = map(int, input().split())\nX = []\nY = []\nfor i in range(N):\n x, y = map(int, input().split())\n X.append(x)\n Y.append(y)\nans = 0\nfor i in range(N):\n distance = math.sqrt(X[i] ** 2 + Y[i] ** 2)\n if distance <= D:\n ans += 1\nprint(ans)", "N,D = list(map(int,input().split(' ')))\n\nans = 0\nfor i in range(N):\n X,Y = list(map(int,input().split(' ')))\n if X**2 + Y**2 <= D**2:\n ans = ans + 1\n\nprint(ans)\n", "#!/usr/bin/env python3\nn, d = map(int, input().split())\nans = 0\nfor i in range(n):\n x, y = map(int, input().split())\n if d**2 >= x**2 + y**2:\n ans += 1\nprint(ans)", "import math\n\nN, D = map(int, input().split())\nans = 0\n\nfor i in range(N):\n x, y = map(int, input().split())\n ans += 1 if math.sqrt(x**2 + y**2) <= D else 0\n\nprint(ans)", "def b174(n, d, xylist):\n\n count = 0\n\n for xy in xylist:\n if (xy[0]**2 + xy[1]**2) ** 0.5 <= d:\n count += 1\n\n return count\n\ndef main():\n n, d = map(int, input().split())\n xylist = [list(map(int, input().split())) for _ in range(n)]\n print(b174(n, d, xylist))\n\ndef __starting_point():\n main()\n__starting_point()", "import math\n \ntemp = list(map(int,input().split()))\ncount = 0\n \nfor i in range(temp[0]):\n l = list(map(int,input().split()))\n if(math.sqrt(l[0]*l[0]+l[1]*l[1])<=temp[1]):\n count += 1\nprint(count)", "#ABC174 B\n\nN,D = map(int,input().split())\nimport math\ncount = 0\n\nfor i in range(N):\n X = list(map(int,input().split()))\n S = math.sqrt(X[0]**2 + X[1]**2)\n if S <= D:\n count += 1\n\nprint(count)", "n, d = map(int, input().split())\nans = 0\nfor _ in range(n):\n a, b = map(int, input().split())\n if (a**2 + b**2)**0.5 <= d:\n ans += 1\nprint(ans)", "import math\n\nN,D=map(int,input().split())\nanswer=0\n\nfor i in range(N):\n X,Y=map(int,input().split())\n distance=math.sqrt(X**2+Y**2)\n if distance<=D:\n answer+=1\nprint(answer)", "import math\ncount = 0\nn, d = list(map(int, input().split()))\nxy = [list(map(int, input().split())) for _ in range(n)]\nx, y = [list(i) for i in zip(*xy)]\nfor i in range(n):\n if math.sqrt(x[i] ** 2 + y[i] ** 2) <= d:\n count += 1\nprint(count)\n"]
{"inputs": ["4 5\n0 5\n-2 4\n3 4\n4 -4\n", "12 3\n1 1\n1 1\n1 1\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n", "20 100000\n14309 -32939\n-56855 100340\n151364 25430\n103789 -113141\n147404 -136977\n-37006 -30929\n188810 -49557\n13419 70401\n-88280 165170\n-196399 137941\n-176527 -61904\n46659 115261\n-153551 114185\n98784 -6820\n94111 -86268\n-30401 61477\n-55056 7872\n5901 -163796\n138819 -185986\n-69848 -96669\n"], "outputs": ["3\n", "7\n", "6\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
22,191
fc9172e93659ca22203bdf08e6cd2c4e
UNKNOWN
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10. Given an integer N, determine whether it is a Harshad number. -----Constraints----- - 1?N?10^8 - N is an integer. -----Input----- Input is given from Standard Input in the following format: N -----Output----- Print Yes if N is a Harshad number; print No otherwise. -----Sample Input----- 12 -----Sample Output----- Yes f(12)=1+2=3. Since 12 is divisible by 3, 12 is a Harshad number.
["N = input()\nX = int(N)\nif X % sum(list(map(int, N))) == 0:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\n\nfx = sum([int(i) for i in str(n)])\n\n\nif n % fx == 0:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = str(input())\na = []\nfor i in n:\n a.append(int(i))\nb = sum(a)\nif int(n) % b == 0:\n print('Yes')\nelse:\n print('No')", "n = input()\nm = list(n)\nm = list(map(int,m))\nif int(n) % sum(m) == 0:\n print('Yes')\nelse:\n print('No')", "def main():\n N = int(input())\n s = list(str(N))\n H = 0\n for i in range(len(s)):\n H += int(s[i])\n if N % H == 0:\n print('Yes')\n else:\n print('No')\n \nmain()\n", "a=input()\nb=int(a)\ns=0\nfor i in range(len(a)):\n s=s+int(a[i])\nif b%s==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\ns = sum(map(int, list(n)))\nprint('Yes' if int(n) % s ==0 else 'No')", "a=input()\ny=[]\nfor i in range(len(a)):\n y.append(int(a[i]))\nif int(a)%sum(y)==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nl = list(str(N))\nfx = 0\nfor i in l:\n fx += int(i)\nif N%fx == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nstrN = str(N)\n\nketa_wa = 0\n\nfor i in range(len(strN)):\n keta_wa += int(strN[i])\n \nif N % keta_wa == 0:\n print('Yes')\nelse:\n print('No')", "s = input()\nsum = 0\nfor i in s:\n sum+=int(i)\nif int(s)%sum == 0: print(\"Yes\")\nelse: print(\"No\")", "n = int(input())\ns = str(n)\nsum = 0\nfor i in range(len(s)):\n sum+=(ord(s[i])-ord('0'))\nif n%sum == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = sum(map(int, list(str(n))))\nprint('Yes' if n%a==0 else 'No')", "N = input()\n\nif int(N)%sum(int(i) for i in N) == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\n\ndef f(x):\n result = 0\n for i in range(len(x)):\n result += int(x[i])\n return result\n\nif int(N) % f(N) == 0:\n print('Yes')\nelse:\n print('No')", "N=str(input())\nf=0\nfor i in range(len(N)):\n f=f+int(N[i])\nif int(N)%f==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\nn_init = n\nm = 0\nwhile n > 0:\n m += n % 10\n n //= 10\nprint(('Yes' if n_init % m == 0 else 'No'))\n", "ipp = input()\nn = [int(x) for x in ipp]\nharshad = 0\n\nfor i in range(0, len(n)):\n harshad += n[i]\n\nif int(ipp) % harshad == 0:\n print(\"Yes\")\nelif int(ipp) % harshad != 0:\n print(\"No\")", "#ABC080B\nn = input()\nprint(\"Yes\" if int(n) %sum(map(int,n)) == 0 else \"No\")", "n = int(input())\n\nnn = str(n)\nha_num = 0\nfor i in nn:\n ha_num += int(i)\n\nif n%ha_num == 0:\n print('Yes')\nelse:\n print('No')", "a=input();print('YNeos'[int(a)%sum([int(i) for i in a])!=0::2])", "n = input()\nprint(\"No\" if int(n)%sum(map(int,n)) else \"Yes\")", "n = input()\nn_int = int(n)\n\nn_sum = 0\n\nfor s in n:\n n_sum += int(s)\n\nif(n_int%n_sum == 0):\n print(\"Yes\")\nelse:\n print(\"No\")", "n=input()\nf=0\nfor i in range(len(n)):\n f+=int(n[i])\nif int(n)%f==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nf = lambda X:sum(int(x) for x in X)\nprint(('Yes' if int(N)%f(N) == 0 else 'No'))\n", "n = input()\nn1 = len(n)\nsu = 0\nfor i in range(n1):\n su += int(n[i])\nif int(n)%su==0:\n print('Yes')\nelse:\n print('No')", "n = input()\nc = 0\nfor i in n:\n c += int(i)\nprint(\"Yes\" if int(n)%c == 0 else \"No\")", "n = input()\n\ns = 0\nfor i in range(len(n)):\n s += int(n[i])\n \nprint('Yes') if int(n) % s == 0 else print('No')", "n = list(map(str,input()))\nfn = 0\nfor i in range(len(n)):\n fn += int(n[i])\nprint(\"Yes\" if int(\"\".join(n))%fn == 0 else \"No\")", "a = input()\nx = [int(i) for i in a]\nprint(\"Yes\" if int(a) % sum(x) == 0 else \"No\")", "N = input()\nfn = 0\nfor i in N:\n fn += int(i)\n \nprint(\"Yes\" if int(N) % fn == 0 else \"No\")", "N=int(input())\nn=sum(map(int,str(N)))\nprint(\"Yes\" if N%n==0 else \"No\")", "N=int(input())\nx=str(N)\ns=0\nfor i in range(len(x)):\n s+=int(x[i])\nif N % s==0:\n ans=\"Yes\"\nelse:\n ans=\"No\"\nprint(ans)", "N = int(input())\n\nf = 0\n\nstr_N = str(N)\n\nfor i in str_N:\n f += int(i)\n\nif N % f == 0:\n print(\"Yes\")\nelse :\n print(\"No\")", "a=input()\ny=[]\nfor i in range(len(a)):\n y.append(int(a[i]))\nif int(a)%sum(y)==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nX = sum(list(map(int,list(N))))\nif int(N) % X == 0:\n print('Yes')\nelse:\n print('No')", "n = int(input())\n\ns = sum(list(map(int, str(n))))\nif n % s == 0:\n print('Yes')\nelse:\n print('No')", "n=int(input())\nx=n\nn=str(n)\nf=0\nfor i in range(len(n)):\n y=int(n[i])\n f+=y\n\nif x%f==0:\n print('Yes')\nelse:\n print(\"No\")", "N = input ()\nx = 0\nfor i in range (len (N)):\n x += int (N[i])\nif int (N)%x == 0:\n print ('Yes')\nelse:\n print ('No')", "N = int(input())\nS = str(N)\nL = len(S)\ntotal = 0\nfor i in range(L):\n total += int(S[i])\nif N % total == 0:\n ans = \"Yes\"\nelse:\n ans = \"No\"\nprint(ans)\n", "N = input()\n\nprint('No' if int(N)%sum(map(int, N)) else 'Yes')", "n = input()\nm = sum(map(int,n))\nif int(n) % m==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "# coding = SJIS\n\nn = str(input())\n\na = 0\n\nfor i in range(len(n)):\n a += int(n[i])\n\nif int(n) % a == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\nx = 0\nfor i in range(len(n)):\n x += int(n[i])\nif int(n) % x == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nif int(N) % sum(map(int, N)):\n print(\"No\")\nelse:\n print(\"Yes\")", "N = int(input())\n\nprint(\"Yes\" if N % sum(map(int, str(N))) == 0 else \"No\")", "n = int(input())\n\nf = False\n\nx = sum(list(map(int, str(n))))\n\nif n % x == 0:\n f = True\n\nif f:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\n\ndef f(x):\n return sum(list(map(int, list(n))))\n\nif int(n) % f(n) == 0:\n print('Yes')\nelse:\n print('No')", "def main():\n N = int(input())\n X = N\n sum = 0\n while True:\n amari = N%10\n sum += amari\n #print(amari,sum)\n N //= 10\n if N == 0:\n break\n\n if X%sum == 0:\n return 'Yes'\n else:\n return 'No'\n\nprint((main()))\n", "A=input()\nnu=int(A)\ntmp=sum(map(int,list(A)))\nprint(\"Yes\") if nu%tmp==0 else print(\"No\")", "n=int(input())\n\nN=n\n\nsum=int(0)\nwhile(n!=0):\n sum+=n%10\n n//=10\n\nif N%sum==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nans = 0\nfor i in range(len(N)):\n ans += int(N[i])\n\n\nif int(N) % ans == 0:\n print('Yes')\nelse:\n print('No')\n", "N=int(input())\nf=sum(list(map(int,str(N))))\n\nif N%f==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "# coding: utf-8\n\nnum = input()\ntable = list(num)\ntotal = 0\nfor i in range(len(table)):\n total += int(table[i])\n\nif int(num) % total == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "def main():\n n = int(input())\n x = sum(map(int, str(n)))\n print(\"Yes\" if n%x==0 else \"No\")\n\n\nmain()", "n=int(input())\ndef digitSum(n):\n # \u6570\u5024\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\n s = str(n)\n # \uff11\u6587\u5b57\u305a\u3064\u6570\u5024\u5316\u3057\u914d\u5217\u306b\u3059\u308b\u3002\n array = list(map(int, s))\n # \u5408\u8a08\u5024\u3092\u8fd4\u3059\n return sum(array)\nprint(\"Yes\" if n%digitSum(n)==0 else \"No\")", "n = str(input())\nsum = 0\nfor i in range(len(n)):\n sum = sum + int(n[i])\nif int(n) % sum == 0:\n print('Yes')\nelse:\n print('No')", "num = int(input())\nnum = str(num)\nn = list(map(int, num))\nS = 0\nfor i in range(len(n)):\n S += int(n[i])\n \nnum = int(num)\nif num%S==0:\n print('Yes')\nelse:\n print('No')", "N = int(input())\n\n\ndef keta_sum(N):\n if N < 10:\n return N\n else:\n return keta_sum(N // 10) + (N % 10)\n\n\nif N % keta_sum(N) == 0:\n print('Yes')\nelse:\n print('No')\n", "n = int(input())\nm = list(str(n))\nf = sum([int(m) for m in m ])\n\nprint(\"Yes\") if n%f==0 else print(\"No\")", "#harshad number \nn = int(input()) \nflag = 0 \nn_str = str(n) \nn_len = len(n_str) \nn_digit = 0 \nfor i in range(n_len):\n n_digit += int(n_str[i]) \n\nif n % n_digit == 0: \n flag = 1\n\n\n\nif flag:\n print('Yes') \nelse:\n print('No')\n", "n = input()\nans = 0\nfor i in range(len(n)):\n ans += int(n[i])\nif int(n) % ans == 0:\n print('Yes')\nelse:\n print('No')", "n = input()\nd = sum(list(map(int, n)))\n\nif int(n) % d == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\n\ns = 0\nfor i in range(len(n)):\n s += int(n[i])\nif int(n) % s == 0:\n print('Yes')\nelse:\n print('No')\n", "n = input()\nf_n = 0\nfor i in n: f_n += int(i)\nif int(n) % f_n == 0: print(\"Yes\")\nelse: print(\"No\")", "N = int(input())\nX = 0\nfor i in str(N):\n X += int(i)\n\nif N % X == 0:\n print('Yes')\nelse:\n print('No')\n", "N = int(input())\nprint('Yes' if N % sum(map(int, str(N))) == 0 else 'No')", "n = int(input())\n\ntmp, nx = 0, n\nwhile nx:\n tmp += nx%10\n nx //= 10\n \nif n % tmp:\n print(\"No\")\nelse:\n print(\"Yes\")", "S=input()\nN=int(S)\nf=sum(int(x) for x in S)\nif N%f==0:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n=input()\nf_x=0\nfor i in range(len(n)):\n f_x+=int(n[i])\nif int(n)%f_x==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\nif int(n) % sum(map(int, n)):\n print(\"No\")\nelse:\n print(\"Yes\")", "import sys\n\nNstr = sys.stdin.readline().strip()\n\ndigit_s = 0\nfor n_i in Nstr:\n digit_s += int(n_i)\n\nif int(Nstr) % digit_s == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\nfx = sum(map(int, list(str(n))))\nprint(['No', 'Yes'][int(n % fx == 0)])", "N = input()\nfX = sum([int(i) for i in list(N)])\nX = int(N)\nif X % fX == 0:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "def digitsum(n):\n return sum(list(map(int,list(str(n)))))\nN=int(input())\nif N%digitsum(N)==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\ns = sum(map(int, list(n)))\nif int(n) % s == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nprint(\"Yes\" if int(N)%sum(map(int, N))==0 else \"No\")", "n=input()\nf=0\nfor i in range(len(n)):\n f += int(n[i])\nif int(n) % f == 0:\n print('Yes')\nelse:\n print('No')", "def digitSum(k):\n if k == 0:\n return 0\n else:\n return digitSum(k//10) + k % 10\n\nN = int(input())\nif N % digitSum(N) == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "a=input();print('YNeos'[int(a)%sum(map(int,a))!=0::2])", "n=int(input())\n\nc=0\nfor i in str(n):\n c+=int(i)\nif n%c==0:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = int(input())\nif n%sum(map(int,list(str(n))))==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nf = 0\nfor num in N:\n f += int(num)\nprint('Yes' if int(N) % f == 0 else 'No')", "b=input()\nf=int(b)\n# a=input()\nc=[]\n# for i in range(b):\n# c.append(a[i])\n#a = list(map(int,input().split()))\n#b = list(map(int,input().split()))\nN = 0\nfor i in range(len(b)):\n c.append(int(b[i]))\nd = f//int(sum(c))\ne = f/int(sum(c))\n\nif d==e:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = input()\nsum_index = 0\nfor i in n:\n sum_index += int(i)\n\nif int(n) % sum_index == 0:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "def d(num):\n l=[int(x) for x in str(num)]\n return sum(l)\n \nn = int(input())\nprint(\"Yes\" if n%d(n)==0 else \"No\")", "n = input()\na = 0\nfor i in range(len(n)):\n a += int(n[i])\n\nx = int(n)\nif x % a == 0:\n print('Yes')\nelse:\n print('No')", "def findSumOfDigits(n):\n sum = 0\n while (n > 0):\n sum += n % 10\n n //= 10\n return sum\n\nans = 0\nn = int(input())\ntotal = findSumOfDigits(n)\nif n % total == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "x = input()\nfx = 0\nintx = int(x)\nfor i in range(len(x)):\n fx += int(x[i])\nif intx%fx == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "#\n# abc080 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 = \"\"\"12\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"57\"\"\"\n output = \"\"\"No\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"148\"\"\"\n output = \"\"\"No\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = input()\n s = 0\n for i in range(len(N)):\n s += int(N[i])\n if int(N) % s == 0:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "def digit_sum(num):\n total_num=0\n while num>0:\n total_num+=num % 10\n num//=10\n return total_num\n\nN=int(input())\nif N%digit_sum(N)==0 :\n print(\"Yes\")\n return\nprint(\"No\")", "N = input()\nprint(\"Yes\" if ((int(N)% sum(map(int,N)) == 0)) else \"No\")", "N = input()\nN_int = int(N)\nN_len = len(N)\nN_wa = 0\nfor i in range(N_len):\n N_wa += int(N[i])\nif N_int % N_wa == 0:\n print('Yes')\nelse:\n print('No')\n", "n = str(input())\nsum = 0\nfor i in range(0, len(n)):\n sum += int(n[i])\nn = int(n)\nif n % sum == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nprint((\"Yes\" if((int(N) % sum(map(int, N)) == 0)) else \"No\"))\n", "def is_harshad_number(x: int) -> bool:\n dividend = x\n sum_of_digits = 0\n\n for _ in range(len(str(x))):\n x, mod = divmod(x, 10)\n sum_of_digits += mod\n\n return dividend % sum_of_digits == 0\n\n\ndef answer(x: int) -> str:\n return 'Yes' if is_harshad_number(x) else 'No'\n\n\ndef main():\n x = int(input())\n print(answer(x))\n\n\ndef __starting_point():\n main()\n__starting_point()", "\ndef harshad(n):\n if n % sum(map(int, list(str(n)))) == 0:\n return True\n else:\n return False\n\nN = int(input())\nprint('Yes' if harshad(N) else 'No')", "n = input()\nfx = 0\nfor i in n:\n fx += int(i)\nif int(n) % fx == 0:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = str(input())\nsum = 0\nfor i in range(0, len(n)): sum += int(n[i])\nif int(n) % sum == 0: print(\"Yes\")\nelse: print(\"No\")", "n = input()\nprint('Yes') if int(n) % sum([int(i) for i in n]) == 0 else print('No')\n"]
{"inputs": ["12\n", "57\n", "148\n"], "outputs": ["Yes\n", "No\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
14,931
bb7fb1b7da8d02d027f0635d42f4f88c
UNKNOWN
There are N sightseeing spots on the x-axis, numbered 1, 2, ..., N. Spot i is at the point with coordinate A_i. It costs |a - b| yen (the currency of Japan) to travel from a point with coordinate a to another point with coordinate b along the axis. You planned a trip along the axis. In this plan, you first depart from the point with coordinate 0, then visit the N spots in the order they are numbered, and finally return to the point with coordinate 0. However, something came up just before the trip, and you no longer have enough time to visit all the N spots, so you decided to choose some i and cancel the visit to Spot i. You will visit the remaining spots as planned in the order they are numbered. You will also depart from and return to the point with coordinate 0 at the beginning and the end, as planned. For each i = 1, 2, ..., N, find the total cost of travel during the trip when the visit to Spot i is canceled. -----Constraints----- - 2 \leq N \leq 10^5 - -5000 \leq A_i \leq 5000 (1 \leq i \leq N) - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N A_1 A_2 ... A_N -----Output----- Print N lines. In the i-th line, print the total cost of travel during the trip when the visit to Spot i is canceled. -----Sample Input----- 3 3 5 -1 -----Sample Output----- 12 8 10 Spot 1, 2 and 3 are at the points with coordinates 3, 5 and -1, respectively. For each i, the course of the trip and the total cost of travel when the visit to Spot i is canceled, are as follows: - For i = 1, the course of the trip is 0 \rightarrow 5 \rightarrow -1 \rightarrow 0 and the total cost of travel is 5 + 6 + 1 = 12 yen. - For i = 2, the course of the trip is 0 \rightarrow 3 \rightarrow -1 \rightarrow 0 and the total cost of travel is 3 + 4 + 1 = 8 yen. - For i = 3, the course of the trip is 0 \rightarrow 3 \rightarrow 5 \rightarrow 0 and the total cost of travel is 3 + 2 + 5 = 10 yen.
["N=int(input())\nA=list(map(int,input().split()))\n\nSUM=abs(A[0])\nfor i in range(N):\n if i < N-1:\n SUM += abs(A[i+1]-A[i])\n else:\n SUM += abs(0-A[i])\n\nnow=0\nfor i in range(N):\n if i != N-1:\n diff = abs(A[i+1]-now)-abs(A[i]-now)-abs(A[i+1]-A[i])\n now = A[i]\n else:\n diff = abs(0-now)-abs(A[i]-now)-abs(0-A[i])\n print(SUM + diff)", "n = int(input())\nA = [0] + list(map(int, input().split())) + [0]\n\ncost = 0\nfor i in range(n+1):\n cost += abs(A[i] - A[i+1])\n\nfor i in range(1, n+1):\n ans = cost\n ans -= abs(A[i] - A[i-1])\n ans -= abs(A[i] - A[i+1])\n ans += abs(A[i-1] - A[i+1])\n print(ans)", "N = int(input())\nA = list(map(int,input().split()))\nA.append(0)\nA.insert(0,0)\nS = 0\n\nfor i in range(len(A)-1):\n S+=abs(A[i+1]-A[i])#\u7dcf\u30b3\u30b9\u30c8\n \nfor i in range(1,N+1):\n print((S-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1])))\n\n\n\n", "n = int(input())\na = list(map(int, input().split()))\n\nd=0\na = [0] + a + [0]\nfor j in range(len(a)-1):\n d += abs(a[j]-a[j+1])\n\nfor i in range(1, len(a)-1):\n if a[i-1] <= a[i] <= a[i+1] or a[i-1] >= a[i] >= a[i+1]:\n print(d)\n else:\n print(d - abs(a[i-1]-a[i]) - abs(a[i+1]-a[i]) + abs(a[i-1]-a[i+1]))", "N = int(input())\nA = list(map(int,input().split()))\nj = abs(A[0]) + abs(A[N-1])\nfor i in range(N-1):\n j += abs(A[i]-A[i+1])\nfor i in range(N):\n if i == 0:\n ans = j-abs(A[0])-abs(A[0]-A[1])+abs(A[1])\n elif i == N-1:\n ans = j-abs(A[N-2]-A[N-1])-abs(A[N-1])+abs(A[N-2])\n else:\n ans = j - abs(A[i]-A[i-1]) - abs(A[i]-A[i+1]) + abs(A[i-1]-A[i+1])\n print(ans)", "n = int(input())\narr = [0] + list(map(int, input().split())) + [0]\nsum_arr = sum(abs(arr[i] - arr[i+1]) for i in range(n+1))\n\nfor i in range(1, n+1):\n diff = abs(arr[i-1] - arr[i]) + abs(arr[i] - arr[i+1])\\\n - abs(arr[i-1] - arr[i+1])\n print(sum_arr - diff)", "n=int(input())\nc=list(map(int, input().split()))\nc = [0] + c + [0]\nans = 0\n\nfor i in range(n+1):\n ans += abs(c[i+1]-c[i])\n\nfor i in range(n):\n d = abs(c[i+1]-c[i])+ abs(c[i+2]-c[i+1])\n e = abs(c[i+2]-c[i])\n print(ans - d + e)", "n = int(input())\nspot = [0] + list(map(int, input().split())) + [0]\nplst = [0] * n\ndissum = 0\nfor i in range(1, n + 1):\n plst[i - 1] = (abs(spot[i + 1] - spot[i - 1])) - (abs(spot[i + 1] - spot[i]) + abs(spot[i] - spot[i - 1]))\n dissum += abs(spot[i] - spot[i - 1])\ndissum += abs(spot[n])\nfor i in range(n):\n print(dissum + plst[i])", "n=int(input())\nl=[0]+list(map(int,input().split()))+[0]\nd=[abs(a-b) for a,b in zip(l,l[1:])]\nm=sum(d)\nfor i in range(n):\n print((m+abs(l[i]-l[i+2])-(d[i]+d[i+1])))\n", "n = int(input())\na = list(map(int, input().split()))\na = [0] + a + [0]\ntnp = 0\nfor i in range(1,n+2):\n tnp += abs(a[i]-a[i-1])\nfor i in range(n):\n ans = tnp - abs(a[i+1]-a[i]) - abs(a[i+2]-a[i+1]) + abs(a[i+2]-a[i])\n print(ans)", "import sys\nimport math\nimport itertools\nimport bisect\nfrom copy import copy\nfrom collections import deque,Counter\nfrom decimal import Decimal\ndef s(): return input()\ndef i(): return int(input())\ndef S(): return input().split()\ndef I(): return map(int,input().split())\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)\nINF = 10**9\nmod = 10**9+7\n\nN = i()\nA = [0]+l()+[0]\nd = []\nfor i in range(N+1):\n d.append(abs(A[i+1]-A[i]))\nans = sum(d)\nfor i in range(N):\n print(ans+abs(A[i]-A[i+2])-d[i]-d[i+1])", "N = int(input())\nA = list(int(a) for a in input().split())\nA = [0] + A + [0]\n\ndist = [0]\nfor i in range(1, N+2):\n dist.append(abs(A[i]-A[i-1]))\n\ndist_cum = [0] * (N+2)\nfor i in range(N+1):\n dist_cum[i+1] = dist_cum[i] + dist[i+1]\n\nfor i in range(1, N+1):\n if A[i-1] < A[i] and A[i] < A[i+1]:\n print((dist_cum[-1]))\n elif A[i-1] > A[i] and A[i] > A[i+1]:\n print((dist_cum[-1]))\n else:\n tmp = dist_cum[i-1]\n tmp += dist_cum[-1] - dist_cum[i+1]\n tmp += abs(A[i+1] - A[i-1])\n print(tmp)\n", "N = int(input())\nA = list(map(int, input().split()))\nB = A[:]\nB.insert(0, 0)\nB.append(0)\n\nsum = 0\n\nfor i in range(N+1):\n sum += abs(B[i+1] - B[i])\n \nfor i in range(N):\n #\u7acb\u3061\u5bc4\u308b\n x = abs(B[i+1] - B[i]) + abs(B[i+2] - B[i+1])\n #\u7acb\u3061\u5bc4\u3089\u306a\u3044\n y = abs(B[i+2] - B[i])\n print(sum - x + y)", "n = int(input())\na = list(map(int,input().split()))\na.insert(n,0)\na.insert(0,0)\nt = 0\ntmp = 0\nfor i in range(n+1):\n t += abs(a[i+1]-a[i])\nfor i in range(1,n+1):\n tmp = t\n tmp -= abs(a[i]-a[i-1])+abs(a[i+1]-a[i])\n tmp += abs(a[i+1]-a[i-1])\n print(tmp)\n\n \n \n \n\n", "n = int(input())\na = list(map(int, input().split()))\na = [0] + a + [0]\n\nmax_fee = 0\nfor i in range(1, n + 2):\n max_fee += abs(a[i] - a[i - 1])\n\nfor i in range(1, n + 1):\n res = max_fee - abs(a[i] - a[i - 1]) - \\\n abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1])\n print(res)\n", "def main():\n n = int(input())\n inlis = list(map(int, input().split()))\n\n total = 0\n mae = 0\n\n for i in range(n):\n total += abs(inlis[i] - mae)\n mae = inlis[i]\n total += abs(inlis[-1])\n inlis.append(0)\n\n #i = 0\n if 0 <= inlis[0] and inlis[0] > inlis[1]:\n if inlis[1] >0:\n print(total - 2 * abs(inlis[1] - inlis[0]))\n else:\n print(total - 2 * abs(inlis[0]))\n elif 0 >= inlis[0] and inlis[0]< inlis[1]:\n if inlis[1] < 0:\n print(total - 2 * abs(inlis[1] - inlis[0]))\n else:\n print(total - 2 * abs(inlis[0]))\n else:\n print(total)\n\n for j in range(1, n):\n if inlis[j-1] <= inlis[j] <= inlis[j+1] or inlis[j-1]>= inlis[j] >= inlis[j+1]:\n print(total)\n elif inlis[j-1] <= inlis[j] and inlis[j] > inlis[j+1]:\n if inlis[j-1] >= inlis[j+1]:\n print(total - 2 * abs(inlis[j-1] - inlis[j]))\n else:\n print(total- 2 * abs(inlis[j+1] - inlis[j]))\n elif inlis[j-1]>= inlis[j] and inlis[j] < inlis[j+1]:\n if inlis[j-1] >= inlis[j+1]:\n print(total - 2 * abs(inlis[j+1] - inlis[j]))\n else:\n print(total - 2 * abs(inlis[j-1] - inlis[j]))\n \n\n\n\n \n\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\nX = list(map(int, input().split()))\nX.append(0)\nload = 0\nnow = 0\nfor i in range(N + 1):\n load += abs(X[i] - now)\n now = X[i]\n \n#print(load) \n\nnow = 0\nfor i in range(N):\n if now <= X[i] <= X[i + 1]:\n print(load)\n elif X[i + 1] <= X[i] <= now:\n print(load)\n else:\n ll = 2 * min(abs(X[i] - now), abs(X[i] - X[i + 1]))\n print((load - ll))\n now = X[i] \n \n \n \n \n \n\n\n\n\n\n\n", "n = int(input())\na = list(map(int, input().split()))\na = [0] + a + [0]\n\nmax_fee = 0\nfor i in range(1, n + 2):\n max_fee += abs(a[i] - a[i - 1])\n\nfor i in range(1, n + 1):\n if a[i - 1] <= a[i] <= a[i + 1] or a[i + 1] <= a[i] <= a[i - 1]:\n print(max_fee)\n else:\n res = max_fee - min(abs(a[i + 1] - a[i]) * 2, abs(a[i] - a[i - 1]) * 2)\n print(res)\n", "n = int(input())\nal = list(map(int, input().split()))\n\nres = 0\n\nal.append(0)\nal.insert(0,0)\n\nfor i in range(n+1):\n res += abs(al[i+1]-al[i])\n\nfor j in range(1,n+1):\n if (al[j+1]-al[j]) * (al[j]-al[j-1]) >= 0:\n print(res)\n else:\n print(res - min(abs(al[j+1]-al[j]),abs(al[j]-al[j-1]))*2)", "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 main():\n n = ni()\n A = nl()\n total = sum([abs(A[i + 1] - A[i]) for i in range(n - 1)])\n for i in range(n):\n if i == 0:\n start = abs(A[1])\n end = abs(A[-1])\n print((total - abs(A[1] - A[0]) + start + end))\n elif i == n - 1:\n start = abs(A[0])\n end = abs(A[-2])\n print((total - abs(A[-2] - A[-1]) + start + end))\n else:\n start = abs(A[0])\n end = abs(A[-1])\n print((total - abs(A[i - 1] - A[i]) -\n abs(A[i] - A[i + 1]) + abs(A[i + 1] - A[i - 1])\n + start + end))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nA = [0] + list(map(int,input().split())) + [0]\nB = [0] * (N+1)\ntotal = 0\nfor i in range(N+1):\n B[i] = A[i+1]-A[i]\n total += abs(B[i])\nfor i in range(N):\n print((total - (abs(B[i])+abs(B[i+1])) + abs(B[i]+B[i+1])))\n", "from copy import deepcopy\nn=int(input())\nA=list(map(int, input().split()))\nB=[0]+deepcopy(A)+[0]\ntotal=0\nb=0\nfor a in A:\n total+=abs(a-b)\n b=a\ntotal+=abs(b)\nfor i in range(1,n+1):\n z,x,c=B[i-1], B[i], B[i+1]\n print(total-abs(x-z)-abs(c-x)+abs(c-z))", "def main():\n n = int(input())\n a = list(map(int, input().split()))\n a.append(0)\n\n base = abs(a[0])\n for i in range(n):\n base += abs(a[i+1] - a[i])\n \n ans = []\n for i in range(n):\n if (a[i] - a[i-1]) * (a[i+1] - a[i]) >= 0:\n ans.append(base)\n else:\n ans.append(base - 2 * min(abs(a[i] - a[i-1]), abs(a[i+1] - a[i])))\n \n for i in ans:\n print(i)\n\nmain()", "N=int(input())\na=[0]+list(map(int,input().split()))+[0]\nsm = 0\nfor i in range(1,N+2):\n sm += abs(a[i-1]-a[i])\nfor i in range(1,N+1):\n print(sm-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1]))", "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, *A = map(int, read().split())\n\n B = [0]\n B.extend(A)\n B.append(0)\n\n M = len(B)\n\n total = 0\n for i in range(M - 1):\n total += abs(B[i + 1] - B[i])\n\n ans = [0] * N\n for i in range(N):\n ans[i] = total - abs(B[i + 1] - B[i]) - abs(B[i + 2] - B[i + 1]) + abs(B[i + 2] - B[i])\n\n print(*ans, sep='\\n')\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = [0] + list(map(int, input().split())) + [0]\n\nres = [0]*(n+1)\nfor i in range(n+1):\n res[i] = abs(a[i]-a[i+1])\n \nt = sum(res)\nfor i in range(1, n+1):\n ans = t - (res[i-1]+res[i]) + abs(a[i-1]-a[i+1])\n print(ans)", "n = int(input())\n\na = [int(i) for i in input().split()]\na.append(0)\na.insert(0,0)\n\ncost =0\nfor i in range(1,len(a)):\n cost += abs(a[i-1] - a[i])\n\nfor i in range(1,len(a)-1):\n if a[i-1] < a[i] < a[i+1]:\n ans = cost\n elif a[i-1] > a[i] > a[i+1]:\n ans = cost\n else:\n ans = cost - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1])\n print(ans)", "N=int(input())\nA=list(map(int,input().split()))\nA.append(0)\nsum=0\nfor i in range(N+1):\n if i==0:\n sum+=abs(A[0])\n else:\n sum+=abs(A[i-1]-A[i])\nfor i in range(N):\n if i==0:\n print(sum+(abs(A[1])-abs(A[1]-A[0])-abs(A[0])))\n else:\n print(sum+(abs(A[i+1]-A[i-1])-abs(A[i+1]-A[i])-abs(A[i]-A[i-1])))", "n = int(input())\na = list(map(int, input().split()))\n\ncost = abs(a[0])\nfor i in range(1,n):\n cost += abs(a[i]-a[i-1])\n#print(cost)\ncost+=abs(a[-1])\nans = [0]*n\n#print(cost)\n#ans[0] = cost - abs(a[1]-a[0])-abs(a[0])+abs(a[1])\nan = cost - abs(a[1]-a[0])-abs(a[0])+abs(a[1])\n#ans[n] = cost - abs(a[n])\nprint(an)\nfor i in range(1,n-1):\n key = cost-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])\n #ans[i] = key\n print(key)\nprint(cost-abs(a[-1])+abs(a[-2])-abs(a[-1]-a[-2]))", "n=int(input())\nA=[0]+list(map(int,input().split()))+[0]\nans = 0\nfor i in range(n+1):\n ans += abs(A[i+1]-A[i])\nfor i in range(1,n+1):\n print(ans-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+\n abs(A[i+1]-A[i-1]))", "N = int(input())\nA = [int(x) for x in input().split()]\nA.insert(0,0)\nA.append(0)\ncost = 0\nfor i in range(1,N+2):\n cost += abs(A[i]-A[i-1])\n\ndef change(i):\n nonlocal A\n return -abs(A[i+1]-A[i])-abs(A[i]-A[i-1])+abs(A[i+1]-A[i-1])\n\nfor i in range(1,N+1):\n print(cost+change(i))", "n = int(input())\na = list(map(int, input().split()))\na = [0] + a + [0]\ntotal = 0\npre = 0\n\nfor i in a:\n total += abs(i-pre)\n pre = i\n\nfor i in range(1, len(a)-1):\n print((total + abs(a[i+1]-a[i-1]) - abs(a[i]-a[i+1]) - abs(a[i]-a[i-1])))\n", "n = int(input())\nlst = list(map(int,input().split()))\n\ns = 0\ndiff_lst = []\nsign_lst = []\nfor i in lst + [0]:\n diff = i - s\n diff_lst.append(abs(diff))\n sign_lst.append(1) if diff > 0 else sign_lst.append(-1)\n s = i\n\nsu = sum(diff_lst)\nfor i in range(n):\n if sign_lst[i] * sign_lst[i+1] > 0:\n print(su)\n else:\n print(su - diff_lst[i] - diff_lst[i+1] + abs(diff_lst[i] - diff_lst[i+1]))", "n = int(input())\na = [0] + list(map(int, input().split())) + [0]\n\nnums = [0]*(n+1)\nfor i in range(1, n+2): nums[i-1] = abs(a[i] - a[i-1])\n\nans = sum(nums)\nfor i in range(1,n+1):\n print(ans - nums[i-1]-nums[i]+abs(a[i+1]-a[i-1]))", "input()\na = [0] + list(map(int, input().split())) + [0]\na = [j - i for i, j in zip(a, a[1:])]\nx = sum(abs(i) for i in a)\nfor i, j in zip(a, a[1:]):\n if i * j >= 0:\n print(x)\n else:\n print(x - 2 * (min(abs(i), abs(j))))", "N = int(input())\n*A, = map(int, input().split())\nA = [0] + A + [0]\nS = 0\nfor i in range(1, N+2):\n S += abs(A[i] - A[i-1])\nfor i in range(1, N+1):\n new = abs(A[i-1] - A[i+1])\n pre_to_now = abs(A[i-1] - A[i])\n now_to_next = abs(A[i] - A[i+1])\n print(S - pre_to_now - now_to_next + new)", "N = int(input())\nA = [0] + list(map(int, input().split())) + [0]\nS = sum(abs(A[i]-A[i+1]) for i in range(N+1))\nfor i in range(1, N+1):\n print(S-(abs(A[i]-A[i-1])+abs(A[i+1]-A[i]))+abs(A[i+1]-A[i-1]))", "n = int(input())\nlis =[0]+ list(map(int, input().split())) + [0]\n\ns = 0\nfor i in range(n+1):\n tmp= abs(lis[i]-lis[i+1])\n s += tmp\n\nfor i in range(1,n+1):\n ans = s+abs(lis[i-1] - lis[i+1]) - (abs(lis[i-1]-lis[i]) +abs(lis[i] - lis[i+1]))\n print(ans)", "n = int(input())\na = [0] + list(map(int,input().split())) + [0]\nans = 0\nfor i in range(n+1):\n ans += abs(a[i]-a[i+1])\nfor i in range(1,n+1):\n if (a[i-1] <= a[i] <= a[i+1]) or (a[i-1] >= a[i] >= a[i+1]):\n print(ans)\n else:\n print(ans-2*min(abs(a[i-1]-a[i]), abs(a[i]-a[i+1])))", "n = int(input())\na = list(map(int, input().split()))\na.append(0)\na.insert(0,0)\ns = 0\nfor i in range(len(a)-1):\n s += abs(a[i]-a[i+1])\nfor h in range(1,n+1):\n t = abs(a[h+1]-a[h-1])-abs(a[h]-a[h-1])-abs(a[h+1]-a[h])\n print(s+t)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 22 16:34:00 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nA = [0]+[int(x) for x in input().split()]+[0]\nans = 0\nfor i in range(N+1):\n ans += abs(A[i+1] - A[i])\n\nfor i in range(1,N+1):\n tmp = ans\n if A[i-1] <= A[i] <= A[i+1]:\n print(tmp)\n elif A[i-1] >= A[i] >= A[i+1]:\n print(tmp)\n else:\n tmp -= min(abs(A[i] - A[i-1]),abs(A[i+1] - A[i]))*2\n print(tmp)", "# input\nN = int(input())\nA = list(map(int, input().split()))\n\nfull_root = [0] + A + [0]\nfull_place = [abs(full_root[i] - full_root[i + 1]) for i in range(N + 1)]\nfull_res = sum(full_place)\n# check\nfor ind in range(1, N + 1):\n res = full_res - sum(full_place[ind - 1:ind + 1]) + abs(full_root[ind - 1] - full_root[ind + 1])\n\n print(res)", "N=int(input())+2\nA=[0]\nA.extend(list(map(int,input().split())))\nA.append(0)\nB=sum(abs(A[i]-A[i-1]) for i in range(1,N))\nfor i in range(1,N-1):\n print(B-abs(A[i]-A[i-1])-abs(A[i+1]-A[i])+abs(A[i+1]-A[i-1]))", "n = int(input())\na = list(map(int, input().split()))\n\ntotal = 0\nfor i in range(1,n):\n total += abs(a[i] - a[i-1])\n\ntotal += abs(a[0]) + abs(a[-1])\n\na.insert(0, 0)\na.append(0)\nfor i in range(1,n+1):\n if a[i-1] <= a[i] and a[i] <= a[i+1]:\n print(total)\n elif a[i+1] <= a[i] and a[i] <= a[i-1]:\n print(total)\n elif max(a[i-1], a[i+1]) < a[i]:\n print(total - abs(a[i] - max(a[i-1], a[i+1]))*2)\n elif a[i] < min(a[i-1], a[i+1]):\n print(total - abs(a[i] - min(a[i-1], a[i+1]))*2)", "N = int(input())\na = list(map(int, input().split()))\nA = [0] + a + [0]\n\ntotal_fee = 0\nfor i in range(N+1):\n total_fee += abs(A[i+1]-A[i])\n\nans_lst = [total_fee] * N\nfor j in range(N):\n ans_lst[j] -= abs(A[j+1]-A[j])\n ans_lst[j] -= abs(A[j+2]-A[j+1])\n ans_lst[j] += abs(A[j+2]-A[j])\n print(ans_lst[j])", "n = int(input())\na = [0] + list(map(int,input().split())) + [0]\nc = []\ntotal = 0\nfor i in range(n+1):\n tmp = abs(a[i+1] - a[i])\n c.append(tmp)\n total += tmp\n \nfor i in range(1,n+1):\n ans = total - c[i-1] - c[i] + abs(a[i+1] - a[i-1])\n print(ans)", "N = int(input())\nA = list(map(int,input().split()))\nA = [0] + A + [0]\n\ncost = [0] * (N + 2)\nfor i in range(N+1):\n cost[i] += abs(A[i+1] - A[i])\n \nsum_money = sum(cost)\n \nskip = [0] * N\nfor j in range(N):\n skip[j] += abs(A[j+2] - A[j])\n \nfor k in range(N):\n print(sum_money - (cost[k] + cost[k+1]) + skip[k])", "n = int(input())\nAs = list(map(int, input().split()))\nS = 0\nfor i in range(n-1):\n S += abs(As[i]-As[i+1])\nS += abs(As[0]) + abs(As[n-1])\nfor i in range(n):\n if i == 0:\n sb1 = abs(As[i])\n sb2 = abs(As[i]-As[i+1])\n ad = abs(As[i+1])\n elif i == n-1:\n sb1 = abs(As[i-1]-As[i])\n sb2 = abs(As[i])\n ad = abs(As[i-1])\n else:\n sb1 = abs(As[i-1]-As[i])\n sb2 = abs(As[i]-As[i+1])\n ad = abs(As[i-1]-As[i+1])\n \n ans = S - sb1 - sb2 + ad\n print(ans)\n", "n = int(input())\na = [0] + list(map(int, input().split())) + [0]\n\nnums = [0]*(n+1)\nfor i in range(n+1): nums[i] = abs(a[i]-a[i+1])\n\ntotal = sum(nums)\nfor i in range(n):\n ans = total - nums[i] - nums[i+1] + abs(a[i]-a[i+2])\n print(ans)", "import sys\nimport heapq, math\nfrom itertools import zip_longest, permutations, combinations, combinations_with_replacement\nfrom itertools import accumulate, dropwhile, takewhile, groupby\nfrom functools import lru_cache\nfrom copy import deepcopy\n\nN = int(input())\n\nA = [0] + list(map(int, input().split())) + [0]\n\nS = 0\nfor i in range(N + 1):\n S += abs(A[i] - A[i + 1])\n\nfor i in range(N):\n print((S - abs(A[i] - A[i + 1]) - abs(A[i + 1] - A[i + 2]) + abs(A[i] - A[i + 2])))\n", "import numpy as np\n\nN=int(input())\nA=np.array(list(map(int,input().split())))\nA=np.append(A,0)\nA=np.insert(A,0,0)\nS=sum(abs(np.diff(A[:])))\n\nfor i in range(1,len(A)-1):\n if A[i-1]==A[i]:\n print(S)\n elif (A[i-1]<A[i] and A[i]<A[i+1]) or (A[i-1]>A[i] and A[i]>A[i+1]):\n print(S)\n else:\n print((S-min(abs(A[i-1]-A[i]),abs(A[i]-A[i+1]))*2))\n", "n = int(input())\nA = [0]\na = list(map(int, input().split()))\nfor a_ in a:\n A.append(a_)\ns = 0\nA.append(0)\nfor i in range(n+1):\n s += abs(A[i+1]-A[i])\n\nfor i in range(1, n+1):\n print(s + abs(A[i+1]-A[i-1]) - (abs(A[i+1]-A[i]) + abs(A[i]-A[i-1])))", "def main():\n n = int(input())\n a_lst = list(map(int, input().split()))\n\n a_lst.insert(0, 0)\n a_lst.append(0)\n lst = []\n for i in range(n + 1):\n lst.append(abs(a_lst[i + 1] - a_lst[i]))\n\n tmp = sum(lst)\n tmp1 = sum(lst)\n answer_lst = []\n for i in range(n):\n for j in range(2):\n tmp1 -= lst[i + j]\n\n tmp1 += abs(a_lst[i + 2] - a_lst[i])\n answer_lst.append(tmp1)\n tmp1 = tmp\n\n for i in range(n):\n print(answer_lst[i])\n\n\ndef __starting_point():\n main()\n__starting_point()", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nfrom copy import deepcopy\ndef main():\n n, *a = map(int, read().split())\n\n if n == 2:\n r = [abs(a[1] * 2), abs(a[0] * 2)]\n print(*r, sep='\\n')\n return\n\n amin = min(a)\n # \u5168ai\u3092\u79fb\u52d5\u3059\u308b\u30b3\u30b9\u30c8\u3092\u51fa\u3059\n # \u4fbf\u5b9c\u306e\u305f\u3081\u3001a\u306e\u524d\u5f8c\u306b0\u5ea7\u6a19\u3092\u8ffd\u52a0\u3059\u308b\u3002\n a.insert(0, 0)\n a.append(0)\n # \u5358\u7d14\u5316\u306e\u305f\u3081\u3001a\u306b\u30de\u30a4\u30ca\u30b9\u5ea7\u6a19\u304c\u3042\u308b(\uff1d\u5de6\u306e\u7aef\u304c\u30de\u30a4\u30ca\u30b9)\u306a\u3089\u3001\n # \u5de6\u306e\u7aef\uff1d\u5ea7\u6a190\u306e\u30b3\u30d4\u30fc\u3092\u3064\u304f\u308b\u3002\u30de\u30a4\u30ca\u30b9\u3067\u306f\u306a\u3044\u306a\u3089\u5358\u7d14\u30b3\u30d4\u30fc\u3002\n if amin < 0:\n a2 = [i - amin for i in a] # amin\u304c\u6b63\u8ca0\u3069\u3061\u3089\u3067\u3082\u3053\u308c\u3067OK\n else:\n a2 = deepcopy(a)\n # a\u3092\u5168\u3066\u56de\u3063\u305f\u5834\u5408\u306e\u30b3\u30b9\u30c8\u3092\u51fa\u3059\n cost = 0\n for i1 in range(n + 1):\n cost += abs(a2[i1] - a2[i1 + 1])\n # r\u306b\u7b54\u3092\u683c\u7d0d\u3059\u308b\u3002a\u306e\u524d\u5f8c\u306b\uff11\u8981\u7d20\u8db3\u3057\u3066\u3044\u308b\u306e\u3067\u9577\u3055\u3092\u5408\u308f\u305b\u308b\u3002\n r = [cost] * (n + 2)\n # a[i]\u305d\u308c\u305e\u308c\u3092\u30d1\u30b9\u3059\u308b\u5834\u5408\u306e\u30b3\u30b9\u30c8\u3092\u51fa\u3059\u3002\u5834\u5408\u5206\u3051\u3059\u308b\u3002\n for j in range(1, n + 1):\n if a2[j - 1] <= a2[j] <= a2[j + 1]:\n continue\n elif a2[j - 1] >= a2[j] >= a2[j + 1]:\n continue\n elif a2[j - 1] <= a2[j] and a2[j + 1] <= a2[j]:\n nearer_dis = min(abs(a2[j - 1] - a2[j]), abs(a2[j] - a2[j + 1]))\n r[j] -= nearer_dis * 2\n else:\n nearer_dis = min(abs(a2[j] - a2[j - 1]), abs(a2[j + 1] - a2[j]))\n r[j] -= nearer_dis * 2\n print(*r[1:-1], sep='\\n')\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N=int(input())\n*A,=map(int,input().split())\n\nB=[0]+A+[0]\ncount=[0]*N\nS=abs(B[1]-0)\ni=1\nwhile i<=N:\n if B[i-1]<=B[i]<=B[i+1] or B[i-1]>=B[i]>=B[i+1]:\n count[i-1]=0\n else:\n count[i-1]=2*min(abs(B[i]-B[i-1]),abs(B[i+1]-B[i]))\n S+=abs(B[i+1]-B[i])\n i+=1\n\nfor c in count:\n print(S-c)", "n = int(input())\na = [0]+list(map(int, input().split()))+[0]\n\nnums = [0]*(n+1)\nfor i in range(n+1): nums[i] = abs(a[i]-a[i+1])\n\nt = sum(nums)\nfor i in range(1,n+1):\n ans = t - (nums[i-1]+nums[i]) + abs(a[i-1]-a[i+1])\n print(ans)", "N = int(input())\nA = list(map(int,input().split()))\nD1 = []\nD2 = []\n\nD1.append(abs(A[0]))\nD2.append(abs(A[1]))\n\nfor i in range(1,N):\n D1.append(abs(A[i]-A[i-1]))\nD1.append(abs(A[N-1]))\n\nfor i in range(1,N-1):\n D2.append(abs(A[i+1]-A[i-1]))\nD2.append(abs(A[N-2]))\n\nS = sum(D1)\n\nfor i in range(N):\n print(S-D1[i]-D1[i+1]+D2[i])", "N = int(input())\nA = [0]+list(map(int,input().split()))+[0]\nplan = 0\nfor i in range(N+1):\n plan += abs(A[i+1]-A[i])\nfor i in range(N):\n difference = abs(A[i+2]-A[i+1])+abs(A[i+1]-A[i])-abs(A[i+2]-A[i])\n print((plan-difference))\n", "n=int(input())\na=list(map(int,input().split()))\n\nsm_al=abs(a[0])+abs(a[n-1])\nfor i in range(n-1):\n sm_al+=abs(a[i+1]-a[i])\n\n#a1\u306b\u884c\u304b\u306a\u3044\u3068\u304d\nsm1=sm_al-abs(a[1]-a[0])-abs(a[0])+abs(a[1])\nprint(sm1)\n#a2-an-1\u306b\u884c\u304b\u306a\u3044\u3068\u304d\nfor i in range(1,n-1):\n sm=sm_al-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])+abs(a[i+1]-a[i-1])\n print(sm)\n#an\u306b\u884c\u304b\u306a\u3044\nsmn=sm_al-abs(a[n-1]-a[n-2])-abs(a[n-1])+abs(a[n-2])\nprint(smn)", "n = int(input())\na = list(map(int, input().split()))\n\n# 0 3 5 -1 0\n# 0 3 5 11 12\n#cum 0 3 8 14 15\n# 0 5 11 12\n# 0 3 7 8\n# 0 3 5 10\n\n# (cumi+1)-(cumi-1) - (i+1 - i-1)\n# 8-0 - 5-0\n# 14-3 - 7-3\n# 2 6 8\n# 3 2 5\n\na.insert(0,0)\na.append(0)\ndef cumulative_sum(collection):\n result = [0]\n for i in range(1, len(collection)):\n item = abs(collection[i] - collection[i-1])\n result.append(result[-1] + item)\n return result\ncuma = cumulative_sum(a)\n\nlp=cuma[-1]\n\nfor i in range(n):\n gap=abs(cuma[i+2]-cuma[i])-abs(a[i+2]-a[i])\n print(lp-gap, flush=True)\n", "n = int(input())\na = [0] + [int(x) for x in input().split()] + [0]\ndiff = [abs(a[i] - a[i + 1]) for i in range(n + 1)]\ntot = sum(diff)\nfor i in range(1, n + 1):\n print(tot - diff[i - 1] - diff[i] + abs(a[i - 1] - a[i + 1]))", "N=int(input())\nA=list(map(int,input().split()))\nA.insert(0,0)\nA.append(0)\nx=0\nfor i in range(0,N+1):\n x+=abs(A[i+1]-A[i])\nfor i in range(1,N+1):\n print((x-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1])))\n", "import sys\nimport copy\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int,input().split()))\nb = [0]\nfor i in range(N):\n b.append(A[i])\nb.append(0)\n\nsumb= 0\nfor i in range(1,len(b)):\n sumb += abs(b[i]-b[i-1])\n\nfor j in range(1,N+1):\n sumc = sumb\n sumc = sumc - abs(b[j+1]-b[j])-abs(b[j]-b[j-1])+abs(b[j+1]-b[j-1])\n print(sumc)\n\n", "# coding: utf-8\nimport sys\nimport numpy as np\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nN = ir()\nA = np.array([0] + lr() + [0])\ndiff = np.diff(A)\ntotal = np.abs(diff).sum()\nanswer = []\nfor i in range(N):\n answer.append(total - abs(diff[i]) - abs(diff[i+1]) + abs(A[i+2]-A[i]))\n\nprint(('\\n'.join(map(str, answer))))\n", "#!/usr/bin/env python3\n\nn = int(input())\na = list(map(int, input().split()))\n\na = [0] + a + [0]\n\ndiff = []\nfor i in range(1, len(a)):\n diff.append(abs(a[i-1]-a[i]))\n\nans = sum(diff)\n\n# print(diff)\nfor i in range(1, len(diff)):\n tmp = abs(a[i+1]-a[i-1])-abs(a[i]-a[i+1])-abs(a[i-1]-a[i])\n print((ans+tmp))\n", "def cost(i, j=1):\n return abs(a[i] - a[i+j])\n\nn = int(input())\na = [0] + [int(i) for i in input().split()] + [0]\n\nc = sum([cost(i) for i in range(n+1)])\nfor i in range(1, n+1):\n print(c - cost(i-1) - cost(i) + cost(i-1, 2))", "n = int(input())\nAs = list(map(int, input().split()))\nais = [0]\nais.extend(As)\nm = 0\nais.append(m)\nS = 0\nfor i in range(n-1):\n S += abs(As[i]-As[i+1])\nS += abs(As[0]) + abs(As[n-1])\nfor i in range(1,n+1):\n sb1 = abs(ais[i-1]-ais[i])\n sb2 = abs(ais[i]-ais[i+1])\n ad = abs(ais[i-1]-ais[i+1])\n \n ans = S - sb1 - sb2 + ad\n print(ans)\n", "n = int(input())\na = list(map(int,input().split())) + [0]\nb = [abs(a[0])]+[abs(a[i+1]-a[i]) for i in range(n)]\nc = [abs(a[1])]+[abs(a[i+2]-a[i]) for i in range(n-1)]\n\nhon = sum(b)\n\nfor i in range(n):\n print(hon-b[i]-b[i+1]+c[i])", "n=int(input())\na=[0]+list(map(int,input().split()))+[0]\nb=[]\nfor i in range(n+1):\n b.append(abs(a[i+1]-a[i]))\ntemp=sum(b)\n\nfor j in range(n):\n ans=temp-b[j]-b[j+1]+abs(a[j+2]-a[j])\n print(ans)\n", "import sys\n\nN = int(input())\n\nA = list(map(int, input().split()))\nA.insert(0, 0)\nA.append(0)\n\nsum = 0\nfor i in range(1, N+2):\n sum += abs(A[i]-A[i-1])\n\nfor i in range(1, N+1):\n print((sum+abs(A[i-1]-A[i+1])-abs(A[i-1]-A[i])-abs(A[i]-A[i+1])))\n", "N=int(input())\nA=list(map(int,input().split()))\nA=[0]+A+[0]\nans=0\nfor i in range(1,N+2):\n ans+=abs(A[i]-A[i-1])\nfor i in range(1,N+1):\n Z=ans\n Z-=(abs(A[i]-A[i-1])+abs(A[i]-A[i+1])-abs(A[i+1]-A[i-1]))\n print(Z)", "N = int(input())\nA = [0]+list(map(int,input().split()))+[0]\nB = [abs(a-b) for a,b in zip(A,A[1:])]\nC = sum(B)\n\nfor n in range(N):\n print(C+abs(A[n]-A[n+2])-(B[n]+B[n+1]))", "n=int(input())\na=list(map(int,input().split()))\n\nsum1=0\nfor x in range(n-1):\n sum1+=abs(a[x]-a[x+1])\n \nsum1+=abs(a[0])+abs(a[n-1])\nfor y in range(n):\n if y==0:\n print((sum1-abs(a[0])-abs(a[1]-a[0])+abs(a[1])))\n elif y==n-1:\n print((sum1-abs(a[n-1]-a[n-2])-abs(a[n-1])+abs(a[n-2])))\n else:\n print((sum1-abs(a[y]-a[y-1])-abs(a[y]-a[y+1])+abs(a[y-1]-a[y+1])))\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\ndef main():\n n = i_input()\n a = i_list()\n\n total = 0\n now = 0\n for i in a:\n total += abs(now-i)\n now = i\n total += abs(i)\n a.insert(0,0)\n a.append(0)\n\n ans = []\n\n for i,k in enumerate(a[1:-1], start=1):\n # print(i,k)\n\n if a[i-1] <= k and k <= a[i+1] or a[i-1] >= k and k >= a[i+1]:\n ans.append(total)\n else:\n ans.append(total - abs(k-a[i-1]) - abs(k-a[i+1]) + abs(a[i-1]-a[i+1]))\n\n for i in ans:\n print(i)\n\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nlsA = [0]+list(map(int,input().split()))+[0]\nsum1 = 0\nfor i in range(1,N+2):\n sum1 += abs(lsA[i]-lsA[i-1])\nlsans = []\nfor i in range(1,N+1):\n if lsA[i-1] <= lsA[i] and lsA[i] <= lsA[i+1]:\n lsans.append(sum1)\n elif lsA[i-1] >= lsA[i] and lsA[i] >= lsA[i+1]:\n lsans.append(sum1)\n else:\n div = min(abs(lsA[i-1]-lsA[i]),abs(lsA[i+1]-lsA[i]))\n lsans.append(sum1-2*div)\nfor i in lsans:\n print(i)", "N = int(input())\nA = [0]+[int(X) for X in input().split()]+[0]\nCost = sum(abs(A[T+1]-A[T]) for T in range(N+1))\nfor T in range(1,N+1):\n Cut = Cost+abs(A[T+1]-A[T-1])-abs(A[T]-A[T-1])-abs(A[T+1]-A[T])\n print(Cut)", "N = int(input())\nA = list(map(int, input().split()))\n\ncost = abs(A[0])\nfor i in range(1, N):\n cost += abs(A[i] - A[i - 1])\ncost += abs(A[N - 1])\n\nprev = 0\nA.append(0)\nfor i in range(N):\n x = abs(A[i + 1] - prev)\n y = abs(A[i] - prev) + abs(A[i + 1] - A[i])\n print(cost - (y - x))\n prev = A[i]", "n=int(input())\na=[int(i) for i in input().split()]\na.append(0)\na=[0]+a\ntotal=0\n\nfor i in range(1,n+2):\n total+=abs(a[i-1]-a[i])\n\ndef herasu(i):\n ans=total-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1])\n return ans\n\n\nfor i in range(1,n+1):\n print((herasu(i)))\n\n", "N=int(input())\nA=list(map(int,input().split()))\nA.insert(0,0)\nA.append(0)\nx=0\nfor i in range(0,N+1):\n x+=abs(A[i+1]-A[i])\nfor i in range(1,N+1):\n print(x-abs(A[i]-A[i-1])-abs(A[i]-A[i+1])+abs(A[i+1]-A[i-1]))", "N = int(input())\nA = list(map(int, input().split()))\n\nA = [0] + A + [0]\nsum_all = 0\n\nfor i, a in enumerate(A[1:N + 2], start=1):\n sum_all += abs(a - A[i - 1])\n\nfor i, a in enumerate(A[1:N + 1], start=1):\n print((sum_all - abs(a - A[i - 1]) - abs(a - A[i + 1]) + abs(A[i + 1] - A[i - 1])))\n\n", "n = int(input())\na = [int(t) for t in input().split()]\na.insert(0,0)\na.append(0)\ns = 0\nfor i in range(1,n+2):\n s += abs(a[i-1] - a[i])\nfor i in range(1,n+1):\n if a[i-1] <= a[i] <= a[i+1] or a[i-1] >= a[i] >= a[i+1]:\n print(s)\n else:\n res = s\n res -= abs(a[i-1] - a[i])\n res -= abs(a[i] - a[i+1])\n res += abs(a[i-1] - a[i+1])\n print(res)", "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)]\nd=[0]\nd=d+al\nd.append(0)\ntotald=0\nfor i in range(1,n+2):\n totald+=abs(d[i]-d[i-1])\n\nfor i in range(1,n+1):\n minus=abs(d[i]-d[i-1])+abs(d[i+1]-d[i])\n add=abs(d[i+1]-d[i-1])\n print((totald-minus+add))\n", "N=int(input())\nA=list(map(int,input().split()))\nm=[abs(0-A[0])]*(N+1)\nfor i in range(1,N):\n m[i]=abs(A[i]-A[i-1])\nm[-1]=abs(0-A[-1])\na=sum(m)\nA.append(0)\nfor i in range(N):\n print(a+abs(A[i-1]-A[i+1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1])))", "n = int(input())\na = [0] + list(map(int,input().split())) + [0]\nc = []\ntotal = 0\nfor i in range(n+1):\n tmp = abs(a[i+1] - a[i])\n c.append(tmp)\n total += tmp\n\nfor i in range(1,n+1):\n ans = total - c[i-1] - c[i] + abs(a[i+1] - a[i-1])\n print(ans)", "# -*- coding: utf-8 -*-\nimport numpy as np\nimport sys\nfrom collections import deque\nfrom collections import defaultdict\nimport heapq\nimport collections\nimport itertools\nimport bisect\n\nsys.setrecursionlimit(10**6)\ndef zz():\n return list(map(int, sys.stdin.readline().split()))\n\n\ndef z():\n return int(sys.stdin.readline())\n\n\ndef S():\n return sys.stdin.readline()\n\n\ndef C(line):\n return [sys.stdin.readline() for _ in range(line)]\n\n\nN=z()\nA = zz()\nA.append(0)\ndiff = [0]*N\nprev = 0\nA_ = [0]\nA_.extend(A)\nsum_ = 0\nfor i in range(len(A_)-1):\n sum_ += abs(A_[i] - A_[i + 1])\n \nfor i in (range(1,N+1)):\n sub = abs(A_[i]-A_[i-1]) + abs(A_[i] - A_[i+1])\n add = abs(A_[i - 1] - A_[i + 1])\n print(sum_ + add - sub)", "N = int(input())\nA = list(map(int, input().split()))\n\ntotal = abs(A[0]) + abs(A[-1])\nfor i in range(N-1):\n total += abs(A[i]-A[i+1])\n \nans = total-abs(A[0])-abs(A[0]-A[1])+abs(A[1])\nprint(ans)\nfor i in range(N-2):\n ans = total-abs(A[i]-A[i+1])-abs(A[i+1]-A[i+2])+abs(A[i]-A[i+2])\n print(ans)\nans = total-abs(A[-1])-abs(A[-1]-A[-2])+abs(A[-2])\nprint(ans)", "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 = ini()\n a = inl()\n a = [0] + a\n a.append(0)\n\n total = 0\n for i in range(1, n + 2):\n total += abs(a[i] - a[i - 1])\n for i in range(1, n + 1):\n diff = abs(a[i + 1] - a[i - 1]) - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i])\n print(total + diff)\n\n\nsolve()\n", "N = int(input())\nN_List = [0] +list(map(int,input().split())) + [0]\nN_Diff_List = []\n\nfor i in range(N+1):\n N_Diff_List.append(abs(N_List[i+1]-N_List[i]))\n\nsumans = sum(N_Diff_List)\nfor i in range(N):\n ans = sumans -(N_Diff_List[i] + N_Diff_List[i+1])\n ans += abs(N_List[i+2]-N_List[i])\n print(ans)\n", "n = int(input())\na = list(map(int, input().split()))\n\nd = [abs(a[0])]\nfor i in range(n-1):\n d.append(abs(a[i+1] - a[i]))\n\nd.append(abs(a[-1]))\n\ns = sum(d)\n\nfor i in range(n):\n if i == 0:\n t = s - d[i] - d[i+1] + abs(a[i+1])\n elif i == n-1:\n t = s - d[i] - d[i+1] + abs(-a[i-1])\n else:\n t = s - d[i] - d[i+1] + abs(a[i+1] - a[i-1])\n print(t)", "from itertools import accumulate\nN = int(input())\nA = [0] + list(map(int, input().split())) + [0]\ncost = sum(abs(A[i+1] - A[i]) for i in range(N+1))\nfor i in range(1, N+1):\n print((cost + abs(A[i+1] - A[i-1]) - abs(A[i-1] - A[i]) - abs(A[i] - A[i+1])))\n", "n = int(input())\na = list(map(int, input().split()))\na = [0] + a + [0]\n\nd_1 = []\nfor i in range(1, n+2):\n d_1.append(abs(a[i]-a[i-1]))\nd_2 = []\nfor i in range(1, n+1):\n d_2.append(abs(a[i+1]-a[i-1]))\n\ns_d = sum(d_1)\nfor i in range(1, n+1):\n print((s_d - d_1[i-1] - d_1[i] + d_2[i-1]))\n", "#!/usr/bin/env python\n\nn = int(input())\na = list(map(int, input().split()))\na = [0] + a + [0] \n\ntotal = 0 \nfor i in range(n+1):\n total += abs(a[i]-a[i+1])\n\nfor i in range(1, n+1):\n ans = total-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1])\n print(ans)\n", "n = int(input())\nspot = [0] + list(map(int, input().split())) + [0]\nmlst = []\nplst = []\ndissum = 0\nfor i in range(1, n + 1):\n mlst.append(abs(spot[i + 1] - spot[i]) + abs(spot[i] - spot[i - 1]))\n plst.append(abs(spot[i + 1] - spot[i - 1]))\n dissum += abs(spot[i] - spot[i - 1])\ndissum += abs(spot[n])\nfor i in range(n):\n print(dissum - mlst[i] + plst[i])", "def main():\n n = int(input())\n As = [0] + list(map(int, input().split())) + [0]\n\n cumsum = [0] * (n+1)\n for i in range(1, n+2):\n cumsum[i-1] = abs(As[i] - As[i-1])\n cumsum_sum = sum(cumsum)\n for i in range(1, n+1):\n ans = cumsum_sum - cumsum[i-1] - cumsum[i] + abs(As[i+1] - As[i-1])\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()"]
{"inputs": ["3\n3 5 -1\n", "5\n1 1 1 2 0\n", "6\n-679 -2409 -3258 3095 -3291 -4462\n"], "outputs": ["12\n8\n10\n", "4\n4\n4\n2\n4\n", "21630\n21630\n19932\n8924\n21630\n19288\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
36,784
0fa7752843cd9f7b8506842cb5c7195f
UNKNOWN
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: a, e, i, o and u. -----Constraints----- - c is a lowercase English letter. -----Input----- The input is given from Standard Input in the following format: c -----Output----- If c is a vowel, print vowel. Otherwise, print consonant. -----Sample Input----- a -----Sample Output----- vowel Since a is a vowel, print vowel.
["c = input()\n\nvo = ['a','e','i','o','u']\nprint('vowel' if c in vo else 'consonant')", "\nc = str(input())\nvowels = ['a','e','i','o','u']\n\nif c in vowels:\n answer = \"vowel\"\nelse:\n answer = \"consonant\"\n\nprint(answer)\n", "C = input()\nif C in 'aiueo':\n print('vowel')\nelse:\n print('consonant')", "s = input()\nif s == 'a' or s == 'i' or s == 'u' or s == 'e' or s == 'o':\n print('vowel')\nelse:\n print('consonant')", "N = input()\nif N in \"aiueo\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "str = input()\nprint((\"vowel\" if str == \"a\" or str == \"i\" or str == \"u\" or str == \"e\" or str == \"o\" else \"consonant\"))\n", "p=[\"consonant\",\"vowel\"]\na=input()\nb=\"aeiou\"\nprint(p[a in b])", "c = str(input())\nboin = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n\nif c in boin:\n print(\"vowel\")\nelse:\n print(\"consonant\")", "alpha=input()\nb=\"a,i,u,e,o\"\n\nprint(\"vowel\" if alpha in b else \"consonant\")", "C =str(input())\n\nif C == 'a' or C == 'i' or C == 'u' or C == 'e' or C == 'o':\n print('vowel')\nelse:\n print('consonant')", "c=input()\nl=['a','i','u','e','o']\nif c in l:print('vowel')\nelse:print('consonant')", "print('vowel' if input() in {'a','i','u','e','o'} else 'consonant')", "c = input()\nvowel = ['a', 'i', 'u', 'e', 'o']\nif c in vowel:\n print('vowel')\nelse:\n print('consonant')\n", "v = ['a', 'i', 'u', 'e', 'o']\nif input() in v:\n print('vowel')\nelse:\n print('consonant')", "c = input()\nprint(['consonant','vowel'][c in ['a','i','u','e','o']])", "# \u6587\u5b57\u3092\u53d6\u5f97\nc = str(input())\nv_list = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n\n# \u6bcd\u97f3\u306a\u306e\u304b\u3092\u78ba\u8a8d\u3057\u7d50\u679c\u3092\u51fa\u529b\nif c in v_list:\n print(\"vowel\")\nelse:\n print(\"consonant\")", "def main():\n c = input()\n boin = ['a','e','i','o','u']\n print('vowel') if c in boin else print('consonant')\n\ndef __starting_point():\n main()\n\n__starting_point()", "c=input()\nli=[\"a\",\"e\",\"i\",\"u\",\"o\"]\nif c in li:\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c = input()\n\nlists = ['a', 'e', 'i', 'u', 'o']\nanswer = 'consonant'\n\nfor i in lists:\n if c == i:\n answer = 'vowel'\n\nprint(answer)", "c = str(input())\n\nif c == 'a':\n print('vowel')\n\nelif c == 'i':\n print('vowel')\n\n\nelif c == 'u':\n print('vowel')\n\n\nelif c == 'e':\n print('vowel')\n\n\nelif c == 'o':\n print('vowel')\n\nelse:\n print('consonant')", "c = input()\n\nif c == \"a\" or c == \"i\" or c == \"u\" or c == \"e\" or c == \"o\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c=input()\nif c==\"a\" or c==\"e\" or c==\"i\" or c==\"o\" or c==\"u\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "C = input()\nvowel = [\"a\",\"i\",\"u\",\"e\",\"o\"]\n\nif C in vowel:\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c = input()\nif c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o':\n print('vowel')\n\nelse:\n print('consonant')", "print(\"vowel\" if input() in \"aeiou\" else \"consonant\")", "c = input()\nif c in ['a', 'e', 'i', 'o', 'u']:\n print('vowel')\nelse:\n print('consonant')", "c = input()\nif c in ['a', 'e', 'i', 'o', 'u']:\n print('vowel')\nelse:\n print('consonant')", "c = input()\nif c in \"aiueo\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c = input()\nif c[0] == \"a\" or c[0] == \"i\" or c[0] == \"u\" or c[0] == \"e\" or c[0] == \"o\":\n print(\"vowel\")\nelse:\n print(\"consonant\")\n", "s = input()\naiueo = [\"a\",\"i\",\"u\",\"e\",\"o\"]\nif s in aiueo:\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c=input()\nprint(\"vowel\" if c in [\"a\",\"e\",\"i\",\"o\",\"u\"] else \"consonant\")", "x = input()\n\nif x in [\"a\",\"i\",\"u\",\"e\",\"o\"]:\n print(\"vowel\")\nelse:\n print(\"consonant\")", "word = input()\nvowel_list = ['a', 'i', 'u', 'e', 'o']\n\nif word in vowel_list:\n print('vowel')\nelse:\n print('consonant')", "c = str.lower(input())\n\ndef answer(c: str) -> str:\n n = ('a', 'e', 'i', 'o', 'u')\n\n if c in n:\n return 'vowel'\n else:\n return 'consonant'\n\nprint((answer(c)))\n", "x = input()\nif x in \"aiueo\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c=input()\nboin=[\"a\",\"e\",\"i\",\"o\",\"u\"]\nif c in boin:\n print(\"vowel\")\nelse:\n print(\"consonant\")", "# A - \u5c45\u5408\u3092\u7d42\u3048\u3001\u9752\u3044\u7d75\u3092\u8986\u3046\n# https://atcoder.jp/contests/abc049/tasks/abc049_a\n\nc = input()\n\nvowel = ['a', 'e', 'i', 'o', 'u']\n\nif c in vowel:\n print('vowel')\nelse:\n print('consonant')\n", "def iroha():\n letter = input()\n vols = [\"a\", \"i\", \"u\", \"e\", \"o\"]\n\n for elm in vols:\n if elm == letter:\n print(\"vowel\")\n return\n \n print(\"consonant\")\n \n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "c = input()\nvowel = {'a', 'i', 'u', 'e', 'o'}\nif c in vowel:\n print('vowel')\nelse:\n print('consonant')\n", "# A - \u5c45\u5408\u3092\u7d42\u3048\u3001\u9752\u3044\u7d75\u3092\u8986\u3046\n\nboin = ('a', 'e', 'i', 'o', 'u')\n\nc = input()\n\nif c in boin:\n print('vowel')\nelse:\n print('consonant')\n", "c = input()\nif c == \"a\" or c == \"e\" or c == \"i\" or c == \"o\" or c == \"u\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "if input() in {\"a\",\"i\",\"u\",\"e\",\"o\"}:\n print(\"vowel\")\nelse:\n print(\"consonant\")\n", "a = input()\nif('a' == a or 'e' == a or 'i' == a or 'o' == a or 'u' == a):\n print(\"vowel\")\nelse:\n print(\"consonant\") ", "c = str(input())\nif c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o':\n print('vowel')\nelse:\n print('consonant')", "a = input()\n\nif a in 'aiueo':\n\tprint('vowel')\nelse:\n\tprint('consonant')", "c = input()\nL = ['a', 'e', 'i', 'o', 'u']\nif c in L:\n print('vowel')\nelse:\n print('consonant')\n", "def solve():\n c = input()\n vowel = ['a', 'e', 'i', 'o', 'u']\n if c in vowel:\n print('vowel')\n else:\n print('consonant')\n\n\ndef __starting_point():\n solve()\n__starting_point()", "'''\n\u554f\u984c\uff1a\n \u82f1\u5c0f\u6587\u5b57 c\u304c\u4e0e\u3048\u3089\u308c\u308b\u306e\u3067\u3001c \u304c\u6bcd\u97f3\u3067\u3042\u308b\u304b\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n \u3053\u3053\u3067\u3001\u82f1\u5c0f\u6587\u5b57\u306e\u3046\u3061\u6bcd\u97f3\u306f a\u3001e\u3001i\u3001o\u3001u\u306e 5\u3064\u3067\u3059\u3002\n'''\n\n'''\n\u5236\u7d04\uff1a\n c\u306f\u82f1\u5c0f\u6587\u5b57\u3067\u3042\u308b\u3002\n'''\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 c \u3092\u53d6\u5f97\u3059\u308b\nc = str(input())\n\nvowel_words = ('a', 'e', 'i', 'o', 'u')\n\nresult = 'ret'\nif c in vowel_words:\n result = 'vowel'\nelse:\n result = 'consonant'\n\nprint(result)\n", "a = input()\nif a =='a' or a == 'e' or a == 'i' or a == 'o' or a == 'u':\n print('vowel')\nelse:\n print('consonant')", "c = input()[0]\naiueo = \"aiueo\"\nif c in aiueo:\n print(\"vowel\")\nelse:\n print(\"consonant\")\n", "c = str(input())\n\nif c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':\n print('vowel')\nelse:\n print('consonant')", "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############################################################\nprint(('vowel' if si() in 'aiueo' else 'consonant'))\n", "c = input()\nif c == \"a\" or c == \"e\" or c == \"i\" or c == \"o\" or c == \"u\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "a=input()\nif a=='a' or a=='i' or a=='u' or a=='e' or a=='o':print(\"vowel\")\nelse:print(\"consonant\")", "c = str(input())\n\nif c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':\n print('vowel')\nelse:\n print('consonant')", "c = str(input())\n\nif c in 'aeiou':\n print('vowel')\nelse:\n print('consonant')", "c = input()\n\n# \u82f1\u5c0f\u6587\u5b57 c \u304c\u4e0e\u3048\u3089\u308c\u308b\u306e\u3067\u3001c\u304c\u6bcd\u97f3\u3067\u3042\u308b\u304b\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n# c \u304c\u6bcd\u97f3\u3067\u3042\u308b\u3068\u304d\u3001vowel \u3068\u3001\u305d\u3046\u3067\u306a\u3044\u3068\u304d consonant \u3068\u51fa\u529b\u305b\u3088\u3002\n\nif c in (\"a\", \"e\", \"i\", \"o\", \"u\"):\n print(\"vowel\")\nelse:\n print(\"consonant\")", "\"\"\"\nABC049 A - \u5c45\u5408\u3092\u7d42\u3048\u3001\u9752\u3044\u7d75\u3092\u8986\u3046\nhttps://atcoder.jp/contests/abc049/tasks/abc049_a\n\"\"\"\n\nc = input()\nboin = ['a', 'e', 'i', 'o', 'u']\nif c in boin:\n print('vowel')\nelse:\n print('consonant')\n", "a = input()\nif a in \"aiueo\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "v = ['a', 'e', 'i', 'o', 'u']\ns = input()\nprint('vowel' if s in v else 'consonant')", "c = input()\nif c == 'a':\n print('vowel')\nelif c == 'i':\n print('vowel')\nelif c == 'u':\n print('vowel')\nelif c == 'e':\n print('vowel')\nelif c == 'o':\n print('vowel')\n\nelse:\n print('consonant')\n", "c = (input())\nlist =['a','i','u','e','o']\nif c in list:\n print('vowel')\nelse:\n print('consonant')", "c = input()\nif c == \"a\" or c == \"i\" or c == \"u\" or c == \"e\" or c == \"o\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c = input()\n# \u6bcd\u97f3\u306e\u30ea\u30b9\u30c8\nvowel = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n# \u30ea\u30b9\u30c8\u306b\u5165\u529b\u5024\u304c\u3042\u3063\u305f\u3089\"vowel\"\u3068\u51fa\u529b\nif c in vowel:\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c = input()\nboin = [\"a\",\"e\",\"i\",\"o\",\"u\"]\nprint(\"vowel\" if c in boin else \"consonant\")", "# c\u304c\u6bcd\u97f3\u3067\u3042\u308b\u304b\u5224\u5b9a\u3059\u308b\u3002\n# \u6bcd\u97f3\u306fa,e,i,o,u\u306e\uff15\u3064\nc = input('')\n\nvowels = ['a', 'e', 'i', 'o', 'u']\n\nif c in vowels:\n print('vowel')\nelse:\n print('consonant')", "x=input()\n\nif(x == \"a\") | (x == \"i\") | (x == \"u\") | (x == \"e\") | (x == \"o\"):\n print(\"vowel\")\nelse:\n print(\"consonant\")", "s = input()\nif s == \"a\" or s == \"i\" or s == \"u\" or s == \"e\" or s == \"o\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "if input('') in ['a', 'e', 'i', 'o', 'u']:\n print('vowel')\nelse:\n print('consonant')", "name = input()\n\nif name == 'a' or name == 'e' or name == 'i' or name == 'o' or name == 'u':\n print('vowel')\nelse:\n print('consonant')", "\n\nc = input()\n\nif c == \"a\":\n print(\"vowel\")\nelif c == \"i\":\n print(\"vowel\")\nelif c == \"u\":\n print(\"vowel\")\nelif c == \"e\":\n print(\"vowel\")\nelif c == \"o\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c = input()\nprint(\"vowel\" if c in [\"a\", \"e\", \"i\", \"o\", \"u\"] else \"consonant\")", "# \u6bcd\u97f3\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3059\u308b\n\nc = input()\n\nvowel = [\"a\", \"e\", \"i\", \"o\", \"u\"]\n\nif c in vowel:\n print(\"vowel\")\nelse:\n print(\"consonant\")\n", "s = input()\nif s in \"aiueo\":\n print(\"vowel\")\nelse:\n print(\"consonant\")\n", "c = str(input())\nif c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o':\n print('vowel')\nelse:\n print('consonant')", "c = input()\nif c in \"aeiou\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "print('vowel' if input() in 'aiueo' else 'consonant')", "# 049a\n\ndef atc_049a(c: str) -> str:\n if c == \"a\" or c == \"e\" or c == \"i\" or c == \"o\" or c == \"u\":\n return \"vowel\"\n else:\n return \"consonant\"\n\nc = input()\nprint((atc_049a(c)))\n", "c=str(input())\n\nif c=='a' or c=='i' or c=='u' or c=='e' or c=='o':\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c = str(input())\n\nif c == \"a\" or c == \"i\" or c == \"u\" or c == \"e\" or c == \"o\":\n print(\"vowel\")\nelse:\n print(\"consonant\")", "c = input()\n\nif c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':\n print('vowel')\nelse:\n print('consonant')", "a = input()\n\nif a == 'a' or a == 'i' or a == 'u' or a == 'e' or a == 'o':\n\tprint('vowel')\nelse:\n\tprint('consonant')", "s = input()\naiueo = [\"a\", \"i\", \"u\", \"e\", \"o\"]\nif s in aiueo:\n print(\"vowel\")\nelse:\n print(\"consonant\")", "vowels = [\"a\", \"i\", \"u\", \"e\", \"o\"]\nc = input()\nprint(\"vowel\" if c in vowels else \"consonant\")", "c = input()\ncorrect = [\"a\", \"i\", \"u\", \"e\", \"o\"]\nif c in correct:\n print(\"vowel\")\nelse:\n print(\"consonant\")\n", "v = 'aiueo'\nif input() in v:\n print('vowel')\nelse:\n print('consonant')", "c = str(input())\nvowels = ['a','e','i','o','u']\nif c in vowels:\n answer = 'vowel'\nelse:\n answer = 'consonant'\nprint(answer)", "c = (input())\nlist =['a','i','u','e','o']\nif c in list:\n print('vowel')\nelse:\n print('consonant')", "c = str(input())\n\nif c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':\n print('vowel')\n \nelse:\n print('consonant')", "X = input()\n\nif X in ('a', 'e', 'i', 'o', 'u'):\n print('vowel')\nelse:\n print('consonant')\n", "# \u82f1\u5c0f\u6587\u5b57 c \u304c\u4e0e\u3048\u3089\u308c\u308b\u306e\u3067\u3001 c \u304c\u6bcd\u97f3\u3067\u3042\u308b\u304b\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u3053\u3053\u3067\u3001\u82f1\u5c0f\u6587\u5b57\u306e\u3046\u3061\u6bcd\u97f3\u306f a\u3001e\u3001i\u3001o\u3001u\u306e 5 \u3064\u3067\u3059\u3002\n\nc = input()\nif c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':\n print('vowel')\nelse:\n print('consonant')", "word = input()\nif word == 'a':\n print('vowel')\nelif word == 'i':\n print('vowel')\nelif word == 'u':\n print('vowel')\nelif word == 'e':\n print('vowel')\nelif word == 'o':\n print('vowel')\nelse:\n print('consonant')", "#49\nmoji=input()\nboin=['a','e','i','o','u']\nif (moji==boin[0] or moji==boin[1] or moji==boin[2] or moji==boin[3] or moji==boin[4]):\n print('vowel')\nelse:\n print('consonant')", "# 049_a\nc=input()\nif c=='a' or c=='i' or c=='u' or c=='e' or c=='o':\n print('vowel')\nelse:\n print('consonant')", "c = input()\nlist01 = ['a', 'e', 'i', 'o', 'u']\nif c in list01:\n print('vowel')\nelse:\n print('consonant')", "a = input()\nif a == 'a'or a == 'e' or a =='i' or a == 'o' or a =='u':\n print('vowel')\nelse:\n print('consonant')", "s = input()\nif s in ['a', 'i', 'u', 'e', 'o']:\n print('vowel')\nelse:\n print('consonant')", "def atc_049a(c: str) -> str:\n if c == \"a\" or c == \"e\" or c == \"i\" or c == \"o\" or c == \"u\":\n return \"vowel\"\n else:\n return \"consonant\"\n\nc = input()\nprint(atc_049a(c))", "c = input()\nboin = 'aeiou'\nif boin.find(c) == -1:\n print(\"consonant\")\nelse:\n print(\"vowel\")"]
{"inputs": ["a\n", "z\n", "s\n"], "outputs": ["vowel\n", "consonant\n", "consonant\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
15,339
6c2308af1c9a8ad5801789c9164102cb
UNKNOWN
Two foxes Jiro and Saburo are playing a game called 1D Reversi. This game is played on a board, using black and white stones. On the board, stones are placed in a row, and each player places a new stone to either end of the row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is B, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is W, it means that the color of the corresponding stone is white. Jiro wants all stones on the board to be of the same color. For this purpose, he will place new stones on the board according to the rules. Find the minimum number of new stones that he needs to place. -----Constraints----- - 1 ≦ |S| ≦ 10^5 - Each character in S is B or W. -----Input----- The input is given from Standard Input in the following format: S -----Output----- Print the minimum number of new stones that Jiro needs to place for his purpose. -----Sample Input----- BBBWW -----Sample Output----- 1 By placing a new black stone to the right end of the row of stones, all white stones will become black. Also, by placing a new white stone to the left end of the row of stones, all black stones will become white. In either way, Jiro's purpose can be achieved by placing one stone.
["s= input()\ncolor = \"chokudai\"\nd = []\n\nfor c in s:\n if c != color:\n d.append(c)\n color = c\nprint(len(d)-1)", "s = input()\ncnt = 1\ncw = s[0]\nfor i in range(len(s)):\n if s[i] != cw: \n cnt += 1\n cw = s[i]\nprint(cnt - 1)", "S = str(input())\nSum = 0 \nfor i in range(len(S) - 1):\n if S[i] != S[i + 1]:\n Sum += 1\n\nprint(Sum)", "s = input()\nprint((sum((s[i] != s[i+1] for i in range(len(s)-1)))))\n", "s=input()\nans=0\nfor i in range(len(s)-1):\n if s[i]!=s[i+1]:\n ans+=1\nprint(ans)\n", "s = input()\ntmp = s[0]\ncnt = 0\nfor c in s:\n if tmp != c:\n tmp = c\n cnt += 1\nprint(cnt)", "S = list(input())\ncount = 0\nt = ''\nfor i in S:\n if t == i:\n continue\n else:\n t = i\n count += 1\nprint(count - 1)", "s=input()\n\ncolor = s[0]\nresult = 0\nfor i in range(len(s)):\n if color != s[i]:\n result += 1\n color = s[i]\nprint(result)", "S = input()\ncount = 0\nfor i in range(len(S)-1):\n if S[i] != S[i+1]:\n count += 1\nprint(count)", "s=list(input())\ntmp=0\nfor i in range(1,len(s)):\n if s[i-1] != s[i]:\n tmp+=1\nprint(tmp)", "S = input()\n#0\u56de\u5224\u5b9a\nx = len(S)\nif S.count(\"B\") == x or S.count(\"W\") == x:\n print(0)\n return\n\n\n\ncntw=0\nfor s in S.split(\"W\"):\n if s:\n cntw += 1\ncntb=0\nfor s in S.split(\"B\"):\n if s:\n cntb += 1\nprint(abs(cntb - cntw) + min(cntb, cntw) * 2 - 1)", "def main():\n S = input()\n ans = 0\n for i, s in enumerate(S):\n if i == 0:\n t = s\n continue\n if t == s:\n continue\n else:\n ans += 1\n t = s\n print(ans)\n \ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\nans = 0\nfor i in range(len(s)-1):\n if s[i] != s[i+1]:\n ans += 1\nprint(ans)", "s = input()\ncnt = 0\nfor i in range(1, len(s)):\n if s[i] != s[i-1]:\n cnt += 1\nprint(cnt)", "def main():\n s = str(input())\n b_count = s.count('B')\n w_count = len(s) - b_count\n\n if b_count == len(s) or w_count == len(s):\n count = 0\n else:\n count = 0\n index = 0\n alp = s[index]\n\n while True:\n if b_count == 0 or w_count == 0:\n break\n else:\n if s[index] == 'B':\n b_count -= 1\n else:\n w_count -= 1\n\n if s[index] == alp:\n index += 1\n else:\n count += 1\n alp = s[index]\n index += 1\n\n if not (b_count == 0 and w_count == 0):\n count += 1\n\n print(count)\n\n\ndef __starting_point():\n main()\n__starting_point()", "S=input()\nprint(S.count(\"BW\")+S.count(\"WB\"))", "s=input()\nc=0\nt=s[0]\nfor k in s[1:]:\n if t!=k:\n t=k\n c+=1\nprint(c)\n", "S = input()\ncnt = 0\nnow = S[0]\n\nfor i in S:\n if i != now:\n now = i\n cnt += 1\nprint(cnt)", "S = input()\nprev = S[0]\ncnt = 0\nfor s in S:\n if prev != s:\n cnt += 1\n prev = s\nprint(cnt)", "S = input()\nans = 0\n\nfor i in range(len(S)-1):\n if S[i] != S[i+1]:\n ans += 1\n\nprint(ans)", "s = input()\ncnt = 0\nfor i in range(1,len(s)):\n if s[i] != s[i-1]: \n cnt += 1\nprint(cnt)", "s = input()\nc = s[0]\nans = 0\nfor i in range(1, len(s)):\n if c != s[i]:\n ans += 1\n c = s[i]\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())\nS = input()\nans = 0\nfor i in range(len(S)-1):\n if S[i+1] != S[i]:\n ans += 1\nprint(ans)\n", "S = input()\nl = len(S)\nans = sum(a != b for a,b in zip(S[:l-1],S[1:]))\nprint(ans)", "from collections import Counter\nS = input()\n\nc = Counter(S)\nif c['W'] == 0 or c['B'] == 0:\n print((0))\n return\n\nnow = ''\ncount = 0\nfor i in range(len(S)):\n if i == 0:\n now = S[i]\n continue\n if now == S[i]:\n continue\n else:\n count += 1\n now = S[i]\n continue\n\nprint(count)\n", "s = list(input())\nans = 0\nfor i in range(1, len(s)):\n if s[i] != s[i-1]:\n ans += 1\nprint(ans)", "s = input()\ncount = 0\nfor i in range(len(s)-1):\n if s[i] != s[i+1]:\n count += 1\nprint(count)", "S = input()\n\nls = [\"WB\", \"BW\"]\n\ncnt = 0\nif S[0] == \"W\":\n i = 0\nelse:\n i = 1\n\nfor j in range(len(S)-1):\n if i == 0 and S[j:j+2] == \"WB\":\n cnt += 1\n i = 1\n if i == 1 and S[j:j+2] == \"BW\":\n cnt += 1\n i = 0\n \nprint(cnt)", "s = input()\nans = 0\nfor i in range(1, len(s)):\n if s[i] != s[i - 1]:\n ans += 1\nprint(ans)", "prev = '0'\nS = ''\nfor c in input():\n if c != prev:\n S += c\n prev = c\nprint(len(S) - 1)", "s = list(input())\nn = len(s)\nb = False\nif s[0] == \"B\":\n b = True\n\nans = 0\nfor i in range(1, n):\n if b and s[i] == \"W\":\n b = False\n ans += 1\n elif not b and s[i] == \"B\":\n b = True\n ans += 1\nprint(ans)", "s=input()\ncount=0\nfor i in range(1,len(s)):\n if s[i-1]!=s[i]:\n count+=1\nprint(count)\n", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 30 02:12:31 2020\n\n@author: liang\n\"\"\"\n\nS = input()\nans = 0\nfor i in range(len(S) - 1):\n if S[i] != S[i+1]:\n ans += 1\n\nprint(ans)", "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 = s_input()\n ans = 0\n trial = s[0]\n for i in s[1:]:\n if trial != i:\n ans += 1\n trial = i\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "S = input()\nc = 0\n\nbs = '_'\nfor s in S:\n if s != bs:\n c += 1\n bs = s\n\nprint(c - 1)", "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\n \ndef iparse():\n return list(map(int, input().split()))\n\ndef RLE(s):\n res = []\n prev = \"\"\n cnt = 0\n for e in s:\n if prev == \"\":\n prev = e\n cnt += 1\n elif prev == e:\n cnt += 1\n else:\n res.append((cnt,prev))\n prev = e\n cnt = 1\n res.append((cnt,prev))\n return res\n\n\ndef __starting_point():\n s = input()\n rle = RLE(s)\n # print(rle)\n print(len(rle)-1)\n__starting_point()", "s = input()\ncounter = 0\n\nfor i in range(1, len(s)):\n if s[i] != s[i - 1]:\n counter += 1\n\nprint(counter)\n", "from itertools import groupby\ns = input()\ncount = 0\nfor k, g in groupby(s):\n count += 1\nprint(count - 1)", "s=input()\nans=[]\npre=\"\"\nfor i in s:\n if pre!=i:\n ans.append(i)\n pre=i\n\nprint(len(ans)-1)", "S = input()\n\ns = S.replace('WB', 'W B').replace('BW', 'B W')\ns = list(s.split())\nprint(len(s) -1)", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tC\n# CreatedDate: 2020-10-09 16:08:34 +0900\n# LastModified: 2020-10-09 16:19:59 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\nfrom itertools import groupby\n\n\ndef main():\n S = input()\n sgroup = groupby(S)\n for cnt, (key, group) in enumerate(sgroup):\n pass\n print(cnt)\n\n\n\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import sys\n\ninput = sys.stdin.readline\nS = input()\nS = S.replace('\\n' , '')\ntmp = \"\"\ndivision_count = 0\nfor s in S:\n if tmp == \"\":\n tmp = s\n continue\n if tmp == s:\n continue\n else:\n tmp = s\n division_count += 1\nprint(division_count)", "prev = '0'\nans = -1\nfor c in input():\n if c != prev:\n ans += 1\n prev = c\nprint(ans)", "s = input()\ncnt = 0\nfor i in range(len(s)-1):\n if s[i+1] != s[i]:\n cnt += 1\nprint(cnt)", "from itertools import groupby\nprint(len(list(groupby(input())))-1)", "s = input()\nprint(s.count(\"BW\")+s.count(\"WB\"))", "from itertools import groupby\n\ns = input()\n\ncnt = 0\n\nfor k, g in groupby(s):\n cnt += 1\n\nprint((cnt - 1))\n", "s = input()\nif len(s) == 1:\n print(0)\nelse:\n cnt = 0\n for i in range(len(s)-1):\n if s[i] != s[i+1]:\n cnt += 1\n\n print(cnt)", "a=input()+\"p\"\nb=0\ni=1\nc=a[0]\nwhile a[i]!=\"p\":\n if a[i]!=c:\n c=a[i]\n b+=1\n i+=1\nprint(b)", "S=input()\nN=len(S)\n\ncount=0\nfor i in range(N-1):\n if S[i]!=S[i+1]:\n count+=1\n\nprint(count)\n", "S = input()\nans = 0\nfor i in range(1,len(S)):\n if S[i] != S[i-1]:\n ans += 1\nprint(ans)", "def main():\n *S, = input()\n c = S.pop()\n ans = 0\n while S:\n if (nc := S.pop()) == c:\n continue\n c = nc\n ans += 1\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "#!/usr/bin/env python\n\ns = input()\nans = 0 \nfor i in range(len(s)-1):\n if s[i+1] != s[i]:\n ans += 1\nprint(ans)\n", "s = list(input())\n\ncount = 0\nfor i in range(len(s) - 1):\n if s[i] != s[i + 1]:\n count += 1\n\nprint(count)", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(S: str):\n S = [s1 for s0, s1 in zip(S, S[1:]+\".\") if s0 != s1]\n return len(S) - 1\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=list(input())\ncnt=0\nbf=s[0]\nfor i in s[1:]:\n if i!=bf:\n cnt+=1\n bf=i\nprint(cnt)", "s=input()\nn=len(s)\nans=0\nfor i in range(n-1):\n if s[i]==s[i+1]:\n continue\n else:\n ans+=1\nprint(ans)", "s = input()\nans = 0\np = s[0]\nfor si in s:\n ans += p != si\n p = si\nprint(ans)", "S=input()\nans=0\nN=len(S)\nnow=S[0]\nfor i in range(1,N):\n if now!=S[i]:\n now=S[i]\n ans+=1\nprint(ans)", "#81 C - \u4e00\u6b21\u5143\u30ea\u30d0\u30fc\u30b7\nS = input()\nS = S + '1'# \u756a\u5175\n\n# \u9023\u7d9a\u3059\u308b\u6587\u5b57\u3092\u30ab\u30a6\u30f3\u30c8\ncnt = []\nconti = 1\nfor i in range(1,len(S)):\n if S[i-1] == S[i]:\n conti += 1\n else:\n cnt.append(conti)\n conti = 1\nprint(len(cnt)-1)", "s = input()\na = 0\nfor i in range(len(s) - 1):\n if s[i] != s[i + 1]:\n a += 1\nprint(a)\n", "#\n# abc047 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 = \"\"\"BBBWW\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"WWWWWW\"\"\"\n output = \"\"\"0\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"WBWBWBWBWB\"\"\"\n output = \"\"\"9\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n S = list(input())\n\n i = 1\n while i < len(S):\n if S[i] == S[i-1]:\n del S[i]\n else:\n i += 1\n\n print((len(S)-1))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "s = input()\ntemp = s[0]\nans = 0\nfor l in s:\n if temp!=l:\n ans += 1\n temp = l\nprint(ans)", "def solve():\n s = input()\n ans = 0\n for i in range(len(s)-1):\n if s[i] != s[i + 1]:\n ans += 1\n print(ans)\n\ndef __starting_point():\n solve()\n__starting_point()", "from itertools import groupby\n\nS = input()\n\nprint((len(list(groupby(S)))-1))\n", "s = input()\nans = 0\n\nfor i in range(len(s)-1):\n if s[i] != s[i+1]:\n ans += 1\n\nprint(ans)", "from itertools import groupby\n\n\n# RUN LENGTH ENCODING str -> tuple\ndef runLengthEncode(S: str):\n grouped = groupby(S)\n res = []\n for k, v in grouped:\n res.append((k, str(len(list(v)))))\n return res\n\n\n# RUN LENGTH DECODING tuple -> str\ndef runLengthDecode(L: \"list[tuple]\"):\n res = \"\"\n for c, n in L:\n res += c * int(n)\n return res\n\n\n# RUN LENGTH ENCODING str -> list\ndef rle_list(S: str):\n grouped = groupby(S)\n res = \"\"\n for k, v in grouped:\n res += k\n return res\n\n\ndef main():\n ss = input()\n rle = rle_list(ss)\n ans = len(list(rle)) - 1\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = list(input())\nans = 0\nt = s[0]\nfor i in range(1,len(s)):\n if s[i] != t:\n t = s[i]\n ans += 1\nprint(ans)", "s = input()\ncount = 0\nfor i in range(len(s)-1):\n if s[i] != s[i+1]:\n count += 1\nprint(count)", "s = input()\ncount = 0\n\nfor i in range(len(s)-1):\n if s[i] != s[i+1]:\n count += 1\nprint(count)", "def main():\n ss = input()\n put_stone = ''\n count = 0\n for stone in ss:\n if put_stone != '' and put_stone == stone:\n count += 1\n if stone == 'B':\n put_stone = 'W'\n else:\n put_stone = 'B'\n print(count)\n\ndef __starting_point():\n main()\n__starting_point()", "S = input()\nnow = S[0]\ncnt = 0\nfor s in S:\n if now == s:\n continue\n cnt += 1\n now = s\nprint(cnt)", "S = input()\nprint(S.count('BW')+S.count('WB'))", "S=input()\nans=0\nfor i in range(len(S)-1):\n if S[i]!=S[i+1]:\n ans+=1\nprint(ans)\n", "S = input()\nList = list(S)\ntrial = 0\nfor i in range(1,len(List)):\n if List[i] != List[i-1]:\n trial += 1\nprint(trial)", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(S: str):\n from itertools import groupby\n return len(list(groupby(S))) - 1\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 = input()\nans = 0\nx = s[0]\n\nfor i in range(len(s)):\n if s[i] != x:\n ans += 1\n x = s[i]\n\nprint(ans)", "def main():\n s = input()\n print((sum([1 for i in range(len(s) - 1) if s[i] != s[i + 1]])))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\n\nn = len(s)\n\ncnt = 0\nfor i in range(1,n):\n if s[i] != s[i-1]:\n cnt +=1\nprint (cnt)\n", "S=str(input())\nans=0\nfor i in range(1,len(S)):\n if S[i-1]!=S[i]:\n ans+=1\nprint(ans)", "s = input()\nprev = s[0]\nans = 0\nfor i in range(1, len(s)):\n if s[i] != prev:\n ans += 1\n prev = s[i]\nprint(ans)\n", "s = input()\ncnt = 0\nfor i in range(len(s)-1):\n if s[i] != s[i+1]:\n cnt += 1\n\nprint(cnt)", "s=input()\nx=s.count(\"WB\")\ny=s.count(\"BW\")\nprint((x+y))\n", "S = list(input())\nk = S.pop(0)\nii = 0\nfor i in S:\n if k == i:\n pass\n else:\n ii += 1\n k = i\nprint(ii)", "s=list(input())\nr=0\nfor ii in range(len(s)-1):\n if s[ii+1]!=s[ii]:\n r+=1\nprint(r)", "a=input()\nb=0\nfor i in range(len(a)-1):\n if a[i]!=a[i+1]:\n b=b+1\nprint(b)", "S=list(input())\nc=0;m=''\nfor i in S:\n if i!=m:\n m=i\n c+=1\nprint(c-1)", "# coding = SJIS\n\ns = str(input())\nans = 0\n\nfor i in range(len(s) - 1):\n if s[i] != s[i + 1]:\n ans += 1\n\nprint(ans)", "s = input()\nans = 0\nfor i in range(len(s)-1):\n if s[i]!=s[i+1]:\n ans += 1\nprint(ans)", "import itertools\ns = input()\nprint(len(list(itertools.groupby(s)))-1)", "from itertools import groupby\nS = input()\ngr = groupby(S)\nprint((len(list(gr))-1))\n", "S = str(input())\nN = len(S)\nD = [0,0] #B,W\nans = 0; prev = S[0]\nfor i in range(N):\n if S[i] == \"B\":\n D[0] += 1\n else:\n D[1] += 1\n if i >= 1:\n if S[i] == prev:\n continue\n else:\n ans += 1\n prev = S[i]\nif D[0] == 0: #\u3059\u3079\u3066W\n print((0)); return\nelif D[1] == 0:\n print((0)); return\nprint(ans)\n", "s = input()\n\ns_ = s[0]\n\nfor c in s:\n if s_[-1]!=c:\n s_ += c\nprint(len(s_)-1)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 30 02:12:31 2020\n\n@author: liang\n\"\"\"\n\nS = input()\nans = 0\nfor i in range(len(S) - 1):\n if S[i] != S[i+1]:\n ans += 1\n\nprint(ans)", "s = input()\nres = 0\nfor i in range(len(s) - 1):\n if s[i] != s[i+1]:\n res += 1\nprint(res)", "S = input()\nprint(S.count(\"WB\")+S.count(\"BW\"))", "s = input()\n\nnow = \"\"\nans = 0\nfor i in range(len(s)):\n if i == 0:\n now = s[0]\n continue\n if s[i] != now:\n ans += 1\n now = s[i]\nprint(ans)", "s = input()\ncnt = 0\ncur = s[0]\nstrk = 1\n\nfor i in range(1, len(s)):\n if s[i] == cur:\n strk += 1\n else:\n cnt += 1\n cur = s[i]\n strk = 1\n\ncnt += 1\n\nprint(cnt-1)", "S=input()\ni=1\nl=len(S)\nres=0\nf=S[0]\n\nwhile i<l:\n if (S[i] == f):\n i+=1\n else:\n res+=1\n f=S[i]\n i+=1\nprint(res)", "S=input()\nrest=S[0]\ncnt=0\nfor i in range(1,len(S)):\n if S[i]!=rest:\n cnt+=1\n rest=S[i]\nprint(cnt)"]
{"inputs": ["BBBWW\n", "WWWWWW\n", "WBWBWBWBWB\n"], "outputs": ["1\n", "0\n", "9\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
19,898
9543be8b54f1d8fdd8f62a8bf27dbf83
UNKNOWN
AtCoDeer the deer has found two positive integers, a and b. Determine whether the concatenation of a and b in this order is a square number. -----Constraints----- - 1 ≀ a,b ≀ 100 - a and b are integers. -----Input----- Input is given from Standard Input in the following format: a b -----Output----- If the concatenation of a and b in this order is a square number, print Yes; otherwise, print No. -----Sample Input----- 1 21 -----Sample Output----- Yes As 121 = 11 Γ— 11, it is a square number.
["\n#ABC086B\na,b = input().split()\na += b\na = int(a)\nprint(\"Yes\" if int((a**.5))**2 == a else \"No\")", "a, b = input().split()\nab = int(a+b)\n\nfor j in range(ab):\n if j ** 2 <= ab:\n if j ** 2 == ab:\n print(\"Yes\")\n return\n else:\n print(\"No\")\n return", "#-*-coding:utf-8-*-\nimport sys\nimport math\ninput=sys.stdin.readline\n\ndef main():\n a,b = input().split()\n number=0\n\n number=int(a+b)\n for i in range(100101):\n if i * i ==number:\n print(\"Yes\")\n return\n else:\n continue\n print(\"No\")\n\n\ndef __starting_point():\n main()\n__starting_point()", "a, b = (i for i in input().split())\nc = int(a + b)\nans = c ** 0.5\nif float.is_integer(ans): print('Yes')\nelse: print('No')", "a,b=map(str,input().split())\nx = a+b\nx = int(x)\ny = x**0.5\nif y.is_integer():\n print('Yes')\nelse:\n print('No')", "a,b=input().split()\nx=int(a)*10**len(b)+int(b)\n\nfor i in range(0,1000):\n if i*i==x:\n print(\"Yes\")\n break\nelse:\n print(\"No\")\n", "a,b=map(int,input().split())\n\ndef ans086(a:int, b:int):\n ab=int(str(a)+str(b))\n import math\n if int(math.sqrt(ab))**2==ab:\n return(\"Yes\")\n else:\n return(\"No\")\n\nprint(ans086(a,b))", "a,b=map(str,input().split())\nans = a+b\nif (int(ans) ** 0.5).is_integer():\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b = input().split()\n\na_b = a + b\na_b = int(a_b)\n\nfor i in range(a_b):\n if i * i == a_b:\n print(\"Yes\")\n return\nprint(\"No\")", "num = int(''.join(input().split()))\nroot = num ** .5\n\nprint(('Yes' if root.is_integer() else 'No'))\n", "import math\nx = int(input().replace(' ',''))\ny = int(math.sqrt(x))\nif y * y == x:\n print(\"Yes\")\nelse:\n print(\"No\")", "import math\na,b = map(int, input().split())\nab = str(a) + str(b)\n\nif math.sqrt(int(ab))%1 == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "import math\na, b = map(str, input().split())\nans = int(a+b)\nfor i in range(ans):\n route = pow(i, 2)\n if ans == route:\n print(\"Yes\")\n return\nprint(\"No\")", "a, b = map(int, input().split())\nm = b + a * 10 ** len(str(b))\nfind = False;\nfor i in range(m):\n if m == i ** 2:\n find = True;\nif find:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b=list(map(str,input().split()))\nc=int(a+b)\nfor i in range(1,1001):\n if i**2==c:\n print(\"Yes\")\n return\nprint(\"No\")\nreturn\n", "a, b = input().split()\nx = int(a+b)\nno = 0\nfor i in range(1000):\n if x == i**2:\n print(\"Yes\")\n else:\n no += 1\n if no == 1000:\n print(\"No\")", "import math\n\ndef main():\n a, b = input().split(\" \")\n x = math.sqrt(int(a + b))\n \n print((\"Yes\" if x.is_integer() else \"No\"))\n\n\nmain()\n", "import math\n\na, b = input().split()\ns = a + b\ni = int(s)\nr = math.sqrt(i)\nif r.is_integer():\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b = map(int,input().split())\n\nfor i in range(2, 400):\n if (10**(len(str(b))) * a + b) == i**2:\n ans = 'Yes'\n break\n else:\n ans = 'No'\nprint(ans)", "N = int(input().replace(' ', ''))\nprint('Yes' if N == int(N**(1/2))**2 else 'No')", "import math \n\nlist=input().split()\n\nnum=int(list[0]+list[1])\n\nnum_squrt=math.sqrt(num)\n\nif num_squrt.is_integer()==True:\n print(\"Yes\")\nelse:\n print(\"No\")", "import math\na,b = input().split()\nn = int(a+b)\nif math.sqrt(n) % 1 == 0:\n print('Yes')\nelse:\n print('No')", "a,b=map(str, input().split())\nq=0\nfor i in range(1000):\n if int(a+b)==i**2:\n print('Yes')\n q=1\n break\nif q==0:\n print('No')", "import math\na, b = map(str, input().split())\n\ns = a + b\ns = int(s)\nr = math.sqrt(s)\nfr = r - int(r)\nif fr == 0:\n print('Yes')\nelse:\n print('No')", "import math\n\na, b = list(map(str, input().split()))\nx = int(a + b)\n\nif math.sqrt(x).is_integer():\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a,b = input().split()\nc = int(a + b)\nif (c**0.5).is_integer() == True:\n print('Yes')\nelse:\n print('No')", "def resolve():\n from math import sqrt\n \n n = int(\"\".join(input().split()))\n print(\"Yes\" if n == int(sqrt(n)) ** 2 else \"No\")\n\n\ndef __starting_point():\n resolve()\n__starting_point()", "a, b = input().split()\ns = int(a+b)\nresult = 'No'\nfor i in range(1,round(s)):\n if s/i == i:\n result = 'Yes'\n \nprint(result)", "N = int(input().replace(\" \",\"\"))\n\nflag = False\nfor i in range(1,10000):\n if N == i**2:\n flag = True\n break\n if N < i**2:\n break\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "p = input().split()\na = int(f\"{p[0]}{p[1]}\")\nprint( \"Yes\" if a == int((a ** 0.5)) **2 else \"No\")", "a,b=list(map(str,input().split()))\nc=int(a+b)\nx=c**(1/2)\nif x.is_integer():\n print('Yes')\nelse :\n print('No')\n", "a,b=input().split()\n\nd=int(a+b)\n\nfor i in range(1000):\n if d==i**2:\n print(\"Yes\")\n break\n\nlis=[j**2!=d for j in range(1000)]\nif all(lis)==True:\n print(\"No\")\n", "import math\n\na, b = input().split()\nnum = int(a+b)\n\nif math.sqrt(num).is_integer():\n print('Yes')\nelse:\n print('No')", "a,b =list(map(str,input().split()))\nx = int(a+b)**0.5\n\nif x - int(x) == 0:\n print('Yes')\nelse:\n print('No')\n", "a,b = list(input().split())\nnum = int(a+b)\nans = round(num**0.5)\nif ans**2 == num:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "import math\na,b = list(map(int,input().split()))\nnumber = int(str(a)+str(b))\nroot = math.sqrt(number)\nif int(root + 0.5) ** 2 == number:\n print(\"Yes\")\nelse:\n print(\"No\")", "import math\na = input(\"\").split(\" \")\na = [int(aa) for aa in a]\nn = int(str(a[0])+str(a[1]))\nr = math.sqrt(n)\nif r**2 == int(r)**2:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b=list(map(str,input().split()))\nc=a+b\nc=int(c)\nfor i in range(1001):\n if i**2==c:\n print(\"Yes\")\n return\nprint(\"No\")\n", "a, b = map(int, input().split())\n\nc = int(str(a)+str(b))\n\nl = []\n\nfor i in range(10, 100100):\n if (i ** .5).is_integer():\n l.append(i)\n\nfor i in l:\n if c == i:\n print('Yes')\n return\n\nprint('No')", "import math\na, b = input().split()\n\nif math.sqrt(int(a + b)) == int(math.sqrt(int(a + b))):\n print('Yes')\nelse:\n print('No')", "import math\na,b = input().split()\nq = int(a+b)\nif math.sqrt(q)//1 == math.sqrt(q):\n print(\"Yes\")\nelse:\n print('No')", "from math import sqrt\na, b = input().split()\nn = int(a+b)\nprint(('Yes' if sqrt(n) == int(sqrt(n)) else 'No'))\n", "import math\ns = input()\ns = int(s.replace(\" \", ''))\nif math.sqrt(s) == int(math.sqrt(s)):\n print(\"Yes\")\nelse:\n print(\"No\")\n", "#!/usr/bin/env python3\n\ndef main():\n ab = int(input().replace(\" \", \"\"))\n print((\"Yes\" if int(ab**.5)**2 == ab else \"No\"))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import math\n\n\ndef answer(a: int, b: int) -> str:\n joined_value = int(str(a) + str(b))\n return 'Yes' if math.sqrt(joined_value) % 1 == 0 else 'No'\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()", "# -*- coding:utf-8 -*-\na, b = input().split()\n\njudge = int(a+b)\n\nif any(i**2 == judge for i in range(judge//2)):\n print(\"Yes\")\nelse:\n print(\"No\")", "import sys\na,b=map(str,input().split())\n\nc=a+b\nc=int(c)\n\nfor i in range(c//2):\n if c==i**2:\n print('Yes')\n return\n\nprint('No')", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\n\na, b = list(map(str, input().split()))\n\n\nnum = int(a+b)\n\nif num == int(num**0.5)**2:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n=int(input().replace(\" \",\"\"))\nprint(\"Yes\" if (n**0.5).is_integer() else \"No\")", "import math\n\na, b = input().split()\nn = int(a + b)\nprint('Yes') if math.sqrt(n) % 1 == 0 else print('No')", "a=int(input().replace(\" \",\"\"))\nprint(\"Yes\" if int(a**0.5)==a**0.5 else 'No')", "a, b = map(str, input().split())\nans = \"No\"\nkey = int(a+b)\nfor i in range(1000):\n if i**2 == key:\n ans =\"Yes\"\n break\nprint(ans)", "import numpy as np\n\na, b = input().split(' ')\n\nc = int(a + b)\n\nsqrt_c = np.sqrt(c)//1\n\nif(sqrt_c**2 == c) :\n print(\"Yes\")\nelse :\n print(\"No\")", "x = int(''.join(input().split()))\na = 1\nwhile True:\n aa = a * a\n if aa == x:\n print(\"Yes\")\n return\n elif aa > x:\n print(\"No\")\n return\n a += 1", "from math import ceil, sqrt\na, b = input().split()\n\nsq = sqrt(int(a+b))\nf = sq - int(sq)\nprint(('Yes' if ceil(f) == 0 else 'No'))\n", "a, b = [i for i in input().split()]\nt = int(a + b)\nans = 'No'\nn = 1\nwhile n*n <= t:\n if n*n == t:\n ans = 'Yes'\n n += 1\nprint(ans)\n", "import math\nab=list(input().split())\ns=int(''.join(ab))\n\nroot=int(math.sqrt(s))\nif root*root==s: print('Yes')\nelse: print('No')", "import math\na, b = list(map(str, input().split()))\n\ntarget = math.sqrt(int(a+b))\n\nif target.is_integer():\n print('Yes')\nelse:\n print('No')\n\n", "import math\n\na, b = input().split()\nn = int(a + b)\n\nif n == round(math.sqrt(n))**2:\n print('Yes')\nelse:\n print('No')", "import math\na,b = input().split()\nc = int(a + b)\n\nd = math.sqrt(c)\nprint(\"Yes\" if d == int(d) else \"No\")", "a,b = map(str,input().split())\nc = int(a + b)\n\nfor i in range(int(c ** 0.5), int(c ** 0.5) + 1 ):\n if i ** 2 == c:\n print('Yes')\n return\n\nprint('No')", "#!/bin/env python3\n# -*- coding: utf-8 -*-\n\nimport math\n\nIS = lambda: int(input())\nIA = lambda: [int(x) for x in input().split()]\n\na, b = IA()\n\nab = int(str(a) + str(b))\nrt = math.sqrt(ab)\nprint((\"Yes\" if int(rt) ** 2 == ab else \"No\"))\n", "#!/usr/bin/env python3\nimport sys\n\nYES = \"Yes\" # type: str\nNO = \"No\" # type: str\n\n\ndef solve(a: int, b: int):\n c = int(str(a) + str(b))\n for i in range(400):\n if c == i*i:\n print(YES)\n break\n else:\n print(NO)\n return\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\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 a = int(next(tokens)) # type: int\n b = int(next(tokens)) # type: int\n solve(a, b)\n\ndef __starting_point():\n main()\n\n__starting_point()", "a=input().split()\nb=int(\"\".join(a))\n\nnum=int(100100**1/2)\n\nans=\"No\"\nfor i in range(num):\n if i**2==b:\n ans=\"Yes\"\n break\n \nprint(ans)", "a,b = input().split()\nab = int(a+b)\nprint(\"Yes\" if (ab**0.5).is_integer() else \"No\")", "import math\na, b = list(map(int, input().split()))\nc = 0\n\nif b < 10:\n c = a*10 + b\nelif 10 <= b <= 99:\n c = a*100 + b\nelif b == 100:\n c = a*1000 + b\n\nd = math.sqrt(c)\n\nif d.is_integer():\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a,b = map(str,input().split())\nc = int(a + b)\nif c ** 0.5 ==int(c ** 0.5):\n print('Yes')\nelse:\n print('No')", "print(('Yes' if int(''.join(input().split())) ** 0.5 % 1 == 0 else 'No'))\n\n", "a, b = input().split()\nt = int(a + b)\nans = 'No'\nn = 1\nwhile n*n <= t:\n if n*n == t:\n ans = 'Yes'\n n += 1\nprint(ans)", "import math\na,b = list(map(str,input().split()))\nc = int(a+b)\nif int(math.sqrt(c))**2 == c:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a, b = input().split()\nt = int(a + b)\nfor i in range(1,10 ** 3):\n if t == (i * i):\n print('Yes')\n return\nprint('No')\n", "import sys\nc = [i for i in input().split()]\nab = int(c[0]+c[1])\nfor i in range(int(100100**0.5)+1):\n if i**2 == ab:\n print(\"Yes\")\n return\n\nprint(\"No\")", "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 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\na = L()\nb = \"\".join(a)\nb = int(b)\nfor i in range(1000):\n if b == i**2:\n print(\"Yes\")\n return\n \nprint(\"No\")", "# 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 = list(map(str,input().split()))\n#K = input()\n# f = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\ncount=0\na=e1+e2\nfor i in range(1,int(a)):\n\tif int(a)/int(i)==int(i):\n\t\tcount+=1\nif count>0:\n\tprint('Yes')\nelse:\n\tprint('No')\n", "n = int(input().replace(' ', ''))\nx = int(n ** 0.5)\nprint('Yes' if x * x == n else 'No')", "ab = int(input().replace(\" \", \"\"))\nans = False\nfor i in range(320):\n if i * i == ab:\n ans = True\n break\nprint(\"Yes\") if ans else print(\"No\")", "ab = int(\"\".join(input().split()))**0.5\n\nif ab.is_integer():\n print(\"Yes\")\nelse:\n print(\"No\")", "import math\na, b = map(str, input().split( ))\nA = int(a+b)\n\nif math.sqrt(A).is_integer() == True:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b=map(str,input().split())\nab=int(a+b)\n\nans=\"No\"\nfor i in range(1010):\n x=i**2\n if x==ab:\n ans=\"Yes\"\n break\n\nprint(ans)", "#!/usr/local/bin/python3\n# https://atcoder.jp/contests/abc086/tasks/abc086_b\nimport math\n\na, b = input().split()\n\nif math.sqrt(int(a+b)).is_integer():\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a,b = map(int,input().split())\nc = int(str(a) + str(b))\nfor i in range(c):\n if i ** 2 == c:\n print('Yes')\n break\n elif i ** 2 > c:\n print('No')\n break", "n = int(\"\".join(input().split()))\nx = n**0.5\nif x == int(x):\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b = input().split()\na = int(a + b)\n\nfor i in range(1000):\n if i ** 2 == a:\n print(\"Yes\")\n break\nelse:\n print(\"No\")\n", "import math\na,b=input().split()\nc=int(a+b)\nd=math.sqrt(c)\ne=math.floor(d)\nif e**2==c:\n print('Yes')\nelse:\n print('No')", "import math\na, b = list(map(int, input().split()))\nc = 0\n\nif b < 10:\n c = a*10 + b\nelif 10 <= b <= 99:\n c = a*100 + b\nelif b == 100:\n c = a*1000 + b\n\nd = math.sqrt(c)\n\nif d.is_integer():\n print(\"Yes\")\nelse:\n print(\"No\")\n", "#\n# abc086 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 21\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"100 100\"\"\"\n output = \"\"\"No\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"12 10\"\"\"\n output = \"\"\"No\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n A, B = input().split()\n\n C = int(A+B)\n for i in range(1, 100100):\n if i**2 == C:\n print(\"Yes\")\n break\n else:\n print(\"No\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "a,b = map(str,input().split())\nfrom math import sqrt\nprint(\"Yes\" if sqrt(int(a+b)) == int(sqrt(int(a+b))) else \"No\")", "a,b=map(str,input().split())\nc=a+b\nfor i in range(1,350):\n if int(c)==i**2:\n print(\"Yes\")\n break\nelse:\n print(\"No\")", "a,b = map(str,input().split())\nc = int(a + b)\nd = int(c ** 0.5)\n\n\nif d ** 2 == c:\n print('Yes')\nelse:\n print('No')", "import math\na,b = map(str, input().split())\nab = int(a+b)\nsq = math.sqrt(ab)\nif sq % 1 < 0.01:\n sq2 = sq**2\n if sq2 == ab:\n ans = 'Yes'\n else:\n ans = 'No'\nelse:\n ans = 'No'\nprint(ans)", "a, b = input().split()\nab = int(a+b)\nimport math\nif math.sqrt(ab).is_integer():\n print('Yes')\nelse:\n print('No')", "a,b=input().split()\ns=0\ns += int(b)\ns += int(a)*(10**len(b))\nfor i in range(320):\n if s==i*i:\n print('Yes')\n return\nprint('No')\n", "import math\n\na, b = map(int, input().split())\nx = int(str(a) + str(b))\nif math.sqrt(x) == math.ceil(math.sqrt(x)):\n print(\"Yes\")\nelse :\n print(\"No\")", "a, b = list(map(str, input().split(\" \")))\n\nans = False\nfor i in range(1000):\n if int(a + b) == i ** 2:\n ans = True\n\nprint((\"Yes\" if ans else \"No\"))\n", "from math import sqrt\na,b=input().split()\nc=int(a+b)\nd=int(sqrt(c))\nprint(\"Yes\" if d**2==c else \"No\")", "a, b = input().split()\nab = int(a+b)\ni = 0\nwhile i**2 <= ab:\n flag = (i**2 == ab)\n i = i+1\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")", "import math\n\na, b = map(str, input().split())\n\nX = int(a) * (10 ** len(b)) + int(b)\n\nif math.sqrt(X) % 1 == 0:\n print('Yes')\nelse:\n print('No')", "from math import sqrt\na, b = input().split()\nc = a + b\nif sqrt(int(c)) == int(sqrt(int(c))):\n print(\"Yes\")\nelse:\n print(\"No\")", "from math import *\nlst = input().split()\n\nif (sqrt(int(lst[0] + lst[1])) % 1) == 0:\n print('Yes')\nelse:\n print('No')", "import math\n\na, b = input().split()\nc = int(a + b)\n\nfor i in range(int(math.sqrt(c))+1):\n if c == i*i:\n print(\"Yes\")\n break\nelse:\n print(\"No\")\n \n"]
{"inputs": ["1 21\n", "100 100\n", "12 10\n"], "outputs": ["Yes\n", "No\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,333
62c8e54fb6b8a6d482b2ff6929877acb
UNKNOWN
You are given an integer sequence of length N, a_1,a_2,...,a_N. For each 1≀i≀N, you have three choices: add 1 to a_i, subtract 1 from a_i or do nothing. After these operations, you select an integer X and count the number of i such that a_i=X. Maximize this count by making optimal choices. -----Constraints----- - 1≀N≀10^5 - 0≀a_i<10^5 (1≀i≀N) - a_i is an integer. -----Input----- The input is given from Standard Input in the following format: N a_1 a_2 .. a_N -----Output----- Print the maximum possible number of i such that a_i=X. -----Sample Input----- 7 3 1 4 1 5 9 2 -----Sample Output----- 4 For example, turn the sequence into 2,2,3,2,6,9,2 and select X=2 to obtain 4, the maximum possible count.
["# -1 0 1\u3092\u8db3\u3057\u305f\u3082\u306e\u306e\u3046\u3061\u6700\u5927\u5024\u3092\u6570\u3048\u308b\nn = int(input())\na = list(map(int, input().split()))\n# ai=0\u306e\u5834\u5408\u3082\u3042\u308b\u306e\u3067-1\u304c\u3042\u308a\u3048\u308b\u3053\u3068\u306b\u6ce8\u610f \u9069\u5f53\u306ba[0]\u3092-1\u306e\u6570\u3068\u3059\u308b\nd = [0] * (10**5 + 10)\nfor av in a:\n for x in [-1, 0, 1]:\n # \u524d\u8ff0\u306e\u901a\u308aa[0]\u3092-1\u306e\u6570\u3068\u3059\u308b\n d[av + x + 1] += 1\nprint(max(d))", "n = int(input())\na = list(map(int,input().split()))\n\nans = 0\n\ncnt = [0]*100001\n\nfor i in a:\n cnt[i] += 1\n\nfor i in range(len(cnt)-2):\n ans = max(ans,cnt[i]+cnt[i+1]+cnt[i+2])\n\nprint(ans)\n", "from collections import defaultdict\nd = defaultdict(int)\nN = int(input())\nN_List = list(map(int,input().split()))\n\nfor i in range(N):\n CN = N_List[i]\n for k in range(-1,2,1):\n d[CN + k] += 1\n \nprint(max(d.values()))", "import sys, math\nfrom functools import lru_cache\nfrom itertools import accumulate\nsys.setrecursionlimit(10**9)\nMOD = 10**9+7\n\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef mi():\n return list(map(int, input().split()))\n\ndef ii():\n return int(input())\n\ndef i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]\n\nN = ii()\na = list(mi())\n\nl = [0]*(max(a)+5)\n\nfor i in range(N):\n l[a[i]] += 1\n l[a[i]+3] -= 1\n\nacc = list(accumulate(l))\n\nprint((max(acc)))\n\n\n", "import sys\nimport collections\n\nN, *A = map(int, open(0).read().split())\n\nB = collections.Counter(A).most_common()\nB.sort(key=lambda x: x[0])\n\nans = 0\nfor i in range(len(B)):\n count = B[i][1]\n if i+1 < len(B) and B[i+1][0] == B[i][0]+1:\n count += B[i+1][1]\n if i+2 < len(B) and B[i+2][0] == B[i][0]+2:\n count += B[i+2][1]\n ans = max(ans, count)\nprint(ans)", "import collections\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(lambda x: x-1, a))\nc = list(map(lambda y: y+1, a))\nd = a+b+c\n\ne = collections.Counter(d)\nprint(max(e.values()))", "n = int(input())\nal = list(map(int, input().split()))\n\nans = [0]*(10**5+2)\n\nfor a in al:\n ans[a] += 1\n ans[a-1] += 1\n ans[a+1] += 1\n\nprint(max(ans))", "n = int(input())\na = [int(x) for x in input().split()]\na.sort()\n\np = [0] * (max(a) + 5)\n\nfor i in range(n):\n p[a[i]+1] += 1\n \nres = 0\nfor i in range(min(a),max(a)+1):\n res = max(res, p[i] + p[i+1] + p[i+2])\n\nprint(res)", "N,*A =map(int,open(0).read().split())\n\nL = [0 for i in range(int(1e5)+1)]\n\nfor a in A:\n L[a]+=1\n\nans = 0\nfor i in range(int(1e5)+1):\n S = sum(L[i:i+3])\n if ans < S:\n ans = S\n \nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\nnum_list = [0] * 10 ** 5\nfor i in range(n):\n num_list[a[i]] += 1\n\nres = 0\nfor i in range(1, 10 ** 5 - 1):\n res = max(res, num_list[i - 1] + num_list[i] + num_list[i + 1])\n\nprint(res)\n", "n=int(input())\na=list(map(int,input().split()))\nc=[0]*(10**5+3)\nfor i in range(n):\n c[a[i]]+=1\n c[a[i]-1]+=1\n c[a[i]+1]+=1\nprint(max(c))", "n = int(input())\nal = list(map(int, input().split()))\nal.sort()\nal.append(-1)\ncnt = 1\nbl = []\nfor i in range(n):\n if al[i] == al[i+1]:\n cnt += 1\n else:\n bl.append([al[i], cnt])\n cnt = 1\ntmp = 0\nans = 0\nfor j in range(len(bl)):\n tmp = bl[j][1]\n if bl[j-1][0] + 1 == bl[j][0]:\n tmp += bl[j-1][1]\n if j!=len(bl)-1 and bl[j][0] == bl[j+1][0] - 1:\n tmp += bl[j+1][1]\n\n if tmp > ans:\n ans = tmp\n\nprint(ans)", "n = int(input())\na = list(map(int,input().split()))\n\ncnt = [0] * (10**5 + 1)\n\nfor i in a:\n cnt[i] += 1\n\nx_cnt = [0] * (10**5 +1)\nfor x in range(1, 10**5):\n tmp = cnt[x-1] + cnt[x] + cnt[x+1]\n x_cnt[x] = tmp\n\nprint(max(x_cnt))", "N, *A = map(int, open(0).read().split())\n\nC = {}\nfor a in A:\n if a in C.keys():\n C[a] += 1\n else:\n C[a] = 1\nB = list(C.items())\nB.sort(key=lambda x: x[0])\n\nans = 0\nfor i in range(len(B)):\n count = B[i][1]\n try:\n for j in [-1,1]:\n if B[i+j][0] == B[i][0]+j:\n count += B[i+j][1]\n except IndexError:\n pass\n ans = max(ans, count)\nprint(ans)", "from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\n\nB = []\nfor a in A:\n B.append(a-1)\n B.append(a)\n B.append(a+1)\nC = Counter(B)\n\nprint(C.most_common()[0][1])", "import collections\n\nn = int(input())\na = list(map(int, input().split()))\n\nlower_a = list(map(lambda x: x - 1, a))\nupper_a = list(map(lambda x: x + 1, a))\nextended_a = collections.Counter(a + lower_a + upper_a)\n\nprint(extended_a.most_common()[0][1])", "input();B=[0]*10**5\nfor a in input().split():B[int(a)]+=1\nprint(max(sum(B[i:i+3])for i in range(10**5)))", "from collections import defaultdict\n\n\ndef main():\n _ = input()\n a = [int(an) for an in input().split()]\n cnt = defaultdict(int)\n for an in a:\n cnt[an - 1] += 1\n cnt[an] += 1\n cnt[an + 1] += 1\n print((max(cnt.values())))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import numpy as np\nn=int(input())\na=np.array(sorted(map(int,input().split())))\nd=np.array([0]*(10**5+3))\ne=np.array([0]*(10**5+3))\nf=np.array([0]*(10**5+3))\nfor i in a:\n d[i+1]+=1\nb=a-1\nfor i in b:\n e[i+1]+=1\nc=a+1\nfor i in c:\n f[i+1]+=1\ng=d+e+f\nprint(max(g))", "import numpy as np\nN = int(input())\nA = np.array(input().split(), dtype = np.int32)\n \ncounter = np.bincount(A)\nif len(counter) <= 2:\n answer = counter.sum()\nelse:\n answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()\nprint(answer)", "N=int(input())\na=list(map(int,input().split()))\nres=0\ncount=[0]*(10**5+2)\nfor i in range(N) :\n count[a[i]]+=1\nfor i in range(10**5) :\n x=count[i]+count[i+1]+count[i-1]\n res=max(res,x)\nprint(res)", "from collections import Counter\n\nn=int(input())\nl=list(map(int,input().split()))\n\na=[i-1 for i in l]\nb=[i+1 for i in l]\n\nl=Counter(l+a+b)\n\nprint(l.most_common()[0][1])", "from collections import defaultdict\n\nn = int(input())\narr = list(map(int, input().split()))\n\nd = defaultdict(int)\nfor x in arr:\n d[x] += 1\n\na = d[0] + d[1] + d[2]\nans = [a]\n\nfor i in range(max(arr) - 2):\n a -= d[i]\n a += d[i + 3]\n ans.append(a)\n\nprint(max(ans))", "n=int(input())\na=list(map(int,input().split()))\ndata=[0]*(10**5+2)\nfor i in a:\n data[i]+=1\n data[i+1]+=1\n data[i+2]+=1\nprint(max(data))", "n = int(input())\ncnt = [0]*100002\n\na = list(map(int,input().split()))\n\nfor v in a:\n cnt[v] += 1\n cnt[v+1] += 1\n cnt[v+2] += 1\n \n#print(cnt)\nprint((max(cnt)))\n\n", "from collections import defaultdict\nd=defaultdict(int)\nN=int(input())\na=list(map(int,input().split()))\nfor x in a:\n d[x]+=1\n d[x-1]+=1\n d[x+1]+=1\nprint(max(d.values()))", "\nN = int(input())\nl = list(map(int,input().split()))\n\nflag = [0] * (max(l)+2)\n\nminone = 0\nfor i in l:\n if i == 0:\n minone+= 1\n else:\n flag[i-1] += 1\n flag[i] += 1\n flag[i+1] += 1\n\nprint(max(max(flag),minone))", "# -*- coding: utf-8 -*-\n\nN = int(input())\na = list(map(int, input().split()))\n\ncount = [0] * (10**5+1)\n\nfor i in range(N):\n count[a[i]] += 1\n if a[i]-1 >=0:\n count[a[i]-1] += 1\n if a[i]+1 <=10**5:\n count[a[i]+1] += 1\n\nmax_value = max(count)\n#max_index = count.index(max_value)\nprint(max_value)", "N = int(input())\nA = [int(x) for x in input().split()]\n\ndata = {}\nfor a in A:\n for i in range(3): #a-1,a,a+1\u3092\u30ab\u30a6\u30f3\u30c8\n if a-1+i in data:\n data[a-1+i] += 1\n else:\n data[a-1+i] = 1\n \n#\u30ab\u30a6\u30f3\u30c8\u3057\u305f\u3082\u306e\u306e\u6700\u5927\u5024\u304c\u7b54\u3048\nans = 0\nfor d in data.values():\n ans = max(ans, d)\nprint(ans)", "import collections\nn=int(input())\na=list(map(int,input().split()))\na1=[x-1 for x in a]\na2=[x+1 for x in a]\nb=a+a1+a2\nc=collections.Counter(b)\n\nprint(max(c.values()))", "n = int(input())\na = list(map(int, input().split())) \n\ndp=[0 for i in range(max(a)+1)]\nfor i in range(n):\n dp[a[i]]+=1\n \nans=0\n\nif len(dp)==1:\n ans=dp[0]\nelse:\n for i in range(1,len(dp)-1):\n ans=max(ans,dp[i-1]+dp[i]+dp[i+1])\n \nprint(ans)", "N=int(input())\na=list(map(int,input().split()))\n\n\nQ=[0]*(max(a)+3)\n\nfor i in a:\n Q[i]+=1\n Q[i+1]+=1\n Q[i+2]+=1\nprint(max(Q))", "import collections\n\nN = int(input())\nAs = sorted(list(map(int, input().split())))\nc = collections.Counter(As)\n\nL = [0] * (10 ** 5 + 1)\nM = [0] * (10 ** 5 + 1)\nfor (x, y) in list(c.items()):\n L[x] = y\n\nfor i in range(0, (10 ** 5)):\n M[i] = L[i - 1] + L[i] + L[i + 1]\n\nprint((max(M)))\n", "N = int(input())\nA = list(map(int, input().split()))\nA = [i + 1 for i in A]\n\nbucket = [0] * (10 ** 5 + 10)\n\nfor a in A:\n bucket[a - 1] += 1\n bucket[a] += 1\n bucket[a+1] += 1\n\nprint(max(bucket))", "from collections import Counter\nimport copy\n\n\ndef LI():\n return list(map(int, input().split()))\n\n\nN = int(input())\nA = LI()\nB = Counter(A)\nA = copy.copy(B)\n\nfor k, v in B.items():\n\n if k-1 in A:\n A[k-1] += v\n else:\n A[k-1] = v\n if k+1 in A:\n A[k+1] += v\n else:\n A[k+1] += v\n\nprint(max(A.values()))", "from collections import defaultdict\n\nn = int(input())\narr = list(map(int, input().split()))\n\nd = defaultdict(int)\n\nfor x in arr:\n d[x] += 1\n d[x - 1] += 1\n d[x + 1] += 1\n\nresult = [y for x, y in d.items()]\n\nprint(max(result))", "import collections\n\nn = int(input())\na_list = list(map(int, input().split()))\nmax_cnt = 0\n\nc = collections.Counter(a_list)\n\nfor i in range(max(c.keys()) + 1) :\n cnt = c[i] + c[i + 1] + c[i + 2]\n \n if max_cnt < cnt :\n max_cnt = cnt\n\nprint(max_cnt)", "n=int(input())\na=list(map(int,input().split()))\n\np=[]\nfor i in range(n):\n p.append(a[i]-1)\n p.append(a[i])\n p.append(a[i]+1)\n\nfrom collections import Counter\n\nc=Counter(p).most_common()\n\nm = list(c)[0][0]\n\nans=0\n\nfor i in range(n):\n if abs(a[i]-m)<=1:\n ans+=1\n\nprint(ans)\n", "n = int(input())\nA = list(map(int, input().split()))\nX = [0]*(10**5+5)\nfor a in A:\n X[a]+=1\n X[a+1]+=1\n X[a-1]+=1\nprint(max(X))", "import statistics\nN = int(input())\nA = list(map(int, input().split()))\nans = []\nfor a in A:\n ans.append(a)\n ans.append(a-1)\n ans.append(a+1)\nmode = statistics.mode(ans)\nprint(ans.count(mode))", "import sys\ninput = lambda: sys.stdin.readline().rstrip()\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n cnt = [0] * (max(a)+3)\n \n for i in a:\n cnt[i-1] += 1\n cnt[i] += 1\n cnt[i+1] += 1\n \n print(max(cnt))\n \ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\na = list(map(int,input().split()))\nmode = [0]*(10**5+2)\nfor i in range(len(a)):\n k = a[i]\n if(a == 0):\n mode[k] += 1\n mode[k+1] += 1\n else:\n mode[k-1] += 1\n mode[k] += 1\n mode[k+1] += 1\n\nprint(max(mode))", "N = int(input())\nA = list(map(int,input().split()))\nans = 0\nA.sort()\na=0\nb=0\nc=1\n\nfor i in range(N-1):\n if A[i] == A[i+1]:\n a += 1\n b += 1\n c += 1\n elif A[i]+1 == A[i+1]:\n if ans < a:\n ans = a\n a = b\n a += 1\n b = c\n b += 1\n c = 1\n elif A[i]+2 == A[i+1]:\n if ans < a:\n ans = a\n if ans < b:\n ans = b\n a = c\n a += 1\n b = 1\n c = 1\n else:\n if ans < a:\n ans = a\n if ans < b:\n ans = b\n if ans < c:\n ans = c\n a = 1\n b = 1\n c = 1\n\nif ans < a:\n ans = a\nif ans < b:\n ans = b\nif ans < c:\n ans = c\nprint(ans)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 21 23:37:30 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\n\nA = [int(x) for x in input().split()]\n\nd = [0]*(10**5 + 1)\n\nfor a in A:\n if a - 1 >= 0:\n d[a-1] += 1\n d[a] += 1\n d[a+1] += 1\n\nans = max(d)\n\nprint(ans)", "import collections\n\nN=int(input())\nList = list(map(int, input().split()))\nsumList = []\nfor i in range(N):\n sumList.append(List[i])\n sumList.append(List[i]+1)\n sumList.append(List[i]-1)\nc = collections.Counter(sumList)\nprint(c.most_common()[0][1])", "N=int(input())\na=list(map(lambda x: int(x), input().split(\" \")))\n#print(a)\nsums=[0]*(10**5+1)\n#print(sums)\n\nfor val in a:\n #print(val)\n if val-1>=0:\n sums[val-1]=sums[val-1]+1\n sums[val]=sums[val]+1\n if val+1<=10**5:\n sums[val+1]=sums[val+1]+1\n\nprint(max(sums))", "# -*- coding: utf-8 -*-\nimport numpy as np\nimport sys\nfrom collections import deque\nfrom collections import defaultdict\nimport heapq\nimport collections\nimport itertools\nimport bisect\nfrom scipy.special import comb\nimport copy\nsys.setrecursionlimit(10**6)\n\n\ndef zz():\n return list(map(int, sys.stdin.readline().split()))\n\n\ndef z():\n return int(sys.stdin.readline())\n\n\ndef S():\n return sys.stdin.readline()[:-1]\n\n\ndef C(line):\n return [sys.stdin.readline() for _ in range(line)]\n\n\nN = z()\nA = zz()\nc = collections.Counter(A)\nans = 0\nfor x in range(max(A)+1):\n tmp = c[x]\n try:\n tmp += c[x-1]\n except:\n pass\n try:\n tmp += c[x+1]\n except:\n pass\n ans = max(tmp, ans)\nprint(ans)\n", "N = int(input())\nA = list(map(int,input().split()))\n\ncount = [0] * (10 ** 5 + 1)\n\nfor a in A:\n count[a] += 1\n \nans = 0 \nfor i in range(1, 10 ** 5):\n X = count[i-1] + count[i] + count[i+1]\n ans = max(ans, X)\n \nprint(ans)", "n = int(input())\nlis = list(map(int, input().split()))\ncon = [0] * (10**5+2)\n\nfor v in lis:\n con[v] +=1\n con[v+1] += 1\n con[v+2] += 1\n\nprint(max(con))", "N = int(input())\nA = list(map(int,input().split()))\nco = [0 for i in range(100002)]\n\nfor i in A:\n co[i] += 1\n\nans = 0\nfor i in range(100001):\n if i == 0:\n x = co[0] + co[1]\n else:\n x = co[i - 1] + co[i] + co[i + 1]\n\n ans = max(ans, x)\nprint(ans)\n", "n=int(input())\na=list(map(int, input().split()))\nans = 0\nl = [0]*(10**5+2)\nfor i in range(n):\n l[a[i]] +=1\nfor i in range(10**5):\n x = l[i] +l[i+1]+l[i-1]\n ans = max(ans,x)\nprint(ans)", "N = int(input())\nA = list(map(int,input().split()))\nK = max(A)\nls = [0 for i in range(K+2)]\nfor i in range(N):\n if A[i] == 0:\n ls[A[i]] += 1\n ls[A[i]+1] += 1\n else:\n ls[A[i]-1] += 1\n ls[A[i]] += 1\n ls[A[i]+1] += 1\nprint(max(ls))", "import sys\nfrom collections import Counter\n\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int, input().split()))\n\ncounter = Counter(A)\nans = 0\nfor value, count in counter.items():\n if value - 1 in counter:\n count += counter[value - 1]\n if value + 1 in counter:\n count += counter[value + 1]\n ans = max(ans, count)\n\nprint(ans)", "import sys\n\ninput = sys.stdin.readline\n\nn = int(input())\n\na_list = list(map(int, input().split()))\nsort_a_list = sorted(a_list)\n\nl = 0\nr = 0\nans = 0\nmax_ans = 0\nsabun = 0\n#print(sort_a_list)\n\nwhile (r < n):\n #print(l,r)\n #print(ans)\n #print(sabun)\n if (sabun <= 2):\n if sort_a_list[r] - sort_a_list[l] > 2:\n l += 1\n sabun = sort_a_list[r] - sort_a_list[l]\n ans -= 1\n continue\n ans += 1\n max_ans = max(max_ans,ans)\n r += 1\n if r >= n:\n break\n sabun = sort_a_list[r] - sort_a_list[l]\n \n else:\n l += 1\n sabun = sort_a_list[r] - sort_a_list[l]\n ans -= 1\nprint(max_ans)", "import numpy as np\n\nn = int(input())\nalist = map(int,input().split())\n\nsort = np.zeros(10**5+1)\nfor a in alist:\n sort[a]+=1\nmax=0\nfor i in range(10**5-2):\n tmp = sort[i:i+3].sum()\n if max<tmp:\n max=tmp\n\nprint(int(max))", "import collections\nn = int(input())\nl = sorted(list(map(int, input().split())) )\nc = collections.Counter(l)\nL = [0]*(10**5+1)\nM = [0]*(10**5+1)\n \nfor x,y in c.items():\n L[x] += y\n \nM[0] = L[0]\nM[10**5] = L[10**5]\nfor i in range(1,10**5):\n M[i] = L[i-1] + L[i] + L[i+1]\nprint(max(M))", "n = int(input())\na = list(map(int, input().split()))\nfor i in range(n):\n a[i] -= 1\n\nc = [0 for _ in range(100005)]\n\nfor i in range(n):\n val = a[i]\n c[val - 1] += 1\n c[val] += 1\n c[val + 1] += 1\n\nans = 0\nfor i in range(100005):\n ans = max(ans, c[i])\n\nprint(ans)", "# coding: utf-8\n\n\ndef main():\n _ = int(input())\n A = list(map(int, input().split()))\n B = [0] * 100002\n ans = 0\n\n for a in A:\n if a != 0: B[a - 1] += 1\n B[a] += 1\n B[a + 1] += 1\n\n ans = max(B)\n \n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "n=int(input())\na=sorted(list(map(int, input().split(\" \"))))\ncounter = [0 for i in range(10 ** 5 + 2)]\nans = 0\n\nfor i in range(n):\n counter[a[i]] += 1\n#print(counter)\nfor i in range(1, 10 ** 5 + 1):\n temp = sum(counter[i-1:i+2])\n ans = max(ans, temp)\nprint(ans)", "import collections\n\nN = int(input())\na = list(map(int, input().split()))\n\nfor i in range(len(a)):\n if a[i] > 0:\n a.append(a[i]-1)\n a.append(a[i]+1)\n\nres = collections.Counter(a)\n\nprint(max(res.values()))", "N = int(input())\na = map(int, input().split())\n\nresult_num_list = [0] * (10 ** 5 + 5)\nfor i in a:\n result_num_list[i-1] += 1\n result_num_list[i] += 1\n result_num_list[i+1] += 1\n\nprint(max(result_num_list))", "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n m = 10**5\n l = [0]*m\n for i in range(n):\n if a[i] >= 1:\n l[a[i]-1] += 1\n l[a[i]] += 1\n if a[i] < m-1:\n l[a[i]+1] += 1\n print(max(l))\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\ncnt = [0]*100002\n\na = list(map(int,input().split()))\n\nfor v in a:\n cnt[v-1] += 1\n cnt[v] += 1\n cnt[v+1] += 1\n \n#print(cnt)\nprint((max(cnt)))\n\n", "n = int(input())\narr = [int(x) for x in input().split()]\ncnt = [0] * (10 ** 5 + 1)\nfor a in arr:\n cnt[a] += 1\n cnt[a+1] += 1\n if a > 0:\n cnt[a-1] += 1\n\nprint(max(cnt))", "import collections\nn = int(input())\na = list(map(int, input().split()))\na1 = [x - 1 for x in a]\na2 = [x + 1 for x in a]\nb = a + a1 + a2\nc = collections.Counter(b)\n\nprint(max(c.values()))", "from sys import stdin, stdout # only need for big input\n\ndef increment_dict(a_dict, element):\n if element in a_dict:\n a_dict[element] = a_dict[element] + 1\n else:\n a_dict[element] = 1\n\ndef solve():\n n = int(input())\n a = list(map(int, input().split()))\n mp = dict()\n best_count = 0\n for num in a:\n increment_dict(mp, num)\n increment_dict(mp, num - 1)\n increment_dict(mp, num + 1)\n best_count = max(best_count, mp[num], mp[num-1], mp[num+1])\n print(best_count)\n\ndef main():\n solve()\n\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\nA = list(map(int, input().split()))\n\nans = [0] * (max(A) + 2)\n\nfor a in A:\n if a == 0:\n ans[a] += 1\n ans[a + 1] += 1\n if a != 0:\n ans[a - 1] += 1\n ans[a] += 1\n ans[a + 1] += 1\n\nprint((max(ans)))\n", "N = int(input())\na = sorted([int(c) for c in input().split()])\n#2\u56de\u306e\u5909\u308f\u308a\u76ee\u3092\u8a18\u61b6\nc1,c2,c3 = [0,0,0]\nma = 1\nfor i in range(N):\n if i > 0:\n if a[i]==a[i-1]+1:\n c1 = c2 \n c2 = c3\n c3 = i\n elif a[i]!=a[i-1]:\n c1,c2,c3=[i,i,i]\n if ma < i - c1+1:\n ma = i - c1+1\n\nprint(ma)", "N = int(input())\nA_list = list(map(int, input().split()))\nA_dict = dict()\nfor a in A_list:\n if A_dict.get(a) is None:\n A_dict[a] = 1\n else:\n A_dict[a] += 1\nans = 0\nfor key, val in list(A_dict.items()):\n temp = 0\n if A_dict.get(key - 1) is not None:\n temp += A_dict.get(key - 1)\n if A_dict.get(key) is not None:\n temp += A_dict.get(key)\n if A_dict.get(key + 1) is not None:\n temp += A_dict.get(key + 1)\n ans = max(temp, ans)\nprint(ans)\n", "import sys\nimport math\nimport itertools\nimport collections\nimport heapq\nimport re\nimport numpy as np\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()\na = rl()\nc = collections.Counter(a)\nans = 0\nif n == 1:\n print((1))\n return\nif n == 2:\n if abs(a[0] - a[1]) == 1:\n print((2))\n return\n else:\n print((1))\n return\nfor i in range(10**5 + 2):\n ans = max(ans, c[i] + c[i+1] + c[i+2])\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", "import numpy as np\n\nN = int(input())\nA = list(map(int, input().split()))\nA = np.bincount(np.array(A, dtype='int64'))\nAns = A.copy()\nAns[1:] += A[:-1]\nAns[:-1] += A[1:]\nprint((max(Ans)))\n\n", "N, *A = map(int, open(0).read().split())\n\nC = {}\nfor a in A:\n if a in C.keys():\n C[a] += 1\n else:\n C[a] = 1\nB = list(C.items())\nB.sort(key=lambda x: x[0])\n\nans = 0\nfor i in range(len(B)):\n count = B[i][1]\n if i+1 < len(B) and B[i+1][0] == B[i][0]+1:\n count += B[i+1][1]\n if i+2 < len(B) and B[i+2][0] == B[i][0]+2:\n count += B[i+2][1]\n ans = max(ans, count)\nprint(ans)", "from collections import Counter\nwith open(0) as f:\n N, *a = map(int, f.read().split())\ndata = [x-1 for x in a] + [x for x in a] + [x+1 for x in a]\nans = Counter(data).most_common(1)[0][1]\nprint(ans)", "N=input()\nls=[int(s) for s in input().split()]\nnum=[0 for s in range(1000001)]\nfor i in ls:\n num[i]+=1\nans=[num[i-1]+num[i]+num[i+1] for i in range(100000)]\nprint(max(ans))", "input();c=[0]*10**6\nfor i in input().split():\n for j in(0,1,2):c[int(i)+j]+=1\nprint(max(c))", "N=int(input())\na=list(map(int,input().split()))\ncount=[0 for _ in range(100001)]\nfor x in a:\n count[x]+=1\n count[x+1]+=1\n if x>0:\n count[x-1]+=1\nprint((max(count)))\n", "N=int(input())\nA=list(map(int,input().split()))\n\nans=0\n\ncnt=[0]*(10**5+10)\nfor i in range(N):\n cnt[A[i]]+=1\n\nfor i in range(0,100000):\n sum=cnt[i]+cnt[i+1]+cnt[i+2]\n ans=max(ans,sum)\n\nprint(ans)", "N=int(input())\na=list(map(int, input().split(\" \")))\n#print(a)\nsums=[0]*(10**5)\n#print(sums)\n\nfor val in a:\n #print(val)\n if val-1>=0:\n sums[val-1]=sums[val-1]+1\n sums[val]=sums[val]+1\n if val+1<10**5:\n sums[val+1]=sums[val+1]+1\n\nprint(max(sums))", "from collections import defaultdict\n\nN = int(input())\na = tuple(map(int, input().split()))\ncnt = defaultdict(int)\n\nfor i in range(N):\n\tcnt[a[i]-1] += 1\n\tcnt[a[i]] += 1\n\tcnt[a[i]+1] += 1\nprint(max(cnt.values()))", "n = int(input())\na = list(map(int,input().split()))\nans = 0\n \nl = [0]*100001\n \nfor i in a:\n l[i] += 1\n\nfor i in range(len(l)-2):\n ans = max(ans,l[i]+l[i+1]+l[i+2])\n \nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\nimport collections\n\nlis = collections.Counter(a)\nans = 0\nmemo = 0\n#print(lis)\n\nfor i in range(10**5):\n memo = lis[i-1] + lis[i] + lis[i+1]\n #print(lis[i-1], lis[i], lis[i+1])\n if memo > ans:\n ans = memo\n\n\nprint(ans)\n\n\n\n", "N = int(input())\na = [int(x) for x in input().split()]\n\nM = max(a)\n\nC = [0] * (M + 1)\n\nfor i in range(N):\n C[a[i]] += 1 \n\nans = 0\n\nfor i in range(1,M):\n wa = C[i - 1] + C[i] + C[i + 1]\n ans = max(ans, wa)\n\nif M <= 1:\n ans = N\n\nprint(ans)", "#\uff08i+1 and i and i-1\uff09\u306e\u5408\u8a08\u6570\u304c\u4e00\u756a\u591a\u3044\u3068\u3053\u308d\u3092\u898b\u3064\u3051\u308b\nfrom collections import Counter\nans = []\nN = int(input())\na = list(map(int,input().split()))\nnum = Counter(a)\nfor i in set(a):\n ans.append(num[i] + num[i+1] + num[i-1])\n \nprint(max(ans))", "#!/usr/bin/env python3\ncnt=[0]*100002\ninput()\nfor x in map(int,input().split()):\n cnt[x]+=1\n cnt[x+1]+=1\n cnt[x+2]+=1\nprint(max(cnt))", "N = int(input())\nA = list(map(int, input().split()))\n \nans = [0] * (max(A) + 2)\n \nfor a in A:\n if a == 0:\n ans[a] += 1\n ans[a + 1] += 1\n if a != 0:\n ans[a - 1] += 1\n ans[a] += 1\n ans[a + 1] += 1\nprint(max(ans))", "import numpy as np\nn=int(input())\na=np.array(list(map(int,input().split())))\nd=np.array([0]*(10**5+2))\nfor i in a:\n for j in (-1,0,1):\n d[i+1+j]+=1\nprint(max(d))", "N = int(input())\nA = list(map(int,input().split()))\nnums = [0]*100000\nans_list=[]\n\nfor i in range(N):\n nums[A[i]] += 1\n\nfor j in range(1,99999):\n ans_list.append(nums[j-1]+nums[j]+nums[j+1])\n\nprint(max(ans_list))", "N=int(input())\na=list(map(int,input().strip().split()))\n\ndp=[0 for n in range(max(a)+1)]\nfor n in range(N):\n dp[a[n]]+=1\n\nans=0\nif len(dp)==1:\n ans=dp[0]\nelse:\n for n in range(1,len(dp)-1):\n ans=max(ans,dp[n-1]+dp[n]+dp[n+1])\n\nprint(ans)\n", "import sys\nN = int(input())\nA = list(map(int, input().split()))\n\nif N == 1:\n print(1)\n return\n \ncnt = [0 for _ in range(10**5+1)]\nfor a in A:\n if a == 0:\n cnt[a] += 1\n cnt[a+1] += 1\n else:\n cnt[a-1] += 1\n cnt[a] += 1\n cnt[a+1] += 1\n \nprint(max(cnt))", "#10 C - Together\nN = int(input())\na = list(map(int,input().split()))\na = sorted(a, reverse = True)\na_set = set(a)\n\n#a\u306e\u5404\u8981\u7d20\u306e\u500b\u6570\u3092\u30ab\u30a6\u30f3\u30c8\na_cnt = [0]*(max(a)+2)#0\u304b\u3089max(a)+1\u307e\u3067\nfor i in a:\n a_cnt[i] += 1\n\nmcnt = 0\nfor j in a:\n cnt = a_cnt[j]\n if j-1 in a_set:\n cnt += a_cnt[j-1]\n if j+1 in a_set:\n cnt += a_cnt[j+1]\n mcnt = max(mcnt,cnt) \nprint(mcnt)", "import collections\nN = int(input())\nlsA = list(map(int,input().split()))\ncounterA = collections.Counter(lsA)\nans = 0\nfor X in range(1,10**5+1):\n b1 = counterA[X-1]\n b2 = counterA[X]\n b3 = counterA[X+1]\n ans = max(ans,sum([b1,b2,b3]))\nprint(ans)", "n = int(input())\na_lst = list(map(int, input().split()))\nfor i in range(n):\n a_lst[i] += 1\n\nmax_a = max(a_lst)\ncount_lst = [0] * (max_a + 2)\n\n\nfor i in range(n):\n a = a_lst[i]\n index1 = a - 1\n index2 = a\n index3 = a + 1\n\n count_lst[index1] += 1\n count_lst[index2] += 1\n count_lst[index3] += 1\n\nmaximum = max(count_lst)\nprint(maximum)", "n = int(input())\na = list(map(int,input().split()))\nb = []\nfor i in range(n):\n b += [a[i],a[i]+1,a[i]-1]\nimport collections\nc = collections.Counter(b)\nprint(c.most_common()[0][1])", "'''\nCreated on 2020/10/01\n\n@author: harurun\n'''\nimport sys\npin=sys.stdin.readline\n\ndef main():\n N=int(pin())\n a=list(map(int,pin().split()))\n d=[0]*(10**5)\n for i in a:\n d[i]+=1\n ans=0\n for i in range(10**5-2):\n ans=max(ans,d[i]+d[i+1]+d[i+2])\n print(ans)\n return \nmain()", "n = int(input())\nnumbers = list(map(int, input().split()))\nnumber_colle = [0] * (10 ** 5 + 2)\nfor i in range(n):\n choise = numbers[i] + 1\n for j in [-1, 0, 1]:\n number_colle[choise + j] += 1\n\nprint((max(number_colle)))\n", "import collections\n\nn = int(input())\na = list(map(int,input().split()))\nc = a + [i-1 for i in a] + [i+1 for i in a]\ncntList = collections.Counter(c)\n\nprint((cntList.most_common()[0][1]))\n", "N, *A = map(int, open(0).read().split())\n\nC = {}\nfor a in A:\n if a in C.keys():\n C[a] += 1\n else:\n C[a] = 1\nB = list(C.items())\nB.sort(key=lambda x: x[0])\n\nM = len(B)\nans = 0\nfor i in range(M):\n count = B[i][1]\n if i-1 >= 0 and B[i-1][0] == B[i][0]-1:\n count += B[i-1][1]\n if i+1 < M and B[i+1][0] == B[i][0]+1:\n count += B[i+1][1]\n ans = max(ans, count)\nprint(ans)"]
{"inputs": ["7\n3 1 4 1 5 9 2\n", "10\n0 1 2 3 4 5 6 7 8 9\n", "1\n99999\n"], "outputs": ["4\n", "3\n", "1\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
28,532
83e356c45cabd5d5cdd592b5c80903cc
UNKNOWN
We have an N \times N square grid. We will paint each square in the grid either black or white. If we paint exactly A squares white, how many squares will be painted black? -----Constraints----- - 1 \leq N \leq 100 - 0 \leq A \leq N^2 -----Inputs----- Input is given from Standard Input in the following format: N A -----Outputs----- Print the number of squares that will be painted black. -----Sample Input----- 3 4 -----Sample Output----- 5 There are nine squares in a 3 \times 3 square grid. Four of them will be painted white, so the remaining five squares will be painted black.
["print(int(input())**2 - int(input()))", "a=int(input())\nb=int(input())\nprint(a*a-b)", "n = int(input())\na = int(input())\nprint(n*n-a)", "N = int(input())\nA = int(input())\nprint((N*N - A))\n", "n = int(input())\na = int(input())\n\nprint(n*n-a)", "N = int(input())\nA = int(input())\nprint(N**2-A)", "n = int(input())\na = int(input())\nprint(n**2 - a)", "print(int(input()) ** 2 - int(input()))", "a = int(input())\nb = int(input())\nprint(a*a-b)", "n=int(input())\na=int(input())\nprint(n*n-a)", "# A - Bichrome Cells\n\n# N*N\u306e\u30de\u30b9\u76ee\u304c\u3042\u308a\u3001A\u30de\u30b9\u3092\u767d\u306b\u5857\u3063\u305f\u5834\u5408\u3001\u6b8b\u308a\u306f\u4f55\u30de\u30b9\u304b\n\n\nN = int(input())\nA = int(input())\n\nprint(((N * N) - A))\n", "n,a=int(input()),int(input())\nprint(n**2-a)", "# N\u00d7N\u306e\u30de\u30b9\u76ee\u306e\u3046\u3061A\u30de\u30b9\u3092\u5857\u3063\u305f\u6b8b\u308a\u306e\u30de\u30b9\u6570\n\nN = int(input())\nA = int(input())\n\nanswer = N ** 2 - A\nprint(answer)", "n = int(input())\na = int(input())\nprint(n * n - a)", "N = int(input())\nA = int(input())\n\nprint((N ** 2 - A))\n", "n = int(input())\na = int(input())\nprint(n**2-a)", "m = int(input())\nn = int(input())\nm = m*m\nprint(m - n)", "n = int(input())\na = int(input())\nprint(n ** 2 - a)", "N, A = (int(input()) for i in range(2))\nprint(N**2 - A)", "n = int(input())\na = int(input())\n\nans = n*n-a\n\nprint(ans)", "print(int(input())**2-int(input()))", "N = int(input())\nA = int(input())\n\nprint(N*N - A)", "x = int(input())\ny = int(input())\nprint(x**2-y)", "# \u5165\u529b\nN = int(input())\nA = int(input())\n\n# N\u306e2\u4e57\u3072\u304fA\nanswer = N ** 2 - A\n\n# \u51fa\u529b\nprint(answer)", "n = int(input())\na = int(input())\n\nprint(n * n - a)", "N = int(input())\nA = int(input())\n\nprint((N * N - A))\n", "n=int(input())\na=int(input())\nprint(n**2-a)", "print(int(input())**2 - int(input()))", "N = int(input())\nA = int(input())\n\nN *= N\nB = N - A\n\nprint(B)", "n = int(input())\na = int(input())\n\nif n ** 2 - a < 0:\n print((0))\nelse:\n print((n ** 2 - a))\n", "N = int(input())\nA = int(input())\nprint(N**2-A)", "N = int(input())\nA = int(input())\n\nprint(N**2 - A)", "def main():\n n, a = (int(input()) for _ in range(2))\n print(n**2 - a)\n\n\nmain()", "n=int(input())\na=int(input())\n\nprint(n**2-a)", "N = int(input())\nA = int(input())\nprint(N * N - A)", "a = int(input())\nprint((a * a - int(input())))\n", "def iroha():\n a = [int(input()) for i in range(2)]\n print(a[0]*a[0]-a[1])\n \ndef __starting_point():\n iroha()\n__starting_point()", "#\n# abc074 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\"\"\"\n output = \"\"\"5\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"19\n100\"\"\"\n output = \"\"\"261\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"10\n0\"\"\"\n output = \"\"\"100\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n A = int(input())\n\n print((N*N-A))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "# AtCoder abc074 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\nn = int(input())\nwhite = int(input())\n\n# \u51e6\u7406\nblack = n ** 2 - white\n\n# \u51fa\u529b\nprint(black)\n", "# \u5165\u529b\nN = int(input())\nA = int(input())\n\n# \u51e6\u7406\nanswer = N ** 2 - A\n\n# \u51fa\u529b\nprint(answer)", "N = int(input())\nA = int(input())\n\nprint( (N ** 2 ) - A)", "n=int(input())\na=int(input())\nans=n**2-a\nprint(ans)", "N=int(input())\nA=int(input())\nprint(N*N-A)", "n = int(input())\na = int(input())\nprint((n ** 2 - a))\n", "N = int(input())\nA = int(input())\nprint(N*N-A)", "S_list = [int(input()) for i in range(2)]\n\nprint((S_list[0]**2 - S_list[1]))\n", "# N \u00d7 N \u306e\u30de\u30b9\u76ee\u304c\u3042\u308a\u307e\u3059\u3002\n# \u3053\u306e\u30de\u30b9\u76ee\u306e\u5404\u30de\u30b9\u3092\u767d\u8272\u307e\u305f\u306f\u9ed2\u8272\u306b\u5857\u308b\u3053\u3068\u306b\u3057\u307e\u3057\u305f\n# (\u3059\u3079\u3066\u306e\u30de\u30b9\u3092\u3069\u3061\u3089\u304b\u7247\u65b9\u306e\u8272\u306b\u5857\u308a\u307e\u3059)\u3002\n#\n# \u3061\u3087\u3046\u3069 A\u30de\u30b9\u3092\u767d\u8272\u306b\u5857\u308b\u3068\u304d\u3001\n# \u9ed2\u8272\u306b\u5857\u308b\u3053\u3068\u306b\u306a\u308b\u30de\u30b9\u306f\u3044\u304f\u3064\u3042\u308b\u3067\u3057\u3087\u3046\u304b\u3002\n\n# \u5236\u7d04\n# 1 \u2266 N \u2266 100\n# 0 \u2266 A \u2266 N\u306e2\u4e57\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 N, A \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\nn = int(input())\na = int(input())\n\n# \u8a08\u7b97\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\nresult = (n * n) - a\n\nprint(result)\n", "N = int(input())\nA = int(input())\n\nprint(N * N - A)", "N = int(input())\nA = int(input())\n\nprint(N * N - A)", "m = int(input())\nn = int(input())\nm = m*m\nprint(m - n)", "# 074_a\nN=int(input())\nA=int(input())\nsum=N*N\nif (1<=N and N<=100) and (0<=A and A<=N**N):\n print(sum-A)", "n = int(input())\na = int(input())\nprint(n * n - a)", "N=int(input())\nA=int(input())\nprint((N*N-A))\n", "N = int(input())\nM = int(input())\nprint(N**2 - M)", "# N\u306e\u307e\u3059\u3081\u3068\u767d\u306b\u5857\u3063\u305f\u30de\u30b9\u76eeA\u3092\u6574\u6570\u3067\u5165\u529b\nN = int(input())\nA = int(input())\n# N*N\u30de\u30b9\u304b\u3089A\u30de\u30b9\u5857\u3063\u305f\u3092\u4f59\u308a\u3092\u51fa\u529b\nprint(N**2 - A)", "#!/usr/bin/env python3\n\ndef main():\n n = int(input())\n a = int(input())\n print((n * n - a))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n=int(input())\na=int(input())\nprint((n*n-a))\n", "a=int(input())\nb=int(input())\nprint(a*a-b)", "N = int(input())\nA = int(input())\nprint(max(N*N-A,0))", "# 074a\n\nN = int(input())\nA = int(input())\n\nBlack_area = N ** 2 - A\nprint(Black_area)\n", "N = int(input())\nA = int(input())\n\n# N\u00d7N\u306e\u30de\u30b9\u76ee\u304c\u3042\u308a\u307e\u3059\nN *= N\n\n# A\u30de\u30b9\u3092\u767d\u8272\u306b\u5857\u308b\u3068\u304d\u3001\u9ed2\u8272\u306b\u5857\u308b\u3053\u3068\u306b\u306a\u308b\u30de\u30b9\u306f\u3044\u304f\u3064\u3042\u308b\u304b\u51fa\u529b\nB = N - A\nprint(B)", "N = int(input())\nA = int(input())\n\nprint(N**2 - A)", "N=int(input())\nA=int(input())\nprint(N**2-A)", "a = int(input())\nb = int(input())\nprint((a*a - b))\n", "# A - Bichrome Cells\n# https://atcoder.jp/contests/abc074/tasks/abc074_a\n\nN = int(input())\nA = int(input())\n\ni = N * N\nresult = i - A\n\nprint(result)\n", "n = int(input())\na = int(input())\n\nprint(n**2 - a)", "N = int(input())\nA = int(input())\n\nprint(N ** 2 - A)", "n = int(input())\na = int(input())\nprint( n*n - a )", "N = int(input())\nA = int(input())\n\nprint(N ** 2 - A)", "a=int(input())\nb=int(input())\nprint(a**2-b)", "n = int(input())\na = int(input())\n\nprint(n*n - a)", "a = int(input())\nb = int(input())\nprint((a * a - b))\n", "n = int(input())\na = int(input())\nprint(n*n - a)", "n = int(input())\na = int(input())\n\nanswer = n ** 2 - a\nprint(answer)", "# \u5165\u529b\nN = int(input())\nA = int(input())\n\n# \u51fa\u529b\nprint((N ** 2 - A))\n", "# \u30de\u30b9\u306e\u7dcf\u6570\u3068\u767d\u8272\u306e\u30de\u30b9\u6570\u3092\u53d6\u5f97\nN = int(input())\nA = int(input())\nTotal = N ** 2\n\n# \u9ed2\u8272\u306b\u5857\u308b\u30de\u30b9\u6570\u3092\u8a08\u7b97\u3057\u3066\u51fa\u529b\nBlack = Total - A\nprint(Black)\n", "N = int(input())\nA = int(input())\nans = N**2 - A\nprint(ans)", "N = int(input())\nA = int(input())\nprint((N * N - A))\n", "def get_colored_cells():\n N = int(input())\n A = int(input())\n print(N ** 2 - A)\n\nget_colored_cells()", "n = int(input())\na = int(input())\n\ny = n * n\nx = y - a\n\nprint(x)", "print((int(input()) ** 2) - int(input()))", "n=int(input())\na=int(input())\nprint(n**2-a)", "N = int(input())\nA = int(input())\nprint(N*N-A)", "N = int(input())\nA = int(input())\nprint(N*N - A)", "n=int(input())\na=int(input())\nprint(n**2-a)", "N, A = (int(input()) for i in range(2))\nprint(N ** 2 - A)", "print(int(input())**2-int(input()))", "n = int(input())\na = int(input())\nprint(n**2-a)", "n = int(input())\na = int(input())\nprint(n**2-a)", "#!/usr/bin/env python3\n\ndef main():\n n = int(input())\n a = int(input())\n print((n * n - a))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nA = int(input())\nprint(N ** 2 - A)", "#74\nN=int(input())\nA=int(input())\nprint(N**2-A)", "a = int(input())\nb = int(input())\n\nprint(a ** 2 - b)", "N=int(input())\nA=int(input())\nprint(N**2-A)", "N = int(input())\nA = int(input())\n\nprint(N ** 2 - A)", "a,b=[int(input()) for i in range(2)]\n\nprint(a**2-b)", "n = int(input())\na = int(input())\n\nprint(n * n - a)", "with open(0) as f:\n n, a = map(int, f.read().split())\nprint(n**2-a)"]
{"inputs": ["3\n4\n", "19\n100\n", "10\n0\n"], "outputs": ["5\n", "261\n", "100\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
9,448
86d8c359812a39654bd2ef8cb2d430ce
UNKNOWN
Three poles stand evenly spaced along a line. Their heights are a, b and c meters, from left to right. We will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, b-a = c-b. Determine whether the arrangement of the poles is beautiful. -----Constraints----- - 1 \leq a,b,c \leq 100 - a, b and c are integers. -----Input----- Input is given from Standard Input in the following format: a b c -----Output----- Print YES if the arrangement of the poles is beautiful; print NO otherwise. -----Sample Input----- 2 4 6 -----Sample Output----- YES Since 4-2 = 6-4, this arrangement of poles is beautiful.
["a,b,c=map(int, input().split()) \nprint(\"YES\" if b-a==c-b else \"NO\")", "pole1, pole2, pole3 = map(int, input().split())\nif pole2 - pole1 == pole3 - pole2:\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\nif b-a == c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "# 058_a\na, b, c = map(int, input().split())\nif (1 <= a & a <= 100) & (1 <= b & b <= 100) & (1 <= c & c <= 100):\n d_ab = b - a\n d_bc = c - b\n if d_ab == d_bc:\n print('YES')\n else:\n print('NO')", "# A - \u03b9\u22a5l\n# https://atcoder.jp/contests/abc058/tasks/abc058_a\n\na, b, c = list(map(int, input().split()))\n\nresult = 'NO'\n\nif b - a == c - b:\n result = 'YES'\nelif a - b == b - c:\n result = 'YES'\n\nprint(result)\n", "a, b, c = list(map(int, input().split()))\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')\n", "a,b,c=map(int,input().split())\nprint(\"YES\")if b-a==c-b else print(\"NO\")", "a,b,c=map(int,input().split())\n\nif b-a==c-b:\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\nif b-a == c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = map(int, input().split())\nif b-a == c-b:\n print('YES')\nelse:\n print('NO')", "a,b,c=map(int, input().split())\nif (b-a)==(c-b):\n print('YES')\nelse:\n print('NO')", "a, b, c = list(map(int, input().split()))\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a, b, c = map(int,input().split())\nprint('YES') if b - a == c - b else print('NO')\n", "a, b, c = list(map(int, input().split()))\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')\n", "a,b,c = map(int,input().split())\nprint(['NO','YES'][b-a == c-b])", "a,b,c = map(int,input().split())\nif b-a==c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c = list(map(int, input().split()))\nif b-a==c-b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a, b, c = map(int,input().split())\n\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c = map(int,input().split())\n\nprint('YES' if b-a == c-b else 'NO')", "a, b, c = map(int, input().split())\n\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")", "def main():\n t = list(map(int, input().split()))\n if t[1] - t[0] == t[2] - t[1]:\n print('YES')\n else:\n print('NO')\n\ndef __starting_point():\n main()\n__starting_point()", "a,b,c=map(int,input().split())\nif b-a==c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = map(int, input().split())\n\nif (b - a) == (c - b):\n print('YES')\nelse:\n print('NO')", "a, b, c = list(map(int, input().split()))\n\ndef __starting_point():\n if (b - a) == (c - b):\n print('YES')\n else:\n print('NO')\n\n__starting_point()", "a,b,c = map(int,input().split())\nif b-a == c-b:\n print('YES')\nelse:\n print('NO')", "a,b,c=map(int,input().split())\nif (b-a)==(c-b):\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "# \u67f1\u306e\u9ad8\u3055a,b,c\u304cb-a=c-b\u3092\u6e80\u305f\u3059\u304b\n\na, b, c = map(int, input().split())\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "def iroha():\n a, b, c = list(map(int, input().split()))\n \n one = b - a\n two = c - b\n\n if one == two:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "a,b,c=map(int,input().split());print('YNEOS'[b-a!=c-b::2])", "a,b,c = map(int,input().split())\nprint('YES' if b-a == c-b else 'NO')", "a,b,c=map(int,input().split())\nif b-a==c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = list(map(int, input().split()))\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\nprint('YES' if b - a == c - b else 'NO')", "a, b, c = map(int, input().split())\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "a, b, c = list(map(int, input().split()))\n\nans = 'NO'\n\nif b - a == c - b:\n ans = 'YES'\nelif a - b == b - c:\n ans = 'YES'\n\nprint(ans)\n", "a,b,c=list(map(int,input().split()))\nif b-a==c-b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a, b, c = map(int, input().split())\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c=list(map(int,input().split()))\n\nif b-a==c-b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "# 3\u672c\u306e\u67f1\u304c\u7b49\u9593\u9694\u306b\u4e26\u3093\u3067\u3044\u307e\u3059\u3002\u67f1\u306e\u9ad8\u3055\u306f\u5de6\u304b\u3089\u9806\u306b\n# a \u30e1\u30fc\u30c8\u30eb,b \u30e1\u30fc\u30c8\u30eb,c \u30e1\u30fc\u30c8\u30eb \u3067\u3059\u3002\n# \u67f1\u306e\u5148\u7aef\u304c\u540c\u4e00\u76f4\u7dda\u4e0a\u306b\u4e26\u3093\u3067\u3044\u308b\u6642\u3001\u3064\u307e\u308a\n# b \u2212 a = c \u2212 b \u3092\u6e80\u305f\u3057\u3066\u3044\u308b\u3068\u304d\u3001\n# \u3053\u306e\u67f1\u306e\u4e26\u3073\u65b9\u3092\u7f8e\u3057\u3044\u3068\u547c\u3073\u307e\u3059\u3002\n# \u67f1\u306e\u4e26\u3073\u65b9\u304c\u7f8e\u3057\u3044\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 a, b, c \u3092\u53d6\u5f97\u3059\u308b\na, b, c = list(map(int, input().split()))\n\n# \u67f1\u306e\u4e26\u3073\u304c\u7f8e\u3057\u3044\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u3066\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\n\nif (b - a) == (c - b):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a,b,c=list(map(int,input().split()))\nif b-a==c-b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "# AtCoder abc058 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\na, b, c = list(map(int, input().split()))\n\n# \u5224\u5b9a\nif (b - a) == (c - b):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a,b,c=map(int,input().split())\nif b-a==c-b: print(\"YES\")\nelse: print(\"NO\")", "a,b,c=map(int,input().split())\nif a-b==b-c:print('YES')\nelse:print('NO')", "a, b, c = map(int, input().split())\n\nif b-a == c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = map(int, input().split())\nif b-a==c-b:\n print('YES')\nelse:\n print('NO')", "a, b, c = list(map(int, input().split()))\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')\n", "a, b, c = map(int, input().split())\nprint('YES' if c - b == b - a else 'NO')", "a,b,c=map(int,input().split())\nif b-a==c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "# \u5165\u529b\na, b, c = map(int, input().split())\n\n# b-a=c-b\u306a\u3089Yes\u3001\u9055\u3046\u306a\u3089No\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "a,b,c = map(int, input().split())\n\nd = b-a\ne = c-b\n\nif d == e:\n print('YES')\nelse:\n print('NO')", "#!/usr/bin/env python3\n\ndef main():\n a, b, c = list(map(int, input().split()))\n print((\"YES\" if b - a == c - b else \"NO\"))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a, b, c = map(int, input().split())\n\nprint(\"YES\" if b-a == c-b else \"NO\")", "a,b,c = map(int,input().split())\nprint(\"YES\" if b-a == c-b else \"NO\")", "a,b,c=map(int,input().split())\nprint(\"YNEOS\"[2*b!=a+c::2])", "a, b, c = map(int, input().split())\nprint((\"NO\", \"YES\")[b - a == c - b])", "a, b, c = map(int,input().split())\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "# 3 \u672c\u306e\u67f1\u304c\u7b49\u9593\u9694\u306b\u4e26\u3093\u3067\u3044\u307e\u3059\u3002\u67f1\u306e\u9ad8\u3055\u306f\u5de6\u304b\u3089\u9806\u306b a \u30e1\u30fc\u30c8\u30eb, b \u30e1\u30fc\u30c8\u30eb, c \u30e1\u30fc\u30c8\u30eb \u3067\u3059\u3002\n# \u67f1\u306e\u5148\u7aef\u304c\u540c\u4e00\u76f4\u7dda\u4e0a\u306b\u4e26\u3093\u3067\u3044\u308b\u6642\u3001\u3064\u307e\u308a b \u2212 a = c \u2212 b \u3092\u6e80\u305f\u3057\u3066\u3044\u308b\u3068\u304d\u3001 \u3053\u306e\u67f1\u306e\u4e26\u3073\u65b9\u3092\u7f8e\u3057\u3044\u3068\u547c\u3073\u307e\u3059\u3002\n# \u67f1\u306e\u4e26\u3073\u65b9\u304c\u7f8e\u3057\u3044\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\na,b,c = map(int,input().split())\n\nif b - a == c - b:\n print('YES')\n\nelse:\n print('NO')", "# \u5404\u6570\u5024\u306e\u53d6\u5f97\na,b,c = map(int,input().split())\n\n# \u8a08\u7b97\u7d50\u679c\u306b\u57fa\u3065\u3044\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = list(map(int, input().split()))\n\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "# 058a\n\na, b, c = list(map(int, input().split()))\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')\n", "a,b,c = map(int, input().split())\nprint('YES' if b-a == c-b else 'NO')", "a, b, c = map(int, input().split())\n\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")", "# A - \u03b9\u22a5l\ndef main():\n a, b, c = map(int, input().split())\n\n if b-a == c-b:\n print('YES')\n else:\n print('NO')\n \n \ndef __starting_point():\n main()\n__starting_point()", "# \u5165\u529b\na, b, c = map(int,input().split())\n\n# \u51e6\u7406\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "a,b,c=map(int,input().split())\nprint('YES' if b-a==c-b else 'NO')", "a = input().split()\nif int(a[2])-int(a[1]) == int(a[1])-int(a[0]):\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c=map(int,input().split())\nif b-a==c-b :\n print(\"YES\")\nelse :\n print(\"NO\")", "a,b,c=map(int,input().split())\nprint(\"YES\" if b-a==c-b else \"NO\")", "a,b,c = map(int,input().split())\nif b-a == c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = map(int, input().split())\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "# \u5165\u529b\na, b, c = map(int, input().split())\n\n# \u51fa\u529b\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "a,b,c = map(int,input().split())\nprint(['NO','YES'][b-a==c-b])", "a, b, c = map(int, input().split())\nif((b-a) == (c - b)):\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = map(int, input().split())\nprint('YES' if b-a == c-b else 'NO')", "a, b, c = map(int,input().split())\n\nif b - a == c - b :\n print( \"YES\" )\nelse:\n print( \"NO\" )", "a, b, c = map(int, input().split())\n\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c = map(int, input().split())\nprint('YES' if b-a == c-b else 'NO')", "a=list(map(int,input().split()))\n \nif a[0]+a[2]==2*a[1]:\n print('YES')\n \nelse:\n print('NO')\n", "a,b,c = [int(x) for x in input().split()]\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c = map(int,input().split())\nif b-a == c-b:\n print('YES')\nelse:\n print('NO')", "a,b,c=map(int,input().split())\n\nif b-a==c-b:\n ans=\"YES\"\nelse:\n ans=\"NO\"\n\nprint(ans)", "a, b, c = map(int, input().split())\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "#n = int(input())\na, b, c = 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 b-a == c-b:\n print('YES')\nelse:\n print('NO')\n", "S_list = list(map(int,input().split()))\n \nif S_list[1] - S_list[0] == S_list[2] - S_list[1]:\n result = \"YES\"\nelse:\n result = \"NO\"\nprint(result)", "a,b,c=map(int,input().split(\" \"))\nprint(\"YES\") if b-a==c-b else print(\"NO\")", "a, b, c = input().split()\n\nif int(b) - int(a) == int(c) - int(b):\n print(\"YES\")\nelse:\n print(\"NO\")", "#58\na,b,c=map(int,input().split())\nif b-a==c-b:\n print('YES')\nelse:\n print('NO')", "a,b,c = list(map(int,input().split()))\nprint((\"YES\" if b-a == c-b else \"NO\"))\n", "a, b, c = map(int, input().split())\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\nif b-a == c-b:\n print(\"YES\")\nelse:\n print(\"NO\")", "A, B, C = [int(i) for i in input().split()]\n\nif B - A == C - B:\n print('YES')\nelse:\n print('NO')\n", "a,b,c = map(int,input().split())\n\nif b - a == c - b:\n print('YES')\nelse:\n print('NO')", "a, b, c = map(int, input().split())\nprint('YES' if b - a == c - b else 'NO')", "'''\nabc058 A - \u03b9\u22a5l\nhttps://atcoder.jp/contests/abc058/tasks/abc058_a\n'''\n\na, b, c = list(map(int, input().split()))\n\nif b - a == c - b:\n ans = 'YES'\nelse:\n ans = 'NO'\n\nprint(ans)\n", "a,b,c = map(int,input().split())\nprint(\"YES\" if b-a == c-b else \"NO\")", "a, b, c = map(int,input().split())\n\nif b - a == c - b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, c= list(map(int, input().split()))\nif b-a==c-b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "# A - \u03b9\u22a5l\n\n# b-a = c-b\u3092\u6e80\u305f\u3057\u3066\u3044\u308c\u3070Yes, \u305d\u3046\u3067\u306a\u3051\u308c\u3070No\u3092\u51fa\u529b\u3059\u308b\n\n\na,b,c = list(map(int,input().split()))\n\nif b-a == c-b:\n print('YES')\nelse:\n print('NO')\n"]
{"inputs": ["2 4 6\n", "2 5 6\n", "3 2 1\n"], "outputs": ["YES\n", "NO\n", "YES\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,146
726d4c0a889cd00793f40951114f3cd5
UNKNOWN
It is September 9 in Japan now. You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N? -----Constraints----- - 10≀N≀99 -----Input----- Input is given from Standard Input in the following format: N -----Output----- If 9 is contained in the decimal notation of N, print Yes; if not, print No. -----Sample Input----- 29 -----Sample Output----- Yes The one's digit of 29 is 9.
["n = input()\nif '9' in n:\n print('Yes')\nelse:\n print('No')", "N = input()\n\nif N[0] == '9' or N[1] == '9':\n print('Yes')\nelse:\n print('No')", "print(('No', 'Yes')['9' in input()])", "N = str(input())\nif \"9\" in N:\n print('Yes')\nelse:\n print('No')", "n=int(input())\n\nif n%10==9 or n//10==9:\n ans=\"Yes\"\nelse:\n ans=\"No\"\nprint(ans)", "#93\ns=list(input())\nc=0\nfor i in range(0,len(s)):\n if s[i]=='9':\n c=c+1\nif c==0:\n print('No')\nelse:\n print('Yes')", "n = input()\nif n[0] == \"9\" or n[1] == \"9\":\n print(\"Yes\")\nelse:\n print(\"No\")", "str_num = str(input())\n\nprint((\"Yes\" if \"9\" in str_num else \"No\"))\n", "print(\"Yes\") if \"9\" in input() else print(\"No\")", "N = str(input())\n\nif \"9\" in N:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input('')\n\nif n[0] == '9' or n[1] == '9':\n print('Yes')\nelse:\n print('No')", "a = input()\nprint(\"Yes\" if \"9\" in a else \"No\") ", "N = input()\n\nif \"9\" in N:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = str(input())\n\nif N[0] == '9' or N[1] == '9':\n print('Yes')\nelse:\n print('No')\n", "N = input()\n\nif '9' in N:\n print('Yes')\nelse:\n print('No')", "N = input()\nif '9' in N:\n print('Yes')\nelse:\n print('No')", "def main():\n n = input()\n if \"9\" in n:\n print(\"Yes\")\n else:\n print(\"No\")\n\nmain()\n", "n=input()\nif \"9\" in n:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b=map(int,input())\n\nif a==9 or b==9:\n print(\"Yes\")\nelse:\n print(\"No\")", "s = input()\nans = \"No\"\nfor c in s:\n\tif c == \"9\":\n\t\tans = \"Yes\"\nprint(ans)", "N = str(input())\n\nif N[0] == '9' or N[1] == '9':\n print('Yes')\nelse:\n print('No')\n", "print('Yes' if '9' in input() else 'No')", "N = str(input())\n\nif N[0] == \"9\" or N[1] == \"9\":\n print(\"Yes\")\nelse:\n print(\"No\")", "N = str(input())\nif N[0]== \"9\" or N[1]==\"9\":\n print('Yes')\nelse:\n print('No')", "N = list(input())\n\nif N[0] == '9' or N[1] == '9':\n print('Yes')\nelse:\n print('No')", "n = input()\nif \"9\" in n:\n print(\"Yes\")\nelse:\n print(\"No\")", "N =list(input())\nif N[0] == '9' or N[1]=='9':\n print('Yes')\nelse:\n print('No')", "n = input()\nif \"9\" in n:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "'''\n\u554f\u984c\uff1a\n \u4eca\u3001\u65e5\u672c\u306f 9 \u6708 9 \u65e5\u3067\u3059\u3002\n \u4e8c\u6841\u306e\u6574\u6570 N \u304c\u4e0e\u3048\u3089\u308c\u308b\u306e\u3067\u3001\u5341\u9032\u6cd5\u3067 N \u306b 9 \u304c\u542b\u307e\u308c\u308b\u304b\u7b54\u3048\u3066\u304f\u3060\u3055\u3044\u3002\n'''\n'''\n\u5236\u7d04\uff1a\n10 \u2266 N \u2266 99\n'''\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 N \u3092\u53d6\u5f97\u3059\u308b\nn = int(input())\n\nresult = \"\"\nif n % 10 == 9: # 1\u306e\u4f4d\u304c 9\n result = \"Yes\"\nelif 90 <= n % 100 < 100: # 10\u306e\u4f4d\u304c 9\n result = \"Yes\"\nelse:\n result = \"No\"\n\nprint(result)\n", "print(\"YNeos\"[input().count(\"9\")<1::2])", "print('Yes' if '9' in input() else 'No')", "N=input()\nif \"9\" in N:\n print(\"Yes\")\nelse:\n print(\"No\")", "n=input()\nif \"9\" in n:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = str(input())\n\nif N[0] == \"9\" or N[1] == \"9\":\n result = \"Yes\"\nelse:\n result = \"No\"\n\nprint(result)\n", "N=int(input())\nif 10<=N and N<=99:\n n=str(N)\n if (int(n[0])==9 or int(n[1])==9) or (int(n[0])==9 and int(n[1])==9):\n print('Yes')\n else:\n print('No')", "N = str(input())\n\ndef answer(N: str) -> str:\n if '9' in N:\n return 'Yes'\n else:\n return 'No'\n\nprint(answer(N))", "N = str(input())\n\nif N[0] == '9' or N[1] == '9':\n print('Yes')\nelse:\n print('No')", "# 1\u306e\u4f4d\u300110\u306e\u4f4d\u306b9\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u306e\u5224\u5b9a\n\nN = input()\n\nif \"9\" in N: # in: \u542b\u307e\u308c\u3066\u3044\u305f\u3089True\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a = input()\nif '9' in a:\n print('Yes')\nelse:\n print('No')\n", "n = input()\nif n.count('9') >= 1:\n print('Yes')\nelse:\n print('No')\n", "n = input()\ns = n.find('9')\n\nif s == -1:\n print(\"No\")\nelse:\n print(\"Yes\")\n", "print(\"Yes\" if \"9\" in input() else \"No\")", "# A - September 9\n# https://atcoder.jp/contests/abc073/tasks/abc073_a\n\nn = input()\n\nif n.count('9'):\n print('Yes')\nelse:\n print('No')\n", "N = int(input())\n\n# \u4e8c\u6841\u306e\u6574\u6570 N \u304c\u4e0e\u3048\u3089\u308c\u308b\u306e\u3067\u3001\n# 9 \u304c\u542b\u307e\u308c\u308b\u3068\u304d Yes \u3001\u542b\u307e\u308c\u306a\u3044\u3068\u304d No \u3092\u51fa\u529b\u305b\u3088\u3002\n\nN = str(N)\nif \"9\" in N:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nif '9' in N:\n print('Yes')\nelse:\n print('No')", "n = input()\nprint((\"Yes\" if n.count(\"9\") > 0 else \"No\"))\n", "N = int(input())\n\nnine = list(str(N))\nif \"9\" in nine:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "N = input()\nans = 'No'\nfor i in N:\n if i == '9':\n ans = 'Yes'\nprint(ans)", "# \u6570\u5024\u3092\u53d6\u5f97\nN = str(input())\n\n# \u6587\u5b57\u5217\u3092\u691c\u67fb\u3057\u7d50\u679c\u3092\u51fa\u529b\nif \"9\" in N:\n print(\"Yes\")\nelse:\n print(\"No\")", "def atc_073a(N: int) -> str:\n try:\n str(N).index(\"9\")\n return \"Yes\"\n except ValueError:\n return \"No\"\n\nN = int(input())\nprint(atc_073a(N))", "N = input()\n\nif str(N[0]) == \"9\" or str(N[1]) == \"9\":\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\nif \"9\" in n:\n print('Yes')\nelse:\n print('No')", "N = input()\nif N[0] == '9' or N[1] == '9':\n print('Yes')\nelse:\n print('No')\n", "if input().count('9'):\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n=input()\nif n.count('9'):\n print('Yes')\nelse:\n print('No')\n", "def iroha():\n num = list((input()))\n for i in num:\n if i == \"9\":\n print(\"Yes\")\n return\n \n print(\"No\")\n\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "N = input()\n\nif \"9\" in N:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = int(input())\nn = str(n)\nif \"9\" in n:\n print(\"Yes\")\nelse:\n print(\"No\")", "S = input()\nif S.count('9') == 0:\n print('No')\nelse:\n print('Yes')", "a = input()\nif \"9\" in a:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nif \"9\" in N:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nif N >= 90 or (N - 9) % 10 == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "# 073a\n\ndef atc_073a(N: int) -> str:\n try:\n str(N).index(\"9\")\n return \"Yes\"\n except ValueError:\n return \"No\"\n\nN = int(input())\nprint((atc_073a(N)))\n", "s = input()\nif s[0] == \"9\" or s[1] == \"9\":\n print(\"Yes\")\nelse:\n print(\"No\")", "A=input()\nif \"9\" in A:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nif '9' in N:\n print('Yes')\nelse:\n print('No')\n", "n = input()\nprint(\"Yes\" if \"9\" in n else \"No\")", "print(\"Yes\" if \"9\" in input() else \"No\")", "N = input()\nprint(('Yes' if N.find('9') != -1 else 'No'))\n", "n = input()\nprint(\"Yes\" if n[0] == \"9\" or n[1] == \"9\" else \"No\")", "print(\"YNeos\"[\"9\"not in input()::2])", "a=input()\nif '9' in a:\n print('Yes')\nelse:\n print('No')", "c = input()\nif \"9\" in c:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\n\nif N[0] == '9' or N[1] == '9':\n print('Yes')\nelse:\n print('No')\n", "N = input()\n\nif \"9\" in N:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\n\nnumber_nine = list(str(N))\nif '9' in number_nine:\n print('Yes')\nelse:\n print('No')", "print((\"Yes\" if \"9\" in input() else \"No\"))\n", "\nN = int(input())\n\nif N % 10 == 9 or N // 10 == 9:\n print('Yes')\n\nelse:\n print('No')\n", "n=input()\nif '9' in n:print('Yes')\nelse:print('No')", "N = input()\nprint(\"Yes\" if N[0] == \"9\" or N[1] == \"9\" else \"No\")", "if input().count(\"9\") >= 1:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = str(input())\n\nprint('Yes' if '9' in n else 'No')", "a = list(input())\ncount = 0\nfor i in range (0, len(a)):\n if a[i] == \"9\":\n count += 1\n\nif count > 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nprint(('Yes' if '9' in N else 'No'))\n", "X = str(input())\n\nif '9' in X:\n print('Yes')\nelse:\n print('No')\n", "n = input()\n\nif n[0] != '9' and n[1] != '9':\n print('No')\nelse:\n print('Yes')", "# A - September 9\n\nN = input()\nmy_list = []\n\nfor i in N:\n my_list.append(i)\n\nif \"9\" in my_list:\n print('Yes')\nelse:\n print('No')", "n = str(input())\n\nif n[0] == \"9\" or n[1] == \"9\":\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\n\nif '9' in n:\n print('Yes')\nelse:\n print('No')", "N = input()\n\nif \"9\" in N:\n print( \"Yes\" )\nelse:\n print( \"No\" )", "N = input()\nif N[0]== \"9\" or N[1] == \"9\":\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\n\nif N.find(\"9\") == -1:\n print(\"No\")\nelse:\n print(\"Yes\")", "n=input()\nprint(\"Yes\" if \"9\" in n else \"No\")", "n = input()\nif n[0] == '9' or n[1] == '9':\n print('Yes')\nelse:\n print('No')", "n = input()\n\nprint('Yes' if n[0] == '9' or n[1] == '9' else 'No') ", "#\n# abc073 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 = \"\"\"29\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"72\"\"\"\n output = \"\"\"No\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"91\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = input()\n if N[0] == \"9\" or N[1] == \"9\":\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "if '9' in input():\n print('Yes')\nelse:\n print('No')", "N = str(input())\nif N[0]=='9' or N[1]=='9':\n result = 'Yes'\nelse:\n result = 'No'\nprint(result)", "N = input()\nif '9' in N:\n print('Yes')\nelse:\n print('No')\n", "N=input()\nif N.count(\"9\")>0 :\n print(\"Yes\")\nelse :\n print(\"No\")"]
{"inputs": ["29\n", "72\n", "91\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
10,915
ed8d86825c9a45e28b1bed276612de78
UNKNOWN
There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right. Initially, you are in Square X. You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N. However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1. It is guaranteed that there is no toll gate in Square 0, Square X and Square N. Find the minimum cost incurred before reaching the goal. -----Constraints----- - 1 \leq N \leq 100 - 1 \leq M \leq 100 - 1 \leq X \leq N - 1 - 1 \leq A_1 < A_2 < ... < A_M \leq N - A_i \neq X - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N M X A_1 A_2 ... A_M -----Output----- Print the minimum cost incurred before reaching the goal. -----Sample Input----- 5 3 3 1 2 4 -----Sample Output----- 1 The optimal solution is as follows: - First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred. - Then, travel from Square 4 to Square 5. This time, no cost is incurred. - Now, we are in Square 5 and we have reached the goal. In this case, the total cost incurred is 1.
["import bisect\n\nN,M,X = map(int,input().split())\nA = list(map(int,input().split()))\n\nindex = bisect.bisect_left(A,X)\nans = min(M-index,index)\nprint(ans)", "n,m,x=map(int, input().split())\na=[int(i) for i in input().split()]\n\ncount_1=0\nfor i in range(x):\n if i in a:\n count_1+=1\n \ncount_2=0\nfor i in range(x,n):\n if i in a:\n count_2+=1\n \nprint(min(count_1, count_2))", "# B - Toll Gates\n# https://atcoder.jp/contests/abc094/tasks/abc094_b\n\nn, m, x = list(map(int, input().split()))\na = list(map(int, input().split()))\n\ncost1 = 0\ncost2 = 0\n\nfor i in range(x, 0, -1):\n if i in a:\n cost1 += 1\n\nfor i in range(x, n):\n if i in a:\n cost2 += 1\n\ncost = [cost1, cost2]\nprint((min(cost)))\n", "# 094b\n\ndef atc_094b(NMX: str, Ai_input: str) -> int:\n N, M, X = list(map(int, NMX.split(\" \")))\n Ai = [int(ai) for ai in Ai_input.split(\" \")]\n\n up_cost = 0\n down_cost = 0\n\n for i in range(X + 1, N + 1):\n if i in Ai:\n up_cost += 1\n for i in range(X - 1, 0, -1):\n if i in Ai:\n down_cost += 1\n return min(up_cost, down_cost)\n\n\nNMX_input_value = input()\nAi_input_value = input()\nprint((atc_094b(NMX_input_value, Ai_input_value)))\n", "n,m,x=map(int,input().split())\nam=sorted(map(int,input().split()))\nprint(min(len(list(filter(lambda a:a<x,am))),len(list(filter(lambda a:x<a,am)))))", "lst = input().split()\nN = int(lst[0])\nM = int(lst[1])\nX = int(lst[2])\nL = input().split()\n\ncost_0 = 0\nfor n in L:\n if 0 < int(n) < X:\n cost_0 += 1\n elif X < int(n):\n break\n\ncost_N = 0\nfor n in L:\n if X < int(n) < N:\n cost_N += 1\n\nprint(min([cost_0, cost_N]))", "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\nroot0 = 0\nrootn = 0\nfor i in range(1,x):\n if i in a:\n root0 += 1\nfor i in range(x+1,n+1):\n if i in a:\n rootn += 1\nprint(min(root0,rootn))", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n n,m,x = map(int,input().split())\n maps=[]\n maps=list(map(int,input().split()))\n dp=[0]*(n+1)\n left=0\n right=0\n\n for i in maps:\n dp[i]=1\n\n left = sum(dp[x:])\n right = sum(dp[:x])\n\n print(min(left,right))\n\ndef __starting_point():\n main()\n__starting_point()", "import sys\nlines = [s.rstrip(\"\\n\") for s in sys.stdin.readlines()]\nn, m, x = [int(num) for num in lines.pop(0).split(\" \")]\na_list = [int(num) for num in lines.pop(0).split(\" \")]\n\nfor i in range(m):\n if a_list[i] > x:\n break\n\nans = min(i, m - i)\nprint(ans)\n", "total_square, total_toll_gate, current_square = map(int, input().split())\ntoll_gate_square = list(map(int, input().split()))\nroute1 = 0\nroute2 = 0\nfor i in range(total_toll_gate):\n if toll_gate_square[i] < current_square:\n route1 += 1\n else:\n route2 += 1\nprint(min(route1, route2))", "# B - Toll Gates\n\n# N M X\nN, M, X = list(map(int, input().split()))\nmy_list = list(map(int, input().split(maxsplit=M)))\ncount_start = 0\ncount_goal = 0\n\n# 0\u3078\u884c\u304f\u30d1\u30bf\u30fc\u30f3\nfor i in range(1, X):\n if i in my_list:\n count_start += 1\n\nfor i in range(X, N):\n if i in my_list:\n count_goal += 1\n\nif count_start >= count_goal:\n answer = count_goal\nelse:\n answer = count_start\n\nprint(answer)\n", "n,m,x=map(int,input().split())\nA=list(map(int,input().split()))\nprint(min(sum([a<x for a in A]),sum([a>x for a in A])))", "n,m,x = map(int,input().split())\na=list(map(int,input().split()))\ncnt1, cnt2 = 0, 0\nfor i in range(m):\n if 0 <= a[i] < x:\n cnt1 += 1\n if x < a[i] <= a[-1]:\n cnt2 += 1\nprint(min(cnt1, cnt2))", "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nX_high = 0\nX_low = 0\n\nfor i in range(X, N + 1):\n if i in A:\n X_high += 1\n\nfor i in range(0, X + 1):\n if i in A:\n X_low += 1\n\nprint(min(X_high, X_low))", "N,M,X=map(int,input().split())\nAi=list(map(int,input().split()))\n\ngoto_0=0\ngoto_N=0\n\nfor i in range(X,0,-1):\n if i in Ai:\n goto_0 += 1\n\nfor i in range(X,N):\n if i in Ai:\n goto_N += 1\n\nprint(min(goto_0,goto_N))", "N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\nl1 = []\nl2 = []\n\nfor i in A:\n if X > i:\n l1.append(i)\n else:\n l2.append(i)\n\nprint((min(len(l1), len(l2))))\n", "def tool_gate(now: int, gate_list: list) -> int:\n back_count = sum(i < now for i in gate_list)\n forward_count = sum(i > now for i in gate_list)\n return min(back_count, forward_count)\n\n\ndef __starting_point():\n n, m, now = list(map(int, input().split()))\n gate_list = list(map(int, input().split()))\n print((tool_gate(now, gate_list)))\n\n__starting_point()", "n,m,x = map(int,input().split())\na =list(map(int,input().split()))\nstart = sum(i>x for i in a)\nend = sum(i<x for i in a)\nprint(min(start,end))", "import sys\ninput = sys.stdin.readline\n \nN,M,X = map(int,input().split())\nA = list(map(int,input().split()))\nif A[int(M/2)] > X:\n b = [i for i in A if i < X]\nelse:\n for i in A[::-1]:\n b = [i for i in A if i > X]\n \nprint(min(len(b),M - len(b)))", "# \u6570\u5024\u306e\u53d6\u5f97\nlast,fee,cur = map(int,input().split())\nfeesqu = list(map(int,input().split()))\ntotal = len(feesqu)\n\n# \u30b3\u30b9\u30c8\u306e\u6700\u5c0f\u5024\u3092\u51fa\u529b\ntcost = 0\ngcost = 0\nfor cnt in range(0,total,1):\n if feesqu[cnt] < cur:\n tcost += 1\ngcost = total - tcost\nprint(min(tcost,gcost))", "N, M, X = list(map(int, input().split()))\na_point = list(map(int,input().split()))\nlg = 0\nsl = 0\nfor i in range(len(a_point)):\n if X < a_point[i]:\n lg += 1\n else:\n sl += 1\n\nif lg > sl:\n print(sl)\nelse:\n print(lg)\n", "N, M, X = map(int,input().split())\nfee = list(map(int,input().split()))\nresult_1 = []\nresult_2 = []\n\nfor i in fee:\n if i > X:\n result_1.append(i)\n else:\n result_2.append(i)\n\nresult = (min(len(result_1) ,len(result_2)))\nprint(result)", "n,m,x=map(int,input().split())\na=list(map(int,input().split()))\nans=0\nfor i in a:\n if i<x:\n ans+=1\n else:\n break\nprint(min(ans,m-ans))", "n, m, x = list(map(int, input().split()))\na_lst = list(map(int, input().split()))\n\ncost1 = 0\ncost2 = 0\nfor i in range(x, n+1):\n if i in a_lst:\n cost1 += 1\nfor i in range(x, -1, -1):\n if i in a_lst:\n cost2 += 1\nprint((min(cost1, cost2)))\n", "import bisect\n\n\ndef answer(n: int, m: int, x: int, a: []) -> int:\n i = bisect.bisect_left(a, x)\n return min(i, len(a) - i)\n\n\ndef main():\n n, m, x = map(int, input().split())\n a = list(map(int, input().split()))\n print(answer(n, m, x, a))\n\n\ndef __starting_point():\n main()\n__starting_point()", "N, M, X = [int(i) for i in input().split()]\nAS = [int(i) for i in input().split()]\n\ncnt1 = 0\nfor i in range(0, X):\n if i in AS:\n cnt1 += 1\n\ncnt2 = 0\nfor i in range(X+1, N+1):\n if i in AS:\n cnt2 += 1\n\nprint((cnt1 if cnt1 < cnt2 else cnt2))\n", "# \u5165\u529b\nn, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\n\ngoto_goal_0 = 0 # 0\u307e\u3067\u306e\u30b3\u30b9\u30c8\ngoto_goal_n = 0 # n\u307e\u3067\u306e\u30b3\u30b9\u30c8\n\n# x \u304b\u3089 0 \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x - 1, 0, -1): # x-1 \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30c7\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n if i in a:\n goto_goal_0 += 1\n # print(\"0 is {}\".format(goto_goal_0))\n\n# x \u304b\u3089 n \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x, n + 1): # x \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n if i in a:\n goto_goal_n += 1\n # print(\"n is {}\".format(goto_goal_n))\n\nif goto_goal_0 < goto_goal_n:\n print(goto_goal_0)\nelse:\n print(goto_goal_n)", "N, M, X = map(int,input().split())\nA = map(int,input().split())\n\nL = 0\nR = 0\n\nfor ai in A:\n if ai < X:\n L = L + 1\n else:\n R = R + 1\nprint(min(L, R))", "import sys\ninput = sys.stdin.readline\n \nN,M,X = list(map(int,input().split()))\nA = list(map(int,input().split()))\ncount = 0\nif A[int(M/2)] > X:\n for i in A:\n if i < X:\n count += 1\n else:\n break\nelse:\n for i in A[::-1]:\n if i > X:\n count += 1\n else:\n break\n \nprint((min(count,M - count)))\n", "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nright = [int(i) for i in A if i > X]\nleft = [int(i) for i in A if i < X]\n\nr = len(right)\nl = len(left)\n\nif r < l:\n print(r)\n\nelse:\n print(l)", "a = [int(c) for c in input().split()]\nN=a[0]\nM=a[1]\nX=a[2]\nA = [int(c) for c in input().split()]\nA2 = [0]*(N+1)\nfor i in range(M):\n A2[A[i]] = 1\n\ncnt = X\ncost1 = 0\nwhile cnt < N+1:\n cost1+=A2[cnt]\n cnt+=1\n\ncnt = X\ncost2 = 0\nwhile cnt > 0:\n cost2+=A2[cnt]\n cnt-=1\n\nif cost1<cost2:\n print(cost1)\nelse:\n print(cost2)\n", "a=input().split()\nN=int(a[0])\nM=int(a[1])\nX=int(a[2])\nryokinjo=[]\nb=input().split()\nfor i in range(len(b)):\n ryokinjo.append(int(b[i]))\ncount1=0\ncount2=0\nfor i in range(len(ryokinjo)):\n if ryokinjo[i]<X:\n count1+=1\n if ryokinjo[i]>X:\n count2+=1\nprint((min([count1,count2])))\n", "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nd=list(map(int,input().split()))\ne=0\nf=0\nfor i in range(b):\n if d[i]>c:\n e=e+1\n if d[i]<c:\n f=f+1\nif e>f:\n print(f)\nelse:\n print(e)", "N,M,X=map(int,input().split())\nA=list(map(int,input().split()))\ncnt=len([a for a,i in enumerate(A) if i>=X])\ncnt=min(cnt,M-cnt)\nprint(cnt)", "n, m, x = list(map(int, input().split()))\na = list(map(int, input().split()))\ncnt1 = 0\ncnt2 = 0\nx1 = x\nx2 = x\n\nwhile x1 < n+1:\n x1 += 1\n if x1 in a:\n cnt1 += 1\n\nwhile x2 > 0:\n x2 -= 1\n if x2 in a:\n cnt2 += 1\n\n\n\nif cnt1 < cnt2:\n ans = cnt1\nelse:\n ans = cnt2\n\nprint(ans)\n", "N,M,X=map(int,input().split())\nAi=list(map(int,input().split()))\n\ngoto_0=0\ngoto_N=0\n\nfor i in range(0,X):\n if i in Ai:\n goto_0 += 1\n\nfor i in range(X,N):\n if i in Ai:\n goto_N += 1\n\nprint(min(goto_0,goto_N))", "n, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\nacc = [0] * (n + 1)\nfor i in a:\n acc[i] = 1\nprint(min(sum(acc[:x]), sum(acc[x:])))", "num, count_station, my_position = list(map(int, input().split()))\na = list(map(int, input().split()))\nstation_list = list(a)\nspace = num + 1\nfirst_me_cost = 0\nlast_me_cost = 0\n\ndistance_me_first = my_position\ndistance_me_last = num - my_position\n\nfor i in station_list:\n if 1 <= i <= my_position - 1:\n first_me_cost += 1\n\nfor i in station_list:\n if my_position + 1 <= i < num:\n last_me_cost += 1\n\nif first_me_cost > last_me_cost:\n print(last_me_cost)\nelif last_me_cost > first_me_cost:\n print(first_me_cost)\nelif last_me_cost == first_me_cost:\n print(first_me_cost)\n", "n,m,x=map(int,input().split())\na=list(map(int,input().split()))\nc=x\nans=0\nans1=0\nwhile c:\n ans+=c in a\n c-=1\nwhile x<n:\n ans1+=x in a\n x+=1\nprint(min(ans,ans1))", "N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = sorted(A)\nC = [0]*(N+1)\ncnt_1 = 0\ncnt_2 = 0\n\nfor i in range(M):\n C[B[i]] += 1\n\nfor j in range(1, N-X):\n cnt_1 += C[X+j]\n\nfor k in range(1, X+1):\n cnt_2 += C[X-k]\n\ncnt = [cnt_1, cnt_2]\n\nprint((min(cnt)))\n", "n,m,x = list(map(int,input().split()))\na = list(map(int,input().split()))\nk = n-1\nfor i in range(m):\n if a[i] > x:\n k = i\n break\nif k==0 or k==n-1:\n print('0')\n return\nelse:\n print((min(k,m-k)))\n", "S_list = [input() for i in range(2)]\nN, M, X= map(int,S_list[0].split()) \nA_list = list(map(int,S_list[1].split()))\n\nA_goal_N = [i for i in A_list if X < i and i < N]\nA_goal_0 = [i for i in A_list if 0 < i and i < X]\nresult = min(len(A_goal_N),len(A_goal_0))\nprint(result)", "N, M, X, *A = map(int, open(0).read().split())\n\nl = [0] * N\nfor a in A:\n l[a-1] = 1\n\nprint(min(sum(l[:X]), sum(l[X:])))", "n, m, x = list(map(int,input().split()))\na = list(map(int,input().split()))\n\ngoal_0 = 0\ngoal_1 = 0\n\nfor i in range(x,0,-1):\n if i in a:\n goal_0 += 1\n\nfor i in range(x,n+1,1):\n if i in a:\n goal_1 += 1\n\nif goal_0 < goal_1:\n print(goal_0)\nelse:\n print(goal_1)\n", "n,m,x=map(int,input().split())\na=list(map(int, input().split()))\np = 0\nq = 0\nfor i in a:\n if i > x:\n p +=1\n elif i < x:\n q +=1\nprint(min(p,q))", "#ABC094 B 3\u756a\u76ee\u304c\u901a\u3089\u306a\u3044\nn,m,x=map(int,input().split())\nList=[int(i) for i in input().split()]\nlcost=0\nrcost=0\nfor a in List:\n if a<x:\n lcost+=1\n\nfor b in List:\n if b>x:\n rcost+=1\nprint(min(lcost,rcost))", "n,m,x = list(map(int, input().split()))\na = list(map(int, input().split()))\nc0 = 0\ncN = 0\nfor A in a:\n if A > x:\n cN += 1\n elif A < x:\n c0 += 1\nprint(min(c0, cN))", "# 094b\n\ndef atc_094b(NMX: str, Ai_input: str) -> int:\n N, M, X = list(map(int, NMX.split(\" \")))\n Ai = [int(ai) for ai in Ai_input.split(\" \")]\n\n up_cost = 0\n down_cost = 0\n\n for i in range(X + 1, N + 1):\n if i in Ai:\n up_cost += 1\n for i in range(X - 1, 0, -1):\n if i in Ai:\n down_cost += 1\n return min(up_cost, down_cost)\n\n\nNMX_input_value = input()\nAi_input_value = input()\nprint((atc_094b(NMX_input_value, Ai_input_value)))\n", "n, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\ndef answer(n: int, m: int, x: int, a:list) -> int:\n left = 0\n right = 0\n for i in a:\n if i < x:\n left += 1\n else:\n right += 1\n return min(left, right)\n\nprint(answer(n, m, x, a))", "N, M, X = map(int,input().split())\nL = list(map(int,input().split()))\ns = 0\nb = 0\nfor i in L:\n if i > X:\n s += 1\n else:\n b += 1\n\nif s >= b:\n print(b)\nelse:\n print(s)", "N, M, X = list(map(int,input().split()))\nS = list(map(int,input().split()))\nFees = list(S)\nGoal1 = []\nGoal2 = []\ncount1 = 0\ncount2 = 0\npoint0 = 0\n\nfor i in range(X):\n point0 += 1\n Goal1.append(point0)\n# print(Goal1)\n\nfor j in range(N-X):\n X += 1\n Goal2.append(X)\n# print(Goal2)\n\nfor fee in Fees:\n if fee in Goal1:\n count1 += 1\n if fee in Goal2:\n count2 += 1\n\nif count1 >= count2:\n print(count2)\nif count1 < count2:\n print(count1)\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n# Fee = list(S)\n# print(Fee)\n# count1 = 0\n# count2 = 0\n# for i in range(N-X):\n# X += 1\n# if X in Fee:\n# count1 += 1\n# print(X)\n# for j in range(N):\n# X -= 1\n# if X in Fee:\n# count2 += 1\n#\n# if count1 <= count2:\n# print(count1)\n# if count1 > count2:\n# print(count2)\n", "n, m, x = map(int, input().split())\n\na = list(map(int, input().split()))\n\nr = 0\nl = 0\n\nfor i in a:\n if i > x:\n r += 1\n elif i < x:\n l += 1\n\nprint(min(l,r))", "from bisect import bisect_left\n\ndef main():\n N, M, X = list(map(int, input().split()))\n A = list(map(int, input().split()))\n mid = bisect_left(A, X)\n l = len(A[:mid])\n r = len(A[mid:])\n print((min(l, r)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "n, m, x = map(int, input().split())\n\na = list(map(int, input().split()))\n\nr = 0\nfor i in range(x+1,n):\n for j in range(m):\n if i == a[j]:\n r += 1\n\nl = 0\nfor i in range(x-1, -1, -1):\n for j in range(m):\n if i == a[j]:\n l += 1\n \nprint(min(l,r))", "\n# \u5165\u529b\nn, m, x = list(map(int, input().split()))\na = list(map(int, input().split()))\n\ngoto_goal_0 = 0 # 0\u307e\u3067\u306e\u30b3\u30b9\u30c8\ngoto_goal_n = 0 # n\u307e\u3067\u306e\u30b3\u30b9\u30c8\n\n# x \u304b\u3089 0 \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x - 1, 0, -1): # x-1 \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30c7\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n if i in a:\n goto_goal_0 += 1\n # print(\"0 is {}\".format(goto_goal_0))\n\n# x \u304b\u3089 n \u3078\u5411\u304b\u3046\u30b3\u30b9\u30c8\u3092\u8a08\u7b97\nfor i in range(x, n + 1): # x \u756a\u76ee\u304b\u3089\u9806\u756a\u306b\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u306a\u304c\u3089for\u30eb\u30fc\u30d7\n if i in a:\n goto_goal_n += 1\n # print(\"n is {}\".format(goto_goal_n))\n\nif goto_goal_0 < goto_goal_n:\n print(goto_goal_0)\nelse:\n print(goto_goal_n)\n", "N, M, X = map(int, input().split())\nA = sum(int(i) < X for i in input().split())\nprint(min(A, M - A))", "import numpy as np\n\nn, m, x = map(int, input().split())\na = list(map(int, input().split()))\n\na = np.array(a)\n\nans = min(len(a[a<x]), len(a[a>x]))\nprint(ans)", "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\ni = 0\nj = 0\nfor k in a:\n if k>x:\n i += 1\n elif k<x:\n j += 1\nprint(min(i,j))", "n, m, x = map(int, input().split())\na = [int(s) for s in input().split()]\n\nfor i in range(m):\n if a[i] > x:\n less = len(a[:i])\n more = len(a[i:])\n print(min(less, more))\n break", "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\ngoal_N = 0\ngoal_0 = 0\n\nfor i in range(X, N + 1):\n if i in A:\n goal_N += 1\n\nfor i in range(0, X + 1):\n if i in A:\n goal_0 += 1\n\nmin_cost = min(goal_N,goal_0)\n\nprint(min_cost)", "N, M, X = map(int, input().split())\nA = [*map(int, input().split())]\nl = [i < X for i in A]\nr = [i > X for i in A]\nprint(l.count(False) if l.count(False) < r.count(False) else r.count(False))", "n, m, x = list(map(int, input().split()))\nam = list(map(int, input().split()))\n\n\nclass Solution:\n def __init__(self, n, m, x, am):\n self.n = n\n self.m = m\n self.x = x\n self.am = am\n\n def __make_list(self):\n list_n = [0] * n\n for i in self.am:\n list_n[i - 1] = 1\n return list_n\n\n def answer(self):\n list_n = self.__make_list()\n print((min(sum(list_n[:self.x - 1]), sum(list_n[x - 1:]))))\n\n\nconditions = Solution(n, m, x, am)\nconditions.answer()\n", "n,m,x = map(int,input().split())\na = [int(s) for s in input().split()]\ncost = []\ncount = 0\n\nfor i in range(x,n):\n if a.count(i) == 1:\n count += 1\ncost.append(count)\ncount = 0\nc = range(0,x)\nfor i in reversed(c):\n if a.count(i) == 1:\n count += 1\ncost.append(count)\nprint(min(cost))", "n,m,x=map(int, input().split())\na=list(map(int, input().split()))\nmas=[0]*(n+1)\nfor i in a:\n mas[i]=1\nprint(min(sum(mas[0:x]),sum(mas[x:n+1])))", "n, m, x = input().split()\nlist01 = input().split()\nlist02 = [int(a) for a in list01]\nb = sum(c > int(x) for c in list02)\nd = sum(e < int(x) for e in list02)\nprint(min(b, d))", "N,M,X=list(map(int,input().split()))\nA=list(map(int,input().split()))\nsum1=0\nsum2=0\nfor i in range(M):\n if A[i]<X:\n sum1+=1\n else:\n sum2+=1\nprint((min(sum1,sum2)))\n", "import sys\nn,m,x=map(int,input().split())\na=list(map(int,input().split()))\n\ns=0\nb=0\nfor i in a:\n if i<x:\n s+=1\n if i>x:\n b+=1\nprint(min(s,b))", "from bisect import bisect_left\nn, m, x, *a = list(map(int, open(0).read().split()))\n\nb = bisect_left(a, x)\nprint((min(m - b, b)))\n", "n,m,x = map(int,input().split())\nlst = list(map(int, input().split()))\n\na_cost = 0\nb_cost = 0\nfor i in lst:\n if i > x:\n a_cost += 1\n else:\n b_cost += 1\nprint(min(a_cost, b_cost))", "N, M, X = map(int,input().split())\nA = list(map(int,input().split()))\n\ngoal_N = 0\ngoal_0 = 0\n\nfor i in range(X, N + 1):\n if i in A:\n goal_N += 1\n\nfor i in range(0, X + 1):\n if i in A:\n goal_0 += 1\n\nmin_cost = min(goal_N,goal_0)\n\nprint(min_cost)", "n, m, x = map(int, input().split())\n\nback = 0\nfor a in map(int, input().split()):\n if a < x:\n back += 1\nelse:\n print(min(back, m - back))", "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nl_cost = 0\ng_cost = 0\n\nfor i in A:\n if i > X:\n l_cost += 1\n else:\n g_cost += 1\n \nprint(min(l_cost, g_cost))", "_, m, x = map(int, input().split())\n\nback = 0\nfor a in map(int, input().split()):\n if a < x:\n back += 1\nelse:\n print(min(back, m - back))", "N,M,X=list(map(int,input().split()))\nA=list(map(int,list(input().split())))\ncountA=0\ncountB=0\nfor i in A:\n if i>X:\n countA+=1\n if i<X:\n countB+=1\nif countA<countB:\n print(countA)\nelse:\n print(countB)\n", "N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\nright = 0\nleft = 0\n\nfor a in A:\n if X > a:\n right += 1\n elif X < a:\n left += 1\n\nprint((min(right, left)))\n\n\n", "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\n\n# \u5c0f\u3055\u3044\u307b\u3046\u306e\u6599\u91d1\u6240\u306e\u6570\nsmall_cost = 0\n# \u5927\u304d\u3044\u65b9\u306e\u6599\u91d1\u6240\u306e\u6570\nbig_cost = 0\n\n# \u30ea\u30b9\u30c8a\u306e\u5024\u3068\uff58\u3092\u6bd4\u8f03\u3057\u3066\nfor i in a:\n # \uff58\u3088\u308a\u5c0f\u3055\u3044\u3082\u306e\u3092\u30ab\u30a6\u30f3\u30c8\n if x > i:\n small_cost += 1\n # \uff58\u3088\u308a\u5927\u304d\u3044\u3082\u306e\u3092\u30ab\u30a6\u30f3\u30c8\n elif x < i:\n big_cost += 1\n# \u5c11\u306a\u3044\u65b9\u306e\u30ab\u30a6\u30f3\u30c8\u3092\u51fa\u529b\nif small_cost <= big_cost:\n print(small_cost)\nelse:\n print(big_cost)", "N, M, X = map(int, input().split())\ncost_masses = map(int, input().split())\n\ncost_ToZero = cost_ToEnd = 0\n\nfor cost_mass in cost_masses:\n if X < cost_mass:\n cost_ToEnd = cost_ToEnd + 1\n elif X > cost_mass:\n cost_ToZero = cost_ToZero + 1\nelse:\n print(min([cost_ToZero, cost_ToEnd]))", "n, m, x = map(int,input().split())\nl = 0\na = list(map(int,input().split()))\nfor j in a:\n l += 1 if j > x else 0\nprint(min(l,m-l))", "# -*- coding:utf-8 -*-\nN,M,X = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\nA.append(X)\nA.sort()\n\nA_index = A.index(X)\n\nlen_bef = len(A[0:A_index])\nlen_aft = len(A[A_index+1:])\nans = len_bef\n\nif len_bef > len_aft:\n ans = len_aft\n\nprint(ans)\n", "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\nl1 = []\nl2 = []\n\nfor i in A:\n if X > i:\n l1.append(i)\n else:\n l2.append(i)\n\nprint(min(len(l1), len(l2)))", "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, m, x = Input()\n a = [0] * n\n for i in Input():\n a[i-1] = 1\n\n print(min(sum(a[:x]), sum(a[x-1:])))\n\n\nmain()", "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\nans = 0\n\nfor i in range(m):\n if a[i] > x:\n if i < m-i: ans = i\n else : ans = m-i\n break\nprint(ans)", "#!/usr/bin/env python3\n\ndef main():\n n, m, x = list(map(int, input().split()))\n a = list(map(int, input().split()))\n for i in range(m):\n if a[i] > x:\n ans = min(i, len(a) - i)\n break\n else:\n ans = 0\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nfor i , a in enumerate(A):\n if X < a:\n break\n\nif i > len(A) / 2:\n ans = len(A[i:])\nelse:\n ans = len(A[:i])\n\nprint(ans)\n", "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\ndata = [0]*(n + 1)\ncost_1 = 0\ncost_2 = 0\nfor i in range(m):\n data[a[i]] = 1\nfor i in range(0,x):\n cost_1 += data[i]\nfor j in range(x,n):\n cost_2 += data[j]\nprint(min(cost_1,cost_2))", "# \u5168\u4f53\u306e\u30de\u30b9\u3092\u958b\u59cb\u4f4d\u7f6e\u3067\u30b9\u30e9\u30a4\u30b9\u3001\u6599\u91d1\u6240\u3060\u3051\u62bd\u51fa\u3057\u3001\u8981\u7d20\u306e\u500b\u6570\u3067\u6761\u4ef6\u5206\u5c90\nN, M, X = list(map(int, input().split()))\nA = list(map(int, input().split()))\n\nsquare = list(range(0, N + 1))\n\na = square[:X + 1]\nb = square[X:]\n\na_costs = []\nb_costs = []\n\nfor i in a:\n if i in A:\n a_costs.append(i)\nfor i in b:\n if i in A:\n b_costs.append(i)\n\na_cost = len(a_costs)\nb_cost = len(b_costs)\n\nif a_cost > b_cost:\n print(b_cost)\nelse:\n print(a_cost)\n", "n,m,x = map(int,input().split())\na = list(map(int,input().split()))\na.append(x)\na = sorted(a)\nprint(len(a[:a.index(x)]) if len(a[:a.index(x)+1]) <= len(a[a.index(x)+1:]) else len(a[a.index(x)+1:]))", "n,m,x = map(int,input().split())\nli = list(map(int,input().split()))\ncnt = 0\ncou = 0\nfor i in range(x):\n if i in li:\n cnt += 1\nfor i in range(x,n):\n if i in li:\n cou += 1\nprint(min(cnt,cou))", "n,m,s = [int(x) for x in input().split()]\na = [int(x) for x in input().split()]\n\nlow = 0\nhigh = 0\nfor i in range(m):\n if a[i] < s:\n low += 1\n else:\n high += 1\nprint(min(low,high))", "N, M, X = list(map(int,input().split()))\nA = list(map(int, input().split())) \n\nzero_goal = 0\nN_goal = 0\n\nfor i in A:\n if i < X:\n zero_goal = zero_goal + 1\n else:\n N_goal = N_goal + 1\nprint((min(zero_goal, N_goal)))\n", "n, m, x = list(map(int, input().split()))\nam = list(map(int, input().split()))\nlist_n = [0] * n\nfor i in am:\n list_n[i - 1] = 1\nprint((min(sum(list_n[:x - 1]), sum(list_n[x - 1:]))))\n", "n, m, x = list(map(int, input().split()))\na = list(map(int, input(). split()))\n\ngoto_goal_0 = 0\ngoto_goal_n = 0\n\nfor i in range(x, 0, -1):\n if i in a:\n goto_goal_0 += 1\n\n\nfor i in range(x, n + 1, 1):\n if i in a:\n goto_goal_n += 1\n\nif goto_goal_0 < goto_goal_n:\n print(goto_goal_0)\nelse:\n print(goto_goal_n)\n\n", "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\ncost_0 = 0\ncost_last = 0\n\nfor n in A:\n if n > X:\n cost_last += 1\n elif n < X:\n cost_0 += 1\n\n\nif cost_0 >= cost_last:\n print(cost_last)\nelif cost_0 < cost_last:\n print(cost_0)", "n,m,x = list(map(int,input().split()))\nl = [0]*n\na = list(map(int,input().split()))\nfor i in a:\n l[i-1] = 1\n\nleft = sum(l[:x])\nright = sum(l[x-1:len(l)])\n\nprint((left if left<=right else right))\n", "n,m,x = list(map(int,input().split()))\na = list(map(int,input().split()))\nans = 0\nans = min(sum(1 for i in a if i > x),sum(1 for i in a if i < x))\nprint(ans)\n\n\n", "N, M, X = map(int, input().split())\nA = list(map(int, input().split()))\n\nA.sort()\n\nimport bisect\nidx = bisect.bisect(A, X)\n\nans_r = len(A[idx:])\nans_l = len(A[:idx])\n\nans = min(ans_l, ans_r)\nprint(ans)", "n, m, x = list(map(int, input().split()))\nsquares = list(map(int, input().split()))\n\nleft_cost = 0\nright_cost = 0\nfor square in squares:\n if square < x:\n left_cost = left_cost + 1\n else:\n right_cost = right_cost + 1\n\nprint((min(right_cost, left_cost)))\n", "n, m, x = map(int, input().split())\na_l = list(map(int, input().split()))\n\nfor i, a in enumerate(a_l):\n if x < a:\n break\nif i > len(a_l)/2:\n ans = len(a_l[i:])\nelse:\n ans = len(a_l[:i])\nprint(ans)", "n, m, x = list(map(int, input().split()))\narr = list(map(int, input().split()))\n\nmn = 0\nl_cost = 0\nr_cost = 0\n\n# Calculate left cost\nfor i in range(x):\n if i in arr:\n l_cost += 1\n\n# Calculate right cost\nfor i in range(x, n + 1):\n if i in arr:\n r_cost += 1\n\nprint((min(l_cost, r_cost)))\n", "n,m,x=map(int,input().split())\na=list(map(int,input().split()))\nk=[0]*(n+1)\nfor i in a:k[i]=1\nprint(min(sum(k[0:x+1]),sum(k[x:n+1])))"]
{"inputs": ["5 3 3\n1 2 4\n", "7 3 2\n4 5 6\n", "10 7 5\n1 2 3 4 6 8 9\n"], "outputs": ["1\n", "0\n", "3\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
28,408
68eaeb6851e45d1ec8b16821c916bc57
UNKNOWN
We have a canvas divided into a grid with H rows and W columns. The square at the i-th row from the top and the j-th column from the left is represented as (i, j). Initially, all the squares are white. square1001 wants to draw a picture with black paint. His specific objective is to make Square (i, j) black when s_{i, j}= #, and to make Square (i, j) white when s_{i, j}= .. However, since he is not a good painter, he can only choose two squares that are horizontally or vertically adjacent and paint those squares black, for some number of times (possibly zero). He may choose squares that are already painted black, in which case the color of those squares remain black. Determine if square1001 can achieve his objective. -----Constraints----- - H is an integer between 1 and 50 (inclusive). - W is an integer between 1 and 50 (inclusive). - For every (i, j) (1 \leq i \leq H, 1 \leq j \leq W), s_{i, j} is # or .. -----Input----- Input is given from Standard Input in the following format: H W s_{1, 1} s_{1, 2} s_{1, 3} ... s_{1, W} s_{2, 1} s_{2, 2} s_{2, 3} ... s_{2, W} : : s_{H, 1} s_{H, 2} s_{H, 3} ... s_{H, W} -----Output----- If square1001 can achieve his objective, print Yes; if he cannot, print No. -----Sample Input----- 3 3 .#. ### .#. -----Sample Output----- Yes One possible way to achieve the objective is shown in the figure below. Here, the squares being painted are marked by stars.
["h,w=list(map(int,input().split()))\ndx=[0,1,0,-1] ; dy=[1,0,-1,0]\nA=[list(input()) for i in range(h)]\n\nfor i in range(h):\n for j in range(w):\n if A[i][j]==\"#\":\n for q,e in zip(dx,dy):\n if 0<=i+q<h and 0<=j+e<w:\n if A[i+q][e+j]==\"#\":break\n else:\n print(\"No\");return\nprint(\"Yes\")\n", "h, w = list(map(int, input().split()))\n\nans = 'Yes'\n\ns = []\nfor i in range(h):\n s += input().split()\n\n# 1\u6587\u5b57\u305a\u3064\u30ea\u30b9\u30c8\u306b\u3059\u308b\ns = list(map(list, s))\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n # \u4e0a\u4e0b\u5de6\u53f3\u3092\u30c1\u30a7\u30c3\u30af\n # \u4ef2\u9593\u304c\u3044\u308b\u6642False\u3001\u5b64\u7acb\u3057\u3066\u3044\u308b\u3068\u304dTrue\n if i > 0:\n flg_up = False if s[i-1][j] == '#' else True\n else:\n flg_up = True\n if i < h - 1:\n flg_down = False if s[i+1][j] == '#' else True\n else:\n flg_down = True\n if j > 0:\n flg_left = False if s[i][j-1] == '#' else True\n else:\n flg_left = True\n if j < w - 1:\n flg_right = False if s[i][j+1] == '#' else True\n else:\n flg_right = True\n # 1\u3064\u3067\u3082\u5b64\u7acb\u3067\u306a\u3044\u30d5\u30e9\u30b0\u304c\u3042\u308c\u3070\u5b64\u7acb\u3067\u306a\u3044\u306e\u3067False\u3001\u5168\u90e8\u5b64\u7acb\u306e\u6642True\n if flg_up & flg_down & flg_left & flg_right:\n ans = 'No'\n break\n else:\n continue\n break\n\nprint(ans)", "from itertools import product\n\n\nH, W = list(map(int, input().split()))\ns = [input() for _ in range(H)]\nfor i, j in product(list(range(H)), list(range(W))):\n if s[i][j] == \".\":\n continue\n is_ok = False\n for di, dj in (1, 0), (-1, 0), (0, 1), (0, -1):\n ni, nj = i + di, j + dj\n if not (0 <= ni < H and 0 <= nj < W):\n continue\n if s[ni][nj] == \"#\":\n is_ok = True\n if not is_ok:\n print(\"No\")\n break\nelse:\n print(\"Yes\")\n", "h, w = list(map(int, input().split()))\nS = [input() for i in range(h)]\nfor i, T in enumerate(S):\n for j, t in enumerate(T):\n if t == \"#\":\n flag = 0\n if j > 0:\n if T[j - 1] == \"#\":\n flag += 1\n if j < w - 1:\n if T[j + 1] == \"#\":\n flag += 1\n if i > 0:\n if S[i - 1][j] == \"#\":\n flag += 1\n if i < h - 1:\n if S[i + 1][j] == \"#\":\n flag += 1\n if flag == 0:\n print(\"No\")\n return\nprint(\"Yes\")\n", "import sys\n\ninput = sys.stdin.readline\n\nd = '.'\ndn = '#'\n\ndef isPaintable(h, w, x, y, canvas):\n if x > 0:\n if canvas[y][x-1] == dn:\n return True\n if x < w-1:\n if canvas[y][x+1] == dn:\n return True\n if y > 0:\n if canvas[y-1][x] == dn:\n return True\n if y < h-1:\n if canvas[y+1][x] == dn:\n return True\n return False\n\ndef main():\n ans = 'Yes'\n h, w = map(int, input().split())\n canvas = []\n for _ in range(h):\n s = list(input().rstrip('\\n'))\n canvas.append(s)\n for y in range(h):\n if ans == 'No':\n break\n for x in range(w):\n if canvas[y][x] == dn and not isPaintable(h, w, x, y, canvas):\n ans = 'No'\n break\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "h, w = map(int, input().split())\nss = [input() for i in range(h)]\nsm = ['.'+s+'.' for s in ss]\nmm = ['.'*(w+2)]+sm+['.'*(w+2)]\n\nfor i in range(1,h+1):\n for j in range(1,w+1):\n if mm[i][j] == '#' and mm[i][j-1] == '.' and mm[i][j+1] == '.' and mm[i-1][j] =='.' and mm[i+1][j] == '.':\n print('No')\n return\n\n\nprint('Yes')", "H, W = map(int, input().split())\nS = []\nfor _ in range(H):\n s = list(input())\n S.append(s)\n \ncnt = [[0]*W for _ in range(H)]\n\nfor h in range(H):\n c = 0\n for w in range(W):\n if S[h][w] == \"#\":\n c += 1\n else:\n if c == 1:\n cnt[h][w-1] = 1\n c = 0\n if c == 1:\n cnt[h][w] = 1\n\nans = \"Yes\"\nfor w in range(W):\n c = 0\n for h in range(H):\n if S[h][w] == \"#\":\n c += 1\n else:\n if c == 1:\n if cnt[h-1][w] == 1:\n ans = \"No\"\n break\n c = 0\n if c == 1:\n if cnt[h][w] == 1:\n ans = \"No\"\n break\n \nprint(ans)", "h,w = list(map(int, input().split()))\ns = [input() for _ in range(h)]\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == \"#\":\n flag = False\n for i_new, j_new in [(i+1, j), (i-1, j), (i,j+1), (i,j-1)]:\n if i_new<0 or i_new>=h or j_new<0 or j_new>=w: continue\n if s[i_new][j_new] == \"#\":\n flag = True\n break\n if not flag:\n print(\"No\")\n return\nprint(\"Yes\")\n", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Sep 18 10:13:51 2020\n\n@author: liang\n\"\"\"\nH, W = map(int, input().split())\nflag = True\nfield = [input() for i in range(H)]\n\nfor i in range(H):\n for j in range(W):\n if field[i][j] == \"#\":\n tmp = False\n if i-1>= 0 and field[i-1][j] == \"#\":\n tmp = True\n if i+1 < H and field[i+1][j] == \"#\":\n tmp = True\n if j-1>= 0 and field[i][j-1] == \"#\":\n tmp = True\n if j+1 < W and field[i][j+1] == \"#\":\n tmp = True\n if tmp == False:\n flag = False\n\nif flag :\n print(\"Yes\")\nelse:\n print(\"No\")", "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 h, w = inl()\n grid = [None] * h\n for i in range(h):\n grid[i] = ins()\n dx = [0, 0, 1, -1]\n dy = [1, -1, 0, 0]\n for i in range(h):\n for j in range(w):\n if grid[i][j] != \"#\":\n continue\n ok = False\n for k in range(4):\n i2 = i + dy[k]\n j2 = j + dx[k]\n if 0 <= i2 < h and 0 <= j2 < w and grid[i2][j2] == \"#\":\n ok = True\n break\n if not ok:\n return False\n return True\n\n\nprint(\"Yes\" if solve() else \"No\")\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\nH, W = I()\n\npad_s = ['.'*(W+2)]\nfor h in range(H):\n pad_s.append('.' + input() + '.')\npad_s.append('.'*(W+2))\n\nfor i,ss in enumerate(pad_s):\n for j,s in enumerate(ss):\n if s == '#'\\\n and pad_s[i][j+1] == '.'\\\n and pad_s[i][j-1] == '.'\\\n and pad_s[i+1][j] == '.'\\\n and pad_s[i-1][j] == '.':\n print('No')\n return\n\nprint('Yes')\n", "h, w = map(int, input().split())\nc = tuple(tuple(0 if i == \".\" else 1 for i in input()) for _ in range(h))\n\nfor i in range(h):\n for j in range(w):\n if c[i][j]:\n T = c[i-1][j] if 0 <= i - 1 else 0\n B = c[i+1][j] if i + 1 < h else 0\n L = c[i][j-1] if 0 <= j - 1 else 0\n R = c[i][j+1] if j + 1 < w else 0\n\n if not (T or B or L or R):\n print(\"No\")\n break\n else:\n continue\n break\nelse:\n print(\"Yes\")", "h, w = list(map(int, input().split()))\ns = [input() for _ in range(h)]\n\ndh = [0, 1, 0, -1]\ndw = [1, 0, -1, 0]\nflag = 0\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n cnt = 0\n for p in range(4):\n if i + dh[p] < 0 or i + dh[p] >= h or j + dw[p] < 0 or j + dw[p] >= w:\n continue\n else:\n if s[i + dh[p]][j + dw[p]] == '#':\n cnt += 1\n if cnt == 0:\n flag = 1\n break\n if flag == 1:\n break\n if flag == 1:\n print('No')\n break\nelse:\n print('Yes')\n \n", "h, w = map(int, input().split())\n\ns = []\nfor i in range(h):\n s.append('.' + input() + '.')\n\ns = ['.'* (w+2)] + s + ['.'*(w+2)]\n\nans = 'Yes'\n\nfor i in range(1,h):\n for j in range(1,w):\n if s[i][j] == '#':\n u = s[i - 1][j]\n d = s[i + 1][j]\n l = s[i][j - 1]\n r = s[i][j + 1]\n if u == '.' and d == '.' and l == '.' and r == '.':\n ans = 'No'\n\nprint(ans)", "h,w=list(map(int,input().split()))\nmasu=[]\nmasu.append([])\nfor i in range(w+2):\n masu[0].append('.')\nfor i in range(h):\n masu.append([])\n masu[i+1].append('.')\n yoko=input()\n for j in range(w):\n masu[i+1].append(yoko[j])\nfor i in range(w+2):\n masu[0].append('.')\nfor i in range(1,h-1):\n for j in range(1,w-1):\n if masu[i][j]=='#':\n if masu[i][j+1]=='.' and masu[i][j-1]=='.' and masu[i+1][j]=='.' and masu[i-1][j]=='.':\n print('No')\n return\nprint('Yes')", "H, W = map(int,input().split())\nS = [list(input()) for i in range(H)]\n\nfor h in range(H):\n for w in range(W):\n if S[h][w] in ['.', 'B']: continue\n \n ary = [[0,1], [0,-1], [1,0], [-1,0]]\n flag = False\n for x, y in ary:\n xd = h+x\n yd = w+y\n if xd < 0 or xd >= H or yd < 0 or yd >=W: continue\n if S[xd][yd] in ['B', '#']:\n S[h][w] = 'B'\n S[xd][yd] = 'B'\n flag = True\n \n if not flag:\n print('No') \n return\n\nprint('Yes')", "H,W = map(int,input().split())\nS = [[\".\"] * (W+2)]\nfor i in range(H):\n S.append(list(\".\"+input().rstrip()+\".\"))\nS.append([\".\"]*(W+2))\n#print(S)\n\ndef checkaround(i,j):\n dirc = [[0,1],[-1,0],[0,-1],[1,0]]\n for d in dirc:\n if S[i-d[0]][j-d[1]] == \"#\":\n return True\n return False\ndef main():\n for i in range(1,H+1):\n for j in range(1,W+1):\n if S[i][j] == \"#\":\n if not checkaround(i,j):\n print(\"No\")\n return\n print(\"Yes\")\n\nmain()", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tC\n# CreatedDate: 2020-06-27 11:11:46 +0900\n# LastModified: 2020-10-01 00:51:09 +0900\n#\n\n\nimport os\nimport sys\nimport numpy as np\n# import pandas as pd\n\n\ndef dfs(visited, maze, h, w):\n visited[h, w] = -1\n if maze[h, w+1] == 1 and visited[h, w+1] == 1:\n dfs(visited, maze, h, w+1)\n if maze[h, w-1] == 1 and visited[h, w-1] == 1:\n dfs(visited, maze, h, w-1)\n if maze[h+1, w] == 1 and visited[h+1, w] == 1:\n dfs(visited, maze, h+1, w)\n if maze[h-1, w] == 1 and visited[h-1, w] == 1:\n dfs(visited, maze, h-1, w)\n\n\ndef check_maze(maze, h, w):\n if maze[h, w+1] == 1:\n return 1\n elif maze[h, w-1] == 1:\n return 1\n elif maze[h+1, w] == 1:\n return 1\n elif maze[h-1, w] == 1:\n return 1\n else:\n return 0\n\n\ndef main():\n H, W = list(map(int, input().split()))\n maze = []\n for _ in range(H):\n S = input()\n S = [1 if s == '#' else 0 for s in S]\n maze.append(S)\n maze = np.array(maze)\n maze = np.pad(maze, [(1, 1), (1, 1)])\n visited = np.copy(maze)\n for h in range(1, H+1):\n for w in range(1, W+1):\n if maze[h, w] == 1:\n flag = check_maze(maze, h, w)\n if flag == 0:\n print(\"No\")\n return\n print(\"Yes\")\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "H, W = map(int, input().split())\ngrid = [input() for _ in range(H)]\n\nflg = True\nfor i in range(H):\n for j in range(W):\n if grid[i][j] == '.':\n continue\n\n flg2 = False\n if j > 0 and grid[i][j - 1] == '#': flg2 = True\n if j < W - 1 and grid[i][j + 1] == '#': flg2 = True\n if i > 0 and grid[i - 1][j] == '#': flg2 = True\n if i < H - 1 and grid[i + 1][j] == '#': flg2 = True\n\n if not flg2:\n flg = False\n\nprint(['No', 'Yes'][flg])", "H,W = map(int,input().split())\nfield = []\nfor h in range(H):\n field.append(list(input()))\n\ndx = [0, 0, 1, -1]\ndy = [1, -1, 0, 0]\nans = 'Yes'\nfor h in range(H):\n for w in range(W):\n if field[h][w] != '#':\n continue\n ok = False\n for i in range(4):\n nw = dx[i] + w\n nh = dy[i] + h\n if nw < 0 or W <= nw or nh < 0 or H <= nh:\n continue\n if field[nh][nw] == '#':\n ok = True\n if not ok:\n ans = 'No'\n\nprint(ans)", "H,W=list(map(int,input().split()))\n\nsq=[list(input()) for i in range(H)]\n\nfor i in range(H):\n for j in range(W):\n if sq[i][j]==\"#\":\n temp=0\n if j!=0:\n if sq[i][j-1]==\"#\":\n temp+=1\n if j!=W-1:\n if sq[i][j+1]==\"#\":\n temp+=1\n if i!=0:\n if sq[i-1][j]==\"#\":\n temp+=1\n if i!=H-1:\n if sq[i+1][j]==\"#\":\n temp+=1\n if temp==0:\n print(\"No\")\n return\n\nprint(\"Yes\")\n", "#\u4e0a\u4e0b\u5de6\u53f3\u306b#\u304c\u5168\u3066\u96a3\u63a5\u3057\u3066\u3044\u308b\u306a\u3089OK\n\nN, M = map(int, input().split())\n#print(N)\nc = 0\nl = []\nfor i in range(N):\n l.append(list(input()))\n \n#print(l)\nN -= 1\nM -= 1\n\nfor i in range(N):\n for j in range(M):\n if l[i][j] == \".\":\n pass\n else:\n if i-1>=0 and i+1<=N and j-1>=0 and j+1<=M and l[i-1][j] == \".\" and l[i+1][j] == \".\" and l[i][j-1] == \".\" and l[i][j+1] == \".\":\n c+=1\n if i==0 and j-1>=0 and j+1<=M and l[i+1][j] == \".\" and l[i][j-1] == \".\" and l[i][j+1] == \".\":\n c+=1\n if i-1>=0 and i+1<=N and j==0 and l[i-1][j] == \".\" and l[i+1][j] == \".\" and l[i][j+1] == \".\":\n c+=1\n if i==N and j-1>=0 and j+1<=M and l[i-1][j] == \".\" and l[i][j-1] == \".\" and l[i][j+1] == \".\":\n c+=1\n if i-1>=0 and i+1<=N and j-1>=0 and j==M and l[i-1][j] == \".\" and l[i+1][j] == \".\" and l[i][j-1] == \".\":\n c+=1\n if i==0 and j==0 and l[i+1][j] == \".\" and l[i][j+1] == \".\":\n c+=1\n if i==0 and j==M and l[i+1][j] == \".\" and l[i][j-1] == \".\":\n c+=1\n if i==N and j==0 and l[i-1][j] == \".\" and l[i][j+1] == \".\":\n c+=1\n if i==N and j==M and l[i-1][j] == \".\" and l[i][j-1] == \".\":\n c+=1\n\nif c == 0:\n print(\"Yes\")\nelse:\n print(\"No\")", "from itertools import product\nH,W=map(int,input().split())\nS=[input() for i in range(H)]\n\nisOK=True\n\nfor y,x in product(range(H),range(W)):\n if S[y][x]=='.':\n continue\n sum=0\n\n if 0<x:\n if S[y][x-1]=='#':sum+=1\n \n if x<W-1:\n if S[y][x+1]=='#':sum+=1\n \n if 0<y:\n if S[y-1][x]=='#':sum+=1\n \n if y<H-1:\n if S[y+1][x]=='#':sum+=1\n \n if sum==0:\n isOK=False\n\nif isOK:\n print(\"Yes\")\nelse:\n print(\"No\")", "H,W = list(map(int,input().split()))\n\nS = [input() for i in range(H)]\n\nfor i in range(H):\n for j in range(W):\n if S[i][j] != \"#\":\n continue\n for y,x in ((0,1),(0,-1),(1,0),(-1,0)):\n if 0 <= i + y < H and 0 <= j + x < W:\n if S[i + y][j + x] == \"#\":\n break\n else:\n print(\"No\")\n return\nprint(\"Yes\")\n", "H,W = list(map(int,input().split()))\nGrid = [[\".\"]*(W+2)]\nfor i in range(H):\n Grid.append(list(\".\" + str(input()) + \".\"))\n \nGrid.append([\".\"]*(W+2))\nfor k in range(1,H+1):\n for l in range(1,W+1):\n moji = Grid[k][l]\n if moji == \"#\":\n flg = 0\n for rec,col in ((1,0),(0,1),(-1,0),(0,-1)):\n if Grid[k+rec][l+col] == \"#\":\n Grid[k+rec][l+col] = \"b\"\n flg = 1\n elif Grid[k+rec][l+col] == \"b\":\n flg = 1\n \n if flg == 1:\n Grid[k][l] = \"b\"\n else:\n break\n else:\n continue\n print(\"No\")\n break \nelse:\n print(\"Yes\")\n \n \n", "h,w = map(int, input().split())\ns = list()\nt = list()\na = [0 for i in range(w+2)]\ns.append(a)\nfor i in range(h):\n b = str(input())\n c = list(('0'+b+'0').replace('.','0').replace('#','1'))\n d = list(map(int, c))\n s.append(d)\n t.append(b)\ns.append(a)\nflag = 0\n\nfor j in range(1,h+1):\n for k in range(1,w+1):\n if flag == 1:\n break\n if s[j][k] == 1:\n cnt = 0\n cnt = s[j-1][k] + s[j][k-1] + s[j][k+1] + s[j+1][k] \n if cnt == 0:\n flag = 1\n print('No')\n\nif flag == 0:\n print('Yes')", "H, W = list(map(int, input().split()))\nmasu = [[\".\" for _ in range(W+2)] for _ in range(H+2)]\n\nfor i in range(H):\n masu[i+1][1:W+1] = input()\n \nresult = [[0 for _ in range(W)] for _ in range(H)]\nfor i in range(1, H+1):\n for j in range(1, W+1):\n if masu[i][j] == '#':\n x = masu[i-1][j]+masu[i][j-1]+masu[i][j+1]+masu[i+1][j]\n if x.count(\"#\")==0:\n print(\"No\")\n return\n \nprint(\"Yes\")\n\n", "H, W = map(int, input().split())\nL = ['.' + input() + '.' for _ in range(H)]\nL = ['.' * (W + 2)] + L + ['.' * (W + 2)]\nfor i in range(1, H + 1):\n for j in range(1, W + 1):\n if L[i][j] == \"#\":\n l = [L[i-1][j], L[i+1][j], L[i][j-1], L[i][j+1]]\n if '#' not in l:\n print('No')\n break\n else:\n continue\n break\nelse:\n print('Yes')", "H, W = map(int, input().split())\ngrid = []\nfor i in range(H):\n grid.append([s for s in input()])\n \nfail_flg = False\nfor i in range(H):\n if fail_flg:\n break\n for j in range(W):\n r_ij = grid[i][j]\n if r_ij == \".\":\n continue\n else:\n c_ij = 0\n if 0<=i<=H-1 and 1<=j<=W-1:\n if grid[i][j-1] == \"#\":\n c_ij += 1\n if 0<=i<=H-1 and 0<=j<=W-2:\n if grid[i][j+1] == \"#\":\n c_ij += 1\n if 1<=i<=H-1 and 0<=j<=W-1:\n if grid[i-1][j] == \"#\":\n c_ij += 1\n if 0<=i<=H-2 and 0<=j<=W-1:\n if grid[i+1][j] == \"#\":\n c_ij += 1\n if c_ij == 0:\n fail_flg = True\n break\n \nif fail_flg:\n print(\"No\")\nelse:\n print(\"Yes\")", "H,W = map(int,input().split())\ns = [list(input()) for _ in range(H)]\n\njougesayuu = [(-1,0),(1,0),(0,-1),(0,1)]\n\ncheck = True\nfor i in range(H):\n for j in range(W):\n if s[i][j] == \"#\":\n flag = False\n for (n,m) in jougesayuu:\n ni, nj = i + n, j + m\n if ni < 0 or H <= ni or nj < 0 or W <= nj:\n continue\n if s[ni][nj] == \"#\":\n flag = True\n if not flag:\n check = False\n \nprint(\"Yes\" if check else \"No\")", "h,w = map(int,input().split())\ns = [list(input()) for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if s[i][j] == \"#\":\n c = 0\n for ni, nj in [(i+1, j),(i, j+1),(i-1, j),(i, j-1)]:\n if 0 <= ni < h and 0 <= nj < w and s[ni][nj] == \"#\":\n c += 1\n if c == 0:\n print(\"No\")\n return\nprint(\"Yes\")", "H,W=list(map(int,input().split()))\ns=[input() for _ in range(H)]\ncells=[(i,j) for i in range(H) for j in range(W)]\ndi=[1,0,-1,0]\ndj=[0,1,0,-1]\n\nfor i,j in cells:\n if s[i][j]=='.':\n continue\n flag=False\n for k in range(4):\n ni=i+di[k]\n nj=j+dj[k]\n if ni<0 or nj<0 or ni>=H or nj>=W:\n continue\n if s[ni][nj]=='#':\n flag=True\n if not flag:\n print(\"No\")\n break\nelse:\n print(\"Yes\")\n", "h, w = map(int, input().split())\nc = [input() for _ in range(h)]\n\nans = 'Yes'\n\nfor i in range(h):\n for j in range(w):\n if c[i][j] == \"#\":\n upper = c[i - 1][j] == \"#\" if 0 <= i - 1 else False\n lower = c[i + 1][j] == \"#\" if i + 1 < h else False\n left = c[i][j - 1] == \"#\" if 0 <= j - 1 else False\n right = c[i][j + 1] == \"#\" if j + 1 < w else False\n\n if not (upper or lower or left or right):\n ans = 'No'\n break\n else:\n continue\n break\n\nprint(ans)", "H, W = list(map(int, input().split()))\nm = [] \n\nfor i in range(H):\n s=input()\n t = []\n for i in s:\n t.append(1 if i == \"#\" else 0)\n m.append(t)\n \nfor i in range(H):\n for j in range(W):\n if m[i][j] == 0:\n continue\n count = 0\n if i !=0 :\n count += m[i-1][j]\n if i != H-1:\n count += m[i+1][j]\n if j != 0:\n count += m[i][j-1]\n if j != W-1:\n count += m[i][j+1]\n if count > 0:\n continue\n else:\n print(\"No\")\n return\nprint(\"Yes\")\n\n \n", "H,W = map(int,input().split())\ngrid = []\nans = \"Yes\"\n\nfor _ in range(H):\n grid_i = input().split()\n grid.append(grid_i[0])\n\nfor i in range(H):\n for j in range(W):\n if grid[i][j] == \"#\":\n X = \"NG\"\n if (i-1 >= 0 and grid[i-1][j] == \".\") or i < 1:\n None\n else:\n X = \"OK\"\n if (j-1 >= 0 and grid[i][j-1] == \".\") or j < 1:\n None\n else:\n X = \"OK\"\n if (i+1 < H and grid[i+1][j] == \".\") or i+1 >= H:\n None\n else:\n X = \"OK\"\n if (j+1 < W and grid[i][j+1] == \".\") or j+1 >= W:\n None\n else:\n X = \"OK\"\n if X == \"NG\":\n ans = \"No\"\n\nprint(ans)", "h,w = list(map(int,input().split()))\ns = [list(input()) for _ in range(h)]\n\ndxy = [(1,0),(0,1),(-1,0),(0,-1)]\nans = True\nfor i in range(h):\n for j in range(w):\n cnt = 0\n if s[i][j]==\"#\":\n for p,q in dxy:\n if not(0<=i+p<h and 0<=j+q<w):\n cnt += 1 \n continue\n elif s[i+p][j+q] == \".\":\n cnt += 1\n else:\n continue\n if cnt == 4:\n ans = False\nprint((\"Yes\" if ans==True else \"No\"))\n\n", "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n H, W = list(map(int, input().split()))\n field = []\n for _ in range(H):\n tmp = list(input()[:-1])\n field.append(tmp)\n \n # import\n from collections import deque\n \n # digtmp\n digtmp = [(0, 1), (1, 0), (0, -1), (-1, 0)]\n #digtmp = [(0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1), (1, 0), (1, 1)]\n \n # BFS\n # please prefer objects:\n # H: height.\n # W: width\n # field: maze field made of '.', '#'.\n # check: check field\n for h in range(H):\n for w in range(W):\n a, b = h, w\n flag = False\n if field[a][b] == '.':\n continue\n for dx, dy in digtmp:\n x = a + dx\n y = b + dy\n if not (0 <= x < H and 0 <= y < W):\n continue\n if field[x][y] == '#':\n flag = True\n continue\n if not flag:\n print('No')\n return\n print('Yes')\n\ndef __starting_point():\n main()\n\n__starting_point()", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\n\nH,W = [int(c) for c in input().split()]\ns = [list(input()) for c in range(H)]\na = [[1 for c in range(W)] for d in range(H)]\nb = [[0 for c in range(W)] for d in range(H)]\n\nfor i in range(H):\n for j in range(W):\n if s[i][j]==\"#\":\n if i-1 >= 0:\n if s[i-1][j] == \"#\":\n a[i][j]=0\n if j-1 >= 0:\n if s[i][j-1] == \"#\":\n a[i][j]=0\n if j+1 < W:\n if s[i][j+1] == \"#\":\n a[i][j]=0\n if i+1 < H:\n if s[i+1][j] == \"#\":\n a[i][j]=0\n else:\n a[i][j]=0\n if a[i][j] == 1:\n print(\"No\")\n return\n\nprint(\"Yes\")", "h, w = list(map(int, input().split()))\ntable = [list(input()) for _ in range(h)]\n\nmx = [0, 1, 0, -1]#y\u3068\u306e\u517c\u306d\u5408\u3044\u3067\u7247\u65b9\u306f0\u306b\u3057\u3066\u4e0a\u4e0b\u5de6\u53f3\u5224\u5b9a\nmy = [1, 0, -1, 0]#x\u3068\u306e\u517c\u306d\u5408\u3044\u3067\u7247\u65b9\u306f0\u306b\u3057\u3066\u4e0a\u4e0b\u5de6\u53f3\u5224\u5b9a\nfor i in range(h):\n for j in range(w):\n if table[i][j] == \"#\":\n for k in range(4):\n tx = j + mx[k]#\u5de6\u53f3\u5224\u5b9a\n ty = i + my[k]#\u4e0a\u4e0b\u5224\u5b9a\n if 0 <= tx < w and 0 <= ty < h and table[ty][tx] == \"#\":#\u6dfb\u3048\u5b57\u306b\u4f7f\u3048\u308b\u304b\u5224\u5b9a\u3057\u3066\u3044\u308b\n break\n else:#break\u3055\u308c\u306a\u304b\u3063\u305f\u6642\u5b9f\u884c\u3055\u308c\u308b\u3001\u4e0a\u4e0b\u5de6\u53f3\u306b#\u304c\u306a\u304b\u3063\u305f\u6642\u306b\u306a\u308b\n print(\"No\")\n return\nprint(\"Yes\")\n\n", "import sys\n\nH, W = list(map(int, input().split()))\nS = [list(sys.stdin.readline().strip()) for _ in range(H)]\n\ndx = [1, 0, -1, 0]\ndy = [0, -1, 0, 1]\n\nfor i, row in enumerate(S):\n for j, s in enumerate(row):\n if s == \".\":\n continue\n ok = False\n for k in range(4):\n nx = j + dx[k]\n ny = i + dy[k]\n if not(0 <= nx < W and 0 <= ny < H):\n continue\n if S[ny][nx] == \"#\":\n ok = True\n if ok is False:\n print(\"No\")\n return\n\nprint(\"Yes\")\n", "H,W=map(int,input().split())\nList = [list(input()) for i in range(H)]\nres = \"Yes\"\nflag = True\n\ndef checkAround(ListX,i,j):\n if i == 0 and j ==0:\n if List[i+1][j] == \"#\" or List[i][j+1] == \"#\":\n return True\n else: \n return False\n elif i == 0 and j !=0 and j != W-1:\n if List[i+1][j] == \"#\" or List[i][j-1] == \"#\" or List[i][j+1] == \"#\":\n return True\n else: \n return False\n elif i == 0 and j == W-1:\n if List[i+1][j] == \"#\" or List[i][j-1] == \"#\":\n return True\n else: \n return False\n elif i != 0 and i != H-1 and j == 0:\n if List[i+1][j] == \"#\" or List[i-1][j] == \"#\" or List[i][j+1] == \"#\":\n return True\n else: \n return False\n elif i == H-1 and j == W-1:\n if List[i-1][j] == \"#\" or List[i][j-1] == \"#\":\n return True\n else: \n return False\n elif i == H-1 and j !=0 and j != W-1:\n if List[i-1][j] == \"#\" or List[i][j+1] == \"#\" or List[i][j-1] == \"#\":\n return True\n else: \n return False\n elif i == H-1 and j == 0:\n if List[i-1][j] == \"#\" or List[i][j-1] == \"#\":\n return True\n else: \n return False\n elif i != 0 and i != H-1 and j == W-1:\n if List[i+1][j] == \"#\" or List[i-1][j] == \"#\" or List[i][j-1] == \"#\":\n return True\n else: \n return False\n else:\n if List[i+1][j] == \"#\" or List[i-1][j] == \"#\" or List[i][j-1] == \"#\" or List[i][j+1] == \"#\":\n return True\n else: \n return False\n\nfor k in range(H):\n for l in range(W):\n if List[k][l] == \".\":\n pass\n else:\n flag = checkAround(List,k,l)\n if not flag:\n res = \"No\"\n break\n if not flag:\n break\nprint(res)", "h, w = list(map(int, input().split()))\n\nans = 'Yes'\n\n\n\ns = []\nfor i in range(h):\n s += input().split()\n\n# \u7aef\u306e\u51e6\u7406\u3092\u697d\u306b\u3059\u308b\u305f\u3081\u306b\u5468\u308a\u3092 . \u3067\u57cb\u3081\u308b\n## \u4e0a\u7aef\ns.insert(0, ''.join(['.'] * (w + 2)))\n## \u4e21\u7aef\ns = list(map(lambda x: '.' + x + '.', s))\n## \u4e0b\u7aef\ns.insert(len(s), ''.join(['.'] * (w + 2)))\n\n# 1\u6587\u5b57\u305a\u3064\u30ea\u30b9\u30c8\u306b\u3059\u308b\ns = list(map(list, s))\n\n# 50 * 50\nfor i in range(1, h + 1):\n for j in range(1, w + 1):\n if s[i][j] == '#':\n # \u4e0a\u4e0b\u5de6\u53f3\u3092\u30c1\u30a7\u30c3\u30af\n # \u4ef2\u9593\u304c\u3044\u308b\u6642False\u3001\u5b64\u7acb\u3057\u3066\u3044\u308b\u3068\u304dTrue\n flg_up = False if s[i-1][j] == '#' else True\n flg_down = False if s[i+1][j] == '#' else True\n flg_left = False if s[i][j-1] == '#' else True\n flg_right = False if s[i][j+1] == '#' else True\n \n # 1\u3064\u3067\u3082\u5b64\u7acb\u3067\u306a\u3044\u30d5\u30e9\u30b0\u304c\u3042\u308c\u3070\u5b64\u7acb\u3067\u306a\u3044\u306e\u3067False\u3001\u5168\u90e8\u5b64\u7acb\u306e\u6642True\n if flg_up & flg_down & flg_left & flg_right:\n ans = 'No'\n break\n else:\n continue\n break\n\nprint(ans)", "h,w = map(int,input().split())\ns = [list(input()) for i in range(h)]\n\nfor i in range(h):\n s[i].insert(0,'.')\n s[i].append('.')\n\ns.insert(0,['.']*(w+2))\ns.append(['.']*(w+2))\n\nflag = True\nfor i in range(1,h+1):\n for j in range(1,w+1):\n if s[i][j] == '#':\n if s[i-1][j] == '#' \\\n or s[i+1][j] == '#' \\\n or s[i][j-1] == '#' \\\n or s[i][j+1] == '#':\n continue\n else:\n flag = False\n break\n if flag == False:\n print('No')\n break\nelse:\n print('Yes')", "h, w = list(map(int, input().split()))\n\nans = 'Yes'\n\ns = []\nfor i in range(h):\n s += input().split()\n\n# 1\u6587\u5b57\u305a\u3064\u30ea\u30b9\u30c8\u306b\u3059\u308b\ns = list(map(list, s))\n\n# 50 * 50\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n # \u4e0a\u4e0b\u5de6\u53f3\u3092\u30c1\u30a7\u30c3\u30af\n # \u4ef2\u9593\u304c\u3044\u308b\u6642False\u3001\u5b64\u7acb\u3057\u3066\u3044\u308b\u3068\u304dTrue\n if i > 0:\n flg_up = False if s[i-1][j] == '#' else True\n else:\n flg_up = True\n \n if i < h - 1:\n flg_down = False if s[i+1][j] == '#' else True\n else:\n flg_down = True\n \n if j > 0:\n flg_left = False if s[i][j-1] == '#' else True\n else:\n flg_left = True\n \n if j < w - 1:\n flg_right = False if s[i][j+1] == '#' else True\n else:\n flg_right = True\n \n # 1\u3064\u3067\u3082\u5b64\u7acb\u3067\u306a\u3044\u30d5\u30e9\u30b0\u304c\u3042\u308c\u3070\u5b64\u7acb\u3067\u306a\u3044\u306e\u3067False\u3001\u5168\u90e8\u5b64\u7acb\u306e\u6642True\n if flg_up & flg_down & flg_left & flg_right:\n ans = 'No'\n break\n else:\n continue\n break\n\nprint(ans)", "h,w=map(int,input().split())\ns=[input() for i in range(h)]\nfor i in range(1,h-1):\n for j in range(1,w-1):\n if s[i][j]=='#':\n if (s[i+1][j]=='#' or s[i-1][j]=='#' or s[i][j+1]=='#' or s[i][j-1]=='#'):\n continue\n else:\n print('No')\n return\nprint('Yes')", "h,w=map(int,input().split()) \nl = [input() for _ in range(h)]\ndx = [1,-1,0,0]\ndy = [0,0,1,-1]\nfor i in range(h):\n for j in range(w):\n if l[i][j] =='#':\n cnt = 0\n for di in range(4):\n y = i+dx[di]\n x = j+dy[di]\n if x<0 or y<0 or x>w-1 or y>h-1:\n continue\n else:\n if l[y][x] =='#':\n cnt +=1\n if cnt == 0:\n print('No')\n return\n\nprint('Yes')", "h, w = list(map(int, input().split()))\n\nans = 'Yes'\n\ns = []\nfor i in range(h):\n s += input().split()\n\n# \u7aef\u306e\u51e6\u7406\u3092\u697d\u306b\u3059\u308b\u305f\u3081\u306b\u5468\u308a\u3092 . \u3067\u57cb\u3081\u308b\n# ..........\n# .#.#.#.#..\n# ..##.###..\n# .....##.#.\n# ...##...#.\n# ..####..#.\n# ..........\n\n## \u4e0a\u7aef\ns.insert(0, ''.join(['.'] * (w + 2)))\n## \u4e21\u7aef\ns = list(map(lambda x: '.' + x + '.', s))\n## \u4e0b\u7aef\ns.insert(len(s), ''.join(['.'] * (w + 2)))\n\n# 1\u6587\u5b57\u305a\u3064\u30ea\u30b9\u30c8\u306b\u3059\u308b\ns = list(map(list, s))\n\n# 50 * 50\nfor i in range(1, h + 1):\n for j in range(1, w + 1):\n if s[i][j] == '#':\n # \u4e0a\u4e0b\u5de6\u53f3\u3092\u30c1\u30a7\u30c3\u30af\n # \u4ef2\u9593\u304c\u3044\u308b\u6642False\u3001\u5b64\u7acb\u3057\u3066\u3044\u308b\u3068\u304dTrue\n #flg_up = False if s[i-1][j] == '#' else True\n #flg_down = False if s[i+1][j] == '#' else True\n #flg_left = False if s[i][j-1] == '#' else True\n #flg_right = False if s[i][j+1] == '#' else True\n flg_up = True if s[i-1][j] == '.' else False\n flg_down = True if s[i+1][j] == '.' else False\n flg_left = True if s[i][j-1] == '.' else False\n flg_right = True if s[i][j+1] == '.' else False\n \n # 1\u3064\u3067\u3082\u5b64\u7acb\u3067\u306a\u3044\u30d5\u30e9\u30b0\u304c\u3042\u308c\u3070\u5b64\u7acb\u3067\u306a\u3044\u306e\u3067False\u3001\u5168\u90e8\u5b64\u7acb\u306e\u6642True\n if flg_up & flg_down & flg_left & flg_right:\n ans = 'No'\n break\n else:\n continue\n break\n\nprint(ans)", "H,W = list(map(int,input().split()))\nL = [list(input()) for _ in range(H)]\nfor i in range(H):\n for j in range(W):\n if L[i][j] == '#':\n if i != 0 and L[i-1][j] == '#':\n continue\n if i != H-1 and L[i+1][j] == '#':\n continue\n if j != 0 and L[i][j-1] == '#':\n continue\n if j != W-1 and L[i][j+1] == '#':\n continue\n print('No')\n return\nprint('Yes')\n", "\nh, w = list(map(int, input().split()))\ns = [input() for _ in range(h)]\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '.':\n continue\n ok = False\n for dx, dy in [(1, 0), (0, 1), (0, -1), (-1, 0)]:\n nx = j + dx\n ny = i + dy\n if 0 <= nx < w and 0 <= ny < h and s[ny][nx] == '#':\n ok = True\n if not ok:\n print('No')\n return\nprint('Yes')\n", "H,W = list(map(int,input().split()))\n\nS = [\".\" * (W + 2)] * (H + 2)\n\nfor i in range(H):\n S[i + 1] = \".\" + input() + \".\"\n\nfor i in range(1, H + 1):\n for j in range(1, W + 1):\n if S[i][j] == \"#\":\n for x,y in ((0,1),(0,-1),(1,0),(-1,0)):\n if S[i + x][j + y] == \"#\":\n break\n else:\n print(\"No\")\n return\nprint(\"Yes\")\n", "H,W = list(map(int, input().split()))\ns = [input() for _ in range(H)]\n\nimport sys\nfor j in range(1,H-1):\n for i in range(1,W-1):\n if s[j][i] =='#':\n if s[j][i-1] == '#':\n pass\n elif s[j-1][i] == '#':\n pass\n elif s[j][i+1] == '#':\n pass\n elif s[j+1][i] == '#':\n pass\n else:\n print('No')\n return\nprint('Yes')\n", "H,W = input().split()\n\ndummy_list = ['.'] *(int(W)+2)\nsquare_list=[]\nsquare_list.append(dummy_list)\nfor i in range(int(H)):\n wide_list = ['.']\n wide_list=wide_list + list(input())\n wide_list.append('.')\n square_list.append(wide_list)\nsquare_list.append(dummy_list)\nans = 'Yes'\nfor i in range(1,int(H)+1):\n for j in range(1,int(W)+1):\n\n before_list = square_list[i-1]\n center_list = square_list[i]\n after_list = square_list[i+1]\n if center_list[j] == '.':\n continue\n if before_list[j] == '.' and center_list[j-1] == '.' and center_list[j + 1] == '.' and after_list[j] == '.':\n ans = 'No'\n\nprint(ans)", "import sys\n\ndef check(i,j,s_list,h,w):\n uesita_list = [-1,1]\n sayuu_list = [-1,1]\n\n for uesita in uesita_list:\n new_i = i + uesita\n if new_i < 0 or new_i > h-1:\n continue\n if s_list[new_i][j] == \"#\":\n return True\n\n for sayuu in sayuu_list:\n new_j = j + sayuu\n if new_j > w-1 or new_j < 0:\n continue\n if s_list[i][new_j] == \"#\":\n return True\n \n return False \n\n\ninput = sys.stdin.readline\n\nh, w= list(map(int, input().split()))\n\ns_list = [[0 for _ in range(w)] for _ in range(h)]\nfor i in range(h):\n w_s_list = input()\n w_s_list = w_s_list.replace('\\n','')\n w_s_list = list(w_s_list)\n for j in range(w):\n s_list[i][j] = w_s_list[j]\n\n\nfor i in range(h):\n for j in range(w):\n s = s_list[i][j]\n if s == \"#\":\n ok_flag = check(i,j,s_list,h,w)\n if not ok_flag:\n print(\"No\")\n return\n\nprint(\"Yes\")\n\n\n", "# coding: utf-8\n\n\ndef main():\n H, W = list(map(int, input().split()))\n ans = 'Yes'\n grid = [['*'] * (W + 2) for _ in range(H + 2)]\n dir = [[1, 0], [-1, 0], [0, 1], [0, -1]]\n for i in range(H):\n S = list(input())\n for j in range(W):\n grid[i + 1][j + 1] = S[j]\n \n for i in range(H):\n for j in range(W):\n if grid[i + 1][j + 1] == '#':\n flg = True\n for x, y in dir:\n if grid[i + 1 + x][j + 1 + y] == '#':\n flg = False\n if flg:\n ans = 'No'\n\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "h, w = list(map(int, input().split()))\ntable = [list(input()) for _ in range(h)]\n\nmx = [0, 1, 0, -1]\nmy = [1, 0, -1, 0]\nfor i in range(h):\n for j in range(w):\n if table[i][j] == \"#\":\n for k in range(4):\n tx, ty = j + mx[k], i + my[k]\n if 0 <= tx < w and 0 <= ty < h and table[ty][tx] == \"#\":\n break\n else:\n print(\"No\")\n return\nprint(\"Yes\")\n\n", "h, w = [int(x) for x in input().split()]\ns_list = [input() for _ in range(h)]\n\niso_flag = [[True] * w for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if s_list[i][j] == \".\":\n continue\n\n flag_r = True\n if j < w - 1 and s_list[i][j + 1] == \"#\":\n flag_r = iso_flag[i][j + 1] = False\n \n flag_d = True\n if i < h - 1 and s_list[i + 1][j] == \"#\":\n flag_d = iso_flag[i + 1][j] = False\n \n if iso_flag[i][j] and flag_r and flag_d:\n print(\"No\")\n return\nprint(\"Yes\")", "from itertools import product\nH,W=map(int,input().split())\nS=[input() for i in range(H)]\n \nisOK=True\n \nfor y,x in product(range(H),range(W)):\n if S[y][x]=='.':\n continue\n sum=0\n \n if 0<x:\n if S[y][x-1]=='#':sum+=1\n \n if x<W-1:\n if S[y][x+1]=='#':sum+=1\n \n if 0<y:\n if S[y-1][x]=='#':sum+=1\n \n if y<H-1:\n if S[y+1][x]=='#':sum+=1\n \n if sum==0:\n isOK=False\n \nif isOK:\n print(\"Yes\")\nelse:\n print(\"No\")", "h, w = list(map(int, input().split()))\ns = ['.' + input() + '.' for _ in range(h)]\ns = ['.' * (w + 2)] + s + ['.' * (w + 2)]\n\nfor y in range(1, h + 1):\n for x in range(1, w + 1):\n if s[y][x] == '#' and all(s[y + dy][x + dx] == '.' for dy, dx in [(1, 0), (0, 1), (-1, 0), (0, -1)]):\n print('No')\n return\nprint('Yes')\n", "import sys\nH, W = list(map(int, input().split()))\nl = []\n\nfor i in range(H):\n l.append(list(input()))\n\nfor i in range(H):\n for j in range(W):\n \n if l[i][j] == '.':\n pass\n else:\n count = 0\n if i > 0 and l[i-1][j] == '#':\n count += 1 #\u4e0a\u65b9\u5411\n if i < (H-1) and l[i+1][j] == '#':\n count += 1 #\u4e0b\u65b9\u5411\n if j > 0 and l[i][j-1] == '#':\n count += 1 #\u5de6\u65b9\u5411\n if j < (W-1) and l[i][j+1] == '#':\n count += 1 #\u53f3\u65b9\u5411\n if count == 0:\n print('No')\n return\n \nprint('Yes')\n", "H,W = map(int, input().split())\ns = [input() for _ in range(H)]\n\nimport sys\nfor j in range(1,H-1):\n for i in range(1,W-1):\n if s[j][i] =='#':\n if s[j][i-1] == '#':\n pass\n elif s[j-1][i] == '#':\n pass\n elif s[j][i+1] == '#':\n pass\n elif s[j+1][i] == '#':\n pass\n else:\n print('No')\n return\nprint('Yes')", "from itertools import product\nfrom collections import deque\nimport numpy as np\nclass Grid:\n def __init__(self, grid, w=0, h=0, function=lambda x: x):\n self.w = w = w if w else len(grid[0])\n self.h = h = h if h else len(grid)\n dtype = type(function(grid[0][0]))\n self.grid = np.empty((h, w), dtype=dtype)\n for i, row in zip(range(h), grid):\n for j, val in zip(range(w), row):\n self.grid[i][j] = function(val)\n \n def is_valid_x(self, x):\n return 0 <= x < self.w\n def is_valid_y(self, y):\n return 0 <= y < self.h\n def is_valid_xy(self, x, y):\n return self.is_valid_x(x) and self.is_valid_y(y) \n \n def __iter__(self):\n return iter(self.grid)\n def __repr__(self):\n return '\\n'.join([' '.join(map(str, row)) for row in self.grid]) + '\\n'\n def __getitem__(self, x):\n return self.grid[x]\n def __setitem__(self, x, val):\n self.grid[x] = val\n\n\ndef dfs(grid, root):\n stack = [root]\n x, y = root\n grid[y, x] = '!'\n while stack:\n x, y = stack.pop()\n yield (x, y)\n for dx, dy in zip([1, 0, -1, 0], [0, 1, 0, -1]):\n nx, ny = x+dx, y+dy\n if grid.is_valid_xy(nx, ny) and grid[ny, nx] == '#':\n stack.append((nx, ny))\n grid[ny, nx] = '!'\n\nh, w = map(int, input().split())\ngrid = Grid([input() for s in range(h)])\n\nfor y, x in product(range(h), range(w)):\n if grid[y, x] == '#':\n if len(list(dfs(grid, (x, y)))) == 1:\n print('No')\n break\nelse:\n print('Yes')", "h, w = list(map(int, input().split()))\n\nans = 'Yes'\n\ns = []\nfor i in range(h):\n s += input().split()\n\n# \u7aef\u306e\u51e6\u7406\u3092\u697d\u306b\u3059\u308b\u305f\u3081\u306b\u5468\u308a\u3092 . \u3067\u57cb\u3081\u308b\n# ..........\n# .#.#.#.#..\n# ..##.###..\n# .....##.#.\n# ...##...#.\n# ..####..#.\n# ..........\n\n## \u4e0a\u7aef\ns.insert(0, ''.join(['.'] * (w + 2)))\n## \u4e21\u7aef\ns = list(map(lambda x: '.' + x + '.', s))\n## \u4e0b\u7aef\ns.insert(len(s), ''.join(['.'] * (w + 2)))\n\n# 1\u6587\u5b57\u305a\u3064\u30ea\u30b9\u30c8\u306b\u3059\u308b\ns = list(map(list, s))\n\n# 50 * 50\nfor i in range(1, h + 1):\n for j in range(1, w + 1):\n if s[i][j] == '#':\n # \u4e0a\u4e0b\u5de6\u53f3\u3092\u30c1\u30a7\u30c3\u30af\n # \u4ef2\u9593\u304c\u3044\u308b\u6642False\u3001\u5b64\u7acb\u3057\u3066\u3044\u308b\u3068\u304dTrue\n #flg_up = False if s[i-1][j] == '#' else True\n #flg_down = False if s[i+1][j] == '#' else True\n #flg_left = False if s[i][j-1] == '#' else True\n #flg_right = False if s[i][j+1] == '#' else True\n flg_up = True if s[i-1][j] == '.' else False\n flg_down = True if s[i+1][j] == '.' else False\n flg_left = True if s[i][j-1] == '.' else False\n flg_right = True if s[i][j+1] == '.' else False\n \n # 1\u3064\u3067\u3082\u5b64\u7acb\u3067\u306a\u3044\u30d5\u30e9\u30b0\u304c\u3042\u308c\u3070\u5b64\u7acb\u3067\u306a\u3044\u306e\u3067False\u3001\u5168\u90e8\u5b64\u7acb\u306e\u6642True\n #if flg_up & flg_down & flg_left & flg_right:\n if (s[i-1][j] == '.') & (s[i+1][j] == '.') & (s[i][j-1] == '.') & (s[i][j+1] == '.'):\n ans = 'No'\n break\n else:\n continue\n break\n\nprint(ans)", "H,W = map(int,input().split())\ns = []\nans = 'Yes'\nfor _ in range(H):\n s.append(input())\n\nfor i in range(1,H-1):\n for j in range(1,W-1):\n if s[i][j]=='#' and s[i][j+1]==s[i+1][j]==s[i][j-1]==s[i-1][j]=='.':\n print('No')\n return\nprint(ans)", "h, w = map(int, input().split())\nsrc = [input() for i in range(h)]\n\nans = []\nfor row in src:\n ans.append(list(row))\n\ndxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]\nfor x in range(h):\n for y in range(w):\n if src[x][y] == \".\":\n continue\n if src[x][y] == \"#\":\n flag = 0\n for dx, dy in dxy:\n if x + dx < 0 or x + dx > h -1 or y + dy < 0 or y + dy > w - 1:\n continue\n if src[x + dx][y + dy] == \"#\":\n flag = 1\n break\n if flag == 0:\n print(\"No\")\n return\n\nprint(\"Yes\")", "h,w = map(int,input().split())\nF = [list(input()) for _ in range(h)]\n\nfor i in range(h):\n for j in range(w):\n cnt = 0\n if F[i][j] == '#':\n if 0 <= (i-1) < h: \n if F[i-1][j] == '#': cnt += 1\n if 0 <= (i+1) < h: \n if F[i+1][j] == '#': cnt += 1\n if 0 <= (j-1) < w:\n if F[i][j-1] == '#': cnt += 1\n if 0 <= (j+1) < w:\n if F[i][j+1] == '#': cnt += 1\n if cnt == 0:\n print('No')\n return\nprint('Yes')", "from sys import stdin, stdout # only need for big input\n\n\ndef solve():\n h, w = list(map(int, input().split())) \n grid = [] \n for _ in range(h):\n s = input()\n assert(len(s) == w)\n grid.append(s)\n\n for i in range(h):\n for j in range(w):\n if grid[i][j] == '.':\n continue\n\n isolate = True\n for px in [i-1, i + 1]:\n if px >= 0 and px < h: \n if grid[px][j] == '#':\n isolate = False\n for py in [j-1, j + 1]:\n if py >= 0 and py < w:\n if grid[i][py] == '#':\n isolate = False\n if isolate:\n print(\"No\")\n return\n \n print(\"Yes\")\n\n\n \n \n\ndef main():\n solve()\n\n\ndef __starting_point():\n main()\n__starting_point()", "h, w = map(int, input().split())\nc = [input() for _ in range(h)]\n\nans = 'Yes'\n\nfor i in range(h):\n for j in range(w):\n if c[i][j] == \"#\":\n upper = c[i - 1][j] == \"#\" if 0 <= i - 1 else False\n lower = c[i + 1][j] == \"#\" if i + 1 < h else False\n left = c[i][j - 1] == \"#\" if 0 <= j - 1 else False\n right = c[i][j + 1] == \"#\" if j + 1 < w else False\n\n if not (upper or lower or left or right):\n ans = 'No'\n break\n\n\nprint(ans)", "import sys\nH,W = map(int,input().split())\nlsHW = [['.' for i in range(W+2)]]\nfor i in range(H):\n Sls = ['.'] + list(input()) + ['.']\n lsHW.append(Sls)\nlsHW.append(['.' for i in range(W+2)])\nfor i in range(1,H+1):\n for j in range(1,W+1):\n if lsHW[i][j] == '.':\n continue\n else:\n if not (lsHW[i-1][j] == '#' or lsHW[i+1][j] == '#' or lsHW[i][j-1] == '#' or lsHW[i][j+1] == '#'):\n print('No')\n return\nprint('Yes')", "H, W = map(int, input().split())\nS = ['.' + input() + '.' for _ in range(H)]\nS = ['.'*(W+2)] + S + ['.'*(W+2)]\nflag = 0\nfor i in range(1, H+1):\n for j in range(1,W+1):\n if S[i][j] == '#':\n if S[i-1][j] == '.' and S[i+1][j] == '.' and S[i][j-1] == '.' and S[i][j+1] == '.':\n flag = 1\nprint('Yes' if flag == 0 else 'No')", "h,w = map(int,input().split())\ns = []\ns.append([\".\"] * (w+2))\nfor i in range(h):\n s.append([a for a in input()])\n s[i+1].insert(0, \".\")\n s[i+1].append(\".\")\ns.append([\".\"] * (w+2))\ncheck = True\nfor j in range(1,h+1):\n for k in range(1,w+1):\n if s[j][k] == \"#\":\n if s[j+1][k] == \".\" and s[j-1][k] == \".\" and s[j][k+1] == \".\" and s[j][k-1] == \".\":\n check = False\nprint(\"Yes\" if check else \"No\")", "# \u4eca\u306e\u5ea7\u6a19\u306e\u8272\u304c#\u306e\u3068\u304d\u3001\u4e0a\u4e0b\u5de6\u53f3\u3044\u305a\u308c\u304b\u306b#\u304c\u3042\u308c\u3070\u304a\uff4b\nh, w = list(map(int, input().split()))\ntable = [input() for _ in range(h)]\nstep = [0, 1, 0, -1, 0]\nfor i in range(h):\n for j in range(w):\n if table[i][j] == \".\":\n continue\n flag = False\n for k in range(4):\n ny, nx = i + step[k], j + step[k + 1]\n if nx < 0 or nx == w or ny < 0 or ny == h:\n continue\n if table[ny][nx] == \"#\":\n flag = True\n if flag == False:\n print(\"No\")\n return\nprint(\"Yes\")\n", "h, w = list(map(int, input().split()))\ns = ['.' + input() + '.' for _ in range(h)]\ns = ['.' * (w + 2)] + s + ['.' * (w + 2)]\n\nfor y in range(1, h + 1):\n for x in range(1, w + 1):\n if s[y][x] == '.':\n continue\n ok = False\n for dy, dx in [(1, 0), (0, 1), (-1, 0), (0, -1)]:\n if s[y + dy][x + dx] == '#':\n ok = True\n if not ok:\n print('No')\n return\nprint('Yes')\n", "import sys\n\n\ndef LI():\n return list(map(int, input().split()))\n\n\ndef LSH(h):\n return [input() for _ in range(h)]\n\n\nH, W = LI()\nmasu = LSH(H)\nfor i in range(H):\n for j in range(W):\n ok = 0\n if masu[i][j] == \".\":\n continue\n if j+1 < W:\n if masu[i][j+1] == \"#\":\n ok = 1\n if j-1 >= 0:\n if masu[i][j-1] == \"#\":\n ok = 1\n if i+1 < H:\n if masu[i+1][j] == \"#\":\n ok = 1\n if i-1 >= 0:\n if masu[i-1][j] == \"#\":\n ok = 1\n if ok == 0:\n print(\"No\")\n return\nprint(\"Yes\")\n", "H, W = list(map(int, input().split()))\n\nS = [list(input()) for _ in range(H)]\n\nfor h in range(H):\n for w in range(W):\n if S[h][w] == \".\":\n continue\n \n if h != 0 and S[h-1][w] == \"#\":\n continue\n elif h != H-1 and S[h+1][w] == \"#\":\n continue\n elif w != 0 and S[h][w-1] == \"#\":\n continue\n elif w != W-1 and S[h][w+1] == \"#\":\n continue\n \n print(\"No\")\n return\n\nprint(\"Yes\")\n\n", "h, w = list(map(int, input().split()))\n\nans = 'Yes'\n\ns = []\nfor i in range(h):\n s += input().split()\n\n# 1\u6587\u5b57\u305a\u3064\u30ea\u30b9\u30c8\u306b\u3059\u308b\ns = list(map(list, s))\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n # \u4e0a\u4e0b\u5de6\u53f3\u3092\u30c1\u30a7\u30c3\u30af\n # \u4ef2\u9593\u304c\u3044\u308b\u6642False\u3001\u5b64\u7acb\u3057\u3066\u3044\u308b\u3068\u304dTrue\n if i > 0:\n flg_up = False if s[i-1][j] == '#' else True\n else:\n flg_up = True\n if i < h - 1:\n flg_down = False if s[i+1][j] == '#' else True\n else:\n flg_down = True\n if j > 0:\n flg_left = False if s[i][j-1] == '#' else True\n else:\n flg_left = True\n if j < w - 1:\n flg_right = False if s[i][j+1] == '#' else True\n else:\n flg_right = True\n # 1\u3064\u3067\u3082\u5b64\u7acb\u3067\u306a\u3044\u30d5\u30e9\u30b0\u304c\u3042\u308c\u3070\u5b64\u7acb\u3067\u306a\u3044\u306e\u3067False\u3001\u5168\u90e8\u5b64\u7acb\u306e\u6642True\n if flg_up & flg_down & flg_left & flg_right:\n ans = 'No'\n break\n\nprint(ans)", "col,row = [int(x) for x in input().split()]\nmap_list = [[0] * (row+2)]\nfor i in range(col):\n map_list.append([\"0\"] + list(input()) + [\"0\"])\nmap_list.append(map_list[0])\n#print(map_list)\n\ndef check(x,y):\n lands = [[x,y]]\n #print(lands)\n area = 0\n sealine = 0\n while lands:\n #print(area)\n #print(lands)\n x,y = lands.pop()\n #print(x,y)\n area += 1\n map_list[y][x] = \"2\"\n if map_list[y+1][x] == \"#\":\n lands.append([x,y+1])\n elif not map_list[y+1][x] == \"2\":\n sealine += 1\n if map_list[y][x+1] == \"#\":\n lands.append([x+1,y])\n elif not map_list[y][x+1] == \"2\":\n sealine += 1\n if map_list[y-1][x] == \"#\":\n lands.append([x,y-1])\n elif not map_list[y-1][x] == \"2\":\n sealine += 1\n if map_list[y][x-1] == \"#\":\n lands.append([x-1,y])\n elif not map_list[y][x-1] == \"2\":\n sealine += 1\n lands = list(map(tuple,lands))\n lands = list(set(lands))\n #print(lands)\n return area\n\nres = \"Yes\"\nfor i in range(1,col+1):\n for j in range(1,row+1):\n if map_list[i][j] == \"#\":\n if check(j,i) == 1:\n res = \"No\"\nprint(res)", "h,w=map(int,input().split())\na=[input()+'.' for i in range(h)]+['.'*w]\nfor i in range(h):\n for j in range(w):\n if a[i][j]==\"#\":\n if any([a[i+1][j]==a[i][j+1]==a[i-1][j]==a[i][j-1]==\".\"]):\n print('No')\n break\n else:\n continue\n break\nelse:\n print('Yes')", "def mapt(fn, *args):\n return tuple(map(fn, *args))\n\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\n\ndef check(i, j, data):\n return any(data[x][y] == \"#\"\n for x, y in ((i-1, j), (i+1, j), (i, j-1), (i, j+1)))\n\n\ndef main():\n h, w = Input()\n a = [\"-\" * (w + 2)]\n data = a + [\"-\" + input() + \"-\" for _ in range(h)] + a\n ans = True\n for i in range(1, h+1):\n for j in range(1, w+1):\n if data[i][j] == \"#\":\n if not check(i, j, data):\n ans = False\n if ans:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\nmain()", "H, W = map(int, input().split())\nx = [list(map(str, list(input()))) for l in range(H)]\n\nfor i in range(len(x)):\n x[i].insert(0, \".\")\n x[i].append(\".\")\nx.insert(0, [\".\"]*(W+2))\nx.append([\".\"]*(W+2))\n\nfor i in range(1, H+1):\n for j in range(1, W+1):\n if x[i][j] == \"#\":\n if x[i][j-1] == x[i][j+1] == x[i-1][j] == x[i+1][j] == \".\":\n print(\"No\")\n return\nprint(\"Yes\")", "h, w = list(map(int, input().split()))\n\nans = 'Yes'\n\ns = []\nfor i in range(h):\n s += input().split()\n\n# \u7aef\u306e\u51e6\u7406\u3092\u697d\u306b\u3059\u308b\u305f\u3081\u306b\u5468\u308a\u3092 . \u3067\u57cb\u3081\u308b\n# ..........\n# .#.#.#.#..\n# ..##.###..\n# .....##.#.\n# ...##...#.\n# ..####..#.\n# ..........\n\n## \u4e0a\u7aef\ns.insert(0, ''.join(['.'] * (w + 2)))\n## \u4e21\u7aef\ns = list(map(lambda x: '.' + x + '.', s))\n## \u4e0b\u7aef\ns.insert(len(s), ''.join(['.'] * (w + 2)))\n\n# 1\u6587\u5b57\u305a\u3064\u30ea\u30b9\u30c8\u306b\u3059\u308b\ns = list(map(list, s))\n\n# 50 * 50\nfor i in range(1, h + 1):\n for j in range(1, w + 1):\n if (s[i][j] == '#') & (s[i-1][j] == '.') & (s[i+1][j] == '.') & (s[i][j-1] == '.') & (s[i][j+1] == '.'):\n ans = 'No'\n break\n else:\n continue\n break\n\nprint(ans)", "H,W = list(map(int,input().split()))\n\nS = [\".\" * (W + 2)]\nS += [\".\" + input() + \".\" for i in range(H)]\nS += [\".\" * (W + 2)]\n\nfor i in range(1, H + 1):\n for j in range(1, W + 1):\n if S[i][j] != \"#\":\n continue\n for y,x in ((0,1),(0,-1),(1,0),(-1,0)):\n if S[i + y][j + x] == \"#\":\n break\n else:\n print(\"No\")\n return\nprint(\"Yes\")\n", "h,w = map(int, input().split())\ns = []\n\nfor i in range(h):\n li = input()\n s.append(li)\n\n\n# \"#\" -> black\n# \".\" -> white\n\ndef check(s, x, y, w, h):\n dx = [0,0,-1,1]\n dy = [1,-1,0,0]\n\n for i in range(4):\n ny, nx = y+dy[i], x+dx[i]\n if 0<=nx<w and 0<=ny<h:\n if s[ny][nx]==\"#\":\n return True\n return False\n\nok = True\nfor i in range(h):\n for j in range(w):\n if s[i][j]==\"#\":\n ok = check(s, j, i, w, h)\n if not ok:\n break\n if not ok:\n break\nif ok or (w==1 and h==1):\n print(\"Yes\")\nelse:\n print(\"No\")", "# -*- coding: utf-8 -*-\n\ndef check(H, W, s, x, y):\n res = False\n if x - 1 >= 0 and s[y][x-1] == '#':\n res = True\n if x + 1 < W and s[y][x+1] == '#':\n res = True\n if y - 1 >= 0 and s[y-1][x] == '#':\n res = True\n if y + 1 < H and s[y+1][x] == '#':\n res = True\n\n return res\n\n\nH,W = map(int, input().split())\ns = []\nfor h in range(H):\n s.append(list(input()))\n\nfor y in range(H):\n for x in range(W):\n if s[y][x] == \"#\" and not check(H, W, s, x, y):\n print(\"No\")\n return\n\nprint(\"Yes\")", "H,W = map(int,input().split())\n\nS = [\".\" * (W + 2)]\nS += [\".\" + input() + \".\" for i in range(H)]\nS += [\".\" * (W + 2)]\n\ndef solve():\n for i in range(1, H + 1):\n for j in range(1, W + 1):\n if S[i][j] != \"#\":\n continue\n for y,x in ((0,1),(0,-1),(1,0),(-1,0)):\n if S[i + y][j + x] == \"#\":\n break\n else:\n return \"No\"\n return \"Yes\"\n\nprint(solve())", "H,W = list(map(int,input().split()))\n\nS = [\".\" * (W + 2)]\nS += [\".\" + input() + \".\" for i in range(H)]\nS += [\".\" * (W + 2)]\n\nng = False\nfor i in range(1, H + 1):\n for j in range(1, W + 1):\n if S[i][j] != \"#\":\n continue\n for y,x in ((0,1),(0,-1),(1,0),(-1,0)):\n if S[i + y][j + x] == \"#\":\n break\n else:\n ng = True\nprint((\"YNeos\"[ng::2]))\n", "h, w = map(int, input().split())\nc = tuple(tuple(0 if i == \".\" else 1 for i in input()) for _ in range(h))\n \nfor i in range(h):\n for j in range(w):\n if c[i][j]:\n T = c[i-1][j] if 0 <= i - 1 else 0\n B = c[i+1][j] if i + 1 < h else 0\n L = c[i][j-1] if 0 <= j - 1 else 0\n R = c[i][j+1] if j + 1 < w else 0\n \n if not (T or B or L or R):\n print(\"No\")\n break\n else:\n continue\n break\nelse:\n print(\"Yes\")", "h,w=list(map(int,input().split()))\n\nsquare=[]\nfor _ in range(h):\n square.append(input())\n\ndef check(i,j):\n flg = False\n for di,dj in [[-1,0],[1,0],[0,-1],[0,1]]:\n if di+i<0 or dj+j<0:\n continue\n if di+i>=h or dj+j>=w:\n continue\n if square[di+i][dj+j]==\"#\":\n flg=True\n return flg\n\nfor i in range(h):\n for j in range(w):\n if square[i][j]==\"#\":\n if not check(i,j):\n # print(i,j)\n print('No')\n return\n\nprint('Yes')\n\n", "H, W = [int(i) for i in input().split()]\nSS = [input() for _ in range(H)]\n\ndef get(lst, i, default=None):\n try:\n return lst[i]\n except IndexError:\n return default\n\nfor i in range(H):\n for j in range(W):\n s = SS[i][j]\n if s == '#':\n if '#' not in [get(get(SS, i-1, []), j), get(get(SS, i, []), j-1), get(get(SS, i+1, []), j), get(get(SS, i, []), j+1)]:\n print('No')\n import sys\n return\n\nprint('Yes')\n", "h, w = map(int, input().split())\nc = [input() for _ in range(h)]\n\nfor i in range(h):\n for j in range(w):\n if c[i][j] == \"#\":\n upper = c[i-1][j] == \"#\" if 0 <= i - 1 else False\n lower = c[i+1][j] == \"#\" if i + 1 < h else False\n left = c[i][j-1] == \"#\" if 0 <= j - 1 else False\n right = c[i][j+1] == \"#\" if j + 1 < w else False\n \n if not (upper or lower or left or right):\n print(\"No\")\n break\n else:\n continue\n break\nelse:\n print(\"Yes\")", "h,w=map(int,input().split())\nlis=[list(input()) for i in range(h)]\n\nans=[[0]*w for i in range(h)]\n\nfor i in range(h):\n for j in range(w):\n x,y=0,0\n if lis[i][j]==\"#\":\n ans[i][j]=1\n for a in range(-1,2):\n if 0<=i+a<h and lis[i+a][j]==\"#\" and a!=0:\n x+=1\n ans[i][j]+=x\n for b in range(-1,2):\n if 0<=j+b<w and lis[i][j+b]==\"#\" and b!=0:\n y+=1\n ans[i][j]+=y\n if ans[i][j]==1:\n print(\"No\")\n return\n else:\n ans[i][j]=0\n \nprint(\"Yes\")", "h,w=map(int,input().split())\na=['.'*(w+2)]\ns=['.'+input()+'.' for _ in range(h)]\ns=a+s+a\nf=True\nfor i in range(1,h+1):\n for j in range(1,w+1):\n if s[i][j]=='#' and s[i][j-1]=='.' and s[i][j+1]=='.' and s[i-1][j]=='.' and s[i+1][j]=='.':\n f=False\nif f:\n print('Yes')\nelse:\n print('No')", "H,W = map(int,input().split())\ns = [input() for _ in range(H)]\nfor i in range(1,H-1):\n for j in range(1,W-1):\n if s[i][j] == \"#\":\n if s[i][j-1] == \".\" and s[i][j+1] == \".\" and s[i-1][j] == \".\" and s[i+1][j] == \".\":\n print(\"No\")\n return\nprint(\"Yes\")", "H,W = map(int,input().split())\n\ncanvas = []\n\nfor i in range(H):\n canvas.append(list(input()))\n \n#print(canvas)\nfor i in range(H):\n for j in range(W):\n cnt = 0\n if canvas[i][j] == \"#\":\n for h in range(-1,2):\n for w in range(-1,2):\n if canvas[min(max(i+h,0),H-1)][min(max(j+w,0),W-1)]==\"#\" and (abs(h)+abs(w))%2==1:\n cnt+=1\n if cnt==0:\n print(\"No\")\n return\nprint(\"Yes\")", "h, w = map(int, input().split())\nc = [input() for _ in range(h)]\n\nfor i in range(h):\n for j in range(w):\n if c[i][j] == \"#\":\n upper = c[i-1][j] == \"#\" if 0 <= i - 1 else False\n lower = c[i+1][j] == \"#\" if i + 1 < h else False\n left = c[i][j-1] == \"#\" if 0 <= j - 1 else False\n right = c[i][j+1] == \"#\" if j + 1 < w else False\n \n if not (upper or lower or left or right):\n print(\"No\")\n break\n else:\n continue\n break\nelse:\n print(\"Yes\")", "h, w = list(map(int, input().split()))\n\nans = 'Yes'\n\ns = []\nfor i in range(h):\n s += input().split()\n\n# \u7aef\u306e\u51e6\u7406\u3092\u697d\u306b\u3059\u308b\u305f\u3081\u306b\u5468\u308a\u3092 . \u3067\u57cb\u3081\u308b\n# ..........\n# .#.#.#.#..\n# ..##.###..\n# .....##.#.\n# ...##...#.\n# ..####..#.\n# ..........\n\n## \u4e0a\u7aef\ns.insert(0, ''.join(['.'] * (w + 2)))\n## \u4e21\u7aef\ns = list(map(lambda x: '.' + x + '.', s))\n## \u4e0b\u7aef\ns.insert(len(s), ''.join(['.'] * (w + 2)))\n\n# 1\u6587\u5b57\u305a\u3064\u30ea\u30b9\u30c8\u306b\u3059\u308b\ns = list(map(list, s))\n\n# 50 * 50\nfor i in range(1, h + 1):\n for j in range(1, w + 1):\n if s[i][j] == '#':\n # \u4e0a\u4e0b\u5de6\u53f3\u3092\u30c1\u30a7\u30c3\u30af\n # \u4ef2\u9593\u304c\u3044\u308b\u6642False\u3001\u5b64\u7acb\u3057\u3066\u3044\u308b\u3068\u304dTrue\n flg_up = False if s[i-1][j] == '#' else True\n flg_down = False if s[i+1][j] == '#' else True\n flg_left = False if s[i][j-1] == '#' else True\n flg_right = False if s[i][j+1] == '#' else True\n \n # 1\u3064\u3067\u3082\u5b64\u7acb\u3067\u306a\u3044\u30d5\u30e9\u30b0\u304c\u3042\u308c\u3070\u5b64\u7acb\u3067\u306a\u3044\u306e\u3067False\u3001\u5168\u90e8\u5b64\u7acb\u306e\u6642True\n if flg_up & flg_down & flg_left & flg_right:\n ans = 'No'\n break\n else:\n continue\n break\n\nprint(ans)", "import re\nimport copy\n\ndef accept_input():\n H, W = list(map(int, input().split()))\n S = []\n for _ in range(H):\n S.append(input())\n return H,W,S\n\ndef process(s):\n if s == \"#\":\n return 1\n else:\n return 0\nH,W,S = accept_input()\narr1 = [(-1,-1),(-1,0),(-1,1),(1,-1),(1,0),(1,1),(0,1),(0,-1)]\narr = [(-1,0),(1,0),(0,1),(0,-1)]\nnew_S = copy.deepcopy(S)\ng = 0\nb = 0\nfor i in range(H):\n for j in range(W):\n if new_S[i][j] == \"#\":\n bl = 0\n for idou in arr:\n if i+idou[0] == -1 or i+idou[0] == H:\n continue\n elif j+idou[1] == -1 or j+idou[1] == W:\n continue\n else:\n if new_S[i+idou[0]][j+idou[1]] == \"#\":\n bl = 1\n if bl != 1:\n b = 1\n break\n if b == 1:\n break\nif b == 1:\n print(\"No\")\nelse:\n print(\"Yes\")\n", "import numpy as np\n\n\ndef get_num_bomb(arr, i, j):\n \"\"\"\n docstring\n \"\"\"\n temp_arr = np.full([arr.shape[0] + 2, arr.shape[1] + 2], False)\n temp_arr[1:1 + arr.shape[0], 1:1 + arr.shape[1]] = arr[:, :]\n # slice = temp_arr[i:i + 3, j:j + 3]\n return temp_arr[i + 1, j] + temp_arr[i, j + 1] + temp_arr[\n i + 2, j + 1] + temp_arr[i + 1, j + 2]\n\n\ndef main():\n h, w = tuple([int(x) for x in input().split(\" \")])\n arr = []\n ret_arr = [[0] * w for i in range(h)]\n for i in range(h):\n x = list([(0 if x == \".\" else 1) for x in input()])\n # x = list(map(lambda x: x, input()))\n arr.append(x)\n arr = np.array(arr)\n # print(arr)\n for i in range(h):\n for j in range(w):\n if arr[i, j] == 1:\n if get_num_bomb(arr, i, j) == 0:\n return \"No\"\n return \"Yes\"\n\n\nprint((main()))\n", "H, W = map(lambda x:int(x)+2, input().split())\ngrid = \".\"*W\nfor _ in range(H-2):\n grid += \".\"+input()+\".\"\ngrid += \".\"*W\n\nFlag = True\nmove_list = [1, -1, W, -W]\n\nfor i in range(1, H-1):\n for j in range(1, W-1):\n if grid[i*W+j] == \"#\" and all(grid[i*W+j+move] == \".\" for move in move_list):\n Flag = False\n break\n\nif Flag:\n print(\"Yes\")\nelse:\n print(\"No\")"]
{"inputs": ["3 3\n.#.\n###\n.#.\n", "5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#\n", "11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##.\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
68,807
ceddb9e89c7b18f50c3001a67c95d7a7
UNKNOWN
Two students of AtCoder Kindergarten are fighting over candy packs. There are three candy packs, each of which contains a, b, and c candies, respectively. Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible. Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students. -----Constraints----- - 1 ≦ a, b, c ≦ 100 -----Input----- The input is given from Standard Input in the following format: a b c -----Output----- If it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No. -----Sample Input----- 10 30 20 -----Sample Output----- Yes Give the pack with 30 candies to one student, and give the two packs with 10 and 20 candies to the other. Then, each gets 30 candies.
["a,b,c=list(map(int,input().split()))\nprint(('Yes'if a+b==c or b+c==a or c+a==b else'No'))\n", "a,b,c=map(int,input().split())\nif max(a,b,c)*2==a+b+c:print('Yes')\nelse:print('No')", "a,b,c = map(int,input().split())\nprint(\"Yes\" if a==b+c or b==a+c or c==a+b else \"No\")", "a,b,c = map(int,input().split())\nif a+b == c or b+c == a or c+a == b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = list(map(int, input().split()))\n\nif a + b == c or a + c == b or b + c == a:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a = list(map(int,input().split()))\nb = a.pop(a.index(max(a)))\nif b == sum(a):\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c = sorted(map(int,input().split()),reverse=True)\nprint(\"Yes\") if a==b+c else print(\"No\")", "a, b, c = sorted(list(map(int, input().split())))\n\nif c == a + b:\n print('Yes')\nelse:\n print('No')", "# A+B=C \u304b\u3000A+C=B \u304b B+C=A\u306b\u306a\u308b\u304b\u5224\u5b9a\n\na, b, c = map(int, input().split())\nif a + b == c or a + c == b or b + c == a:\n print('Yes')\nelse:\n print('No')", "a,b,c=map(int,input().split())\n\nif max(a,b,c)==a+b+c-max(a,b,c):\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = map(int, input().split())\nif a + b == c or b + c == a or c + a == b:\n print('Yes')\nelse:\n print('No')", "#47\ndata=list(input().split())\nif (int(data[0])>int(data[1]) and int(data[0])>int(data[2])):\n if int(data[0])==int(data[1])+int(data[2]):\n print('Yes')\n else:\n print('No')\nelif (int(data[1])>int(data[0]) and int(data[1])>int(data[2])):\n if int(data[1])==int(data[0])+int(data[2]):\n print('Yes')\n else:\n print('No')\nelif (int(data[2])>int(data[1]) and int(data[2])>int(data[0])):\n if int(data[2])==int(data[1])+int(data[0]):\n print('Yes')\n else:\n print('No')\nelse:\n print('No')", "a, b, c = map(int, input().split())\n\nif a == b + c or b == a + c or c == a + b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = map(int, input().split())\n\nif a+b==c or b+c==a or c+a==b:\n print(\"Yes\")\nelse:\n print(\"No\")", "# A - \u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u30682\u4eba\u306e\u5b50\u4f9b\n# https://atcoder.jp/contests/abc047/tasks/abc047_a\n\na, b, c = list(map(int, input().split()))\n\nresult = 'No'\n\nif a + b == c or a + c == b or a == b + c:\n result = 'Yes'\n\nprint(result)\n", "a, b, c = map(int, input().split())\nif a+b==c or b+c==a or c+a==b:\n print('Yes')\nelse:\n print('No')", "#ABC047A\na = list(map(int,input().split()))\na = sorted(a)\nprint(\"Yes\" if a[0]+a[1]==a[2] else \"No\")", "packs = list(map(int, input().split()))\n\nif packs[0] + packs[1] == packs[2] or packs[0] + packs[2] == packs[1] or packs[2] + packs[1] == packs[0]:\n print('Yes')\nelse:\n print('No')", "S_list = list(map(int, input().split()))\n\nS_max = max(S_list)\nanswer = (sum(S_list)) / S_max\nif answer == 2:\n result = \"Yes\"\nelse:\n result = \"No\"\nprint(result)", "a,b,c = map(int,input().split())\n\nif a+b == c or a+c == b or b+c == a:\n print('Yes')\nelse:\n print('No')", "# 3\u500b\u306e\u30d1\u30c3\u30af\u306b\u305d\u308c\u305e\u308c\u3001a,b,c\u500b\u306e\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u304c\u5165\u3063\u3066\u3044\u308b\n# \u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u30922\u4eba\u306b\u5206\u3051\u308b\u969b\u3001\u500b\u6570\u304c\u7b49\u3057\u304f\u306a\u308b\u304b\u5224\u5b9a\n\n# \u5165\u529b\na, b, c = list(map(int, input().split()))\n\n# \u51e6\u7406\nif a == b + c or b == a + c or c == a + b:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a, b, c = map(int, input().split())\njdg = False\nif a + b == c: jdg = True\nif b + c == a: jdg = True\nif c + a == b: jdg = True\nprint( 'Yes' if jdg else 'No')", "def main():\n t = list(map(int, input().split()))\n if sum(t[0:2]) == t[2] or sum(t[1:]) == t[0] or sum(t[::2]) == t[1]:\n print('Yes')\n else:\n print('No')\n\ndef __starting_point():\n main()\n__starting_point()", "abc = list(map(int,input().split()))\nabc.sort()\n\nprint(\"Yes\" if abc[0]+abc[1] == abc[2] else \"No\")", "a, b, c = map(int, input().split())\nif a == b + c or b == a + c or c == a + b:\n print(\"Yes\")\nelse:\n print(\"No\")", "# \u7af6\u30d7\u30ed\u5e7c\u7a1a\u5712\u306b\u901a\u3046 2\u4eba\u306e\u5b50\u4f9b\u304c\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u306e\u53d6\u308a\u5408\u3044\u3092\u3057\u3066\u3044\u307e\u3059\u3002\n# 3\u500b\u306e\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u30d1\u30c3\u30af\u304c\u3042\u308a\u3001\n# \u305d\u308c\u305e\u308c\u306e\u30d1\u30c3\u30af\u306b\u306f\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u304c a, b, c\u500b\u5165\u3063\u3066\u3044\u307e\u3059\u3002\n# \u3048\u3073\u5148\u751f\u306f\u3053\u306e 3\u500b\u306e\u30d1\u30c3\u30af\u3092\u3001\n# \u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u306e\u500b\u6570\u304c\u7b49\u3057\u304f\u306a\u308b\u3088\u3046\u306b 2\u4eba\u306b\u5206\u3051\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059\u3002\n# \u305d\u306e\u3088\u3046\u306a\u5206\u3051\u65b9\u304c\u53ef\u80fd\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n# \u305f\u3060\u3057\u3001\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u3092\u30d1\u30c3\u30af\u304b\u3089\u53d6\u308a\u51fa\u3059\u3053\u3068\u306f\u3067\u304d\u305a\u3001\n# \u305d\u308c\u305e\u308c\u306e\u30d1\u30c3\u30af\u3092\u305d\u306e\u307e\u307e\u3069\u3061\u3089\u304b\u306e\u5b50\u4f9b\u306b\u3042\u3052\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\n\n# \u5236\u7d04\n# 1 \u2266 a, b, c \u2266 100\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089\u3001a, b, c \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\na, b, c = list(map(int,input().split()))\n\nresult = \"ret\"\nif (a + b) == c:\n result = \"Yes\"\nelif (a + c) == b:\n result = \"Yes\"\nelif (b + c) == a:\n result = \"Yes\"\nelse:\n result = \"No\"\n\nprint(result)\n", "a,b,c = map(int, input().split())\n\ns = sum([a,b,c])\nm = max(a,b,c)\n\nif m == (s - m):\n print(\"Yes\")\nelse:\n print(\"No\")", "L=list(map(int,input().split()))\nL.sort()\nprint('Yes' if sum(L[:2])==L[2] else 'No')", "a,b,c=map(int,input().split())\nif a+b==c or a+c==b or b+c==a:\n print(\"Yes\")\nelse:\n print(\"No\")", "l = list(map(int,input().split()))\nl1 = sorted(l, reverse = True)\ns = sum(l1)\nif l1[0] == s/2:\n print(\"Yes\")\nelse:\n print(\"No\")", "a = list(map(int, input().split()))\nif max(a)*2 == sum(a):\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = list(map(int, input().split()))\n\nif a + b == c:\n print('Yes')\nelif a + c == b:\n print('Yes')\nelif c + b == a:\n print('Yes')\nelse:\n print('No')\n", "L = sorted(list(map(int, input().split())))\nprint('Yes' if sum(L[:2]) == L[2] else 'No')", "x = list(map(int,input().split()))\ny = sorted(x)\nif y[0]+y[1]==y[2]:\n print(\"Yes\")\nelse:\n print(\"No\")", "# \u5165\u529b\na, b, c = map(int, input().split())\n\n# \u51fa\u529b\nif a == b + c or b == a + c or c == a + b:\n print('Yes')\nelse:\n print('No')", "A,B,C = map(int,input().split())\n\nif A == B + C or B == A + C or C == A + B:\n print('Yes')\nelse:\n print('No')", "a = sorted(list(map(int, input().split())))\nif sum(a[:2]) == a[2]:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "p = list(map(int, input().split()))\np.sort()\nprint('Yes' if p[0]+p[1]==p[2] else 'No')", "A = sorted(map(int, input().split()))\nprint((\"Yes\" if sum(A[:2]) == A[2] else \"No\"))\n", "a, b, c = map(int,input().split())\nif a+b==c or b+c==a or c+a==b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = map(int, input().split())\n\nif a == b + c:\n print('Yes')\nelif b == a + c:\n print('Yes')\nelif c == a + b:\n print('Yes')\nelse:\n print('No')", "# \u5165\u529b\na, b, c = list(map(int, input().split()))\n\n# 2\u7b49\u5206\u3067\u304d\u308b\u306a\u3089Yes\u3001\u3067\u304d\u306a\u3044\u306a\u3089No\nif a + b == c:\n print('Yes')\nelif a + c == b:\n print('Yes')\nelif b + c == a:\n print('Yes')\nelse:\n print('No')\n", "abc = list(map(int, input().split()))\nabc_max = max(abc)\nabc2 = abc\nabc2.remove(abc_max)\n\nif abc_max == sum(abc2):\n print('Yes')\nelse:\n print('No')", "a = [int(x) for x in input().split()]\na.sort()\nif a[0] + a[1] == a[2]:\n print(\"Yes\")\nelse:\n print(\"No\")", "arr = list(map(int, input().split()))\narr.sort()\n\nif arr[0] + arr[1] == arr[2]:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = list(map(int, input().split()))\n\nif a + b == c or a + c == b or b + c == a:\n print('Yes')\nelse:\n print('No')\n", "ary = sorted(list(map(int, input().split())))\nprint('Yes' if ary[0] + ary[1] == ary[2] else 'No')", "# \u5165\u529b\na, b, c = list(map(int, input().split()))\n\n# \u51e6\u7406\nif a + b == c or b + c == a or c + a == b:\n print('Yes')\n\nelse:\n print('No')\n\n\n# \u51fa\u529b\n\n", "# A - \u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u30682\u4eba\u306e\u5b50\u4f9b\n\n# \u305d\u308c\u305e\u308c\u6570\u500b\u305a\u3064\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u306e\u5165\u3063\u305f\u30d1\u30c3\u30af\u304c3\u500b\u3042\u308b\n# \u4e8c\u4eba\u306e\u5b50\u4f9b\u306b\u3001\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u3092\u7b49\u3057\u3044\u6570\u305a\u3064\u5206\u3051\u3089\u308c\u308b\u304b\u5224\u5b9a\u3059\u308b\n\n\na, b, c = list(map(int, input().split()))\n\nif a + b == c \\\nor a + c == b \\\nor b + c == a:\n print('Yes')\nelse:\n print('No')\n", "a,b,c=map(int,input().split())\nif a+b==c or b+c==a or c+a==b:print(\"Yes\")\nelse:print(\"No\")", "a,b,c=map(int,input().split())\nif a+b==c or a+c==b or b+c==a:\n print(\"Yes\")\nelse:\n print(\"No\")", "A, B, C = [int(i) for i in input().split()]\nx = max(A, B, C)\ns = sum([A, B, C])\ny = s - x\n\nif x == y:\n print('Yes')\nelse:\n print('No')\n", "a,b,c=map(int,input().split())\nif a==b+c or b==c+a or c==a+b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = map(int, input().split())\n\nif a == (b + c) or b == (a + c) or c == (a + b):\n print('Yes')\n\nelse:\n print('No')", "a,b,c = list(map(int,input().split()))\n\nif a+b == c or b+c == a or a+c == b:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "def iroha():\n li = list(map(int, input().split()))\n li.sort()\n merge = li[0] + li[1]\n if merge == li[2]:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "#\n# abc047 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 = \"\"\"10 30 20\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"30 30 100\"\"\"\n output = \"\"\"No\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"56 25 31\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n C = list(map(int, input().split()))\n C.sort()\n\n if C[2] == C[0] + C[1]:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "a,b,c = map(int,input().split())\nif(a+b == c or a+c == b or b+c ==a):\n print(\"Yes\")\nelse:\n print(\"No\")", "# 047_a\na, b, c = list(map(int, input().split()))\nif (1 <= a <= 100) & (1 <= b <= 100) & (1 <= c <= 100):\n if (a + b == c) | (a == b + c) | (a + c == b):\n print('Yes')\n else:\n print('No')\n", "a = list(map(int,input().split()))\n\na.sort()\nif a[0] + a[1] == a[2]:\n print('Yes')\nelse:\n print('No')", "l=list(map(int,input().split()))\nprint(\"Yes\")if(e:=sum(l))%2==0 and e//2 in l else print(\"No\")", "a,b,c=map(int,input().split())\nif a+b==c or a+c==b or a==b+c:\n print(\"Yes\")\nelse:\n print(\"No\")", "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 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 = sorted(lint())\nprint(('Yes' if a + b == c else 'No'))\n", "abc = list(map(int, input().split()))\nabc.sort()\nif abc[0] + abc[1] == abc[2]:\n print('Yes')\nelse:\n print('No')", "a=sorted(list(map(int,input().split())))\nif a[0]+a[1]==a[2]:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c = map(int,input().split())\n\nif a + b == c or a + c == b or b + c == a:\n print(\"Yes\")\nelse:\n print(\"No\")", "a = list(map(int, input().split()))\na.sort()\nif a[0] + a[1] == a[2]:\n print('Yes')\nelse:\n print('No')", "a,b,c = map(int,input().split())\nprint(['No','Yes'][a+b == c or a+c == b or b+c == a])", "a, b, c = list(map(int, input().split()))\ns = (a + b + c) / 2\nif s == a or s == b or s == c:\n print('Yes')\nelse:\n print('No')", "a,b,c=map(int,input().split())\nlist=[a,b,c]\n\nlist.sort()\nif list[0]+list[1]==list[2]:\n print(\"Yes\")\nelse:\n print(\"No\")", "a = list(map(int, input().split()))\na.sort()\nprint('Yes') if a[0] + a[1] == a[2] else print('No')", "a, b, c = sorted(map(int, input().split()))\nprint((\"No\", \"Yes\")[a + b == c])", "a, b, c = list(map(int, input().split()))\nma = max(a, b, c)\nrem = a + b + c - ma\nif ma == rem:\n print('Yes')\nelse:\n print('No')\n", "a,b,c = list(map(int,input().split()))\n\nif (a+b == c)or(b+c == a)or(a+c == b):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")\n", "a = list(map(int, input().split()))\na.sort()\nif(a[0]+a[2] == a[1] or a[0]+a[1] == a[2]):\n print(\"Yes\")\nelse:\n print(\"No\")", "candy = sorted([int(x) for x in input().split()])\nif candy[0] + candy[1] == candy[2]:\n print('Yes')\nelse:\n print('No')", "a,b,c=list(map(int,input().split()))\n\nif(a+b == c or a+c == b or b+c == a):\n print(\"Yes\")\nelse:\n print(\"No\")", "# \u5165\u529b\na, b, c = map(int, input().split())\n\n# \u51e6\u7406\nif a + b == c:\n print('Yes')\nelif a + c == b:\n print('Yes')\nelif b + c == a:\n print('Yes')\nelse:\n print('No')", "x = list(map(int, input().split(' ')))\nif x[0] == x[1] + x[2]:\n print('Yes')\nelif x[0] + x[1] == x[2]:\n print('Yes')\nelif x[0] + x[2] == x[1]:\n print('Yes')\nelse:\n print('No')", "def solve():\n a, b, c = map(int, input().split())\n if a == b + c or b == a + c or c == a + b:\n print('Yes')\n else:\n print('No')\n\n\ndef __starting_point():\n solve()\n__starting_point()", "a = list(map(int, input().split()))\na.sort()\n\nif a[0]+a[1] == a[2]:\n print('Yes')\nelse:\n print('No')\n", "# \u7af6\u30d7\u30ed\u5e7c\u7a1a\u5712\u306b\u901a\u30462\u4eba\u306e\u5b50\u4f9b\u304c\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u306e\u53d6\u308a\u5408\u3044\u3092\u3057\u3066\u3044\u307e\u3059\u3002\n# 3\u500b\u306e\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u30d1\u30c3\u30af\u304c\u3042\u308a\u3001\u305d\u308c\u305e\u308c\u306e\u30d1\u30c3\u30af\u306b\u306f\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u304ca,b,c\u500b\u5165\u3063\u3066\u3044\u307e\u3059\u3002\n# \u3048\u3073\u5148\u751f\u306f\u3053\u306e3\u500b\u306e\u30d1\u30c3\u30af\u3092\u3001\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u306e\u500b\u6570\u304c\u7b49\u3057\u304f\u306a\u308b\u3088\u3046\u306b2\u4eba\u306b\u5206\u3051\u3088\u3046\u3068\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u306e\u3088\u3046\u306a\u5206\u3051\u65b9\u304c\u53ef\u80fd\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n# \u305f\u3060\u3057\u3001\u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u3092\u30d1\u30c3\u30af\u304b\u3089\u53d6\u308a\u51fa\u3059\u3053\u3068\u306f\u3067\u304d\u305a\u3001\u305d\u308c\u305e\u308c\u306e\u30d1\u30c3\u30af\u3092\u305d\u306e\u307e\u307e\u3069\u3061\u3089\u304b\u306e\u5b50\u4f9b\u306b\u3042\u3052\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\n\na,b,c =map(int,input().split())\n\nif (a + b == c) or (a + c == b) or (b + c == a):\n print('Yes')\n\nelse:\n print('No')", "a,b,c=map(int,input().split())\n\nif a == b+c or b == a+c or c == a+b:\n print('Yes')\n \nelse:\n print('No')", "a, b, c = map(int, input().split())\n\nif a + b == c or b + c == a or c + a == b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c=map(int,input().split())\nif sum([a,b,c])==max(a,b,c)*2:\n print(\"Yes\")\nelse:\n print(\"No\")", "# \u5165\u529b\na, b, c = map(int,input().split())\n\n# \u51e6\u7406\nif a == b + c or b == a + c or c == a + b:\n print('Yes')\nelse:\n print('No')", "a,b,c=map(int,input().split())\nprint('NYoe s'[a+b==c or a+c==b or a==b+c::2])", "a, b, c = map(int, input().split())\n\nli = sorted([a, b, c])\nans = 'No'\nif sum(li[:2])==li[2]:\n ans ='Yes'\nprint(ans)", "a,b,c = sorted(map(int, input().split()))\n\nprint((\"Yes\" if a+b == c else \"No\"))\n", "import sys\nsys.setrecursionlimit(250000)\n\ndef main():\n a,b,c = list(map(int, input().split()))\n\n if a == b + c :\n print(\"Yes\")\n elif b == a + c:\n print(\"Yes\")\n elif c == a + b:\n print(\"Yes\")\n else:\n print(\"No\")\nmain()\n\n\n\n#\n# while True:\n# pair_str = input().split()\n# pair_int = [int(s) for s in pair_str]\n# if pair_int[0] == 0 and pair_int[1] == 0 :\n# break\n# else:\n# input_list.append(pair_int)\n\n\n# if b > c * 2 :\n # b_price = c\n #\n # input_array_list = []\n #\n # while True:\n # input_array = input().split()\n # if input_array[0] == \"0\" and input_array[1] == \"0\":\n # break\n # else:\n # input_array_list.append(input_array)\n #\n # for item in input_array_list:\n # n = int(item[0])\n # k_sum = int(item[1])\n #\n # count = 0\n # for i in range(1,n + 1- 2):\n # for j in range(i+1, n + 1 - 1):\n # for k in range (j+1, n+ 1):\n # if i + j + k == k_sum :\n # count = count + 1\n # print(count)\n\n #\n # for item in input_array_list:\n # if item[1] == \"+\":\n # print(str(int(item[0])+int(item[2])))\n # elif item[1] ==\"-\":\n # print(str(int(item[0])-int(item[2])))\n # elif item[1] == \"/\":\n # print(str(int(item[0])//int(item[2])))\n # elif item[1] == \"*\":\n # print(str(int(item[0])*int(item[2])))\n #\n\n# import sympy as sp\n\n# input_list = []\n# a,b,c = map(int, input().split())\n# divisors = sp.divisors(c)\n#\n# count = 0\n#\n# for divisor in divisors:\n# if a <= divisor and divisor <= b:\n# count = count + 1\n# print(count)\n#\n# while True:\n# pair_str = input().split()\n# pair_int = [int(s) for s in pair_str]\n# if pair_int[0] == 0 and pair_int[1] == 0 :\n# break\n# else:\n# input_list.append(pair_int)\n#\n# for pair_int in input_list:\n# if pair_int[0] <= pair_int[1]:\n# print(\"{} {}\".format(pair_int[0], pair_int[1]))\n# else:\n# print(\"{} {}\".format(pair_int[1], pair_int[0]))\n\n#for i in range(10000):\n# print(\"Hello World\")\n#a = input().split()\n#a_int = [int(s) for s in a]\n#a_sorted = sorted(a_int)\n#print(' '.join(map(str, a_sorted)))\n", "\"\"\"\nABC047 A - \u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u30682\u4eba\u306e\u5b50\u4f9b\nhttps://atcoder.jp/contests/abc047/tasks/abc047_a\n\"\"\"\n\nl = list(map(int, input().split()))\nl.sort()\nif l[0] + l[1] == l[2]:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "l = sorted(list(map(int, input().split())))\nprint(\"Yes\" if l[2] == sum(l[:2]) else \"No\")", "a,b,c = map(int, input().split())\n\nif a+b==c or b+c==a or a+c==b:\n print('Yes')\nelse:\n print('No')", "a, b, c = map(int, input().split())\n\nif a+b == c or a+c == b or b+c == a:\n print('Yes')\nelse:\n print('No')", "str_line = input().split(\" \")\nnum_line = [int(n) for n in str_line]\nnum_line.sort()\n#print(num_line)\n\nif (num_line[2] == num_line[1] + num_line[0]):\n print(\"Yes\")\nelse:\n print(\"No\")", "# \u30ad\u30e3\u30f3\u30c7\u30a3\u306e\u500b\u6570\u3092\u53d6\u5f97\na,b,c = map(int,input().split())\n\n#\u5224\u5b9a\u7d50\u679c\u3092\u3082\u3068\u306b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\nif a == b + c\\\nor b == a + c\\\nor c == a + b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c=map(int,input().split())\nprint(\"Yes\" if a+b==c or a+c==b or b+c==a else \"No\")", "# 047a\n\na, b, c = list(map(int, input().split()))\n\nif a + b == c or a + c == b or b + c == a:\n print('Yes')\nelse:\n print('No')\n\n", "abc=sorted(list(map(int,input().split())))\nprint('Yes' if abc[0]+abc[1]==abc[2] else 'No')", "a,b,c=map(int,input().split())\nsortlist=sorted([a,b,c])\nif sortlist[0]+sortlist[1]==sortlist[2]:\n print(\"Yes\")\nelse:\n print(\"No\")"]
{"inputs": ["10 30 20\n", "30 30 100\n", "56 25 31\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
21,511
bce00d87ed514526cc1db91a4d0f44a8
UNKNOWN
A balance scale tips to the left if L>R, where L is the total weight of the masses on the left pan and R is the total weight of the masses on the right pan. Similarly, it balances if L=R, and tips to the right if L<R. Takahashi placed a mass of weight A and a mass of weight B on the left pan of a balance scale, and placed a mass of weight C and a mass of weight D on the right pan. Print Left if the balance scale tips to the left; print Balanced if it balances; print Right if it tips to the right. -----Constraints----- - 1\leq A,B,C,D \leq 10 - All input values are integers. -----Input----- Input is given from Standard Input in the following format: A B C D -----Output----- Print Left if the balance scale tips to the left; print Balanced if it balances; print Right if it tips to the right. -----Sample Input----- 3 8 7 1 -----Sample Output----- Left The total weight of the masses on the left pan is 11, and the total weight of the masses on the right pan is 8. Since 11>8, we should print Left.
["a,b,c,d = map(int,input().split())\nab = a + b\ncd = c + d\nif ab > cd:\n print('Left')\nelif ab < cd:\n print('Right')\nelse:\n print('Balanced')", "A,B,C,D=map(int,input().split())\nif A+B>C+D :\n print(\"Left\")\nelif A+B==C+D :\n print(\"Balanced\")\nelse :\n print(\"Right\")", "A,B,C,D=map(int,input().split())\nif A+B>C+D:\n print(\"Left\")\nelif A+B<C+D:\n print(\"Right\")\nelse:\n print(\"Balanced\")", "a,b,c,d=map(int,input().split())\na += b\nc += d\nif a>c:\n print('Left')\nelif a < c:\n print('Right')\nelse:\n print('Balanced')", "A, B, C, D = map(int, input().split())\n\nif (A + B) > (C + D):\n print(\"Left\")\nelif (A + B) < (C + D):\n print(\"Right\")\nelse:\n print(\"Balanced\")", "A, B, C, D = map(int, input().split())\n\nif A + B > C + D: print('Left')\nelif A + B == C + D: print('Balanced')\nelse: print('Right')", "a, b, c, d = map(int, input().split())\nl = a+b\nr = c+d\nif l > r:\n print('Left')\nelif l < r:\n print('Right')\nelse:\n print('Balanced')", "a,b,c,d = map(int,input().split())\n\nif a+b > c+d:\n print('Left')\nelif a+b == c+d:\n print('Balanced')\nelse:\n print('Right')", "A, B, C, D = list(map(int,input().split()))\nif A + B < C + D:\n print(\"Right\")\nelif A + B == C + D:\n print(\"Balanced\")\nelse:\n print(\"Left\")\n", "a, b, c, d = map(int,input().split())\nif a+b==c+d:\n print(\"Balanced\")\nelif a+b>c+d:\n print(\"Left\")\nelse:\n print(\"Right\")", "a, b, c, d = (int(x) for x in input().split())\nif a + b > c + d:\n print('Left')\nelif a + b < c + d:\n print('Right')\nelse:\n print('Balanced')", "a, b, c, d = list(map(int, input().split()))\nleft = a + b\nright = c + d\n\nif left == right:\n print('Balanced')\nelif left > right:\n print('Left')\nelse:\n print('Right')\n", "A,B,C,D=list(map(int,input().split()))\nif A+B>C+D:\n print(\"Left\")\nelif A+B<C+D:\n print(\"Right\")\nelse:\n print(\"Balanced\")\n", "A, B, C, D = list(map(int, input().split()))\nif A + B > C + D:\n print('Left')\nelif A + B < C + D:\n print('Right')\nelse:\n print('Balanced')\n", "a,b,c,d = map(int,input().split())\nprint(\"Left\" if a+b>c+d else \"Right\" if a+b<c+d else \"Balanced\")", "# \u4e0a\u76bf\u5929\u79e4\u306f\u3001\u5de6\u306e\u76bf\u306b\u4e57\u3063\u3066\u3044\u308b\u304a\u3082\u308a\u306e\u91cd\u3055\u306e\u5408\u8a08\u3092 L \u3068\u3057\u3001\n# \u53f3\u306e\u76bf\u306b\u4e57\u3063\u3066\u3044\u308b\u304a\u3082\u308a\u306e\u91cd\u3055\u306e\u5408\u8a08\u3092 R \u3068\u3057\u305f\u3068\u304d\u3001\n# L > R \u306a\u3089\u5de6\u306b\u50be\u304d\u3001 L = R \u306a\u3089\u91e3\u308a\u5408\u3044\u3001\n# L < R \u306a\u3089\u53f3\u306b\u50be\u304d\u307e\u3059\u3002\n#\n# \u9ad8\u6a4b\u541b\u306f\u3001\u4e0a\u76bf\u5929\u79e4\u306e\u5de6\u306e\u76bf\u306b\u91cd\u3055 A \u306e\u304a\u3082\u308a\u3068\u91cd\u3055 B \u306e\u304a\u3082\u308a\u3092\u3001\n# \u53f3\u306e\u76bf\u306b\u91cd\u3055 C \u306e\u304a\u3082\u308a\u3068\u91cd\u3055 D \u306e\u304a\u3082\u308a\u3092\u7f6e\u304d\u307e\u3057\u305f\u3002\n#\n# \u4e0a\u76bf\u5929\u79e4\u304c\u5de6\u306b\u50be\u304f\u306a\u3089 Left \u3092\u3001\n# \u91e3\u308a\u5408\u3046\u306a\u3089 Balanced \u3092\u3001\n# \u53f3\u306b\u50be\u304f\u306a\u3089 Right \u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# 1 \u2266 A, B, C, D \u2266 10\n# \u5165\u529b\u306f\u3059\u3079\u3066\u6574\u6570\u3067\u3042\u308b\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\n# \u4e0a\u76bf\u5929\u79e4\u306e\u72b6\u614b\u3092\u5224\u5b9a\u3057\u3001\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\nresult = \"ret\"\n\nif (a + b) > (c + d):\n result = \"Left\"\nelif (a + b) < (c + d):\n result = \"Right\"\nelse:\n result = \"Balanced\"\n\nprint(result)\n", "a,b,c,d=map(int,input().split())\n\nif a+b>c+d:\n ans=\"Left\"\nelif a+b<c+d:\n ans=\"Right\"\nelse:\n ans=\"Balanced\"\nprint(ans)", "left1, left2, right1, right2 = map(int, input().split())\nif right1 + right2 > left1 + left2:\n print('Right')\nelif right1 + right2 < left1 + left2:\n print('Left')\nelse:\n print('Balanced')", "a,b,c,d = map(int,input().split())\nL = a+b\nR = c+d\nprint(\"Left\" if L>R else \"Right\" if R>L else \"Balanced\")", "# \u5165\u529b\nA, B, C, D = list(map(int, input().split()))\n\n# \u51fa\u529b\nif 1 <= A and B and C and D <= 10:\n if A + B == C + D:\n print('Balanced')\n elif A + B > C + D:\n print('Left')\n elif A + B < C + D:\n print('Right')\n", "a,b,c,d=map(int,input().split())\nif a+b>c+d:print('Left')\nelif a+b<c+d:print('Right')\nelse:print('Balanced')", "a,b,c,d=(int(x) for x in input().split())\ne = int(a) + int(b)\nf = int(c) + int(d)\nif e > f:\n print('Left')\nelif e < f:\n print('Right')\nelse:\n print('Balanced')", "a,b,c,d=map(int,input().split())\n\nl=a+b;r=c+d\n\nif l<r:\n print('Right')\n \nelif l>r:\n print('Left')\n \nelse:\n print('Balanced')", "# \u4e0a\u76bf\u5929\u79e4\u306f\u3001\u5de6\u306e\u76bf\u306b\u4e57\u3063\u3066\u3044\u308b\u304a\u3082\u308a\u306e\u91cd\u3055\u306e\u5408\u8a08\u3092 L \u3068\u3057\u3001\n# \u53f3\u306e\u76bf\u306b\u4e57\u3063\u3066\u3044\u308b\u304a\u3082\u308a\u306e\u91cd\u3055\u306e\u5408\u8a08\u3092 R \u3068\u3057\u305f\u3068\u304d\u3001\n# L > R \u306a\u3089\u5de6\u306b\u50be\u304d\u3001 L = R \u306a\u3089\u91e3\u308a\u5408\u3044\u3001\n# L < R \u306a\u3089\u53f3\u306b\u50be\u304d\u307e\u3059\u3002\n#\n# \u9ad8\u6a4b\u541b\u306f\u3001\u4e0a\u76bf\u5929\u79e4\u306e\u5de6\u306e\u76bf\u306b\u91cd\u3055 A \u306e\u304a\u3082\u308a\u3068\u91cd\u3055 B \u306e\u304a\u3082\u308a\u3092\u3001\n# \u53f3\u306e\u76bf\u306b\u91cd\u3055 C \u306e\u304a\u3082\u308a\u3068\u91cd\u3055 D \u306e\u304a\u3082\u308a\u3092\u7f6e\u304d\u307e\u3057\u305f\u3002\n#\n# \u4e0a\u76bf\u5929\u79e4\u304c\u5de6\u306b\u50be\u304f\u306a\u3089 Left \u3092\u3001\n# \u91e3\u308a\u5408\u3046\u306a\u3089 Balanced \u3092\u3001\n# \u53f3\u306b\u50be\u304f\u306a\u3089 Right \u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# 1 \u2266 A, B, C, D \u2266 10\n# \u5165\u529b\u306f\u3059\u3079\u3066\u6574\u6570\u3067\u3042\u308b\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\n# \u4e0a\u76bf\u5929\u79e4\u306e\u72b6\u614b\u3092\u5224\u5b9a\u3057\u3001\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\nresult = \"ret\"\n\nif (a + b) > (c + d):\n result = \"Left\"\nelif (a + b) < (c + d):\n result = \"Right\"\nelse:\n result = \"Balanced\"\n\nprint(result)\n", "# 083_a\nA,B,C,D=list(map(int,input().split()))\nif (1<=A and A<=10)and(1<=B and B<=10)and(1<=C and C<=10)and(1<=D and D<=10):\n L=A+B\n R=C+D\n if L>R:\n print('Left')\n elif L==R:\n print('Balanced')\n elif L<R:\n print('Right')\n", "S = input()\nS_list = S.split()\n\nL = int(S_list[0]) + int(S_list[1])\nR = int(S_list[2]) + int(S_list[3])\n \nif L-R>0:\n print(\"Left\")\nelif L-R<0:\n print(\"Right\")\nelse:\n print(\"Balanced\")", "a, b, c, d = (int(x) for x in input().split())\nif a+b > c+d:\n ans = 'Left'\nelif a+b < c+d:\n ans = 'Right'\nelse:\n ans = 'Balanced'\nprint(ans)", "# A - Libra\n# https://atcoder.jp/contests/abc083/tasks/abc083_a\n\nA, B, C, D = list(map(int, input().split()))\n\nab = A + B\ncd = C + D\nresult = 'Balanced'\n\nif ab > cd:\n result = 'Left'\nelif ab < cd:\n result = 'Right'\n\nprint(result)\n", "a = list(map(int, input().split()))\na = a[0] + a[1] - a[2] - a[3]\nif a == 0:\n print('Balanced')\nelif a > 0:\n print('Left')\nelse:\n print('Right')\n", "a,b,c,d = [int(x) for x in input().split()]\nif a+b == c+d:\n print(\"Balanced\")\nelif a+b > c+d:\n print(\"Left\")\nelse:\n print(\"Right\")", "A, B, C, D = map(int, input().split())\nif A + B == C + D:\n print(\"Balanced\")\nelif A + B < C + D:\n print(\"Right\")\nelse:\n print(\"Left\")", "a, b, c, d = map(int, input().split())\nif a + b > c + d:\n print('Left')\nelif a + b < c + d:\n print('Right')\nelse:\n print('Balanced')", "a,b,c,d=map(int,input().split())\nif a+b==c+d:\n print(\"Balanced\")\nelif a+b>=c+d:\n print(\"Left\")\nelse:\n print(\"Right\")", "a,b,c,d = map(int,input().split())\ne,f=a+b,c+d\nif e<f:\n print(\"Right\")\nelif e==f:\n print(\"Balanced\")\nelse:\n print(\"Left\")", "import math\n# 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]<a[2]+a[3]:\n print(\"Right\")\nelif a[0]+a[1]==a[2]+a[3]:\n print(\"Balanced\")\nelif a[0]+a[1]>a[2]+a[3]:\n print(\"Left\")", "a, b, c, d = list(map(int, input().split()))\nif a+b > c+d:\n print('Left')\nelif a+b == c+d:\n print('Balanced')\nelse:\n print('Right')\n", "a, b, c, d = map(int, input().split())\nif a+b > c+d:\n print(\"Left\")\nelif a+b == c+d:\n print(\"Balanced\")\nelse:\n print(\"Right\")", "A,B,C,D = map(int, input().split())\nif A+B > C + D:\n print('Left')\nelif A+B < C+ D:\n print('Right')\nelse:\n print('Balanced')", "a, b, c, d = list(map(int, input().split()))\nleft = a+b\nright = c+d\nprint((['Balanced', 'Left', 'Right'][left > right or -(right > left)]))\n\n", "a,b,c,d=map(int,input().split())\nif a+b>c+d:\n print(\"Left\")\nelif a+b==c+d:\n print(\"Balanced\")\nelse:\n print(\"Right\")", "a,b,c,d=map(int,input().split())\nif a+b<c+d:\n print(\"Right\")\nelif a+b>c+d:\n print(\"Left\")\nelse:\n print(\"Balanced\")", "a, b, c, d = map(int,input().split())\n\nL = a + b\nR = c + d\n\nprint(\"Left\" if L > R else \"Balanced\" if L == R else \"Right\")", "a,b,c,d = map(int,input().split())\n\nif a+b > c+d:\n print('Left')\n \nelif a+b < c+d:\n print('Right')\n \nelse:\n print('Balanced')", "# \u5404\u9318\u306e\u91cd\u91cf\u3092\u53d6\u5f97\nA,B,C,D = map(int,input().split())\n\n# \u5de6\u3068\u53f3\u306e\u76bf\u306e\u91cd\u3055\u3092\u8a08\u7b97\nLWeight = A + B\nRWeight = C + D\n\n# \u6bd4\u8f03\u7d50\u679c\u306b\u3082\u3069\u3065\u3044\u3066\u5404\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\nif LWeight > RWeight:\n print(\"Left\")\nelif LWeight < RWeight:\n print(\"Right\")\nelse:\n print(\"Balanced\")", "#\n# abc083 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 8 7 1\"\"\"\n output = \"\"\"Left\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"3 4 5 2\"\"\"\n output = \"\"\"Balanced\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"1 7 6 4\"\"\"\n output = \"\"\"Right\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n A, B, C, D = list(map(int, input().split()))\n if A+B > C+D:\n print(\"Left\")\n elif A+B < C+D:\n print(\"Right\")\n else:\n print(\"Balanced\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "A, B, C, D = map(int, input().split())\nif A + B > C + D:\n print('Left')\nelif A + B < C + D:\n print('Right')\nelse:\n print('Balanced')", "a, b, c, d = map(int, input().split())\n\nleft = a + b\nright = c + d\n\nif left > right:\n print(\"Left\")\nelif left == right:\n print(\"Balanced\")\nelse:\n print(\"Right\")", "# A - Libra\n\n# \u5929\u79e4\u306e\u5de6\u306e\u76bf\u306b\u304a\u3082\u308aA,B\u3092\u3001\u53f3\u306e\u76bf\u306b\u304a\u3082\u308aB,D\u3092\u8f09\u305b\u305f\u5834\u5408\u3001\n# \u5929\u79e4\u304c\u3069\u3061\u3089\u306b\u50be\u304f\u304b\u3092\u51fa\u529b\u3059\u308b\n\n\nA,B,C,D = list(map(int,input().split()))\n\nleft_dish = A + B\nright_dish = C + D\n\nif left_dish > right_dish:\n print('Left')\nelif left_dish < right_dish:\n print('Right')\nelif left_dish == right_dish:\n print('Balanced')\n", "a, b, c, d = map(int, input().split())\nx = a + b\ny = c + d\nif x == y:\n print('Balanced')\nelif x > y:\n print('Left')\nelse:\n print('Right')", "a, b, c, d = map(int, input().split())\nz = a + b - c - d\nif z > 0:\n print('Left')\nelif z < 0:\n print('Right')\nelse:\n print('Balanced')", "a,b,c,d = list(map(int,input().split()))\nif a+b>c+d:\n print(\"Left\")\nelif a+b==c+d:\n print(\"Balanced\")\nelse:\n print(\"Right\")\n", "# AtCoder abc083 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\na, b, c, d = list(map(int, input().split()))\n\n# \u5224\u5b9a\ndiff = (a + b) - (c + d)\nif diff == 0:\n print(\"Balanced\")\nelif diff > 0:\n print(\"Left\")\nelse:\n print(\"Right\")\n", "left_a, left_b, right_a, right_b = list(map(int, input().split()))\n\nleft_weight = left_a + left_b\nright_weight = right_a + right_b\n\nif left_weight == right_weight:\n print('Balanced')\nelif left_weight > right_weight:\n print('Left')\nelif right_weight > left_weight:\n print('Right')\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, c, d = Input()\n x, y = a + b, c + d\n \n if x > y: print(\"Left\")\n elif x < y: print(\"Right\")\n else: print(\"Balanced\")\n\n\nmain()", "A,B,C,D = map(int, input().split())\nif A+B > C+D:\n print(\"Left\")\nelif A+B == C+D:\n print(\"Balanced\")\nelse:\n print(\"Right\")", "A, B, C, D = map(int, input().split())\n\nL = A + B\nR = C + D\n\nif L > R:\n print(\"Left\")\nelif L == R:\n print(\"Balanced\")\nelse:\n print(\"Right\")", "a,b,c,d=map(int,input().split(\" \"))\nprint(\"Balanced\") if a+b==c+d else print(\"Right\") if a+b<c+d else print(\"Left\")", "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 A, B, C, D = LI()\n\n L = A + B\n R = C + D\n if L == R:\n print('Balanced')\n elif L > R:\n print('Left')\n else:\n print('Right')\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "a, b, c, d=map(int,input().split())\nif a+b<c+d:\n print(\"Right\")\nelif a+b==c+d:\n print(\"Balanced\")\nelse:\n print(\"Left\")", "a,b,c,d=map(int,input().split())\nif (a+b)<(c+d):\n print(\"Right\")\nelif (a+b)>(c+d):\n print(\"Left\")\nelse:\n print(\"Balanced\")", "A,B,C,D =map(int,input().split())\nif A+B == C+D:\n print(\"Balanced\")\nelse:\n print((\"Left\",\"Right\")[A+B <C+D])", "a,b,c,d = list(map(int,input().split()))\n\nif a+b > c+d:\n print('Left')\nelif a+b == c+d:\n print('Balanced')\nelse:\n print('Right')\n", "A,B,C,D = map(int,input().split())\n\nL = A + B\nR = C + D\n\nif L > R:\n print('Left')\n\nelif L == R:\n print('Balanced')\n\nelse:\n print('Right')", "A, B, C, D = map(int, input().split())\nif A+B < C+D:\n print(\"Right\")\nelif A+B > C+D:\n print(\"Left\")\nelse:\n print(\"Balanced\")", "a,b,c,d=map(int,input().split())\nif a+b>c+d:\n print(\"Left\")\nelif a+b<c+d:\n print('Right')\nelse:\n print('Balanced')", "a, b, c, d = list(map(int, input().split()))\nif a + b > c + d:\n print(\"Left\")\nelif a + b == c + d:\n print(\"Balanced\")\nelse:\n print(\"Right\")\n", "a,b,c,d=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nd=int(d)\nif a+b==c+d:\n print(\"Balanced\")\nif a+b>c+d:\n print(\"Left\")\nif a+b<c+d:\n print(\"Right\")", "a,b,c,d = list(map(int,input().split()))\nif a + b > c + d:\n print(\"Left\")\nelif a + b == c + d:\n print(\"Balanced\")\nelse:\n print(\"Right\")\n\n", "a = input().split()\na = [int(j) for j in a]\na.append(a[:2])\na.append(a[2:4])\nif sum(a[4]) > sum(a[5]):\n print(\"Left\")\nif sum(a[4]) == sum(a[5]):\n print(\"Balanced\")\nif sum(a[4]) < sum(a[5]):\n print(\"Right\")", "# \u5165\u529b\nA, B, C, D = map(int,input().split())\n\n# \u51e6\u7406\nif A + B == C + D:\n print('Balanced')\nelif A + B > C + D:\n print('Left')\nelse:\n print('Right')", "a, b, c, d = map(int, input().split())\n\nL = a + b\nR = c + d\n\nif L > R:\n print('Left')\nelif L < R:\n print('Right')\nelse:\n print('Balanced')", "A, B, C, D = map(int, input().split())\n\nL = A + B\nR = C + D\n\nif L > R:\n print('Left')\nelif L < R:\n print('Right')\nelse:\n print('Balanced')", "a,b,c,d = map(int,input().split())\n#lis = list(map(int,input().split()))\nif a+b>c+d:print(\"Left\")\nelif a+b<c+d:print(\"Right\")\nelse:print(\"Balanced\")", "import sys\n\nA, B, C, D = list(map(int, input().split()))\n\nif A+B > C+D:\n print(\"Left\")\nelif A+B == C+D:\n print(\"Balanced\")\nelse:\n print(\"Right\")", "# A,B,C,D\u306e\u304a\u3082\u308a\u306e\u91cd\u3055\u3092\u6574\u6570\u3067\u5165\u529b\nA,B,C,D = map(int,input().split())\nif A + B > C + D:\n# \u5de6\u306e\u76bf\uff08A+B\uff09\u306e\u65b9\u304c\u91cd\u3044\u306a\u3089Left\u3001\u540c\u3058\u306a\u3089Balanced\u3001\u5de6\u306e\u76bf\uff08C+D\uff09\u304c\u91cd\u3044\u306a\u3089Right\u3092\u51fa\u529b\n print(\"Left\")\nelif A + B == C + D:\n print(\"Balanced\")\nelse:\n print(\"Right\")", "a,b,c,d=(int(x) for x in input().split())\ne = int(a) + int(b)\nf = int(c) + int(d)\nif e > f:\n print('Left')\nelif e < f:\n print('Right')\nelse:\n print('Balanced')", "a,b,c,d=map(int,input().split())\n\nprint('Left') if a+b>c+d else print('Right') if a+b<c+d else print('Balanced')", "a,b,c,d=map(int, input().split())\nprint(\"Left\" if c+d<a+b else \"Right\" if c+d>a+b else \"Balanced\")", "a,b,c,d = map(int,input().split())\nprint(\"Left\" if a+b > c+d else \"Right\" if a+b < c+d else \"Balanced\")", "a,b,c,d=map(int,input().split())\nprint(\"Left\" if a+b>c+d else \"Balanced\" if a+b==c+d else \"Right\")", "a,b,c,d = map(int, input().split())\nprint('Left' if (a+b) > (c+d) else 'Balanced' if (a+b) == (c+d) else 'Right')", "a,b,c,d=map(int,input().split())\nif a+b==c+d:\n print(\"Balanced\")\nelif a+b>c+d:\n print(\"Left\")\nelse:\n print(\"Right\")", "# 4\u3064\u306e\u304a\u3082\u308a\u3067\u5929\u79e4\u306e\u91cd\u3055\u6bd4\u3079\n\nA, B, C, D = map(int, input().split())\nL = A + B\nR = C + D\n\nif L > R:\n print('Left')\nelif L == R:\n print('Balanced')\nelse:\n print('Right')", "a, b, c, d = list(map(int, input().split()))\n\nif a + b < c + d:\n print(\"Right\")\nelif c + d < a + b:\n print(\"Left\")\nelse:\n print(\"Balanced\")\n", "A, B, C, D = map(int, input().split())\nAB = A + B\nCD = C + D\n\nif AB > CD:\n print('Left')\nelif AB < CD:\n print('Right')\nelse:\n print('Balanced')", "A, B, C, D = map(int, input().split())\nif A+B == C+D:\n print('Balanced')\nelif A+B > C+D:\n print('Left')\nelse:\n print('Right')", "A, B, C, D = map(int, input().split())\n\nif A + B > C + D:\n print('Left')\nelif A + B == C + D:\n print('Balanced')\nelse:\n print('Right')", "a,b,c,d = map(int,input().split())\nif a+b > c + d:\n print(\"Left\")\nelif a+b == c+d:\n print(\"Balanced\")\nelse:\n print(\"Right\")", "lst = input().split()\n\nd = (int(lst[0]) + int(lst[1])) - (int(lst[2]) + int(lst[3]))\n\nif d == 0:\n print('Balanced')\nelif 0 < d:\n print('Left')\nelse:\n print('Right')", "x,y,z,w =map(int,input().split())\nprint(\"Left\" if x+y>z+w else \"Right\" if x+y<z+w else \"Balanced\")", "a, b, c, d = map(int, input().split())\nl = a + b\nr = c + d\nif l > r:\n print('Left')\nelif l < r:\n print('Right')\nelse:\n print('Balanced')", "import sys\nmapin = lambda: map(int, sys.stdin.readline().split())\nlistin = lambda: list(map(int, sys.stdin.readline().split()))\ninp = lambda: sys.stdin.readline()\nA,B,C,D = mapin()\nl = A + B;r = C + D\nif l < r:print(\"Right\")\nelif l > r:print(\"Left\")\nelse:print(\"Balanced\")", "a,b,c,d = list(map(int, input().split()))\nif sum((a,b)) > sum((c,d)):\n print(\"Left\")\nelif sum((a,b)) < sum((c,d)):\n print(\"Right\")\nelse:\n print(\"Balanced\")", "A, B, C, D = map(int, input().split())\nprint('Right' if C + D > A + B else 'Left' if C + D < A + B else 'Balanced')", "# 083a\n\nA, B, C, D = list(map(int, input().split()))\n\nif A + B == C + D:\n print('Balanced')\nelif A + B > C + D:\n print('Left')\nelse:\n print('Right')\n", "a, b, c, d = map(int, input().split())\nif a + b > c + d:\n print(\"Left\")\nelif a + b < c + d:\n print(\"Right\")\nelif a + b == c + d:\n print(\"Balanced\")", "a, b, c, d = map(int, input().split())\nleft = a + b \nright = c + d\n\nif left > right:\n print('Left')\nelif left == right:\n print('Balanced')\nelse:\n print('Right')", "A, B, C, D = map(int,input().split())\n\nif A + B > C + D:\n print(\"Left\")\nelif A + B < C + D:\n print(\"Right\")\nelse:\n print(\"Balanced\")", "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,C,D,=LI()\n\nif A + B > C + D:\n print(\"Left\")\nelif A + B == C + D:\n print(\"Balanced\")\nelse:\n print(\"Right\")", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\na, b, c, d = list(map(int, input().split()))\n\ne = a+b\nf = c+d\nif e > f:\n print(\"Left\")\nif e == f:\n print(\"Balanced\")\nif e < f:\n print(\"Right\")\n"]
{"inputs": ["3 8 7 1\n", "3 4 5 2\n", "1 7 6 4\n"], "outputs": ["Left\n", "Balanced\n", "Right\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
22,411
82138a598013f3ec29fcdaa8d4a6d606
UNKNOWN
Joisino is planning to open a shop in a shopping street. Each of the five weekdays is divided into two periods, the morning and the evening. For each of those ten periods, a shop must be either open during the whole period, or closed during the whole period. Naturally, a shop must be open during at least one of those periods. There are already N stores in the street, numbered 1 through N. You are given information of the business hours of those shops, F_{i,j,k}. If F_{i,j,k}=1, Shop i is open during Period k on Day j (this notation is explained below); if F_{i,j,k}=0, Shop i is closed during that period. Here, the days of the week are denoted as follows. Monday: Day 1, Tuesday: Day 2, Wednesday: Day 3, Thursday: Day 4, Friday: Day 5. Also, the morning is denoted as Period 1, and the afternoon is denoted as Period 2. Let c_i be the number of periods during which both Shop i and Joisino's shop are open. Then, the profit of Joisino's shop will be P_{1,c_1}+P_{2,c_2}+...+P_{N,c_N}. Find the maximum possible profit of Joisino's shop when she decides whether her shop is open during each period, making sure that it is open during at least one period. -----Constraints----- - 1≀N≀100 - 0≀F_{i,j,k}≀1 - For every integer i such that 1≀i≀N, there exists at least one pair (j,k) such that F_{i,j,k}=1. - -10^7≀P_{i,j}≀10^7 - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N F_{1,1,1} F_{1,1,2} ... F_{1,5,1} F_{1,5,2} : F_{N,1,1} F_{N,1,2} ... F_{N,5,1} F_{N,5,2} P_{1,0} ... P_{1,10} : P_{N,0} ... P_{N,10} -----Output----- Print the maximum possible profit of Joisino's shop. -----Sample Input----- 1 1 1 0 1 0 0 0 1 0 1 3 4 5 6 7 8 9 -2 -3 4 -2 -----Sample Output----- 8 If her shop is open only during the periods when Shop 1 is opened, the profit will be 8, which is the maximum possible profit.
["n=int(input())\nF = [int(input().replace(\" \",\"\"),2) for _ in range(n)]\nP = [list(map(int,input().split())) for _ in range(n)]\n\ntotal = -10**9\nfor i in range(1,2**10):\n pgain = 0\n for f,p in zip(F,P):\n pgain += p[bin(f&i).count(\"1\")]\n if total < pgain:\n total = pgain\n k = i\nprint(total)", "n = int(input())\nf = []\nans = -10**9\n\nfor i in range(n):\n a = input().split()\n f.append(a)\n\np = [list(map(int, input().split())) for i in range(n)]\n\nfor i in range(1, 2**10):\n ref = 0\n i = str(bin(i))[2:].zfill(10)\n for j in range(n):\n cnt = 0\n for k in range(10):\n if i[k] == f[j][k] == \"1\":\n cnt += 1\n ref += p[j][cnt]\n else:\n ans = max(ans, ref)\n\nprint(ans)", "N = int(input())\n\nF = [list(map(int, input().split())) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\n\nans = -float('inf')\nfor i in range(1,1 << 10):\n g = [0] * N\n for j in range(10):\n if i >> j & 1:\n for k in range(N):\n g[k] += F[k][j]\n sub = 0\n for i in range(N):\n sub += P[i][g[i]]\n ans = max(ans, sub)\nprint(ans)", "import numpy as np\nimport heapq as hq\nN = int(input())\nF = np.array([[int(x) for x in input().split()] for _ in range(N)])\nP = np.array([[int(x) for x in input().split()] for _ in range(N)])\n\nProfit = []\nfor i in range(1,2**10): #bit\u5168\u63a2\u7d22\n Open = np.array([int(x) for x in format(i, '010b')]) #2\u9032\u6570\u3092\u30d9\u30af\u30c8\u30eb\u306b\u5909\u63db\n prf = 0\n for f, p in zip(F, P):\n cnt = np.dot(Open, f)\n prf += p[cnt]\n hq.heappush(Profit, -prf)\nprint((-Profit[0]))\n", "N = int(input())\nF = [list(map(int, input().split())) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\n\nans = -10**10\n\nfor a in range(2**10):\n t = [(a>>b)&1 for b in range(10)]\n if 1 not in t:\n continue\n \n p = 0\n for i in range(N):\n p += P[i][sum(t[j] and F[i][j] for j in range(10))]\n\n ans = max(p, ans)\n\nprint(ans)", "n = int(input())\nf = [list(map(int, input().split())) for i in range(n)]\np = [list(map(int, input().split())) for i in range(n)]\nans = -float(\"inf\")\nfor i in range(1, 2**10):\n tf = [False]*10\n for j in range(10):\n if (i>>j)&1:\n tf[j] = True\n cnt1 = 0\n for j in range(n):\n cnt2 = 0\n for k in range(10):\n if tf[k] and f[j][k]:\n cnt2 += 1\n cnt1 += p[j][cnt2]\n ans = max(ans, cnt1)\nprint(ans)", "import sys\nmod=10**9+7 ; inf=float(\"inf\")\nfrom math import sqrt, ceil\nfrom collections import deque, Counter, defaultdict #\u3059\u3079\u3066\u306ekey\u304c\u7528\u610f\u3055\u308c\u3066\u308b defaultdict(int)\u3067\u521d\u671f\u5316\ninput=lambda: sys.stdin.readline().strip()\nsys.setrecursionlimit(11451419)\nfrom decimal import ROUND_HALF_UP,Decimal #\u5909\u63db\u5f8c\u306e\u672b\u5c3e\u6841\u30920\u30840.01\u3067\u6307\u5b9a\n #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))\nfrom functools import lru_cache\nfrom bisect import bisect_left as bileft, bisect_right as biright\n#\u30e1\u30e2\u5316\u518d\u5e30def\u306e\u5192\u982d\u306b\u6bce\u56de @lru_cache(maxsize=10**10)\n#\u5f15\u6570\u306blist\u306f\u3060\u3081\n#######\u3053\u3053\u307e\u3067\u30c6\u30f3\u30d7\u30ec#######\n#\u30bd\u30fc\u30c8\u3001\"a\"+\"b\"\u3001\u518d\u5e30\u306a\u3089Python3\u306e\u65b9\u304c\u3044\u3044\n#######\u3053\u3053\u304b\u3089\u5929\u3077\u3089########\n\nn=int(input());ans=-inf\nF=[] ;P=[]\nfor i in range(n):\n F.append(list(map(int,input().split())))\nfor i in range(n):\n P.append(list(map(int,input().split())))\n\nfor bit in range(1,1<<10):\n L=[(bit>>i)&1 for i in range(10)]\n now=0\n for i in range(n):\n cnt=0\n for cc in range(10):\n if (F[i][cc]==1 and L[cc]==1) : cnt+=1\n now+=P[i][cnt]\n ans=max(ans,now)\nprint(ans)\n", "from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb\nfrom itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement\nfrom collections import deque,defaultdict,Counter\nfrom bisect import bisect_left,bisect_right\nfrom operator import itemgetter\nfrom heapq import heapify,heappop,heappush\nfrom queue import Queue,LifoQueue,PriorityQueue\nfrom copy import deepcopy\nfrom time import time\nfrom functools import reduce\nimport string\nimport sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\n\nn = INT()\nf = []\nfor i in range(n):\n f.append(LIST())\np = []\nfor i in range(n):\n p.append(LIST())\n\nans = -inf\nfor x in product([0, 1], repeat=10):\n if sum(x) != 0:\n tmp = 0\n for j in range(n):\n count = 0\n for k in range(10):\n count += f[j][k]*x[k]\n tmp += p[j][count]\n ans = max(ans, tmp)\nprint(ans)", "def dfs(s,N):\n if len(s)==10:\n if \"1\" in s:\n cal(s,N)\n return\n dfs(s+\"0\",N)\n dfs(s+\"1\",N)\n\ndef cal(s,N):\n p = 0\n for i in range(N):\n c=0\n for j in range(10):\n c+=F[i][j]*int(s[j])\n p+=P[i][c]\n profit.append(p)\n return\n\nN = int(input())\nF=[list(map(int,input().split())) for _ in range(N)]\nP=[list(map(int,input().split())) for _ in range(N)]\nprofit=[]\n\ndfs(\"\",N)\nprint(max(profit))", "n = int(input())\n\nL,score = [],[]\nfor i in range(n):\n L.append(list(map(int,input().split())))\n \nfor i in range(n):\n score.append(list(map(int,input().split())))\n\nans = -10**32\n \nfor k in range(1,1<<10):\n sc = 0\n \n for i in range(n):\n cnt = 0\n for j in range(10):\n if L[i][j] and k>>j&1:\n cnt +=1\n #print(L[i],v,cnt,i,score,score[i][cnt])\n sc += score[i][cnt]\n #print(L[i],v,cnt,i,score,score[i][cnt])\n ans = max(ans,sc)\n\nprint(ans)", "#coding: utf-8\nfrom collections import deque\n\nN = int(input())\nF = []\nfor i in range(N):\n F.append([int(x) for x in input().split()])\n\nP = []\nfor i in range(N):\n P.append([int(x) for x in input().split()])\n\nret = None\nfor bit in range(1, 2**10):\n nWork = [0] * N\n for i in range(10):\n if (bit >> i) & 1:\n for shop in range(N):\n if F[shop][i] == 1:\n nWork[shop] += 1\n\n cand = 0\n for i in range(N):\n cand += P[i][nWork[i]]\n if ret == None or cand > ret:\n ret = cand\nprint(ret)\n\n", "N=int(input())\nF=[list(map(int,input().split()))for _ in range(N)]\nP=[list(map(int,input().split()))for _ in range(N)]\n\nans=-10**9\nfor i in range(2**10-1):\n Bit=[1]*10\n for j in range(10):\n if (i>>j)&1:\n Bit[j]=0\n count=0\n for k in range(N):\n op=sum(b&f for b,f in zip(Bit,F[k]))\n count+=P[k][op]\n ans=max(ans,count)\nprint(ans)", "n=int(input())\nf=[list(map(int, input().split())) for _ in range(n)]\np=[list(map(int, input().split())) for _ in range(n)]\n\nfrom itertools import product\nbits_l=list(product([0,1], repeat=10))\nbits_l.remove((0,0,0,0,0,0,0,0,0,0))\n\nans=-float(\"inf\")\nfor bits in bits_l:\n tmp_ans=0\n for shop in range(n):\n tmp_cnt=0\n for i, bit in enumerate(bits):\n if bit==1 and f[shop][i]==1:\n tmp_cnt+=1\n tmp_ans+=p[shop][tmp_cnt]\n ans=max(ans, tmp_ans)\n\nprint(ans)", "n = int(input())\nF = [int(\"\".join(input().split()), 2) for _ in range(n)]\nP = [list(map(int, input().split())) for _ in range(n)]\nnum = 1 << 10\nans = -(10 ** 10)\n\n\ndef popcnt(n):\n c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)\n c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)\n c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F)\n c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF)\n c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF)\n c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF)\n return c\n\n\n# print(F)\n\nfor i in range(1, num):\n temp = 0\n for j in range(n):\n temp += P[j][popcnt(i & F[j])]\n ans = max(temp, ans)\nprint(ans)\n", "n=int(input())\nf=[]\nfor i in range(n):\n fn=[int(x) for x in input().rstrip().split()]\n f.append(fn)\n\np=[]\nfor i in range(n):\n pn=[int(x) for x in input().rstrip().split()]\n p.append(pn)\n\nans=-float('inf')\nfor i in range(1,2**10):\n now=0\n for s in range(n):\n cnt=0\n for j in range(10):\n if ((i>>j) & 1) and f[s][j]==1:\n cnt+=1\n now+=p[s][cnt]\n ans=max(ans,now)\nprint(ans)", "n = int(input())\nf = [list(map(int, input().split())) for i in range(n)]\np = [list(map(int, input().split())) for i in range(n)]\nans = -(1 << 30)\nfor bit in range(1, 1 << 10):\n cnt = 0\n for i in range(n):\n cnt2 = 0\n for j in range(10):\n if (bit >> j & 1) and f[i][j]:\n cnt2 += 1\n cnt += p[i][cnt2]\n if ans < cnt:\n ans = cnt\nprint(ans)", "N = int(input())\nF = [list(map(int, input().split())) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\nans = -9999999999\nfor i in range(1, 2 ** 10):\n s = 0\n for j in range(N):\n cnt = 0\n for k in range(10):\n if i >> k & 1 and F[j][k] == 1:\n cnt += 1\n s += P[j][cnt]\n ans = max(ans, s)\nprint(ans)", "import sys, math\nfrom functools import lru_cache\nfrom collections import defaultdict\nfrom decimal import Decimal\nsys.setrecursionlimit(10**9)\nMOD = 10**9+7\n\ndef input():\n return sys.stdin.readline()[:-1]\n\ndef mi():\n return list(map(int, input().split()))\n\ndef ii():\n return int(input())\n\ndef i2(n):\n tmp = [list(mi()) for i in range(n)]\n return [list(i) for i in zip(*tmp)]\n\ndef main():\n N = ii()\n F = [list(mi()) for i in range(N)]\n P = [list(mi()) for i in range(N)]\n\n m = -math.inf\n\n for ptn in range(1, 2**10):\n r = 0\n for i in range(N):\n cnt = 0\n for j in range(10):\n if F[i][j] and (ptn>>j)&1:\n cnt += 1\n r += P[i][cnt]\n m = max(m, r)\n\n print(m)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nF = [list(map(int,input().split())) for i in range(N)]\nP = [list(map(int,input().split())) for i in range(N)]\n \nans = -10**9\nfor i in range(2**10-1):\n Bit = [1]*10\n for j in range(10):\n if (i>>j)&1:\n Bit[j]=0\n count = 0\n for k in range(N):\n op = sum(b&f for b,f in zip(Bit,F[k]))\n count+=P[k][op]\n ans = max(ans,count)\nprint(ans)", "import itertools\nN = int(input())\nF =[ list(input().split()) for i in range(N)]\nP =[ list(input().split()) for i in range(N)]\nset01 = list(itertools.product('01',repeat = 10))\ncounter = []\nans = -10**9\nfor s01 in set01:\n if s01 != (\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\",\"0\"):\n prof = 0\n for i in range(N):\n counter = 0\n for j in range(10):\n if s01[j] ==\"1\" and F[i][j] == \"1\":\n counter += 1\n prof += int(P[i][counter])\n ans = max(ans,prof)\nprint(ans)", "def solve():\n import numpy as np\n n = int(input())\n oc = [[] for _ in range(n)]\n prof = [[] for _ in range(n)]\n\n for i in range(n):\n oc[i] = list(map(int, input().split()))\n for i in range(n):\n prof[i] = list(map(int, input().split()))\n\n oc = np.array(oc)\n prof = np.array(prof)\n\n ans = -9999999999\n\n for a in range(1, 1 << 10):\n res = np.zeros(n, dtype=np.int64)\n for b in range(10):\n if a >> b & 1:\n res += oc[:, b]\n #print(res)\n tmp = 0\n for i, x in enumerate(res):\n tmp += prof[i, x]\n #print(tmp)\n ans = max(ans, tmp)\n print(ans)\n\n\nsolve()\n", "n = int(input())\narr = [list(map(int, input().split())) for i in range(n)]\narm = [list(map(int, input().split())) for j in range(n)]\n\nans = -9999999999\nfor item in range(1, 1024):\n fund = 0\n for i in range(n):\n cou = 0\n for x in range(10):\n if (item >> x) % 2 == 1 and arr[i][x] == 1:\n cou += 1\n fund += arm[i][cou]\n ans = max(ans, fund)\n\nprint(ans)", "import numpy as np\nN = int(input())\nschedules = [list(map(int, input().split())) for _ in range(N)]\nprices = [list(map(int, input().split())) for _ in range(N)]\n# print(schedules)\n# print(prices)\nans = -1 * float('inf')\nfor i in range(1, 1 << 10):\n my_schedule = list(map(int, bin(i)[2:].zfill(10)))\n score = 0\n for j, schedule in enumerate(schedules):\n count = 0\n for k in range(10):\n if my_schedule[k] == schedule[k] and schedule[k] == 1:\n count += 1\n score += prices[j][count]\n ans = max(ans, score)\nprint(ans)\n", "def solve():\n import numpy as np\n n = int(input())\n oc = [list(map(int, input().split())) for _ in range(n)]\n prof = [list(map(int, input().split())) for _ in range(n)]\n\n oc = np.array(oc)\n prof = np.array(prof)\n\n inf = 10 ** 10\n ans = - inf\n\n for a in range(1, 1 << 10):\n res = np.zeros(n, dtype=np.int64)\n for b in range(10):\n if a >> b & 1:\n res += oc[:, b]\n tmp = 0\n for i, x in enumerate(res):\n tmp += prof[i, x]\n ans = max(ans, tmp)\n print(ans)\n\n\nsolve()\n\n", "N = int(input())\nF = [list(map(int, input().split())) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\n\nres = - 10 ** 18\nfor i in range(1, 2 ** 10):\n tmp = [0] * N\n for j in range(10):\n if i >> j & 1:\n for k in range(N):\n tmp[k] += F[k][j]\n res_tmp = 0\n for j in range(N):\n res_tmp += P[j][tmp[j]]\n res = max(res, res_tmp)\n\nprint(res)\n", "n = int(input())\n\nf = []\nfor i in range(n):\n f.append(list(map(int, input().split())))\np = []\nfor i in range(n):\n p.append(list(map(int, input().split())))\n\nans = -10**18\nfor ci in range(1, 2**10):\n score = 0\n for cn in range(n):\n cnt = 0\n for cj in range(10):\n x = ci >> cj & 1\n if x and f[cn][cj]:\n cnt += 1\n score += p[cn][cnt]\n ans = max(ans, score)\nprint(ans)\n", "import sys\nfrom itertools import product\n\ninput = sys.stdin.readline\n\n\ndef main():\n N = int(input())\n F = [None] * N\n for i in range(N):\n F[i] = tuple(map(int, input().split()))\n P = [None] * N\n for i in range(N):\n P[i] = tuple(map(int, input().split()))\n\n ans = -float(\"inf\")\n for comb in product(list(range(2)), repeat=10):\n if sum(comb) == 0:\n continue\n c = [0] * N\n for j, is_open in enumerate(comb):\n if is_open:\n for i in range(N):\n c[i] += F[i][j]\n profit = sum(P[i][c[i]] for i in range(N))\n ans = max(ans, profit)\n\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nF = [list(map(int, input().split())) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\n\n# bit\u5168\u63a2\u7d22\ninf = float(\"inf\")\nans = -inf\nfor i in range(1, 2**10):\n op = []\n for j in range(10):\n if (i >> j) & 1:\n op.append(1)\n else:\n op.append(0)\n\n res = 0\n for k in range(N):\n temp = 0\n for l in range(10):\n if op[l] == 1 and F[k][l] == 1:\n temp += 1\n res += P[k][temp]\n ans = max(ans, res)\n\nprint(ans)", "N = int(input())\nF = [list(map(int,input().split())) for i in range(N)]\nP = [list(map(int,input().split())) for i in range(N)]\nans = - 10**9\nfor i in range(1,2**10):\n s = i\n b = [0]*10\n for j in range(10):\n if s >= (2**(10-j-1)):\n s -= 2**(10-j-1)\n b[j] = 1\n a = 0\n for j in range(N):\n c = 0\n for k in range(10):\n if b[k] == 1 and F[j][k] == 1:\n c += 1\n a += P[j][c]\n ans = max(ans,a)\nprint(ans)", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[2]:\n\n\nimport itertools\n\n\n# In[47]:\n\n\nN = int(input())\nF = []\nfor _ in range(N):\n F.append(list(map(int, input().split())))\nP = []\nfor _ in range(N):\n P.append(list(map(int, input().split())))\n\n\n# In[48]:\n\n\nans = sum([min(a) for a in P])\nfor b in range(1,1024):\n b = list(map(int, format(b,\"010b\")))\n tmp = 0\n for i in range(N):\n cnt = 0\n for j,x in enumerate(b):\n cnt += F[i][j]*x\n tmp += P[i][cnt]\n ans = max(ans, tmp)\nprint(ans)\n\n\n# In[ ]:\n\n\n\n\n", "from itertools import product\nn=int(input())\nfs=[list(map(int,input().split())) for _ in range(n)]\nps=[list(map(int,input().split())) for _ in range(n)]\nans=-float('inf')\nfor b in product((0,1),repeat=10):\n if sum(b)==0:\n continue\n v=0\n for f,p in zip(fs,ps):\n cnt=sum([a&b for a,b in zip(b,f)])\n v+=p[cnt]\n ans=max(ans,v)\nprint(ans)\n", "N = int(input())\narr = [list(map(int,input().split())) for i in range(N)]\narm = [list(map(int,input().split())) for j in range(N)]\n\nans = -9999999999\nfor item in range(1,2**10):#joisino\u304a\u59c9\u3061\u3083\u3093\u304c\u55b6\u696d\u3059\u308b\u3057\u306a\u3044\u306e\u7d44\u307f\u5408\u308f\u305b1024\u901a\u308a\n fund = 0\n for i in range(N):#\u5e97\u306e\u6570\n cou = 0\n for x in range(10):#\u55b6\u696d\u30bf\u30a4\u30df\u30f3\u30b0\uff08\u6708~\u91d1\u305d\u308c\u305e\u308c\u5348\u524d\u3001\u5348\u5f8c\uff09\n if (item >> x) % 2 == 1 and arr[i][x] == 1:#joisino\u59c9\u306e\u958b\u5e97\u3068\u5e97i\u306e\u958b\u5e97\u304c\u4e00\u81f4\n cou += 1\n fund += arm[i][cou]\n ans = max(ans, fund)\n\nprint(ans)", "N=int(input())\nF=[list(map(int,input().split())) for _ in range(N)]\nP=[list(map(int,input().split())) for _ in range(N)]\nans=-1000000000\nfor i in range(1,1<<10):\n cnt=[0 for _ in range(N)]\n for j in range(10):\n if (i>>j)%2==1:\n for k in range(N):\n cnt[k]+=F[k][j]\n A=[P[j][cnt[j]] for j in range(N)]\n ans=max(ans,sum(A))\nprint(ans)\n", "from itertools import product\nn = int(input())\nf = []\nfor i in range(n):\n f.append(list(map(int, input().split())))\np = []\nfor _ in range(n):\n p.append(list(map(int, input().split())))\n\nschejule_list = set(product([0, 1], repeat=10))\nans = - float(\"inf\")\nfor schedule in schejule_list:\n if schedule == (0, 0, 0, 0, 0, 0, 0, 0, 0, 0):\n continue\n res = 0\n for i in range(n):\n kaburi = 0\n for j in range(10):\n kaburi += f[i][j] * schedule[j]\n res += p[i][kaburi]\n ans = max(ans, res)\nprint(ans)\n\n\n", "n = int(input())\nl = []\nm = []\nans = -10**9\n\nfor i in range(n):\n f = \"\".join(input().split())\n f = int(f, 2)\n l.append(f)\n\nfor i in range(n):\n p = list(map(int, input().split()))\n m.append(p)\n\nfor i in range(1, 2**10):\n ref = 0\n for j in range(n):\n cnt = bin(i & l[j]).count(\"1\")\n ref += m[j][cnt]\n else:\n ans = max(ans, ref)\n\nprint(ans)", "import numpy as np\nN = int(input())\nF = np.array([list(map(int, input().split())) for i in range(N)])\nP = np.array([list(map(int, input().split())) for i in range(N)])\nans = -10**18\nfor i in range(2**10):\n box = []\n for k in range(10):\n if ((i>>k)&1):\n box = [1]+ box\n else:\n box = [0]+ box\n if all(i == 0 for i in box):\n continue\n # box \u306f\u958b\u696d\u3059\u308b0~9\u306e\u5019\u88dc\u30ea\u30b9\u30c8\n # G \u306f F(0\u304b1\u306e\u5404\u5e97\u958b\u696d\u72b6\u6cc1)\n G = np.sum(F*box, axis=1)\n a = 0\n for x,y in zip(G,P):\n a += y[x]\n ans = max(ans, a)\n \nprint(ans)", "import sys\nfrom itertools import product\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 F = [list(map(int, input().split())) for _ in range(n)]\n P = [list(map(int, input().split())) for _ in range(n)]\n\n res = -f_inf\n for pattern in product([0, 1], repeat=10):\n if sum(pattern) == 0:\n continue\n tmp = 0\n for i in range(n):\n cnt = 0\n for p, f in zip(pattern, F[i]):\n if p == 1 and f == 1:\n cnt += 1\n tmp += P[i][cnt]\n res = max(res, tmp)\n print(res)\n\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "def pad_zero(s, n):\n\ts = str(s)\n\treturn (\"0\" * n + s)[-n:]\n\ndef main():\n\tN = int(input())\n\tF = [[int(f) for f in input().split(\" \")] for i in range(N)]\n\tP = [[int(p) for p in input().split(\" \")] for i in range(N)]\n\n\ttotal_profit = []\n\tfor b in range(1, 2 ** 10):\n\t\tsale_bit = list(pad_zero(format(b, 'b'), 10))\n\t\tprofit = 0\n\t\tfor i in range(len(F)):\n\t\t\tf = F[i]\n\t\t\tp = P[i]\n\t\t\tprofit += p[sum([fjk * int(s) for (fjk, s) in zip(f, sale_bit)])]\n\t\ttotal_profit.append(profit)\n\tprint(max(total_profit))\n\n\nmain()", "import itertools\nN=int(input())\nF=[list(map(int,input().split())) for _ in range(N)]\nP=[list(map(int,input().split())) for _ in range(N)]\nans=-10**9\nfor i in list(itertools.product(range(2),repeat=10)):\n if sum(i)==0:\n continue\n bns=0\n for j in range(N):\n b=0\n for k in range(10):\n if i[k]*F[j][k]==1:\n b+=1\n bns+=P[j][b]\n ans=max(ans,bns)\nprint(ans)", "from itertools import product\ndef main():\n N = int(input())\n F = []\n for _ in range(N):\n f = list(map(int, input().split()))\n F.append(f)\n P = []\n for _ in range(N):\n p = list(map(int, input().split()))\n P.append(p)\n m = -10**21\n for i in product(list(range(2)), repeat=10):\n if sum(i) == 0:\n continue\n r = 0\n for j in range(N):\n r += P[j][sum(ii&jj for ii, jj in zip(i, F[j]))]\n m = max(r, m)\n return m\nprint((main()))\n", "n = int(input())\nfl = [list(map(int, input().split())) for _ in range(n)]\npl = [list(map(int, input().split())) for _ in range(n)]\n\nans = -1001001001\nfor i in range(1, 2**10):\n profit = 0\n cnt = [0]*n\n for j in range(10):\n if (i >> j) & 1 == 1:\n for k in range(n):\n if fl[k][j] == 1:\n cnt[k] += 1\n for k in range(n):\n profit += pl[k][cnt[k]]\n ans = max(ans, profit)\n\nprint(ans)\n", "#coding: utf-8\nfrom itertools import product\n\nN = int(input())\nF = [[int(x) for x in input().split()] for _ in range(N)]\nP = [[int(x) for x in input().split()] for _ in range(N)]\n\nret = -10 ** 18\n\n# skip (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)\nitr = product([0, 1], repeat=10)\nitr.__next__()\nfor bit in itr:\n cand = sum((P[i][sum((f*b for f, b in zip(F[i], bit)))] for i in range(N)))\n ret = max(ret, cand)\n\nprint(ret)\n", "from itertools import combinations\n\nn = int(input())\nf = [list(map(int, input().split())) for _ in range(n)]\np = [list(map(int, input().split())) for _ in range(n)]\n\nans = - 10 ** 18\nfor i in range(1, 11):\n for pat in combinations(list(range(10)), i):\n cnt = [0] * n\n for e in pat:\n for j in range(n):\n cnt[j] += f[j][e]\n\n score = 0\n for i, e in enumerate(cnt):\n score += p[i][e]\n\n ans = max(ans, score)\n\nprint(ans)\n", "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n N = int(input())\n F = []\n for _ in range(N):\n F.append(list(map(int, input().split())))\n P = []\n for _ in range(N):\n P.append(list(map(int, input().split())))\n\n # A: choosen list\n A = list(range(10))\n n = len(A)\n ans = -float('inf')\n for i in range(2 ** n):\n select = []\n score = 0\n for j in range(n):\n if (i >> j) & 1:\n select.append(A[j])\n if len(select) == 0:\n continue\n \n for j in range(N):\n cnt = 0\n for k in select:\n if F[j][k] == 1:\n cnt += 1\n score += P[j][cnt]\n \n ans = max(ans, score)\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "import sys\nfrom heapq import heappush, heappop\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 n = ii()\n F = []\n P = []\n for _ in range(n):\n F.append(li())\n for _ in range(n):\n P.append(li())\n \n inf = 10 ** 18\n ans = -inf\n for i in range(1, 1<<10):\n c = [0]*(n)\n tmp = 0\n for j in range(10):\n if (i>>j)&1:\n for k in range(n):\n c[k] += F[k][j]\n for k in range(n):\n tmp += P[k][c[k]]\n ans = max(ans, tmp)\n print(ans)\n \n \n \n \n\n\n\n\ndef __starting_point():\n main()\n__starting_point()", "#!/usr/bin/env python3\nimport numpy as np\nfrom itertools import product\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\n\ndata = np.zeros((10, n), dtype=int)\nfor i in range(n):\n f = np.array(list(map(int, input().split())))\n data[:, i] = f\n\n# print(data)\n\np = [list(map(int, input().split())) for i in range(n)]\n# print(p)\n\nans = -10**10\n\nfor j, i in enumerate(product([0, 1], repeat=10)):\n if j == 0:\n continue\n\n indices = [x for x, y in enumerate(i) if y == 1]\n # print(indices)\n\n data_tmp = data[indices]\n data_tmp = np.sum(data_tmp, axis=0)\n ans_tmp = sum([p[a][b] for a, b in enumerate(data_tmp)])\n ans = max(ans, ans_tmp)\nprint(ans)\n", "from itertools import product\n\nN=int(input())\nF=[list(map(int,input().split())) for _ in range(N)]\nP=[list(map(int,input().split())) for _ in range(N)]\n\nMAX=-10**12\nfor p in product(range(2),repeat=10):\n if p==(0,)*10:continue\n SUM=0\n for i in range(N):\n count=0\n for j in range(10):\n if p[j]==1 and F[i][j]==1:\n count+=1\n SUM += P[i][count]\n MAX = max(MAX,SUM)\nprint(MAX)", "N = int(input())\nF = [0] * N\nfor i in range(N):\n F[i] = list(map(int, input().split()))\n\nP = [0] * N\nfor i in range(N):\n P[i] = list(map(int, input().split()))\n\nans = -float(\"inf\")\n\nfor j in range(1, 1024):\n ss = 0\n for i in range(N):\n b = format(j, \"010b\")\n bb = [0] * 10\n for k in range(10):\n bb[k] = F[i][k] * int(b[k])\n ss += P[i][sum(bb)]\n ans = max(ans, ss)\n\nprint(ans)", "def solve():\n n = int(input())\n oc = [list(map(int, input().split())) for _ in range(n)]\n prof = [list(map(int, input().split())) for _ in range(n)]\n\n ans = -9999999999\n\n for a in range(1, 1 << 10):\n res = 0\n for i in range(n):\n cnt = 0\n for x in range(10):\n if (a >> x) % 2 == 1 and oc[i][x] == 1:\n cnt += 1\n res += prof[i][cnt]\n ans = max(ans, res)\n print(ans)\n\n\nsolve()\n", "import numpy as np\n \nN = int(input())\nF = np.array([list(map(int, input().split(' '))) for _ in range(N)])\nP = np.array([list(map(int, input().split(' '))) for _ in range(N)])\n \nans = - (10 ** 11)\n \nfor n in range(1, 1024):\n bits = np.array(list(map(int, list('{:010b}'.format(n)))))\n dup = np.sum(F * bits, axis=1)\n ans = max(ans, np.sum(P[range(N), dup]))\n\nprint(ans)", "n = int(input())\nf = [list(map(int,input().split())) for _ in range(n)]\np = [list(map(int,input().split())) for _ in range(n)]\n\nli = []\n\nfor i in range(2**10):\n if i == 0:\n continue\n ans = 0\n co = [0]*n\n for j in range(10):\n if (i>>j &1)==1:\n for k in range(n):\n if f[k][j]==1:\n co[k] +=1\n #print(i,bin(i),co)\n for l in range(n):\n ans += p[l][co[l]]\n li += [ans]\nprint(max(li))", "N = int(input())\nF = [ list(map(int, input().split())) for _ in range(N)]\nP = [ list(map(int, input().split())) for _ in range(N)]\n\nres = -(1<<30)\n\nfor b in range(1,1<<10):\n cc = 0\n for i in range(N):\n c = 0\n for j in range(10):\n if (b>>j&1) & F[i][j]:\n c+=1\n cc += P[i][c]\n if res<cc:\n res = cc\n \nprint(res)\n", "import numpy as np\nimport heapq as hq\nN = int(input())\nF = np.array([[int(x) for x in input().split()] for _ in range(N)])\nP = np.array([[int(x) for x in input().split()] for _ in range(N)])\n\nProfit = []\nfor i in range(1,2**10):\n Open = np.array([int(x) for x in format(i, '010b')])\n prf = 0\n for f, p in zip(F, P):\n cnt = np.dot(Open, f)\n prf += p[cnt]\n hq.heappush(Profit, -prf)\nprint((-Profit[0]))\n", "from itertools import product\nn = int(input())\nf = []\nfor i in range(n):\n f.append(list(map(int, input().split())))\np = []\nfor _ in range(n):\n p.append(list(map(int, input().split())))\n\nschejule_list = list(product([0, 1], repeat=10))\nans = - float(\"inf\")\nfor schedule in schejule_list:\n if schedule == (0,0,0,0,0,0,0,0,0,0):\n continue\n res = 0\n for i in range(n):\n kaburi = 0\n for j in range(10):\n kaburi += f[i][j] * schedule[j]\n res += p[i][kaburi]\n ans = max(ans, res)\nprint(ans)\n\n\n", "import numpy as np\n\ndef main():\n with open(0) as f:\n N = int(f.readline())\n F = np.array([list(map(int, f.readline().split())) for _ in range(N)])\n P = [list(map(int, f.readline().split())) for _ in range(N)]\n\n max_profit = -np.inf\n for i in range(1,2**10):\n Open = np.array([(i>>j)&1 for j in range(10)])\n conflict = np.dot(F, Open.T)\n profit = sum(P[i][v] for i,v in enumerate(conflict))\n max_profit = max(max_profit, profit)\n print(max_profit)\n\nmain()", "N = int(input())\nF = []\nfor i in range(N):\n A = list(map(int, input().split()))\n F.append(A[::-1])\n\nP = []\nfor i in range(N):\n A = list(map(int, input().split()))\n P.append(A)\n\nresult = float(\"inf\")*(-1)\nfor i in range(1, 2**10):\n ans = 0\n for l in range(N):\n c = 0\n for j in range(10):\n if ((i>>j) & 1):\n if F[l][j] == 1:\n c += 1\n ans += P[l][c]\n result = max(ans, result)\nprint(result)\n", "n = int(input())\ndata1 = [list(map(int,input().split())) for _ in range(n)]\ndata2 = [list(map(int,input().split())) for _ in range(n)]\nans = []\ntrans = -1\nfor i in range(2**10):\n S = [0]*n\n l = 0\n for j in range(10):\n for k in range(n):\n S[k] += data1[k][j]*((i>>j)&1)\n for j in range(n):\n l += data2[j][S[j]]\n ans.append(l)\n if not i:\n trans = l\nans.sort()\nprint(ans[-1] if ans[-1] != trans else ans[-2])", "N = int(input())\nF, P = [], []\nfor i in range(N):\n F.append(list(map(int, input().split())))\nfor i in range(N):\n P.append(list(map(int, input().split())))\n \nans = -(10**9)\nfor i in range(1, 2**10):\n l = [0] * N\n for j in range(10):\n if (i>>j) & 1:\n for k in range(N):\n if F[k][j] == 1:\n l[k] += 1\n tmp = 0\n for m in range(N):\n n = l[m]\n tmp += P[m][n]\n ans = max(tmp, ans)\nprint(ans)", "# \u30d3\u30c3\u30c8\u5168\u63a2\u7d22\nfrom itertools import product\n\nN = int(input())\nF = [list(map(int, input().split())) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\n\nresult = -float('inf')\nfor i in product([True, False], repeat=10):\n if i.count(False) == 10:\n continue\n t = 0\n for j in range(N):\n t += P[j][sum(1 & F[j][k] for k in range(10) if i[k])]\n result = max(result, t)\nprint(result)\n", "n = int(input())\n\nF = []\nP = []\nfor i in range(n):\n F.append(list(map(int, input().split())))\nfor i in range(n):\n P.append(list(map(int, input().split())))\nans = -10**9\nfor i in range(1, 1 << (10)):\n C = [0]*n\n for j in range(10):\n if i & 2**j:\n for k in range(n):\n if F[k][j]:\n C[k] += 1\n current = 0\n for k in range(n):\n current += P[k][C[k]]\n ans = max(current, ans)\nprint (ans)", "n=int(input())\nf=[list(map(int,input().split())) for i in range(n)]\np=[list(map(int,input().split())) for i in range(n)]\nans=-(10**10)\nfor i in range(1,1024):\n bit=bin(i)[2:].zfill(10)\n a=0\n for j in range(n):\n b=0\n for k in range(10):\n if int(bit[k]) and f[j][k]:\n b+=1\n a+=p[j][b]\n ans=max(ans,a)\nprint(ans)", "n=int(input())\nf=[list(map(int,input().split())) for _ in range(n)]\np=[list(map(int,input().split())) for _ in range(n)]\nmaxp=-float(\"inf\")\nfor i in range(1,2**10):\n pt=0\n for j in range(n):\n cnt=0\n for k in range(10):\n if (i>>k)&1 and f[j][k]==1:\n cnt+=1\n pt+=p[j][cnt]\n maxp=max(maxp,pt)\nprint(maxp)", "n = int(input())\nF = [0]*n\nP = [0]*n\nfor i in range(n):\n F[i] = list(map(int,input().split()))\nfor i in range(n):\n P[i] = list(map(int,input().split()))\n \nans = -float(\"Inf\")\nfor i in range(1,2**10):\n L = []\n b = 0\n for j in range(10):\n if (i>>j)&1:\n L.append(j)\n for j in range(n):\n c = 0\n for x in L:\n if F[j][x] == 1:\n c += 1\n b += P[j][c]\n \n ans = max(ans, b)\n \n \nprint(ans)", "n = int(input())\nf = []\nans = -10**9\n\nfor i in range(n):\n a = \"\".join(input().split())\n a = int(a, 2)\n f.append(a)\n\np = [list(map(int, input().split())) for i in range(n)]\n\nfor i in range(1, 2**10):\n ref = 0\n for j in range(n):\n cnt = bin(i&f[j]).count(\"1\")\n ref += p[j][cnt]\n else:\n ans = max(ans, ref)\n\nprint(ans)", "from itertools import product\nN = int(input())\nlsF = [[]]\nfor i in range(N):\n lsF.append(list(map(int,input().split())))\nlsP = [[]]\nfor i in range(N):\n lsP.append(list(map(int,input().split())))\nbita = list(product(range(2),repeat=10))\nbita.pop(0)\nans = -10**10\nfor bit in bita:\n count = [0 for i in range(N+1)]\n for i in range(10):\n for j in range(1,N+1):\n count[j] += bit[i]*lsF[j][i]\n benifit = 0\n for i in range(1,N+1):\n benifit += lsP[i][count[i]]\n ans = max(ans,benifit)\nprint(ans)", "A=int(input())\nshop_l=[list(map(int,input().split())) for i in range(A)]\nshop_count_l=[list(map(int,input().split())) for i in range(A)]\nans=-1*10**10\nfor i in range(1,1024):\n tmp=0\n l=[0]*A\n for j in range(10):\n if (i>>j)&1:\n for k in range(A):\n if shop_l[k][j] == 1:\n l[k]+=1\n for i in range(A):\n tmp+=shop_count_l[i][l[i]]\n ans=max(ans,tmp)\nprint(ans)", "def solve():\n n = int(input())\n oc = [list(map(int, input().split())) for _ in range(n)]\n prof = [list(map(int, input().split())) for _ in range(n)]\n\n inf = 10 ** 16\n ans = - inf\n\n for a in range(1, 1 << 10):\n res = 0\n for i in range(n):\n cnt = 0\n for x in range(10):\n if a >> x & 1 and oc[i][x] == 1:\n cnt += 1\n res += prof[i][cnt]\n ans = max(ans, res)\n print(ans)\n\n\nsolve()\n", "import sys\nn = int(input())\nF = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]\nP = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]\nans = -pow(10,9)-7\nfor i in range(1,pow(2,10)):\n b = bin(i)[2:].zfill(10)\n t = 0\n for j in range(n):\n c = 0\n for k in range(10):\n if int(b[k]) and F[j][k]:\n c += 1\n t += P[j][c]\n ans = max(ans, t)\nprint(ans)", "n = int(input())\nf = []\nfor i in range(n):\n line = list(map(int, input().split()))\n f.append(line)\n\np = []\nfor i in range(n):\n line = [int(j) for j in input().split()]\n p.append(line)\n\nres = - 10 ** 11\nfor i in range(1, 1 << 10):\n tmp_res = 0\n for j in range(n):\n counter = 0\n for k in range(10):\n if i >> k & f[j][k]:\n counter += 1\n tmp_res += p[j][counter]\n res = max(res, tmp_res)\n\nprint(res)\n", "import itertools\nn=int(input())\nf=[list(map(int,input().split())) for _ in range(n)]\np=[list(map(int,input().split())) for _ in range(n)]\nans=-(10**12)\nfor i in range(1,11):\n num=list(itertools.combinations(list(range(10)),i))\n for j in range(len(num)):\n cnt=[0]*n\n cnt2=0\n for k in range(i):\n for l in range(n):\n if f[l][num[j][k]]==1:\n cnt[l]+=1\n for k in range(n):\n cnt2+=p[k][cnt[k]]\n ans=max(cnt2,ans)\nprint(ans)\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 N = I()\n F = [LI() for _ in range(N)]\n P = [LI() for _ in range(N)]\n\n ans = -INF\n for i in range(1, 2 ** 10):\n tmp = 0\n for j in range(N):\n cnt = 0\n for k in range(10):\n if i >> k & 1:\n cnt += F[j][k]\n tmp += P[j][cnt]\n ans = max(tmp, ans)\n\n print(ans)\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "n = int(input())\nf = []\nans = -10**9\n\nfor i in range(n):\n a = \"\".join(input().split())\n a = int(a, 2)\n f.append(a)\n\np = [list(map(int, input().split())) for i in range(n)]\n\nfor i in range(1, 2**10):\n ref = 0\n for j in range(n):\n cnt = bin(i & f[j]).count(\"1\")\n ref += p[j][cnt]\n else:\n ans = max(ans, ref)\n\nprint(ans)", "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 = int(readline())\n F = [list(map(int, readline().split())) for _ in range(N)]\n P = [list(map(int, readline().split())) for _ in range(N)]\n\n ans = -INF\n for bits in range(1, 1 << 10):\n res = 0\n for i in range(N):\n c = 0\n for j in range(10):\n if F[i][j] and (bits & (1 << j)):\n c += 1\n res += P[i][c]\n if ans < res:\n ans = res\n\n print(ans)\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nF = [0]*n\nP = [0]*n\nfor i in range(n):\n F[i] = list(map(int,input().split()))\nfor i in range(n):\n P[i] = list(map(int,input().split()))\n\nans = -float(\"Inf\")\nfor i in range(1,2**10):\n L = []\n b = 0\n for j in range(10):\n if (i>>j)&1:\n L.append(j)\n for j in range(n):\n c = 0\n for x in L:\n if F[j][x] == 1:\n c += 1\n b += P[j][c]\n \n ans = max(ans, b)\n\n\nprint(ans)", "def count_set_bits(n):\n count = 0\n while n:\n count += n & 1\n n >>= 1\n return count\n\n\nN = int(input())\nF = [int(\"\".join(input().split()), 2) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\nans = -float(\"inf\")\nfor i in range(1, 1 << 10):\n tmp = 0\n for j in range(N):\n tmp += P[j][count_set_bits(i & F[j])]\n ans = max(ans, tmp)\nprint(ans)\n", "N = int(input())\nF = [int(''.join(list(input().split())), 2) for i in range(N)]\nP = [list(map(int, input().split())) for i in range(N)]\n\nans = -float('inf')\n\nfor i in range(1, 2**10):\n res = 0\n for k in range(N):\n p = i & F[k]\n cnt = 0\n for j in range(10):\n if (p >> j) & 1:\n cnt += 1\n res += P[k][cnt]\n ans = max(ans, res)\n\nprint(ans)", "n = int(input())\n\nf = [list(map(int, input().split())) for _ in range(n)]\n# f = zip(*f)\n\np = [list(map(int, input().split())) for _ in range(n)]\n# p = zip(*p)\n\nans = -10**10\nfor i in range(1,1<<10):\n c = [0] * n # \u540c\u6642\u306b\u5e97\u3092\u958b\u3044\u3066\u3044\u308b\u6642\u9593\u5e2f\u6570\n for j in range(10):\n if i & (1<<j):\n for k,F in enumerate(f):\n if F[j]:\n c[k] += 1\n profit = 0\n for j in range(n):\n profit += p[j][c[j]]\n ans = max(ans, profit)\n\nprint(ans)", "N = int(input())\nF = [list(map(int,input().split())) for n in range(N)]\nP = [list(map(int,input().split())) for n in range(N)]\nans = []\n\nfor i in range(1,1024):\n p = 0\n for j in range(N):\n c = 0\n for k in range(10):\n if (i>>k&1) & F[j][k]:\n c+=1\n p+=P[j][c]\n ans+=[p]\n \nprint(max(ans))", "n = int(input())\nf = [int(input().replace(\" \", \"\"), 2) for i in range(n)]\np = [list(map(int, input().split())) for i in range(n)]\nans = -float('inf')\nfor i in range(1, 2 ** 10):\n sum = 0\n for j in range(n):\n sum += p[j][bin(i & f[j]).count('1')]\n ans = max(ans, sum)\nprint(ans)", "N = int(input())\nF = [0] * N\nfor i in range(N):\n F[i] = list(map(int, input().split()))\n \nP = [0] * N \nfor i in range(N):\n P[i] = list(map(int, input().split()))\n\n#print(F, P)\n#print(4 >> 1)\nans = - 10 ** 10\n#print(ans)\nfor i in range(1, 2 ** 10):#bit\u5168\u63a2\u7d22 #0\u306f\u7a7a\u3044\u3066\u308b\u6642\u9593\u5e2f\u304c\u306a\u3044\u306e\u3067\u30ab\u30c3\u30c8\n open_n = [0] * N\n profit = 0\n for j in range(10):#10240\u901a\u308a\n if ((i >> j) & 1):#j\u306e\u6642\u9593\u5e2f\u306b\u7a7a\u3044\u3066\u308b\n for k in range(N):#100\n if F[k][j] == 1:\n open_n[k] += 1\n for l in range(N):\n profit += P[l][open_n[l]]\n if ans < profit:\n ans = profit\n \nprint(ans) \n", "import numpy as np\nimport heapq as hq\nN = int(input())\nF = np.array([[int(x) for x in input().split()] for _ in range(N)])\nP = np.array([[int(x) for x in input().split()] for _ in range(N)])\n\nProfit = []\nfor i in range(1,2**10): #\u55b6\u696d\u6642\u9593\u5e2f\u306b\u3064\u3044\u3066bit\u5168\u63a2\u7d22\n Open = np.array([int(x) for x in format(i, '010b')]).T #2\u9032\u6570\u3092\u7e26\u30d9\u30af\u30c8\u30eb\u306b\u5909\u63db\n c = np.dot(F, Open) #\u5e97\u5225\u306b\u88ab\u308b\u6642\u9593\u5e2f\u306e\u500b\u6570\u3092\u30d9\u30af\u30c8\u30eb\u3068\u3057\u3066\u7b97\u51fa\n hq.heappush(Profit, -sum(P[i, c[i]] for i in range(N))) #-1\u500d\u3057\u305f\u5229\u76ca\u3092Profit\u306bpush\u3002\nprint((-Profit[0])) #heap\u304b\u3089\u6700\u5c0f\u5024\u3092\u53d6\u5f97\n", "n=int(input())\nf=[list(map(int,input().split())) for _ in range(n)]\np=[list(map(int,input().split())) for _ in range(n)]\n\nbh=[0]*n\nc=[0]*n\nfor i,s in enumerate(f):\n for j,h in enumerate(s):\n bh[i]|=h<<j\n\nmaxp=-float('inf')\nfor mbh in range(1,2**10):\n for i in range(n):\n intsect=mbh&bh[i]\n c[i]=sum(intsect>>k&1 for k in range(10))\n maxp=max(maxp,sum(p[i][c[i]] for i in range(n)))\nprint(maxp)", "#\n# abc080 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 = \"\"\"1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\"\"\"\n output = \"\"\"8\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\"\"\"\n output = \"\"\"-2\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7\"\"\"\n output = \"\"\"23\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n F = [list(map(int, input().split())) for _ in range(N)]\n P = [list(map(int, input().split())) for _ in range(N)]\n\n ans = sum([min(p) for p in P])\n for bit in range(1, 1 << 10):\n lbit = list(map(int, format(bit, \"b\").zfill(10)))\n p = 0\n for i, f in enumerate(F):\n n = 0\n for j in range(10):\n if lbit[j] == f[j] == 1:\n n += 1\n p += P[i][n]\n ans = max(ans, p)\n\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "import numpy as np\nN = int(input())\n\nF = np.empty((N,10))\nP = np.empty((N,11))\nfor i in range(N):\n Flist = np.array(list(map(int, input().split())), dtype = int)\n F[i] = Flist\nfor i in range(N):\n Plist = np.array(list(map(int, input().split())), dtype = int)\n P[i] = Plist\nBenefitMax = 0\n\nfor i in range(1,1024):\n A = np.zeros(10)\n iForBin = i\n for j in range(10):\n if iForBin %2 == 1:\n A[j] = 1\n iForBin = iForBin // 2\n ADotF = np.tensordot(A,F,((0),(1)))\n Benefit = 0\n for j in range(N):\n Benefit += P[j,int(ADotF[j])]\n if i == 1:\n BenefitMax = Benefit\n else:\n if BenefitMax < Benefit:\n BenefitMax = Benefit\n\nprint(int(BenefitMax))", "n=int(input())\nimport numpy as np\nf=[]\nfor i in range(n):\n f.append(list(map(int,input().split())))\np=[]\nfor i in range(n):\n p.append(list(map(int,input().split())))\nx=np.asarray(f)\nmx=-10**9\nfor i in range(1,2**10):\n y=np.asarray([int(x) for x in list(format(i,'010b'))])\n z=x*y\n can=np.sum(z,axis=1)\n c=0\n for j in range(n):\n c += p[j][can[j]]\n mx=max(c,mx)\nprint(mx)", "def bitcount(x):\n x = x - ((x >> 1) & 0x5555555555555555)\n x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)\n x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f #8bit\u3054\u3068\n x = x + (x >> 8) #16bit\u3054\u3068\n x = x + (x >> 16) #32bit\u3054\u3068\n x = x + (x >> 32) #64bit\u3054\u3068 = \u5168\u90e8\u306e\u5408\u8a08\n return x & 0x0000007f\n\ndef binary_to_int(x):\n temp = 0\n for i in range(len(str(x))):\n temp += 2**(len(str(x))-i-1) * int(str(x[i]))\n return temp\n\nn = int(input())\nshops = []\nfor i in range(n):\n shops.append(binary_to_int(\"\".join(input().split())))\np = []\nfor i in range(n):\n p.append(list(map(int, input().split())))\n\nfor i in range(1, 2**10):\n temp = 0\n for j in range(n):\n temp += p[j-1][bitcount(i & shops[j-1])]\n if i == 1:\n ans = temp\n elif temp > ans:\n ans = temp\n\nprint(ans)", "N = int(input())\nF = [int(\"\".join(input().split()),2) for n in range(N)]\nP = [list(map(int,input().split())) for n in range(N)]\nprint(max(sum(p[bin(n&f).count(\"1\")]for f,p in zip(F,P)) for n in range(1,1024)))", "def ForBaseConvert(Roop,MaxD,Base):\n if all(type(TT) is int for TT in [Roop,MaxD,Base]):\n if Base>=2 and MaxD>=1:\n ConvertN = []\n while Roop>0:\n ConvertN.append(Roop%Base)\n Roop = Roop//Base\n\n BaseConv = [0]*(MaxD-len(ConvertN))+ConvertN[::-1]\n BaseSInd = [[] for TB in range(0,Base)]\n for TB in range(0,Base):\n BaseSInd[TB] = [SInd for SInd,SNum in enumerate(BaseConv) if SNum==TB]\n return BaseConv,BaseSInd\n else:\n return []\n else:\n return []\n \nN = int(input())\nF = [[] for TF in range(0,N)]\nfor TF in range(0,N):\n F[TF] = [int(T) for T in input().split()]\nP = [[] for TP in range(0,N)]\nfor TP in range(0,N):\n P[TP] = [int(T) for T in input().split()]\n \nMAXB = -10**9\nfor TB in range(1,2**10):\n BaseConv,BaseSInd = ForBaseConvert(TB,10,2)\n Benefit = 0\n for TN in range(0,N): \n Count = sum(1 if F[TN][TT]==1 else 0 for TT in BaseSInd[1])\n Benefit += P[TN][Count]\n if MAXB<Benefit:\n MAXB = Benefit\nprint(MAXB)", "import itertools\nn=int(input())\nf=[list(map(int,input().split())) for _ in range(n)]\np=[list(map(int,input().split())) for _ in range(n)]\nans=-(10**12)\nfor i in range(1,11):\n num=list(itertools.combinations(list(range(10)),i))\n for j in range(len(num)):\n cnt=[0]*n\n cnt2=0\n for k in range(i):\n for l in range(n):\n if f[l][num[j][k]]==1:\n cnt[l]+=1\n for k in range(n):\n cnt2+=p[k][cnt[k]]\n ans=max(cnt2,ans)\nprint(ans)\n", "N = int(input())\nF = [list(map(int, input().split())) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\n\nmax_prof = -float('inf')\n\nfor s in range(1, 1 << 10):\n\n sum_prof = 0\n for store_no in range(N):\n state = s\n\n time_zone = 0\n both_open_cnt = 0\n while state > 0:\n if (state & 1) and F[store_no][time_zone]:\n both_open_cnt += 1\n\n state >>= 1\n time_zone += 1\n\n sum_prof += P[store_no][both_open_cnt]\n\n max_prof = max(max_prof, sum_prof)\n\n\nprint(max_prof)\n", "from math import inf\n\nn = int(input())\nf = [list(map(int, input().split())) for _ in range(n)]\np = [list(map(int, input().split())) for _ in range(n)]\n\nans = -inf\nfor bit in range(1,1024):\n res = 0\n for j in range(n):\n c = 0\n for k in range(10):\n mask = 1 << k\n if f[j][k] and bit&mask:\n c+=1\n res += p[j][c]\n ans = max(ans, res)\nprint(ans)\n\n\n", "from itertools import product\nN = int(input())\nF = [list(map(int, input().split())) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\nA = [0, 1]\nM = -10**18\nPr = list(product(A, repeat=10))\nPr.remove((0,0,0,0,0,0,0,0,0,0))\nfor I in Pr:\n s = 0\n for i in range(N):\n s += P[i][sum(i*f for i, f in zip(I, F[i]))]\n M = max(M, s)\nprint(M)", "N = int(input())\n\nF = [list(map(int, input().split())) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\n\nans = -float(\"inf\")\n\nfor i in range(1, 2**10):\n score = 0\n jonson = [0 for _ in range(10)]\n\n #jonson\u304c\u304a\u5e97\u3092\u958b\u304f\u6642\u9593\u3092\u6c7a\u3081\u308b\n for j in range(10):\n if ((i >> j)&1):\n jonson[j] = 1\n #\u4ed6\u306e\u304a\u5e97\u3068\u30aa\u30fc\u30d7\u30f3\u304c\u304b\u3076\u3063\u3066\u3044\u308b\u6642\u9593\u3092\u8abf\u3079\u308b\n for k in range(N):\n cnt = 0\n for l in range(10):\n if F[k][l] == jonson[l] == 1:\n cnt += 1\n score += P[k][cnt]\n\n ans = max(score, ans)\n\nprint(ans)", "N = int(input())\nF = [int(input().replace(' ', ''), 2) for _ in range(N)]\nP = [list(map(int, input().split())) for _ in range(N)]\nans = float('-inf')\n\nfor i in range(1, 2**10):\n ans = max(ans, sum(p[bin(i & f).count('1')] for f, p in zip(F, P)))\nprint(ans)\n", "import itertools\n\nN = int(input())\nM = 10\nF = [list(map(int, input().split())) for i in range(N)]\nP = [list(map(int, input().split())) for i in range(N)]\n\nans = -10 ** 10\nfor s in itertools.product([0, 1], repeat=M):\n if max(s) == 0:\n continue\n score = 0\n for i in range(N):\n cnt = 0\n for j in range(M):\n if s[j] and F[i][j]:\n cnt += 1\n score += P[i][cnt]\n ans = max(ans, score)\nprint(ans)\n", "from itertools import product\n\nans = -10**9 - 1\n\nN = int(input())\nF = []\nfor _ in range(N):\n F.append(list(map(int, input().split())))\n\nP = []\nfor _ in range(N):\n P.append(list(map(int, input().split())))\n\nall_x = True\nfor ox in product((0, 1), repeat=10):\n if all_x:\n all_x = False\n else:\n temp = 0\n for n in range(N):\n cnt = 0\n for i, j in zip(F[n], ox):\n cnt += i*j\n temp += P[n][cnt]\n ans = max(ans, temp)\n\nprint(ans)"]
{"inputs": ["1\n1 1 0 1 0 0 0 1 0 1\n3 4 5 6 7 8 9 -2 -3 4 -2\n", "2\n1 1 1 1 1 0 0 0 0 0\n0 0 0 0 0 1 1 1 1 1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1\n", "3\n1 1 1 1 1 1 0 0 1 1\n0 1 0 1 1 1 1 0 1 0\n1 0 1 1 0 1 0 1 0 1\n-8 6 -2 -8 -8 4 8 7 -6 2 2\n-9 2 0 1 7 -5 0 -2 -6 5 5\n6 -6 7 -9 6 -5 8 0 -9 -7 -7\n"], "outputs": ["8\n", "-2\n", "23\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
53,449
8d127982b8cc2a80d1602e1f59a6efa4
UNKNOWN
The postal code in Atcoder Kingdom is A+B+1 characters long, its (A+1)-th character is a hyphen -, and the other characters are digits from 0 through 9. You are given a string S. Determine whether it follows the postal code format in Atcoder Kingdom. -----Constraints----- - 1≀A,B≀5 - |S|=A+B+1 - S consists of - and digits from 0 through 9. -----Input----- Input is given from Standard Input in the following format: A B S -----Output----- Print Yes if S follows the postal code format in AtCoder Kingdom; print No otherwise. -----Sample Input----- 3 4 269-6650 -----Sample Output----- Yes The (A+1)-th character of S is -, and the other characters are digits from 0 through 9, so it follows the format.
["a,b = list(map(int, input().split()))\ns = input()\ncount = 0\nans = 'Yes'\nfor i in range(a+b+1):\n if i == a:\n if s[i] != '-':\n ans = 'No'\n break\n else:\n if s[i] == '-':\n ans = 'No'\n break\nprint(ans)\n", "A, B = map(int, input().split())\nS = input()\nD = [ str(i) for i in range(10)]\nT = S[:A] + S[A+1:]\n\nif S[A] == \"-\" and all( t in D for t in T):\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b = map(int, input().split())\ns = input()\n\nA = s[:a]\ncon = s[a]\nB = s[-b:]\n\nflg = True\nnum = [str(x) for x in range(10)]\nnum = set(num)\n\nfor x in A:\n if x not in num:\n flg = False\n\nfor x in B:\n if x not in num:\n flg = False\n\nif con != \"-\":\n flg = False\n\nprint(\"Yes\" if flg else \"No\")", "li = [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"]\na,b = map(int,input().split())\ns = input()\nfor i in range(a+b):\n if i != a:\n if s[i] not in li:\n print(\"No\")\n return\n else:\n if s[i] != \"-\":\n print(\"No\")\n return\nprint(\"Yes\")", "a, b = map(int, input().split())\ns = input()\n\nif len(s.split('-')) == 2 and s[a] == '-':\n print('Yes')\nelse:\n print('No')", "a,b=map(int,input().split())\ns=list(input())\nif s[a]=='-':\n c=0\n for i in range(0,a+b+1):\n if s[i].isdecimal()==True:\n c=c+1\n if c==a+b:\n print('Yes')\n else:\n print('No')\nelse:\n print('No')", "a,b=input().split()\nc=input()\na=int(a)\nb=int(b)\nd=0\nif c[a]==\"-\":\n for i in range(a+b+1):\n if c[i]==\"-\":\n d=d+1\n if d==1:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "import re\na,b = input().split()\ns = input()\nif re.match(r'\\d{' + a + '}-\\d{' + b + '}', s):\n print('Yes')\nelse:\n print('No')", "import sys\nA, B = [int(x) for x in input().split()]\nS = list(input())\nfor i in range(A+B+1):\n if(i==A):\n if(S[i]!='-'):\n print('No')\n return\n else:\n if(str.isdecimal(S[i])==False):\n print('No')\n return\nprint('Yes')", "a, b = map(int, input().split())\ns = input()\nt = s.split('-')\nprint('Yes' if s[a] == '-' and len(t) == 2 else 'No')", "dg = \"0123456789\"\n\nA,B = map(int,input().split())\nS = input()\n\npostcode = True\nfor i, ch in enumerate(S):\n if i == A:\n if ch != \"-\":\n postcode = False\n break\n else:\n if ch not in dg:\n postcode = False\n break\n \nif postcode:\n print(\"Yes\")\nelse:\n print(\"No\")", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\n\nl = [int(c) for c in input().split()]\nA=l[0]\nB=l[1]\nS=input()\n\nif S[A] == \"-\" and str.isdecimal(S[0:A]+S[A+1:A+B]):\n print(\"Yes\")\nelse:\n print(\"No\")", "A, B = list(map(int, input().split()))\nS = input()\n\nif S[A] == '-' and '-' not in S[:A] and '-' not in S[-B:]:\n print('Yes')\nelse:\n print('No')\n", "a,b=map(int, input().split())\ns=input()\nres=\"No\"\nif s[a]==\"-\":\n if s[:a].isdecimal() and s[a+1:].isdecimal():\n res=\"Yes\"\nprint(res)", "import re\na,b = list(map(int,input().split()))\ns = input()\nif s[a]==\"-\":\n if \"-\" not in s[:a]+s[(a+1):]:\n print(\"Yes\")\n return\nprint(\"No\")", "a,b=map(int, input().split())\ns=input()\n\nif len(s)==a+b+1 and s[a]==\"-\" and s.count(\"-\")==1:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b = map(int, input().split())\ns = input()\nif s[a] == \"-\" and s.count(\"-\") == 1:\n print(\"Yes\")\nelse:\n print(\"No\")", "import re\nA, B = list(map(int, input().split()))\nS = input()\nn_pattern = \"[0-9]\"\nres = \"Yes\"\nfor i in range(A+B+1):\n if i < A:\n if re.match(n_pattern, S[i]) is None:\n res = \"No\"\n break\n elif i == A:\n if S[i] != \"-\":\n res = \"No\"\n break\n else:\n if re.match(n_pattern, S[i]) is None:\n res = \"No\"\n break\n \nprint(res)\n", "a,b = map(int,input().split())\ns = list(input())\nans ='No'\n\nif s.count('-') == 1:\n ind = s.index('-')\n alen = ind\n blen = len(s)-(ind+1)\n\n if alen == a and blen == b:\n ans = 'Yes'\n\nprint(ans)", "a,b = list(map(int,input().split()))\ns =input()\nfor i in range(a+b+1):\n if i == a:\n if s[i] !='-':\n print('No')\n break\n else:\n if s[i]=='-':\n print(\"No\")\n break\n \n else:\n if int(s[i])<0 or 9<int(s[i]):\n print(\"No\")\n break\nelse:\n print('Yes')", "a,b = list(map(int,input().split()))\ns = input()\n\nnum = list(map(str,list(range(10))))\n\nflag = True\nfor i in range(a):\n if s[i] not in num:\n flag = False\nif s[a] != \"-\":\n flag = False\nfor i in range(a+1,a+b+1):\n if s[i] not in num:\n flag = False\n\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "import re\nA,B = input().split()\nS = input()\n\nmy_regex = r\"\\d{\" + A + r\"}-\\d{\"+ B +r\"}\"\n\nif re.fullmatch(my_regex, S) == None:\n print('No')\n \nelse:\n print('Yes')", "A, B = map(int, input().split())\nS = input()\n\nflag = False\nif S[A] == '-':\n S_ = S.split('-')\n if len(S_) == 2:\n if len(S_[0]) == A and len(S_[1]) == B:\n if S_[0].isdigit() and S_[1].isdigit():\n flag = True\n\nif flag:\n print('Yes')\nelse:\n print('No')", "A, B = map(int, input().split())\nS = input()\n\nif S.find(\"-\") == S.rfind(\"-\") == A:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b = list(map(int, input().split()))\ns = input()\nans = True\nfor i in range(a + b + 1):\n if s[a] != \"-\":\n ans = False\n break\n else:\n if i == a:\n pass\n else:\n for j in range(10):\n if s[i] == str(j):\n break\n else:\n ans = False\n\nif ans:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a,b=list(map(int,input().split()))\ns=input()\nif len(s) != a+b+1:\n print('No')\n return\nelse:\n if s[a] != '-':\n print('No')\n return\n else:\n for i in range(0,a):\n if s[i] == '-':\n print('No')\n return\n for i in range(a+1,a+b+1):\n if s[i] == '-':\n print('No')\n return\nprint('Yes')\n \n", "a, b = map(int, input().split())\ns = input()\nif s[a] == '-' and s.count('-') == 1:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b = map(int, input().split())\ns = input()\nfor i in s[0:a]:\n if 48 <= ord(i) and ord(i) <= 57:\n continue\n else:\n print(\"No\")\n return\nif s[a] != \"-\":\n print(\"No\")\n return\nfor i in s[a+1:a+b+1]:\n if 48 <= ord(i) and ord(i) <= 57:\n continue\n else:\n print(\"No\")\n return\nprint(\"Yes\")", "a, b = map(int, input().split())\ns = input()\n\nres = s.split('-')\nif len(res) == 2:\n if len(res[0]) == a and len(res[1]) == b and res[0].isdigit() and res[1].isdigit():\n print('Yes')\n else:\n print('No')\nelse:\n print('No')", "import sys\n\n\ndef LI():\n return list(map(int, input().split()))\n\n\nA, B = LI()\nS = input()\nans = \"Yes\"\nfor i in range(A):\n if S[i] == \"-\":\n ans = \"No\"\n break\nif S[A] != \"-\":\n ans = \"No\"\nfor i in range(A+1, A+B+1):\n if S[i] == \"-\":\n ans = \"No\"\n break\nprint(ans)\n", "A,B = map(int,input().split())\nS = input()\nfor i in range(A+B+1):\n if i < A and S[i] == '-':\n print('No')\n return\n elif i == A and S[i] != '-':\n print('No')\n return\n elif i > A and S[i] == '-':\n print('No')\n return\nprint('Yes')", "A,B = list(map(int, input().split()))\nS = input()\nprint((\"Yes\" if S[A] == \"-\" and S.count(\"-\") == 1 else \"No\"))\n", "A,B=list(map(int,input().split()))\nS=input()\nif S.count('-')==1 and S[A]=='-':\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a, b = map(int, input().split())\ns = input()\n\nif s[a] == \"-\" and len(s) == a + b + 1 and \"-\" not in s[:a] and \"-\" not in s[a+1:]:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b=map(int,input().split())\ns = input()\nx = ['0','1','2','3','4','5','6','7','8','9']\nif s[a] !='-':\n print('No')\n return\ns =list(s)\ndel s[a]\nfor i in s:\n if i not in x:\n print('No')\n return\nprint('Yes')", "a, b = map(int, input().split())\ns = list(input())\n\nif len(s) == a + b + 1:\n\tif s[a] == \"-\":\n\t\tdel s[a]\n\t\ttry:\n\t\t\tif all([0 <= int(x) <= 9 for x in s]):\n\t\t\t\tprint(\"Yes\")\n\t\t\telse:\n\t\t\t\tprint(\"No\")\n\t\texcept:\n\t\t\tprint(\"No\")\n\telse:\n\t\tprint(\"No\")\nelse:\n\tprint(\"No\")", "a,b = map(int, input().split())\ns = input()\n\nif (\"-\" not in s[:a])&(\"-\" not in s[a+1:])&(s[a]==\"-\"):\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b = map(int,input().split())\ns = input()\nif len(s) == a + b + 1:\n if s[a] == \"-\":\n s = s.replace(\"-\",\"\")\n if s.isdecimal() and len(s) == a + b:\n print(\"Yes\")\n else:\n print(\"No\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "a,b = map(int,input().split())\nn = input()\nif 1<=a<=5 and 1<=b<=5:\n if n[a]==\"-\":\n if n[0:a].isdecimal() and n[a+1:a+b+1].isdecimal():\n print(\"Yes\")\n return\nprint(\"No\")", "a,b=map(int,input().split())\ns=str(input())\ne=[\"0\",'1','2','3','4','5','6','7','8','9']\nfor i in range(len(s)):\n if a==i:\n if s[i]!='-':\n print(\"No\")\n return\n else:\n if s[i] not in e:\n print(\"No\")\n return\n\nprint(\"Yes\")", "#Postal Code\nA,B=map(int,input().split())\nd=[\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"]\nS=input()\ntotal=0\nfor i in range(A):\n if S[i] in d:\n pass\n else:\n total=1\nS=S[A:]\nif S[0]!=\"-\":\n total=1\nS=S[1:]\nfor i in range(B):\n if S[i] in d:\n pass\n else:\n total=1\nif total==1:\n print(\"No\")\nelse:\n print(\"Yes\")", "A,B = map(int,input().split())\nS = str(input())\nfor i in range(len(S)):\n if i < A:\n if not S[i].isnumeric():\n print(\"No\")\n return\n elif i == A:\n if S[i] != \"-\":\n print(\"No\")\n return\n else:\n if not S[i].isnumeric():\n print(\"No\")\n return\nprint(\"Yes\")", "import re\n\na, b = map(int, input().split())\ns = input()\ns = re.sub(r\"[0-9]\", \"+\", s)\nif s[0:a].count(\"+\") == a and s[a] == \"-\" and s[a+1:a+b+1].count(\"+\") == b:\n print(\"Yes\")\nelse:\n print(\"No\")", "A,B = map(int, input().split())\nS = input()\nprint(\"Yes\" if S[A] == \"-\" and S.count(\"-\") == 1 else \"No\")", "a, b = list(map(int, input().split()))\ns = input()\n\nif s[:a].isdecimal() and s[a] == '-' and s[a+1:].isdecimal():\n print('Yes')\nelse:\n print('No')", "A, B = list(map(int, input().split()))\nS = input()\nprint((\"Yes\" if S[A] == \"-\" and S.count(\"-\") == 1 else \"No\"))\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 s = input()\n\n if all(chr == \"-\" if index==a else chr.isdigit() for index, chr in enumerate(s)):\n print(\"Yes\")\n else:\n print(\"No\")\n\n\nmain()", "a,b = map(int,input().split())\ns = str(input())\n\nif len(s)== a+b+1 \\\n and s[a:a+1] =='-' \\\n and str.isdecimal(s[0:a]) \\\n and str.isdecimal(s[a+1:a+1+b]):\n print('Yes')\nelse:\n print('No')", "a,b = map(int, input().split())\ns = str(input())\n#print(s[a+1])\n\nif s[a] == \"-\" and s.count(\"-\") == 1:\n print(\"Yes\")\nelse:\n print(\"No\")", "import re\nA, B = map(int, input().split())\nS = input()\npattern = re.compile('[0-9]'*A + '-' +'[0-9]'*B)\nprint('Yes' if pattern.fullmatch(S) != None else 'No')", "a,b=map(int,input().split())\nl=input().split('-')\nif(len(l[0])==a and len(l[1])==b):\n print(\"Yes\")\nelse:\n print(\"No\")", "A, B = list(map(int, input().split()))\nS = input()\ncnt = 0\n\nfor i in S:\n if i == '-':\n cnt += 1\n\nif cnt == 1:\n post = S.split('-')\n if len(post[0]) == A and len(post[1]) == B:\n print('Yes')\n return\n\nprint('No')\n", "a,b = map(int,input().split())\ns = input()\nif s.count('-') == 1 and s[a] =='-':\n print('Yes')\nelse:\n print('No')", "a, b = list(map(int, input().split()))\ns = input()\n\nans = True\n\nfor (i, char) in enumerate(s):\n if i == a:\n if char == '-':\n ans = True\n else:\n ans = False\n break\n else:\n try:\n ans = type(int(char)) is int\n except:\n ans = False\n break\n\nif ans:\n print('Yes')\nelse:\n print('No')\n", "a,b=map(int,input().split())\nn = input()\nif n[0:a].isdecimal() and n[a]==\"-\" and n[a+1:a+b+1].isdecimal():\n print(\"Yes\")\nelse:\n print(\"No\")", "A,B=map(int,input().split())\nS=input()\na=S[:A]\nb=S[A]\nc=S[A+1:]\nans=True\nfor i in range(A):\n if a[i].isdigit()==False:\n print('No')\n return\nif b!='-':\n print('No')\n return\nfor i in range(B):\n if c[i].isdigit()==False:\n print('No')\n return\nprint('Yes')", "lst = input().split()\nA = int(lst[0])\nB = int(lst[1])\ns = input()\n\nif (len(s) == (A + B + 1)) and (s.count('-') == 1) and (s[A] == '-'):\n print('Yes')\nelse:\n print('No')", "import re\nA, B = list(map(int, input().split()))\nS = input()\n\nans = 'No'\np = '\\d{' + str(A) + '}-\\d{' + str(B) + '}'\nif re.match(p, S):\n ans = 'Yes'\nprint(ans)\n", "A, B = map(int, input().split())\nS = input()\n\nresult = 'Yes'\nif '-' in S[:A]:\n result = 'No'\nif '-' not in S[A]:\n result = 'No'\nif '-' in S[A+1:]:\n result = 'No'\n\nprint(result)", "import sys\nA, B = map(int,input().split())\nS = input()\nfor i in range(A + B + 1):\n if i == A:\n if S[i] != '-':\n print('No')\n return\n else:\n if not S[i] in '0123456789':\n print('No')\n return\nprint('Yes')", "import re\na,b = list(map(int,input().split()))\ns = input()\nif re.search(r\"[0-9][0-9]*\",s[0:a]):\n if s[a]==\"-\":\n if re.search(r\"[0-9][0-9]*\",s[(a+1):]):\n print(\"Yes\")\n return\nprint(\"No\")", "a,b = map(int,input().split())\ns = input()\nc = 0\n\ndef is_int(s):\n\ttry:\n\t\tint(s)\n\t\treturn True\n\texcept ValueError:\n\t\treturn False\n\nfor i in range(a):\n\tif is_int(s[i]) == True:\n\t\tc += 1\nfor i in range(a+1,a+b):\n\tif is_int(s[i]) == True:\n\t\tc += 1\nif s[a] == '-' and c == len(s) - 2:\n\tprint('Yes')\nelse:\n\tprint('No')", "a,b = list(map(int,input().split()))\ns =input()\nfor i in range(a+b+1):\n if i == a:\n if s[i] !='-':\n print('No')\n break\n else:\n if s[i]=='-':\n print(\"No\")\n break\n \n else:\n if int(s[i])<0 or 9<int(s[i]):\n print(\"No\")\n break\nelse:\n print('Yes')", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\na, b = list(map(int, input().split()))\ns = str(input())\n\nx = s.split(\"-\")\n\nif len(x[0]) == a and len(x[1]) == b:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a, b = (int(i) for i in input().split())\ns = input()\nif '-' not in s[:a] and s[a] == '-' and '-' not in s[a + 1:]: print(\"Yes\")\nelse: print(\"No\")", "a, b = map(int, input().split())\ns = input()\nt = s[:a] + s[a+1:]\n\nif s[a]=='-' and '-' not in t:\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "a, b = map(int, input().split())\ns = input()\nans = 'Yes'\nfor i in range(len(s)):\n if i > a + b:\n ans = 'No'\n break\n if i == a:\n if s[i] != '-':\n ans = 'No'\n break\n elif not s[i].isdigit(): \n ans = 'No'\n break\nprint(ans)", "a,b=list(map(int,input().split()))\ns=input()\nif len(s) != a+b+1:\n print('No')\n return\nelse:\n if s[a] != '-':\n print('No')\n return\n elif s.count('-')!=1:\n print('No')\n return\nprint('Yes')\n \n", "a,b=map(int,input().split())\nS=input()\nfor i in range(len(S)):\n if i==a:\n if S[i]!=\"-\":\n print(\"No\")\n break\n else:\n try:\n Si = int(S[i])\n except:\n print(\"No\")\n break\nelse:\n print(\"Yes\")", "a, b = map(int, input().split())\ns = input()\nt = s[:a] + s[a+1:]\n\nif s[a]=='-' and '-' not in t:\n\tprint(\"Yes\")\nelse:\n print(\"No\")", "import re\nimport sys\nA, B = map(int, input().split())\nS = input()\n\nif S[A] != '-':\n print('No')\n return\n\nS = S.replace('-', '')\n\nif len(S) == 0:\n print('No')\n return\n\ncount = 0\nfor i in range(len(S)):\n if re.match(r'[0-9]', S[i]):\n count += 1\n\nif count == A+B:\n print('Yes')\nelse:\n print('No')", "a,b= map(int, input().split())\ns = input()\n\nif (\"-\" in s) and s.count(\"-\") == 1:\n s = s.split(\"-\")\n if len(s[0]) == (a) and len(s[1]) == b:\n print(\"Yes\")\n else:\n print(\"No\")\n\nelse:\n print(\"No\")", "def main():\n A, B = list(map(int, input().split()))\n S = input()\n cond = [\n len(S) == A + B + 1,\n S[A] == '-',\n S[:A].isdigit(),\n S[A + 1:].isdigit()\n ]\n print(('Yes' if all(cond) else 'No'))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a, b = map(int, input().split())\ns = input()\n\nnum = '0123456789'\n\nif all(s[i] in num for i in range(a)) and s[a] == '-' and all(s[-(i+1)] in num for i in range(b)):\n print('Yes')\nelse:\n print('No')", "A,B = list(map(int,input().split()))\nL = ['0','1','2','3','4','5','6','7','8','9']\ns = str(input())\nfor i in range(len(s)):\n if i == A:\n if s[A] != '-':\n print('No')\n return\n else:\n b = s[i]\n if b not in L:\n print('No')\n return\nprint('Yes')\n \n", "a,b = map(int,input().split())\ns = input()\nif len(s) == a + b + 1 and s[a] == \"-\":\n s = s.replace(\"-\",\"\")\n if s.isdecimal() and len(s) == a + b:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "a,b = list(map(int,input().split()))\ns = input()\nif len(s) == a+b+1:\n if s[a] == '-':\n cnt = 0\n for i in range(len(s)):\n if s[i]=='0'or s[i]=='1'or s[i]=='2'or s[i]=='3'or s[i]=='4'or s[i]=='5'or s[i]=='6'or s[i]=='7'or s[i]=='8'or s[i]=='9':\n cnt += 1 \n if cnt == a+b:\n print('Yes')\n else:\n print('No')\n else:\n print('No')\nelse:\n print('No')\n", "a, b = map(int,input().split())\ns = input()\nprint(\"Yes\" if s[:a].isdecimal() and s[a] == \"-\" and s[a+1:].isdecimal() else \"No\")", "\nA, B = list(map(int, input().split()))\nS = input()\n\nif len(S) != A+B+1:\n print(\"No\")\n return\n\nfor i in range(A+B+1):\n\n if i == A:\n if S[i] != \"-\":\n print('No')\n return\n else:\n if not('0' <= S[i] <= '9'):\n print('No')\n return\nprint('Yes')\n", "a,b=list(map(int,input().split()))\n\nS=input()\nd=0\nc=a+b+3\nfor i in range(a+b+1):\n\tif S[i]=='-':\n\t\tc=i+1\n\t\td+=1\n\nif c==a+1 and d==1:\n\tprint('Yes')\nelse:\n\tprint('No')\n", "#ABC084B\na,b = map(int,input().split())\ns = input()\nprint(\"Yes\" if s[a]==\"-\" and s.count(\"-\")==1 else \"No\")", "a, b = map(int, input().split())\ns = input().rstrip().split('-')\nif len(s) == 2 and len(s[0]) == a and len(s[1]) == b:\n print('Yes')\nelse:\n print('No')", "A,B = map(int,input().split())\nS = list(input().split(\"-\"))\n\ncheck = False\nif len(S) == 2:\n s,t = S[0],S[1]\n if A == len(s) and B == len(t):\n check = True\n\nprint(\"Yes\" if check else \"No\")", "A, B = map(int, input().split())\nS = input()\nflag = True\nfor i in range(A + B + 1):\n if i == A:\n if S[i] != '-':\n flag = False\n else:\n if S[i] == '-':\n flag = False\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")", "A, B = map(int, input().split())\nS = input()\nflag = False\nfor i in range(A):\n if S[i] == \"-\":\n flag=True\nif S[A] != \"-\":\n flag=True\nfor i in range(A+1, A+B+1):\n if S[i] == \"-\":\n flag=True\nif flag:\n print(\"No\")\nelse:\n print(\"Yes\")", "A, B = list(map(int, input().split()))\nS = input()\ncnt = 0\n\nfor i in S:\n if i == '-':\n cnt += 1\n\nif cnt == 1:\n post = S.split('-')\n if len(post[0]) == A and len(post[1]) == B:\n print('Yes')\n return\n\nprint('No')\n", "A,B=map(int,input().split())\nS=input()\nif S[:A].isdecimal() and S[A]=='-' and S[A+1:].isdecimal():\n print('Yes')\nelse:\n print('No')", "import re\n\nA, B = map(int, input().split())\nS = input()\n\nformer = S[0:A]\nlater = S[(A+1):(A+B+3)]\n\nr_f = re.compile('\\d{' + str(A) + '}')\nr_l = re.compile('\\d{' + str(B) + '}')\n\nif r_f.findall(former) and r_l.findall(later) and S[A] == '-':\n print('Yes')\nelse:\n print('No')", "a,b = map(int,input().split())\ns = input()\nfor i in range(a+b+1):\n if i == a:\n if s[i] != \"-\":\n print(\"No\")\n return\n else:\n if s[i] == \"-\":\n print(\"No\")\n return\nprint(\"Yes\")", "a,b=map(int,input().split())\ns=input().split(\"-\")\nprint(\"Yes\" if len(s)==2 and len(s[0])==a and len(s[1])==b else \"No\")", "a, b = map(int, input().split())\ns = list(input())\ndef f():\n for i in range(len(s)):\n if i == a:\n if s[i] != \"-\":\n return \"No\"\n else:\n if s[i] == \"-\":\n return \"No\"\n return \"Yes\"\nprint(f())", "import math\n\nis_no = 0\nnum1, num2 = list(map(int, input().split()))\nstr1 = input()\ntable = list(str1)\ncount = 0\nfor i in range(len(str1)):\n if table[i] == '-':\n count += 1\n else:\n continue\nif count == 1 and table[num1] =='-':\n print('Yes')\nelse:\n print('No')\n", "# -*- coding:utf-8 -*-\nA,B = map(int,input().split())\nS = input()\n\n\n\nif S[:A].isdecimal() and S[A]==\"-\" and S[A+1:].isdecimal():\n print(\"Yes\")\nelse:\n print(\"No\")", "A, B = map(int, input().split())\nS = list(input())\nAB = [0]*2\nf = 0\nfor s in S:\n if s == \"-\" :\n f = 1\n continue\n AB[f] += 1\nif AB[0] == A and AB[1] == B:\n print(\"Yes\")\nelse:\n print(\"No\")", "# 33\nA, B = map(int, input().split(' '))\nS = str(input())\n\nans = 'Yes'\nif S[A] != '-':\n ans = 'No'\nelse:\n S = S.replace('-', '', 1)\n if S.isdecimal() == False:\n ans = 'No'\n\nprint(ans)", "import re\n\n\ndef answer(a: int, b: int, s: str) -> str:\n pattern = fr'\\d{{{a}}}-\\d{{{b}}}'\n if re.match(pattern, s):\n return 'Yes'\n return 'No'\n\n\ndef main():\n a, b = list(map(int, input().split()))\n s = input()\n print((answer(a, b, s)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a, b = map(int, input().split())\ns = input()\n\nres = s.split('-')\nif len(res) == 2:\n if len(res[0]) == a and len(res[1]) == b and res[0].isdigit() and res[1].isdigit():\n print('Yes')\n else:\n print('No')\nelse:\n print('No')", "a,b = map(int,input().split())\ns = input()\nif len(s) == a + b + 1 and s[a] == \"-\":\n s = s.replace(\"-\",\"\")\n if s.isdecimal() and len(s) == a + b:\n print(\"Yes\")\n return\nprint(\"No\")"]
{"inputs": ["3 4\n269-6650\n", "1 1\n---\n", "1 2\n7444\n"], "outputs": ["Yes\n", "No\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
23,561
d485189b48d22fd85f1fa005c868e13d
UNKNOWN
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved. -----Constraints----- - All input values are integers. - 1≀W≀10^5 - 1≀a,b≀10^5 -----Input----- The input is given from Standard Input in the following format: W a b -----Output----- Print the minimum distance the second rectangle needs to be moved. -----Sample Input----- 3 2 6 -----Sample Output----- 1 This input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of 1.
["W,a,b=map(int,input().split());print([abs(a-b)-W,0][abs(a-b)<=W])", "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nif b<=c:\n if a+b>=c:\n print(0)\n else:\n print(c-b-a)\nelse:\n if a+c>=b:\n print(0)\n else:\n print(b-c-a)", "w,a,b = map(int, input().split())\nprint(max(0,b-a-w) if b >= a else max(0,a-b-w))", "#!/usr/bin/env python3\nW, a, b = list(map(int, input().split()))\n\na_l = a\na_r = a + W\nb_l = b\nb_r = b + W\n\nif b_r < a_l:\n print((abs(b_r - a_l)))\nelif a_r < b_l:\n print((abs(a_r - b_l)))\nelse:\n print((0))\n", "w,a,b=map(int,input().split())\nif b>=a+w:\n print(b-a-w)\nelse:\n if b+w>=a:\n print('0')\n else:\n print(a-b-w)", "w, a, b = map(int, input().split())\nprint(max(abs(a-b)-w,0))", "w, a, b = map(int, input().split())\nif a <= b:\n if a+w < b:\n print(b-a-w)\n else:\n print(0)\nelse:\n if b+w < a:\n print(a-b-w)\n else:\n print(0)", "w, a, b = list(map(int, input().split()))\nif abs(a - b) <= w:\n print((0))\nelse:\n print((abs(a -b) - w))\n", "w, a, b = map(int, input().split())\n\nif a + w < b:\n print(b - (a + w))\nelif b + w < a:\n print(a - (b + w))\nelse:\n print(0)", "w, a, b = map(int, input().split())\n\nif a+w < b:\n ans = b-(a+w)\nelif b+w < a:\n ans = a-(b+w)\nelse:\n ans = 0\n\nprint(ans)", "W,a,b = map(int,input().split())\nprint(max(0,b-(a+W),a-(b+W)))", "w,a,b = map(int,input().split())\nif a <= b <= a+w or a <= b+w <= a+w:\n print(0)\nelse:\n print(min(abs(a+w-b),abs(b+w-a)))", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(W: int, a: int, b: int):\n if abs(a-b) <= W:\n return 0\n return abs(a-b) - W\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 W = int(next(tokens)) # type: int\n a = int(next(tokens)) # type: int\n b = int(next(tokens)) # type: int\n print((solve(W, a, b)))\n\ndef test():\n import doctest\n doctest.testmod()\n\ndef __starting_point():\n #test()\n main()\n\n__starting_point()", "#!/usr/bin/env python3\nw,a,b=map(int,input().split())\nif b>a:\n if b-w-a>0:\n print(b-w-a)\n else:\n print(0)\nif a>b:\n if a-w-b>0:\n print(a-w-b)\n else:\n print(0)\nif a==b:\n print(0)", "W,a,b=map(int,input().split())\nif b+W<a :\n print(a-(b+W))\nelif a+W<b :\n print(b-(a+W))\nelse :\n print(0)", "W, a, b = map(int, input().split())\nf = lambda x:x if x > 0 else 0\nprint(f(abs(a-b)-W))", "w, a, b = map(int, input().split())\nprint(max(0, b - a - w, a - b - w))", "W, a, b = list(map(int, input().split()))\n\nif a + W < b:\n print((b - (a + W)))\nelif a > b + W:\n print((a - (b + W)))\nelse:\n print((0))\n", "w,a,b = map(int, input().split())\n\nif a <= b <= a + w or a <= b + w <= a + w:\n print(0)\nelif a + w < b:\n print(b - (w + a))\nelif b + w < a:\n print(a - (w + b))", "w,a,b=map(int,input().split())\nif a<b:\n if a+w>b:\n print(0)\n else:\n print(b-a-w)\nelif b<a:\n if b+w>a:\n print(0)\n else:\n print(a-b-w)\nelse:\n print(0)", "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 w, a, b = MI()\n if b < a:\n temp = a\n a = b\n b = temp\n ans = max(0, b-a-w)\n print(ans)\n\n\ndef __starting_point():\n main()\n__starting_point()", "w,a,b = map(int,input().split())\nif abs(a - b) <= w:\n print(0)\nelse:\n print(abs(a - b) - w)", "lst = input().split()\n\nW = int(lst[0])\na = int(lst[1])\nb = int(lst[2])\n\nif b-W <= a <= b+W:\n print(0)\nelse:\n print(max([b - (a + W), a - (b + W)]))", "w,a,b = (int(T) for T in input().split())\nif a+w<b:\n print(b-(a+w))\nelif a<=b<=a+w:\n print(0)\nelse:\n print(a-(b+w))", "w, a, b = list(map(int, input().split()))\nif b + w < a:\n res = a - (b + w)\nelif a <= b + w <= a + 2 * w:\n res = 0\nelse:\n res = b - (a + w)\n\nprint(res)\n", "W, a, b = map(int, input().split())\n\nif abs(b - a) - W <= 0:\n print(0)\nelse:\n print(abs(b - a) - W)", "W, a, b = list(map(int, input().split()))\n\nif abs(a - b) <= W:\n print(0)\nelse:\n print(abs(a - b) - W)", "W, a, b = list(map(int, input().split()))\n\nif a <= b <= a + W or a <= b + W <= a + W:\n print((0))\nelse:\n print((min(abs(a + W - b), abs(b + W - a))))\n", "W, a, b = list(map(int, input().split()))\n\nif a + W < b:\n print((abs(a + W - b)))\nelif b + W < a:\n print((abs(b + W - a)))\nelse:\n print((0))\n", "w, a, b = list(map(int, input().split()))\n\nif a <= b <= a+w or b <= a <= b+w:\n ans = 0\nelif a < b:\n ans = b-a-w\nelse:\n ans = a-b-w\n\nprint(ans)\n", "W,a,b = map(int,input().split())\nif a-W <= b <= a+W:\n print(0)\nelif b+W < a:\n print(a-(b+W))\nelse:\n print(b-(a+W))", "W,a,b = map(int, input ().split ())\nif a < b:\n A,B = W+a,b\n if A >= B:\n print (0)\n else:\n print (B-A)\nelse:\n A,B = a,W+b\n if B >= A:\n print (0)\n else:\n print (A-B)", "w, a, b = map(int, input().split())\nans = max(a, b) - min(a+w, b+w)\nprint(max(ans, 0))", "W, A, B = [int(i) for i in input().split()]\n\nif B <= A <= B+W or B <= A+W <= B+W or A <= B <= A+W or A <= B+W <= A+W:\n print((0))\nelif W + A <= B:\n print((B - (W + A)))\nelse:\n print((A - (B + W)))\n", "w, a, b = map(int, input().split())\nif a <= b:\n if a + w >= b:\n print(0)\n else:\n print(b - a - w)\nelse:\n if b + w >= a:\n print(0)\n else:\n print(a - b - w)", "w,a,b = map(int,input().split())\nif a+w < b:\n print(b-a-w)\nelif b+w < a:\n print(a-b-w)\nelse:\n print(0)", "W, a, b = map(int, input().split())\nL = [b - (a + W), a - (b + W), 0]\nprint(max(L))", "w,a,b=map(int,input().split())\nif a>b:a,b=b,a\nprint(max(0,b-a-w))", "w, a, b = map(int, input().split())\n\nif abs(a - b) < w:\n print(0)\nelse:\n print(abs(a - b) - w)", "w, a, b = map(int,input().split())\nif a > b:\n a, b = b, a\n\nprint(max(b - a - w, 0))", "W,a,b =list(map(int,input().split()))\nif b>=a:\n if b-(a+W)<0:print((0))\n else:print((b-(a+W)))\nelse :\n if a-(b+W)<0:print((0))\n else:print((a-(b+W)))\n \n", "w,a,b=map(int,input().split())\n\nif a<=b:\n if a+w<b:\n print(b-a-w)\n else:\n print(0)\n \nelse:\n if b+w<a:\n print(a-b-w)\n else:\n print(0)", "# import math\n# import statistics\n# import itertools\n# a=int(input())\n# b=input()\n# c=[]\n# for i in a:\n# c.append(int(i))\nW,a,b= list(map(int,input().split()))\n# f = list(map(int,input().split()))\n# g = [int(input()) for _ in range(N)]\n# h = []\n# for i in range(a):\n# h.append(list(map(int,input().split())))\n# a = [[0] for _ in range(H)]#nizigen\n\nans1=b-(a+W)\nans2=a-(b+W)\n\nif a+W<b or b+W<a:\n print((min(abs(ans1),abs(ans2))))\nelse:\n print((0))\n", "w,a,b=map(int,input().split())\nif len(sorted(set(range(a,a+w+1)) & set(range(b,b+w+1)))) !=0:\n print(\"0\")\nelif b>=a+w:\n print(b-a-w)\nelif a>=b+w:\n print(a-b-w)", "w,a,b = map(int, input().split())\nprint(max(abs(a-b)-w,0))", "w, a, b = map(int, input().split())\nif abs(a - b) < w:\n ans = 0\nelse:\n ans = abs(a - b) - w\nprint(ans)", "W,a,b=map(int,input().split())\nprint(max(0,b-a-W,a-b-W))", "W, a, b = list(map(int, input().split()))\n\nif (a <= b <= a + W) or (a <= b + W <= a + W):\n print((0))\n return\n\nif a + W < b:\n print((b - (a + W)))\n return\nelse:\n print((a - (b + W)))\n", "W,a,b=list(map(int,input().split()))\nprint((max(abs(a-b)-W,0)))\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\nw, a, b = rm()\nif a < b:\n print((max(b-(a+w), 0)))\nelse:\n print((max(a-(b+w), 0)))\n\n\n\n\n\n\n\n\n\n\n\n", "w,a,b=map(int,input().split())\nif abs(a-b) <= abs(w):\n print(0)\nelse:\n print(abs(a-b)-w)", "w, a, b = list(map(int, input().split()))\nif a+w < b:\n print((b-a-w))\nelif b+w < a:\n print((a-b-w))\nelif a <= b <= a+w:\n print((0))\nelse:\n print((0))\n", "w,a,b=map(int,input().split())\nA=[i for i in range(a,a+w+1)]\nB=[i for i in range(b,b+w+1)]\nif a in B or b in A:\n print(0)\nelse:\n print(min(abs(a+w-b),abs(b+w-a)))", "w,a,b = map(int,input().split())\n\nmin_side = min(a,b)\nmax_side = max(a,b)\n\nt = max_side - (min_side + w)\nt = max(t,0)\n\nprint(t)", "w,a,c=map(int,input().split())\n\nb=w+a\nd=w+c\n\nif a>c:\n if a>d:\n print(abs(d-a))\n else:\n print('0')\n\nelse:\n if c>b:\n print(abs(c-b))\n else:\n print('0')", "W,a,b=map(int, input().split())\n\ndis = max(0, abs(a-b)-W)\nprint(dis)", "w,a,b = map(int, input().split())\nif b >= a:\n print(max(0,b-(a+w)))\nelse:\n print(max(0,a-(b+w)))", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(W: int, a: int, b: int):\n if a <= b <= a+W or b <= a <= b+W:\n return 0\n return min(min(abs(aa-bb) for bb in [b, b+W]) for aa in [a, a+W])\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 W = int(next(tokens)) # type: int\n a = int(next(tokens)) # type: int\n b = int(next(tokens)) # type: int\n print((solve(W, a, b)))\n\ndef test():\n import doctest\n doctest.testmod()\n\ndef __starting_point():\n #test()\n main()\n\n__starting_point()", "w, a, b = map(int, input().split())\n\nif b > a + w:\n print(b - a - w)\nelif b + w < a:\n print(a - b - w)\nelse:\n print(0)", "w,a,b = map(int, input().split())\n\nif (a <= b <= a+w) or (a <= b+w <= a+w):\n print(0)\nelif a+w < b:\n print(b-a-w)\nelif b+w < a:\n print(a-b-w)", "w,a,b = map(int,input().split())\naw = a + w\nbw = b + w\nif a == bw or b == aw or a == b:\n print(0)\nelif a < b < aw or b < a < bw:\n print(0)\nelse:\n if aw < b:\n print(b-aw)\n if bw < a:\n print(a-bw)", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\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 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############################################################\nW, a, b = lint()\nprint(max(0, max(a, b) - min(a, b) - W))", "w,a,b = map(int,input().split())\n#print(w,a,b)\nif a+w < b:\n print(abs(b-(a+w)))\nelif b+w < a:\n print(abs(a-(b+w)))\nelse:\n print(0)", "w, a, b = list(map(int, input().split()))\nres = max(0, abs(a - b) - w)\nprint(res)\n", "def answer(w: int, a: int, b: int) -> int:\n b_a = abs(b - a)\n if b_a <= w:\n return 0\n return b_a - w\n\n\ndef main():\n w, a, b = map(int, input().split())\n print(answer(w, a, b))\n\n\ndef __starting_point():\n main()\n__starting_point()", "w, a, b = map(int, input().split())\nprint(0) if a+w >= b and b+w >= a else print(b-a-w) if a+w < b else print(a-b-w)", "w,a,b = [int(x) for x in input().split()]\na,b = min(a,b) ,max(a,b)\n\nprint(max(0,b-a-w))", "W, a, b = list(map(int, input().split()))\n\nprint((max(abs(b-a)-W, 0)))\n", "w, a, b = map(int, input().split())\n\nif a + w < b:\n print(abs(b - (a+w)))\nelif b + w < a:\n print(abs(a - (b+w)))\nelse:\n print(0)", "# B - NarrowRectanglesEasy\ndef main():\n W, a, b = map(int, input().split())\n\n if a > b:\n print(max(0, a-b-W))\n else:\n print(max(0, b-a-W))\n \ndef __starting_point():\n main()\n__starting_point()", "w, a, b = map(int, input().split())\nif a <= b:\n print(b - w - a if b - w - a > 0 else 0)\nelse :\n print(a - w - b if a - w - b > 0 else 0)", "W, a, b = map(int, input().split())\nif abs(a-b) < W:\n ans = 0\nelse:\n ans = abs(a-b) - W\nprint(ans)", "w,a,b = list(map(int,input().split()))\nans = 0\nif a+w<b:\n ans = b-(a+w)\nelif b<a:\n ans = a-(b+w)\nelse:\n ans = 0\nprint(ans)\n", "w,a,b=map(int,input().split())\nif a<=b:\n print(max(0,b-(a+w)))\nelse:\n print(max(0,a-(b+w)))", "w,a,b=map(int,input().split())\n#a,a+w b,b+w\nif b<=a<=b+w or a<=b<=a+w:\n print(0)\nelse:\n print(min(abs(b-a-w),abs(b+w-a)))", "W,a,b=map(int,input().split())\nif a>b:\n if a<=b+W:\n print('0')\n else :\n print(a-b-W)\nelif b>a:\n if b<=a+W:\n print('0')\n else :\n print(b-a-W)\nelse:\n print('0')", "w, a, b = map(int, input().split())\nif a <= b <= a+w or b <= a <= b+w:\n print(\"0\")\nelif a+w < b:\n print(b-(a+w))\nelse:\n print(a-(b+w))", "W, a, b = list(map(int, input().split()))\nif b+W < a:\n print((a-(b+W)))\nelif b > a+W:\n print((b-(a+W)))\nelse:\n print((0))\n", "w,a,b=list(map(int,input().split()))\nif a<b:\n print((b-a-w if b-a-w>0 else 0))\nelse:\n print((a-b-w if a-b-w>0 else 0))\n", "#n = int(input())\nw, 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)]\n\nif a <= b:\n ans = max(0, b-(a+w))\nelse:\n ans = max(0, a-(b+w))\nprint(ans)\n", "w,a,b = map(int,input().split())\nif b>=a:\n print(max(0,b-(a+w)))\nelse:\n print(max(0,a-(b+w)))", "w,a,b = map(int,input().split())\nif a+w < b:\n print(b-(a+w))\nelif b+w < a:\n print(a-(b+w))\nelse:\n print(0)", "W,a,b=map(int,input().split())\nans=0\nif a+W<b:\n ans=b-(a+W)\nelif b+W<a:\n ans=a-(b+W)\nprint(ans)", "w, a, b = map(int, input().split())\n\nprint(max(a, b) - min(a, b) - w) if abs(a - b) > w else print(0)", "w,a,b = map(int,input().split())\naw = a+w\nbw =b+w\nprint(max(0,a-bw,b-aw))", "W,a,b=map(int,input().split())\nprint(max(0,b-a-W,a-b-W))", "w, a, b = list(map(int, input().split()))\nif a + w < b:\n print((b - (a + w)))\nelif b + w < a:\n print((a - (b + w)))\nelse:\n print((0))\n", "w,a,b = map(int,input().split())\nn = max(a,b)-(min(a,b)+w)\nif n < 0:\n print(0)\nelse:\n print(n)", "w, a, b = list(map(int, input().split()))\nans = abs(a - b) - w\nprint(ans) if ans > 0 else print(0)", "W,a,b=list(map(int,input().split()))\nprint(0 if W>abs(a-b) else abs(a-b)-W)", "w, a, b = map(int, input().split())\nl = max(a, b) - min(a, b)\nprint(l - w if l > w else 0)", "w,a,b=map(int,input().split())\nif a<b:\n if a+w<b:\n print(b-a-w)\n else:\n print(0)\nelif a>b:\n if b+w<a:\n print(a-b-w)\n else:\n print(0)\nelse:\n print(0)", "w,a,b=map(int,input().split())\nif b<=a+w<=b+w or b<=a<=b+w:\n print(0)\nelse:\n print(min(abs(a+w-b),abs(b+w-a)))", "W, A, B = map(int, input().split())\nprint(max(abs(B-A)-W, 0))", "W, a, b = list(map(lambda x: int(x), input().split(\" \")))\nm = min([a,b])\nM = max([a,b])\n\nif M - m > W:\n print(M - m - W)\nelse:\n print(0)", "w, a, b = map(int, input().split())\n\nif a + w < b:\n print(b - a - w)\nelif a < b + w:\n print(0)\nelse:\n print(a - b - w)", "w,a,b=map(int,input().split())\nif ((a<=b and b<=a+w) or (a<=b+w and b<=a)):\n print(0)\nelif a+w<b:\n print(b-a-w)\nelse:\n print(a-b-w)", "W,a,b=map(int,input().split())\nif b>a:\n if b-(a+W)<=0:\n \tprint(0)\n \treturn\n print(b-(a+W))\nelse:\n if a-(b+W)<=0:\n \tprint(0)\n \treturn\n print(a-(b+W))", "#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\n\nW,a,b = list(map(int, input().split()))\n\nif (b+W < a):\n print((a-(b+W)))\nelif (a+W < b):\n print((b-(a+W)))\nelse:\n print((0))\n"]
{"inputs": ["3 2 6\n", "3 1 3\n", "5 10 1\n"], "outputs": ["1\n", "0\n", "4\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,487
e193bbd6732dfe0abc8530ca556b5d05
UNKNOWN
Print all the integers that satisfies the following in ascending order: - Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers. -----Constraints----- - 1 \leq A \leq B \leq 10^9 - 1 \leq K \leq 100 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: A B K -----Output----- Print all the integers that satisfies the condition above in ascending order. -----Sample Input----- 3 8 2 -----Sample Output----- 3 4 7 8 - 3 is the first smallest integer among the integers between 3 and 8. - 4 is the second smallest integer among the integers between 3 and 8. - 7 is the second largest integer among the integers between 3 and 8. - 8 is the first largest integer among the integers between 3 and 8.
["a, b, k = map(int,input().split())\nfor i in range(a,min(b,a+k-1)+1):\n print(i)\nfor i in range(max(b-k+1,a+k),b+1):\n print(i)", "import sys\nlines = [s.rstrip(\"\\n\") for s in sys.stdin.readlines()]\na, b, k = [int(num) for num in lines.pop(0).split(\" \")]\ns1 = set(range(a, min(b, a + k)))\ns2 = set(range(max(a, b - k + 1), b + 1))\nlis = sorted(s1 | s2)\nfor i in lis:\n print(i)\n", "a, b, k = map(int, input().split())\n\nans = set()\nr = range(a, b + 1)\nfor i in range(min(k, len(r))):\n ans.add(r[i])\n ans.add(r[-i-1])\nelse:\n [print(i) for i in sorted(ans)]", "a, b, k = map(int, input().split())\n\nnum_limit = b-a+1\nif num_limit <= k*2:\n ans_list = [i for i in range(a, b+1, 1)]\nelse:\n ans_list = []\n for j in range(k):\n low = a+j\n high = b-j\n ans_list.append(low)\n ans_list.append(high)\n ans_list.sort()\n\nfor l in ans_list:\n print(l)", "a, b, k = map(int, input().split())\n\nif b-a < k:\n k = b-a\nif k == 0:\n k = 1\n \nans = []\nfor i in range(a, a+k):\n ans.append(i)\nfor j in range(b, b-k, -1):\n ans.append(j)\n \nans = sorted(set(ans))\nfor i in ans:\n print(i)", "a,b,k=map(int,input().split())\nr=range(a,b+1)\nfor i in sorted(set(r[:k])|set(r[-k:])):print(i)", "# ABC093\nA, B, K = map(int, input().split())\n\nfor num in range(A, min(B+1, A+K)):\n print(num)\nfor num in range(max(A+K, B-K+1), B+1):\n print(num)", "A,B,K=map(int,input().split())\na=range(A,B+1)\nfor i in sorted(set(a[:K])|set(a[-K:])):\n print(i)", "A,B,K=map(int, input().split())\n\nif K>(B-A)/2:\n for i in range(A,B+1):\n print(i)\nelse:\n for i in range(A,A+K):\n print(i)\n for i in range(B-K+1,B+1):\n print(i)", "a, b, k = map(int, input().split())\nx = [i for i in range(a, min(a + k, b + 1))]\ny = [i for i in range(max(a, b - k + 1), b + 1)]\nfor i in sorted(set(x + y)):\n print(i)", "a,b,k = map(int, input().split())\nfor i in range(a, a+k):\n if b < i:\n break\n print(i)\nfor i in range(max(a+k,b-k+1), b+1):\n if i < a:\n continue\n print(i)", "a,b,k = list(map(int, input().split()))\nans = []\nfor i in range(k):\n n = a + i\n if n > b:\n break\n ans.append(n)\n\nst = b - k + 1\nst = max(st, ans[-1]+1)\nfor i in range(st, b+1):\n ans.append(i)\n\nprint(*ans, sep='\\n')", "A,B,K=map(int,input().split())\nC=A\nif K>=B-A:\n for f in range(1+B-A):\n print(C)\n C+=1\nelse:\n B-=(K-1)\n for i in range(K):\n print(A)\n A+=1\n if A==B:\n break\n for j in range(K):\n print(B)\n B+=1", "lst = input().split()\nA = int(lst[0])\nB = int(lst[1])\nK = int(lst[2])\n\nif (B - A + 1) <= 2 * K:\n for n in list(range(A, B+1)):\n print(n)\nelse:\n for n in list(range(A, A+K)):\n print(n)\n for n in list(range(B-K+1, B+1)):\n print(n)", "a,b,k=map(int,input().split())\n\nif k>=b-a+1:\n for i in range(a,b+1):\n print(i)\n\nelse:\n a_set={i for i in range(a,a+k)}\n b_set={i for i in range(b-k+1,b+1)}\n\n ans_set = sorted(a_set | b_set)\n\n for i in ans_set:\n print(i)", "A, B, K = map(int, input().split())\n\nans = []\n\nfor i in range(K):\n if A + i <= B and A + i not in ans:\n ans.append(A + i)\n \n if B - i >= A and B - i not in ans:\n ans.append(B - i)\n \nans.sort()\n\nfor i in ans:\n print(i)", "a, b, k = map(int, input().split())\n\nr = range(a, b + 1)\nr = list(set(r[:k]) | set(r[-k:]))\nr.sort()\n\nfor _r in r:\n print(_r)", "A, B, K = list(map(int, input().split()))\n\nfor i in range(A, min(A+K, B+1)):\n print(i)\nfor i in range(max(A+K, B-K+1), B+1):\n print(i)\n", "a,b,k = map(int, input().split())\nl = [i for i in range(a,min(b,a+k))]\nl = l + [i for i in range(max(a,b-k+1),b+1)]\nl = list(set(l))\nl.sort()\nfor i in l:\n print(i)", "a,b,k=map(int,input().split())\nif b-a>=k*2-1:\n for i in range(k):\n print(a+i)\n for i in range(k):\n print(b+1-(k-i))\nelse:\n for j in range(a,b+1):\n print(j)", "a, b, k = map(int, input().split())\nX = range(a, b+1)\nY = sorted(list(set(X[:k]) | set(X[-k:])))\nprint(*Y, sep='\\n')", "a,b,n=map(int,input().split())\nAlist = list(range(a,min(a+n,b+1),1))\nBlist = list(range(max(a,b-n+1),b+1,1))\nC = sorted(set(Alist)|set(Blist))\nfor i in list(C):\n print(i)", "A,B,K = map(int,input().split())\nif K >= (B - A + 1)/2:\n for i in range(A,B+1):\n print(i)\nelse:\n for i in range(A,A+K):\n print(i)\n for i in range(B -K +1,B+1):\n print(i)", "A,B,K=list(map(int,input().split()))\n\nif B-A+1>2*K:\n for i in range(K):\n print((A+i))\n for j in range(K):\n print((B-K+j+1))\nelse:\n for k in range(B-A+1):\n print((A+k))\n", "a,b,k=list(map(int,input().split()))\n\nans=[]\n\nfor i in range(k):\n if a+i<=b-i:\n ans.append(a+i)\n ans.append(b-i)\n\nans=set(ans)\nans=list(ans)\nans.sort()\n\n\nfor a in ans:\n print(a)\n\n", "a, b, k = map(int, input().split())\nx = list()\nfor i in range(k):\n if a+i<= b:\n print(a+i)\n x.append(a+i)\nfor j in range(k):\n f = b-k+j+1\n if a <= f and f <= b and f not in x:\n print(f)", "A, B, K = map(int, input().split())\n\nL = []\ns = [i for i in range(A, min(A+K, B+1))]\nl = [j for j in range(B, max(A-1, B-K), -1)]\nL += s + l\nL = list(set(L))\nL.sort()\n\nfor i in L:\n print(i)", "A,B,K = map(int,input().split())\n\nfor i in range(A,min(A+K,B+1)):\n print(i)\n \nfor i in range(max(A+K,B-K+1),B+1):\n print(i)", "a, b, k = map(int, input().split())\n\nif b - a < 2 * k:\n for i in range(a, b + 1):\n print(i)\nelse:\n for i in range(a, a + k):\n print(i)\n for i in range(b - k + 1, b + 1):\n print(i)", "a, b, k = map(int, input().split())\n\nif b-a <= k:\n for i in range(a, b+1):\n print(i)\nelse:\n ans = []\n for i in range(a, a+k):\n if i not in ans:\n ans.append(i)\n print(i)\n for j in range(b-k+1, b+1):\n if j not in ans:\n print(j)", "#B - Small and Large Integers\nA,B,K = map(int,input().split())\n\nans = []\nfor j in range(K):\n a = A+j\n b = B-j\n if a > B or b < A:\n break\n ans.append(a)\n ans.append(b)\n\nans = list(sorted(set(ans), reverse = False))\n\nfor i in ans:\n print(i)", "a,b,k=list(map(int,input().split()))\nans=[]\nfor i in range(a,k+a):\n if a<=i<=b:\n ans.append(i)\n \nfor i in range(b-k+1,b+1):\n if a<=i<=b:\n ans.append(i)\nans=list(set(ans))\nans.sort()\nfor i in ans:\n print(i)\n\n", "a,b,k=map(int,input().split())\nans=set()\nfor i in range(k):\n ans.add(a+i)\n ans.add(b-i)\nfor i in sorted(list(ans)):\n if a<=i<=b:\n print(i)", "A,B,K=map(int,input().split())\nif B-A<=2*(K-1):\n for i in range(A,B+1):\n print(i)\nelse:\n for i in range(A,A+K):\n print(i)\n for j in range(B-K+1,B+1):\n print(j)", "a,b,k = map(int,input().split())\nans = set([])\nfor i in range(a,min(a+k,b)):\n ans.add(i)\nfor i in range(max(b-k+1,a),b+1):\n ans.add(i)\nans = list(ans)\nans.sort()\nfor i in ans:\n print(i)", "a,b,k=map(int,input().split())\n\ncnt=int(b-a+1)\n\nif cnt<=2*k:\n for i in range(a,b+1):\n print(i)\nelse:\n for i in range(a,a+k):\n print(i)\n for i in range(b-k+1,b+1):\n print(i)", "#!/usr/bin/env python3\n\na, b, k = list(map(int, input().split()))\n\nans = set([])\n\nfor i in range(a, min(a+k, b)):\n ans.add(i)\n\nfor i in range(max(a, b-k+1), b+1):\n ans.add(i)\n\nfor i in sorted(list(ans)):\n print(i)\n", "a,b,k = map(int,input().split())\n\nif (b - a + 1) >= 2*k:\n for i in range(a,a+k):\n print(i)\n for j in range(b-k+1,b+1):\n print(j)\n \nelse:\n for i in range(a,b+1):\n print(i)", "A,B,K=list(map(int,input().split()))\nif A+K-1>=B-K+1:\n for i in range(A,B+1):\n print(i)\nelse:\n for i in range(A,A+K):\n print(i)\n for i in range(B-K+1,B+1):\n print(i)\n", "a,b,k = map(int, input().split())\nsetA = set(i for i in range(a,min(a+k,b+1)))\nsetB = set(j for j in range(b,max(b-k,a-1),-1))\nl = list(setA|setB)\nl.sort()\nfor m in l:\n print(m)", "a,b,k = map(int,input().split())\nif (b-a+1) >= (2*k):\n for i in range(k):\n print(a+i)\n for i in reversed(range(0,k)):\n print(b-i)\nelse:\n for i in range(a,b+1):\n print(i)", "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 main():\n a, b, k = nm()\n\n for i in range(a, min(a + k, b + 1)):\n print(i)\n for i in range(max(a + k, b - k + 1), b + 1):\n print(i)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "A, B, K = map(int, input().split())\n\nfor i in range(A, min(A + K, B + 1)):\n print(i)\nfor i in range(max(B - K + 1, A + K), B + 1):\n print(i)", "A, B, K = list(map(int, input().split()))\n\nupstart = max(B - K + 1, 0)\nuplim = min(upstart + K, B)\nans = set([a for a in range(A, min(A + K, B))] + [b for b in range(upstart, uplim + 1)])\nans = sorted(list(ans))\nfor a in ans:\n if a < A:\n continue\n print(a)\n", "a,b,k=map(int,input().split())\nif b-a+1<=2*k:\n for i in range(a,b+1):\n print(i)\nelse:\n for i in range(a,a+k):\n print(i)\n for j in range(b-k+1,b+1):\n print(j)", "a, b, k = list(map(int, input().split()))\n\nif b-a <= k:\n for i in range(a, b+1):\n print(i)\nelse:\n ans = []\n for i in range(a, a+k):\n if i not in ans:\n ans.append(i)\n print(i)\n for j in range(b-k+1, b+1):\n if j not in ans:\n print(j)\n", "import sys\nsys.setrecursionlimit(10**9)\n\ndef mi(): return map(int,input().split())\ndef ii(): return int(input())\ndef isp(): return input().split()\ndef deb(text): print(\"-------\\n{}\\n-------\".format(text))\n\nINF=10**20\ndef main():\n A,B,K=mi()\n ans = set()\n for i in range(A,A+K):\n if A<=i<=B:\n ans.add(i)\n \n for i in range(B-K+1,B+1):\n if A<=i<=B:\n ans.add(i)\n \n ans = list(ans)\n ans.sort()\n print(*ans,sep='\\n')\n\n\n\n\n\n\n\ndef __starting_point():\n main()\n__starting_point()", "a,b,k=map(int,input().split())\nx=[]\ny=[]\nif b-a<k:\n k=b-a+1\nfor i in range(a,a+k):\n x.append(i)\nfor i in range(b-k+1,b+1):\n x.append(i)\nx=list(set(x))\nx.sort()\nfor i in range(len(x)):\n print(x[i])", "a, b, k = list(map(int, input().split()))\nif (b - a + 1) <= 2 * k:\n for i in range(a, b + 1):\n print(i)\nelse:\n for i in range(a, a + k):\n print(i)\n for i in range(b - k + 1, b + 1):\n print(i)\n", "from typing import List\n\n\ndef answer(a: int, b: int, k: int) -> List[int]:\n a_k = set(range(a, min(a + k, b + 1)))\n k_b = set(range(max(b - k + 1, a + 1), b + 1))\n\n return sorted(a_k.union(k_b))\n\n\ndef main():\n a, b, k = list(map(int, input().split()))\n for i in answer(a, b, k):\n print(i)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "A, B, K = map(int, input().split())\nL = set()\nfor i in range(A, A+K):\n if i <= B:\n L.add(i)\nfor i in range(B, B-K, -1):\n if i >= A:\n L.add(i)\nprint(*sorted(list(L)), sep=\"\\n\")", "A, B, K = map(int, input().split())\n\nnum = []\nif A == B:\n print(A)\nelif (B + 1 - A) / 2 <= K:\n for i in range(A, B + 1):\n print(i)\nelse:\n for j in range(K):\n num.append(A + j)\n num.append(B - j)\n for k in range(len(num)):\n num.sort()\n print(num[k])", "a, b, k = list(map(int, input().split()))\n\nfor i in range(k):\n x = a + i\n if x <= b:\n print(a + i)\n \nfor i in range(k):\n x = b - k + i + 1\n if x <= a + k - 1 or x < a:\n pass\n else:\n print(x)", "a,b,k=map(int, input().split())\nr=range(2)\nan=sorted(set(range(a,min(a+k,b+1)))|set(range(max(a,b-k+1),b+1)))\nfor i in an:\n print(i)", "A,B,K = map(int, input().split())\nflag = True\n\nfor i in range(A,A+K):\n print(i)\n if i == B:\n falg = False\n break\n\nif flag:\n if A+(K-1) < B-(K-1):\n for i in range(B-(K-1),B+1):\n print(i)\n if i == B:\n break\n\n else:\n for i in range(A+K,B+1):\n print(i)\n if i == B:\n break", "a,b,k = map(int,input().split())\nfor i in range(a,min(b+1,a+k)):\n print(i)\nfor j in range(max(b-k,a+k-1),b):\n print(j+1)", "a, b, k = list(map(int, input().split()))\nres = set()\nfor i in range(a, a + k):\n res.add(min(b, i))\n\nfor i in range(b, b - k, -1):\n res.add(max(a, i))\n\nres = sorted(list(res))\nfor i in range(len(res)):\n print((res[i]))\n", "A,B,K = list(map(int,input().split()))\nif B - A >= 2 * K :\n for i in range(K):\n print((A + i))\n for j in reversed(list(range(K))):\n print((B - j))\nelse:\n for _ in range(A,B + 1):\n print(_)\n", "a,b,k = map(int,input().split())\nsmall = [i for i in range(a,a+k) if a <= i <= b]\nbig = [i for i in range(b-k+1,b+1) if a <= i <= b]\nfor i in range(len(small)):\n if small[i] not in big:\n big.append(small[i])\nbig.sort()\nfor i in range(len(big)):\n print(big[i])", "a,b,k=map(int,input().split())\nans = []\nfor i in range(k):\n if a <= a+i <= b:\n ans.append(a + i)\n if a <= b-i <= b:\n ans.append(b - i)\nans = list(set(ans))\nans.sort()\nfor i in range(len(ans)):\n print(ans[i])", "A,B,K=map(int,input().split())\n\nx = range(A,B+1)\n\nfor s in sorted(set(x[:K]) | set(x[-K:])):\n\tprint(s)", "a,b,k=list(map(int, input().split()))\nk=min(k,b-a+1)\n*al,=list(range(a,a+k))\n*al2,=list(range(b-k+1,b+1))\nans=al+al2\nans=list(set(ans))\nans.sort()\nfor i in ans:print(i)\n\n", "a,b,k = list(map(int,input().split()))\nl = []\nfor i in range(a,min(b,a+k)):\n l.append(i)\nfor i in range(max(b-k+1,a),b+1):\n l.append(i)\nans = sorted(set(l))\nfor i in ans:\n print(i)\n\n", "a,b,k=map(int, input().split())\n\nif b-a+1<=k*2:\n for i in range(a,b+1):\n print(i)\n \nelse:\n for j in range(a,a+k):\n print(j)\n \n for p in range(b-k+1,b+1):\n print(p)", "A, B, K = list(map(int, input().split()))\nSA = list(range(A, min(B, A + K)))\nSB = list(range(max(A, B - K + 1), B + 1))\n\nans = sorted(set(SA + SB))\nfor a in ans:\n print(a)\n", "A, B, K = map(int, input().split())\n\nif K > (B - A) // 2:\n for i in range(A, B + 1):\n print(i)\nelse:\n for i in range(A, A + K):\n print(i)\n for i in range(B - K + 1, B + 1):\n print(i)", "a, b, k = map(int, input().split())\n\nif (b-a +1) <= 2 * k:\n for i in range(a,b+1):\n print(i)\nelse:\n for i in range(a, a+k):\n print(i)\n for i in range(b-k+1, b+1):\n print(i)", "a, b, k = (int(i) for i in input().split())\nlist_ans = []\nfor i in range(1, k + 1):\n if a == b:\n list_ans.append(a)\n break\n if a > b: break\n list_ans.append(a)\n list_ans.append(b)\n a = a + 1\n b = b - 1\n\nfor i in sorted(list_ans): print(i)", "A,B,K = map(int,input().split())\n\nif K*2 > B-A:\n for i in range(A,B+1):\n print(i)\n\nelse:\n for i in range(A,A+K):\n print(i)\n for j in range(B-K+1,B+1):\n print(j)", "def resolve():\n a, b, k = map(int, input().split())\n if a+k-1 >= b-k+1:\n for i in range(a, b+1):\n print(i)\n else:\n for i in range(a, a+k):\n print(i)\n for i in range(b-k+1, b+1):\n print(i)\nresolve()", "a,b,k = map(int,input().split())\n\nk = k-1\ni = a\nwhile True:\n print(i)\n i += 1\n if i > a + k or i > b:\n break\nif i < b-k:\n i = b-k\nwhile i <= b:\n print(i)\n i += 1", "a,b,k = [int(x) for x in input().split()]\nres = []\nfor i in range(a,min(b,k+a-1) + 1):\n res.append(i)\nfor i in range(max(b-k+1,a),b+1):\n res.append(i)\nres = list(set(res))\nres.sort()\nfor i in range(len(res)):\n print(res[i])", "a=input().split(' ')\nA=int(a[0])\nB=int(a[1])\nK=int(a[2])\nif B-A+1<=K*2:\n for i in range(A,B+1):\n print(i)\nelse:\n for i in range(K):\n print((A+i))\n for i in range(K):\n print((B-K+1+i))\n", "a,b,k=map(int,input().split())\nans=[]\nnum_min=a+k\nnum_max=b-k+1\nif (b-a+1)>2*k:\n for i in range(a,num_min):\n ans.append(i)\n for i in range(num_max,b+1):\n ans.append(i)\nelse:\n for i in range(a,b+1):\n ans.append(i)\nans=sorted(set(ans))\nfor i in ans:\n print(i)", "A, B, K = list(map(int, input().split()))\nS = sorted(list(set([i for i in range(A, min(A + K, B))] + [i for i in range(max(A, B - K + 1), B + 1)])))\nfor s in S:\n print(s)\n", "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nif (a+c-1)<(b-c+1):\n for i in range(c):\n print(a+i)\n for i in range(c):\n print(b-c+1+i)\nelse:\n for i in range(a,b+1):\n print(i)", "#\n# abc093 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 = \"\"\"3 8 2\"\"\"\n output = \"\"\"3\n4\n7\n8\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"4 8 3\"\"\"\n output = \"\"\"4\n5\n6\n7\n8\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"2 9 100\"\"\"\n output = \"\"\"2\n3\n4\n5\n6\n7\n8\n9\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n A, B, K = list(map(int, input().split()))\n\n ans = []\n for i in range(K):\n if A+i <= B and A+i not in ans:\n ans.append(A+i)\n if B-i >= A and B-i not in ans:\n ans.append(B-i)\n\n ans.sort()\n\n for a in ans:\n print(a)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\nimport numpy as np\n\ndef main2():\n A,B,K=map(int,input().split())\n if A+K-1>=B-K+1:\n for i in range(A,B+1):\n print(i)\n else:\n for i in range(A,A+K):\n print(i)\n for i in range(B-K+1,B+1):\n print(i)\n\ndef main():\n numbers=[]\n a,b,k = map(int,input().split())\n numbers=np.arange(a,b+1)\n A=set(numbers[:k])\n B=set(numbers[-k:])\n answers = A|B\n \n for i in sorted(answers):\n print(i)\n\ndef __starting_point():\n main2()\n__starting_point()", "a, b, k = list(map(int, input().split()))\n\nfor i in range(a, min(b, a + k - 1) + 1):\n print(i)\nfor i in range(max(b - k + 1, a + k), b + 1):\n print(i)\n", "A,B,K = list(map(int,input().split()))\nc = 0\nS = []\nif B - A <= K:\n for i in range(A,B+1):\n print(i)\n return\nfor i in range(A,B+1):\n if c == K:\n break\n print(i)\n S.append(i)\n c += 1\nfor i in range(B-K+1,B+1):\n if i not in S: \n print(i)\n", "a,b,k=map(int,input().split())\nif b-a+1>k*2:\n for i in range(a,a+k):\n print(i)\n for j in range(b-k+1,b+1):\n print(j)\nelse:\n for h in range(a,b+1):\n print(h)", "a, b, k = map(int, input().split())\nn = b - a + 1\n\nif n > k * 2:\n for i in range(k):\n print(a+i)\n for i in range(k):\n print(b-(k-i-1))\nelse:\n for i in range(a, b+1):\n print(i)", "a,b,k = map(int,input().split())\nif 2*k > b - a:\n for i in range(a,b + 1):\n print(i)\nelse:\n for i in range(k):\n print(a + i)\n for j in range(k):\n print(b - k + 1 + j)", "a,b,k = map(int,input().split())\nli = []\nif (b-a)+1 < k or (b-a) < k*2:\n for i in range(a,b+1):\n li.append(i)\n for i in li:\n print(i)\n return\nfor i in range(a,a+k):\n li.append(i)\nfor i in range(b-k+1,b+1):\n li.append(i)\nfor i in li:\n print(i)", "a, b, k = list(map(int, input().split()))\n\nans = set()\nk = min(k,b-a+1)\nfor i in range(a, a+k):\n ans.add(i)\n\nfor i in range(b, b - k, -1):\n ans.add(i)\n\nans=sorted(list(ans))\n\nfor i in (ans):\n print(i)\n", "a, b, k = map(int,input().split())\nif a+k+1 <= b:\n for i in range(a, k+a):\n print(i)\n if a+k+1 <= b+1-k:\n for i in range(b+1-k, b+1):\n print(i)\n else:\n for i in range(a+k, b+1):\n print(i)\nelse:\n for i in range(a, b+1):\n print(i)", "a,b,k = map(int,input().split())\n[print(i) for i in sorted(set(list(range(a,min(a+k,b+1)))+list(range(max(a,b-k+1),b+1))))]\n", "a,b,k = map(int, input().split())\n\nif b-a+1 > 2*k:\n for i in range(a,a+k): print(i)\n for i in range(b-k+1,b+1): print(i)\nelse: \n for i in range(a,b+1): print(i)", "A,B,K = list(map(int,input().split()))\n\nA1 = A\nA2 = min(A+K,B+1)\nfor i in range(A1,A2):\n print(i)\n\nB1 = max(B-K+1,A+K)\nB2 = B+1 \nfor i in range(B1,B2):\n print(i)\n", "A,B,K = map(int,input().split())\n\nls_1 = [i for i in range(A,min(A+K,B+1))]\nls_2 = [j for j in range(max(A,B-K+1),B+1) if j not in ls_1]\nls = ls_1 + ls_2\n\nfor ans in ls:\n print(ans)", "A, B, K = list(map(int, input().split()))\n\nif B - A < K*2:\n for i in range(A, B+1):\n print(i)\nelse:\n for i in range(A, A+K):\n print(i)\n for i in range(B-K+1, B+1):\n print(i)\n \n", "a,b,k=map(int, input().split())\nan=[]\nfor i in range(a,min(a+k,b+1)):\n an.append(i)\nfor i in range(max(b-k+1,a),b+1):\n an.append(i)\nan=sorted(list(set(an)))\nfor i in an:\n print(i)", "a, b, k = map(int, input().split())\nr = range(a, b+1)\nprint(*sorted(set(r[:k]) | set(r[-k:])), sep='\\n')", "a, b, k = map(int, input().split())\nn = range(a, b+1)\nfor i in sorted(set(n[:k]) | set(n[-k:])):\n print(i)", "from collections import OrderedDict\n\nA, B, K = map(int, input().split())\nL = []\nres = []\n\nif K > B-A:\n for i in range(A, B+1):\n print(i)\n return\nelse:\n for i in range(A, A+K):\n res.append(i)\n for i in range(B-K+1, B+1):\n res.append(i)\n\nres_unique = list(set(res))\nres_unique.sort()\n\nfor i in res_unique:\n print(i)", "a, b, k = list(map(int, input().split()))\n\nfor i in range(k):\n if a + i > b:\n break\n print((a + i))\n\nstart = max(a+k, b-k+1)\n\nfor i in range(start, b+1):\n print(i)\n", "a, b, k = list(map(int, input().split()))\nlis1 = []\nlis2 = []\nlis3 = []\n\nfor i in range(0, k):\n ap = a + i\n bm = b - i\n lis1.append(ap)\n lis2.append(bm)\n\nlis3 = lis1 + lis2\nsorted_lis = sorted(set(lis3))\n\nfor ans in sorted_lis:\n if a <= ans and ans <= b:\n print(ans)\n \n", "a,b,k = map(int,input().split())\n\nans = {}\nfor i in range(a,a+k):\n if i<=b:\n ans.setdefault(i,0)\n ans[i] += 1\n else:\n break\nfor i in range(b-(k-1),b+1):\n if a<=i:\n ans.setdefault(i,0)\n ans[i] += 1\n else:\n break\nfor i in ans.keys():\n print(i)", "a,b,k = list(map(int, input().split()))\nif b-a+1 < 2*k:\n for i in range(a,b+1):\n print(i)\nelse:\n for i in range(k):\n print((a+i))\n for j in range(k):\n print((b+j-k+1))\n", "a, b, k = map(int, input().split())\nn = []\nfor i in range(k):\n if a + i > b:\n break\n n.append(a + i)\nfor j in range(k):\n if b - k + 1 + j < a:\n break\n if n.count(b - k + 1 + j) <= 0:\n n.append(b - k + 1 + j)\n[print(num) for num in n]"]
{"inputs": ["3 8 2\n", "4 8 3\n", "2 9 100\n"], "outputs": ["3\n4\n7\n8\n", "4\n5\n6\n7\n8\n", "2\n3\n4\n5\n6\n7\n8\n9\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
23,794
7ea23d505abac626f3d6151fa30ce906
UNKNOWN
Snuke is going to open a contest named "AtCoder s Contest". Here, s is a string of length 1 or greater, where the first character is an uppercase English letter, and the second and subsequent characters are lowercase English letters. Snuke has decided to abbreviate the name of the contest as "AxC". Here, x is the uppercase English letter at the beginning of s. Given the name of the contest, print the abbreviation of the name. -----Constraints----- - The length of s is between 1 and 100, inclusive. - The first character in s is an uppercase English letter. - The second and subsequent characters in s are lowercase English letters. -----Input----- The input is given from Standard Input in the following format: AtCoder s Contest -----Output----- Print the abbreviation of the name of the contest. -----Sample Input----- AtCoder Beginner Contest -----Sample Output----- ABC The contest in which you are participating now.
["A,S,C=map(str,input().split())\nprint(\"A\"+S[0]+\"C\")", "s=input()\nprint(\"A\"+s[8]+\"C\")", "print(('A' + input().split()[1][0] + 'C'))\n", "a,b,c=map(str,input().split())\nprint('A'+b[0]+'C')", "lst = list(map(str, input().split()))\nprint(lst[0][0] + lst[1][0] + lst[2][0])", "arr = list(input().split())\nprint(arr[0][0] + arr[1][0] + arr[2][0])", "s = input().split()\nprint(\"A\" + s[1][0] + \"C\")", "s=input().split()\ns=[s[i][0] for i in range(len(s))]\nprint(\"\".join(s))", "x=input()\nprint((\"A\"+x[8]+\"C\"))\n", "S = input()\ns = 'A'+S[8].upper() + 'C'\nprint(s)", "s = input().split()\nprint('A'+ s[1][0].upper() +'C')", "a,b,c=input().split()\nprint(a[0]+b[0]+c[0])", "a=list(input().split())\nprint(a[0][0]+a[1][0]+a[2][0])", "a,b,c=map(str,input().split())\nprint(\"A\"+b[0]+\"C\")", "a, b, c = input().split()\n\nprint((a[0] + b[0] + c[0]))\n", "a,b,c = input().split()\n\nprint((a[0]+b[0]+c[0]).upper())", "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:/python/cp/output.txt\",\"w\")\n# sys.stdin = open(\"e:/python/cp/input.txt\",\"r\")\n\ns = input()\nprint(f\"A{s[8].upper()}C\")", "#!/usr/bin/env python3\n\ndef main():\n a, s, c = input().split()\n print((a[0] + s[0] + c[0]))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s1, s2, s3 = input().split()\nprint((s1[0] + s2[0] + s3[0]))\n", "s = input().split()\nprint(s[0][0]+s[1][0]+s[2][0])", "print(f'A{input()[8]}C')", "a,s,c=input().split()\nprint(\"A\" + s[0].upper() + \"C\")", "a, b, c = input().split()\nprint(a[0] + b[0] + c[0])", "a,b,c=input().split()\nx=b[0]\nA=[]\nA.append('A')\nA.append(x)\nA.append('C')\nprint(''.join(A))", "s = list(map(str, input().split()))\n\nprint((s[0][0] + s[1][0] + s[2][0]))\n", "a, b, c = list(map(list, input().split()))\n\nprint(\"A\" + b[0] + \"C\")", "def solve():\n print('A'+input()[8]+'C')\n\n\ndef __starting_point():\n solve()\n__starting_point()", "a,b,c,=input().split()\nprint((a[0]+b[0]+c[0]))\n", "a,x,c = input().split()\n\nprint('A'+x[0]+'C')", "a,s,t = map(str,input().split())\nprint(\"A\"+s[0]+\"C\")", "a, b, c = list(map(str, input().split()))\nprint((a[0] + b[0] + c[0]))\n", "print(\"A\"+input()[8]+\"C\")", "s = input()\nprint((\"A\" + s[8] + \"C\"))\n", "l = list(input().split())\nprint(\"A\" + l[1][0] + \"C\")", "s = list(input().split())\nn = s[1]\nprint(\"A\" + n[0] + \"C\")", "s=input().split()\n\nprint((\"A\"+s[1][0]+\"C\"))\n", "from sys import stdin, stdout\nfrom time import perf_counter\n\nimport sys\nsys.setrecursionlimit(10**9)\nmod = 10**9+7\n\ns = input()\nprint(f\"A{s[8].upper()}C \")", "a = input().split()\nb=[]\n\nfor i in range(3):\n b.append(a[i][0])\n \nprint(b[0]+b[1]+b[2])", "a = list(map(str,input().split()))\nmidle = list(a[1])\nprint(\"A\"+midle[0]+\"C\")", "a,b,c=input().split()\nprint(a[0]+b[0]+c[0])", "A = list(map(str, input().split()))\nprint(A[0][0] + A[1][0] + A[2][0])", "a = input().split()\nprint(*[h[0] for h in a], sep='')\n", "a,s,c=map(str,input().split())\nprint((\"A\"+s[0]+\"C\"))", "s = input()\nprint((\"A\"+s[8]+\"C\"))\n", "a,b,c=input().split()\nprint(a[0]+b[0]+c[0])", "def iroha():\n head, string, heel = list(map(str, input().split()))\n headC = head[0]\n Capital = string[0]\n heelC = heel[0]\n print((headC + Capital + heelC))\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "print(*[i[0] for i in input().split()],sep='')", "S = input()\nprint(\"A\"+S[8]+\"C\")", "s = input().split()[1]\nprint(\"A\"+s[0]+\"C\")", "a,b,c=input().split()\nprint('A'+b[0]+'C')", "#\n# abc048 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 = \"\"\"AtCoder Beginner Contest\"\"\"\n output = \"\"\"ABC\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"AtCoder Snuke Contest\"\"\"\n output = \"\"\"ASC\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"AtCoder X Contest\"\"\"\n output = \"\"\"AXC\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n S = list(input().split())\n\n print((\"A\"+S[1][0]+\"C\"))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "s = input().split()\nprint(\"A\", s[1][0], \"C\", sep=\"\")\n", "a = list(input().split())\nprint(\"A\"+a[1][0]+\"C\")", "a, b, c = input().split()\n\nprint(('A' + b[0] + 'C'))\n", "\"\"\"\nABC048 A - AtCoder *** Contest\nhttps://atcoder.jp/contests/abc048/tasks/abc048_a\n\"\"\"\na,b,c = input().split()\nprint((a[0]+b[0]+c[0]))\n", "def __starting_point():\n\tstr = input()\n\ta,b,c = str.split()\n\tprint(a[0]+b[0]+c[0])\n__starting_point()", "print((\"\".join(s[0] for s in input().split())))\n", "x = input()[8]\nprint(\"A\"+x+\"C\")", "lst=input().split()\nx=lst[1]\nprint('A'+x[0]+'C')", "s = input()\nprint(\"A\" + s[8] + \"C\") ", "a,b,c =input().split()\nprint('A' + b[0] + 'C')", "names = input().split()\nprint(\"\".join([a[0] for a in names]))", "A,B,C=input().split()\nprint(\"A\"+B[0]+\"C\")", "S = input().split()\nprint(S[0][0]+S[1][0]+S[2][0])", "s = list(input().split())\nprint(\"A\" + s[1][0] + \"C\")", "print(f\"A%sC\"%input()[8])", "a,b,c = input().split()\n\nprint(a[0]+b[0]+c[0])", "print(''.join([s[0] for s in input().split()]))", "a = list(map(str, input().split()))\nprint(a[0][0] + a[1][0] + a[2][0])", "_, s, _ = input().split()\nprint((\"A\" + s[0] + \"C\"))\n", "a,s,c=map(str,input().split())\n\nprint('A'+s[0]+'C')", "a,b,c=list(map(str,input().split()))\nprint((a[0]+b[0]+c[0]))\n", "a,b,c=input().split()\nprint('A'+b[0]+'C')", "a,b,c = input().split(\" \")\nprint(f\"A{b[0]}C\")", "s = input()\nstrs = s.split(' ')\nc = strs[1][0].upper()\n\nans = \"{}{}{}\".format(strs[0][0], c, strs[2][0])\nprint(ans)", "#48\nS=input().split()\ns=S[1]\nrev_s=list(s)\nprint('A'+rev_s[0]+'C')", "a,b,c=input().split()\nprint(\"A\"+b[0]+\"C\")", "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:/python/cp/output.txt\",\"w\")\n# sys.stdin = open(\"e:/python/cp/input.txt\",\"r\")\n\n\n\ns = input()\n# print(F\"Atcoder {s.title()} Contest\")\n\n# print(f\"A{s[0].upper()}C \")\nprint(f\"A{s[8].upper()}C\")", "a,b,c =input().split()\n\nprint(\"A\"+ b[0] + \"C\")", "s=input().split()\ns2=s[1]\n\nprint(\"A\"+s2[0]+\"C\")", "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############################################################\nprint(('A' + lstr()[1][0] + 'C'))\n", "title = list(map(str, input().split()))\nprint('A'+title[1][0]+'C')", "a, x, c = input().split()\nprint('A' + x[0] + 'C')", "s = input().split()\nprint(f\"A{s[1][0]}C\")", "a, b, c = map(str, input().split())\nprint(a[0] + b[0] + c[0])", "a, b, c = input().split()\nprint(\"A\" + b[0] + \"C\")", "AtCoder, s, Contest = input().split()\nprint(AtCoder[0] + s[0] + Contest[0])", "x,y,z = input().split()\nprint(x[0]+y[0]+z[0])", "a,b,c=input().split()\nprint(\"A\"+b[0]+\"C\")", "a,b,c=map(str,input().split())\nprint(\"A\"+b[0]+\"C\")", "title = input().split(\" \")\nname = title[1]\nfst = list(name)\nprint((\"A\"+fst[0]+\"C\"))\n", "a,b,c=input().split()\nprint(a[0]+b[0]+c[0])", "a = map(str, input().split())\nname_list = list(a)\nprint('{}{}{}'.format(name_list[0][0], name_list[1][0], name_list[2][0]))", "s, a, b = map(str, input().split())\nprint(\"A\" + a[0] + \"C\")", "A, x, C = list(map(str, input().split()))\nS = 'A' + x[0].upper() + 'C'\nprint(S)", "a,b,c = map(str,input().split())\n\nprint('A'+b[0]+'C')", "a,b,c = list(input().split())\n\nprint(a[0] + b[0] + c[0])", "a, b, c = input().split()\nprint(a[0] + b[0] + c[0])", "S=list(map(str,input().split()))\nprint(\"A\"+S[1][0]+\"C\")"]
{"inputs": ["AtCoder Beginner Contest\n", "AtCoder Snuke Contest\n", "AtCoder X Contest\n"], "outputs": ["ABC\n", "ASC\n", "AXC\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
8,779
aeb7bb140c9feda13c6ba24f03ad50b6
UNKNOWN
There are a total of A + B cats and dogs. Among them, A are known to be cats, but the remaining B are not known to be either cats or dogs. Determine if it is possible that there are exactly X cats among these A + B animals. -----Constraints----- - 1 \leq A \leq 100 - 1 \leq B \leq 100 - 1 \leq X \leq 200 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: A B X -----Output----- If it is possible that there are exactly X cats, print YES; if it is impossible, print NO. -----Sample Input----- 3 5 4 -----Sample Output----- YES If there are one cat and four dogs among the B = 5 animals, there are X = 4 cats in total.
["a, b, x = map(int, input().split())\nprint(\"YES\" if a <= x and x <= a+b else \"NO\")", "a,b,x=map(int, input().split())\nprint(\"YES\" if a+b>=x>=a else \"NO\")", "a,b,x = list(map(int,input().split()))\nif a<=x and a+b>=x:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a, b, x= list(map(int, input().split()))\n\nif a <= x <= a + b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a, b, x = map(int, input().split())\nif a > x:\n print('NO')\nelif x - a <= b:\n print('YES')\nelse:\n print('NO')", "A, B, X = list(map(int, input().split()))\nif A <= X <= A+B:\n print('YES')\nelse:\n print('NO')\n", "a,b,x=map(int,input().split())\nif a<=x<=a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,c=map(int,input().split())\nif c<a:\n print(\"NO\")\nelse:\n if c>a+b:\n print(\"NO\")\n else:\n print(\"YES\")", "A,B,X = map(int, input().split())\nprint('YES' if A <= X and A+B >= X else 'NO')", "a,b,x = map(int,input().split())\nprint('YES') if a <= x and x <= a+b else print('NO')", "a,b,x=map(int,input().split())\nif a<=x<=a+b:print('YES')\nelse:print('NO')", "A,B,X = map(int,input().split())\nprint('YES' if A <= X <= A+B else 'NO')", "a,b,x=map(int,input().split())\nif a<=x and a+b>=x:\n print(\"YES\")\nelse:\n print(\"NO\")", "A,B,X=map(int,input().split())\nif A+B>=X and A<=X:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, x = map(int, input().split())\nif a <= x <= a + b:\n print('YES')\nelse:\n print('NO')", "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, x = Input()\n print(\"YES\"\n if a <= x <= (a + b)\n else \"NO\")\n\n\nmain()", "a, b, x = map(int, input().split())\nprint(\"YES\" if a <= x and a + b >= x else \"NO\")", "a, b, x = list(map(int, input().split()))\nif a <= x <= a+b:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a, b, c = map(int, input().split())\nif c >= a and c <= a + b:\n print('YES')\nelse:\n print('NO')", "A,B,X = map(int,input().split())\ns = \"YES\"\nif A > X or A+B < X:\n s = \"NO\"\nprint(s)", "a,b,x=map(int,input().split())\nprint(\"NO\")if a+b<x or x<a else print(\"YES\")", "a, b, x = map(int, input().split())\nif a+b < x or a > x:\n print(\"NO\")\nelse:\n print(\"YES\")", "a,b,x = map(int,input().split())\nif a > x:\n print(\"NO\")\nelif a + b < x:\n print(\"NO\")\nelse:\n print(\"YES\")", "a,b,x=map(int,input().split())\nans=\"YES\" if x<=a+b and x>=a else \"NO\"\nprint(ans)", "a, b, c = map(int, input().split())\nif a <= c and c <= a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "A,B,X = map(int,input().split())\nprint(\"YES\" if A <= X <= A+B else \"NO\")", "a,b,x=map(int,input().split())\nif a<=x<=a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,x=map(int,input().split())\nif a==x:print(\"YES\")\nelif a<x and a+b>=x:print(\"YES\")\nelse:print(\"NO\")", "a=input().split(' ')\nA=int(a[0])\nB=int(a[1])\nX=int(a[2])\nif A<=X and A+B>=X:\n print('YES')\nelse:\n print('NO')", "a,b,x = map(int,input().split())\nif x - a < 0:\n print(\"NO\")\nelse:\n print((\"NO\",\"YES\")[x-a<=b])", "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nif a+b>=c:\n if a<=c:\n print(\"YES\")\n else:\n print(\"NO\")\nelse:\n print(\"NO\")", "a, b, x = map(int, input().split())\nif a <= x <= a + b:\n print('YES')\nelse:\n print('NO')", "def resolve():\n a, b, x = map(int, input().split())\n ans = \"\"\n if a <= x and x <= a+b:\n ans = \"YES\"\n else:\n ans = \"NO\"\n print(ans)\nresolve()", "A, B, X = [int(i) for i in input().split()]\n\nif A <= X <= A + B:\n print('YES')\nelse:\n print('NO')\n", "a,b,x = map(int, input().split())\nif a<=x<=a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,x=map(int,input().split())\nif a>x or x>a+b:\n print(\"NO\")\nelse:\n print(\"YES\")", "#!/usr/bin/env python3\n\na, b, x = list(map(int, input().split()))\n\nif a+b >= x and x >= a:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a,b,x = map(int,input().split())\n\nif a>x:\n print('NO')\nelse:\n if x-a <= b:\n print('YES')\n else:\n print('NO')", "# coding: utf-8\nimport math\n\ncat, meta, x = map(int, input().split())\n\nif cat > x or cat + meta < x:\n print(\"NO\")\nelse:\n print(\"YES\")", "a,b,x=map(int,input().split())\nif a<=x<=a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, x = map(int, input().split())\n\nif a <= x:\n print(\"YES\" if a + b >= x else \"NO\")\nelse:\n print(\"NO\")", "a,b,c=map(int,input().split(\" \"))\nprint(\"YES\") if a<=c and a+b>=c else print(\"NO\")", "a,b,x = map(int,input().split())\nprint(\"YES\" if a<=x and a+b-x>0 else \"NO\")", "a, b, x = map(int,input().split())\nif a<=x and a+b>=x:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,x=map(int,input().split())\nif x>a+b or x<a:\n print(\"NO\")\nelse:\n print(\"YES\")", "a,b,x=map(int, input().split())\nprint('NO' if x<a or x>a+b else 'YES')", "a,b,x=map(int,input().split())\nif a<=x and x<=a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, x = map(int, input().split())\nif a<=x<=a+b:\n print('YES')\nelse:\n print('NO')", "A,B,X=map(int,input().split())\nans=\"NO\"\nif A<=X<=A+B:\n ans=\"YES\"\nprint(ans)", "a,b,x=map(int,input().split())\nif a<=x<=a+b:print(\"YES\")\nelse:print(\"NO\")", "a,b,x=list(map(int,input().split()))\nif a>x:\n print('NO')\nelif a+b>=x:\n print('YES')\nelse:\n print('NO')\n", "a,b,x = map(int,input().split())\n\nif a <= x and a + b >= x:\n print('YES')\nelse:\n print('NO')", "a,b,c = map(int,input().split())\nif a <= c and a+b >= c:\n print('YES')\nelse:\n print('NO')", "a, b, x = map(int, input().split())\nif a > x:\n print('NO')\nelif a+b >= x:\n print('YES')\nelse:\n print('NO')", "a,b,x = list(map(int, input().split()))\n\n\nprint(('YES' if x <= a+b and a <= x else 'NO'))\n", "a, b, x =map(int,input().split())\n\n\nif a <= x and (a+b) >= x:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,x = map(int, input().split())\nif a <= x <= a+b:\n print('YES')\nelse:\n print('NO')", "a,b,x=list(map(int, input().split()))\n\nif (a+b)>=x>=a:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a,b,c=list(map(int,input().split()))\nif a<=c:\n if a+b>=c:\n print('YES')\n else:\n print('NO')\nelse:\n print('NO')\n", "a, b, x = list(map(int, input().split()))\nif (x >= a) and (x <= a + b):\n print('YES')\nelse:\n print('NO')\n", "A, B, X = map(int, input().split())\nif X >= A and X <= A+B:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, x = list(map(int, input().split()))\n\n\nif 0 <= x - a <= b:\n print(\"YES\")\nelse:\n print(\"NO\")", "A, B, X = map(int, input().split())\n\nif X >= A and A + B >= X:\n print('YES')\nelse:\n print('NO')", "A, B, X = list(map(int, input().split()))\nif A + B < X or A > X:\n print('NO')\nelse:\n print('YES')\n", "A,B,X=map(int,input().split())\nif A+B>=X:\n if X<A :\n print('NO')\n else :\n print('YES')\nelse :\n print('NO')", "a,b,n=map(int,input().split())\nif a<=n and n<=a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "A,B,X = map(int,input().split())\nprint(\"YES\" if A <= X and A + B >= X else \"NO\")", "a, b, x = map(int, input().split())\nprint(\"YES\" if a <= x <= a + b else \"NO\")", "a,b,x = map(int,input().split())\nif a > x:\n print('NO')\nelif x - a < b:\n print('YES')\nelse:\n print('NO')", "lst = input().split()\na = int(lst[0])\nb = int(lst[1])\nx = int(lst[2])\n\nif (x <= a + b) and (a <= x):\n print('YES')\nelse:\n print('NO')", "a,b,x=map(int,input().split())\nif(a>x):\n print(\"NO\")\nelif(a+b<x):\n print(\"NO\")\nelse:\n print(\"YES\")", "a,b,x=map(int,input().split())\nprint(\"YES\" if a<=x<=a+b else \"NO\")", "a,b,c = [int(x) for x in input().split()]\nres = \"YES\"\nif a > c:\n res = \"NO\"\nif a + b < c:\n res = \"NO\"\nprint(res)", "a,b,x = map(int,input().split())\nif a <= x and a+b >= x:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,x = map(int,input().split())\nif x>=a and x<=a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,x = map(int,input().split())\nprint(\"YES\" if a+b >= x and a <= x else \"NO\")", "def main():\n a, b, x = list(map(int, input().split()))\n print(('YES' if a <= x and a + b >= x else 'NO'))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "A, B, X = map(int, input().split())\n\nif 0 <= X - A <= B:\n print('YES')\nelse:\n print('NO')", "a,b,x=map(int,input().split())\nif a<=x<=a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, x = map(int, input().split())\nif a == x or (a + b >= x and a < x):\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,x=map(int,input().split())\n\nif a<=x and a+b>=x:\n ans=\"YES\"\nelse:\n ans=\"NO\"\nprint(ans)", "a,b,x = map(int,input().split())\nif a <= x and a+b >= x:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, x = map(int, input().split())\n\nif a <= x <= a + b:\n print('YES')\nelse:\n print('NO')", "A,B,X=map(int,input().split())\nif X < A or A+B < X:\n print('NO')\nelse:\n print('YES')", "a, b, x = list(map(int, input().split()))\nif a + b >= x and a <= x:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "A,B,X=list(map(int,input().split()))\nif A<=X and X<=A+B:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a,b,x=map(int,input().split())\nif a+b >= x and a <= x:\n print('YES')\nelse:\n print('NO')", "A,B,X = list(map(int,input().split()))\nif A>X:\n print(\"NO\")\nif A<=X:\n if (A +B)<X:\n print(\"NO\")\n else:\n print(\"YES\")\n", "a,b,x=list(map(int,input().split()))\nc=a+b\n\n\nif x<=c:\n if a>x:\n print('NO')\n else:\n print('YES')\nelse:\n print('NO')\n", "A, B, X = map(int, input().split())\nfor i in range(0, B + 1):\n if A + i == X:\n print(\"YES\")\n return\nprint(\"NO\")", "a,b,x = map(int,input().split())\nif a <= x <= a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "#ABC094A\na,b,x = map(int,input().split())\nprint(\"YES\" if a<=x <= a+b else \"NO\")", "a,b,x = list(map(int, input().split()))\n\nif a + b < x :\n print(\"NO\")\n\nelif a > x :\n print(\"NO\")\n\nelse :\n print(\"YES\")\n \n", "a, b, x = map(int, input().split())\nif a <= x <= a + b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a,b,x = map(int,input().split())\nif a<=x and x<=a+b:\n print(\"YES\")\nelse:\n print(\"NO\")", "a, b, x = map(int, input().split())\nprint('YES' if a <= x <= a + b else 'NO')", "cat_num, unknown_animals, question_num_cat = map(int, input().split())\n\nif cat_num <= question_num_cat <= cat_num + unknown_animals:\n print('YES')\nelse:\n print('NO')", "a, b, x = map(int, input().split())\n\nif a+b>=x and a<=x:\n print('YES')\nelse:\n print('NO')", "a,b,x = map(int,input().split())\n\nif a+b >= x and a <= x:\n print(\"YES\")\nelse:\n print(\"NO\")", "A,B,X = map(int, input().split())\nif X >= A and B >= (X-A):\n print('YES')\nelse:\n print('NO')"]
{"inputs": ["3 5 4\n", "2 2 6\n", "5 3 2\n"], "outputs": ["YES\n", "NO\n", "NO\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
11,057
6c10059ba552af0fa276768778f7aff8
UNKNOWN
We have a sandglass that runs for X seconds. The sand drops from the upper bulb at a rate of 1 gram per second. That is, the upper bulb initially contains X grams of sand. How many grams of sand will the upper bulb contains after t seconds? -----Constraints----- - 1≀X≀10^9 - 1≀t≀10^9 - X and t are integers. -----Input----- The input is given from Standard Input in the following format: X t -----Output----- Print the number of sand in the upper bulb after t second. -----Sample Input----- 100 17 -----Sample Output----- 83 17 out of the initial 100 grams of sand will be consumed, resulting in 83 grams.
["x, t = list(map(int, input().split()))\nprint((max(0, x - t)))\n", "a,b=list(map(int,input().split()))\nif a <= b:\n print((0))\nelse:\n print((a-b))\n", "from collections import Counter,defaultdict,deque\nfrom heapq import heappop,heappush,heapify\nimport sys,bisect,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\nx,t = inpl()\nprint(max(x-t,0))", "X,t = list(map(int,input().split()))\n\nif X > t:\n print((X-t))\nelse:\n print((0))\n", "# AtCoder abc072 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\nx, t = list(map(int, input().split()))\n\n# \u51e6\u7406\nif (x -t) <= 0:\n print((0))\nelse:\n print((x - t))\n", "x, t = map(int, input().split())\n\nif x <= t:\n print(0)\nelse:\n print(x -t)", "X, t = map(int, input().split())\nprint(max(X-t, 0))", "# 072_a\nX,t=map(int,input().split())\nif (1<=X and X<=10**9) and (1<=t and t<=10**9):\n if X<=t:\n print(0)\n else:\n print(X-t)", "# \u5165\u529b\nX, t = map(int, input().split())\n\n# X\u304ct\u3088\u308a\u5c0f\u3055\u3044\u306a\u30890\u3001\u305d\u3046\u3058\u3083\u306a\u3044\u306a\u3089X-t\u306e\u7d50\u679c\u3092\u51fa\u529b\nif X < t:\n print(0)\nelse:\n print(X - t)", "x,t = list(map(int,input().split()))\nprint((max(x-t,0)))\n", "x, t = map(int, input().split())\nprint(x-t if x>=t else 0)", "x, t= map(int, input().split())\nprint(max(x-t, 0))", "#\n# abc072 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 = \"\"\"100 17\"\"\"\n output = \"\"\"83\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"48 58\"\"\"\n output = \"\"\"0\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"1000000000 1000000000\"\"\"\n output = \"\"\"0\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n X, t = list(map(int, input().split()))\n print((max(X-t, 0)))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "X, t = map(int, input().split())\nprint(X-t if t<X else 0)", "X,t=list(map(int,input().split()))\nprint((max(0,X-t)))\n", "def LI():\n return list(map(int, input().split()))\n\n\nX, t = LI()\nans = max(X-t, 0)\nprint(ans)\n", "import sys\n\nsys.setrecursionlimit(10 ** 7)\ninput = sys.stdin.readline\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n x, t = list(map(int, input().split()))\n print((max(0, x - t)))\n\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "x,t=map(int,input().split())\nprint(max(0,x-t))", "x,t=map(int,input().split())\n\nprint(max((x-t),0))", "x, t = list(map(int, input().split()))\n\ndef answer(x: int, t: int) -> int:\n if x > t:\n return x - t\n else:\n return 0\n\nprint(answer(x, t))", "def iroha():\n x,t = list(map(int, input().split()))\n print((0 if t >= x else x-t))\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "def main():\n X,t = list(map(int,input().split()))\n tmp = X-t\n if tmp<0:\n return 0\n else:\n return tmp\n\nprint((main()))\n", "X, t = list(map(int, input().split()))\n\nif X - t >= 0:\n print((X - t))\nelse:\n print('0')\n", "a,b = map(int,input().split())\nif a - b > 0:\n print(a - b)\nelse:\n print(0)", "x,t=map(int,input().split())\n\nif x<=t:\n print(0)\nelse:\n print(x-t)", "x,t=map(int,input().split())\nif x-t>0:\n print(x-t)\nelse:\n print(0)", "X, t = list(map(int, input().split()))\nprint((max(X - t, 0)))\n", "x, t = map(int, input().split())\nprint(max(0, x - t))", "x,t = list(map(int,input().split()))\nprint(( x-t if x-t > 0 else 0))\n", "X, t = map(int, input().split())\nprint(X - t if X - t >= 0 else 0)", "X, t = map(int, input().split())\nif X < t:\n print(0)\nelse:\n print(X - t)", "# \u5165\u529b\nX, t = map(int, input().split())\n\n# \u51fa\u529b\nif X <= t:\n print(0)\nelse:\n print(X - t)", "x,t=map(int,input().split())\nprint(x-t if x>=t else 0)", "a,b=map(int,input().split())\nif a-b>0:\n print(a-b)\nelse:\n print(0)", "X, t = map(int,input().split())\nanswer = int( X - t )\nif answer > 0:\n print(answer)\nelse:\n print(0)", "X,t = map(int,input().split())\nans = X-min(X,t)\nprint(ans)", "import sys\n\nX, t = map(int, sys.stdin.readline().split())\nprint(max(0, X - t))", "x,t=map(int,input().split())\nif x>=t:\n print(x-t)\nelse:\n print(0)", "x, t = map(int, input().split())\nprint(max(0, x - t))", "a,b=map(int,input().split())\nprint(max(0,a-b))", "X, t = list(map(int, input().split()))\nprint((max(X-t,0)))\n", "x,t = map(int,input().split())\nprint(x-t if x>t else 0)", "a, b = map(int, input().split())\n\nif a > b:\n print(a - b)\nelse:\n print(0)", "a,b=map(int,input().split())\n \nc=a-b\n\nif c<0:\n print(0)\nelse:\n print(c)", "x,t=map(int,input().split())\nif x<t:\n print(0)\nelse:\n print(x-t)", "x, t = list(map(int, input().split()))\nif x - t >= 0:\n print((x - t))\nelse:\n print((0))\n", "X, t = map(int, input().split())\nprint(max(X-t,0))", "n = [int(x) for x in input().split()]\nprint(max(0,n[0]-n[1]))", "X, t=map(int, input().split(\" \"))\n\nprint(max(X-t, 0))", "\nx,t = map(int,input().split())\nif x-t <= 0:\n print('0')\nelse:\n print(x-t)", "a,b = map(int,input().split())\nprint(max(a-b,0))", "x, t = map(int, input().split())\n\nprint(max(x - t, 0))", "x,t=map(int,input().split())\nprint(x-t) if x-t>=0 else print(0)", "# \u5165\u529b\nX, t = map(int,input().split())\n# \u51e6\u7406\nanswer = X - t\nif X <= t:\n print(0)\nelse:\n print(answer)", "X, t = map(int, input().split())\n\nprint(max(X-t, 0))", "X, x = list(map(int, input().split()))\n\nif X - x < 0:\n print((0))\nelse:\n print((X - x))\n", "A,B=list(map(int,input().split()))\nprint(A-B if A-B>0 else 0)", "x, t = map(int, input().split())\nprint(x - t if x >= t else 0)", "# A - Sandglass2\n\n# X\u79d2\u6e2c\u308c\u308b\u7802\u6642\u8a08\u3067\u3001t\u79d2\u5f8c\u306b\u6b8b\u3063\u3066\u3044\u308b\u7802\u306f\u4f55\u30b0\u30e9\u30e0\u304b\n\n\nX,t = list(map(int,input().split()))\n\nif X <= t:\n print('0')\nelse:\n print((X - t))\n", "X, t = map(int, input().split())\n\nprint(X - t if X - t >= 0 else 0)", "a,b = map(int,input().split())\n\nprint(0 if a-b <= 0 else a-b)", "a, b = map(int, input().split())\nc = a - b\nif c < 0:\n print(0)\nelse:\n print(c)", "X, t = map(int, input().split())\n\nif X <= t:\n print(0)\nelse:\n print(X - t)", "X, t = map(int, input().split())\nprint(max(X-t, 0))", "lst = input().split()\n\nd = int(lst[0]) - int(lst[1])\n\nif 0 <= d:\n print(d)\nelse:\n print(0)", "# \u554f\u984c\u6587\n# X\u79d2\u3092\u6e2c\u308c\u308b\u7802\u6642\u8a08\u304c\u3042\u308a\u307e\u3059\u3002\n# \u306f\u3058\u3081\u4e0a\u306e\u30d1\u30fc\u30c4\u306b\u7802\u304c X[g] \u3042\u308a\u30011\u79d2\u9593\u306b 1[g] \u7802\u304c\u843d\u3061\u307e\u3059\u3002\n# \u306a\u304a\u3001\u4e0a\u306e\u30d1\u30fc\u30c4\u306b\u3082\u3046\u7802\u304c\u6b8b\u3063\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u7802\u306f\u843d\u3061\u307e\u305b\u3093\u3002\n# t\u79d2\u5f8c\u306b\u4e0a\u306e\u30d1\u30fc\u30c4\u306b\u6b8b\u3063\u3066\u3044\u308b\u7802\u306f\u4f55g\u3067\u3057\u3087\u3046\u3002\n\n# x\uff08\u79d2\uff09\u3001t\uff08\u79d2\u5f8c\uff09\uff1a\u6a19\u6e96\u5165\u529b\uff08\u6570\u5024\uff09\nx,t = map(int, input().split())\n\n# x>t\u306e\u6642\u3001\u7802\u304c\u6b8b\u3063\u3066\u3044\u308b x-t\u304c\u5b58\u5728\u3059\u308b\n# x<=t\u306e\u6642\u3001\u7802\u306f\u6b8b\u3063\u3066\u304a\u3089\u305a\u7802\u306f\u843d\u3061\u306a\u3044\nweight = 0\nif x > t:\n weight = x - t\nelse:\n weight = 0\n\nprint(weight)", "a,b = map(int,input().split())\nprint((a-b,0)[a<b])", "X,t = map(int,input().split())\nprint(max(X-t,0))", "x, t = map(int, input().split())\n\n\nprint(max(x-t,0))", "X, t = map(int, input().split())\nx = X - t\n \nif x > 0:\n print(x)\nelse:\n print(0)", "x,t = map(int,input().split())\nprint(max(x-t,0))", "X, t = map(int,input().split())\n\nif t >= X:\n print(\"0\")\nelse:\n print(X - t)", "a,b = map(int,input().split())\n\nif a < b:\n print(0)\nelse:\n print(a-b)", "X, t = map(int, input().split())\n\nif X >= t:\n print(X - t)\nelse:\n print(0)", "X, t = map(int, input().split())\n\nif X - t <= 0:\n print(0)\nelse:\n print(X - t)", "X,t=map(int,input().split())\nif X-t<0 :\n print(0)\nelse :\n print(X-t)", "x, t = map(int , input().split())\nif t >= x:\n print(0)\nelse:\n print(x-t)", "# X\u79d2\u3092\u6e2c\u308c\u308b\u7802\u6642\u8a08\u304c\u3042\u308a\u307e\u3059\u3002\n# \u306f\u3058\u3081\u4e0a\u306e\u30d1\u30fc\u30c4\u306b\u7802\u304c X[g] \u3042\u308a\u30011\u79d2\u9593\u306b 1[g] \u7802\u304c\u843d\u3061\u307e\u3059\u3002\n# \u306a\u304a\u3001\u4e0a\u306e\u30d1\u30fc\u30c4\u306b\u3082\u3046\u7802\u304c\u6b8b\u3063\u3066\u3044\u306a\u3044\u5834\u5408\u306f\u7802\u306f\u843d\u3061\u307e\u305b\u3093\u3002\n# t\u79d2\u5f8c\u306b\u4e0a\u306e\u30d1\u30fc\u30c4\u306b\u6b8b\u3063\u3066\u3044\u308b\u7802\u306f\u4f55g\u3067\u3057\u3087\u3046\u3002\n\n# \u5236\u7d04\n# 1 \u2266 X \u2266 1000000000\n# 1 \u2266 t \u2266 1000000000\n# X, t \u306f\u6574\u6570\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 X, t\u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\nx, t = list(map(int, input().split()))\n\n# t\u79d2\u5f8c\u306e\u7802\u306e[g]\u30b0\u30e9\u30e0\u6570\u3092\u8a08\u7b97\u3057\u3001\u51fa\u529b\u3059\u308b\nresult = 0\n\nif x > t: # x\u304ct\u3088\u308a\u5927\u304d\u3044\u5834\u5408\u306f\u3001\u6b8b\u308ax - t[g]\n result = x - t\nelse:\n result = 0 # t\u306e\u65b9\u304c\u5927\u304d\u3044\u5834\u5408\u306f\u6b8b\u308a 0[g]\n\nprint(result)\n", "X,t = map(int,input().split())\n\nif X - t > 0:\n print(X - t)\n\nelse:\n print('0')", "x,t = map(int, input().split())\nprint(x-t if x-t >= 0 else 0)", "x, t = map(int, input().split())\n\nanswer = x - t\n\nif answer <= -1:\n print(0)\nelse:\n print(answer)", "#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())\nX,t = readInts()\nprint((0 if X <= t else X-t))\n", "s,t = map(int,input().split())\nans = s-t\nif ans < 0:\n print(0)\nelse:\n print(ans)", "# A - Sandglass2\n# https://atcoder.jp/contests/abc072/tasks/abc072_a\n\nX, t = list(map(int, input().split()))\n\nresult = X - t\n\nif result < 0:\n result = 0\n\nprint(result)\n", "x, t = map(int, input().split())\nif x > t:\n print(x - t)\nelse:\n print(0)", "x, t = list(map(int, input().split()))\nprint((0 if x <= t else x - t))\n", "X, t = list(map(int, input().split()))\nprint((max(0, X - t)))\n", "X, t = map(int, input().split())\n\nprint(X - t if X > t else 0)", "x,t=map(int, input().split()) \nprint(x-t if x-t>=0 else 0)", "x,t = map(int, input().split())\nif x > t:\n print(x- t)\nelse:\n print(0)", "x,t=map(int,input().split())\nprint(max(0,x-t))", "a, b = map(int, input().split())\nx = a -b\nif x >= 0:\n print(x)\nelse:\n print(0)", "x, t = map(int, input().split())\nf = lambda x: x if x > 0 else 0\nprint(f(x-t))", "x,t = map(int,input().split())\n\nprint(x-t) if x > t else print(0)\n", "# Xg\u3042\u308b\u7802\u304c1\u79d2\u306b1g\u843d\u3061\u308b\u7802\u6642\u8a08 t\u79d2\u5f8c\u306b\u4f55g\u6b8b\u308b\u304b\n\nX, t = map(int, input().split())\nx = X - t\n\nif x > 0:\n print(x)\nelse:\n print(0)", "x,t = map(int, input().split())\nprint(max(x-t,0))", "#\nx,t=map(int,input().split())\nif x-t>0:\n print(x-t)\nelse:\n print(0)"]
{"inputs": ["100 17\n", "48 58\n", "1000000000 1000000000\n"], "outputs": ["83\n", "0\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,197
b4b3697e0bed56ebe8ac9312ec078b86
UNKNOWN
Given N integers A_1, ..., A_N, compute A_1 \times ... \times A_N. However, if the result exceeds 10^{18}, print -1 instead. -----Constraints----- - 2 \leq N \leq 10^5 - 0 \leq A_i \leq 10^{18} - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N A_1 ... A_N -----Output----- Print the value A_1 \times ... \times A_N as an integer, or -1 if the value exceeds 10^{18}. -----Sample Input----- 2 1000000000 1000000000 -----Sample Output----- 1000000000000000000 We have 1000000000 \times 1000000000 = 1000000000000000000.
["a=1\nfor i in[*open(0)][1].split():a*=int(i);a=[-1,a][0<=a<=10**18]\nprint(a)", "from typing import List\n\n\ndef answer(n: int, a: List[int]) -> int:\n if 0 in a:\n return 0\n\n max_value = 10 ** 18\n product = 1\n for i in a:\n product *= i\n if max_value < product:\n return -1\n\n return product\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()", "N = int(input())\nA = list(map(int,input().split()))\nans = 1\nA.sort()\n\nfor i in range(N):\n ans *= A[i]\n if ans > 1e18:\n print(-1)\n return\n\nprint(ans)", "i=input;i();l=i().split();x=1-('0'in l)\nfor j in l:\n x*=int(j)\n if x>1e18:x=-1;break\nprint(x)\n", "input();l=input().split();x=not\"0\"in l\nfor j in l:x=x*int(j)if 0<=x*int(j)<=1e18else-1\nprint(x)", "N = int(input())\nA = list(map(int, input().split()))\n\nif 0 in A:\n print(0)\n return\nelse:\n flag = True\n prd = 1\n A.sort(reverse=True)\n for i in range(N):\n prd *= A[i]\n if prd > 10**18:\n flag = False\n break\nif flag:\n print(prd)\nelse:\n print(-1)", "n = int(input())\naa = list(map(int, input().split()))\n\nif 0 in aa:\n print('0')\n return\n\nresult = 1\nfor a in aa:\n result *= a\n if result > pow(10, 18):\n print('-1')\n return\n\nprint(result)\n", "n=int(input())\nl=list(map(int,input().split()))\n# print(l)\nans=1\nif 0 in l:\n print(0)\n return\nfor i in l:\n ans*=i\n if ans> 10**18:\n # print(ans)\n print(-1)\n return\nprint(ans)", "a,b=open(0);c=1;\nfor i in b.split():c=[-1,d:=int(i)*c][-1<d<=10**18]\nprint(c)", "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\nn= i_input()\naa=i_list()\naa.sort()\nans=1\nfor a in aa:\n ans*=a\n if ans>10**18:\n ans=-1\n break\nprint(ans)", "n = int(input())\na = list(map(int,input().split()))\n\nans = 1\nif 0 in a:\n print((0))\n return\nelse:\n for i in a:\n ans *= i\n if ans > 10**18:\n print((-1))\n return\n\nprint(ans)\n", "import math\n\n\ndef main():\n n = int(input())\n aList = list(map(int, input().split()))\n sumA = 1\n if aList.count(0) > 0:\n print((0))\n return\n for a in aList:\n sumA *= a\n if sumA > 10 ** 18:\n print((-1))\n return\n print(sumA)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import sys\n\nn = int(input())\nA = sorted(list(map(int,input().split())))\nans = 1\n\nif A[0] == 0:\n print((0))\nelse:\n for i in range(len(A)):\n ans *= A[i]\n if ans > 10**18:\n print((-1))\n return\n print(ans)\n", "i=input;i();l=i().split();x=1-('0'in l)\nfor j in l:\n x*=int(j);\n if x>1e18:x=-1;break\nprint(x)", "N=int(input())\na=list(map(int,input().split()))\nsum_=1\nif 0 in a:\n print (0)\nelse:\n for i in range(N):\n sum_ *= a[i]\n if sum_> 10**18:\n sum_ =-1\n break\n print(sum_)", "a,b=open(0);c=1;\nfor i in sorted(b.split()):c=[-1,d:=int(i)*c][-1<d<=10**18]\nprint(c)", "a=1\nfor i in[*open(0)][1].split():a*=int(i);a=[-1,a][-2<a-1<1e18]\nprint(a)", "import sys\n\ninput = sys.stdin.readline\nN = int(input())\nA = list(map(int, input().split()))\n\nif 0 in A:\n print(0)\nelse:\n ans = 1\n for a_i in A:\n ans *= a_i\n if ans > 10**18:\n print(-1)\n return\n print(ans)", "n = int(input())\naaa = sorted(map(int, input().split()))\nans = 1\nlimit = 10 ** 18\nfor a in aaa:\n ans *= a\n if ans > limit:\n ans = -1\n break\nprint(ans)", "\ndef i_input(): return int(input())\ndef i_map(): return map(int, input().split())\ndef i_list(): return list(map(int, input().split()))\ndef i_row(N): return [int(input()) for _ in range(N)]\ndef i_row_list(N): return [list(map(int, input().split())) for _ in range(N)]\n\nn=i_input()\naa=i_list()\naa.sort()\nans=1\ninf=10**18\nfor a in aa:\n ans*=a\n if ans>inf:\n ans=-1\n break\nprint(ans)", "n = int(input())\nmod = 10**18\nli = list(map(int, input().split()))\nli.sort()\nans = 1\nfor i in range(n):\n ans *= li[i]\n if ans > mod:\n ans = -1\n break\nprint(ans)\n", "N = int(input())\nA = list(map(int,input().split()))\nAA = 1\n\nif 0 in A:\n print(0)\n return\n\nfor i in range(N):\n AA *= A[i]\n if AA > 10**18:\n print(-1)\n return\n\nprint(AA)", "a,b=open(0);c=1;\nfor i in sorted(b.split()):\n c*=int(i)\n if c>10**18:c=-1;break\nprint(c)", "i=input;i();l=i().split();x=1-('0'in l)\nfor j in l:\n x*=int(j)\n if x>1e18:x=-1;break\nprint(x)\n", "N = int(input())\nA = list(map(int,input().split()))\nans = 1\nif 0 in A:\n print(0)\n return\n \nfor i in range(N):\n ans *= A[i]\n if ans > 10**18:\n print(-1)\n return\n\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\n\nif 0 in A:\n print(0)\n return\nproduct = 1\nfor num in A:\n product = product * num\n if product > 10 ** 18:\n print(-1)\n return\n\nprint(product)", "a=1\nfor i in[*open(0)][1].split():a=[-1,a:=a*int(i)][-1<a<=1e18]\nprint(a)", "N = int(input())\nA = list(map(int,input().split()))\nresult = 1\nif 0 in A:\n print(0)\nelse:\n for i in A:\n result *= i\n if result > 10 ** 18:\n print(\"-1\")\n break\n else:\n print(result)", "num=int(input())\nline=input().split(\" \")\nchecklis=sorted(line)\nif checklis[0]==\"0\":\n res=0\nelse:\n res=1\n i=0\n while res<=1000000000000000000 and i<num:\n res *= int(line[i])\n i+=1\n \n if res>1000000000000000000:\n res= -1\n \nprint(res)\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect\n#from operator import itemgetter\n#from heapq import heappush, heappop\n#import numpy as np\n#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson\n#from scipy.sparse import csr_matrix\n#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN\nimport sys\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nnf = lambda: float(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnb = lambda: list(map(float, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nmax_ = 10 ** 18\nN = ni()\nA = na()\nA.sort()\nans = 1\nfor i in range(N):\n ans *= A[i]\n if ans > max_:\n ans = -1\n break\nprint(ans)", "n = int(input())\na = list( map (int , input().split() ) )\na.sort()\nans = 1\nfor i in range(n):\n ans*=a[i]\n if ans>10**18:\n print((-1))\n return\n\nprint(ans)\n", "n=int(input())\na=sorted([int(x) for x in input().split()])\n\nif a[0]==0: print(0); return\nans=1\nfor ai in a:\n ans*=ai\n if ans>10**18: print(-1); break\nelse:\n print(ans)", "N=int(input())\na=list(map(int,input().split()))\n\nans=1\nif (0 in a):\n\tprint(0)\nelse:\n\tfor i in range(0,N):\n\t\tans=ans*a[i]\n\t\tif ans > 10**18:\n\t\t\tprint(-1)\n\t\t\tbreak\n\n\tif ans <= 10**18:\n\t\tprint(ans)", "n = int(input())\na = list(map(int, input().split()))\ndef solve(a):\n ans = 1\n if 0 in a:\n return 0\n for i in a:\n ans *= i\n if ans > pow(10, 18):\n return -1\n return ans\nans = solve(a)\nprint(ans)", "a,b=open(0);c=1;\nfor i in sorted(b.split()):c=[d:=int(i)*c,-1][10**18<d or c<0]\nprint(c)", "n = input()\na = list(map(int,input().split()))\nMX = 10**18\nans = 1\nfor i in a:\n if i == 0:\n print(0)\n return\nfor i in a:\n ans *= i\n if ans > MX:\n print(-1)\n return\nprint(ans)", "def calc():\n n = int(input())\n\n a = list(map(int, input().split()))\n\n \n if 0 in a:\n print(0)\n return \n\n ans = 1\n\n for i in range(len(a)):\n ans *= a[i]\n if ans > 10 ** 18:\n print(-1)\n return \n print(ans)\n\n\ncalc()", "N = int(input())\nA = list(map(int, input().split()))\n\n\ndef ans():\n if 0 in A:\n return print(0)\n product = 1\n for num in A:\n product = product * num\n if product > 10 ** 18:\n return print(-1)\n\n print(product)\n\n\nans()", "input();a=1\nfor i in input().split():a*=int(i);a=[-1,a][0<=a<=10**18]\nprint(a)", "i=input;i();l=i().split();x=1-('0'in l)\nfor j in l:\n x*=int(j)\n if x>1e18:\n x=-1;break\nprint(x)\n", "_,b=open(0);a=1\nfor i in b.split():a*=int(i);a=[-1,a][-1<a<=1e18]\nprint(a)", "n= int(input())\na = list(map(int,input().split()))\nscore=1\nif 0 in a:\n print(0)\n return\nfor i in a:\n score*=i\n if score>10**18:\n print(-1)\n return\nprint(score)", "n = input()\na = list(map(int,input().split()))\na.sort()\np = 1\nif a[0] == 0:\n ans = 0\nelse:\n for i in a:\n p *= i\n if p >10**18:\n ans = -1\n break\n ans = p\nprint(ans)", "n = int(input())\nA = sorted(list(map(int, input().split())))\nans = 1\nfor a in A:\n ans *= a\n if ans > 10**18:\n ans = -1\n break\nprint(ans)\n", "n=int(input())\na=list(map(int ,input().split()))\na=sorted(a)\nres=1\nfor i in range(n):\n res*=a[i]\n if res>10**18:\n res=-1\n break\nprint(res)", "n = int(input())\na = list(map(int,input().split()))\n\nif 0 in a:\n print(0)\n return\n\nans = 1\nfor i in a:\n ans *= i\n if(ans > 10**18):\n print(-1)\n return\n\nprint(ans)", "import random\nimport time\nimport copy\nimport io, sys\n\n#def pow(a, b):\n# res = 1;\n# for ()\n\nn = int(input())\na = list(map(int,input().split()))\n\nsum = 1\nfor a_ in a:\n if (sum != -1): sum *= a_\n if sum != 0 and sum > pow(10, 18):\n sum = -1\n if a_ == 0:\n sum = 0\n break\n\nprint(sum)\n", "N = int(input())\nA = [int(i) for i in input().split()]\nans = 1\nif(0 in A):\n print(0)\n return\nfor i in range(N):\n ans *= A[i]\n if(ans > 10 ** 18):\n print(-1)\n return\nprint(ans)", "N = int(input())\n\nA = list(map(int, input().split()))\nB = 0\nC = 1\n\nif 0 in A:\n print(0)\n return\n\nfor i in range(N):\n C = C * A[i]\n if C > 1000000000000000000:\n print(-1)\n return\n\nprint(C)", "n=int(input())\na=list(map(int,input().split()))\ns=1000000000000000000\nk,c=1,0\nfor i in a:\n if k*i>s:\n c=1\n break\n k*=i\nif 0 in a:\n print(0)\n \nelif c==0:\n print(k)\nelse:\n print(-1)", "N = int(input())\nA = list(map(int, input().split()))\n\nresult = 1\nA = sorted(A)\n\nfor i in A:\n result *= i\n if result > 10 ** 18:\n print((-1))\n break\nelse:\n print(result)\n\n\n", "n = int(input())\nal = list(map(int, input().split()))\nans = 1\n\nif al.count(0) > 0:\n print(0)\nelse:\n for a in al:\n ans *= a\n if ans > 10**18:\n print(-1)\n return\n print(ans)", "a=1;d=10**18\nfor i in[*open(0)][1].split():a=min(a*int(i),d+1)\nprint([a,-1][a>d])", "n = int(input())\n\nalst = list(map(int, input().split()))\nif 0 in alst:\n print(0)\n return\n \nelse:\n ans = 1\n for i in range(n):\n ans *= alst[i]\n if ans > 10**18:\n print('-1')\n return\n\n print(ans)", "i=input;i();l=i().split();x=not '0' in l\nfor j in l:\n x*=int(j)\n if x>1e18:\n print((-1));return\nprint(x)\n", "n = int(input())\na = list(map(int,input().split()))\n\nans = 1\nif 0 in set(a):\n print((0))\n return\nelse:\n for i in range(n):\n ans *= a[i]\n if ans > 10**18:\n print((-1))\n return\nprint(ans)\n", "input();l=input().split();x=1\nfor j in sorted(l):\n x*=int(j)\n if x>1e18:x=-1;break\nprint(x)", "n = input()\na = list(map(int,input().split()))\nans = 1\na.sort()\nfor i in a:\n ans *= i\n if ans > 1000000000000000000:\n print(-1)\n return\nprint(ans)", "n = int(input())\nli = list(map(int, input().split()))\npr = 1\ngr = 0\nfor l in li:\n pr = pr*l\n if pr>10e17:\n gr = 1\n break\nif gr==1:\n if 0 in li:\n print((0))\n else:\n print(\"-1\")\nelse:\n print(pr)\n", "n=int(input())\nl=list(map(int,input().split()))\nm=1\nl.sort()\nfor i in range(n):\n m *= l[i]\n if m>10**18:\n print(-1)\n return\n \nprint(m)", "i=input;i();l=i().split();x=not'0'in l\nfor j in l:\n x*=int(j);\n if x>1e18:x=-1;break\nprint(x)", "N = int(input())\nA = list(map(int, input().split()))\nA.sort()\nans = 1\n\nfor i in A:\n ans *= i\n if ans > 10 ** 18:\n print((-1))\n break\nelse:\n print(ans)\n\n\n", "from heapq import *\n\nN = int(input())\nAs = list(map(int, input().split()))\nheapify(As)\nwhile len(As) >= 2:\n A1 = heappop(As)\n A2 = heappop(As)\n heappush(As, A1 * A2)\n \nif As[0] > 10 ** 18:\n print((-1))\nelse:\n print((As[0]))\n", "n = int(input())\na = list(map(int, input().split()))\n\nif 0 in a:\n print((0))\n return\n\nm = 10**18\nans = 1\nfor x in a:\n ans *= x\n if ans > m:\n print((-1))\n return\n \nprint(ans)\n\n", "import sys\nN = int(input())\nlsA = list(map(int,input().split()))\nif 0 in lsA:\n print(0)\n return\nans = 1\nfor i in range(N):\n ans *= lsA[i]\n if ans > 10 ** 18:\n print(-1)\n return\nprint(ans)", "n = int(input())\ntmp = list(map(int, input().split()))\ntmp.sort()\nbound = int(10**18)\nans = 1\nfor i in range(0, n):\n ans *= int(tmp[i])\n if (ans > bound):\n print((-1))\n return\nprint(ans)\n", "n=int(input())\na=list(map(int,input().split()))\nfor i in range(n):\n if a[i]==0:\n print(0)\n return\ntmp=1\nfor i in range(n):\n if a[i]<=(int(1e18)//tmp):tmp*=a[i]\n else:\n print(-1)\n return\nprint(tmp)", "n = int(input())\na = list(map(int,input().split()))\nans = 1\nif 0 in a:\n print((0))\nelse:\n for i in range(n):\n ans *= a[i]\n if ans > 10 ** 18:\n print((-1))\n break\n else:\n print(ans)\n", "n = int(input())\n\na = list(map(int, input().split()))\n\nans = 1\n\nif 0 in a:\n print(0)\n return\n\nfor i in range(n):\n ans *= a[i]\n if ans > 10 ** 18:\n print(-1)\n return\n \nprint(ans)", "import sys\n\nn = int(input())\nli = list(map(int,input().split()))\nans = 1\n\nif 0 in li:\n print(0)\n return\n\nfor i in range(n):\n ans = ans * li[i]\n if ans > 10**18:\n print(-1)\n return\n\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A)\nresult = 1\nfor i in range(N):\n result *= A[i]\n if result > 10**18:\n result = -1\n break\nprint(result)", "dontt_use = input()\nstr_list = list(input().split())\nn = map(int,str_list)\n\ndef foo(n):\n total = 1 \n for number in n:\n total = total * number\n if total > 10**18:\n print('-1')\n return\n print(total)\nif '0' in str_list :\n print(0)\nelse:\n foo(n)", "n = int(input())\naaa = sorted(map(int, input().split()), reverse=True)\nif aaa[-1] == 0:\n ans = 0\nelse:\n ans = 1\n limit = 10 ** 18\n for a in aaa:\n ans *= a\n if ans > limit:\n ans = -1\n break\nprint(ans)", "import sys\nn = int(input())\na = list(map(int, input().split()))\n\nif a.count(0) > 0:\n print(\"0\")\n return\n \nans = 1\nfor i in range(n):\n ans *= a[i]\n if ans > 10 ** 18:\n print(\"-1\")\n return\n \nprint(ans)\n", "i=input;i();l=i().split();x=1-('0'in l)\nfor j in l:\n x*=int(j)\n if x>1e18:\n print((-1));return\nprint(x)\n", "n = int(input())\nA = list(map(int, input().split()))\nif 0 in A:\n print(0);return\nans = 1\nfor a in A:\n ans *= a\n if ans > 10**18:\n print(-1);return()\nprint(ans)", "input();ans,a=1,[*map(int,input().split())]\nif 0 in a:\n print(0)\nelse:\n for i in a:\n ans*=i\n if ans>10**18:\n print(-1);break\n else:\n print(ans)", "input();x=1;*A,=map(int,input().split())\nif 0in A:print(0);return\nfor a in A:\n x*=a\n if x>10**18:print(-1);return\nprint(x)", "N = int(input())\nA = list(map(int,input().split()))\nans = 1\nA.sort()\n\nfor i in range(N):\n ans *= A[i]\n if ans > 1e18:\n print(-1)\n break\nelse:\n print(ans)", "for i in[*open(0)][(a:=1)].split():a*=int(i);a=[-1,a][0<=a<=10**18]\nprint(a)", "N = int(input())\nA=list(map(int, input().split()))\n\nconst = 10**18\n\nif 0 in A:\n print(0)\n return\n\nresult = 1\nfor i in A:\n result *= i\n if result>const:\n print(-1)\n return\nprint(result)", "input();l=input().split();x=1\nfor j in sorted(l):\n x*=int(j);\n if x>1e18:x=-1;break\nprint(x)", "n=int(input())\n\nA=list(map(int,input().split()))\nA.sort()\n\nans=int(1)\nfor i in range(n):\n ans*=A[i]\n if(ans>1e18):\n print(-1)\n return\n\nprint(ans)", "input()\n\nn = list(map(int,input().split(\" \")))\nans = int(n[0])\nb = n[1:]\n\nif 0 in n:\n ans = 0\nelse:\n for i in b:\n ans *= int(i)\n \n if ans > 10**18:\n ans = -1\n break\n \nprint(ans)", "n=int(input())\n\nA=list(map(int,input().split()))\nA.sort()\n\nans=int(1)\n\nfor i in range(n):\n ans*=A[i]\n if ans>1e18:\n print(-1)\n return\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\nA.sort()\nresult = 1\nfor i in range(N):\n result *= A[i]\n if result > 10**18:\n result = -1\n break\nprint(result)", "N=int(input())\nA = list(map(int,input().split()))\nanswer=1\n\nif 0 in A:\n print((0))\n return\n\nfor i in range(N):\n answer*=A[i]\n if answer > 10**18:\n print((-1))\n return\n\nprint(answer)\n\n", "for i in[*open(0)][(a:=1)].split():a*=int(i);a=[-1,a][0<=a<=10**18]\nprint(a)", "a=1\nfor i in[*open(0)][1].split():a*=int(i);a=[-1,a][-1<a<=1e18]\nprint(a)", "n=int(input())\nA=list(map(int,input().split()))\nMAX = 10**18\nans = 1\n\nfor a in A:\n if a == 0:\n print(0)\n return\n\nfor a in A:\n ans *= a\n if MAX < ans:\n print(-1)\n return\nprint(ans)", "N = int(input())\nCONST = 10 ** 18\nresult = 1\nnumbers = list(map(int, input().split()))\nif 0 in numbers:\n print(0)\n return\nnumbers.sort(reverse=True)\nfor i in numbers:\n result = result * i\n if result > CONST:\n print(-1)\n return\nprint(result)", "n = int(input())\na = list(map(int, input().split()))\nans = 1\nx = -1\nif 0 in a:\n print((0))\n return\nfor i in range(n):\n x += 1\n ans *= a[x]\n if ans > 1e18:\n print((-1))\n return\nprint(ans)\n", "n = int(input())\nl = list(map(int,input().split())) \nif 0 in l:\n print(\"0\")\n return\nresult = l[0]\nl.pop(0)\nfor data in l:\n result *= data\n if result > 10 ** 18:\n result = -1\n break\nprint(result)", "N = int(input())\nnums = [int(i) for i in input().split()]\n\n\ndef calc(N, nums):\n ans = 1\n flg = False\n if 0 in nums:\n return 0\n for i in range(N):\n ans *= nums[i]\n if ans > 10 ** 18:\n flg = True\n break\n if flg:\n return -1\n else:\n return ans\n\n\nprint(calc(N, nums))", "n = int(input())\nl = list(map(int,input().split()))\nans = 1\n \nif(0 in l):\n ans = 0\nelse:\n for i in range(n):\n ans=ans*l[i]\n if(ans > 10**18):\n ans = -1\n break\nprint(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 = int(input())\nA = [int(i) for i in input().split()]\n\ntmp = 0\nres = 1\n\nA = sorted(A)\nfor i in range(n):\n res *= A[i]\n if res > 10 ** 18:\n res = -1\n break\n if res == 0:\n break\n\nprint(res)\n", "input();l=input().split();x=not'0'in l\nfor j in l:\n x*=int(j);\n if x>1e18:x=-1;break\nprint(x)", "n = int(input())\na = list(map(int,input().split()))\nans = 1\nif 0 in a:\n print(0)\nelse:\n for i in range(n):\n ans *= a[i]\n if ans > 10 ** 18:\n print(-1)\n break\n else:\n print(ans)"]
{"inputs": ["2\n1000000000 1000000000\n", "3\n101 9901 999999000001\n", "31\n4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0\n"], "outputs": ["1000000000000000000\n", "-1\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
20,916
d11c85cf7de243e2d9f3127496badf07
UNKNOWN
E869120 has A 1-yen coins and infinitely many 500-yen coins. Determine if he can pay exactly N yen using only these coins. -----Constraints----- - N is an integer between 1 and 10000 (inclusive). - A is an integer between 0 and 1000 (inclusive). -----Input----- Input is given from Standard Input in the following format: N A -----Output----- If E869120 can pay exactly N yen using only his 1-yen and 500-yen coins, print Yes; otherwise, print No. -----Sample Input----- 2018 218 -----Sample Output----- Yes We can pay 2018 yen with four 500-yen coins and 18 1-yen coins, so the answer is Yes.
["n=int(input())\na=int(input())\nif n%500<=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nif n % 500 <= a:\n print('Yes')\nelse:\n print('No')", "n = int(input())\na = int(input())\nprint('Yes' if (n % 500) <= a else 'No')", "n = int(input())\na = int(input())\nmod = n % 500\nif mod > a:\n print(\"No\")\nelse:\n print(\"Yes\")\n", "n = int(input())\na = int(input())\nif n%500<=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nprint('Yes' if n %500 <= a else 'No')", "a,b=int(input()),int(input())\nprint(\"Yes\") if a%500<=b else print(\"No\")", "n = int(input())\na = int(input())\n\nif n%500 <= a:\n print('Yes')\nelse:\n print('No')", "n = int(input())\na = int(input())\n\nif a >= n % 500:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nA = int(input())\n\nN %= 500\nprint(\"Yes\" if N <= A else \"No\")", "N = int(input())\nA = int(input())\n\nmod = N % 500\nif mod <= A:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = int(input())\na = int(input())\nx = n % 500\nprint(\"Yes\" if a >= x else (\"No\"))", "N = int(input())\nA = int(input())\nif N % 500 <= A:\n print('Yes')\nelse:\n print('No')", "# -*- coding: utf-8 -*-\n\nN = int(input())\nA = int(input())\n\nremainder = N % 500\nif A > remainder or remainder==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nif (n%500)<=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "def main():\n n = int(input())\n a = int(input())\n\n if a >= n % 500:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\nmain()", "N=int(input())\nA=int(input())\nif N%500>A:\n print(\"No\")\nelse:\n print(\"Yes\")\n", "n = int(input())\na = int(input())\ncnt = 0\nfor i in range(21):\n if 0 <= n - i*500 and n - i*500 <= a:\n print(\"Yes\")\n break\n else:\n cnt += 1\n if cnt == 21:\n print(\"No\")\n break", "N = int(input())\nA = int(input())\n\nif N%500 <= A:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\n\nif n % 500 <= a:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a = int(input())\nb = int(input())\nx = a % 500\nif x <= b:\n print('Yes')\nelse:\n print('No')", "N = int(input())\nA = int(input())\n\nif N % 500 <= A:\n print('Yes')\nelse:\n print('No')", "n = int(input())\na = int(input())\nif a>=(n%500):\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nn1 = n % 500\nif n1 <= a:\n print('Yes')\nelse:\n print('No')", "N=int(input())\nA=int(input())\nN %= 500\nif N>A:\n print('No')\nelse:\n print('Yes')", "#!/usr/bin/env python3\n\nn = int(input())\na = int(input())\n\nnum = n % 500\n\nif num > a:\n print(\"No\")\nelse:\n print(\"Yes\")\n", "a = [int(input()) for i in range(2)]\nif(a[0]%500 <= a[1]): print(\"Yes\")\nelse: print(\"No\")", "N = int(input())\nA = int(input())\n\nif A >= (N % 500):\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a = int(input()) % 500\nichi = int(input())\nif ichi >= a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n=int(input())\na=int(input())\ns=n%500\nif s<=a:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "N = int(input())\nA = int(input())\nif N % 500 <= A:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = int(input())\na = int(input())\nif n % 500 <= a:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = int(input())\na = int(input())\n\nif a >= (n%500):\n print('Yes')\nelse:\n print('No')", "n = int(input())\na = int(input())\nif n % 500 <= a:\n print(\"Yes\")\nelse:\n print(\"No\")", "total_price = int(input())\nnum_one_coin = int(input())\n\nmod = total_price % 500\n\nif num_one_coin >= mod:\n print('Yes')\nelse:\n print('No')", "n=int(input())\na=int(input())\nif n%500 <=a:\n print(\"Yes\")\nelse : print(\"No\")", "import sys\nn = int(input())\na = int(input())\nb = 0\nwhile True:\n c = 0\n if (500*b + c) > n:\n print(\"No\")\n break\n for i in range(a+1):\n if (500*b + c) == n:\n print(\"Yes\")\n return\n c+=1\n b+=1\n", "n=int(input())\na=int(input())\n\nif n%500<=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\n\nif n % 500 <= a:\n print('Yes')\nelse:\n print('No')\n", "N=int(input())\nA=int(input())\nif N%500<=A:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "N = int(input())\nA = int(input())\nif N%500 > A:\n print(\"No\")\nelse:\n print(\"Yes\")", "n = int(input())\na = int(input())\nif n%500<=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nb = n % 500\nif a >= b:\n print('Yes')\nelse:\n print('No')", "N = int(input())\nA = int(input())\nif N%500 <= A:\n print('Yes')\nelse:\n print('No')", "N = int(input())\nA = int(input())\n\nb = N%500\n\nif A >= b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a = int(input())\nb = int(input())\nif a % 500 <= b:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nA = int(input())\nm = N % 500\n\nif m <= A:\n print('Yes')\nelse:\n print('No')", "N=int(input())\nA=int(input())\nif N%500<=A:\n print('Yes')\nelse :\n print('No')", "n = int(input())\na = int(input())\nif n%500 <= a:\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\n", "N=int(input())\nA=int(input())\n\nAmari=N%500\n\nif A>=Amari:\n print('Yes')\n\nelif A<Amari:\n print('No')", "n = int(input())\na = int(input())\nif n%500<=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nA = int(input())\n\nanswer = \"Yes\" if N % 500 <= A else \"No\"\nprint(answer)", "N = int(input())\nA = int(input())\n\nnokori = N % 500\n\nif nokori <= A:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = int(input())\na = int(input())\nif n % 500 <= a:\n print('Yes')\nelse:\n print('No')\n", "n = int(input())\na = int(input())\n\ndiv = n % 500\nif div <= a:\n print('Yes')\nelse:\n print('No')", "n = int(input())\na = int(input())\nprint(\"Yes\" if n%500 <= a else \"No\")", "n=int(input())\na=int(input())\nif a>=n%500:print(\"Yes\")\nelse:print(\"No\")", "n = int(input())\na = int(input())\nprint('Yes' if a - n%500 >= 0 else 'No')", "# \u6574\u6570\u306e\u5165\u529b\nN = int(input())\n# \u6574\u6570\u306e\u5165\u529b\nA = int(input())\n \nx = N % 500\nif x <= A:\n print(\"Yes\")\nelse:\n print(\"No\")", "n,a=[int(input()) for i in range(2)]\nprint(\"Yes\" if n%500<=a else \"No\")", "n = int(input())\na = int(input())\nif n % 500 <= a:\n print('Yes')\nelse:\n print('No')", "n = int(input())\na = int(input())\nn -= n//500 * 500\nif n <= a:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = int(input())\na = int(input())\nprint('Yes' if n%500 <= a else 'No')", "n = int(input())\na = int(input())\nif n%500<= a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nif n % 500 <= a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\n \nmod = n % 500\nprint(\"Yes\" if a >= mod else \"No\")", "n = int(input())\na = int(input())\n\nprint(\"Yes\" if n%500 <= a else \"No\")", "n = int(input())\na = int(input())\nprint(('Yes' if n % 500 <= a else 'No'))\n", "N = int(input())\nA = int(input())\nif N%500 > A :\n print('No')\nelse :\n print('Yes')", "n = int(input())\na = int(input())\nif n%500<=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nif (n % 500) <= a:\n print('Yes')\nelse:\n print('No')", "n = int(input())\na = int(input())\nprint((\"Yes\" if n%500<=a else \"No\"))\n", "n = int(input())\na = int(input())\n\nif n % 500 <= a:\n print(\"Yes\")\nelse:\n print(\"No\")", "n=int(input())\na=int(input())\ns=n%500\nif a>=s:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nA = int(input())\n\nif N % 500 <= A:\n print('Yes')\nelse:\n print('No')", "N=int(input())\nA=int(input())\nif N % 500 <=A:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nif n % 500 <=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nA = int(input())\nif N%500 <= A:\n print('Yes')\nelse:\n print('No')", "N = int(input())\nA = int(input())\nif N%500 <= A:\n print('Yes')\nelse:\n print('No')\n", "n = int(input())\na = int(input())\nif n - 500*(n//500) <=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "#!/usr/bin/env python3\n\n\ndef main():\n N, A = list(map(int, open(0).read().split()))\n if N % 500 <= A:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\nmain()\n", "#!/usr/bin/env python3\n\n\ndef main():\n N, A = list(map(int, open(0).read().split()))\n if N % 500 <= A:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\nmain()\n", "n=int(input())\na=int(input())\nif n%500<=a:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nA = int(input())\n\nif (N%500) <= A:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "N = int(input())\nA = int(input())\nN %= 500\nprint(\"Yes\") if A >= N else print(\"No\")\n", "n=int(input())\na=int(input())\nprint(\"Yes\" if n%500<=a else \"No\")", "N = int(input())\nA = int(input())\nwhile N>=500:\n N-=500\nif N<=A:\n print('Yes')\nelse:\n print('No')", "#!/usr/bin/env python3\nimport sys\n\nYES = \"Yes\" # type: str\nNO = \"No\" # type: str\n\n\ndef solve(N: int, A: int):\n return YES if (N % 500) <= A else NO\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 N = int(next(tokens)) # type: int\n A = int(next(tokens)) # type: 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()", "n = int(input())\na = int(input())\nprint(\"Yes\" if n%500 <=a else \"No\")", "N, A = [int(input()) for i in range(2)]\nprint('Yes') if N % 500 <= A else print('No')\n", "N = int(input())\nA = int(input())\nif N % 500 <= A:\n print('Yes')\nelse :\n print('No')", "n=int(input())\na=int(input())\nif n%500<=a:print('Yes')\nelse:print('No')", "N = int(input())\nA = int(input())\n\nif (N % 500) <= A:\n print('Yes')\nelse:\n print('No')", "import sys\nN, A = map(int, sys.stdin.readlines())\nN %= 500\nprint('Yes' if N <= A else 'No')", "n, a = int(input()), int(input())\nflg = n % 500 - a > 0\n\nprint('No' if flg else 'Yes')", "N = int(input())\nA = int(input())\n\na = N % 500\n\nif A >= a:\n print('Yes')\nelse:\n print('No')", "n = int(input())\na = int(input())\n\nif n%500 <= a:\n print('Yes')\n \nelse:\n print('No')", "N = int(input())\nA = int(input())\n \nif N % 500 <= A: print('Yes')\nelse: print('No')", "a=int(input())\nb=int(input())\nif a%500 <= b:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\na = int(input())\nif a >= n % 500:\n print(\"Yes\")\nelse:\n print(\"No\")\n"]
{"inputs": ["2018\n218\n", "2763\n0\n", "37\n514\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
11,044
60698cc4678fa66e03d01a646d731506
UNKNOWN
Takahashi has a strong stomach. He never gets a stomachache from eating something whose "best-by" date is at most X days earlier. He gets a stomachache if the "best-by" date of the food is X+1 or more days earlier, though. Other than that, he finds the food delicious if he eats it not later than the "best-by" date. Otherwise, he does not find it delicious. Takahashi bought some food A days before the "best-by" date, and ate it B days after he bought it. Write a program that outputs delicious if he found it delicious, safe if he did not found it delicious but did not get a stomachache either, and dangerous if he got a stomachache. -----Constraints----- - 1 ≀ X,A,B ≀ 10^9 -----Input----- Input is given from Standard Input in the following format: X A B -----Output----- Print delicious if Takahashi found the food delicious; print safe if he neither found it delicious nor got a stomachache; print dangerous if he got a stomachache. -----Sample Input----- 4 3 6 -----Sample Output----- safe He ate the food three days after the "best-by" date. It was not delicious or harmful for him.
["X,A,B=list(map(int,input().split()))\nif A-B>=0:\n print(\"delicious\")\nelif -A+B<=X:\n print(\"safe\")\nelse:\n print(\"dangerous\")\n", "x,a,b = map(int,input().split())\n\nif a>=b: print('delicious')\nelif a+x+1>b: print('safe')\nelse: print('dangerous')", "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 x, a, b = inl()\n if b - a > x:\n return \"dangerous\"\n elif b > a:\n return \"safe\"\n return \"delicious\"\n\n\nprint(solve())\n", "a,b,c = [int(x) for x in input().split()]\nif b >= c:\n print(\"delicious\")\nelif c > (a + b):\n print(\"dangerous\")\nelse:\n print(\"safe\")", "x, a, b = list(map(int, input().split()))\np = b - a\nif p <= 0:\n print(\"delicious\")\nelif x >= p:\n print(\"safe\")\nelse:\n print(\"dangerous\")\n", "x, a, b = list(map(int, input().split()))\nif b-a <= 0:\n print('delicious')\nelif b-a <= x:\n print('safe')\nelse:\n print('dangerous')\n", "x, a, b = map(int, input().split())\n\nif b <= a:\n print('delicious')\nelif (b-a) < (x+1):\n print('safe')\nelse:\n print('dangerous')", "x, a, b = list(map(int, input().split()))\n\nif 0 < b <= a:\n print('delicious') \nelif a < b <= a+x:\n print('safe')\nelif a+x < b:\n print('dangerous')\n", "X, A, B = list(map(int, input().split()))\n\nif B <= A:\n print(\"delicious\")\nelif B <= A + X:\n print(\"safe\")\nelse:\n print(\"dangerous\")\n", "X,A,B=map(int,input().split())\nif B-A<=0 :\n print(\"delicious\")\nelif B-A<X+1 :\n print(\"safe\")\nelse :\n print(\"dangerous\")", "x,a,b=map(int, input().split())\nprint(\"delicious\" if b<=a else \"safe\" if b<=a+x else \"dangerous\")", "x,a,b=map(int, input().split())\nif a>=b:\n print('delicious')\nelif b-a<=x:\n print('safe')\nelse:\n print('dangerous')", "x,a,b=map(int,input().split())\nif 1<=(b-a)<=x:\n print('safe')\nelif (b-a)>x:\n print('dangerous')\nelse:\n print('delicious')", "\nx,a,b = list(map(int,input().split()))\nprint((\"dangerous\" if x<(b-a) else \"safe\" if a<b else \"delicious\"))\n", "x,a,b = map(int,input().split())\nif b <= a:\n print('delicious')\nelif b - a <= x:\n print('safe')\nelse:\n print('dangerous')", "x,a,b = map(int,input().split())\nprint(\"dangerous\" if b-a>x else \"safe\" if b-a>0 else \"delicious\")", "x, a, b = map(int, input().split())\nif b-a > x:\n print('dangerous')\nelif b-a > 0:\n print('safe')\nelse:\n print('delicious')", "x,a,b = map(int,input().split())\n\nprint('delicious') if b <= a else print('safe') if b <= a+x else print('dangerous')\n", "x,a,b=map(int,input().split())\nif a>=b:\n print(\"delicious\")\nelif 0<b-a<=x:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "x, a, b = map(int, input().split())\n\n\nif a-b >= 0:\n print(\"delicious\")\nelif b-a <= x:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "lst = input().split()\n\nX = int(lst[0])\nA = int(lst[1])\nB = int(lst[2])\n\nd = B - A\n\nif d <= 0:\n print('delicious')\nelif d <= X:\n print('safe')\nelse:\n print('dangerous')", "a,b,c=map(int,input().split())\nif c<=b:\n print(\"delicious\")\nelif c<=a+b:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "x,a,b=map(int,input().split())\nif b<=a:print('delicious')\nelif b<=a+x:print('safe')\nelse:print('dangerous')", "x, a, b = list(map(int, input().split()))\nif b <= a:\n print(\"delicious\")\nelif a < b <= a + x:\n print(\"safe\")\nelse:\n print(\"dangerous\")\n", "X,A,B=map(int,input().split())\ndate=A-B\nif date>=0:\n ans=\"delicious\"\nelif abs(date)>X:\n ans=\"dangerous\"\nelse:\n ans=\"safe\"\nprint(ans)", "x,a,b=map(int,input().split())\nprint([['dangerous','safe'][a+x>=b],'delicious'][a>=b])", "x,a,b = list(map(int, input().split())) \nd = b-a\n\nif (d <= 0):\n print('delicious ')\nelif(d <= x):\n print('safe')\nelse:\n print('dangerous')\n", "X, A, B = list(map(int, input().split()))\nif A - B >= 0:\n print('delicious')\nelif A + X - B >= 0:\n print('safe')\nelse:\n print('dangerous')", "a,b,c=map(int,input().split(\" \"))\nif c>a+b:print(\"dangerous\")\nelif c>a:print(\"safe\")\nelse:print(\"delicious\")", "X,A,B = list(map(int,input().split()))\nif B-A<=0:print(\"delicious\")\nelif B-A <=X:print(\"safe\")\nelse:print(\"dangerous\")\n", "x, a, b = map(int, input().split())\nif b <= a:\n print(\"delicious\")\nelif b - a <= x:\n print(\"safe\")\nelif b - a > x:\n print(\"dangerous\")", "x, a, b = map(int, input().split())\nif b-a <= 0:\n print('delicious')\nelif b-a <= x:\n print('safe')\nelse:\n print('dangerous')", "X,A,B=map(int,input().split())\n\nif B<=A:\n print('delicious')\nelif B>(X+A):\n print('dangerous')\nelse:\n print('safe')", "X,A,B = map(int,input().split())\n \nif B <= A:\n print(\"delicious\")\nelif B <= A+X:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "x, a, b = map(int,input().split())\nif b <= a:\n print('delicious')\nelif b <= a + x:\n print('safe')\nelse:\n print('dangerous')", "X, A, B = map(int, input().split())\n\nif B - A <= 0:\n print('delicious')\nelif B - A <= X:\n print('safe')\nelse:\n print('dangerous')", "x,a,b = list(map(int,input().split()))\nif a>=b:\n print('delicious')\nelif x>=b-a:\n print('safe')\nelse:\n print('dangerous')\n", "X, A, B = list(map(int, input().split()))\nif B <= A:\n print('delicious')\nelif B <= A + X:\n print('safe')\nelse:\n print('dangerous')\n", "x,a,b =map(int,input().split())\nif b-a<=0:\n print(\"delicious\")\nelif (b-a)>0 and (b-a)<=x:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "x,a,b = map(int, input().split())\nif b <= a:\n print('delicious')\nelif a < b <= x+a:\n print('safe')\nelse:\n print('dangerous')", "a, b, c= list(map(int, input().split()))\nif b >= c:\n print(\"delicious\")\nelif c-b<=a:\n print(\"safe\")\nelse:\n print(\"dangerous\")\n", "x,a,b=map(int,input().split())\ny=b-a\nif y > x:\n print('dangerous')\nelif 0 < y <=x:\n print('safe')\nelif y <= 0:\n print('delicious')", "x, a, b=list(map(int, input().split()))\nif a>=b:\n print('delicious')\nelse:\n if b-a<x+1:\n print('safe')\n else:\n print('dangerous')\n", "x,a,b=map(int,input().split())\n\ntmp = b-a\nif tmp <= 0:print('delicious')\nelif tmp <= x:print('safe')\nelse:print('dangerous')", "def solve():\n x, a, b = map(int, input().split())\n if b <= a:\n print('delicious')\n elif a < b <= a + x:\n print('safe')\n else:\n print('dangerous')\n\n\ndef __starting_point():\n solve()\n__starting_point()", "x,a,b = map(int, input().split())\nif a >= b:\n print(\"delicious\")\nelif a+x >= b:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "X, A, B = map(int, input().split())\nif A-B >= 0:\n print(\"delicious\")\nelif B-A <= X:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "X, A, B = map(int, input().split())\n\nif A >= B:\n print('delicious')\nelif A + X < B:\n print('dangerous')\nelse:\n print('safe')", "x,a,b=map(int,input().split())\nprint(\"dangerous\" if x<b-a else \"safe\" if a<b else \"delicious\")", "x,a,b = map(int,input().split())\n\nif a >= b:\n print(\"delicious\")\nelif b > (x + a):\n print(\"dangerous\")\nelse:\n print(\"safe\")", "#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,a,b = list(map(int, input().split()))\n\nif (b <= a):\n print(\"delicious\")\nelif (b <= x+a):\n print(\"safe\")\nelse:\n print(\"dangerous\")\n\n", "x, a, b = map(int, input().split())\nprint(\"delicious\" if b - a <= 0 else \"safe\" if b - a <= x else \"dangerous\")", "x,a,b=list(map(int, input().split()))\n\n\nif -a+b <=0:\n print('delicious')\nelif -a+b < x+1:\n print('safe')\nelse:\n print('dangerous')\n", "x,a,b=map(int,input().split())\nprint(\"delicious\"if a>=b else\"safe\"if x+a>=b else 'dangerous')", "x,a,b = map(int,input().split())\nprint(\"delicious\" if b <= a else \"safe\" if b <= a+x else \"dangerous\")", "x,a,b = list(map(int,input().split()))\nif a >= b:\n print('delicious')\nelif x + a >= b:\n print('safe')\nelse:\n print('dangerous')\n\n", "days_of_fine, day_before_expiration, eating_day = map(int, input().split())\n\nif eating_day <= day_before_expiration:\n print('delicious')\nelif day_before_expiration < eating_day <= days_of_fine + day_before_expiration:\n print('safe')\nelse:\n print('dangerous')", "x,a,b = map(int,input().split())\n\nif a-b >= 0:\n print('delicious')\nelif b-a <= x:\n print('safe')\nelse:\n print('dangerous')", "X,A,B = map(int,input().split())\nif B <= A:\n print('delicious')\nelif A < B and B <= A+X:\n print('safe')\nelse:\n print('dangerous')", "X, A, B = map(int,input().split())\nif B <= A:\n print(\"delicious\")\nelif B <= X + A:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "days_of_fine, day_befoe_exparitation, eating_day = map(int, input().split())\n\nif eating_day <= days_of_fine:\n print('delicious')\nelif day_befoe_exparitation < eating_day <= days_of_fine + day_befoe_exparitation:\n print('safe')\nelse:\n print('dangerous')", "x, a, b = map(int, input().split())\nif a >= b:\n print(\"delicious\")\nelif x >= b-a:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "X,A,B=map(int,input().split())\n \nif A>=B:\n print('delicious')\nelse:\n if X>=B-A:\n print('safe')\n else:\n print('dangerous')", "X,A,B=map(int,input().split())\nif A-B>=0:\n print(\"delicious\")\nelif B-A<=X:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "x,a,b=map(int,input().split())\nprint([[\"delicious\",\"safe\"][a<b],\"dangerous\"][x+a<b])", "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 X, A, B = LI()\n\n if B <= A:\n print('delicious')\n elif A < B <= A + X:\n print('safe')\n else:\n print('dangerous')\n\ndef __starting_point():\n resolve()\n__starting_point()", "def iroha():\n x, a, b = list(map(int, input().split()))\n \n if a - b >= 0:\n print(\"delicious\")\n elif x+a-b >= 0:\n print(\"safe\") \n else:\n print(\"dangerous\")\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "X, A, B = [ int(v) for v in input().split(\" \") ]\n\n# A: 3 B: 4 X: 3\n\nresult = A - B\n\nif result >= 0:\n print(\"delicious\")\nelif abs(result) > X:\n print(\"dangerous\")\nelse:\n print(\"safe\")\n\n", "a,b,c=input().split()\na=int(a)\nb=int(b)\nc=int(c)\nif (b-c)>=0:\n print(\"delicious\")\nelse:\n if (b-c)>=-a:\n print(\"safe\")\n else:\n print(\"dangerous\")", "x,a,b=map(int,input().split())\n\nif b-a<=0:\n ans=\"delicious\"\nelif b-a<=x:\n ans=\"safe\"\nelse:\n ans=\"dangerous\"\n\nprint(ans)", "x,a,b=map(int,input().split())\nif (b-a)<=0 :\n print(\"delicious\")\nelif 0<(b-a)<=x:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "x,a,b = map(int,input().split())\nif b<=a:\n print(\"delicious\")\nelif b<=a+x:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "X, A, B = map(int, input().split())\n\nif B - A <= 0:\n print(\"delicious\")\nelif B - A <= X:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "#\n# abc065 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 = \"\"\"4 3 6\"\"\"\n output = \"\"\"safe\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"6 5 1\"\"\"\n output = \"\"\"delicious\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"3 7 12\"\"\"\n output = \"\"\"dangerous\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n X, A, B = list(map(int, input().split()))\n\n if A-B >= 0:\n print(\"delicious\")\n elif B-A <= X:\n print(\"safe\")\n else:\n print(\"dangerous\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "#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)]\n\nif a >= b:\n ans = 'delicious'\nelif a+x >= b:\n ans = 'safe'\nelse:\n ans = 'dangerous'\nprint(ans)\n", "#!/usr/bin/env python3\nX, A, B = list(map(int, input().split()))\n\nif B <= A:\n print('delicious')\nelif B - A <= X:\n print('safe')\nelse:\n print('dangerous')\n", "X, A, B = map(int, input().split())\nif A-B >= 0:\n print('delicious')\nelif A-B >= -X:\n print('safe')\nelse:\n print('dangerous')", "x,a,b=list(map(int,input().split()))\nif a>=b:\n print(\"delicious\")\nelif a+x>=b:\n print(\"safe\")\nelse:\n print(\"dangerous\")\n", "x,a,b=map(int,input().split())\nif b-a<=0:print(\"delicious\")\nelif b-a<=x:print(\"safe\")\nelse:print(\"dangerous\")", "x, a, b = map(int, input().split())\n\nif b <= a:\n print('delicious')\nelif a < b <= a + x:\n print('safe')\nelse:\n print('dangerous')", "x, a, b = map(int, input().split())\n\nif b <= a:\n print('delicious')\nelif b - a <= x:\n print('safe')\nelse:\n print('dangerous')", "x,a,b = list(map(int,input().split()))\nif a >= b:\n print(\"delicious\")\nelif (b-a) <= x:\n print(\"safe\")\nelse:\n print(\"dangerous\")\n", "x,a,b=map(int,input().split())\n\nif b-a<=0:\n print('delicious')\n \nelif 0<b-a<=x:\n print('safe')\n \nelse:\n print('dangerous')", "x, a, b = map(int, input().split())\nif a >= b:\n print('delicious')\nelif b - a <= x:\n print('safe')\nelse:\n print('dangerous')", "x,a,b=map(int,input().split())\nif b<=a:\n print(\"delicious\")\nelif a<b and b<=a+x:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "a,b,c = map(int,input().split())\nif b < c:\n if abs(b - c) <= a:\n print(\"safe\")\n else:\n print(\"dangerous\")\nelse:\n print(\"delicious\")", "x,a,b = map(int,input().split())\nif a >= b:\n print(\"delicious\")\nelif x-(b-a) >= 0:\n print(\"safe\")\nelse:\n print(\"dangerous\")", "x,a,b=map(int,input().split())\nb -= a\nif b <= 0:\n print('delicious')\n \nelse:\n if b > x:\n print('dangerous')\n else:\n print('safe')", "x, a, b = (list(map(int, input().split())))\n\nday = b - a\nif day <= 0:\n print('delicious')\nelif day <= x:\n print('safe')\nelse:\n print('dangerous')\n", "x, a, b = list(map(int, input().split()))\n\nif b <= a:\n print(\"delicious\")\nelif a < b and abs(a - b) <= x:\n print(\"safe\")\nelse:\n print(\"dangerous\")\n", "x, a, b = map(int, input().split())\nif a >= b:\n print('delicious')\nelif b - a <= x:\n print('safe')\nelse:\n print('dangerous')", "LI = lambda: list(map(int, input().split()))\n\nX, A, B = LI()\n\n\ndef main():\n x = B - A\n if x <= 0:\n ans = \"delicious\"\n elif x <= X:\n ans = \"safe\"\n else:\n ans = \"dangerous\"\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "x, a, b=map(int, input().split())\n\nif a>=b:\n print('delicious')\nelif b - a < x + 1:\n print('safe')\nelse:\n print('dangerous')", "X, A, B=map(int, input().split(\" \"))\n\nif A-B>=0:\n print('delicious')\nelif B-A>X:\n print('dangerous')\nelif B-A<=X:\n print('safe')", "x, a, b = map(int, input().split())\nif b - a <= 0:\n print('delicious')\nelif b - a <= x:\n print('safe')\nelse:\n print('dangerous')", "#!/usr/bin/env python3\nx,a,b=map(int,input().split())\nif a-b >= 0:\n print('delicious')\nelif a-b >= -x:\n print('safe')\nelse:\n print('dangerous')", "x, a, b = map(int, input().split())\nd = -1*a + b\nif(d <= 0):\n print(\"delicious\")\nelif(abs(d) <= x):\n print(\"safe\")\nelse:\n print(\"dangerous\")", "with open(0) as f:\n X, A, B = map(int, f.read().split())\nif B-A <= 0:\n ans = 'delicious'\nif 0 < B-A <= X:\n ans = 'safe'\nif B-A > X:\n ans = 'dangerous'\nprint(ans)"]
{"inputs": ["4 3 6\n", "6 5 1\n", "3 7 12\n"], "outputs": ["safe\n", "delicious\n", "dangerous\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,991
a5d3074c9e7609843b6ec12f8fc1a8a5
UNKNOWN
Find the largest square number not exceeding N. Here, a square number is an integer that can be represented as the square of an integer. -----Constraints----- - 1 \leq N \leq 10^9 - N is an integer. -----Input----- Input is given from Standard Input in the following format: N -----Output----- Print the largest square number not exceeding N. -----Sample Input----- 10 -----Sample Output----- 9 10 is not square, but 9 = 3 Γ— 3 is. Thus, we print 9.
["N = int (input ())\nx = 1\nwhile x**2 <= N:\n x += 1\nx -= 1\nprint (x**2)", "#\n# abc077 b\n#\nimport sys\nfrom io import StringIO\nimport unittest\nimport math\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 = \"\"\"10\"\"\"\n output = \"\"\"9\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"81\"\"\"\n output = \"\"\"81\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"271828182\"\"\"\n output = \"\"\"271821169\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n print((math.floor(math.sqrt(N))**2))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "n = int(input())\n\ni=1\nwhile i*i <= n:\n ans = i*i\n i+=1\nprint(ans)", "n = int(input())\nprint(int(n**(1/2))**2)", "N = int(input())\ni = 1\nif N == 1:\n print(i)\nelse:\n while i <= N:\n if((i * i) > N):\n print((i-1) * (i-1))\n break\n i += 1", "from math import sqrt\n\nn = int(input())\n\nfor i in range(int(sqrt(n) + 1)):\n if i ** 2 <= n:\n ans = i ** 2\nprint(ans)", "from math import sqrt\nn = int(input())\nprint(int(sqrt(n))**2)", "#!/usr/bin/env python3\nN = int(input())\n\nans = 0\nfor i in range(1, 10**5):\n n = i ** 2\n if n <= N:\n ans = n\n else:\n break\nprint(ans)\n", "print(int(int(input())**.5)**2)", "a=int(input())\ni=0\nwhile i**2<=a:\n i=i+1\nprint((i-1)**2)", "n = int(input())\n\nfor i in range(n, 0, -1):\n j = int(i ** 0.5)\n if int(j) ** 2 == i:\n break\nprint(i)\n", "print((int(int(input())**0.5)**2))\n", "import math\nx=int(input())\ny= math.sqrt(x)\nz= y//1\na=z**2\nprint(int(a))", "n = int(input())\nprint((int(n ** 0.5) ** 2))\n", "n = int(input())\nwhile (n ** 0.5) % 1 != 0:\n n -= 1\nprint(n)", "print(int(int(input()) ** 0.5) ** 2)", "from math import sqrt\n\nn = int(input())\n\nans = int(sqrt(n))\n\nif (ans + 1) * (ans + 1) <= n:\n print((ans + 1) * (ans + 1))\nelif ans * ans <= n:\n print(ans * ans)\nelse:\n print((ans - 1) * (ans - 1))", "print(int(int(input())**0.5//1)**2)", "N=int(input())\nans=1\nfor i in range(N+1):\n if i*i<=N:\n ans=i\n else:\n break\nprint((ans**2))\n", "n = int(input())\nx = 1\nwhile x * x <= n:\n x += 1\n \nx -= 1\nprint(x * x)", "n = int(input())\nprint(int(n ** 0.5) ** 2)", "n = int(input())\nfor i in range(100000):\n if n >= (10**5-i)**2:\n print((10**5-i)**2)\n return", "n=int(input())\nprint(int(n**(1/2))**2)", "import math\nprint(int(math.sqrt(int(input())))**2)", "from math import sqrt\nn=int(input())\nfor i in range(1,int(sqrt(n))+1):\n if i**2>n:\n print((i-1)**2)\n break\nelse:\n print(i**2)", "import sys\nN=int(input())\nif N==1:\n print(\"1\")\nelif N==2:\n print(\"1\")\nelse:\n for i in range(N):\n if i**2>N:\n print((i-1)**2)\n return\n else:\n pass", "import math\nN=int(input())\nc=int(math.sqrt(N))\nprint(c**2)", "n=int(input())\ni=1\ntmp=1\nwhile True:\n if i**2 <= n:\n tmp = i**2\n else:\n break\n i += 1\nprint(tmp)", "def multiple(n):\n a = []\n for i in range(1,int(n**.5)+1):\n a.append(i*i)\n return a\nn = int(input())\na = multiple(n)\nans = 10**18\nfor i in a:\n if n-i < 0:\n continue\n ans = min(ans,abs(n-i))\nprint(n-ans)", "# coding = SJIS\n\nn = int(input())\n\nfor i in range(n):\n if int((n - i) ** 0.5) == (n - i) ** 0.5:\n print((n - i))\n return\n", "import math\na=int(input())\nb=math.sqrt(a)\nn=math.ceil(b)\nm=math.floor(b)\nprint(m**2)", "N=int(input())\nfor i in range(int(N**0.5)+1):\n if N>=i**2:\n ans=i**2\n else:\n break\nprint(ans)", "import math\n\n\ndef answer(n: int) -> int:\n return int(math.sqrt(n)) ** 2\n\n\ndef main():\n n = int(input())\n print(answer(n))\n\n\ndef __starting_point():\n main()\n__starting_point()", "n=int(input())\nfor i in range(1,10**5+2):\n if i**2>n:print(((i-1)**2));return\n", "n = int(input())\nfor i in range(100000):\n if i**2 > n:\n print((i-1)**2)\n break", "n = int(input())\nfor i in range(1,n+2):\n if i*i > n:\n print((i-1)*(i-1))\n return", "print((int(int(input())**.5)**2))\n", "n = int(input())\nans=1\nfor i in range(n+1):\n if i**2<=n:\n ans=i**2\n else:\n break\n\nprint(ans)", "import math\nN = int(input())\n\nans = 1\nfor i in range(1,math.floor(math.sqrt(N))+1):\n if i * i <= N:\n ans = i * i\n \nprint(ans)", "def main():\n N = int(input())\n a = 1\n i = 0\n prev = 0\n while a <= N:\n i += 1\n prev = a\n if a > N:\n break\n else:\n a = i * i\n print(prev) \nmain()\n", "print(int(int(input())**.5)**2)", "import math\nN = int(input())\nfor i in range(N):\n x = N - i\n if int(math.sqrt(x)) == math.sqrt(x):\n print(x)\n break\n", "N = int(input())\n\nfrom math import floor, sqrt\nans = floor(sqrt(N))**2\nprint(ans)\n", "n = int(input())\nprint(int(n**0.5)**2)", "N = int(input())\nfor i in range(1, N+1):\n if i*i > N:\n print(((i-1)*(i-1)))\n return\nprint((1))\n", "N = int(input())\n \nprint(int(N**0.5)**2)", "N = int(input())\nprint(int(N**(1/2))**2)", "N = int(input())\nprint(int((N**(1/2)//1)**2))", "n=int(input())\n\nans=1\nloop = 3\nfor i in range (1,100000):\n if i**2 <= n:\n ans=i**2\n \n \n\nprint(ans)", "n=int(input())\ni=1\ntmp=1\nwhile True:\n if i**2<=n:\n tmp=i**2\n else:\n break\n i+=1\nprint(tmp)", "n = int(input())\nprint((int(n ** 0.5)) ** 2)", "N = int(input())\n\nfor i in range(1, 10**9):\n if i**2 == N:\n print((i**2))\n break\n elif i**2 > N:\n print(((i-1)**2))\n break\n", "N = int(input())\nprint((int(N**(1/2))**2))\n", "n = int(input())\nprint((int(n**(1/2)))**2)", "n = int(input())\n\n\nans = 1\nfor i in range(1, n):\n if i**2 > n:\n ans = (i-1)**2\n break\n\n\nprint(ans)", "import math\nans=math.floor(int(input())**0.5)\nprint (ans*ans)", "N = int(input())\nans = 1\nfor i in range(1, N):\n if i*i > N:\n break\n ans = max(ans, i*i)\nprint(ans)", "print(int(int(input())**.5)**2)", "n = int(input())\nans = 0\nfor i in range(100001):\n if i **2 <= n:\n ans = i**2\n \nprint(ans)\n", "import math\n\nN=int(input())\nn=math.floor(math.sqrt(N))**2\n\nprint(n)\n\n", "n = int(input())\nprint(int(n ** 0.5) ** 2)", "from math import sqrt\n\nn = int(input())\nprint(int(sqrt(n)) ** 2)", "import math\nn = int(input())\nprint(int(math.sqrt(n))**2)", "import math\nn = int(input())\nprint(int(math.sqrt(n))**2)", "n = int(input())\nc = 1\nfor i in range(10**5):\n if i**2 <= n:c = i**2\n else:break\nprint(c)", "N = int(input())\n\nfor i in range(int(N**0.5)+3):\n if i**2 > N:\n print((i-1)**2)\n break", "n = int(input())\nprint(int(n**.5) ** 2)", "import math\nN=int(input())\nans=N\nfor i in range(N):\n if math.sqrt(ans).is_integer():\n print(ans)\n break\n ans-=1", "N=int(input())\nimport math\nprint((int(math.sqrt(N)))**2)", "n = int(input())\n\nfor i in range(1, 10**5):\n p = i**2\n if p > n:\n print((i-1)**2)\n break", "import math\n\nn = int(input())\nprint(math.floor(math.sqrt(n)) ** 2)", "N=int(input())\nprint(int(N**(1/2))**2)", "n = int(input())\n\nans = 0\nmax = int(n**0.5)+1\nfor i in range(1, max, 1):\n tmp = i**2\n if tmp <= n:\n ans = tmp\nprint(ans)", "n=int(input())\n\nfor i in range(10**5):\n if i**2 > n:\n print((i-1)**2)\n break", "n = int(input())\np = int(n**0.5)\na = 1\nans = 1\nwhile a<=p:\n if a**2 <=n:\n ans = max(ans,a**2)\n a +=1\nprint(ans)", "N = int(input())\nprint(int(N**(0.5))**2)", "N=int(input())\nif int((N+1)**.5)**2==N:print(N)\nelse:print(int(N**.5)**2)", "N = int(input())\nprint((int(N**.5)**2))\n", "N = int(input())\nprint(int(N**0.5)**2)", "N = int(input())\nfrom math import sqrt, floor\nfor i in range(1,floor(sqrt(N))+2):\n if i**2 > N:\n print((i-1)**2)", "import math\nn = int(input())\n\nfor i in range(10**5):\n if n < i ** 2:\n print((i-1) ** 2)\n break", "n=int(input())\nprint(int(n**0.5)**2)", "n=int(input())\nres=1\nfor i in range(100000):\n if i**2>n:\n break\n res=i*i\nprint(res)", "n = int(input())\nfor i in range(1, n):\n if i**2 > n:\n print((i-1)**2)\n break\nelse:\n print(1)", "import math\nn = int(input())\nfor i in range(10**9):\n if math.sqrt(n) == int(math.sqrt(n)):\n print(n)\n break\n n -= 1\n", "N=int(input())\nif N==1 :\n print(1)\n return\nfor i in range(1,N+1) :\n if i*i>N :\n print((i-1)*(i-1))\n return", "n = int(input())\n\nans = 0\nfor i in range(1, 10 ** 5):\n if i ** 2 <= n:\n ans = i ** 2\n\nprint(ans)\n", "import math\n\nn = int(input())\nprint(math.floor(math.sqrt(n)) ** 2)", "x = int(input())\nfor i in range(10**5):\n if i**2>x:\n a=((i-1)**2)\n break\nprint(a)", "import math\nn = int(input())\nprint(int(math.sqrt(n)) * int(math.sqrt(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\nn = int(input())\n\nans = 1\nfor i in range(1,n+1):\n if (i*i > n):\n ans = (i-1)**2\n break\nprint(ans)\n\n\n\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\nn = ri()\na = int(n**0.5)\nprint((a**2))\n\n\n\n\n\n\n\n\n\n\n", "N = int(input())\nfor i in range(N+1):\n if i ** 2 == N:\n print((i**2))\n return\n elif i ** 2 > N:\n print((max((i-1)**2,1)))\n return\n", "n = int(input())\nans = 0\nk = 1\nwhile k ** 2 <= n:\n ans = k ** 2\n k += 1\nprint(ans)", "#ABC077B\nn = int(input())\nwhile n>0:\n tmp = n**(1/2)\n if(tmp==int(tmp)):\n print(n)\n break\n n-=1", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\n\nans = 1\nfor i in range(0, n):\n if (ans+1)**2 > n:\n break\n ans += 1\nprint((ans**2))\n", "import math\nn = int(input())\ntmp = int(math.sqrt(n))\nprint(tmp**2)", "N = int(input())\n\ni = 1\nwhile i*i <= N:\n i += 1\n\nprint((i-1)**2)", "N=int(input())\nC=0\nif N==1:\n print(1)\n return\nfor i in range(1,N):\n if i**2<N:\n C=i**2\n elif i**2==N:\n C=i**2\n break\n elif i**2>N:\n break\nprint(C)"]
{"inputs": ["10\n", "81\n", "271828182\n"], "outputs": ["9\n", "81\n", "271821169\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
11,372
4a0b99bac18df99a74f5342d30869ecf
UNKNOWN
AtCoDeer the deer is seeing a quick report of election results on TV. Two candidates are standing for the election: Takahashi and Aoki. The report shows the ratio of the current numbers of votes the two candidates have obtained, but not the actual numbers of votes. AtCoDeer has checked the report N times, and when he checked it for the i-th (1≦i≦N) time, the ratio was T_i:A_i. It is known that each candidate had at least one vote when he checked the report for the first time. Find the minimum possible total number of votes obtained by the two candidates when he checked the report for the N-th time. It can be assumed that the number of votes obtained by each candidate never decreases. -----Constraints----- - 1≦N≦1000 - 1≦T_i,A_i≦1000 (1≦i≦N) - T_i and A_i (1≦i≦N) are coprime. - It is guaranteed that the correct answer is at most 10^{18}. -----Input----- The input is given from Standard Input in the following format: N T_1 A_1 T_2 A_2 : T_N A_N -----Output----- Print the minimum possible total number of votes obtained by Takahashi and Aoki when AtCoDeer checked the report for the N-th time. -----Sample Input----- 3 2 3 1 1 3 2 -----Sample Output----- 10 When the numbers of votes obtained by the two candidates change as 2,3 β†’ 3,3 β†’ 6,4, the total number of votes at the end is 10, which is the minimum possible number.
["import sys\nreadline = sys.stdin.readline\ndef ceil(a, b):\n return -(-a//b)\n\ndef main():\n N = int(readline())\n inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]\n scr_t, scr_a = 0, 0\n for t, a in inp:\n if t >= scr_t and a >= scr_a:\n scr_t = t\n scr_a = a\n elif t < scr_t and a >= scr_a:\n scr_t = t * ceil(scr_t, t)\n scr_a = scr_t * a // t\n elif a < scr_a and t >= scr_t:\n scr_a = a * ceil(scr_a, a)\n scr_t = scr_a * t // a\n else:\n if t / a >= scr_t / scr_a:\n scr_a = a * ceil(scr_a, a)\n scr_t = scr_a * t // a\n else:\n scr_t = t * ceil(scr_t, t)\n scr_a = scr_t * a // t\n\n print((scr_t + scr_a))\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nvote_t = 1\nvote_a = 1\n \nfor _ in range(n):\n t,a = list(map(int, input().split()))\n n = max((vote_t + t - 1) // t, (vote_a + a -1) // a)\n vote_t = n * t\n vote_a = n * a\n\nprint(vote_t + vote_a)", "import sys\n\ndef resolve():\n readline=sys.stdin.readline\n\n n=int(readline())\n a,b=map(int, readline().rstrip().split())\n for _ in range(n-1):\n x,y=map(int, readline().rstrip().split())\n start=max(a//x,b//y)\n for z in range(start,start+1000):\n if x*z>=a and y*z>=b:\n a,b=x*z,y*z\n break\n print(a+b)\n\n return\n\nif 'doTest' not in globals():\n resolve()\n return", "n = int(input())\nA, B = 0, 0\nfor i in range(n):\n x, y = map(int,input().split())\n dx, dy = 1, 1\n if A > x:\n dx = A // x\n if A % x != 0:\n dx += 1\n \n if B > y:\n dy = B // y\n if B % y != 0:\n dy += 1\n\n a = max(dx, dy)\n A, B = a * x, a * y\nprint(A + B)", "t = 1\na = 1\n\nfor i in range(int(input())):\n T,A = map(int,input().split())\n n = max(-(-t//T),-(-a//A))\n t = n*T\n a = n*A\n\nprint(t+a)", "N = int(input())\nRatio = [tuple(map(int, input().split())) for _ in range(N)]\nfrom math import ceil\nVote = (1, 1)\nfor t,a in Ratio:\n p = max((t+Vote[0]-1)//t, (a+Vote[1]-1)//a)\n Vote = (p*t, p*a)\nprint(sum(Vote))", "n = int(input())\nt_all, a_all = 0, 0\nfor i in range(n):\n t, a = list(map(int, input().split()))\n if i == 0:\n t_all = t\n a_all = a\n else:\n if t >= t_all and a >= a_all:\n t_all, a_all = t, a\n else:\n diff1, diff2 = 0, 0\n diff1 = t_all // t if t_all % t == 0 else t_all // t + 1\n diff2 = a_all // a if a_all % a == 0 else a_all // a + 1\n max_diff = max(diff1, diff2)\n t_all = t * max_diff\n a_all = a * max_diff\nprint((t_all + a_all))\n \n", "N = int(input())\nTNow,ANow = (int(T) for T in input().split())\nfor TN in range(1,N):\n TNext,ANext = (int(T) for T in input().split())\n Magn = max(TNow//TNext+(TNow%TNext!=0),ANow//ANext+(ANow%ANext!=0))\n TNow,ANow = TNext*Magn,ANext*Magn\nprint(TNow+ANow)", "import sys\ndef v():\n N=int(sys.stdin.readline())\n P=[]\n pt,pa=tuple(map(int,sys.stdin.readline().split()))\n res=pt+pa\n for _ in [0]*(N-1):\n xt,xa=tuple(map(int,sys.stdin.readline().split()))\n xs=xt+xa\n kt=pt//xt if pt%xt ==0 else pt//xt+1\n ka=pa//xa if pa%xa ==0 else pa//xa+1\n k=max([kt,ka])\n pt,pa=k*xt,k*xa\n res=pt+pa\n print(res)\ndef __starting_point():v()\n\n__starting_point()", "from decimal import Decimal, ROUND_CEILING\n\nN = int(input())\npairs = (map(Decimal, input().split()) for _ in range(N))\n\nt = Decimal('1')\na = Decimal('1')\nceil = lambda d: d.to_integral_exact(rounding=ROUND_CEILING)\n\nfor ti, ai in pairs:\n mul = max(ceil(t / ti), ceil(a / ai))\n t = ti * mul\n a = ai * mul\n\nprint(int(t + a))", "import sys\n\nsys.setrecursionlimit(10 ** 6)\nint1 = lambda x: int(x) - 1\np2D = lambda x: print(*x, sep=\"\\n\")\ndef II(): return int(sys.stdin.readline())\ndef MI(): return map(int, sys.stdin.readline().split())\ndef LI(): return list(map(int, sys.stdin.readline().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef SI(): return sys.stdin.readline()[:-1]\n\ndef gcd(a,b):\n while b:a,b=b,a%b\n return a\n\ndef lcm(a,b):return a*b//gcd(a,b)\n\ndef main():\n n=II()\n ta=LLI(n)\n x=y=-1\n for t,a in ta:\n if x==-1:\n x,y=t,a\n continue\n c=max((t+x-1)//t,(a+y-1)//a)\n x=c*t\n y=c*a\n print(x+y)\n\nmain()", "import numpy as np\nimport sys\ndef sinput(): return sys.stdin.readline()\ndef iinput(): return int(sinput())\ndef imap(): return map(int, sinput().split())\ndef fmap(): return map(float, sinput().split())\ndef iarr(): return list(imap())\ndef farr(): return list(fmap())\ndef sarr(): return sinput().split()\n\nn = int(input())\ntv = av = 1\nt = [0]*n; a = [0]*n\nfor i in range(n):\n t[i], a[i] = imap()\nfor i in range(n):\n tmp = max(tv//t[i]+(tv%t[i]!=0), av//a[i]+(av%a[i]!=0))\n tv = t[i]*tmp; av=a[i]*tmp\nprint(tv+av)", "T = 1\nA = 1\n\nfor n in range(int(input())):\n t,a = map(int,input().split())\n m = max(-(-T//t),-(-A//a))\n T = m*t\n A = m*a\n\nprint(T+A)", "n = int(input())\nt_lst, a_lst = [], []\nfor i in range(n):\n ti, ai = map(int, input().split())\n t_lst.append(ti)\n a_lst.append(ai)\n\nt, a = 1, 1\nfor i in range(n):\n ti, ai = t_lst[i], a_lst[i]\n n = max((t+ti-1)//ti, (a+ai-1)//ai)\n t = n*ti\n a = n*ai\nprint(t+a)", "from math import ceil \nN = int(input())\nvotes = [1,1]\nrate = 1\nfor i in range(N):\n t,a = map(int,input().split())\n rate = max((votes[0] - 1) // t, (votes[1] - 1) // a) + 1\n # if t * rate >= votes[0] and a * rate >= votes[1]:\n votes = [t * rate, a * rate]\n\nprint(sum(votes))", "n = int(input())\nA,B = 0,0\nfor i in range(n):\n x,y = map(int,input().split())\n t,a = 1,1\n if A > x:\n t = A // x\n if A % x != 0:\n t += 1\n if B > y:\n a = B // y\n if B % y != 0:\n a += 1\n m = max(t,a)\n A = x*m\n B = y*m\nprint(A+B)", "import sys\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 TA = [list(map(int, input().split())) for _ in range(n)]\n\n t_pev, a_prev = TA[0]\n for i in range(1, n):\n t_now, a_now = TA[i]\n if t_pev <= t_now and a_prev <= a_now:\n t_pev, a_prev = t_now, a_now\n else:\n d = max((t_pev + (t_now - 1)) // t_now, (a_prev + (a_now - 1)) // a_now)\n t_pev, a_prev = t_now * d, a_now * d\n print((t_pev + a_prev))\n\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "import math\nfrom fractions import Fraction\nn = int(input())\n# t0, a0 = map(int, input().split())\nanst = 1\nansa = 1\nfor _ in range(n):\n ti, ai = list(map(int, input().split()))\n anst = ti * math.ceil(max(Fraction(anst, ti), Fraction(ansa, ai)))\n ansa = ai * math.ceil(max(Fraction(anst, ti), Fraction(ansa, ai)))\n # p\n # if math.ceil(anst/ti) < math.ceil(ansa/ai):\n # # if math.ceil(anst/ti)*ai >= ansa:\n # # anst = ti * math.ceil(anst/ti)\n # # ansa = ai * math.ceil(anst/ti)\n # # else:\n # ansa = ai * math.ceil(ansa/ai)\n # anst = ti * math.ceil(ansa/ai)\n # else:\n # # if math.ceil(ansa/ai)*ti >= anst:\n # # ansa = ai * math.ceil(ansa/ai)\n # # anst = ti * math.ceil(ansa/ai)\n # # else:\n # ansa = ai * math.ceil(anst/ti)\n # anst = ti * math.ceil(anst/ti)\n # # print(\"anst\", anst,\"ansa = \", ansa)\n \nprint((int(anst + ansa)))\n \n", "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\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()\nTA = [LIST() for _ in range(N)]\nvote_T = 1\nvote_A = 1\nfor x, y in TA:\n\tn = max((vote_T+x-1)//x, (vote_A+y-1)//y)\n\tvote_T = x * n\n\tvote_A = y * n\nprint((vote_A + vote_T))\n", "### ----------------\n### \u3053\u3053\u304b\u3089\n### ----------------\n\nimport sys\nfrom io import StringIO\nimport unittest\n\ndef yn(b):\n print((\"Yes\" if b==1 else \"No\"))\n return\n\ndef resolve():\n readline=sys.stdin.readline\n\n #a,b,c=map(int, readline().rstrip().split())\n #arr=list(map(int, readline().rstrip().split()))\n n=int(readline())\n for i in range(n):\n x,y=list(map(int, readline().rstrip().split()))\n if i==0:\n a,b=x,y\n continue\n start=max(a//x,b//y)\n zz=start-1\n for z in range(start,start+1000):\n if x*z>=a and y*z>=b:\n zz=z\n break\n a,b=x*z,y*z\n print((a+b))\n #ss=readline().rstrip()\n #yn(1)\n\n return\n\nif 'doTest' not in globals():\n resolve()\n return\n\n### ----------------\n### \u3053\u3053\u307e\u3067 \n### ----------------\n", "n = int(input())\npt, pa = 0, 0\nfor _ in range(n):\n t, a = tuple(map(int, input().split()))\n l = 0\n r = 10**18+1\n while (r-l) > 1:\n mid = (l+r)//2\n if (t*mid >= pt and a*mid >= pa):\n r = mid\n else:\n l = mid\n pt, pa = t*r, a*r\n\nprint((pt+pa))\n", "import math\nN = int(input())\nls = []\nfor i in range(N):\n ls.append(list(map(int,input().split())))\n\nT = 1\nA = 1\nfor i in range(N):\n bai = max(-(-T//ls[i][0]),-(-A//ls[i][1]))\n T = bai * ls[i][0]\n A = bai * ls[i][1]\nprint(T+A)", "def cin():\n\treturn list(map(int,input().split()))\n\ndef cino(test=False):\n if not test:\n return int(input())\n else:\n return input()\ndef cina():\n return list(map(int,input().split()))\n\na = cino()\nx,y = 1,1\nfor _ in range(a):\n p,q = cin()\n k = max((x+p-1)//p,(y+q-1)//q)\n x,y = k*p,k*q\nprint((x+y))\n \n", "n = int(input())\nary = list(map(int, input().split()))\nfor i in range(n - 1):\n tmp_ary = list(map(int, input().split()))\n t_rate = (ary[0] - 1) // tmp_ary[0] + 1\n a_rate = (ary[1] - 1) // tmp_ary[1] + 1\n rate = max([t_rate, a_rate])\n ary = list(map(lambda x: x * rate, tmp_ary))\nprint(int(ary[0] + ary[1]))", "N=int(input())\ntakahashi=1\naoki=1\nfor i in range(N):\n T,A=list(map(int,input().split()))\n n=max((takahashi+T-1)//T,(aoki+A-1)//A)\n takahashi=n*T\n aoki=n*A\nprint((takahashi+aoki))\n", "import sys\nreadline = sys.stdin.readline\n\ndef ceil(a, b):\n return -(-a//b)\n\ndef main():\n N = int(readline())\n inp = [tuple(map(int, readline().rstrip().split())) for _ in range(N)]\n scr_t, scr_a = 1, 1\n for t, a in inp:\n n = max(ceil(scr_t, t), ceil(scr_a, a))\n scr_t = n * t\n scr_a = n * a\n\n print(scr_t + scr_a)\n\ndef __starting_point():\n main()\n__starting_point()", "N=int(input())\n\nvt=va=1\nfor _ in range(N):\n T,A=map(int,input().split())\n kt=-(-vt//T)\n ka=-(-va//A)\n \n k=max(kt,ka)\n vt=k*T\n va=k*A \n #print(vt,va)\n \nprint(vt+va)", "N = int(input())\nQ = [tuple(map(int, input().split())) for _ in range(N)]\nvote = Q[0] # \u521d\u671f\u5024\u306f\u305d\u306e\u307e\u307e\u5f97\u7968(\u4e92\u3044\u306b\u7d20)\n\nfor p, q in Q[1:]:\n if p == q:\n g = max(vote)\n vote = (g, g)\n # p\u57fa\u6e96: \u73fe\u5728\u306e\u5f97\u7968\u4ee5\u4e0a\u306e\u6700\u5c0f\u306ep\u306e\u500d\u6570\n p_v0 = ((vote[0] + p - 1) // p) * p\n p_v1 = q * p_v0 // p\n # q\u57fa\u6e96\n q_v1 = ((vote[1] + q - 1) // q) * q\n q_v0 = p * q_v1 // q\n # \u6e1b\u3063\u3066\u3044\u305f\u3089\u9664\u5916\n if p_v1 < vote[1]:\n vote = (q_v0, q_v1)\n elif q_v0 < vote[0]:\n vote = (p_v0, p_v1)\n else:\n # \u3069\u3063\u3061\u3082\u3042\u308a\u3048\u308b\u306a\u3089\u5c0f\u3055\u3044\u307b\u3046\n if p_v0 + p_v1 <= q_v0 + q_v1:\n vote = (p_v0, p_v1)\n else:\n vote = (q_v0, q_v1)\n\nans = sum(vote)\nprint(ans)", "N = int(input())\na, b = 1, 1\nfor i in range(N):\n x, y = map(int, input().split())\n n = max((a + x - 1) // x, (b + y - 1) // y)\n a = n * x\n b = n * y\nprint(a + b)", "n = int(input())\nt,a = 1,1\nimport math\nfor _ in range(n):\n T,A = map(int,input().split())\n k=(T+t-1)//T\n m=(A+a-1)//A\n x=max(k,m)\n t,a = x*T,x*A\nprint(t+a)", "def ceil(x, y):\n # ceil(x / y)\n return (x + y - 1) // y\n\n\ndef main():\n n = int(input())\n takahashi = 1\n aoki = 1\n for _ in range(n):\n t, a = list(map(int, input().split()))\n diff = max(ceil(takahashi, t), ceil(aoki, a))\n takahashi = t * diff\n aoki = a * diff\n print((takahashi + aoki))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import math\nfrom fractions import Fraction\nfrom decimal import *\n# ex) Fraction(2,6) > 1/3 > 0.33333\n\nn = int(input())\nx, y = list(map(int, input().split()))\nt, a = x, y\n\nfor _ in range(n - 1):\n tt, aa = list(map(int, input().split()))\n\n # c = 1\n '''\n if (t >= a):\n c = math.ceil(tt / t)\n\n else:\n c = math.ceil(aa / a)\n '''\n # c = math.ceil(max(t / tt, a / aa))\n # c = math.ceil(max(Fraction(t + tt - 1, tt), Fraction(a + aa - 1 / aa)))\n c = max(math.ceil(Fraction(t, tt)), math.ceil(Fraction(a, aa)))\n c = max(1, c)\n\n t = tt * c\n a = aa * c\n\n\nans = t + a\nprint(ans)\n", "from decimal import Decimal,getcontext\nfrom math import ceil\n\nN = int(input())\n\ntakahashi,aoki = 1,1\n\nfor _ in range(N):\n a,b = map(int,input().split())\n c = max(ceil(takahashi/Decimal(a)),ceil(aoki/Decimal(b)))\n takahashi = c*a\n aoki = c*b\n\nprint(takahashi+aoki)", "n = int(input())\nquery = [tuple(map(int, input().split())) for _ in range(n)]\n\nx, y = 1, 1\nfor t, a in query:\n if t >= x and a >= y:\n x = t\n y = a\n else:\n if t < x and a < y:\n x = t * max((x + t - 1) // t, (y + a - 1) // a)\n y = a * max((x + t - 1) // t, (y + a - 1) // a)\n elif t < x:\n x = t * ((x + t - 1) // t)\n y = a * ((x + t - 1) // t)\n else:\n x = t * ((y + a - 1) // a)\n y = a * ((y + a - 1) // a)\nprint(x + y)", "N=int(input())\nt=a=1\nfor i in range(N):\n T,A=list(map(int,input().split()))\n num=max(-(-t//T),-(-a//A))\n t,a=num*T,num*A\nprint((t+a))\n", "N = int(input())\nballots = [list(map(int,input().split())) for _ in range(N)]\n\ndef eceil(x, y):\n return (x+y-1)//y\nprev = ballots[0]\n\nfor i in range(1,N):\n m,n = ballots[i]\n k = max(eceil(prev[0],m),eceil(prev[1],n))\n tot = k * (m+n)\n prev[0] = tot*m//(m+n)\n prev[1] = tot*n//(m+n)\n #print(m,n,k,tot,prev)\nprint((sum(prev)))\n", "def gcd(x,y):\n if y==0:\n return x\n else:\n return gcd(y,x%y)\ndef lcm(x,y):\n return x*y//gcd(x,y)\nN=int(input())\nx,y=0,0\nfor i in range(N):\n p=0\n T,A=map(int,input().split())\n if i==0:\n x,y=T,A\n continue\n if x<=T and y<=A:\n x,y=T,A\n elif x<=T and A<y:\n if y%A!=0:\n p=1\n x=T*(y//A+p)\n y=A*(y//A+p)\n elif T<x and y<=T:\n if x%T!=0:\n p=1\n y=A*(x//T+p)\n x=T*(x//T+p)\n else:\n if (x//T+1)<=(y//A+1):\n if y%A!=0:\n p=1\n x=T*(y//A+p)\n y=A*(y//A+p)\n else:\n if x%T!=0:\n p=1\n y=A*(x//T+p)\n x=T*(x//T+p)\nprint(x+y)", "N = int(input())\nT = 1\nA = 1\nfor i in range(N):\n Tk = [0,0]\n Ak = [0,0]\n Tn,An = map(int,input().rstrip().split(\" \"))\n if T % Tn == 0:\n Tk[0] = T\n else:\n Tk[0] = (T // Tn + 1) * Tn\n Ak[0] = (Tk[0] // Tn) * An\n if Ak[0] < A:\n Ak[0] = 10 ** 18 + 1\n\n if A % An == 0:\n Ak[1] = A\n else:\n Ak[1] = (A // An + 1) * An\n Tk[1] = (Ak[1] // An) * Tn\n if Tk[1] < T:\n Tk[1] = 10 ** 18 + 1\n \n if Tk[0] + Ak[0] <= Tk[1] + Ak[1]:\n T = Tk[0]\n A = Ak[0]\n else:\n T = Tk[1]\n A = Ak[1]\nprint(A + T)", "n = int(input())\nt, a = map(int, input().split())\nfor _ in range(n - 1):\n x, y = map(int, input().split())\n s = max((t + x - 1) // x, (a + y - 1) // y)\n t, a = s * x, s * y\nprint(t + a)", "import math\nfrom fractions import Fraction\n\nN = int(input())\na, b = map(int, input().split())\nret_a = a\nret_b = b\nfor _ in range(1, N):\n a, b = map(int, input().split())\n x = math.ceil(max(Fraction(ret_a, a), Fraction(ret_b, b)))\n ret_a = a * x\n ret_b = b * x\nprint(ret_a + ret_b)", "n = int(input())\nca, cb = 0, 0\nfor i in range(n):\n a, b = list(map(int,input().split()))\n x, y = 1, 1\n if ca > a:\n x = ca // a\n if ca % a:\n x += 1\n if cb > b:\n y = cb // b\n if cb % b:\n y += 1\n x = max(x, y)\n ca = a * x\n cb = b * x\nprint((ca + cb))\n", "#\n# abc046 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 = \"\"\"3\n2 3\n1 1\n3 2\"\"\"\n output = \"\"\"10\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"4\n1 1\n1 1\n1 5\n1 100\"\"\"\n output = \"\"\"101\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"5\n3 10\n48 17\n31 199\n231 23\n3 2\"\"\"\n output = \"\"\"6930\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n R = [list(map(int, input().split())) for _ in range(N)]\n\n t = R[0][0]\n a = R[0][1]\n for i in range(1, N):\n n = max((t+R[i][0]-1)//R[i][0], (a+R[i][1]-1)//R[i][1])\n t = n*R[i][0]\n a = n*R[i][1]\n\n print((t+a))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "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, *TA = list(map(int, read().split()))\n\n x, y = 1, 1\n\n for t, a in zip(*[iter(TA)] * 2):\n m1 = (x + t - 1) // t\n m2 = (y + a - 1) // a\n m = max(m1, m2)\n x, y = t * m, a * m\n\n print((x + y))\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import sys\nimport heapq, math\nfrom itertools import zip_longest, permutations, combinations, combinations_with_replacement\nfrom itertools import accumulate, dropwhile, takewhile, groupby\nfrom functools import lru_cache\nfrom copy import deepcopy\n\nN = int(input())\n\nA, B = 1, 1\n\nfor i in range(N):\n XA, XB = map(int, input().split())\n\n if A * XB > XA * B:\n d = (A + XA - 1) // XA\n A, B = d * XA, d * XB\n else:\n d = (B + XB - 1) // XB\n A, B = d * XA, d * XB\n\nprint(A + B)", "n=int(input())\nta=[list(map(int,input().split())) for _ in range(n)]\ntv,av=1,1\n#print('-----')\nfor t,a in ta:\n i=(t+tv-1)//t\n j=(a+av-1)//a\n k=max(i,j)\n tv=t*k\n av=a*k\nprint(tv+av)", "n = int(input())\n\np = 1\nq = 1\nfor i in range(n):\n t, a = map(int, input().split())\n f = max((p + t - 1) // t, (q + a - 1) // a)\n p = t * f\n q = a * f\n \nprint(p+q)", "n=int(input())\na=b=1\nfor i in range(n):\n x,y=map(int,input().split())\n m=max(int((a-1)//x)+1,int((b-1)//y)+1)\n a=m*x\n b=m*y\nprint(a+b)", "N = int(input())\n\nT, A = map(int, input().split())\n\nfor i in range(N-1):\n t, a = map(int, input().split())\n da = (a - A%a)%a\n dt = (A + da)*t//a - T\n if dt >= 0:\n A += da\n T += dt\n else:\n i = -(dt // t)\n da += i*a\n dt += i*t\n A += da\n T += dt\n\nprint(T + A)", "n = int(input())\ntvote = 1\navote = 1\n\nfor i in range(n):\n\tt, a = [int(n) for n in input().split()]\n\tk = (tvote-1)//t + 1\n\ttnow = t * k\n\tanow = a * k\n\tif avote > anow:\n\t\tk = (avote-1)//a + 1\n\t\ttnow = t * k\n\t\tanow = a * k\n\ttvote = tnow\n\tavote = anow\n\t\nprint(avote+tvote)", "n=int(input())\np,q=1,1\n\nfor _ in range(n):\n t,a=map(int,input().split())\n #n=1\n #hile p>n*t or q>n*a:\n # n+=1\n n=max((p+t-1)//t,(q+a-1)//a)\n p,q=n*t,n*a\n #print(n,p,q)\n\nprint(p+q)", "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians\nfrom itertools import permutations, combinations, product\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\n\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()\nTA = [LIST() for _ in range(N)]\nvote_T = 1\nvote_A = 1\nfor x, y in TA:\n\tn = max(-(-vote_T // x), -(-vote_A // y))\n\tvote_T = x * n\n\tvote_A = y * n\nprint((vote_A + vote_T))\n", "N=int(input())\nt=a=1\nfor i in range(N):\n T,A=list(map(int,input().split()))\n num=max(-(-t//T),-(-a//A))\n t,a=num*T,num*A\n\nprint((t + a))\n", "from sys import stdin,stdout\n\nimport bisect\n\nimport math\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 soe(limit):\n l=[1]*(limit+1)\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,b=b,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 a,b=1,1\n for _ in range(n):\n x,y=mp()\n d=max((x+a-1)//x,(y+b-1)//y)\n a=d*x\n b=d*y\n pr(a+b)\nfor _ in range(1):\n solve()\n \n", "N=int(input())\nt=a=1\nfor i in range(N):\n T,A=list(map(int,input().split()))\n num=max(-(-t//T),-(-a//A))\n t,a=num*T,num*A\n\nprint((t + a))\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\n\ndef __starting_point():\n n = int(input())\n ml = 1\n last = [0,0]\n for i in range(n):\n x = iparse()\n # print(len(x))\n l = (last[0] + x[0] - 1) // x[0]\n r = (last[1] + x[1] - 1) // x[1]\n m = max(l, r)\n if m == 0:\n m = 1\n x[0] *= m\n x[1] *= m\n \n last = x\n print((sum(last)))\n \n \n \n\n__starting_point()", "n = int(input())\n\nt0, a0 = 1, 1\n\nfor i in range(n):\n t1, a1 = map(int, input().split())\n f0 = t0 // t1\n if t0 % t1 != 0:f0 += 1\n f1 = a0 // a1\n if a0 % a1 != 0:f1 += 1\n f = max(f0, f1)\n t0, a0 = t1*f, a1*f\n\nprint(t0 + a0)", "N = int(input())\nx = 1\ny = 1\nfor i in range(N):\n T, A = list(map(int, input().split()))\n p = (T + x - 1) // T\n q = (A + y - 1) // A\n x = T * max(p, q)\n y = A * max(p, q)\n #print(f\"[{x} {y}]\")\nprint((x + y))\n", "n = int(input())\nT, A = map(int, input().split())\n\nfor _ in range(n-1):\n t, a = map(int, input().split())\n x = max(-(-T//t), -(-A//a))\n T = x * t; A = x * a\nprint(T+A)", "n = int(input())\na,b = map(int,input().split())\n\nfor i in range(n-1):\n c,d = map(int,input().split())\n x = -min((-a)//c,(-b)//d)\n a,b = c*x,d*x\nprint(a + b)", "#!/usr/bin/env python3\nimport math\n\ndef main():\n N = int(input())\n T, A = list(map(int, input().split()))\n for _ in range(N-1):\n t, a = list(map(int, input().split()))\n # \u6841\u304c\u5927\u304d\u3044\u3068float\u306e\u8aa4\u5dee\u304c\u751f\u3058\u3066\u6b63\u3057\u304f\u5224\u5b9a\u3067\u304d\u306a\u3044\n # \u8ca0\u306e\u6570\u306b\u3057\u3066\u5207\u308a\u6368\u3066\u306b\u3059\u308c\u3070ceil\u3068\u540c\u3058\u6319\u52d5\u306b\u306a\u308b\n x = max(-(-T//t), -(-A//a))\n T = t*x\n A = a*x\n print((T+A))\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nvt, va = 1, 1\nfor i in range(n):\n t, a = list(map(int, input().split()))\n d = max((t + vt - 1) // t, (a + va - 1) // a)\n vt = d * t\n va = d * a\nprint((vt + va))\n", "n = int(input())\nt = [0]*n\na = [0]*n\nfor i in range(n): t[i],a[i] = map(int,input().split())\ntcnt = t[0]\nacnt = a[0]\nfor i in range(1,n):\n x = max((tcnt+t[i]-1)//t[i],(acnt+a[i]-1)//a[i])\n tcnt = t[i]*x\n acnt = a[i]*x\nprint(tcnt+acnt)", "N = int(input())\nt, a = list(map(int, input().split(' ')))\n\nfor _ in range(N - 1):\n nt, na = list(map(int, input().split(' ')))\n if nt >= t and na >= a:\n t = nt\n a = na\n else:\n tr = (t + nt - 1) // nt\n ar = (a + na - 1) // na\n r = max(tr, ar)\n t = r * nt\n a = r * na\n\nprint((t + a))\n", "n = int(input())\nca, cb = 0, 0\nfor i in range(n):\n a, b = list(map(int,input().split()))\n x, y = 1, 1\n if ca > a:\n x = ca // a\n if ca % a:\n x += 1\n if cb > b:\n y = cb // b\n if cb % b:\n y += 1\n x = max(x, y)\n ca = a * x\n cb = b * x\nprint((ca + cb))\n", "def nextpt(ratio1, ratio2, pt):\n if ratio1[0]*ratio2[1]-ratio1[1]*ratio2[0]>0:\n pt[0]=pt[0]+((-1)*pt[0])%ratio2[0]\n pt[1]=pt[0]*ratio2[1]//ratio2[0]\n else:\n pt[1]=pt[1]+((-1)*pt[1])%ratio2[1]\n pt[0]=pt[1]*ratio2[0]//ratio2[1]\n return pt\n\nn=int(input())\nratios = [list(map(int,input().split())) for _ in range(n)]\n\npt=ratios[0]\nfor i in range(n-1):\n pt=nextpt(ratios[i], ratios[i+1], pt)\n\nprint(sum(pt))", "from sys import stdin\nimport math\nN = int(stdin.readline().rstrip())\nt,a = 1,1\n \nfor _ in range(N):\n T,A = [int(x) for x in stdin.readline().rstrip().split()]\n n = max((t + T - 1) // T,(a + A - 1) // A)\n t = n*T\n a = n*A\n \nprint(t+a)", "from decimal import Decimal,getcontext\nfrom math import ceil\ngetcontext().prec = 1000\nN = int(input())\n \ntakahashi,aoki = 1,1\n \nfor _ in range(N):\n a,b = map(int,input().split())\n c = max(ceil(Decimal(str(takahashi))/Decimal(a)),ceil(Decimal(str(aoki))/Decimal(b)))\n takahashi = c*a\n aoki = c*b\n \nprint(takahashi+aoki)", "n = int(input())\nary = list(map(int, input().split()))\nfor i in range(n - 1):\n tmp_ary = list(map(int, input().split()))\n # \u6841\u304c\u5927\u304d\u3044\u3068ceil, floor\u3067\u306f\u6b63\u3057\u304f\u5224\u5b9a\u304c\u3067\u304d\u306a\u3044\n t_rate = (ary[0] - 1) // tmp_ary[0] + 1\n a_rate = (ary[1] - 1) // tmp_ary[1] + 1\n rate = max([t_rate, a_rate])\n ary = list(map(lambda x: x * rate, tmp_ary))\nprint(int(ary[0] + ary[1]))", "import math\n\nn=int(input())\nans=list(map(int,input().split()))\nif n==1:\n print((sum(ans)))\n \nelse:\n ans1=[]\n ans1.append(ans)\n for i in range(n-1):\n x,y=list(map(int,input().split()))\n p,q=ans1[-1][0],ans1[-1][1]\n if p%x==0:\n p1=p//x\n else:\n p1=p//x+1\n if q%y==0:\n q1=q//y\n else:\n q1=q//y+1\n pq=max(p1,q1)\n r=[x*pq,y*pq]\n ans1.append(r)\n \n print((sum(ans1[-1])))\n \n", "def main():\n N = int(input())\n TA = [list(map(int, input().split(' '))) for _ in range(N)]\n if N == 1:\n print(sum(TA[0]))\n return\n cur_t, cur_a = TA[0]\n for t, a in TA[1:]:\n ratio = max([(cur_t + t - 1) // t, (cur_a + a - 1) // a])\n cur_t, cur_a = ratio * t, ratio * a\n print(cur_t + cur_a)\n\n\ndef __starting_point():\n main()\n__starting_point()", "def main():\n N = int(input())\n T1, A1 = map(int, input().split())\n for _ in range(N-1):\n T2, A2 = map(int, input().split())\n n = max(-(-T1//T2),-(-A1//A2))\n T1,A1 = T2*n,A2*n\n print(T1 + A1)\n\n\ndef __starting_point():\n main()\n__starting_point()", "def main():\n from math import ceil\n n = int(input())\n a, b = 1, 1\n for _ in range(n):\n i, j = list(map(int, input().split()))\n x = max((a + i - 1) // i, (b + j - 1) // j)\n a, b = x * i, x * j\n print((a + b))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "from sys import stdin\nimport math\nN = int(stdin.readline().rstrip())\nt,a = [int(x) for x in stdin.readline().rstrip().split()]\n \nfor _ in range(N-1):\n T,A = [int(x) for x in stdin.readline().rstrip().split()]\n n = max((t + T - 1) // T,(a + A - 1) // A)\n t = n*T\n a = n*A\n \nprint(t+a)", "n = int(input())\n\nra,rb = 1,1\nfor i in range(n):\n a,b = map(int,input().split())\n n = max((ra+a-1)//a,(rb+b-1)//b)\n ra = a*n\n rb = b*n\n \nprint(ra+rb)", "#!/usr/bin/env python3\n\nimport sys\n# import time\nimport math\n# import numpy as np\n# import scipy.sparse.csgraph as cs # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall\n# import random # random, uniform, randint, randrange, shuffle, sample\n# import string # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits\n# import re # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)\n# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).\n# from collections import deque # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()\n# from collections import defaultdict # subclass of dict. defaultdict(facroty)\n# from collections import Counter # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)\n# from datetime import date, datetime # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj\n# from datetime.datetime import strptime # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj\n# from datetime import timedelta # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.\n# from copy import copy, deepcopy # use deepcopy to copy multi-dimentional matrix without reference\n# from functools import reduce # reduce(f, iter[, init])\n# from functools import lru_cache # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)\n# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).\n# from heapq import nlargest, nsmallest # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).\n# from itertools import count, cycle, repeat # count(start[,step]), cycle(iter), repeat(elm[,n])\n# from itertools import groupby # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]\n# from itertools import starmap # starmap(pow, [[2,5], [3,2]]) returns [32, 9]\n# from itertools import product, permutations # product(iter, repeat=n), permutations(iter[,r])\n# from itertools import combinations, combinations_with_replacement\n# from itertools import accumulate # accumulate(iter[, f])\n# from operator import itemgetter # itemgetter(1), itemgetter('key')\n# from fractions import gcd # for Python 3.4 (previous contest @AtCoder)\n\n\n\ndef main():\n mod = 1000000007 # 10^9+7\n inf = float('inf') # sys.float_info.max = 1.79...e+308\n # inf = 2 ** 64 - 1 # (for fast JIT compile in PyPy) 1.84...e+19\n sys.setrecursionlimit(10**6) # 1000 -> 1000000\n def input(): return sys.stdin.readline().rstrip()\n def ii(): return int(input())\n def mi(): return list(map(int, input().split()))\n def mi_0(): return [int(x)-1 for x in input().split()]\n def lmi(): return list(map(int, input().split()))\n def lmi_0(): return list([int(x)-1 for x in input().split()])\n def li(): return list(input())\n\n def calc_minimum_card_pair(a, b, s, t):\n \"\"\"\n \u73fe\u5728 a, b \u679a\u3067\u3042\u308b\u3068\u3059\u308b\n \u30ab\u30fc\u30c9\u3092\u5897\u3084\u3059\u64cd\u4f5c\u3092\u884c\u3044\u6bd4\u3092 s : t \u306b\u3059\u308b\u3068\u304d\u3001\u5909\u5316\u5f8c\u306e\u30ab\u30fc\u30c9\u679a\u6570\u3092\u8fd4\u3059\n \"\"\"\n # multiply_rate = max(math.ceil(a / s), math.ceil(b / t))\n multiply_rate = max((a + s - 1) // s, (b + t - 1) // t)\n return (s * multiply_rate, t * multiply_rate)\n \n \n n = ii()\n L = [lmi() for _ in range(n)]\n a, b = 1, 1\n for s, t in L:\n a, b = calc_minimum_card_pair(a, b, s, t)\n # print(a, b)\n \n # print('')\n print((a + b))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import fractions\nN=int(input())\n\nvt=va=0\nfor _ in range(N):\n T,A=map(int,input().split())\n kt=-(-vt//T)\n ka=-(-va//A)\n if kt==0 and ka==0:\n vt=T\n va=A\n else:\n k=max(kt,ka)\n vt=k*T\n va=k*A\n \n #print(vt,va)\n \nprint(vt+va)", "n = int(input())\nA, B = 0, 0\nfor i in range(n):\n x, y = map(int,input().split())\n dx, dy = 1, 1\n if A > x:\n dx = A // x\n if A % x != 0:\n dx += 1\n \n if B > y:\n dy = B // y\n if B % y != 0:\n dy += 1\n \n a = max(dx, dy)\n A, B = a * x, a * y\nprint(A + B)", "n = int(input())\nt_i,a_i = map(int,input().split())\nt = []\na = []\nt.append(t_i)\na.append(a_i)\nfor i in range(1,n):\n t_i,a_i = map(int,input().split())\n t.append(t_i)\n a.append(a_i)\n if t[i-1]>t[i] or a[i-1]>a[i]:\n t_max = t[i-1]//t[i]\n if t[i-1]%t[i]!=0:\n t_max += 1\n a_max = a[i-1]//a[i]\n if a[i-1]%a[i]!=0:\n a_max += 1\n bai = max(t_max,a_max)\n t[i] *= bai\n a[i] *= bai\nprint(t[-1]+a[-1])", "import math\n\nn = int(input())\nta = [list(map(int, input().split())) for _ in range(n)]\n\nx, y = ta[0]\nfor i in range(1, n):\n t, a = ta[i]\n k = max(-(-x // t), -(-y // a))\n x, y = k * t, k * a\n\nprint((x + y))\n", "from math import gcd\n\nn = int(input())\nfor i in range(n):\n a, b = list(map(int, input().split()))\n if i == 0:\n pre_a, pre_b = a, b\n if pre_a * b < pre_b * a:\n mul = (pre_b + b - 1) // b\n pre_b = mul * b\n pre_a = pre_b * a // b\n else:\n mul = (pre_a + a - 1) // a\n pre_a = mul * a\n pre_b = pre_a * b // a\n # print(i, pre_a, pre_b)\nprint((pre_a + pre_b))\n", "N=int(input())\nx,y=0,0\nfor i in range(N):\n p=0\n T,A=map(int,input().split())\n if i==0:\n x,y=T,A\n continue\n if x<=T and y<=A:\n x,y=T,A\n elif x<=T and A<y:\n if y%A!=0:\n p=1\n x=T*(y//A+p)\n y=A*(y//A+p)\n elif T<x and y<=T:\n if x%T!=0:\n p=1\n y=A*(x//T+p)\n x=T*(x//T+p)\n else:\n if (x//T+1)<=(y//A+1):\n if y%A!=0:\n p=1\n x=T*(y//A+p)\n y=A*(y//A+p)\n else:\n if x%T!=0:\n p=1\n y=A*(x//T+p)\n x=T*(x//T+p)\nprint(x+y)", "n=int(input())\nanst,ansa=map(int,input().split())\nfor _ in range(1,n):\n t,a=map(int,input().split())\n if anst>t or ansa>a:\n mul=max(-(-anst//t),-(-ansa//a))\n anst=mul*t\n ansa=mul*a\n else:\n anst=t\n ansa=a\nprint(anst+ansa)", "N=int(input())\nA,B=1,1\nfor i in range(N):\n tmpl=list(map(int,input().split()))\n tmp=max(-1*(-1*A//tmpl[0]),-1*(-1*B//tmpl[1]))\n A,B=tmpl[0]*tmp,tmpl[1]*tmp\nprint(A+B)", "from decimal import Decimal,getcontext\nfrom math import ceil\ngetcontext().prec = 1000\nN = int(input())\n\ntakahashi,aoki = 1,1\n\nfor _ in range(N):\n a,b = map(int,input().split())\n c = max(ceil(Decimal(takahashi)/Decimal(a)),ceil(Decimal(aoki)/Decimal(b)))\n takahashi = c*a\n aoki = c*b\n\nprint(takahashi+aoki)", "n = int(input())\n\nt1, a1 = list(map(int,input().split()))\n\nfor i in range(n-1):\n t,a = list(map(int,input().split()))\n if t1 * a == t * a1:\n pass\n elif t1 * a < t * a1:\n a1 = -(-a1 // a) * a\n t1 = a1 // a * t\n else:\n t1 = -(-t1 // t) * t\n a1 = t1 // t * a\n\nprint((a1+t1))\n", "N=int(input())\n\nvt=va=0\nfor _ in range(N):\n T,A=map(int,input().split())\n kt=-(-vt//T)\n ka=-(-va//A)\n \n k=max(kt,ka,1)\n vt=k*T\n va=k*A \n #print(vt,va)\n \nprint(vt+va)", "N = int(input())\nT, A = 1, 1\nfor _ in range(N):\n t, a = map(int,input().split())\n k = max((T - 1) // t + 1, (A - 1) // a + 1)\n T = t * k\n A = a * k\nprint(A + T)", "n = int(input())\nt_v = a_v = 1\nfor _ in range(n):\n t, a = [int(x) for x in input().split()]\n r = max((t_v + t - 1) // t, (a_v + a - 1) // a)\n t_v, a_v = r * t, r * a\nprint(t_v + a_v)", "N = int(input())\n\ntakahashi,aoki = 1,1\n\nfor _ in range(N):\n a,b = map(int,input().split())\n c = max((takahashi-1)//a+1,(aoki-1)//b+1)\n takahashi = c*a\n aoki = c*b\n\nprint(takahashi+aoki)", "n=int(input())\nans_t=1\nans_a=1\nfor i in range(n):\n t,a=map(int,input().split())\n if t==1:\n k1=ans_t\n else:\n \tk1=(ans_t-1)//t+1\n if a==1:\n k2=ans_a\n else:\n \tk2=(ans_a-1)//a+1\n k=max(k1,k2)\n ans_t=k*t\n ans_a=k*a\nprint(ans_t+ans_a)", "from sys import stdin\ndef main():\n #\u5165\u529b\n readline=stdin.readline\n n=int(readline())\n for i in range(n):\n if i==0:\n t,a=map(int,readline().split())\n else:\n t_i,a_i=map(int,readline().split())\n tmp1=(t+t_i-1)//t_i\n tmp2=(a+a_i-1)//a_i\n x=max(tmp1,tmp2)\n t=t_i*x\n a=a_i*x\n \n print(a+t)\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\nT, A = map(int, input().split())\nfor i in range(N-1):\n t, a = map(int, input().split())\n p = (T-1)//t + 1\n q = (A-1)//a + 1\n n = max(p, q)\n T = n*t\n A = n*a\nprint(T+A)", "N = int(input())\nTA = [list(map(int, input().split())) for _ in range(N)]\n\nT, A = 0, 0\nfor t, a in TA:\n if T == 0 and A == 0:\n T = t\n A = a\n continue\n if t == a:\n M = max(T, A)\n T = M\n A = M\n elif t < a:\n n = max((T // t) * t, (A // a) * t)\n while n < T or a * (n // t) < A:\n n += t\n T = n\n A = a * (T // t)\n else:\n n = max((A // a) * a, (T // t) * a)\n while n < A or t * (n // a) < T:\n n += a\n A = n\n T = t * (A // a)\nprint(A + T)", "import math\nN = int(input())\nta = [tuple(map(int,input().split())) for _ in range(N)]\nleft = ta[0][0]\nright = ta[0][1]\nres = left+right\nfor t,a in ta[1:]:\n tmp1 = (left+t-1)//t\n tmp2 = (right+a-1)//a\n buff = max(tmp1,tmp2)\n right = buff*a\n left = buff*t\nprint((int(right+left)))\n\n\n", "n=int(input())\nx,y=map(int,input().split())\nz=x+y\nfor i in range(n-1):\n a,b=map(int,input().split())\n k=max((x-1)//a,(y-1)//b)+1\n x=k*a\n y=k*b\nprint(x+y)"]
{"inputs": ["3\n2 3\n1 1\n3 2\n", "4\n1 1\n1 1\n1 5\n1 100\n", "5\n3 10\n48 17\n31 199\n231 23\n3 2\n"], "outputs": ["10\n", "101\n", "6930\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
41,770
6b9ed73bae9617b4deaf9edb740e405a
UNKNOWN
You are given a string S consisting of lowercase English letters. Determine whether all the characters in S are different. -----Constraints----- - 2 ≀ |S| ≀ 26, where |S| denotes the length of S. - S consists of lowercase English letters. -----Input----- Input is given from Standard Input in the following format: S -----Output----- If all the characters in S are different, print yes (case-sensitive); otherwise, print no. -----Sample Input----- uncopyrightable -----Sample Output----- yes
["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############################################################\nS = si()\nprint('yes' if len(set(S)) == len(S) else 'no')", "s = input()\ns = sorted(s)\ndif = True\nfor i in range(len(s)-1):\n if s[i] == s[i+1]:\n dif = False\nprint(\"yes\" if dif else \"no\")", "s = input()\nprint('yes') if len(set(list(s))) == len(s) else print('no')", "s=input()\nt=True\nfor i in s:\n if s.count(i) != 1:\n t=False\nprint(\"yes\" if t else \"no\")", "s=str(input())\nt=[]\nt.append(s[0])\nfor i in range(1,len(s)):\n if s[i] in t:\n print(\"no\")\n return\n t.append(s[i])\n\nprint(\"yes\")", "s=input()\nif len(s)==len(set(s)):\n print(\"yes\")\nelse:\n print(\"no\")", "s = input()\nans = \"yes\" if len(set(s)) == len(s) else \"no\"\nprint(ans)\n", "s = input()\nl = []\nfor i in range(len(s)):\n if not s[i] in l:\n l.append(s[i])\n else :\n print('no')\n return\nprint('yes')\n\n", "s = str(input())\nL = []\nfor i in s:\n if i in L:\n print('no')\n return\n else:\n L.append(i)\nprint('yes')", "s = input()\nres = \"yes\"\nfor i in range(len(s)):\n for j in range(i+1,len(s)):\n if s[i] == s[j]:\n res = \"no\"\nprint(res)", "s = input()\nse = set(s)\nprint(\"yes\" if len(s) == len(se) else \"no\")", "def main():\n s = input()\n ans = 'no'\n if len(set(s)) == len(s):\n ans = 'yes'\n print(ans)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "S=input()\nfor c in S:\n if S.count(c)>1:\n print(\"no\")\n break\nelse:\n print(\"yes\")\n", "s = list(map(str, input()))\n\nif len(s) == len(set(s)):\n print('yes')\nelse:\n print('no')\n", "s = [c for c in input()]\n\nif len(set(s)) < len(s):\n print('no')\nelse:\n print('yes')", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\n\nS = input()\nfor i in range(len(S)):\n if S.count(S[i])>1:\n print(\"no\")\n return\n\nprint(\"yes\")", "s=list(input())\nl=len(s)\nk=set(s)\nif l != len(k):\n print('no')\nelse:\n print('yes')", "s = input()\nprint('yes' if len(list(s)) == len(set(s)) else 'no')", "# ABC063\nfrom collections import Counter\n\nS = input()\ncount = Counter(S)\n\nfor cnt in count.values():\n if cnt != 1:\n print('no')\n return\nelse:\n print('yes')", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n s = input().rstrip()\n string_dict={}\n\n for i in s:\n if i not in string_dict:\n d = {i:1}\n string_dict.update(d) \n else:\n print(\"no\")\n return\n print(\"yes\")\n\ndef __starting_point():\n main()\n__starting_point()", "# 31\nS = str(input())\n\nlist = []\nans = 'yes'\nfor s in S:\n for past in list:\n if s == past: \n ans = 'no'\n break\n if ans == 'no': break\n list.append(s)\n\nprint(ans)", "s = input()\nif len(s) == len(list(set(list(s)))):\n print('yes')\nelse:\n print('no')", "S = input()\n\nn1 = len(S)\nn2 = len(set(S))\n\nif n1 == n2: print('yes')\nelse: print('no')", "S = input()\nls = []\ncheck = True\nfor i in range(len(S)):\n if S[i] in ls:\n check = False\n break\n ls.append(S[i])\n \nprint(\"yes\" if check else \"no\")", "S = input()\n\ndef duplicate(seq):\n seen = []\n unique = [x for x in seq if x not in seen and not seen.append(x)]\n return len(seq) != len(unique)\n\nif duplicate(S):\n print('no')\nelse:\n print('yes')", "string = input()\nprint('yes') if len(string) == len(set(string)) else print('no')\n \n", "S = input()\n\n\nprint(\"yes\" if len(set(S)) == len(S) else \"no\")", "a=[0]*26\nS=input()\ni=0\nwhile True:\n if i==len(S):\n print(\"yes\")\n break\n b=ord(S[i])-97\n if a[b]==1:\n print(\"no\")\n break\n else:\n a[b]=1\n i+=1", "data=list(input())\nc=0\nfor i in range(0,len(data)-1):\n for j in range(i+1,len(data)):\n if data[i]==data[j]:\n c=c+1\nif c==0:\n print('yes')\nelse:\n print('no')", "S=input()\nprint(\"yes\" if len(S)==len(set(S)) else \"no\")", "# \u300cABC-154-C\u300d\u306e\u985e\u984c\nS = input()\n \nn1 = len(S)\nn2 = len(set(S))\n \nif n1 == n2: print('yes')\nelse: print('no')", "s = str(input())\nchars = set()\nans = 'yes'\nfor c in s:\n if c in chars:\n ans = 'no'\n break\n chars.add(c)\nprint(ans)", "S = input()\nans = \"\"\n\nfor s in S:\n if S.count(s) > 1:\n ans = \"no\"\n break\n else:\n ans = \"yes\"\n\nprint(ans)\n", "S = input()\nT = sorted(S)\nU = set(T)\nU = sorted(U)\nif T == U:\n print('yes')\nelse:\n print('no')\n", "s = input()\nprint(\"yes\") if len(set(s)) == len(s) else print(\"no\")", "def main():\n s = input()\n answer = 'yes'\n\n for i in range(len(s)-1):\n if s[i] in s[i+1:]:\n answer = 'no'\n print(answer)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\nx = 0\nfor i in s:\n c = 0\n for j in s:\n if i == j:\n c += 1\n if c != 1:\n print(\"no\")\n break\n else:\n x += 1\n if x == len(s):\n print(\"yes\")\n break", "u = input()\nfor i in range(len(u)):\n for j in range(i+1,len(u)):\n if u[i]==u[j]:\n print(\"no\")\n return\nprint(\"yes\")", "s = input()\nl = []\nfor i in s:\n if i in l:\n print('no')\n return\n else:\n l.append(i)\nprint('yes')\n", "from collections import Counter\n\nstring = Counter(input())\n\nfor _ in string.values():\n if _ > 1:\n print(\"no\")\n break\nelse:\n print(\"yes\")", "s = input()\nbool = True\nfor i in range(len(s) - 1):\n for j in range(i + 1,len(s)):\n if s[i] == s[j]:\n bool = False\nif bool:\n print('yes')\nelse:\n print('no')", "s = list(map(str,input()))\nprint(\"yes\" if len(s) == len(set(s)) else \"no\")", "from collections import deque\nd = deque()\nfor s in input():\n if s in d:\n print('no')\n return\n else: \n d.append(s)\nprint('yes')", "# -*- coding:utf-8 -*-\nS = input()\n\npast = []\nans = \"yes\"\n\nfor s in S:\n if s not in past:\n past.append(s)\n else:\n ans = \"no\"\n break\n\nprint(ans)\n", "s = input()\nword = []\n\nfor i in s:\n if (i not in word):\n word.append(i)\n else:\n print('no')\n return\n\nprint('yes')\n", "s = input()\nprint(\"yes\" if len(s) == len(set(s)) else \"no\")", "import sys\nS = input()\n\nfor s in S:\n if S.count(s) > 1:\n print('no')\n return\n \nprint('yes')", "a=input()\nb=[]\nc=0\nfor i in range(len(a)):\n b.append(a[i])\nb.sort()\nfor i in range(len(a)-1):\n if b[i]==b[i+1]:\n c=c+1\nif c==0:\n print(\"yes\")\nelse:\n print(\"no\")", "s=input()\nt=set()\nfor x in s:\n if x in t:\n print('no')\n return\n else:\n t.add(x)\nprint('yes')", "s = input()\nprint(\"yes\" if len(s) == len(set(s)) else \"no\")", "S = input()\n\nfor i in range(len(S)):\n if S[i] in S[i+1:]:\n print('no')\n break\nelse:\n print('yes')", "S=list(input())\nS.sort()\ncount = 0\nfor i in range(len(S)-1):\n if S[i] == S[i+1]:\n count += 1\nif count == 0:\n print(\"yes\")\nelse:\n print(\"no\")", "from typing import List\n\n\nS = list(input()) # type: List[str]\nif len(S) == len(set(S)):\n print('yes')\nelse:\n print('no')\n", "def main():\n s = input()\n if len(set(s)) == len(s):\n print('yes')\n else:\n print('no')\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\na = \"\"\nfor i in s:\n if a.find(i) == -1:\n a += i\n else:\n print(\"no\")\n break\nelse:\n print(\"yes\")\n", "s = list(input())\nwhile s:\n c = s.pop()\n if c in s:\n print('no')\n return\nprint('yes')", "S=input()\nfor i in range(len(S)) :\n for j in range(i+1,len(S)) :\n if S[i]==S[j] :\n print(\"no\")\n return\nprint(\"yes\")", "S = input()\nprint(\"yes\") if len(S) == len(set(list(S))) else print(\"no\")", "S = str(input())\ndata1 = []\nfor i in range(len(S)):\n data1.append(S[i])\ndata2 = list(set(data1))\n\nif len(data1) == len(data2):\n print('yes')\nelse:\n print('no')\n", "s=input()\ns=sorted(s)\nfor i in range(len(s)-1):\n if s[i]==s[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,e3,e4 = map(int,input().split())\n#f = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\n\nd=set(c)\n\nif len(d)<len(c):\n print(\"no\")\nelse:\n print(\"yes\")", "#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)]\ns = list(input())\nif len(s) == len(set(s)):\n print('yes')\nelse:\n print('no')\n", "s = input()\nletters = []\nans = 'yes'\nfor i in s:\n if i in letters:\n ans = 'no'\n break\n else:\n letters.append(i)\nprint(ans)\n", "s = input()\nl = list(set(s))\nif len(s) == len(l):\n print(\"yes\")\nelse:\n print(\"no\")", "s = input()\nprint(\"yes\" if len(s)==len(set(s)) else \"no\")", "S=input()\na=[0]*26\nnum=ord('a')\nfor i in range(len(S)):\n tmp=ord(S[i])-num\n if a[tmp]:\n print('no')\n break\n a[tmp]=1\nelse:\n print('yes')\n", "s = str(input())\n\nif len(s) == len(set(s)):\n print(\"yes\")\nelse:\n print(\"no\")", "S = input()\nprint('yes' if len(set(S)) == len(S) else 'no')", "from collections import defaultdict\nimport sys\ns = input()\nn = len(s)\ndic = defaultdict(int)\n\nfor i in range(n):\n dic[s[i]] += 1\n if dic[s[i]]==2:\n print(\"no\")\n return\n\nprint('yes')", "S = list(input())\n\nS.sort()\n\nfor i in range(len(S)-1):\n if S[i] == S[i+1]:\n print('no')\n return\n \nprint('yes')\n\n", "S = input()\nif len(set(S)) == len(S):\n print(\"yes\")\nelse:\n print(\"no\")", "s = str(input())\n\nif len(s) == len(set(s)):\n print(\"yes\")\nelse:\n print(\"no\")", "s = input()\nfor i in range(len(s)-1):\n for j in range(i+1,len(s)):\n if s[i] == s[j]:\n print('no')\n return\nprint('yes')", "s = input()\n\nlst1 = []\nfor i in range(len(s)):\n lst1.append(s[i])\nlst1.sort()\n\nlst2 = list(set(lst1))\nlst2.sort()\n\nif lst1 == lst2:\n print('yes')\nelse:\n print('no')", "s=input()\nprint(\"yes\" if len(s)==len(set(s)) else \"no\")", "S = input()\n\nif len(set(S)) == len(S):\n print('yes')\n \nelse:\n print('no')", "#ABC063\ns = input()\nprint(\"yes\" if len(set(s))==len(s) else \"no\")", "s = list(input())\nif len(s) == len(set(s)):\n print(\"yes\")\nelse:\n print(\"no\")", "s = input()\nprint((\"yes\" if len(set(s)) == len(s) else \"no\"))\n", "# coding: utf-8\n\nstr = input()\ncount = 0\ntable = list(str)\nfor i in range(len(str) - 1):\n for j in range(i+1, len(str)):\n if table[i] == table[j]:\n count += 1\nif count == 0:\n print(\"yes\")\nelse:\n print(\"no\")", "s = input()\n\nst = set()\nfor c in s:\n if c in st:\n print(\"no\")\n return\n st.add(c)\n\nprint(\"yes\")\n", "S = list(input())\nans = \"yes\"\nfor i in range(len(S)):\n ch = S[i]\n S[i] = \"-1\"\n if ch in S:\n ans = \"no\"\n break\nprint(ans)", "def answer(s: str) -> str:\n return 'yes' if len(s) == len(set(s)) else 'no'\n\n\ndef main():\n s = input()\n print(answer(s))\n\n\ndef __starting_point():\n main()\n__starting_point()", "s=input()\nprint(\"yes\" if len(s)==len(set(s)) else \"no\")", "s=input()\nfor i in s:\n if s.count(i) != 1:\n print(\"no\")\n return\nprint('yes')", "S = input()\ndata = set()\nfor s in S:\n if s not in data:\n data.add(s)\n else:\n print(\"no\")\n return\nprint(\"yes\")", "l = list(input())\ns = set(l)\nif len(s) == len(l):\n\tprint(\"yes\")\nelse:\n\tprint(\"no\")\n", "s = list(input())\nn = len(s)\ns = set(s)\nnn = len(s)\n\nif n == nn:\n print(\"yes\")\nelse:\n print(\"no\")", "import collections\ns = input()\nc = collections.Counter(s)\n\nif all(x == 1 for x in c.values()):\n print('yes')\nelse:\n print('no')", "s = list(input())\nif len(s) == len(set(s)):\n print('yes')\nelse:\n print('no')", "s=input()\nn=len(s)\nfor i in range(n):\n if s.count(s[i])!=1:\n print('no')\n return\nprint('yes')", "S = list(input())\ns = set(S)\nif(len(S)==len(s)):\n print('yes')\nelse:\n print('no')", "S = input()\nprint('yes' if len(S) == len(set(S)) else 'no')", "s = input()\n\nif len(set(s)) == len(s):\n print(\"yes\")\nelse:\n print(\"no\")", "s = list(input())\nif len(s) == len(set(s)):\n print(\"yes\")\nelse:\n print(\"no\")", "s = list(input())\n\nfor i in s:\n if s.count(i) > 1:\n print('no')\n break\nelse:\n print('yes')\n", "s = input()\nif len(s) == len(set(s)):\n print(\"yes\")\nelse:\n print(\"no\")\n"]
{"inputs": ["uncopyrightable\n", "different\n", "no\n"], "outputs": ["yes\n", "no\n", "yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,669
a92957f45079f53aa09a345943688293
UNKNOWN
There are N people standing in a row from west to east. Each person is facing east or west. The directions of the people is given as a string S of length N. The i-th person from the west is facing east if S_i = E, and west if S_i = W. You will appoint one of the N people as the leader, then command the rest of them to face in the direction of the leader. Here, we do not care which direction the leader is facing. The people in the row hate to change their directions, so you would like to select the leader so that the number of people who have to change their directions is minimized. Find the minimum number of people who have to change their directions. -----Constraints----- - 2 \leq N \leq 3 \times 10^5 - |S| = N - S_i is E or W. -----Input----- Input is given from Standard Input in the following format: N S -----Output----- Print the minimum number of people who have to change their directions. -----Sample Input----- 5 WEEWW -----Sample Output----- 1 Assume that we appoint the third person from the west as the leader. Then, the first person from the west needs to face east and has to turn around. The other people do not need to change their directions, so the number of people who have to change their directions is 1 in this case. It is not possible to have 0 people who have to change their directions, so the answer is 1.
["n=int(input())\ns=input()\n\ncnt=s[1:].count(\"E\")\nans=cnt\n\nfor i in range(1,n):\n if s[i-1]==\"W\":\n cnt+=1\n if s[i]==\"E\":\n cnt-=1\n ans=min(ans,cnt)\n\nprint(ans)", "N = int(input())\nS = list(input())\n\ne_count = 0\nfor s in S:\n if s == 'E':\n e_count += 1\n\nmin_inv = float('infinity')\n \nfor s in S:\n if s == 'E':\n e_count -= 1\n \n min_inv = min(e_count, min_inv)\n \n if s == 'W':\n e_count += 1\n\nprint(min_inv)\n", "n=int(input())\ns=input()\nW_cnt=[0]\nE_cnt=[0]\n\nfor ss in s:\n w=W_cnt[-1]\n if ss==\"W\":\n w+=1\n W_cnt.append(w)\n\nfor ss in reversed(s):\n e=E_cnt[-1]\n if ss==\"E\":\n e+=1\n E_cnt.append(e)\nE_cnt=E_cnt[::-1]\n\nminc=float(\"inf\")\nfor i in range(n):\n c=(W_cnt[i] + E_cnt[i+1])\n minc=min(minc,c)\nprint(minc)\n", "N = int(input())\nS = list(input())\nans_list = []\n\nans = S[1:].count(\"E\")\nans_list.append(ans)\n\nfor i in range(1,N):\n if S[i-1] == \"W\":\n ans += 1\n if S[i] == \"E\":\n ans -= 1\n ans_list.append(ans)\n\nprint(min(ans_list))", "N = int(input())\nS = input()\nnumE = [0] * N\nnumW = [0] * N\nfor i in range(N):\n if S[i] == 'E':\n numE[i] += 1\n else:\n numW[i] += 1\n if 0 < i:\n numE[i] += numE[i - 1]\n numW[i] += numW[i - 1]\nans = N\nfor i in range(N):\n if i == 0:\n val = numE[-1] - numE[i]\n elif i == N - 1:\n val = numW[i - 1]\n else:\n val = numE[-1] - numE[i] + numW[i - 1]\n ans = min(ans, val)\nprint(ans)", "N = int(input())\nS = input()\n\ncnt = S[1:].count(\"E\")\nans = cnt\n\nfor i in range(1,N):\n if S[i-1] == \"W\":\n cnt += 1\n if S[i] == \"E\":\n cnt -= 1\n ans = min(ans, cnt)\n \nprint(ans)", "n = int(input())\ns = str(input())\nsE = s.count('E')\nsW = s.count('W')\nl = []\ne, w = 0, 0\nfor ch in s:\n if ch == 'E':\n e += 1\n else:\n w += 1\n m = (sE-e)+w\n l.append(sE-e+w-1 if ch == 'W' else sE-e+w)\nprint((min(l)))\n", "#!/usr/bin/env python3\n\nfrom itertools import accumulate\nn = int(input())\ns = [0 if i == \"E\" else 1 for i in str(input())]\n\ns_cumsum = list(accumulate(s))\ns_cumsum_rev = list(accumulate(reversed(s)))\n\nans = 10**10\n\nfor i in range(1, n-1):\n\n a_1 = s_cumsum[i-1]\n a_0 = i - a_1\n b_1 = s_cumsum_rev[-2-i]\n b_0 = (n-1-i) - b_1\n\n # print(a_1+b_0)\n ans = min(ans, a_1+b_0)\n\nans = min(ans, s_cumsum[-2])\nans = min(ans, (n-1)-s_cumsum_rev[-2])\nprint(ans)\n", "N = int(input())\nS = list(input())\n\nminCount = N\nleft = 0\nright = S.count(\"E\")\nfor n in range(0, N):\n if n != 0 and S[n-1] == \"W\":\n left += 1\n\n if S[n] == \"E\":\n right -= 1\n\n if minCount > left + right:\n minCount = left + right\n\nprint(minCount)\n", "N = int(input())\nS = list(input())\n\nsum_W = [0]\nfor i in range(1, N):\n if S[i-1] == \"W\":\n sum_W.append(sum_W[i-1]+1)\n else:\n sum_W.append(sum_W[i-1])\n\nsum_E = [S[1:].count(\"E\")]\nfor i in range(0, N-1):\n if S[i+1] == \"E\":\n sum_E.append(sum_E[i]-1)\n else:\n sum_E.append(sum_E[i])\n\ncounts = []\nfor i in range(N):\n count = 0\n counts.append(sum_W[i]+sum_E[i])\n\nprint(min(counts))", "N=int(input())\nS=input()\na=S.count(\"E\")\nc=a\nfor s in S:\n if s==\"E\":\n c-=1\n else:\n c+=1\n a=min(a,c)\nprint(a)\n", "n = int(input())\ns = input()\nres = n\ne = s.count(\"E\")\n\nl_w = 0\nl_e = 0\nfor i in range(n):\n if i == n - 1 and s[i] == \"E\":\n l_e += 1\n tmp = l_w + (e - l_e)\n res = min(tmp, res)\n if s[i] == \"W\":\n l_w += 1\n else:\n l_e += 1\nprint(res)\n", "n = int(input())\ns = str(input())\nleft = s[0]\nans = 10**6\nleft = {}\nleft.setdefault('W',0)\nleft.setdefault('E',0)\nright = {}\nright.setdefault('E',0)\nright.setdefault('W',0)\nfor i in range(n):\n right[s[i]] += 1\nans = 10**6\nfor i in range(n):\n right[s[i]] -= 1\n ans = min(ans,left['W']+right['E'])\n #print(left,right)\n left[s[i]] += 1\nprint(ans)\n \n", "import math\nimport sys\nimport os\nfrom operator import mul\nimport numpy as np\n\nsys.setrecursionlimit(10**7)\n\ndef _S(): return sys.stdin.readline().rstrip()\ndef I(): return int(_S())\ndef LS(): return list(_S().split())\ndef LI(): return list(map(int,LS()))\n\nif os.getenv(\"LOCAL\"):\n inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'\n sys.stdin = open(inputFile, \"r\")\nINF = float(\"inf\")\n\n\nN = I()\nS = list(_S())\nans = N\n\nSn = np.array(S)\nS_cum = np.zeros(N+1,dtype='int')\nS_cum[1:] = np.cumsum(Sn=='W')\n\nSnr=np.flip(Sn, 0)\nS_cumr = np.zeros(N+1,dtype='int')\nS_cumr[1:] = np.cumsum(Snr=='E')\n\n# print(S_cum)\n# print(S_cumr)\n\nfor i in range(N):\n attention = S_cum[i] + S_cumr[N-(i+1)]\n # print(attention)\n ans = min(ans, attention)\n\nprint(ans)", "n = int(input())\ns = input()\n\nw = [0]*n\ne = [0]*n\nif s[0] == \"W\": w[0] = 1\nelse: e[0] = 1\nfor i in range(1,n):\n if s[i] == \"W\":\n w[i] = w[i-1]+1\n e[i] = e[i-1]\n else:\n w[i] = w[i-1]\n e[i] = e[i-1]+1\n\nans = float(\"inf\")\nfor i in range(n):\n t = 0\n if i != 0: t += w[i-1]\n if i != n-1: t += e[-1] - e[i]\n if t < ans: ans = t\nprint(ans) ", "import sys\nsys.setrecursionlimit(10**8)\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 li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]\ndef dp2(ini, i, j): return [[ini]*i for _ in range(j)]\n#import bisect #bisect.bisect_left(B, a)\n#from collections import defaultdict #d = defaultdict(int) d[key] += value\n#from collections import Counter # a = Counter(A).most_common()\nfrom itertools import accumulate #list(accumulate(A))\n\nN = ii()\nS = input()\ncnt = [0] * N\n\nfor i in range(N):\n if S[i] == 'W':\n cnt[i] = 1\n\ncnt = list(accumulate(cnt))\nans = N\n\nfor i in range(N):\n if S[i] == 'E':\n ans = min(ans, cnt[i] + (N-1-i)-(cnt[-1]-cnt[i]))\n else:\n ans = min(ans, i+1-cnt[i] + (N-1-i)-(cnt[-1]-cnt[i]))\n\nprint(ans)", "N=int(input())\nS=list(input())\ne,w=[0]*(N+1),[0]*(N+1)\nfor i in range(1,N+1):\n w[i] += w[i-1] + (1 if S[i-1]=='W' else 0)\n e[i] += e[i-1] + (1 if S[i-1]=='E' else 0)\nans=N\nfor i in range(N):\n ans=min(ans,w[i]+e[-1]-e[i+1])\nprint(ans)", "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 n = i_input()\n s = input()\n\n ans = 0\n for i in s[1:]:\n if i == \"E\":\n ans += 1\n l = [ans]\n\n for i in range(n-1):\n trial = 0\n if s[i] == \"W\":\n trial += 1\n if s[i+1] == \"E\":\n trial -= 1\n ans += trial\n l.append(ans)\n\n print((min(l)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\ns = input()\narr = []\nE = s.count('E')\nw = 0\ne = 0\nfor i in range(n):\n if s[i] == 'W':\n arr.append(w + E - e)\n w += 1\n else:\n arr.append(w + E - e - 1)\n e += 1\nans = min(arr)\nprint(ans)", "N = int(input())\nS = input()\ne = S.count(\"E\")\ncnt = e\nfor i in S:\n if i == \"E\":\n cnt -= 1\n else:\n cnt += 1\n e = min(e, cnt)\nprint(e)", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nfrom itertools import accumulate\ndef main():\n n = int(input())\n s = list(input())\n enum = [1 if c == 'E' else 0 for c in s]\n wnum = [1 if c == 'W' else 0 for c in s]\n enuma = tuple(accumulate(enum))\n wnuma = tuple(accumulate(wnum))\n wnumm = wnuma[-1]\n wnuma2 = [wnumm - wn for wn in wnuma]\n num = max(wnuma2[0], enuma[-2])\n for i1 in range(1, n - 1):\n num = max(num, enuma[i1 - 1] + wnuma2[i1])\n r = n - num - 1\n print(r)\n\ndef __starting_point():\n main()\n__starting_point()", "#\n# abc096 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 = \"\"\"5\nWEEWW\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"12\nWEWEWEEEWWWE\"\"\"\n output = \"\"\"4\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"8\nWWWWWEEE\"\"\"\n output = \"\"\"3\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n S = list(input())\n\n# ans = float(\"inf\")\n# for i in range(N):\n# if i == 0:\n# ans = min(ans, S[1:].count(\"E\"))\n# elif i == N-1:\n# ans = min(ans, S[0:N-1].count(\"W\"))\n# else:\n# ans = min(ans, S[0:i].count(\"W\") + S[i+1:].count(\"E\"))\n# print(ans)\n\n W = [0] * N\n E = [0] * N\n L = 0\n R = 0\n\n for i in range(N):\n if S[i] == \"W\":\n L += 1\n if S[N-1-i] == \"E\":\n R += 1\n W[i] = L\n E[N-1-i] = R\n\n ans = float(\"inf\")\n for i in range(N):\n ans = min(ans, E[i]+W[i]-1)\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "EW=0\nans=99999999999999999999999999999999\n\nN=int(input())\nS=input()\n\nfor i in range(N):\n if i==0:\n pass\n elif S[i]==\"E\":\n EW+=1\nif ans>EW:\n ans=EW\n\nfor j in range(1,N):\n if S[j]==\"E\":\n EW-=1\n if S[j-1]==\"W\":\n EW+=1\n\n if ans>EW:\n ans=EW\nprint(ans)\n", "N=int(input())\nS=list(input())\ne,w=[0]*(N+1),[0]*(N+1)\nfor i in range(1,N+1):\n w[i] += w[i-1] + (1 if S[i-1]=='W' else 0)\n e[i] += e[i-1] + (1 if S[i-1]=='E' else 0)\nans=N\nfor i in range(N):\n ans=min(ans,w[i]+e[-1]-e[i+1])\nprint(ans)", "n=int(input())\ns=input()\n\ndef count(n,s):\n cntw=0\n cnte=0\n mcntw=0\n mcnte=0\n maxn=0\n for i in range(n):\n if s[i]==\"W\":\n cntw+=1\n else:\n cnte+=1\n if maxn<cnte-cntw:\n maxn=cnte-cntw\n mcnte=cnte\n mcntw=cntw\n\n if cntw==0 or cnte==0:\n print((0))\n return\n\n else:\n print((mcntw+cnte-mcnte))\n return\ncount(n,s)\n\n", "N = int(input())\nS = list(input())\n\nans = N\n\nleft_W = 0\nright_E = S[1:].count(\"E\")\n\nfor n in range(N):\n if n == 0:\n ans = min(ans,S[1:].count(\"E\"))\n \n elif n == N-1 :\n ans = min(ans,S[:n].count(\"W\"))\n \n else:\n if S[n] == \"E\":\n right_E -= 1\n if S[n-1] == \"W\":\n left_W += 1\n ans = min(ans,left_W + right_E)\n\nprint(ans)", "N = int(input())\nS = input()\nans = S.count(\"E\")\nleft = 0\nright = ans\nfor i in S:\n if i == \"E\":\n right -= 1\n ans = min(ans,right+left)\n if i == \"W\":\n ans = min(ans,right+left)\n left += 1\nprint(ans)", "# import itertools\n# import math\n# import sys\n# sys.setrecursionlimit(500*500)\n# import numpy as np\n# import heapq\n# from collections import deque\n\nN = int(input())\nS = 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)]\n# S = 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\nnum_E = [0] * N\nnum_W = [0] * N\nmax_num = 0\nleader_index = 0\nfor i, c in enumerate(S):\n if c == \"W\":\n num_W[i] = num_W[i - 1] + 1\n num_E[i] = num_E[i - 1]\n else:\n num_W[i] = num_W[i - 1]\n num_E[i] = num_E[i - 1] + 1\n tmp = num_E[i] - num_W[i]\n if max_num < tmp:\n leader_index = i\n max_num = tmp\n\nprint(S[:leader_index].count(\"W\") + S[leader_index + 1:].count(\"E\"))", "n = int(input())\ns = input()\nl = [0]*n\nr = [0]*n\nfor i in range(1, n):\n l[i] = l[i-1] + (s[i-1] == 'W')\nfor i in range(n-2, -1, -1):\n r[i] = r[i+1] + (s[i+1] == \"E\")\nans = n-1\nfor i in range(n):\n ans = min(ans, l[i]+r[i])\nprint(ans)\n\n", "n = int(input())\ns = input()\nl = [0] * n\nr = [0] * n\nans = n\nfor i in range(n):\n if i == 0:\n if s[0] == \"W\":\n l[0] = 1\n elif s[i] == \"W\":\n l[i] = l[i - 1] + 1\n else:\n l[i] = l[i - 1]\n if i == 0:\n if s[-1] == \"E\":\n r[0] = 1\n elif s[-i-1] == \"E\":\n r[i] = r[i - 1] + 1\n else:\n r[i] = r[i - 1]\nfor i in range(n):\n if i == 0:\n ans = min(ans, r[n - 1 - i])\n elif i == n - 1:\n ans = min(ans, l[i - 1])\n else:\n ans = min(ans, l[i - 1] + r[n - 1 - i])\nprint(ans)", "N = int(input())\nS = input()\n\nA = [0]*N\nB = [0]*N\n\nfor i in range(1, N):\n A[i] = A[i-1] + (1 if S[i-1]=='W' else 0)\n B[N-i-1] = B[N-i] + (1 if S[N-i]=='E' else 0)\n\nprint(min(map(lambda x: x[0]+x[1], zip(A, B))))", "import math\n\nn = int(input())\ns = input()\n\neS = [0] * n\nwS = [0] * n\n\nec = 0\nfor i in range(n):\n eS[i] = ec\n if s[i] == \"W\":\n ec += 1\n\nwc = 0\nfor i in reversed(list(range(n))):\n wS[i] = wc\n if s[i] == \"E\":\n wc += 1\n\nans = 10000000\n\nfor i in range(n):\n ans = min(ans, eS[i] + wS[i])\n\nprint(ans)\n", "n = int(input())\ns = input()\ne = s.count('E')\nw = s.count('W')\nans = 1000000\ne_counter = 0\nw_counter = 0\nfor i in range(len(s)):\n if s[i] == 'E':\n e_counter += 1\n else:\n w_counter += 1\n d = w_counter\n if s[i] == 'W':\n d -= 1\n ans1 = d + (e - e_counter)\n ans = min(ans1, ans)\nprint(ans)", "N = int(input())\nS = list(input())\ndirected = [S[1:].count(\"W\")]\n\nfor i in range(1, len(S)):\n d = directed[i - 1]\n if S[i - 1] == \"E\":\n d += 1\n if S[i] == \"W\":\n d -= 1\n directed.append(d)\n\nprint(N - max(directed) - 1)", "n=int(input())\ns=list(input())\nsw=[0]\nse=[0]\nswc=0\nsec=0\nfor i in range(n):\n if s[i]=='W':\n swc+=1\n else:\n sec+=1\n sw.append(swc)\n se.append(sec)\nm=n\nfor i in range(n+1):\n m=min(m,sw[i]+se[-1]-se[i])\nprint(m)", "\nn = int(input())\nA =input()\ne = A.count('E')\ncnt = e\n\nfor i in A:\n if i == 'E':\n cnt -= 1\n else:\n cnt += 1\n e = min(e,cnt)\n\nprint(e)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Sat Sep 19 20:18:57 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nS = input()\n\ntmp = 0\n\nfor i in range(1,N):\n if S[i] == \"E\":\n tmp += 1\n\nans = 10**6\nfor i in range(N):\n if ans > tmp:\n ans = tmp\n if i == N-1:\n break\n if S[i] == \"W\":\n tmp += 1\n if S[i+1] == \"E\":\n tmp -= 1\n #print(tmp)\n \nprint(ans)", "N = int(input())\nS = input()\n\n\nw_cnt = 0\ne_cnt = 0\nw_lst = []\ne_lst = []\n\nfor s in S:\n if s == 'W':\n w_cnt += 1\n\n else:\n e_cnt += 1\n\n w_lst.append(w_cnt)\n e_lst.append(e_cnt)\n\nans = float('inf')\ne_all = e_lst[-1]\nfor i in range(N):\n if S[i] == 'W':\n t = w_lst[i] - 1 + e_all - e_lst[i]\n else:\n t = w_lst[i] + e_all - e_lst[i]\n\n ans = min(ans, t)\n\n\nprint(ans)", "n = int(input())\na = list(input())\nwcnt,ecnt,ans,box = 0,0,0,[]\nW = a.count(\"W\")\nE = a.count(\"E\")\nfor i in range(n-1):\n if a[i] == \"W\":\n box.append(E+wcnt)\n wcnt += 1\n W -= 1\n else:\n box.append(E+wcnt)\n ecnt += 1\n E -= 1\nif a[n-1] == \"W\":\n W -= 1\n box.append(E+wcnt)\n wcnt += 1\nelse:\n E -= 1\n box.append(E+wcnt)\n ecnt += 1\nprint(min(box))", "n = int(input())\ns = input()\n\ne_all = s.count(\"E\")\nw_all = s.count(\"W\")\ne_l = 0\nw_l = 0\n\nunti = [0] * n\n\nfor i in range(n):\n if s[i] == \"E\":\n e_l += 1\n unti[i] = w_l + (e_all - e_l) \n if s[i] == \"W\":\n unti[i] = w_l + (e_all - e_l) \n w_l += 1\n\n\n#print(unti)\nprint(min(unti))", "n = int(input())\ns = input()\n\nleft = [0] * n\nright = [0] * n\n\ntmp = 0\nfor i in range(1, n):\n if s[i - 1] == \"W\":\n tmp += 1\n left[i] = tmp\n else:\n left[i] = tmp\n\ntmp = 0\nfor i in range(n - 2, -1, -1):\n if s[i + 1] == \"E\":\n tmp += 1\n right[i] = tmp\n else:\n right[i] = tmp\n\nres = 10**9\nfor i in range(n):\n res = min(res, left[i] + right[i])\nprint(res)\n", "N = int(input())\nS = input()\n\nEP = [0]*(N+1)\nWP = [0]*(N+1)\nCP = [0]*N\nfor T in range(0,N):\n EP[N-T-1] = EP[N-T]+(S[N-1-T]=='E')\n WP[T+1] = WP[T]+(S[T]=='W')\nfor T in range(0,N):\n CP[T] = EP[T+1]+WP[T]\nprint(min(CP))", "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 = int(readline())\n S = readline().strip()\n\n east = [0] * (N + 1)\n west = [0] * (N + 1)\n for i in range(N):\n east[i + 1] = east[i] + (1 if S[i] == 'E' else 0)\n west[i + 1] = west[i] + (1 if S[i] == 'W' else 0)\n\n ans = INF\n for i in range(N):\n if ans > west[i] + east[N] - east[i + 1]:\n ans = west[i] + east[N] - east[i + 1]\n\n print(ans)\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n=int(input())\ns=input()\nv=[0 for i in range(n)]\n\nfor i in range(n):\n j=0\n if s[i]==\"E\":\n j=1\n else:\n j=-1\n if i==0:\n v[i]+=j\n else:\n v[i]+=j+v[i-1]\n\nsum=-2\nw=0\nres=\"\"\nfor i in range(n):\n if sum<v[i]:\n sum=v[i]\n wmax=w\n emax=i-w\n res=s[i]\n if s[i]==\"W\":\n w+=1\n\nif res==\"W\":\n print((wmax+s.count(\"E\")-emax))\nelse:\n print((wmax+s.count(\"E\")-emax-1))\n", "N = int(input())\nS = list(input())\nallW = S.count('W')\nallE = S.count('E')\nnumW = S.count('E')\nnumE = 0\nans = 3*10**5\nfor i in range(N):\n if S[i] == 'E':\n numW -= 1\n ans = min(ans,numW + numE)\n if S[i] == 'W':\n numE += 1 \nprint(ans)", "N = int(input())\nS = list(input())\n\nlst = [0]*N\nRe = S.count(\"E\")\nLw = 0\n\nfor i in range(N):\n if S[i] == \"E\":\n Re -= 1\n lst[i] = Re + Lw\n else:\n Lw += 1\n lst[i] = Re + Lw - 1\n\nans = min(lst)\nprint(ans)\n", "n=int(input())\ns=input()\n\ndp_w=[0]\ndp_e=[0]\n\nfor i in range(n):\n if i!=0:\n dp_w.append(dp_w[-1])\n dp_e.append(dp_e[-1])\n if s[i]==\"W\":\n dp_w[-1]+=1\n else:\n dp_e[-1]+=1\n\ndef migi(i):\n if i==n-1:\n return 0\n return dp_e[n-1]-dp_e[i]\ndef hidari(i):\n if i==0:\n return 0\n return dp_w[i-1]\nans=1000000000000000\nfor i in range(n):\n right=migi(i)\n left=hidari(i)\n ans=min(right+left,ans)\nprint(ans)", "n = int(input())\ns = list(input())\ncnt = 0\nans_list = [0]\ne_cnt = 0\n\nfor i in range(1,n):\n if s[i-1] == \"E\" and s[i] == \"E\":\n cnt -= 1\n e_cnt += 1\n if s[i-1] == \"E\" and s[i] == \"W\":\n cnt -= 0\n if s[i-1] == \"W\" and s[i] == \"E\":\n cnt += 0\n e_cnt += 1\n if s[i-1] == \"W\" and s[i] == \"W\":\n cnt += 1\n ans_list.append(cnt)\n\nprint(min(ans_list) + e_cnt)", "from collections import Counter\nn = int(input())\ns = input()\nsn = Counter(s)\n\nl = 0\nr = sn['E']\n\nans = r\nfor i in range(n):\n if s[i] == 'W':\n l += 1\n else:\n r -= 1\n ans = min(ans, l+r)\nprint(ans)\n", "n = int(input())\ns = input()\n\nw = [0]*n\ne = [0]*n\n\nif s[0] == \"W\": w[0] += 1\nelse: e[0] += 1\nfor i in range(1,n):\n if s[i] == \"W\":\n w[i] = w[i-1]+1\n e[i] = e[i-1]\n else:\n w[i] = w[i-1]\n e[i] = e[i-1]+1\n\nans = float(\"inf\")\nif e[n-1]-e[0] < ans: ans = e[n-1]-e[0]\nif w[n-1] < ans: ans = w[n-1]\n\nfor i in range(1,n-1):\n t = w[i-1] + e[n-1]-e[i]\n if t < ans: ans = t\nprint(ans)", "n = int(input())\ns = input()\n\nans = [0]*(n+1)\nfor i in range(n):\n if s[i] == 'E':\n ans[i+1] = ans[i] + 1\n else:\n ans[i+1] = ans[i]\n \nprint(min(i-ans[i]+ans[n]-ans[i+1] for i in range(n)))", "def count(left_w, right_e):\n return left_w + right_e\n\n\ndef main():\n n = int(input())\n s = str(input())\n\n w_count = s.count('W')\n e_count = n - w_count\n\n lst = []\n left = 0\n left_w = 0\n right = n\n right_e = e_count\n for i in range(n):\n s_alp = s[i]\n right -= 1\n if s_alp == 'E':\n right_e -= 1\n\n lst.append(count(left_w, right_e))\n\n left += 1\n if s_alp == 'W':\n left_w += 1\n\n minimum = min(lst)\n print(minimum)\n\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\ns = input()\ne = s.count(\"E\")\nw = n - e\nans = 10**9\nif s[0] == \"W\":\n cnt = e\nelse:\n cnt = e-1\nnum = cnt\nfor i in range(n-1):\n if s[i] == s[i+1] and s[i] == \"E\":\n cnt -= 1\n elif s[i] == s[i+1]:\n cnt += 1\n ans = min(ans,cnt,num)\n ans = max(ans,0)\nprint(max(ans,0))", "n=int(input())\ns=list(input())\nans=[0]*n\nans[0]+=list(s[1:]).count(\"E\")\nfor i in range(1,n):\n if s[i]==\"E\" and s[i-1]==\"E\":\n ans[i]=ans[i-1]-1\n elif (s[i]==\"E\" and s[i-1]==\"W\") or (s[i-1]==\"E\" and s[i]==\"W\"):\n ans[i]=ans[i-1] \n else:\n ans[i]=ans[i-1]+1\nprint(min(ans))", "# -*- coding: utf-8 -*-\n\nN = int(input())\nS = list(input())\n\nW = [0] * N\nE = [0] * N\n\nW_pre = E_pre = 0\nfor i in range(N):\n if S[i] == \"W\":\n W[i] = W_pre + 1\n E[i] = E_pre\n else:\n W[i] = W_pre\n E[i] = E_pre + 1\n W_pre = W[i]\n E_pre = E[i] \n\nans = N\nfor i in range(N):\n if i>0:\n res1 = W[i-1]\n else:\n res1 = 0\n res2 = E[N-1]-E[i]\n #print(i,res1,res2)\n ans = min(ans,res1+res2)\n\nprint(ans)\n", "N = int(input())\nS = input()\na = S.count(\"E\")\nc = a \n\nfor s in S:\n if s==\"E\":\n c-=1\n else:\n c+=1\n a=min(a,c)\n\nprint(a)", "N = int(input())\nS = input()\nl = 0\nr = S[1:N].count('E')\nans = l+r\n\nfor n in range(1,N):\n if S[n-1]==\"W\":\n l+=1\n if S[n]==\"E\":\n r-=1\n ans=min(ans,l+r)\n\nprint(ans)", "n = int(input())\ns = input()\n\ncount = s.count('E')\nans = s.count('E')\nfor i in range(len(s)):\n if s[i] == 'E':\n count -=1\n else:\n count+=1\n ans = min(count,ans)\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\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 S = INPUT()\n\n left, right = 0, S[1:].count('E')\n ans = left + right\n for i in range(N-1):\n if S[i] == 'W':\n left += 1\n if S[i+1] == 'E':\n right -= 1\n\n ans = min(ans, left + right)\n\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "# import sys\n# sys.setrecursionlimit(10 ** 6)\n# import bisect\n# # from collections import deque\n# from decorator import stop_watch\n#\n#\n# @stop_watch\ndef solve(N, S):\n W_sum = [0]\n E_sum = [0]\n for s in list(S):\n if s == 'W':\n W_sum.append(W_sum[-1] + 1)\n E_sum.append(E_sum[-1])\n else:\n W_sum.append(W_sum[-1])\n E_sum.append(E_sum[-1] + 1)\n\n ans = N + 1\n for i in range(1, N + 1):\n ans = min(W_sum[i - 1] + (E_sum[-1] - E_sum[i]), ans)\n\n print(ans)\n\n\n\ndef __starting_point():\n N = int(input())\n S = input()\n solve(N, S)\n\n # # test\n # from random import randint\n # from func import random_str\n # solve()\n\n__starting_point()", "n=int(input())\ns=list(input())\n\nE=s.count('E')\nW=s.count('W')\n\nif s[0]=='E':\n ans=E-1\nelse:\n ans=E\n \nans1=[]\nans1.append(ans)\n \nfor x in range(1,n):\n if s[x]=='E':\n if s[x-1]=='E':\n ans-=1\n \n else:\n if s[x-1]=='W':\n ans+=1\n ans1.append(ans)\n \nprint(min(ans1))", "def main():\n N = int(input())\n S = input()\n lst = [0] * N\n ans = N\n\n if S[0] == \"E\":\n lst[0] = 1\n for i in range(1, N):\n if S[i] == \"E\":\n lst[i] = lst[i - 1] + 1\n else:\n lst[i] = lst[i - 1]\n\n for i in range(N):\n if i == 0:\n left = 0\n else:\n left = i - lst[i - 1]\n right = lst[N - 1] - lst[i]\n\n if left + right < ans:\n ans = left + right\n\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nS = list(input())\nE = S[1:].count('E')\nW = 0\nmi = E+W\nfor i in range(1,N):\n if S[i] == 'E':E -= 1\n if S[i-1] == 'W':W+=1\n if E+W <= mi:mi = E+W\nprint(mi)\n", "N = int(input())\nS = input()\n\nwest = [0]*N\neast = [0]*N\n\ntmp = 0\nfor i in range(1,N):\n if S[i-1] == 'W':\n tmp += 1\n west[i] = tmp\n else:\n west[i] = tmp\n\ntmp = 0\nfor i in range(N-2,-1,-1):\n if S[i+1] == 'E':\n tmp += 1\n east[i] = tmp\n else:\n east[i] = tmp\n\nans = float('inf')\nfor i in range(N):\n ans = min(ans,west[i]+east[i])\nprint (ans)\n", "import sys\n\nN = int(input())\nS = input()\n\nW = [0]*N\nE = [0]*N\nans = N\nfor i in range(1, N):\n W[i] = W[i-1]+1 if S[i-1]=='W' else W[i-1]\n E[-i-1] = E[-i]+1 if S[-i]=='E' else E[-i]\n\nfor i in range(N):\n ans = min(W[i]+E[i], ans)\n\nprint(ans)\n\n\n\n", "n=int(input())\nS=list(input())\nW=[0]*(n+1)\nE=[0]*(n+1)\nfor i in range(n):\n W[i]=W[i-1]+S[i].count(\"W\")\n E[n-i-1]=E[n-i]+S[n-i-1].count(\"E\")\nW = W[:n]\nE = E[:n]\nans = 1000000\nfor i in range(n):\n ans = min(ans,W[i]+E[i]-1)\nprint(ans)\n", "n=int(input())\ns=input()\nW=0 ; E=s[1:].count(\"E\")\nans=float(\"inf\")\nfor i in range(n):\n ans=min(ans, W+E)\n if i==n-1:print(ans);return\n if s[i]==\"W\":\n W+=1\n if s[i+1]==\"E\":\n E-=1", "N = int(input())\nS = input()\n\ne_all = S.count('E')\n\nw_cnt = 0\ne_cnt = 0\nans = float('inf')\nfor i in range(N):\n if S[i] == 'W':\n w_cnt += 1\n ans = min(ans, w_cnt - 1 + e_all - e_cnt)\n else:\n e_cnt += 1\n ans = min(ans, w_cnt + e_all - e_cnt)\n\nprint(ans)\n", "n = int(input())\ns = input()\n\nfrom collections import Counter\ncount = Counter(s[1:])\nx = count[\"E\"]\n\ntemp =x\nfor i in range(1,n):\n if s[i-1] ==\"W\":\n x +=1\n if s[i] ==\"E\":\n x -=1\n temp = min(temp,x)\n\nprint(temp) ", "n = int(input())\ns = input()\nres = n\nw = 0\ne = 0\nfor i in range(n):\n if s[i] == \"W\":\n w += 1\n else:\n e += 1\n\nl_w = 0\nl_e = 0\nfor i in range(n):\n if i == n - 1 and s[i] == \"E\":\n l_e += 1\n tmp = l_w + (e - l_e)\n res = min(tmp, res)\n if s[i] == \"W\":\n l_w += 1\n else:\n l_e += 1\nprint(res)\n", "N = int(input())\nS = input()\nwest = S.count('W')\neast = N - west \nQ = [0,0,west,east] #[\u81ea\u5206\u3088\u308a\u897f\u3067\u897f\u5411\u304d\u3001\u6771\u5411\u304d\u3001\u81ea\u5206\u3088\u308a\u6771\u3067\u897f\u5411\u304d\u3001\u6771\u5411\u304d]\nans = N-1\nfor i in range(N):\n if S[i]=='W':\n Q[2]-=1\n cnt = Q[0]+Q[3]\n Q[0]+=1\n else:\n Q[3]-=1\n cnt = Q[0]+Q[3]\n Q[1]+=1\n ans = min(ans,cnt)\nprint(ans)", "N = int(input())\nr = input()\n\nE_sum = sum(x == \"E\" for x in r)\nW_sum = N-E_sum\nleft_sum = 0\nright_sum = E_sum\nmin_sum = E_sum\nfor i in range(N):\n if i == 0:\n if r[i] == \"E\":\n min_sum -= 1\n prev_sum = min_sum\n else:\n if (r[i-1], r[i]) == (\"W\", \"W\"):\n prev_sum += 1\n elif (r[i-1], r[i]) == (\"E\", \"W\"):\n pass\n elif (r[i-1], r[i]) == (\"E\", \"E\"):\n prev_sum -= 1\n elif (r[i-1], r[i]) == (\"W\", \"E\"):\n pass\n if min_sum > prev_sum:\n min_sum = prev_sum\n\nprint(min_sum)", "#!/usr/bin/env python\n\nn = int(input())\ns = input()\n\ntotal_E = s.count('E')\ntotal_W = n-total_E\n\nright_E = []\ntmp_E = total_E\ntmp_W = 0 \nfor i in range(n):\n if s[i] == 'E':\n tmp_E -= 1 \n right_E.append(tmp_E)\n\nleft_W = [0] \nfor i in range(1,n):\n if s[i-1] == 'W':\n tmp_W += 1 \n left_W.append(tmp_W)\n\ncandidates = []\nfor i in range(n):\n candidates.append(right_E[i]+left_W[i])\n\n#print('candidates =', candidates)\n#print('right_E =', right_E)\n#print('left_W =', left_W)\nans = min(candidates)\nprint(ans)\n", "n = int(input())\ns = [(i == \"W\")*1 for i in list(input())]\nc = [0]*(n+1)\nfor i in range(n):\n c[i+1] = c[i] + s[i]\nans = float(\"inf\")\nfor i in range(n):\n t = c[i] + (n-i-1-c[-1]+c[i+1])\n ans = min(ans,t)\nprint(ans)", "inf = float('inf')\nn = int(input())\ns = input()\n\nright_e = s.count(\"E\")\nleft_w = 0\ncnt = inf\n\nfor e in s:\n if e == \"W\":\n cnt = min(cnt, right_e + left_w)\n left_w += 1\n else:\n right_e -= 1\n cnt = min(cnt, right_e + left_w)\nprint(cnt)", "N=int(input())\nS=input()\na=[0]\nfor i in range(N):\n a.append(a[-1])\n if S[i]=='W':\n a[-1]+=1\n\nans=N\nfor i in range(N):\n ans=min(ans,a[i]+N-(i+1)-(a[N]-a[i+1]))\nprint(ans)\n", "n = int(input())\ns = input()\nwcnt = [0] * n\necnt = [0] * (n)\nenum = 0\nwnum = 0\nfor i in range(n):\n if s[i] == \"W\":\n wnum += 1\n wcnt[i] += wnum\n if s[-i - 1] == \"E\":\n enum += 1\n ecnt[-i - 1] += enum\nans = 10 ** 10\nfor i in range(n):\n temp = 0\n if i - 1 >= 0:\n temp += wcnt[i - 1]\n if i + 1 < n:\n temp += ecnt[i + 1]\n ans = min(ans, temp)\nprint(ans)\n", "N=int(input())\nS=input()\nans=S.count(\"W\")\nans1=-10\nfor i in range(N):\n if S[i]==\"W\":\n ans-=1\n if i!=0:\n if S[i-1]==\"E\":\n ans+=1\n ans1=max(ans,ans1)\nprint(N-1-ans1)", "n=int(input())\ns=input()\nl,r=[],[]\nans=min(s.count(\"W\"),s.count(\"E\"))\nk=s.count(\"E\")\nfor i in range(n):\n if s[i]==\"W\":\n k+=1\n else:\n k-=1\n ans=min(ans,k)\nprint(ans)", "def main():\n n = int(input())\n ss = list(input())\n num_sum = [0]*n\n west_sum = 0\n east_sum = 0\n for i in range(1, n):\n if ss[i-1] == 'W':\n west_sum += 1\n num_sum[i] += west_sum\n\n for i in range(n-2, -1, -1):\n if ss[i+1] == 'E':\n east_sum += 1\n num_sum[i] += east_sum\n\n ans = min(num_sum)\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "from itertools import accumulate\nn = int(input())\ns = list(input())\nl = [1 if s[i] == \"E\" else 0 for i in range(n)]\nl = list(accumulate(l))\nans = l[-1]-l[0]\nfor i in range(1, n):\n ans = min(ans, i-l[i-1] + l[-1]-l[i])\nprint(ans)", "def schange(s):\n if s==\"E\":\n return 1\n else:\n return 0\n\nn = int(input())\ns = list(map(schange,input()))\nssum = [0]*(n+1)\n\nfor i in range(n):\n ssum[i+1] = ssum[i] + s[i]\n\nans = float('inf')\nfor i in range(1,n+1):\n turnE = (i-1)-ssum[i-1]\n turnW = ssum[-1] - ssum[i]\n ans=min(ans,turnE+turnW)\n \nprint(ans)", "N = int(input())\nS = input()\n \noE = S.count(\"E\")\nWo = 0\n\nL = []\nfor i in range(N):\n if i == 0:\n if S[i] == \"E\":\n oE -= 1\n else:\n if S[i-1] == \"W\":\n Wo += 1\n if S[i] == \"E\":\n oE -= 1\n L.append(Wo + oE)\n if Wo + oE == 0:\n break\nprint(min(L))", "n = int(input())\ns = input()\n\nli = []\nfor i in range(n):\n if s[i]==\"W\":\n li.append(-1)\n else:\n li.append(1)\n\ncumsum = [li[0]]\nfor i in range(n-1):\n cumsum.append(cumsum[i] + li[i+1])\n\nl = cumsum.index(max(cumsum))\nw_to_e = 0\ne_to_w = 0\n\nfor i in range(n):\n if i < l:\n if li[i]==-1:\n w_to_e += 1\n elif i > l:\n if li[i]==1:\n e_to_w += 1\nprint(e_to_w + w_to_e)", "from collections import deque\n\nN=int(input())\nS=input()\n\nleft=deque([0])\nright=[0]\nfor i in range(N):\n if S[i]=='W':plus=1\n else:plus=0\n left.append(left[-1]+plus)\n if S[-i-1]=='E':plus=1\n else:plus=0\n right.append(right[-1]+plus)\n \nleft.popleft()\nright = right[::-1]\nright.pop()\n\nprint(min([left[i]+right[i] for i in range(N)])-1)", "N=int(input())\nS=list(str(input()))\neast=S[1:].count('E')\nans_min = east\nans = east\nfor l in range(1,N):\n if S[l-1]=='W':\n ans+=1\n if S[l]=='E':\n ans-=1\n if ans<=0:\n ans_min = 0\n break\n if ans < ans_min:\n ans_min = ans\nprint(ans_min)\n", "N=int(input())\nS=list(input())\n\ndp_f=[0 for _ in range(N)]\ndp_b=[0 for _ in range(N)]\nfor n in range(1,N):\n if S[n-1]==\"W\":\n tmp=1\n else:\n tmp=0\n dp_f[n]=dp_f[n-1]+tmp\n\nfor n in reversed(range(N-1)):\n if S[n+1]==\"E\":\n tmp=1\n else:\n tmp=0\n dp_b[n]=dp_b[n+1]+tmp\n\nMIN=N\nfor n in range(N):\n if n==N-1:\n MIN=min(MIN,dp_f[N-1])\n elif n==0:\n MIN=min(MIN,dp_b[0])\n else:\n MIN=min(MIN,dp_f[n]+dp_b[n])\nprint(MIN)", "n = int(input())\ns = input()\ncnt_e = [0] * n\ncnt_w = [0] * n\nfor i in range(n):\n if i == 0 :\n if s[i] == 'E':\n cnt_e[i] = 1\n else :\n cnt_w[i] = 1\n else :\n if s[i] == 'E':\n cnt_e[i] = cnt_e[i-1] + 1\n cnt_w[i] = cnt_w[i-1]\n else :\n cnt_e[i] = cnt_e[i-1]\n cnt_w[i] = cnt_w[i-1] + 1\nans = 3 * 10**5 + 1\nfor i in range(n):\n if s[i] == 'E':\n e = cnt_e[-1] - cnt_e[i]\n w = cnt_w[i]\n else :\n e = cnt_e[-1] - cnt_e[i]\n w = cnt_w[i] - 1\n ans = min(ans, e + w)\nprint(ans)\n", "N=int(input())\nS=input()\nS=\"N\"+S+\"N\"\nans=0\nE=0\nW=S.count(\"W\")\nfor i in range(1,N+1):\n if S[i-1]==\"E\":\n E+=1\n if S[i]==\"W\":\n W-=1\n tmp=E+W\n if tmp>ans:\n ans=tmp\nans=N-1-ans\nprint(ans)\n", "n = int(input())\ns = input()\n\nwest_back = s.count(\"W\")\neast_back = n-west_back\nwest_front = 0\neast_front = 0\n\nans = 10**6\nfor i in range(n):\n if s[i] == \"W\":\n west_front += 1\n west_back -= 1\n key = west_front+east_back-1\n else:\n east_front += 1\n east_back -= 1\n key = west_front+east_back\n ans = min(ans, key)\nprint(ans)\n", "n = int(input())\ns = input()\nc = [0,0]\nfor i in range(n):\n if (s[i]==\"E\"):\n c[0] += 1\n else:\n c[1] += 1\nb = [0,0]\nans = c[0]\nfor i in range(n):\n if (s[i]==\"E\"):\n c[0] -= 1\n b[0] += 1\n else:\n c[1] -= 1\n b[1] += 1\n ans = min(ans,c[0]+b[1])\nprint(ans)", "N = int(input())\nN_List = str(input())\nC_Ans = N_List[1:].count(\"E\")\nAns = C_Ans\nfor i in range(1,N):\n C_Ans = C_Ans + (0,1)[N_List[i-1] == \"W\"] - (0,1)[N_List[i] == \"E\"]\n if C_Ans < Ans:\n Ans = C_Ans\n\nprint(Ans)", "n = int(input())\ns = input()\n\n# full search\ncnt = s.count('E')\n\nans = cnt\nfor i in range(n):\n if s[i] == 'E':\n cnt -= 1\n if ans > cnt:\n ans = cnt\n \n else:\n cnt += 1\n\nprint(ans)", "n=int(input())\ns=input()\ndata=[0]*(n+1)\nfor i in range(n):\n if s[i]=='E':\n data[i+1]=data[i]+1\n else:\n data[i+1]=data[i]\nprint(min(i-data[i]+data[n]-data[i+1] for i in range(n)))", "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 S = ns()\n E = np.cumsum([1 if s == 'E' else 0 for s in S][::-1])[::-1]\n W = np.cumsum([1 if s == 'W' else 0 for s in S])\n ans = E + W\n print((np.min(ans) - 1))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nS = input()\na = S.count(\"E\")\nc = a \n \nfor s in S:\n if s==\"E\":\n c-=1\n else:\n c+=1\n a=min(a,c)\n \nprint(a)", "N = int(input())\nS = input()\nL = [0]*(N+1)\nfor i in range(N):\n if S[i]==\"E\":\n L[i+1] = L[i]+1\n else:\n L[i+1] = L[i]\nprint(min(i-L[i]+L[N]-L[i+1] for i in range(N)))", "n = int(input())\ns = input()\n\ndp = [0] * n\n\nfor i in range(1,n):\n if s[i] == \"E\":\n dp[0] += 1\n\nfor i in range(1,n):\n dp[i] = dp[i-1]\n if s[i-1] == \"W\":\n dp[i] += 1\n if s[i] == \"E\":\n dp[i] -= 1\n\nprint(min(dp))", "import sys\nimport re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\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 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(str, input().split()))\ndef LIST(): return list(map(int, input().split()))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nN = INT()\nS = [_ for _ in input()]\n\nleft, right = 0, S[1:].count('E')\nans = left + right\nfor i in range(N-1):\n if S[i] == 'W':\n left += 1\n if S[i+1] == 'E':\n right -= 1\n\n ans = min(ans, left + right)\n\nprint(ans)\n"]
{"inputs": ["5\nWEEWW\n", "12\nWEWEWEEEWWWE\n", "8\nWWWWWEEE\n"], "outputs": ["1\n", "4\n", "3\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
39,969
a60f1638433d52d37c9839dbe70799af
UNKNOWN
There are N cities and M roads. The i-th road (1≀i≀M) connects two cities a_i and b_i (1≀a_i,b_i≀N) bidirectionally. There may be more than one road that connects the same pair of two cities. For each city, how many roads are connected to the city? -----Constraints----- - 2≀N,M≀50 - 1≀a_i,b_i≀N - a_i β‰  b_i - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N M a_1 b_1 : a_M b_M -----Output----- Print the answer in N lines. In the i-th line (1≀i≀N), print the number of roads connected to city i. -----Sample Input----- 4 3 1 2 2 3 1 4 -----Sample Output----- 2 2 1 1 - City 1 is connected to the 1-st and 3-rd roads. - City 2 is connected to the 1-st and 2-nd roads. - City 3 is connected to the 2-nd road. - City 4 is connected to the 3-rd road.
["n,m = map(int, input().split())\nc = [0 for _ in range(n)]\nfor i in range(m):\n a,b = map(int, input().split())\n c[a-1] += 1\n c[b-1] += 1\nfor j in range(n):\n print(c[j])", "n,m = [int(x) for x in input().split()]\ncount = [0] * (n+1)\nfor i in range(m):\n a,b = [int(x) for x in input().split()]\n count[a] += 1\n count[b] += 1\nfor i in range(1,n+1):\n print(count[i])", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main2():\n numbers=[]\n n,m = map(int,input().split())\n numbers=[list(map(int,input().split())) for _ in range(m)]\n dp=[0]*n\n for number in numbers:\n for n in number:\n dp[n-1]+=1\n for ans in dp:\n print(ans)\n\ndef main():\n numbers=[]\n n,m = map(int,input().split())\n numbers=[list(map(int,input().split())) for _ in range(m)]\n dp={}\n for number in numbers:\n for n in number:\n if n not in dp:\n dp[n]=1\n else:\n dp[n]+=1\n print(dp)\n for i in range(1,len(dp)+1):\n print(dp[i])\n\ndef __starting_point():\n main2()\n__starting_point()", "n,m = list(map(int, input().split()))\ng = [[] for _ in range(n)]\n\nfor i in range(m):\n a,b = list(map(int, input().split()))\n g[a-1].append( b-1)\n g[b-1].append( a-1)\n \nfor nd in g:\n print((len(nd)))\n\n", "n,m = map(int, input().split())\na = [0] * m\nb = [0] * m\nfor i in range(m):\n a[i], b[i] = map(int, input().split())\nfor i in range(n):\n print((a+b).count(i+1))", "n, m = list(map(int, input().split()))\nAB = [[] for _ in range(n)]\nfor i in range(m):\n a, b = [int(x)-1 for x in input().split()]\n AB[a].append(b)\n AB[b].append(a)\nfor i in range(n):\n print((len(AB[i])))\n", "n,m=map(int,input().split())\na=[]\nfor i in range(m):\n x,y=map(int,input().split())\n a.append(x)\n a.append(y)\nfor i in range(1,n+1):\n print(a.count(i))", "n,m = map(int,input().split())\nans = []\nfor i in range(m):\n a,b = map(int,input().split())\n ans.append(a)\n ans.append(b)\n\nfor j in range(1,n+1):\n print(ans.count(j))", "n,m=list(map(int,input().split()))\nal=[]\nbl=[]\nfor i in range(m):\n a,b=list(map(int,input().split()))\n al.append(a)\n bl.append(b)\n\nfor i in range(1,n+1):\n print((al.count(i)+bl.count(i)))\n", "N, M = map(int, input().split())\nroad_list = []\nfor i in range(M):\n road_list.append(list(map(int, input().split())))\n\nroad_dict = {}\nfor road in road_list:\n first_city = road[0]\n second_city = road[1]\n first_city_road_list = road_dict.get(first_city, [])\n first_city_road_list.append(second_city)\n road_dict[first_city] = first_city_road_list\n \n second_city_road_list = road_dict.get(second_city, [])\n second_city_road_list.append(first_city)\n road_dict[second_city] = second_city_road_list\n\nfor i in range(1, N+1):\n city_road_list = road_dict.get(i, [])\n road_num = len(city_road_list) if city_road_list != [] else 0\n print(road_num)", "n,m = map(int,input().split())\nli1 = [0]*n\nfor i in range(m):\n a,b = map(int,input().split())\n li1[a-1] += 1\n li1[b-1] += 1\nfor i in range(n):\n print(li1[i])", "n, m = list(map(int, input().split()))\ncounter_list = [0] * (n + 1)\nfor i in range(m):\n a, b = list(map(int, input().split()))\n counter_list[a] += 1\n counter_list[b] += 1\n\nfor i in range(1, n + 1):\n print((counter_list[i]))\n", "n, m = map(int, input().split())\nc = []\nfor _ in range(m):\n a, b = map(str, input().split())\n c.append(a)\n c.append(b)\nfor i in range(1, n + 1):\n print(c.count(str(i)))", "N,M = list(map(int,input().split()))\nL = [0] * (N+1)\nfor i in range(M):\n A,B = list(map(int,input().split()))\n L[A] += 1\n L[B] += 1\nfor j in range(1,N+1):\n print((L[j]))\n", "n,m = map(int,input().split())\ndata = [input().split() for i in range(m)]\nfor i in range(1,n+1):\n count = 0\n for j in range(m):\n if int(data[j][0]) == i or int(data[j][1]) == i:\n count += 1\n print(count)", "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, m = rm()\nli = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = rm()\n a -= 1\n b -= 1\n li[a].append(b)\n li[b].append(a)\nfor lis in li:\n print((len(lis)))\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "N, M = tuple(map(int, input().split()))\n\ncount_road = [0 for _ in range(N+1)]\n\nfor _ in range(M):\n a, b = tuple(map(int, input().split()))\n count_road[a] += 1\n count_road[b] += 1\n \nfor i in range(1, N+1):\n print(count_road[i])", "n, m = list(map(int, input().split()))\narr = [0] * n\n\nfor _ in range(m):\n x, y = list(map(int, input().split()))\n arr[x - 1] += 1\n arr[y - 1] += 1\n\nfor ele in arr:\n print(ele)\n", "N, M=map(int, input().split())\nnums=[0]*(N+1)\nfor _ in range(M):\n a, b=map(int, input().split())\n nums[a]+=1\n nums[b]+=1\nprint(*nums[1:], sep='\\n')", "n, m = list(map(int, input().split()))\nans = [0]*n\n\nfor _ in range(m):\n a, b, = list(map(int, input().split()))\n ans[a-1] += 1\n ans[b-1] += 1\n\nfor i in range(n):\n print((ans[i]))\n", "N, M = list(map(int, input().split()))\na_s = []\nb_s = []\nfor i in range(M):\n\ta, b = list(map(int, input().split()))\n\ta_s.append(a)\n\tb_s.append(b)\n\nfor i in range(1, N + 1):\n\tprint((a_s.count(i) + b_s.count(i)))\n", "n, m = map(int, input().split())\nnum = []\nfor i in range(m):\n a, b = map(int, input().split())\n num.append(a)\n num.append(b)\n\nfor i in range(n):\n print(num.count(i + 1))", "N,M = list(map(int,input().split()))\nli = []\nfor _ in range(M):\n li += input().split()\nfor i in range(1,N+1):\n print((li.count(str(i))))\n", "n, m = map(int, input().split())\nl = []\nfor i in range(m):\n\ta,b = map(int, input().split())\n\tl.append(a)\n\tl.append(b)\nfor i in range(n):\n\tt = i + 1\n\tans = l.count(t)\n\tprint(ans)", "N, M, *cnt = open(0).read().split()\nfrom collections import Counter\ncnt = Counter(cnt)\nfor i in range(1,int(N)+1):\n print(cnt[str(i)])", "n,m=map(int,input().split())\nroads=[0 for _ in range(n)]\nfor _ in range(m):\n a,b=map(int,input().split())\n roads[a-1]+=1\n roads[b-1]+=1\nfor i in roads:\n print(i)", "N,M = map(int,input().split())\ncity = [0] * N\n\nfor _ in range(M):\n a,b = map(int,input().split())\n city[a-1] += 1\n city[b-1] += 1\n \nfor ans in city:\n print(ans)", "N,M=map(int,input().split())\ncity=[0]*N\nfor i in range(M):\n road=list(map(int,input().split()))\n for j in road:\n city[j-1]+=1\nfor i in city:\n print(i)", "n, m = map(int, input().split())\na = []\nfor i in range(m):\n x, y = map(int, input().split())\n a.append(x)\n a.append(y)\nfor i in range(1, n + 1):\n print(a.count(i))", "import itertools\n\nN, M = list(map(int, input().split()))\n\nres = []\n\nfor i in range(M):\n ab = list(map(int, input().split()))\n res.append(ab)\n\nres = list(itertools.chain.from_iterable(res))\n\nfor i in range(N):\n print((res.count(i+1)))\n", "lst1 = input().split()\n\nN = int(lst1[0])\nM = int(lst1[1])\n\nlst2 = []\n\nfor i in range(M):\n lst2.append(input().split())\n\nlst3 = []\nfor i in range(N):\n lst3.append(0)\n\nfor i in range(M):\n for j in range(2):\n lst3[ int(lst2[i][j]) - 1 ] += 1\n\nfor i in range(N):\n print(lst3[i])", "n, m = map(int, input().split())\nedge = [[] for _ in range(n)]\nfor _ in range(m):\n a, b = map(int, input().split())\n edge[a-1].append(b-1)\n edge[b-1].append(a-1)\nprint(\"\\n\".join(list(map(lambda x:str(len(x)), edge))))", "n,m=map(int,input().split())\nA=[]\nB=[]\nfor i in range(m):\n a,b=map(int,input().split())\n A.append(a)\n B.append(b)\nfor j in range(n):\n print(A.count(j+1)+B.count(j+1))", "n,m=map(int,input().split())\nL=[[0 for _ in range(n)] for _ in range(n)]\nfor _ in range(m):\n a,b=map(int,input().split())\n L[a-1][b-1]+=1\n L[b-1][a-1]+=1\nfor i in range(n):\n print(sum(L[i]))", "#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)]\ndic = {i: 0 for i in range(1, n+1)}\nfor i in range(m):\n a, b = list(map(int, input().split()))\n dic[a] = dic[a]+1\n dic[b] = dic[b]+1\n\nfor i in range(1, n+1):\n print((dic[i]))\n", "import numpy as np\nn,m = map(int, input().split())\nans = np.zeros(n, dtype=int)\nfor i in range(m):\n a,b = map(int, input().split())\n ans[a-1] += 1\n ans[b-1] += 1\nfor i in range(n):\n print(ans[i])", "N,M =map(int,input().split())\nnums =[0]*N\nfor i in range(M):\n a, b = map(int, input().split())\n nums[a-1] += 1\n nums[b-1] += 1\n\nfor ans in nums:\n print(ans)", "n,m = map(int,input().split())\nans = [0]*n\nfor i in range(m):\n a,b = map(int,input().split())\n ans[a-1] += 1\n ans[b-1] += 1\nfor i in range(n):\n print(ans[i])", "def actual(N, M, A, B):\n AB = A + B\n\n counts = [AB.count(i) for i in range(1, N + 1)]\n \n return '\\n'.join(map(str, counts))\n\nN, M = list(map(int, input().split()))\nA, B = [], []\nfor _ in range(M):\n a, b = list(map(int, input().split()))\n A.append(a)\n B.append(b)\n \nprint((actual(N, M, A, B)))\n", "n, m = map(int, input().split())\ncount = [0] * n\nfor i in range(m):\n a, b = map(int, input().split())\n count[a-1] += 1\n count[b-1] += 1\nfor i in range(n):\n print(count[i])", "n,m=map(int,input().split())\nd=[0]*n\nfor i in range(m):\n a,b=map(int,input().split())\n d[a-1]+=1\n d[b-1]+=1\nfor i in d:\n print(i)", "c, r = [int(x) for x in input().split()]\ntotal = [0] * c\nfor i in range(r):\n f, s = [int(x) for x in input().split()]\n total[f - 1] += 1\n total[s - 1] += 1\n\nfor number in total:\n print(number)\n \n", "N, M = list(map(int, input().split()))\ndata = [[] for _ in range(N + 1)]\nfor i in range(M):\n x, y = list(map(int, input().split()))\n data[x].append(y)\n data[y].append(x)\n\nfor i in range(1, N + 1):\n print((len(data[i])))\n", "from typing import List\n\n\ndef answer(n: int, m: int, ab_s: List[List[int]]) -> List[int]:\n roads = [0 for _ in range(n)]\n for ab in ab_s:\n a, b = ab\n roads[a - 1] += 1\n roads[b - 1] += 1\n\n return roads\n\n\ndef main():\n n, m = map(int, input().split())\n ab_s = [list(map(int, input().split())) for _ in range(m)]\n for i in answer(n, m, ab_s):\n print(i)\n\n\ndef __starting_point():\n main()\n__starting_point()", "n, m = map(int, input().split())\ncount = [0]*n\n##print(count)\nfor i in range(m):\n a, b = map(int, input().split())\n count[a-1]+=1\n count[b-1]+=1\n ##print(count)\nfor i in count:\n print(i)", "N,M=map(int,input().split())\nx=[0]*(N+1)\nfor i in range(M) :\n a,b=map(int,input().split())\n for j in range(1,N+1) :\n if a==j or b==j :\n x[j]+=1\nfor i in range(1,N+1) :\n print(x[i])", "n,m = map(int,input().split())\nans = [0]*n\nfor _ in range(m):\n a,b = map(int,input().split())\n ans[a-1] += 1\n ans[b-1] += 1\nfor i in range(n):\n print(ans[i])", "n,m = map(int,input().split())\nl = [0]*n\nfor i in range(m):\n a,b = map(int,input().split())\n l[a-1] +=1\n l[b-1] +=1\nfor i in l:\n print(i)", "n , m = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(m)]\nans = []\nfor i in range(n):\n cnt = 0\n for j in range(m):\n if ab[j][0] == i+1 or ab[j][1] == i+1:\n cnt += 1\n ans.append(cnt)\nfor k in range(n):\n print(ans[k])", "n,m = map(int, input().split())\n\nl=[]\n\nfor i in range(m):\n a,b = map(int, input().split())\n l.append(a)\n l.append(b)\n \nfor i in range(n):\n print(l.count(i+1))", "n, m = map(int, input().split())\n\nar = [0] * n\n\nfor i in range(m):\n a, b = map(int, input().split())\n ar[a-1] += 1\n ar[b-1] += 1\nfor i in range(n):\n print(ar[i])", "\n\nN, M = map(int, input().split())\ntree = [[] for _ in range(N)]\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n tree[a].append(b)\n tree[b].append(a)\n\nfor i in range(N):\n print(len(tree[i]))", "n, m = map(int, input().split())\nroad_list = []\n\nfor _ in range(m):\n a, b = (input().split())\n road_list.append(a)\n road_list.append(b)\n \nfor i in range(1, n + 1):\n print(road_list.count(str(i)))", "n,m=list(map(int,input().split()))\na_s=[]\nb_s=[]\nfor i in range(m):\n a,b=list(map(int,input().split()))\n a_s.append(a)\n b_s.append(b)\n\nfor i in range(1,n+1):\n print((a_s.count(i)+b_s.count(i)))\n", "# -*- coding: utf-8 -*-\n\nN,M = map(int, input().split())\nload_num = [0] * N\nfor i in range(M):\n a, b = map(int, input().split())\n load_num[a-1] += 1\n load_num[b-1] += 1\n\nfor i in range(N):\n print(load_num[i])", "n,m=map(int,input().split())\nc={i:0 for i in range(1,n+1)}\nfor a,b in [list(map(int,input().split())) for i in range(m)]:\n c[a]+=1;c[b]+=1\nprint(*c.values(),sep='\\n')", "N, M = map(int, input().split())\nL = [0] * N\nfor i in range(M):\n a, b = map(int, input().split())\n L[a-1] += 1\n L[b-1] += 1\nprint(*L, sep = \"\\n\")", "\nN, M = list(map(int, input().split()))\n# \u90fd\u5e02A\u3068\u90fd\u5e02B\u3092\u7d50\u3076\u8def\u7ddaM\nA_B = [list(map(int, input().split())) for _ in range(M)]\nans = [0] * N\n\nfor a, b in A_B:\n ans[a-1] += 1\n ans[b-1] += 1\nfor a in ans:\n print(a)\n", "N,M = list(map(int,input().split()))\nAB = [list(map(int,input().split())) for _ in range(M)]\n\nWAY = [0] * (N+1)\nfor a,b in AB:\n WAY[a] += 1\n WAY[b] += 1\n \nprint((\"\\n\".join(map(str,WAY[1:]))))\n \n", "import itertools\nn,m = map(int,input().split())\nli = [list(map(int,input().split())) for i in range(m)]\n#print(li)\nlis = list(itertools.chain.from_iterable(li))\n#print(lis)\nfor i in range(1,n+1):\n print(lis.count(i))", "n, m = map(int,input().split())\nroad = [list(map(int,input().split())) for _ in range(m)]\ncnt = [0] * n\nfor i in road:\n cnt[i[0]-1] += 1\n cnt[i[1]-1] += 1\nfor j in range(n):\n print(cnt[j])", "n, m = map(int,input().split())\n\nl = []\nfor i in range(m):\n x,y = map(int,input().split())\n l.append(x)\n l.append(y)\n\nfor i in range(n):\n print(l.count(i+1))", "n, m = map(int, input().split())\na = [0] * m\nb = [0] * m\nfor i in range(m):\n a[i], b[i] = map(int, input().split())\n\nans = [0] * n\n\nfor i in range(m):\n ans[a[i]-1] += 1\n ans [b[i]-1] += 1\n\nfor i in ans:\n print(i)", "# ABC061B\nN,M = map(int, input().split())\nAB = [[] for _ in range(N)]\nfor _ in range(M):\n a,b = map(int, input().split())\n AB[a-1].append(b-1)\n AB[b-1].append(a-1)\nfor i in range(N):\n print(len(AB[i]))", "N, M = list(map(int, input().split()))\nab = [list(map(int, input().split())) for _ in range(M)]\n\nd = {i+1: 0 for i in range(N)}\nfor i in range(M):\n a = ab[i][0]\n b = ab[i][1]\n d[a] += 1\n d[b] += 1\n\nfor i in range(N):\n print((d[i+1]))\n", "n,m=map(int,input().split())\nc={i:0 for i in range(1,n+1)}\nfor _ in range(m):\n a,b=map(int,input().split())\n c[a]+=1;c[b]+=1\nprint(*c.values(),sep='\\n')", "n, m = map(int, input().split())\nar = [0] * n\nfor i in range(m):\n a, b = map(int, input().split())\n ar[a-1] += 1\n ar[b-1] += 1\nfor i in range(n):\n print(ar[i])", "n, m = map(int, input().split())\nedges = [tuple(map(int, input().split())) for _ in range(m)]\n\nc = [[] for _ in range(n + 1)]\n\nfor a, b in edges:\n c[a].append(b)\n c[b].append(a)\n\nfor i in range(1, n + 1):\n print(len(c[i]))", "n,m = map(int,input().split())\ng = [[] for i in range(n)]\nfor i in range(m):\n a,b = map(int,input().split())\n g[a-1].append(b)\n g[b-1].append(a)\nfor i in range(n):\n print(len((g[i])))", "#!/usr/bin/env python3\n\n\ndef main():\n import numpy as np\n\n N, M = list(map(int, input().split()))\n ab = np.array([list(map(int, input().split())) for _ in range(M)])\n for i in range(1, N+1):\n print((np.count_nonzero(ab == i)))\n\n\nmain()\n", "n, m = list(map(int, input().split()))\ncnt = [0] * n\nfor i in range(m):\n a, b = list(map(int, input().split()))\n cnt[a-1] += 1\n cnt[b-1] += 1\nfor i in range(n):\n print((cnt[i]))\n", "n,m = map(int,input().split())\nN = list(range(1,n+1))\nD = dict.fromkeys(N,0)\n\nfor _ in range(m):\n R = list(map(int,input().split()))\n for r in R:\n D[r] += 1\n\nfor d in D.values():\n print(d)", "N, M = map(int,input().split())\nlist = []\n\nfor i in range(M):\n a, b = map(int,input().split())\n list.append(a)\n list.append(b)\n\nfor j in range(1,N+1):\n print(list.count(j))", "n, m = map(int, input().split())\n\ngraph = [[] for i in range(n+1)]\n\nfor i in range(m):\n a, b = map(int, input().split())\n graph[a].append(b)\n graph[b].append(a)\n\nfor i in range(n):\n print(len(graph[i+1]))", "n, m = map(int, input().split())\ns = []\nN = [0 for i in range(n)]\nfor i in range(m):\n a,b = map(int, input().split())\n s.append([a,b])\n N[a-1] += 1\n N[b-1] += 1\nfor j in range(n):\n print(N[j])", "nm = list(map(int, input().split()))\nn, m = nm[0], nm[1]\nab_list = [list(map(int, input().split())) for _ in range(m)]\nresults = dict([(i, 0) for i in range(1, n + 1)])\nfor ab in ab_list:\n results[ab[0]] += 1\n results[ab[1]] += 1\n\nfor i in range(1, n + 1):\n print((results[i]))\n", "N, M = tuple(map(int, input().split()))\n\ncount_road = [[0 for _ in range(N+1)] for _ in range(N+1)]\n\nfor _ in range(M):\n a, b = tuple(map(int, input().split()))\n count_road[a][b] += 1\n count_road[b][a] += 1\n \nfor i in range(1, N+1):\n print(sum(count_road[i]))", "n, m = map(int, input().split())\ncity = [0] * n\nfor i in range(m):\n a, b = map(int, input().split())\n city[a - 1] += 1\n city[b - 1] += 1\n\nfor i in city:\n print(i)", "N,M=map(int,input().split())\ncnt=[0 for i in range(N)]\n\n\nfor i in range(M):\n a,b=map(int,input().split())\n cnt[a-1]+=1\n cnt[b-1]+=1\n\nfor i in range(N):\n print(cnt[i])", "from collections import Counter\n\nn,m=map(int,input().split())\n\nl=[]\nfor i in range(m):\n lis=list(map(int,input().split()))\n l+=lis\n \nl=Counter(l)\n\nfor i in range(1,n+1):\n print(l[i])", "N, M = map(int,input().split())\nab_list = []\n\nfor i in range(M):\n a, b = map(int,input().split())\n ab_list.append(a)\n ab_list.append(b)\n \nfor i in range(1, N + 1):\n print(ab_list.count(i))", "N, M = map(int, input().split())\nab = [list(map(int, input().split())) for _ in range(M)]\nans = [0 for _ in range(N)]\nn = 1\nwhile True:\n for i in range(M):\n for j in range(2):\n if n == ab[i][j]:\n ans[n-1] += 1\n if n == N:\n break\n n += 1\nfor i in range(N):\n print(ans[i])", "from collections import defaultdict\nn,m = map(int, input().split())\nans = 0\nroute = [[0]*(n+1) for i in range(n+1)]\n\nfor i in range(m):\n f,t = map(int, input().split())\n route[f][t] += 1\n route[t][f] += 1\n\nfor i in range(1, n+1):\n print(sum(route[i]))", "import sys\nreadline = sys.stdin.readline\n\nN,M = map(int,readline().split())\nans = [0] * N\n\nfor i in range(M):\n ab = list(map(int,readline().split()))\n for a in ab:\n ans[a - 1] += 1\n \nfor a in ans:\n print(a)", "N,M = map(int,input().split())\nl = [0]*N\nfor i in range(M):\n a,b= map(int,input().split())\n l[a-1]+=1\n l[b-1]+=1\nfor i in range(N):\n print(l[i])", "n,m = map(int,input().split())\ns = [[] for i in range(n)]\nfor i in range(m):\n a,b = map(int,input().split())\n s[a-1].append(b)\n s[b-1].append(a)\nfor i in s:\n print(len(i))", "n,m=map(int,input().split())\nc=[0]*n\nfor _ in range(m):\n a,b=[int(j) for j in input().split()]\n c[a-1]+=1\n c[b-1]+=1\nfor i in c:\n print(i)", "n, m = map(int, input().split())\nroad = [list(map(int, input().split())) for _ in range(m)]\n\nroad = sum(road, [])\nfor i in range(1, n+1):\n print(road.count(i))", "N, M = map(int, input().split())\nL = []\nfor i in range(M):\n a, b = map(int, input().split())\n L.append(a)\n L.append(b)\n\nfor n in range(1, N+1):\n print(L.count(n))", "N,M=list(map(int,input().split()))\nans=[0 for i in range(N)]\nfor _ in range(M):\n a,b=list(map(int,input().split()))\n ans[a-1]+=1\n ans[b-1]+=1\n\nfor x in ans:\n print(x)\n", "n,m = map(int,input().split())\nx =[0]*n\nfor i in range(m):\n a,b = map(int,input().split())\n x[a-1]+=1\n x[b-1]+=1\nfor i in range(n):\n print(x[i])"]
{"inputs": ["4 3\n1 2\n2 3\n1 4\n", "2 5\n1 2\n2 1\n1 2\n2 1\n1 2\n", "8 8\n1 2\n3 4\n1 5\n2 8\n3 7\n5 2\n4 1\n6 8\n"], "outputs": ["2\n2\n1\n1\n", "5\n5\n", "3\n3\n2\n2\n2\n1\n1\n2\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
20,944
6e7896c51b585a5b8ef7d53bdbb0e754
UNKNOWN
You are taking a computer-based examination. The examination consists of N questions, and the score allocated to the i-th question is s_i. Your answer to each question will be judged as either "correct" or "incorrect", and your grade will be the sum of the points allocated to questions that are answered correctly. When you finish answering the questions, your answers will be immediately judged and your grade will be displayed... if everything goes well. However, the examination system is actually flawed, and if your grade is a multiple of 10, the system displays 0 as your grade. Otherwise, your grade is displayed correctly. In this situation, what is the maximum value that can be displayed as your grade? -----Constraints----- - All input values are integers. - 1 ≀ N ≀ 100 - 1 ≀ s_i ≀ 100 -----Input----- Input is given from Standard Input in the following format: N s_1 s_2 : s_N -----Output----- Print the maximum value that can be displayed as your grade. -----Sample Input----- 3 5 10 15 -----Sample Output----- 25 Your grade will be 25 if the 10-point and 15-point questions are answered correctly and the 5-point question is not, and this grade will be displayed correctly. Your grade will become 30 if the 5-point question is also answered correctly, but this grade will be incorrectly displayed as 0.
["N = int(input())\ns = []\n\nfor i in range(N):\n s.append(int(input()))\n \nS = sum(s)\n\nif S%10 != 0:\n print(S)\nelse:\n b = True\n for j in range(N):\n if s[j]%10 == 0:\n continue\n else:\n b = False\n if b:\n print(0)\n else:\n s.sort()\n for k in range(N):\n if s[k]%10 != 0:\n print(S-s[k])\n break", "n=int(input())\ntens=[]\nothers=[]\nfor i in range(n):\n s=int(input())\n if s%10==0:\n tens.append(s)\n else:\n others.append(s)\ntens.sort(reverse=True)\nothers.sort(reverse=True)\n\nscore=sum(tens)+sum(others)\nif score%10==0:\n if len(others)!=0:\n print(score-min(others))\n else:\n print(0)\nelse:\n print(score)", "n = int(input())\ns_l = [ int(input()) for _ in range(n) ]\ns_l = sorted(s_l)\n\nif sum(s_l)%10 != 0:\n ans = sum(s_l)\nelse:\n ans = 0\n base_ans = sum(s_l)\n for i in range(n):\n if (base_ans-s_l[i])%10 != 0:\n ans = max(base_ans-s_l[i], ans)\nprint(ans)", "n = int(input())\ns = [int(input()) for i in range(n)]\nst = sorted(s)\nans = [0]\n\nsm1 = sum(s)\nfor i in range(len(st)):\n if sm1 % 10 != 0:\n ans.append(sm1)\n break\n else:\n sm1 -= st[i]\nsm2 = sum(s)\nfor i in range(len(st)):\n if st[i] % 10 != 0:\n ans.append(sm2 - st[i])\n break\nprint(max(ans))", "n = int(input())\na = [int(input()) for _ in range(n)]\ns = sum(a)\nif s % 10 != 0:\n print(s)\nelse:\n for i in range(n):\n if min(a) % 10 != 0:\n print(s - min(a))\n break\n a.remove(min(a))\n else:\n print(0)", "n = int(input())\ns = sorted([int(input()) for _ in range(n)])\n\ngrade = 0 if sum(s) % 10 == 0 else (sum(s))\n\nif grade == 0:\n for i in s:\n if i % 10 != 0:\n print((sum(s) - i))\n return\n\nprint(grade)\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############################################################\nN = ii()\n\nans = 0\nS = []\nfor i in range(N):\n s = ii()\n ans += s\n S.append(s)\n\nS.sort()\nif ans % 10 == 0:\n for s in S:\n if s % 10:\n ans -= s\n break\n else:\n ans = 0\n\nprint(ans)", "N=int(input())\nS=sorted([int(input()) for _ in range(N)])\n\nt=sum(S)\n\nif (t%10!=0):\n print(sum(S))\nelse:\n for i in S:\n if (t-i)%10!=0:\n print(t-i)\n break\n else:\n print(0)", "n=sorted([int(input()) for _ in range(int(input()))]);r,a=sum(n),0\nif r%10==0:\n for i in n:\n if (r-i)%10!=0: a=max(a,r-i)\n print(a)\nelse:\n print(r)", "with open(0) as f:\n N, *S = map(int, f.read().split())\nScore = [True if i == 0 else False for i in range(10000)]\nfor s in S:\n for i in reversed(range(s, 10000)):\n if Score[i-s]:\n Score[i] = True\n\nfor i in reversed(range(10000)):\n if Score[i] and i % 10 != 0:\n print(i)\n break\nelse:\n print(0)", "#16 C - Bugged\nN = int(input())\ns = [int(input()) for _ in range(N)]\ns = sorted(s,reverse = False)\n\nscore = sum(s)\nif score%10 == 0:\n for i in s:\n score -= i\n if score%10 != 0:\n break\n score += i\n else:\n score = 0\nprint(score)", "import copy\nn=int(input())\ns=[int(input()) for i in range(n)]\n\nSum=[]\nif sum(s)%10 != 0:\n print(sum(s))\n return\nfor i in s:\n c=copy.copy(s)\n c.remove(i)\n baisu=sum(c)\n #print(c)\n if baisu % 10 != 0:\n Sum.append(baisu)\n\nif len(Sum) == 0:\n print(0)\nelse:\n print(max(Sum))", "N=int(input())\ns=[int(input()) for _ in range(N)]\n\ns = sorted(s)\nSUM = sum(s)\n\nif SUM % 10 != 0:\n print(SUM)\n return\n\nfor i in range(N):\n if s[i] % 10 != 0:\n print(SUM - s[i])\n return\n \nprint(0)", "#!/usr/bin/env python3\nN = int(input())\ns = sorted([int(input()) for i in range(N)])\n\nans = sum(s)\n\nif ans % 10 == 0:\n for i in s:\n if i % 10 == 0:\n pass\n else:\n ans -= i\n if ans % 10 != 0:\n break\n\nif ans % 10 == 0 and ans == sum(s):\n print((0))\nelse:\n print(ans)\n", "n=int(input())\nl=[int(input()) for i in range(n)]\n\nlis=[i for i in l if i%10!=0]\n\nsum_l=sum(l)\n\nif sum_l%10!=0:\n print(sum_l)\nelse:\n if len(lis)==0:\n print(0)\n else:\n print(sum_l-min(lis))", "s = [int(input()) for _ in range(int(input()))]\n\nif sum(s) % 10 != 0:\n print(sum(s))\nelse:\n s.sort()\n for x in s:\n if x % 10 != 0:\n print(sum(s) - x)\n break\n else:\n print(0)", "N=int(input())\ns=[0]*N\ns_nz=[101]*N\nres=0\nfor i in range(N) :\n s[i]=int(input())\n if s[i]%10!=0 :\n s_nz[i]=s[i]\n res+=s[i]\nif res%10==0 :\n if min(s_nz)==101 :\n res=0\n else :\n res-=min(s_nz)\nprint(res)\n\n", "from itertools import combinations\nn = int(input())\ns = sorted([int(input()) for _ in range(n)])\n\nans = sum(s)\nif ans % 10 != 0: print(ans)\nelif all(i%10 == 0 for i in s): print(0)\nelse:\n for i in range(1,n):\n for j in combinations(s,i):\n t = sum(j)\n if (ans-t)%10 != 0:\n print(ans-t)\n return", "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 = ini()\n s = [ini() for _ in range(n)]\n a = sum(s)\n if a % 10 != 0:\n return a\n m = 1000\n for x in s:\n if x % 10 != 0 and m > x:\n m = x\n if m == 1000:\n return 0\n return a - m\n\n\nprint(solve())\n", "N = int(input())\ns = [int(input()) for _ in range(N)]\n\ns.sort()\nmod = [i%10 for i in s]\nans = sum(s)\n\nif ans%10 == 0:\n if mod.count(0)==N:\n ans=0\n else:\n for i in range(N):\n if mod[i]!=0:\n ans -=s[i]\n break\n \nprint(ans)", "n = int(input())\ns = []\nfor i in range(n):\n s.append(int(input()))\n\nif sum(s) % 10 != 0:\n print((sum(s)))\nelse:\n s.sort()\n for i in range(n):\n if s[i] % 10 == 0:\n pass\n else:\n print((sum(s) - s[i]))\n break\n else:\n print((0))\n", "n=int(input())\nl=[int(input())for _ in range(n)]\nl.sort()\nans=sum(l)\nif ans%10!=0:\n print(ans)\n return\nfor s in l:\n if (ans-s)%10!=0:\n print((ans-s))\n return\nprint((0))\n", "N,*S = list(map(int,open(0).read().split()))\n\nans =sum(S)\nif ans%10 !=0:\n print(ans)\nelse:\n S = sorted(S)\n for s in S:\n if s%10 != 0:\n print((ans-s))\n return\n print((0))\n", "n = int(input())\nproblems = [int(input()) for _ in range(n)]\nsum_all = sum(problems)\nnot_multi_of_10 = [x for x in problems if x % 10 != 0]\nnot_multi_of_10.sort()\n\nif sum_all % 10:\n print(sum_all)\nelse:\n if len(not_multi_of_10) == 0:\n print(0)\n else:\n print(sum_all - not_multi_of_10[0])", "n = int(input())\ns = [int(input()) for _ in range(n)]\n\nans = sum(s)\nif ans % 10 != 0:\n print(ans)\nelse:\n if all([i % 10 == 0 for i in s]):\n print(0)\n else:\n print(ans - min([i for i in s if i % 10 != 0]))", "N = int(input())\nscore = [int(input()) for _ in range(N)]\ns_score = sorted(score)\na = 0\nfor i in s_score:\n if i % 10 != 0:\n a = i\n break\nif sum(score) % 10 != 0:\n print(sum(score))\nelse:\n if a == 0:\n print(0)\n else:\n print(sum(score)-a)", "n = int(input())\nll = []\nfor i in range(n):\n ll.append(int(input()))\nll.sort()\nans = sum(ll)\nif ans%10 == 0:\n for l in ll:\n if l%10 != 0:\n print(ans-l)\n return\n print(0)\nelse:\n print(ans)", "N = int(input())\nminimum = 100 \ntotal = 0\nfor i in range(N):\n s = int(input())\n total += s \n if s % 10 != 0:\n minimum = min(minimum,s)\nif total % 10 != 0:\n print(total)\nelif minimum == 100:\n print(0)\nelse:\n print(total - minimum)", "N = int(input())\nS = [int(input()) for _ in range(N)]\n\nS.sort()\n\ns = sum(S)\n\nif s % 10 == 0:\n for ss in S:\n if (s - ss) % 10 != 0:\n print(s - ss)\n return\n\n print(0)\n\nelse:\n print(s)", "N = int(input())\ns = [int(input()) for _ in range(N)]\n\nres = 0\nother = []\n\nfor num in s:\n if num % 10 == 0:\n res += num\n else:\n other.append(num)\n \nif other:\n other.sort()\n res += sum(other)\n if res % 10 == 0:\n res -= other[0]\n print(res)\n \nelse:\n print(0)", "arr = []\narr2 = []\nfor i in range(int(input())):\n a = int(input())\n if a%10 == 0:\n arr2.append(a)\n else:\n arr.append(a)\n\narr.sort()\nj = sum(arr)+sum(arr2)\nif j%10 != 0:\n print(j)\nelse:\n k = 0\n while j%10 == 0 and k<len(arr):\n j -= arr[k]\n k += 1\n if j%10 == 0:\n print(0)\n else:\n print(j)", "n = int(input())\ns = sorted([int(input()) for _ in range(n)])\nans = sum(s)\nfor v in s:\n if ans%10!=0:\n print(ans)\n break\n if v%10!=0:\n ans -= v\nelse:\n print(0)", "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)]\nsl = []\nfor i in range(n):\n sl.append(int(input()))\n\ntotal = sum(sl)\nsl.sort()\n\nif total % 10 == 0:\n ans = 0\n for i in range(n):\n if sl[i]%10!=0:\n ans=total-sl[i]\n break\nelse:\n ans = total\nprint(ans)\n", "N=int(input())\ns=[]\nnin=10**7\nfor i in range(N):\n temp=int(input())\n if temp%10!=0:\n nin=min(nin,temp)\n s.append(temp)\n\nans=sum(s)\nif ans%10==0:\n ans-=nin\n print((max(ans,0)))\nelse:\n print(ans)\n", "N = int(input())\nS = []\nfor _ in range(N):\n S.append(int(input()))\n\ns = sum(S)\nif s % 10 != 0:\n print(s)\nelse:\n S.sort()\n for i in S:\n if i % 10 != 0:\n s -= i\n break\n if s % 10 == 0:\n print(0)\n else:\n print(s)", "N=int(input())\ns=[int(input()) for i in range(N)]\ns.sort()\nans = sum(s)\nif ans%10!=0:\n print(ans)\n return\nelse:\n for i in s:\n ans2 = ans-i\n if ans2%10!=0:\n print(ans2)\n return\nprint(0)", "n = int(input())\ns = [0]\nmins = 1000\nfor i in range(n):\n tmp = int(input())\n s.append(tmp)\n if tmp%10!=0:\n mins = min(mins,tmp)\nif sum(s)%10==0:\n if mins == 1000:\n print((0))\n else:\n print((sum(s)-mins))\nelse:\n print((sum(s)))\n", "N = int(input())\ns = [int(input()) for _ in range(N)]\ns.sort()\nsu = sum(s)\n\nif su%10 != 0:\n print(su)\n return\n \nfor i in s:\n if i%10 != 0:\n print(su - i)\n return\nprint(0)", "n = int(input())\ns_lst = [int(input()) for _ in range(n)]\n\nmaximum = sum(s_lst)\ns_lst.sort()\n\n\nif maximum % 10 != 0:\n answer = maximum\nelse:\n\n for i in range(n):\n maximum -= s_lst[i]\n if maximum % 10 != 0:\n answer = maximum\n break\n else:\n maximum += s_lst[i]\n\n if i == n - 1 and maximum == sum(s_lst):\n answer = 0\n\nprint(answer)", "N = int(input())\nS = [int(input()) for _ in range(N)]\nif sum(S)%10 != 0:\n print(sum(S))\nelse:\n A = sorted(S)\n for i in A:\n if (sum(S)-i)%10 != 0:\n print(sum(S)-i)\n return\n print(0)", "s = [int(input()) for _ in range(int(input()))]\n\nif sum(s) % 10 != 0:\n print(sum(s))\nelse:\n s.sort()\n for i, x in enumerate(s):\n if x % 10 != 0:\n print(sum(s) - x)\n break\n else:\n print(0)", "N = int(input())\nS = []\n\nfor i in range(N):\n S.append(int(input()))\n \nS.sort()\nans = sum(S)\n\nif ans % 10 != 0:\n print(ans)\n return\n \nfor i in range(N):\n if S[i] % 10 != 0:\n ans -= S[i]\n print(ans)\n return\n\nprint((0))\n", "n = int(input())\nS = sorted([int(input()) for _ in range(n)])\n\nif sum(S)%10!=0:\n print((sum(S)))\n return\nfor i in range(n):\n if S[i]%10==0:\n continue\n print((sum(S)-S[i]))\n return\nprint((0))\n\n\n", "n = int(input())\na = [int(input()) for i in range(n)]\na.sort()\n\nans = sum(a)\nif ans % 10 != 0:\n print(ans)\n return\n \nflg = False\nfor i in range(n):\n if a[i] % 10 != 0:\n ans -= a[i]\n flg = True\n break\nprint(ans) if flg else print(0)", "import sys\nN=int(input())\ns=[int(input()) for i in range(N)]\nnum=sum(s)\n\nif num%10!=0:\n print(num)\nelse:\n for i in range(N):\n s=sorted(s)\n if s[i]%10==0:\n continue\n else:\n print(num-s[i])\n return\n print(0)", "n = int(input())\ns = [0] * n\nfor i in range(n):\n s[i] = int(input())\n \n\njudge = 0\nanswer = 0\n\nfor i in s:\n answer += i\n if i%10 == 0:\n judge += 1 \n\n#print(answer)\n\ns.sort()\nmi = 0\n#print(s)\n\nfor i in s:\n if i%10 != 0:\n mi = i\n break\n\n\n#print(mi)\n\nif judge == len(s):\n print((0))\nelse:\n if answer%10 == 0:\n answer -= mi\n\n print(answer)\n\n\n", "N = int(input())\ns = []\nfor i in range(N):\n s.append(int(input()))\n\ns.sort()\nx = sum(s)\n\nif str(x)[-1] != '0':\n print(x)\n return\n\nans = x\nfor i in range(N):\n ans = max(x-s[i], ans-s[i])\n if str(ans)[-1] != '0':\n print(ans)\n return\nprint((0))\n", "n = int(input())\nsum=0\npoint=[]\nfor i in range(n):\n now= int(input())\n point.append(now)\n sum+=now\n#point = list(map(int, input()))\nif sum%10!=0:\n print(sum)\nelse:\n point.sort()\n judge = False\n for i in point:\n if i%10!=0:\n point.remove(i)\n sum-=i\n judge = True\n break\n if judge:\n print(sum)\n else:\n print((0))\n", "n = int(input())\nss = sorted([int(input()) for i in range(n)])\ntss = sum(ss) # total ss\nif tss % 10 != 0:\n print(tss)\nelse:\n for s in ss:\n x = tss - s\n if x % 10 != 0:\n print(x)\n return\n print(0)", "a=int(input())\nb=[int(input()) for i in range(a)]\nb.sort()\nc=sum(b)\nd=0\nif c%10!=0:\n print(c)\nelse:\n for i in range(a):\n if b[i]%10!=0:\n c=c-b[i]\n print(c)\n break\n if sum(b)==c:\n print(0)", "n=int(input())\ns=[int(input()) for i in range(n)]\ns.sort()\nS=sum(s)\nans=0\nif S%10!=0:\n print(S)\nelse:\n for i in range(n):\n if (S-s[i])%10!=0:\n ans=max(S-s[i],ans)\n print(ans)", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\nimport re\n\nN = int(input())\ns = [int(input()) for c in range(N)]\nans = sum(s)\ns = [c for c in sorted(list(set(s))) if c%10 != 0]\n\nif ans % 10 ==0:\n if len(s) > 0:\n print(ans-s[0])\n return\n else:\n print(0)\n return\nelse:\n print(ans)\n return\n\nprint(0)", "N=int(input())\ns=[int(input()) for _ in range(N)]\nmn=101\nfor n in range(N):\n if s[n]%10!=0:\n mn=min(mn,s[n])\nif mn==101:\n print((0))\nelse:\n ss=sum(s)\n print((ss if ss%10!=0 else ss-mn))\n\n", "# C - Bugged\ndef main():\n n = int(input())\n s = [int(input()) for _ in range(n)]\n s.sort()\n \n if sum(s) % 10 != 0:\n print(sum(s))\n else:\n for i in range(n):\n if s[i] % 10 != 0:\n s.pop(i)\n print(sum(s))\n return\n else:\n print(0)\n\n\nif __name__ == \"__main__\":\n main()", "n=int(input())\ns=[int(input()) for i in range(n)]\nif sum(s)%10!=0:\n print(sum(s))\nelse:\n s.sort()\n flag=0\n for i in range(n):\n if s[i]%10!=0:\n print(sum(s)-s[i])\n flag=1\n break\n if flag==0:\n print(0)", "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n ans = 0\n n = int(input())\n s = [] \n for i in range(n):\n t = int(input())\n ans += t\n s.append(t)\n s.sort()\n \n if ans%10 == 0:\n for i in range(n):\n if s[i]%10 != 0:\n ans -= s[i]\n break\n if ans%10 == 0:\n ans = 0\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\ns = []\nfor i in range(N):\n s.append(int(input()))\n\ns.sort()\nans = sum(s)\nif ans % 10 == 0:\n fil = list(filter(lambda x: x % 10 != 0, s))\n if len(fil) == 0:\n print(0)\n else:\n print(ans - fil[0])\nelse:\n print(ans)", "n=int(input())\ns = [int(input()) for _ in range(n)]\ns.sort()\nif sum(s) %10 !=0:\n print(sum(s))\n return\nelse:\n for i in range(n):\n if s[i] %10 != 0:\n print(sum(s) - s[i])\n return\n else:\n continue\nprint(0)", "n = int(input())\ns = []\nfor _ in range(n):\n s.append(int(input()))\nans = sum(s) if sum(s) % 10 != 0 else 0\ncheck = 0\nfor i in range(len(s)):\n check = sum(s[:i]) + sum(s[i+1:])\n ans = max(ans,(check if check % 10 != 0 else 0))\nprint(ans)", "n = int(input())\ns = [int(input()) for i in range(n)]\ns.sort()\nans = sum(s)\n\nif ans%10==0:\n for i in range(len(s)):\n if s[i]%10!=0 :\n ans -= s[i]\n break\n else:\n ans = 0\n\nprint(ans)\n", "n = int(input())\ns = []\nfor i in range(n):\n s.append(int(input()))\nx = 0\nt = []\nfor i in range(n):\n if s[i]%10 == 0:\n t.append(i)\n x += s[i]\ncnt = 0\nfor i in t:\n del s[i-cnt]\n cnt += 1\ns.sort()\nwhile sum(s)%10 == 0 and len(s)>0:\n del s[0]\nif sum(s) == 0:\n print(0)\nelse:\n print(sum(s)+x)", "n = int(input())\np = []\n\nfor i in range(n):\n p.append(int(input()))\n\np.sort()\n\nans = sum(p)\nif ans%10==0:\n for i in p:\n if i%10!=0:\n ans -= i\n break\n if ans%10==0:\n print((0))\n else:\n print(ans)\nelse:\n print(ans)\n", "n = int(input())\ns=[]\n\nfor i in range(n):\n sl = int(input())\n s.append(sl)\n \ns.sort()\nans = sum(s)\n\ni = 0\nwhile ans>0 and i<n:\n if ans%10!=0:\n print(ans)\n return\n else:\n if s[i]%10!=0:\n ans = ans-s[i]\n i += 1\n \nprint((ans%10))\n", "n = int(input())\na = [int(input()) for i in range(n)]\n\np, q = 0, 0\njudge = 1000\nfor v in a:\n if v%10:\n p += v\n judge = min(judge, v)\n else:\n q += v\n\nans = p + q\nif ans % 10 == 0:\n if judge == 1000:\n ans = 0\n else:\n ans -= judge\n\nprint(ans)\n \n\n", "N=int(input())\nS=[int(input()) for _ in range(N)]\nS.sort()\n\nx=sum(S)\nif x%10!=0:\n print(x)\nelse:\n for i in range(N):\n if(x-S[i])%10!=0:\n print((x-S[i]))\n break;\n else:\n print((0))\n", "g = int(input())\n\ngrades = []\nfor i in range(g):\n grade = int(input())\n grades.append(grade)\n\ntotal = sum(grades)\ngrades.sort()\ngrades = [0] + grades\ncount = 0\nfor grade in grades:\n if (total - grade) % 10 != 0:\n print((total - grade))\n break\n else:\n count += 1\n\nif count == len(grades):\n print((0))\n", "Row = int(input())\nList = []\nfor i in range (Row):\n List.append(int(input()))\nList.sort(reverse = True)\nmid = 0\nfor i in range(Row):\n mid += List[i]\nsumList = [mid]* (Row+1)\nfor i in range(Row):\n sumList[i] = sumList[i]-List[i]\n if sumList[i] % 10 == 0:\n sumList[i]=0\nif sumList[Row] % 10 == 0:\n sumList[Row] = 0\nres = max(sumList)\nprint(res)", "N = int(input())\nA = [0]*N\nfor i in range(N):\n A[i] = int(input())\n \nA.sort()\n\nS = sum(A)\nif S%10 != 0:\n print(S)\n return\n\nfor i in range(N):\n if A[i]%10 !=0:\n print(S-A[i])\n return\n \nprint(0)", "# coding = SJIS\n\nn = int(input())\ns = []\nfor i in range(n):\n s.append(int(input()))\n\ns.sort()\n\nif sum(s) % 10 != 0:\n print(sum(s))\n return\nelse:\n for i in s:\n if i % 10 != 0:\n print(sum(s) - i)\n return\n\nprint(0)", "# C - Bugged\ndef main():\n n = int(input())\n s = [int(input()) for _ in range(n)]\n s.sort()\n \n if sum(s) % 10 != 0:\n print(sum(s))\n else:\n for i in range(n):\n if s[i] % 10 != 0:\n print(sum(s)-s[i])\n return\n else:\n print(0)\n\n\nif __name__ == \"__main__\":\n main()", "# coding: utf-8\n\n\ndef main():\n N = int(input())\n A = [int(input()) for _ in range(N)]\n ans = sum(A)\n\n if ans % 10 == 0:\n tmp = 0\n for i in range(N):\n if A[i] % 10 != 0:\n tmp = max(tmp, ans - A[i])\n if tmp % 10 == 0:\n ans = 0\n else:\n ans = tmp\n\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = 0\nx = 9999\nfor _ in range(n):\n v = int(input())\n a += v\n if v % 10 != 0:\n x = min(x, v)\nif a % 10 != 0:\n print(a)\nelse:\n if x == 9999:\n # \u305c\u3093\u307610\u3067\u5272\u308a\u5207\u308c\u308b\u306e\u3067\u99c4\u76ee\n print((0))\n else:\n print((a - x))\n", "n = int(input())\ns = [int(input()) for i in range(n)]\ns.sort()\nif sum(s) % 10 != 0:\n print(sum(s))\nelse:\n for i in range(n):\n if s[i] % 10 != 0:\n print(sum(s)-s[i])\n return\n print(0)", "N = int(input())\ndp = [0]\nfor i in range(N):\n P = int(input())\n dp_p = list(map(lambda x:x + P,dp))\n dp = list(set(dp + dp_p))\n\nP_List = [0] + [i for i in dp if i % 10 != 0]\nprint(max(P_List))", "n = int(input())\nnon_10 = [0]\na = []\nfor i in range(n):\n a.append(int(input()))\n if a[i] % 10 != 0:\n non_10.append(a[i])\ns = sum(a)\nnon_10.sort()\nif s % 10 == 0:\n if len(non_10) > 1:\n s -= non_10[1]\n else:\n s = 0\nprint(s)", "n = int(input())\ns = []\nfor i in range(n):\n s += [int(input())]\ns = sorted(s)\na = sum(s)\nif a % 10 != 0:\n print(a)\n return\nelse:\n for i in range(n):\n if s[i] % 10 != 0:\n a -= s[i]\n if a % 10 != 0:\n print(a)\n f = 0\n return\n else:\n f = 1\nif f:\n print(0)", "N = int(input())\ns = [int(input()) for _ in range(N)]\n\nxs = [x%10 for x in s]\n\nif xs.count(0) == N:\n print((0))\nelif sum(s) % 10 != 0:\n print((sum(s)))\nelse:\n minimum = 999\n for n in range(N):\n if s[n] % 10 != 0:\n minimum = min(minimum,s[n])\n print((sum(s)-minimum))\n", "n = int(input())\nargList = [int(input()) for _ in range(n)]\nargList.sort()\nret = sum(argList)\nif ret % 10 == 0:\n bias = 0\n for b in argList:\n if b % 10 != 0:\n bias = b\n break\n if bias == 0:\n print(0)\n else:\n print(ret-bias)\nelse:\n print(ret)", "n = int(input())\nx = 0\nmn = 100\nfor i in range(n):\n s = int(input())\n x += s\n if s % 10 != 0:\n if s <= mn:\n mn = s\nif x % 10 != 0:\n print(x)\nelse:\n x -= mn\n if x % 10 == 0:\n print((0))\n else:\n if x < 0:\n print((0))\n return\n print(x)\n", "n=int(input())\ns=[]\nfor i in range(n):\n s.append(int(input()))\ns.sort()\n\nif sum(s)%10==0:\n for i in range(n):\n if s[i]%10!=0:\n print((sum(s)-s[i]))\n return\n print((0))\n return\nprint((sum(s)))\n", "from typing import List\n\n\ndef answer(n: int, s: List[int]) -> int:\n ans = 0\n not_multiples_of_10 = []\n\n for i in s:\n ans += i\n if i % 10 != 0:\n not_multiples_of_10.append(i)\n\n if not not_multiples_of_10:\n return 0\n\n if ans % 10 == 0:\n ans = ans - min(not_multiples_of_10)\n\n return ans\n\n\ndef main():\n n = int(input())\n s = [int(input()) for _ in range(n)]\n print(answer(n, s))\n\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\ns=[]\nfor i in range(n):\n s.append(int(input()))\ns.sort()\n\nm = -1\nfor i in s:\n if i % 10 != 0:\n m = i\n break\n\nif sum(s) % 10 == 0:\n if m == -1:\n print(0)\n else:\n print(sum(s) - m)\nelse:\n print(sum(s))", "n = int(input())\ns = []\nfor i in range(n):\n s += [int(input())]\ns = sorted(s)\na = sum(s)\nif a % 10 != 0:\n print(a)\n return\nelse:\n for i in range(n):\n if s[i] % 10 != 0:\n a -= s[i]\n if a % 10 != 0:\n print(a)\n f = 0\n return\n else:\n f = 1\nif f:\n print(0)", "N = int(input())\nS = sorted([int(input()) for n in range(N)])\nS1 = []\nS2 = []\n\nfor s in S:\n if s%10 ==0:\n S1.append(s)\n else:\n S2.append(s)\n \nif sum(S)%10!=0:\n print(sum(S))\nelse:\n if len(S2)>0:\n print(sum(S)-S2[0])\n else:\n print(0)", "n=int(input())\ns=[int(input()) for _ in range(n)]\nans=0\nfor i in range(n):\n for j in range(i,n):\n a=sum(s[:i])+sum(s[j:])\n if a>ans and a%10:\n ans=a\nprint(ans)", "n = int(input())\ns = list(int(input()) for _ in range(n))\ns.sort()\n\nif all(num % 10 == 0 for num in s):\n print(0)\nelse:\n if sum(s) % 10 == 0:\n for num in s:\n if num % 10 != 0:\n print(sum(s) - num)\n break\n else:\n print(sum(s))", "N,*S = list(map(int,open(0).read().split()))\n\np = [[False for i in range(100*100+1)] for j in range(N+1)]\n\np[0][0] = True\n\nfor i in range(N):\n for j in range(100*N+1):\n #S0~Si, point sum is j\n if p[i][j] == True:\n # incorrect\n p[i+1][j] = True\n # correct\n p[i+1][j+S[i]] = True \n\nfor i in range(100*N, -1, -1):\n if p[N][i] == True and i % 10 != 0:\n print(i)\n return\n\nprint((0))\n", "n = int(input())\n\nl = []\nfor _ in range(n):\n l.append(int(input()))\n\nl.sort()\nm = sum(l)\n\nif m % 10 != 0:\n print(m)\nelse:\n for e in l:\n if (m - e) % 10 != 0:\n print((m-e))\n return\n\n print((0))\n", "n=int(input())\na=sorted([int(input()) for i in range(n)])\ns=sum(a)\nif s%10!=0:\n print(s)\nelse:\n for i in a:\n if i%10!=0:\n print(s-i)\n break\n else:\n print(0)", "N = int(input())\nls = []\nfor i in range(N):\n ls.append(int(input()))\nsum1 = sum(ls)\nls.sort()\nans = 0\nif sum1 % 10 != 0:\n ans = sum1\nelse:\n for i in range(N):\n if (sum1-ls[i]) % 10 != 0:\n ans = sum1-ls[i]\n break\nprint(ans)", "'''\nCreated on 2020/10/01\n\n@author: harurun\n'''\nimport sys\npin=sys.stdin.readline\n\ndef main():\n N=int(pin())\n su=0\n S=[]\n for i in range(N):\n s=int(pin())\n S.append(s)\n su+=s\n if su%10!=0:\n print(su)\n return\n S.sort()\n for i in S:\n if (su-i)%10!=0:\n print(su-i)\n return\n print(0)\n return\nmain()", "n = int(input())\ns = [int(input()) for _ in range(n)]\n\nss = sum(s)\nans = ss * min(1, ss % 10)\n\nfor i in range(n):\n score = ss - s[i]\n\n ans = max(ans, score * min(1, score % 10))\n\nprint(ans)\n", "import sys\n\ninput = sys.stdin.readline\n\nn = int(input())\n\ns_list = []\nnot_10_s_list = []\n\nfor _ in range(n):\n s = int(input())\n if not s % 10 == 0:\n not_10_s_list.append(s)\n s_list.append(s)\n\nif len(not_10_s_list) == 0:\n print(0)\n return\n\nelse:\n sum_s = sum(s_list)\n if not sum_s % 10 == 0:\n max_s = sum_s\n print(max_s)\n return\n\n max_s = -1\n for not_10_s in not_10_s_list:\n if not sum_s - not_10_s % 10 == 0:\n max_s = max(max_s,sum_s - not_10_s)\n print(max_s)\n return", "N = int(input())\nmaxs = 0 \ns = []\nfor i in range(N):\n cin = int(input())\n s.append(cin)\n maxs = max(maxs, cin)\nM = maxs * N\n\ndp = [False] * (M+1)\ndp[0] = True\n\nfor x in s:\n for i in range(M+1):\n if M-i < x: continue\n if dp[M-i-x]: dp[M-i] = True\n\nfor i in range(M+1):\n if (M-i)%10 != 0 and dp[M-i]:\n print(M-i)\n break\nelse:\n print(0) ", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 22 15:10:57 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nlis10 = list()\nlis =list()\nans = 0\nfor i in range(N):\n s = int(input())\n if s % 10 == 0:\n lis10.append(s)\n else:\n lis.append(s)\nans += sum(lis10)\nlis.sort()\nans += sum(lis)\nif ans % 10 == 0:\n if lis:\n ans -= lis[0]\n else:\n ans = 0\nprint(ans)", "N = int(input())\ns = []\nSum = 0\nfor i in range(N):\n s.append(int(input()))\n Sum += s[i]\ns.sort()\n\nif Sum % 10 != 0:\n print(Sum)\nelse:\n for i in range(N):\n if s[i] % 10 != 0:\n print(Sum - s[i])\n break\n if i == N - 1:\n print(0) ", "N = int(input())\nten, notten = [], []\nfor i in range(N):\n s = int(input())\n ten.append(s) if s%10 == 0 else notten.append(s)\n\nscore = sum(notten)\n\nwhile score % 10 == 0:\n if len(notten) == 0:\n break\n score -= min(notten)\n notten.remove(min(notten))\n\nif score == 0:\n print(0)\nelse:\n print(score+sum(ten))"]
{"inputs": ["3\n5\n10\n15\n", "3\n10\n10\n15\n", "3\n10\n20\n30\n"], "outputs": ["25\n", "35\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
29,851
ca965a51515e9e79017c4215fc9c4565
UNKNOWN
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position. -----Constraints----- - 2 \leq N \leq 100 - |S| = N - S consists of lowercase English letters. -----Input----- Input is given from Standard Input in the following format: N S -----Output----- Print the largest possible number of different letters contained in both X and Y. -----Sample Input----- 6 aabbca -----Sample Output----- 2 If we cut the string between the third and fourth letters into X = aab and Y = bca, the letters contained in both X and Y are a and b. There will never be three or more different letters contained in both X and Y, so the answer is 2.
["#\n# abc096 b\n#\nimport sys\nfrom io import StringIO\nimport unittest\nfrom collections import Counter\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\naabbca\"\"\"\n output = \"\"\"2\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"10\naaaaaaaaaa\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\"\"\"\n output = \"\"\"9\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n S = input()\n\n ans = 0\n for i in range(1, N-1):\n x = Counter(S[0:i])\n y = S[i:]\n tmp = 0\n for j in list(x.keys()):\n if j in y:\n tmp += 1\n ans = max(ans, tmp)\n\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "N = int(input())\nS = input()\n\nans = 0\nfor i in range(1,N-1):\n set1 = set(S[:i])\n set2 = set(S[i:])\n z = set1.intersection(set2)\n ans = max(ans,len(z))\n\nprint(ans)\n", "N = int(input())\nS = input()\nans = 0\nfor i in range(1, N):\n L = set(S[:i])\n R = set(S[i:])\n ans = max(ans, len(L & R))\n\nprint(ans)", "n = int(input())\ns = list(input())\nans = 0\nfor i in range(1, n):\n count = 0\n x = sorted(set(s[:i]))\n y = sorted(set(s[i:]))\n for j in x:\n if j in y:\n count += 1\n ans = max(ans, count)\nprint(ans)", "n = int(input())\ns = input()\nans = 0\nfor i in range(n-1):\n front = set(s[:i+1])\n back = set(s[i+1:])\n ans = max(ans, len(front&back))\nprint(ans)", "N = int(input())\nS = input()\n\ncnt = 0\nfor i in range(N):\n s1 = set(S[:i])\n s2 = set(S[i:])\n l: int = len(s1 & s2)\n if l > cnt:\n cnt = l\n\nprint(cnt)\n", "n = int(input())\ns = input()\n\ndef check(a,b):\n c = [0] * 26\n d = [0] * 26\n for i in range(len(a)):\n c[ord(a[i])-97] = 1\n for i in range(len(b)):\n d[ord(b[i])-97] = 1\n ans = 0\n for i in range(26):\n if c[i] == 1 and d[i] == 1:\n ans += 1\n return ans\n\nres = 0\nfor i in range(n):\n res = max(res,check(s[:i],s[i:]))\nprint(res)\n", "_ = input()\nS = input()\n\nprint(max([len(set(S[:i]) & set(S[i:])) for i in range(len(S))]))", "n=int(input())\ns=input()\ns=list(s)\n\nx=[]\n\nfor i in range(n):\n a=s[:i]\n b=s[i:]\n cnt=0\n c=set(a)\n d=set(b)\n c=list(c)\n d=list(d)\n for j in range(len(c)):\n for k in range(len(d)):\n if c[j]==d[k]:\n cnt+=1\n break\n x.append(cnt)\n\nprint(max(x))", "n=int(input())\ns=input()\nprint(max(len(set(s[:i])&set(s[i:])) for i in range(n)))", "N = int(input())\nS = input()\n\nlist1 = []\nfor i in range(N):\n x = set()\n \n for s in S[:i+1]:\n if s in S[i+1:]:\n x.add(s)\n list1.append(len(x))\nprint(max(list1))", "n=int(input())\nS=input()\nans=0\nfor i in range(1,len(S)):\n S1=S[:i]\n S2=S[i:]\n cnt = set()\n for s1 in S1:\n if s1 in S2:\n cnt.add(s1)\n ans = max(ans,len(cnt))\nprint(ans)", "n=int(input())\ns=input()\nans=0\nfor i in range(1,n):\n cnt=0\n l=set (s[:i])\n r=set (s[i:])\n for v in l:\n if v in r:\n cnt+=1\n ans=max(ans,cnt)\nprint(ans)", "N = int(input())\nS = input()\n\nmax_cnt = 0\nfor i in range(1, N):\n x = set(S[0:i])\n y = set(S[i:N])\n x_y = len(x & y)\n \n if x_y > max_cnt:\n max_cnt = x_y\n \nprint(max_cnt)", "n = int(input())\ns = list(input())\nans = 0\nc = 0\nfh = []\nlh = s\nfor i in range(n):\n tmp = lh.pop(0)\n if tmp not in fh:\n if tmp in lh:\n c += 1\n elif tmp not in lh:\n c -= 1\n fh.append(tmp)\n ans = max(ans, c)\nprint(ans)", "n=int(input())\ns=input()\nans=0\nfor i in range(n-1):\n a=set()\n b=set()\n for j in range(i):\n a.add(s[j])\n for j in range(i,n):\n b.add(s[j])\n ans=max(ans,len(a&b))\nprint(ans)", "N = int(input())\nS = input()\n\nmax_counter = 0\nfor i in range(1, N-1):\n x = set(S[0:i])\n y = set(S[i:N])\n if len(x & y) > max_counter:\n max_counter = len(x & y)\n\nprint(max_counter)", "N = int(input())\nS = input()\nlist = [0]*N\nfor i in range(N):\n A = S[:i]\n B = S[i:]\n A = set(A)\n B = set(B)\n for j in A:\n if j in B:\n list[i] += 1\nlist = sorted(list)\nprint(list[-1])", "n = int(input())\ns = input()\nc = 0\nfor i in range(1,n-1):\n x = set(s[:i])\n y = set(s[i:])\n cap = x&y\n c = max(c,len(cap))\nprint(c)", "n = int(input())\ns = input()\na = []\nfor i in range(1, len(s)):\n s1 = list(s[:i])\n s2 = list(s[i:])\n b = []\n for j in s1:\n if j in s2 and j not in b:\n b.append(j)\n a.append(len(b))\nprint(max(a))", "n=int(input())\ns=str(input())\n\nans=0\nfor i in range(1,n):\n be_s=set(s[:i])\n af_s=set(s[i:])\n num=len(be_s & af_s)\n ans=max(ans,num)\n \nprint(ans)", "n = int(input())\ns = input()\n\ncount = []\nfor i in range(1,n):\n first = s[:i]\n second= s[i:]\n # print(first,second)\n count.append(len(set(first)&set(second)))\n\n# print(count)\nprint((max(count)))\n", "n = int(input())\ns = input()\nL = \"\"\nR = \"\"\nC = \"\"\ntmp = 0\nans = []\nfor i in range(1, len(s)):\n L = s[:i]\n R = s[i:]\n C = len(set(L) & set(R))\n ans.append(C)\n L = \"\"\n R = \"\"\nprint(max(ans))", "import sys\nlines = [s.rstrip(\"\\n\") for s in sys.stdin.readlines()]\nn, = [int(num) for num in lines.pop(0).split(\" \")]\ns = lines.pop(0)\n\nans = 0\nfor i in range(n):\n intersection = set(s[:i]) & set(s[i:])\n num = len(intersection)\n if num > ans:\n ans = num\nprint(ans)\n", "N = int(input())\nS = [i for i in input()]\nANS = []\n\nfor i in range(1, N+1):\n ans = 0\n A = []\n B = []\n A = list(set(S[:i]))\n B = list(set(S[i:]))\n for a in A:\n for b in B:\n if a == b:\n ans += 1\n ANS.append(ans)\nprint(max(ANS))", "n = int(input())\ns = input()\n\nans = 0\n\nfor i in range(n):\n #\u8907\u6570\u306e\u30ea\u30b9\u30c8\u304b\u3089\u5171\u901a\u3059\u308b\u8981\u7d20\u3092\u62bd\u51fa\n ans = max(ans, len(set(list(s[:i])) & set(list(s[i:]))))\n\nprint(ans)", "n = int(input())\ns = input()\nans = 0\nfor i in range(1, n+1):\n cnt = 0\n x = s[0:i]\n y = s[i:n+1]\n for j in range(97, 123):\n if chr(j) in x and chr(j) in y:\n cnt += 1\n ans = max(cnt, ans)\nprint(ans)", "n = int(input())\ns = input()\nc = 0\nfor i in range(n-1):\n xy=set(s[i+1:])&set(s[:i+1])\n c = max(c,len(xy))\nprint(c)", "n = int(input())\ns = input()\n\nalphabets = [chr(i + 97) for i in range(26)]\n\n# forward\nl1 = [0] * (n-1)\nnow = [False] * 26\nfor i in range(n-1):\n now[ord(s[i]) - 97] = True\n l1[i] = now.copy()\n\n# backward\nl2 = [0] * (n-1)\nnow = [False] * 26\nfor i in range(n-1, 0, -1):\n now[ord(s[i]) - 97] = True\n l2[i-1] = now.copy()\n\nans = 0\nfor i in range(n-1):\n cnt = 0\n for j in range(26):\n if l1[i][j] and l2[i][j]:\n cnt += 1\n\n if ans < cnt:\n ans = cnt\n\nprint(ans)", "N = int(input())\nS = input()\n\ncnt = []\nfor n in range(1, N):\n x = sorted(S[:n])\n y = sorted(S[n:])\n cnt.append(len(set(x)&set(y)))\n \nprint(max(cnt))", "n = int(input())\ns = input()\ncount = 0\nans = 0\nfor i in range(0, n - 1):\n x = list(s[:i + 1])\n y = list(s[i + 1:])\n for c in range(ord('a'), ord('z') + 1):\n if chr(c) in x and chr(c) in y:\n count += 1\n if ans < count:\n ans = count\n count = 0\nprint(ans)", "import collections\nn = int(input())\ns = input()\nans = 0\nfor l in range(1,n):\n s1 = s[:l]\n s2 = s[l:]\n s1 = collections.Counter(s1)\n s2 = collections.Counter(s2)\n num = 0\n for i in s1:\n if i in s2:\n num += 1\n ans = max(ans,num)\nprint(ans)", "N = int(input())\nS = input()\n\nprint(max([len(set(list(S[:i])) & set(list(S[i:]))) for i in range(N)]))", "n = int(input())\ns = input()\nans = []\nfor i in range(1,n):\n cnt = 0\n A = set(s[:i])\n B = set(s[i:])\n for j in A:\n if j in B:\n cnt += 1\n ans.append(cnt)\nprint(max(ans))", "n = int(input())\ns = input()\nmx = -1\nfor i in range(1,n):\n x = set(s[0:i])\n y = set(s[i:])\n mx = max(mx,len(x&y))\nprint(mx)\n \n", "n = int(input())\ns = input()\nans = 0\n\nfor i in range(1,len(s)):\n s1 = s[:i]\n s2 = s[i:]\n cnt = set()\n for j in s1:\n if j in s2:\n cnt.add(j)\n ans = max(ans,len(cnt))\nprint(ans)\n", "N = int(input())\nS = input()\n\nans = 0\nfor i in range(N):\n l = S[:i]\n r = S[i:]\n now = len(set(l) & set(r))\n ans = max(ans, now)\nprint(ans)", "N = int(input())\nS = list(input())\nres = []\n\nfor i in range(1, N):\n res.append(len(set(S[:i]) & set(S[i:])))\n\nprint(max(res))", "N = int(input())\nS = input()\n\nres = 0\nfor i in range(1,N):\n com = set(S[:i]) & set(S[i:])\n if res<len(com):\n res=len(com)\nprint(res)", "N = int(input())\nS = input()\n\ndef f(s, t):\n set_s = set()\n set_t = set()\n for i in s:\n set_s.add(i)\n for i in t:\n set_t.add(i)\n return len( set_s & set_t )\n\nans = 0\nfor i in range(1,N):\n s = S[i:]\n t = S[:i]\n ans = max(ans, f(s ,t))\nprint(ans)", "\nN = int(input())\nS = input()\n\nans = 0\nfor i in range(1,N):\n common = set(S[i:]) & set(S[:i])\n ans = max(ans,len(common))\n\nprint(ans)", "#!/usr/local/bin/python3\n# https://atcoder.jp/contests/abc098/tasks/abc098_b\n\nN = int(input())\nS = input()\n\n\ndef check(i):\n return len(set(S[:i]) & set(S[i:]))\n\n\nans = [0] * N\nfor i in range(N):\n ans[i] = check(i)\n\nprint((max(ans)))\n", "import sys\n\ninput = sys.stdin.readline\nN = int(input())\nS = list(input().strip())\n\nans = 0\nfor i in range(N):\n ans = max(ans, len(set(S[:i]) & set(S[i:])))\nprint(ans)", "n = int(input())\ns = input()\nalphabets = 'abcdefghijklmnopqrstuvwxyz'\nmax_chr = 0\n\nfor i in range(len(s)-1):\n cnt = 0\n for letter in alphabets:\n if (letter in s[:i+1]) and (letter in s[i+1:]):\n cnt += 1\n max_chr = max(max_chr, cnt)\nprint(max_chr)", "n = int(input())\ns = input()\nans = 0\nfor i in range(1,n):\n x,y = set(s[:i]),set(s[i:])\n ans = max(ans,len(x&y))\nprint(ans)", "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\ndef main():\n n = i_input()\n s = s_input()\n ans = 0\n for i in range(n):\n l = set(s[:i])\n r = set(s[i:])\n trial = 0\n for k in l:\n if k in r:\n trial += 1\n ans = max(ans,trial)\n print(ans)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N=int(input())\nS=input()\nans=0\ns=\"abcdefghijklmnopqrstuvwxyz\"\nfor i in range(1,N):\n T1=S[0:i]\n T2=S[i:N]\n count=0\n for c in s:\n if c in T1 and c in T2:\n count+=1\n ans=max(ans,count)\nprint(ans)\n", "n = int(input())\ns = input()\n\ncnt = 0\nfor i in range(1, n-1):\n tmp = 0\n r, l = s[:i], s[i:]\n rs = list(set(r))\n for ri in rs:\n if l.count(ri) > 0:\n tmp += 1\n cnt = max(cnt, tmp)\n\nprint(cnt)", "N = int(input())\nS = input()\nans = 0\nfor i in range(1, N - 1):\n ans = max(ans, len(set(S[:i]) & set(S[i:])))\nprint(ans)", "N = int(input())\nS = list(input())\ndic = {}\n\nfor i in range(N):\n if S[i] not in dic.keys():\n dic[S[i]] = [i]\n else:\n dic[S[i]].append(i)\n \nans = 0\nfor j in range(1,N):\n cnt = 0\n for k in dic.values():\n check1 = False\n check2 = False\n for l in k:\n if l < j:\n check1 = True\n if j <= l:\n check2 = True\n if check1 and check2:\n cnt += 1\n ans = max(ans, cnt)\n \nprint(ans)", "N=int(input())\nS=input()\nalf=\"abcdefghijklmnopqrstuvwxyz\"\nans=0\n\nfor i in range(N-1):\n S1=list(S[0:i+1])\n S2=list(S[i+1:N])\n\n temp=0\n li1=[0]*26\n li2=[0]*26\n\n for j in range(len(S1)):\n li1[alf.find(S1[j])]+=1\n for k in range(len(S2)):\n li2[alf.find(S2[k])]+=1\n \n for l in range(26):\n if min(li1[l],li2[l])!=0:\n temp+=1\n if temp>ans:\n ans=temp\nprint(ans)\n", "n = int(input())\ns = input()\ncnt = 0\nfor i in range(1,n):\n l = []\n for j in s[:i]:\n if j in s[i:]:\n l.append(j)\n l = set(l)\n cnt = max(cnt,len(l))\n\nprint(cnt)", "N = int(input())\nS = input()\nans = 0\nfor i in range(N):\n s1 = set(S[:i])\n s2 = set(S[i:])\n ans = max(len(s1 & s2), ans)\nprint(ans)", "n=int(input())\ns=input()\ncount = 0\nfor i in range(n-1):\n a=s[:i + 1]\n b=s[i+1:]\n temp = 0\n for j in range(27):\n if chr(96+j) in a and chr(96+j) in b:\n temp += 1\n count = max(temp, count)\nprint(count)", "def main():\n n = int(input())\n s = input()\n ans = 0\n\n for i in range(1, n):\n cnt = 0\n x, y = set(s[:i]), set(s[i:])\n for j in x:\n if j in y:\n cnt += 1\n ans = max(ans, cnt)\n\n print(ans)\n\n\nmain()", "n = int(input())\ns = input()\nans = 0\nfor i in range(1,n):\n cnt = 0\n l = set(s[:i])\n r = set(s[i:])\n for v in l:\n if v in r:\n cnt += 1\n ans = max(ans,cnt)\nprint(ans)", "#\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 = \"\"\"6\naabbca\"\"\"\n output = \"\"\"2\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"10\naaaaaaaaaa\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\"\"\"\n output = \"\"\"9\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n S = input()\n\n ans = 0\n for i in range(1, N-1):\n x = set(S[0:i])\n y = set(S[i:])\n ans = max(ans, len(x & y))\n\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "def al_cnt(k,s):\n count = 0\n if 'a' in s[:k] and 'a' in s[k:]:\n count += 1\n if 'b' in s[:k] and 'b' in s[k:]:\n count += 1\n if 'c' in s[:k] and 'c' in s[k:]:\n count += 1\n if 'd' in s[:k] and 'd' in s[k:]:\n count += 1\n if 'e' in s[:k] and 'e' in s[k:]:\n count += 1\n if 'f' in s[:k] and'f' in s[k:]:\n count += 1\n if 'g' in s[:k] and 'g' in s[k:]:\n count += 1\n if 'h' in s[:k] and 'h' in s[k:]:\n count += 1\n if 'i' in s[:k] and 'i' in s[k:]:\n count += 1\n if 'j' in s[:k] and 'j' in s[k:]:\n count += 1\n if 'k' in s[:k] and 'k' in s[k:]:\n count += 1\n if 'l' in s[:k] and 'l' in s[k:]:\n count += 1\n if 'm' in s[:k] and 'm' in s[k:]:\n count += 1\n if 'n' in s[:k] and 'n' in s[k:]:\n count += 1\n if 'o' in s[:k] and 'o' in s[k:]:\n count += 1\n if 'p' in s[:k] and 'p' in s[k:]:\n count += 1\n if 'q' in s[:k] and 'q' in s[k:]:\n count += 1\n if 'r' in s[:k] and 'r' in s[k:]:\n count += 1\n if 's' in s[:k] and 's' in s[k:]:\n count += 1\n if 't' in s[:k] and 't' in s[k:]:\n count += 1\n if 'u' in s[:k] and 'u' in s[k:]:\n count += 1\n if 'v' in s[:k] and 'v' in s[k:]:\n count += 1\n if 'w' in s[:k] and 'w' in s[k:]:\n count += 1\n if 'x' in s[:k] and 'x' in s[k:]:\n count += 1\n if 'y' in s[:k] and 'y' in s[k:]:\n count += 1\n if 'z' in s[:k] and 'z' in s[k:]:\n count += 1\n return count\nn = int(input())\ns = input()\nans = 0\nfor i in range(1,n-1):\n temp = al_cnt(i,s)\n ans = max(ans,temp)\nprint(ans)", "N = int(input())\nS = str(input())\n_sum = 0\nvisited = set()\n_sum_visited = set()\nmax_size = len(set(S))\n\n\nfor n in range(N-1):\n if S[n] in S[n+1:] and (S[n] not in visited):\n _sum += 1\n \n elif S[n] in visited and (S[n] not in S[n+1:]):\n _sum -= 1\n \n visited.add(S[n])\n _sum_visited.add(_sum)\n last_size = len(set(S[n+1]))\n ans = max(_sum_visited)\n if ans == max_size:\n break\n \nprint(max(_sum_visited))", "N=int(input())\nS=input()\n\nans = 0\nfor i in range(N):\n\ts1,s2=set(S[:i]),set(S[i:])\n\ttmp = len(s1.intersection(s2))\n\tif tmp > ans:ans=tmp\n\n\nprint(ans)", "n = int(input())\nS = input()\n\nans = 0\nfor i in range(1, n):\n X, Y = S[:i], S[i:]\n cnt = 0\n for x in set(X):\n if x in Y:\n cnt += 1\n ans = max(cnt, ans)\nprint(ans)", "N = int(input())\nS = input()\n\nmax_count = 0\nfor i in range(0, N-1):\n X = S[0:i+1]\n Y = S[i+1:]\n\n X_set = set(X)\n Y_set = set(Y)\n\n count = len(X_set & Y_set)\n if max_count < count:\n max_count = count\n\nprint(max_count)\n", "N = int(input())\nS = input()\n\nprint(max(len((set(S[:i]) & set(S[i:]))) for i in range(1, N)))", "N = int(input())\nS = list(input())\n\nres = 0\n\nfor i in range(1, N):\n cnt = set(S[0:i]) & set(S[i:N])\n if res < len(cnt):\n res = len(cnt)\n\nprint(res)", "n=int(input())\ns=input()\ncount_list=[]\n\nfor i in range(1,n):\n x=s[:i]\n y=s[i:]\n xset=set(x)\n xlist=list(xset)\n count=0\n for j in xlist:\n if j in y:\n count+=1\n count_list.append(count)\n\n\nprint((max(count_list))) \n", "n = int(input())\ns = input()\n\nmax_count = 0\n\nfor i in range(1, n):\n s1 = ''.join(set(s[:i]))\n s2 = ''.join(set(s[i:]))\n count = 0\n for j in range(len(s1)):\n if s1[j] in s2:\n count += 1\n if count > max_count:\n max_count = count\nprint(max_count)", "from collections import Counter\nN = int(input())\nS = input()\nans = 0\nfor i in range(N):\n d1 = Counter(S[:i])\n d2 = Counter(S[i:])\n tmp = 0\n for alphabet in 'abcdefghijklmnopqrstuvwxyz':\n tmp += min(d1[alphabet], d2[alphabet], 1)\n print\n ans = max(ans, tmp)\nprint(ans)", "N=int(input())\nS=input()\ntmp=0\nans=0\nfor i in range(N):\n A=set(S[:i])\n B=set(S[i:N])\n AB=A & B\n tmp=len(AB)\n if tmp > ans:\n ans=tmp\nprint(ans)\n \n", "n=int(input())\ns=input()\n\nresult = 0\nfor i in range(1,n):\n x = s[:i]\n y = s[i:]\n x_set = set(x)\n y_set = set(y)\n num = x_set & y_set\n result = max(result, len(num))\nprint(result)\n", "n=int(input())\ns=input()\ntmp,ans=0,0\nfor i in range(n+1):\n s0=[]\n for j in range(n):\n if j<i:\n t=True\n for x in s0:\n if x==s[j]:t=False\n if t:s0.append(s[j])\n else:\n for k in range(len(s0)):\n if s0[k]==s[j]:\n tmp+=1\n s0[k]=-1\n #print(i,tmp)\n tmp,ans=0,max(ans,tmp)\nprint(ans)", "input()\nS = input()\n\nprint(max(len(set(S[:i]) & set(S[i:])) for i in range(len(S))))", "n=int(input())\ns=input()\ndata=[]\nans=0\nfor i in range(n-1):\n if s[i] not in data:\n data.append(s[i])\n res=0\n for j in data:\n if j in s[i+1:n]:\n res+=1\n ans=max(ans,res)\nprint(ans)", "N = int(input())\nN_List = list(map(str,input().strip()))\nans = 0\nfor i in range(1,N):\n c_ans = len(set(N_List[:i]) & set(N_List[i:]))\n if c_ans > ans:\n ans = c_ans\nprint(ans)", "n = int(input())\ns = input()\nlist_intersection = []\n\nfor i in range(1, n + 1):\n a = set(s[:i])\n b = set(s[i:])\n intersection_a_b = a.intersection(b)\n list_intersection.append(len(intersection_a_b))\n\nprint(max(list_intersection))", "# len(set) \u611a\u76f4\nn = int(input())\ns = list(input())\nans = 0\nfor i in range(1, n):\n x, y = set(s[:i]), set(s[i:])\n ans = max(ans, len(x & y))\nprint(ans)\n", "N = int(input())\ns = input()\n\nresult = 0\nfor i in range(N - 1):\n a = set(s[:i])\n b = set(s[i:])\n result = max(result, len(a & b))\n \nprint(result)", "n = int(input())\ns = input()\nans = 0\nfor i in range(1,n-1):\n a = set(s[:i])\n b = set(s[i:])\n q = max(len(a),len(b))\n t = 0\n if ans >= q:\n continue\n if len(a) >= len(b):\n w = list(a)\n h = list(b)\n else:\n w = list(b)\n h = list(a)\n for k in range(q):\n if w[k] in h:\n t += 1\n ans = max(ans,t)\nprint(ans)", "n=int(input())\ns = list(input())\nwd = list(\"abcdefghijklmnopqrstuvwxyz\")\nans=0\nfor i in range(n):\n s1 = set(s[:i])\n s2=set(s[i:])\n tmp=0\n for w in wd:\n if w in s1 and w in s2:\n tmp+=1\n ans=max(ans,tmp)\nprint(ans)\n", "n = int(input())\ns = input()\nmatch = []\nfor i in range(1,len(s)):\n s1 = list(s[:i])\n s2 = list(s[i:])\n cnts = []\n for j in s1:\n if j in s2:\n if j not in cnts:\n cnts.append(j)\n match.append(len(cnts))\nprint(max(match))", "n = int(input())\na = input()\ndic=\"abcdefghijklmnopqrstuvwxyz\"\nmaxcount = 0\nfor i in range(n):\n count = 0\n for j in range(26):\n if str(dic[j]) in a[:i] and str(dic[j]) in a[i:]:\n count+=1\n maxcount = max(count,maxcount)\nprint(maxcount)", "n=int(input())\ns=input()\nalh=\"abcdefghijklmnopqrstuvwxyz\"\nmax=0\nfor i in range(n):\n front=s[:i]\n rear=s[i:]\n cnt=0\n for j in alh:\n if j in front and j in rear:\n cnt+=1\n if cnt>max:\n max=cnt\nprint(max)", "N = int(input())\nS = input()\n\nprint(max([len(set(S[:i]) & set(S[i:])) for i in range(N)]))", "n = int(input())\ns = input()\na = []\nfor i in range(1, n):\n a.append(len(set(s[:i]) & set(s[i:])))\nprint(max(a))", "# ABC098\n\nN = int(input())\nS = input()\nans = 0\nfor i in range(len(S)):\n left = set(S[0:i])\n right = set(S[i:len(S)])\n\n ans = max(ans, len(left & right))\nprint(ans)\n", "n = int(input())\ns = list(input())\nans = []\nfor i in range(1, n):\n first_falf = set(s[:i])\n after_falf = set(s[i:])\n count = 0\n for word in first_falf:\n if word in after_falf:\n count += 1\n ans.append(count)\nprint((max(ans)))\n", "n = int(input())\ns = str(input())\nans = 0\n\nfor i in range(1,n):\n l = list(s[0:i])\n r = list(s[i:n])\n dup = len(set(l)&set(r))\n\n if ans < dup:\n ans = dup\nprint(ans)\n", "n = int(input())\ns = list(map(str,input()))\nansl = []\nfor i in range(1,n):\n ans = 0\n x = list(set(s[:i]))\n y = list(set(s[i:]))\n for j in range(len(x)):\n if x[j] in y:\n ans += 1\n ansl.append(ans)\nprint(max(ansl))", "n = int(input())\nS = list(input())\nans = 0\n\nfor i in range(1,n-1):\n L = S[:i]\n R = S[i:]\n UL = set(L)\n UR = set(R)\n ans = max(ans, len(UL & UR))\n\nprint(ans)", "N = int(input())\nS = input()\n\nr = 0\nfor i in range(1, N):\n s1 = S[:i]\n s2 = S[i:]\n r = max(len(set(s1) & set(s2)), r)\n\nprint(r)\n", "n=int(input())\ns=input()\nshurui=[]\nfor i in range(len(s)-1):\n zenhan=s[0:i+1]\n kouhan=s[i+1:len(s)]\n kaburu=[]\n kaburu.clear()\n a=0\n for j in range(len(zenhan)):\n if kouhan.count(zenhan[j]) != 0 and kaburu.count(zenhan[j])==0:\n a+=1\n kaburu.append(zenhan[j])\n shurui.append(a)\nprint((max(shurui)))\n", "_ = input()\nS = input()\n\nprint(max(len(set(S[:i]) & set(S[i:])) for i in range(len(S))))", "N = int(input())\ns = input()\n\ndef count(x, y):\n l= []\n result = 0\n for i in range(len(x + y)):\n l.append((x + y)[i])\n for letter in set(l):\n if (letter in x) and (letter in y):\n result += 1\n return result\n\nlst = []\nfor i in range(1, N):\n lst.append(count(s[:i], s[i:]))\n\nprint(max(lst))", "N = int(input())\nS = list(input())\n\nprint(max([len(set(S[:i]) & set(S[i:])) for i in range(N)]))", "N = int(input())\nS = input()\n\nss = []\nfor s in S:\n if s not in ss:\n ss.append(s)\n\nmax_count = 0\nfor i in range(1, N-1):\n count = 0\n for s in ss:\n x = S[0:i]\n y = S[i:N]\n if s in x and s in y:\n count += 1\n if count > max_count:\n max_count = count\n\nprint(max_count)", "N=int(input())\nS=input()\n\nans=0\nfor i in range(N):\n X=S[0:i]\n Y=S[i:N] \n XY=set(X) & set(Y)\n cnt=len(XY)\n ans=max(ans,cnt)\n\nprint(ans)", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools\nfrom collections import deque\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nDR = [1, -1, 0, 0]\nDC = [0, 0, 1, -1]\n\ndef LI(): return [int(x) for x in sys.stdin.readline().split()]\ndef LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]\ndef LF(): return [float(x) for x in sys.stdin.readline().split()]\ndef LS(): return sys.stdin.readline().split()\ndef I(): return int(sys.stdin.readline())\ndef F(): return float(sys.stdin.readline())\ndef S(): return input()\n \ndef main():\n N = I()\n s = S()\n ans = 0\n for i in range(N):\n a = s[:i]\n b = s[i:]\n c = len(set(a).intersection(set(b)))\n ans = max(c, ans)\n print(ans)\n\n\nmain()\n\n", "def answer(n: int, s: str) -> int:\n result = 0\n for i in range(1, n):\n x = set(s[i:])\n y = set(s[:i])\n common_characters = x.intersection(y)\n result = max(result, len(common_characters))\n\n return result\n\ndef main():\n n = int(input())\n s = input()\n print((answer(n,s)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "\nN = int(input())\nS = input()\n\nans = 0\n\nfor i in range(N-1):\n L = S[:i+1]\n R = S[i+1:]\n c = 0\n for l in set(L):\n if l in R:\n c += 1\n\n ans = max(ans, c)\n\nprint(ans)", "def calc_intersection():\n n = int(input())\n s = input()\n list_intersection = []\n\n for i in range(1, n):\n a = set(s[:i])\n b = set(s[i:])\n intersection_a_b = a.intersection(b)\n list_intersection.append(len(intersection_a_b))\n return max(list_intersection)\n\n\ndef __starting_point():\n print(calc_intersection())\n__starting_point()"]
{"inputs": ["6\naabbca\n", "10\naaaaaaaaaa\n", "45\ntgxgdqkyjzhyputjjtllptdfxocrylqfqjynmfbfucbir\n"], "outputs": ["2\n", "1\n", "9\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
27,511
ba7990346a681de06ba6217412b64ca4
UNKNOWN
The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ... Given is a string S representing the weather in the town today. Predict the weather tomorrow. -----Constraints----- - S is Sunny, Cloudy, or Rainy. -----Input----- Input is given from Standard Input in the following format: S -----Output----- Print a string representing the expected weather tomorrow, in the same format in which input is given. -----Sample Input----- Sunny -----Sample Output----- Cloudy In Takahashi's town, a sunny day is followed by a cloudy day.
["s=input()\n\nif s=='Sunny':\n print('Cloudy')\nif s=='Cloudy':\n print('Rainy')\nif s=='Rainy':\n print('Sunny')\n \n", "s=str(input())\nif s=='Sunny':\n print('Cloudy')\nelif s=='Cloudy':\n print('Rainy') \nelse:\n print('Sunny')", "S = input()\nweather = [\"Sunny\", \"Cloudy\", \"Rainy\"]\n \nprint(weather[(weather.index(S)+1)%3]) ", "S=input()\na=['Sunny','Cloudy','Rainy']\nfor i in range(3):\n if a[i]==S:\n print((a[(i+1)%3]))\n", "w=['Sunny', 'Cloudy', 'Rainy']\nprint((w[(w.index(input())+1)%3]))\n", "T = ['Sunny', 'Cloudy', 'Rainy']\nS = input()\nidx = T.index(S)\nprint(T[idx+1] if idx!=2 else T[0])", "S = input()\nif S.startswith('S'):\n print('Cloudy')\nelif S.startswith('C'):\n print('Rainy')\nelse:\n print('Sunny')", "s=list(input())\nif s[0]==\"S\":\n print(\"Cloudy\")\nelif s[0]==\"C\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "s = input()\nif s == 'Sunny':\n print('Cloudy')\nelif s == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')\n", "a = input()\nif a == 'Sunny':\n print('Cloudy')\nelif a == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')\n", "S=input()\nW=['Sunny','Cloudy','Rainy']\ni=W.index(S)\nif i==2:\n ans=0\nelse:\n ans=i+1 \nprint(W[ans])", "S = input()\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "s = input()\nif s == 'Sunny':\n print('Cloudy')\nelif s == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')\n", "S = input()\n\nif S == 'Sunny':\n ans = 'Cloudy'\nelif S == 'Cloudy':\n ans = 'Rainy'\nelif S == 'Rainy':\n ans = 'Sunny'\n\nprint(ans)", "S = input()\n\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "S = input()\nif S == 'Sunny':\n ans = 'Cloudy'\nelif S == 'Cloudy':\n ans = 'Rainy'\nelse:\n ans = 'Sunny'\nprint(ans)", "list = ['Sunny', 'Cloudy', 'Rainy']\n\ns = input()\n\ni = list.index(s)\n\nanswer = list[i - 2]\n\nprint(answer)", "S = str(input())\n\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')\n", "s = input()\nans_list = ['Sunny', 'Cloudy', 'Rainy']\nprint((ans_list[ (ans_list.index(s) + 1) % 3 ]))\n", "s = input()\nif s[0] == \"S\":\n print(\"Cloudy\")\nelif s[0] == \"C\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "s = input()\nif s == 'Sunny':\n print('Cloudy')\nelif s == ('Cloudy'):\n print('Rainy')\nelse:\n print('Sunny')", "s = input()\nL = ['Sunny', 'Cloudy', 'Rainy']\n\nprint((L[(L.index(s)+1)%3]))\n", "#141-A\n\nS = input()\n\nA =[\"Sunny\",\"Cloudy\",\"Rainy\"]\n\nc = A.index(S)\n\n#print(A[c+1])\n\nif c == 2:\n print((A[0]))\n\nelse:\n print((A[c+1]))\n", "S=input()\nif S=='Sunny':\n print('Cloudy')\nelif S=='Cloudy':\n print('Rainy')\nelif S=='Rainy':\n print('Sunny')\n", "s=input()\n \n \nif s==\"Sunny\":\n print(\"Cloudy\")\nelif s==\"Cloudy\":\n print(\"Rainy\")\nelif s==\"Rainy\":\n print(\"Sunny\")", "s = str(input())\nwe = [\"Sunny\",\"Cloudy\",\"Rainy\"]\nans = 0\nfor i in range(3):\n if(we[i]==s):\n ans = i\n break\nprint(we[(i+1)%3])", "s=str(input())\nif s==\"Sunny\":\n print(\"Cloudy\")\nelif s==\"Cloudy\":\n print(\"Rainy\")\nelif s==\"Rainy\":\n print(\"Sunny\")", "s = input()\n\nif s == \"Sunny\":\n print(\"Cloudy\")\n\nelif s == \"Cloudy\":\n print(\"Rainy\")\n\nelif s == \"Rainy\":\n print(\"Sunny\")", "s = str(input())\nif s == \"Sunny\":\n print(\"Cloudy\")\nelif s == \"Cloudy\":\n print(\"Rainy\")\nelif s == \"Rainy\":\n print(\"Sunny\")", "s=input()\nprint('Cloudy' if s=='Sunny' else 'Rainy' if s=='Cloudy' else 'Sunny')", "s = input()\nif(s[:1]=='S'):\n print('Cloudy')\nelif(s[:1]=='C'):\n print('Rainy')\nelse:\n print('Sunny')", "s = input()\nprint(\"Sunny\" if s == \"Rainy\" else \"Cloudy\" if s == \"Sunny\" else \"Rainy\")", "S = input()\nif(S == \"Sunny\"):\n print(\"Cloudy\")\nelif(S == \"Cloudy\"):\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "S = input()\nif S == \"Sunny\":\n print(\"Cloudy\")\nelif S == \"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "w=['Sunny','Cloudy','Rainy'];print(w[(w.index(input())+1)%3])", "w = ['Sunny', 'Cloudy', 'Rainy']\ns = input()\nprint(w[(w.index(s) + 1) % 3])", "S = input()\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "s=input()\nif s==\"Sunny\":\n print(\"Cloudy\")\nelif s==\"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "S = input()\n\nif S == 'Rainy': print('Sunny')\nelif S == 'Cloudy': print('Rainy')\nelse: print('Cloudy')", "s = list(input())\n\nif s[0] == 'S':\n print(\"Cloudy\")\nelif s[0] == 'C':\n print(\"Rainy\")\nelif s[0] == 'R':\n print(\"Sunny\")", "s=input()\nif(s==\"Sunny\"):\n print(\"Cloudy\")\nelif(s==\"Cloudy\"):\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "s = input()\n\nprint(\"Sunny\" if s==\"Rainy\" else \"Cloudy\" if s == \"Sunny\" else \"Rainy\")", "lis = [\"Sunny\", \"Cloudy\", \"Rainy\"]\nS = input()\nx = lis.index(S)\nif x == 2:\n ans_key = 0\nelse:\n ans_key = x + 1\nprint(lis[ans_key])", "S = input()\n\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "S=['Sunny','Cloudy','Rainy']\nprint(S[S.index(input())-2])", "# coding: utf-8\n# Your code here!\ns=input()\nprint(\"Cloudy\"if s==\"Sunny\"\n else\"Sunny\" if s==\"Rainy\"\n else\"Rainy\")", "Wet = ['Sunny','Cloudy','Rainy','Sunny']\nprint(Wet[Wet.index(input())+1])", "w=[\"Sunny\",\"Cloudy\",\"Rainy\",\"Sunny\"]\ns=input()\nfor i in range(3):\n if s==w[i]: print(w[i+1])", "ary = ['Sunny', 'Cloudy', 'Rainy']\nS = input()\nprint(ary[(ary.index(S)+1) % 3])", "S=input()\nif S==\"Sunny\":\n print(\"Cloudy\")\nelif S==\"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "def resolve():\n weather = ['Sunny','Cloudy','Rainy']\n s = input()\n print(weather[(weather.index(s)+1)%3])\nresolve()", "s = input()\n\nif s == 'Sunny':\n print('Cloudy')\nelif s == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')\n", "S = input()\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "def __starting_point():\n\n s = input()\n\n if s == \"Sunny\":\n print(\"Cloudy\")\n elif s == \"Cloudy\":\n print(\"Rainy\")\n else:\n print(\"Sunny\")\n\n__starting_point()", "S = str(input())\n\nweather = ['Sunny', 'Cloudy', 'Rainy']\n\nprint((weather[(weather.index(S) + 1) % 3]))\n", "s = input()\nif (s == \"Sunny\"):\n print(\"Cloudy\")\nelif (s == \"Cloudy\"):\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "S = input()\nif S == \"Sunny\":\n print(\"Cloudy\")\nelif S == \"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")\n", "import sys\nimport math\n#from queue import *\n#import random\n#sys.setrecursionlimit(int(1e6))\ninput = sys.stdin.readline\n \n############ ---- USER DEFINED INPUT FUNCTIONS ---- ############\ndef inp():\n return(int(input()))\ndef inara():\n return(list(map(int,input().split())))\ndef insr():\n s = input()\n return(list(s[:len(s) - 1]))\ndef invr():\n return(list(map(int,input().split())))\n################################################################\n############ ---- THE ACTUAL CODE STARTS BELOW ---- ############\n\ns=insr()\nara=[\"Sunny\", \"Cloudy\", \"Rainy\", \"Sunny\", \"Cloudy\", \"Rainy\"]\n\nif s[0]=='S':\n\tprint((ara[1]))\nelif s[0]=='C':\n\tprint((ara[2]))\nelse:\n\tprint((ara[0]))\n", "S = input()\nans = {'Sunny': 'Cloudy', 'Cloudy': 'Rainy', 'Rainy': 'Sunny'}\n\nprint(ans[S])", "S = input()\nls = ['Sunny','Cloudy','Rainy']\nif S == 'Sunny':\n print(ls[1])\nelif S == 'Cloudy':\n print(ls[2])\nelse:\n print(ls[0])", "S = input()\n\nif S == \"Sunny\":\n print(\"Cloudy\")\nif S == \"Cloudy\":\n print(\"Rainy\")\nif S == \"Rainy\":\n print(\"Sunny\")", "s=input()\nwea=[\"Sunny\",\"Cloudy\",\"Rainy\"]\nprint(wea[(wea.index(s)+1)%3])", "s = input()\n\nprint('Sunny' if s == 'Rainy' else 'Cloudy' if s == 'Sunny' else 'Rainy')", "weather = [\"Sunny\",\"Cloudy\",\"Rainy\"]\n\n\nprint(weather[(weather.index(input())+1)%3])", "S = input()\n\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "s = input()\nw = ['Sunny','Cloudy','Rainy']\nif w.index(s) == 2:\n print(w[0])\nelse:\n print(w[w.index(s)+1])", "s = input()\n\nif s == 'Sunny':\n print('Cloudy')\nif s == 'Cloudy':\n print('Rainy')\nif s == 'Rainy':\n print('Sunny')\n", "s = input()\nif s == 'Sunny':\n print('Cloudy')\nelif s == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "S=input()\nweather=['Sunny','Cloudy','Rainy','Sunny']\nprint((weather[weather.index(S)+1]))\n", "S =input()\nif S==\"Sunny\":print(\"Cloudy\")\nelif S==\"Cloudy\":print(\"Rainy\")\nelse : print(\"Sunny\")", "S=input()\na=[\"Sunny\", \"Cloudy\", \"Rainy\"]\nprint((a[((a.index(S)+1))%3]))\n", "S=input()\nif S==\"Sunny\":print(\"Cloudy\")\nif S==\"Cloudy\":print(\"Rainy\")\nif S==\"Rainy\":print(\"Sunny\")", "S = input()\n\nif S == \"Sunny\":\n print(\"Cloudy\")\nelif S == \"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "Weather = [\"Sunny\", \"Cloudy\", \"Rainy\", \"Sunny\"]\nS = input()\nprint(Weather[Weather.index(S)+1])", "a = input()\nif a == \"Sunny\":\n print(\"Cloudy\")\nelif a == \"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "s = input()\nif s == 'Sunny':\n print('Cloudy')\nelif s == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "list = ['Sunny', 'Cloudy', 'Rainy']\n\ns = input()\n\ni = list.index(s)\nanswer = list[i - 2]\n\nprint(answer)\n", "s = input()\nif s == 'Sunny':\n result = 'Cloudy'\nelif s == 'Cloudy':\n result = 'Rainy'\nelse:\n result = 'Sunny'\n\nprint(result)\n", "s = input()\n\nif s == 'Sunny':\n print('Cloudy')\nelif s == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')\n", "\ns=input()\nif s=='Sunny':\n print('Cloudy')\nelif s == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "s = input()\nif s == 'Sunny' :\n print('Cloudy')\nelif s == 'Cloudy' :\n print('Rainy')\nelse :\n print('Sunny')", "s = input()\nif s == \"Sunny\":\n print(\"Cloudy\")\nelif s == \"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "s = input()\nw = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']\nprint(w[w.index(s) + 1])", "s=input()\nn=[\"Sunny\",\"Cloudy\",\"Rainy\"]\nfor i in range(2):\n if s==n[i]:\n print(n[i+1])\nif s==\"Rainy\":\n print(\"Sunny\")", "S = str(input())\n\nif S == \"Sunny\":\n print(\"Cloudy\")\nelif S == \"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "t = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']\nprint(t[t.index(input())+1])", "S = input()\nif S.startswith('S'):\n print('Cloudy')\nelif S.startswith('C'):\n print('Rainy')\nelse:\n print('Sunny')", "S = str(input())\n\n\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')", "s = input()\nprint('Cloudy' if s == 'Sunny' else 'Rainy' if s == 'Cloudy' else 'Sunny')", "s=input()\nif s==\"Sunny\":\n print(\"Cloudy\")\nelif s==\"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "weather = input()\nnext_weather = {'Sunny' : 'Cloudy', 'Cloudy' : 'Rainy', 'Rainy' : 'Sunny'}\nprint((next_weather[weather]))\n", "import sys\n\nS = sys.stdin.readline().strip()\nweathers = [\"Sunny\", \"Cloudy\", \"Rainy\"]\nprint(weathers[(weathers.index(S) + 1) % 3])", "S = input()\n\n\nweather = [\"Sunny\", \"Cloudy\", \"Rainy\"]\n\nprint(weather[(weather.index(S)+1) % 3])", "s = input()\nprint(('Sunny' if s == 'Rainy' else 'Cloudy' if s == 'Sunny' else 'Rainy'))\n", "S = str(input())\nif S == \"Sunny\":\n print(\"Cloudy\")\nelif S == \"Cloudy\":\n print(\"Rainy\")\nelse:\n print(\"Sunny\")", "# A - Weather Prediction\n\nS = input()\n\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelif S == 'Rainy':\n print('Sunny')", "s=input()\n\nif s==\"Sunny\":\n print(\"Cloudy\")\nelif s==\"Cloudy\":\n print(\"Rainy\")\nelif s==\"Rainy\":\n print(\"Sunny\")", "S = str(input())\n\nif S == 'Sunny':\n print('Cloudy')\nelif S == 'Cloudy':\n print('Rainy')\nelse:\n print('Sunny')\n", "li = ['Sunny','Cloudy','Rainy','Sunny']\n\nn = input()\n\nprint(li[li.index(n) + 1])"]
{"inputs": ["Sunny\n", "Rainy\n", "Cloudy\n"], "outputs": ["Cloudy\n", "Sunny\n", "Rainy\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
12,479
13e896c7ecb770e0ff95c1e9e82e3681
UNKNOWN
You are parking at a parking lot. You can choose from the following two fee plans: - Plan 1: The fee will be AΓ—T yen (the currency of Japan) when you park for T hours. - Plan 2: The fee will be B yen, regardless of the duration. Find the minimum fee when you park for N hours. -----Constraints----- - 1≀N≀20 - 1≀A≀100 - 1≀B≀2000 - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N A B -----Output----- When the minimum fee is x yen, print the value of x. -----Sample Input----- 7 17 120 -----Sample Output----- 119 - If you choose Plan 1, the fee will be 7Γ—17=119 yen. - If you choose Plan 2, the fee will be 120 yen. Thus, the minimum fee is 119 yen.
["n, a, b = (int(n) for n in input().split())\nprint(min(n * a, b))", "N, A, B = map(int,input().split())\n\nif N*A > B:\n print(B)\nelse:\n print(N * A)", "N,A,B = list(map(int, input().split()))\n\nif N * A < B:\n x = N * A\nelse:\n x = B\nprint(x)\n", "# \u6570\u5024\u306e\u53d6\u5f97\nN,A,B = map(int,input().split())\n\n# \u6599\u91d1\u306e\u6700\u5b89\u5024\u3092\u51fa\u529b\nplan1 = A * N\nplan2 = B\nprint(min(plan1,plan2))", "n, a, b = list(map(int, input().split()))\nprint((min(a * n, b)))\n", "N,A,B = map(int,input().split())\nprint(min(N*A,B))", "n, a, b = list(map(int, input().split()))\nres = min(a * n, b)\nprint(res)\n", "N,A,B = map(int,input().split())\nif N*A >= B:\n print(B)\nelse:\n print(N*A)", "#ABC080A\nn,a,b = map(int,input().split())\nprint(min(a*n,b))", "n, a, b = map(int, input().split())\nprint(min(b, a * n))", "N, A, B = map(int, input().split())\n\nprint(min(N*A, B))", "n,a,b = map(int,input().split())\nprint(n*a if n*a < b else b)", "n,a,b=map(int,input().split())\nprint(min(a*n,b))", "N, A, B = map(int, input().split())\nprint(min(A*N, B))", "N, A, B = map(int, input().split())\n\nprint(min(A * N, B))", "N, A, B = list(map(int, input().split()))\n\nprint((min(N * A, B)))\n", "N, A, B = map(int, input().split())\nprint(min(N * A, B))", "N, A, B = list(map(int, input().split()))\nprint((min(N * A, B)))\n", "n,a,b=map(int,input().split())\nprint(min(a*n,b))", "n,a,b=map(int,input().split())\nprint(min(n*a,b))", "n, a, b = map(int, input().split())\nprint(min(n * a, b))", "N,A,B = list(map(int,input().split()))\nprice = [N * A, B]\nprint((min(price)))\n", "def iroha():\n n,a,b=list(map(int, input().split()))\n print((b if b <= a*n else a*n))\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "n, a, b = list(map(int, input().split()))\n\nprint((min(n * a, b)))\n", "t, a, b = map(int, input().split())\n\nplan1 = a * t\nplan2 = b\n\nprint(min(plan1, b))", "n,a,b=map(int,input().split(\" \"))\nprint(min(n*a,b))", "N, A, B = list(map(int, input().split()))\n\nprint((min(A * N, B)))\n", "N,A,B= map(int, input().split())\n\nif N * A < B:\n print(N*A)\nelse:\n print(B)", "n, a, b = map(int, input().split())\n\nif a * n <= b:\n print(a * n)\nelse:\n print(b)", "# 080_a\nN, A, B = map(int, input().split())\nif (1 <= N & N <= 20) & (1 <= A & A <= 100) & (1 <= B & B <= 2000):\n p1 = A * N\n p2 = B\n print(min(p1, p2))", "N, A, B = map(int, input().split())\n\nprint(min(A*N, B))", "N, A, B = map(int, input().split())\n\nprint(min(N * A, B))", "n,a,b=map(int,input().split())\nprint(min(n*a,b))", "n, a, b = map(int, input().split())\nprint(min(a * n, b))", "#\n# abc080 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 = \"\"\"7 17 120\"\"\"\n output = \"\"\"119\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"5 20 100\"\"\"\n output = \"\"\"100\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"6 18 100\"\"\"\n output = \"\"\"100\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N, A, B = list(map(int, input().split()))\n print((min(N*A, B)))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "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\nN, A, B = LI()\n\nx = A*N\ny = B\n\nif x <= y:\n print(x)\nelse:\n print(y)\n\n", "N, A, B = map(int,input().split())\n\nif A * N < B:\n answer = A * N\nelse:\n answer = B\nprint(answer)", "a, b, c = map(int, input().split())\nprint(min(a * b, c))", "n,a,b = map(int,input().split())\n\nprint(min(n*a,b))", "lst = input().split()\nprint(min([int(lst[0]) * int(lst[1]), int(lst[2])]))", "T,A,B = map(int, input().split())\nprint(min(T*A, B))", "a, b, c = list(map(int, input().split()))\nif a * b <= c:\n print((a * b))\nelse:\n print(c)\n", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn, a, b = list(map(int, input().split()))\n\nprint((min(b, n*a)))\n", "n,a,b = map(int,input().split())\nprint(min(n*a,b))", "n, a, b = map(int, input().split())\nprint(min(n * a, b))", "N, A, B = map(int, input().split())\n\ns = N * A\nprint(min(s, B))", "N, A, B = map(int, input().split())\nprice = min(A * N, B)\nprint(price)", "n, a, b = map(int, input().split())\nif n * a > b:\n print(b)\nelse:\n print(n * a)", "a,b,c=map(int,input().split())\nprint(min(a*b,c))", "n,a,b = map(int,input().split())\n\nif a*n > b:\n print(b)\n \nelse:\n print(a*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 t, a, b = Input()\n print(min(t*a, b))\n\n\nmain()", "\nn,a,b=list(map(int,input().split()))\n\nprint((min(n*a,b)))\n\n\n", "# 080a\n\ndef atc_080a(NAB: str) -> int:\n N, A, B = map(int, NAB.split(\" \"))\n return min(N * A, B)\n\nNAB = input()\nprint(atc_080a(NAB))", "# 080a\n\ndef atc_080a(NAB: str) -> int:\n N, A, B = list(map(int, NAB.split(\" \")))\n return min(N * A, B)\n\nNAB = input()\nprint((atc_080a(NAB)))\n", "parking_time, time_price, anytime_price = list(map(int, input().split()))\n\nmin_price_plan = min(parking_time * time_price, anytime_price)\n\nprint(min_price_plan)\n", "n, a, b = map(int, input().split())\nprint(min(a*n, b))", "n,a,b=map(int,input().split())\nprint(min(a*n,b))", "n,a,b=map(int,input().split())\n\nprint(min(a*n,b))", "n, a, b = map(int, input().split())\n\nplan1 = a * n\nplan2 = b\n\nprint(min(plan1, plan2))", "n,a,b=map(int,input().split())\nprint(min(n*a,b))", "n,a,b = map(int,input().split())\n\nif n * a < b:\n x = n * a\nelse:\n x = b\nprint(x)", "'''\n\u554f\u984c\uff1a\n \u99d0\u8eca\u5834\u304c\u3042\u308a\u3001\u4ee5\u4e0b\u306e\u4e8c\u7a2e\u985e\u306e\u30d7\u30e9\u30f3\u306e\u3069\u3061\u3089\u304b\u3092\u9078\u3093\u3067\u99d0\u8eca\u3067\u304d\u307e\u3059\u3002\n \u30d7\u30e9\u30f3 1 : T\u6642\u9593\u99d0\u8eca\u3057\u305f\u5834\u5408\u3001A\u00d7T \u5186\u304c\u99d0\u8eca\u6599\u91d1\u3068\u306a\u308b\u3002\n \u30d7\u30e9\u30f3 2 : \u99d0\u8eca\u3057\u305f\u6642\u9593\u306b\u95a2\u308f\u3089\u305a B \u5186\u304c\u99d0\u8eca\u6599\u91d1\u3068\u306a\u308b\u3002\n N\u6642\u9593\u99d0\u8eca\u3059\u308b\u3068\u304d\u3001\u99d0\u8eca\u6599\u91d1\u306f\u6700\u5c0f\u3067\u3044\u304f\u3089\u306b\u306a\u308b\u304b\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n'''\n\n'''\n\u5236\u7d04\uff1a\n 1 \u2266 N \u2266 20\n 1 \u2266 A \u2266 100\n 1 \u2266 B \u2266 2000\n \u5165\u529b\u306f\u5168\u3066\u6574\u6570\n'''\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 N, A, B \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\nn, a, b = list(map(int, input().split()))\n\nresult = [n * a, b] # \u7d50\u679c\u51fa\u529b\u7528\u306e\u30ea\u30b9\u30c8\n\nprint((min(result)))\n", "N, A, B = map(int, input().split())\n\n# \u30d7\u30e9\u30f3 1: T\u6642\u9593\u99d0\u8eca\u3057\u305f\u5834\u5408\u3001A \u00d7 T\u5186 \u304c\u99d0\u8eca\u6599\u91d1\u3068\u306a\u308b\u3002\n# \u30d7\u30e9\u30f3 2: \u99d0\u8eca\u3057\u305f\u6642\u9593\u306b\u95a2\u308f\u3089\u305a B\u5186 \u304c\u99d0\u8eca\u6599\u91d1\u3068\u306a\u308b\u3002\n# N\u6642\u9593\u99d0\u8eca\u3059\u308b\u3068\u304d\u3001\u99d0\u8eca\u6599\u91d1\u306f\u6700\u5c0f\u3067\u3044\u304f\u3089\u306b\u306a\u308b\u304b\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\nplan_A = A * N\nplan_B = B\n\nprint(min(plan_A, plan_B))", "a,b,c = map(int, input().split())\nprint(min(a * b, c))", "N, A, B = map(int, input().split())\nprint(min(N*A, B))", "n, a, b = map(int, input().split())\n\nprint(min(a * n, b))", "N, A, B = list(map(int, input().split()))\nif N * A >= B:\n print(B)\nelse:\n print((N * A))\n", "N, A, B = list(map(int, input().split()))\nprint((min(N * A, B)))\n", "# \u99d0\u8eca\u5834\u304c\u3042\u308a\u3001\u4ee5\u4e0b\u306e\u4e8c\u7a2e\u985e\u306e\u30d7\u30e9\u30f3\u306e\u3069\u3061\u3089\u304b\u3092\u9078\u3093\u3067\u99d0\u8eca\u3067\u304d\u307e\u3059\u3002 \u30d7\u30e9\u30f3 1 : T \u6642\u9593\u99d0\u8eca\u3057\u305f\u5834\u5408\u3001 A \u00d7 T \u5186\u304c\u99d0\u8eca\u6599\u91d1\u3068\u306a\u308b\u3002\n# \u30d7\u30e9\u30f3 2 : \u99d0\u8eca\u3057\u305f\u6642\u9593\u306b\u95a2\u308f\u3089\u305a B \u5186\u304c\u99d0\u8eca\u6599\u91d1\u3068\u306a\u308b\u3002 N \u6642\u9593\u99d0\u8eca\u3059\u308b\u3068\u304d\u3001\u99d0\u8eca\u6599\u91d1\u306f\u6700\u5c0f\u3067\u3044\u304f\u3089\u306b\u306a\u308b\u304b\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\nN,A,B = map(int,input().split())\n\nprint(min(N * A, B))", "N, A, B = map(int, input().split())\nprint(min(N * A, B))", "N, A, B, = map(int, input().split())\n\nprices = [A * N, B]\n\nprint(min(prices))", "\nN, A, B = map(int, input().split())\n\n\n\nplan_A = A * N\nplan_B = B\n\nprint(min(plan_A, plan_B))", "N, A, B = map(int, input().split())\n\nprint(min(N*A, B))", "# A - Parking\n# N A B\n\nN, A, B = list(map(int, input().split()))\n\n# A * N < B \u21d4 B\n\nif (N * A) < B:\n print((N * A))\nelse:\n print(B)\n", "N,A,B = list(map(int,input().split()))\n\nplan1 = N * A\nplan2 = B\n\nmin_plice = min(plan1,plan2)\nprint(min_plice)\n", "#080A\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\nplan1 = a * b\nplan2 = c\n\nresalt=[plan1,plan2]\n\nprint(min(resalt))", "N, A, B = list(map(int,input().split()))\n\npark_price = []\npark_price.append(N * A)\npark_price.append(B)\n\nanswer = min(park_price)\nprint(answer)\n", "n,a,b=map(int,input().split())\nprint(min(a*n,b))", "N,A,B=list(map(int,input().split()))\nif N*A>B:\n print(B)\nelse:\n print((N*A)) \n", "N, A, B = map(int, input().split())\nprint(min(A * N, B))", "n, a, b = map(int,input().split())\n\nplan_1 = n * a\n\nplan_2 = b\n\nif plan_1 < plan_2:\n print(plan_1)\nelse:\n print(plan_2)", "N, T, B = map(int,input().split())\n\nprint(min(N * T, B))", "time, normal_cost, unlimited_cost = list(map(int, input().split()))\nif normal_cost * time < unlimited_cost:\n total_cost = normal_cost * time\nelse:\n total_cost = unlimited_cost\nprint(total_cost)\n", "N, A, B = map(int,input().split())\n\nif N * A >= B :\n print(B)\nelse:\n print(N * A)", "t, a, b = map(int, input().split())\nprint((min(a * t, b)))", "# N\u6642\u9593\u99d0\u8eca\u3057\u305f\u6642\u306e\u6700\u5c0f\u6599\u91d1\u3092\u6c42\u3081\u308b\n\nN, A, B = list(map(int, input().split()))\n\nfee = [N * A, B]\nprint((min(fee)))\n", "N, A, B = map(int, input().split())\n\nprint(min(A * N, B))", "N, A, B = map(int, input().split())\n\nif A * N < B:\n print(A * N)\nelse:\n print(B)", "n, a, b = map(int, input().split())\nprint(min(n*a, b))", "n, a, b = map(int, input().split())\nc = n * a\nif c > b:\n print(b)\nelse:\n print(c)", "n,a,b=map(int,input().split())\nprint(min(n*a,b))", "# A - Parking\n# https://atcoder.jp/contests/abc080/tasks/abc080_a\n\nn, a, b = list(map(int, input().split()))\n\nplan = [n * a, b]\nprint((min(plan)))\n", "n,a,b = map(int,input().split())\nprint(min((n*a,b)))", "n,a,b=map(int,input().split())\nprint(min(n*a,b))", "N,A,B=list(map(int,input().split()))\nprint((min(A*N,B)))\n", "#https://atcoder.jp/contests/abc080/tasks/abc080_a\nS_list = list(map(int,input().split()))\nN,A,B = S_list\nif N * A > B:\n result = B\nelse:\n result = N * A\nprint(result)", "n, a, b = map(int, input().split())\n\nprint(min(n*a, b))", "N,A,B = map(int,input().split())\n\nplan1 = N * A\nplan2 = B\n\nprint(min(plan1,plan2))", "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\nN,A,B=LI()\nx=N*A\ny=B\n\nif x <= y:\n print(x)\nelse:\n print(y)"]
{"inputs": ["7 17 120\n", "5 20 100\n", "6 18 100\n"], "outputs": ["119\n", "100\n", "100\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
12,843
8565200e240119b7a54b827d84b5389a
UNKNOWN
Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is YES or NO. When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases. Then, he rewrote the code to correctly solve each of those M cases with 1/2 probability in 1900 milliseconds, and correctly solve each of the other N-M cases without fail in 100 milliseconds. Now, he goes through the following process: - Submit the code. - Wait until the code finishes execution on all the cases. - If the code fails to correctly solve some of the M cases, submit it again. - Repeat until the code correctly solve all the cases in one submission. Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer). -----Constraints----- - All input values are integers. - 1 \leq N \leq 100 - 1 \leq M \leq {\rm min}(N, 5) -----Input----- Input is given from Standard Input in the following format: N M -----Output----- Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 10^9. -----Sample Input----- 1 1 -----Sample Output----- 3800 In this input, there is only one case. Takahashi will repeatedly submit the code that correctly solves this case with 1/2 probability in 1900 milliseconds. The code will succeed in one attempt with 1/2 probability, in two attempts with 1/4 probability, and in three attempts with 1/8 probability, and so on. Thus, the answer is 1900 \times 1/2 + (2 \times 1900) \times 1/4 + (3 \times 1900) \times 1/8 + ... = 3800.
["n, m = list(map(int, input().split()))\n\nans = (1900 * m + 100 * (n - m)) * (2 ** m)\n\nprint(ans)\n", "N,M = map(int,input().split())\nprint(((N-M)*100+M*1900)*2**M)", "n, m = map(int, input().split())\nvalue = 1900*m+(n-m)*100\np = 2**m\nans = value*p\nprint(ans) ", "n, m = map(int, input().split())\nbase = m * 1900 + (n - m) * 100\ncase = pow(2, m)\nprint(base * case)", "def main():\n N, M = list(map(int, input().split()))\n ans = (1900*M + 100*(N - M))*pow(2, M)\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "import math\nimport sys\nimport bisect\nreadline = sys.stdin.readline\n\n\ndef main():\n n, m = list(map(int, readline().rstrip().split()))\n cnt = 2 ** m\n print(((n + m * 18) * cnt * 100))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n,m = map(int, input().split())\nprint((100*(n-m)+1900*m)*(2**m))", "n,m=map(int,input().split())\nprint((100*n+1800*m)*(2**m))", "n, m = list(map(int, input().split()))\nprint(((1900*m + (n-m)*100)*2**m))\n", "N,M = map(int,input().split())\n\nprint((1900 * M + 100 * (N - M)) * (2 ** M))", "n,m = map(int,input().split())\n\nans = (1800*m + 100*n)*(2**m)\nprint(ans)", "n, m = list(map(int, input().split()))\nans = 0\nans += pow(2, m) * (1900 * m + 100 * (n - m))\nprint(ans)\n", "N,M=map(int,input().split())\nprint((1900*M + 100*(N-M))*2**M)", "n, m = map(int, input().split())\nprint((2 ** m) * (1900 * m + 100 * (n - m)))", "n, m = list(map(int, input().split()))\nprint(((2**m) * (1900*m + 100*(n-m))))\n\n# unit = 1900*m + 100*(n-m)\n# p = 1 / (2**m)\n# r = 1 - p\n# ans / p = 1*1 + 2*r + 3*(r**2) + 4*(r**3) + ...\n# ans * r / p = 1*r + 2*(r**2) + 3*(r**3) + 4*(r**4) + ...\n# (ans / p) - (ans * r / p) = 1 + r + r**2 + r**3 + r**4 + ...\n# (ans / p) * (1 - r) = 1 / (1 - r)\n# ans = 1 / p = 2**m\n# answer = ans * unit\n", "a,b=map(int, input().split())\nc = 2**b\nA = 100*(a-b)\nB = 1900*b\nprint((A+B)*c)", "def main():\n n, m = list(map(int, input().split()))\n wa = 0\n kaisuu = 1900 * (2 ** m)\n nokori = ((n - m) * 100) * (2 ** m)\n ikai = (1900 * m) + (100 * (n-m))\n print((ikai*(2**m)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "n,m=map(int,input().split())\nx=1900*m+100*(n-m)\nans=x*2**m\nprint(ans)", "N,M=map(int,input().split())\nprint(((N-M)*100+1900*M)*(2**M))", "#E:=\u521d\u3081\u3066\u5168\u3066\u306e\u554f\u984c\u304cAC\u3057\u305f\u6642\u307e\u3067\u306e\u8a66\u884c\u56de\u6570\u306e\u671f\u5f85\u5024\n#E=(1/2)^m+(1-(1/2)^m)(E+1)<=>E(1/2)^m=1<=>E=2^m\nn,m=map(int,input().split())\ne=2**m\nprint((1900*m+100*(n-m))*e)", "n,m = map(int,input().split())\n\nprint((1900*m+100*(n-m))*2**m)", "N, M = map(int, input().split())\n\nprint((1900*M+100*(N-M))*(2**M))", "N, M = map(int, input().split())\nprint((1900*M + 100*(N-M))*2**M)", "def main():\n n, m = list(map(int, input().split()))\n ikai = (1900 * m) + (100 * (n-m))\n print(ikai*(2**m))\n\ndef __starting_point():\n main()\n__starting_point()", "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 ans = ((N - M) * 100 + 1900 * M) * pow(2, M)\n\n print(ans)\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n, m = map(int, input().split())\n\nt = m * 1900 + (n - m) * 100\nans = t * (2 ** m)\n\nprint(ans)", "N, M = list(map(int, input().split()))\np_allac = (1/2)**M\nref = 2**M\nT = 100*(N-M) + 1900*M\nprint((T*ref))\n", "#78 C - HSI\nN,M = map(int,input().split())\n# \u5168\u3066 AC \u3068\u306a\u308b\u78ba\u7387\np = (1/2)**M\n\n# E = 1/p \u306b\u306a\u308b\nE = 1/p\nans = (1900*M + 100*(N-M))*E\nans = round(ans)\nprint(ans)", "N,M = map(int,input().split())\n\nprint(pow(2,M)*(M*1900+(N-M)*100))", "N,M = map(int,input().split())\nt = (N-M) * 100 + M * 1900\nprint(t * (2**M))", "N, M = map(int, input().split())\n\nt = (N - M) * 100 + M * 1900 \nprint(t * (2 ** M))", "#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)]\n\nprint((1900*m+100*(n-m))*(2**m))", "N,M = list(map(int,input().split()))\nA = 1900*M+100*(N-M)\n\nans = A*pow(2,M)\n#print(A)\nprint(ans)\n", "n,m=map(int,input().split())\nprint((2**m)*((n-m)*100+1900*m))", "n,m = map(int,input().split())\n\nprint(int((1900*m+100*(n-m))//(1/2**m)))", "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 n,m = i_map()\n t = 1900*m +100*(n-m)\n p = 2**m\n print((t*p))\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n, m = map(int, input().split())\nvalue = 1900*m+(n-m)*100\np = 2**m\nans = value*p\nprint(ans) ", "#!/usr/bin/env python3\n\n#import\n#import math\n#import numpy as np\n#= int(input())\n#= input()\nN, M = list(map(int, input().split()))\n\nprint(((1900 * M + 100 *(N - M)) * 2 ** M))\n\n", "n,m = map(int,input().split())\nprint((1900*m+100*(n-m))*(2**m))", "from math import ceil\nn, m = list(map(int, input().split()))\n\nbase = (n-m)*100+1900*m\nallok = pow(2,m)\n\n\"\"\"\n1\u56de\u76ee\u306fbase\u79d2\u304b\u304b\u308b\n2\u56de\u76ee\u306e\u671f\u5f85\u5024\u306f\u30011\u56de\u76ee\u306e\u6642\u70b9\u304b\u3089\u8003\u3048\u308b\u3068base + (allok-1)*y\n\"\"\"\n\nprint((base*allok))\n\n", "N,M=list(map(int,input().split()))\n\nprint((M*1900*(2**M)+(N-M)*100*(2**M)))\n", "n, m = map(int, input().split())\nprint((1900*m + 100*(n-m)) * 2**m)", "n, m = map(int, input().split())\nprint((1900 * m + (n - m) * 100) * 2 ** m)", "n, m = map(int, input().split())\n\nans = (100*(n-m) + 1900*m)*(2)**m\n\nprint(ans)", "\nN, M = map(int, input().split())\nprint((1900*M+100*(N-M))*pow(2, M))", "n,m=[int(i) for i in input().split()]\nx=1-1/(2**m)\nt=1900*m+100*(n-m)\nprint(int(t/((2**m)*((1-x)**2))))", "n, m = map(int, input().split())\nprint((1900 * m + 100 * (n - m)) * (2 ** m))", "N, M = map(int, input().split())\nprint((100 * (N - M) + 1900 * M) * (2**M))", "n,m = map(int,input().split())\nprint((1900 * m + 100 * (n - m)) * 2 ** m)", "a = [int(s) for s in input().split()]\nprint(((a[0]-a[1])*100+a[1]*1900)*(2**a[1]))", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tC\n# CreatedDate: 2020-09-27 01:33:17 +0900\n# LastModified: 2020-10-09 16:05:14 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\n\n\ndef main():\n N, M = list(map(int, input().split()))\n para0 = (1900*M+100*(N-M))/(2**M)\n para1 = 1-(1/(2**M))\n para0_ = para0\n para1_ = 1/((1-para1)**2)\n print((int(para0_*para1_)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N, M = [int(n) for n in input().split(\" \")]\n\nprint((2 ** M) * (1800 * M + 100 * N))", "# coding = SJIS\n\nn, m = map(int, input().split())\n\nprint((100 * (n - m) + 1900 * m) * (2 ** m))", "import sys\n\ninput = sys.stdin.readline\n\nn, m= map(int, input().split())\n\ny = (1900*m + 100*(n - m)) * 2**m\nprint(y)", "n,m = map(int,input().split())\n\n# \uff11\u56de\u304b\u304b\u308b\u6642\u9593\nsubmit = 1900 * m + 100 * (n-m)\n\nans = submit * 2**m\nprint(ans)", "N, M = map(int, input().split())\n \nwating_time = 1900 * M + 100 * (N-M)\nprint(2**M*wating_time)", "N,M=map(int,input().split())\nc=M*1800+N*100\nprint(c*(2**M))", "n,m = map(int, input().split())\n\nprint((1900*m+100*(n-m))*(2**m))", "n, m = list(map(int, input().split()))\nE = (2 ** m) * (1900 * m + 100 * (n - m))\nprint(E)\n", "n,m=map(int,input().split())\nprint((1900*m+100*(n-m))*2**(m))", "n, m = map(int, input().split())\nans = int((1900 * m + 100 * (n - m)) / ((1 / 2) ** m))\nprint(ans)", "n, m = list(map(int, input().split()))\nprint(((1900*m + 100*(n-m))*2**m)) \n", "n,m=map(int,input().split())\na=(n-m)*100+m*1900\n\nprint(a*(2**m))", "N,M=map(int,input().split())\nprint(1900*(M*2**M)+100*(N-M)*2**M)", "n, m = list(map(int, input().split()))\n\nexp = 2**m\n\nans = exp*(1900*m + 100*(n-m))\n\nprint(ans)", "N, M = map(int, input().split())\nprint((1900 * M + 100*(N-M)) * 2**M)", "from collections import defaultdict\nfrom collections import deque\nfrom collections import Counter\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,m = readInts()\n\nans = (1900*m+(n-m)*100)*2**m\n\nprint(ans)", "#78 C - HSI\nN,M = map(int,input().split())\n# \u5168\u3066 AC \u3068\u306a\u308b\u78ba\u7387\np = (1/2)**M\n\n# \u5168\u3066 AC \u3068\u306a\u308b\u3068\u304d\u306e\u671f\u5f85\u5024\n# k \u56de\u76ee\u307e\u3067\u306b\u300c\u6210\u529f\u3057\u306a\u3044\u300d\u78ba\u7387\u306e\u671f\u5f85\u5024\n# E = (1-p)**0 + (1-p)**1 + (1-p)**2+...\nE = 0\nfor k in range(10**6):\n E += (1-p)**k\n\nans = (1900*M + 100*(N-M))*E\nans = round(ans)\nprint(ans)", "n,m=map(int, input().split(\" \"))\nprint((1900 * m+ (n-m) * 100) * (2 ** m))", "N,M=list(map(int,input().split()))\nprint((1900*M+100*(N-M))*2**M)", "n,m=map(int,input().split())\nprint((100*(n-m)+1900*m)*(2**m))", "def main():\n n, m = map(int, input().split())\n\n time = 1900 * m + 100 * (n - m)\n power = 2 ** m\n print(time * power)\n\n\ndef __starting_point():\n main()\n__starting_point()", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn, m = list(map(int, input().split()))\n\nx = m\ny = n-m\n\nans = (1900*x+100*y)*2**x\n\nprint(ans)\n", "N,M=map(int,input().split())\nprint((1900*M+100*(N-M))*2**M)", "N, M = (int(x) for x in input().split())\n\nans = 2**M * (M*1900+(N-M)*100)\nprint(ans)\n", "n,m=map(int,input().split())\n\nonetry=100*(n-m)+1900*m\nprint(onetry*2**m)", "n,m = map(int, input().split())\n\nprint((1900*m + ((n-m)*100))*(2**m))", "import sys\nimport math\nimport heapq\nmod=10**9+7\ninf=float(\"inf\")\nfrom math import sqrt\nfrom collections import deque\nfrom collections import Counter\nfrom collections import defaultdict\n#\u3059\u3079\u3066\u306ekey\u304c\u7528\u610f\u3055\u308c\u3066\u308b defaultdict(int)\u3067\u521d\u671f\u5316\nfrom collections import OrderedDict\n#\u9806\u5e8f\u3092\u4fdd\u3063\u305fdict\nfrom math import ceil\ninput=lambda: sys.stdin.readline().strip()\nsys.setrecursionlimit(11451419)\nfrom decimal import Decimal #float\u306e\u9ad8\u7cbe\u5ea6ver, \u6e21\u3059\u306e\u306fstr\u578b\u3067\nfrom functools import lru_cache\n#\u30e1\u30e2\u5316\u518d\u5e30def\u306e\u5192\u982d\u306b\u6bce\u56de @lru_cache(maxsize=10**10)\n#\u5f15\u6570\u306blist\u306f\u3060\u3081\n#######\u3053\u3053\u307e\u3067\u30c6\u30f3\u30d7\u30ec#######\n#\u30bd\u30fc\u30c8\u3001\"a\"+\"b\"\u3001\u518d\u5e30\u306a\u3089Python3\u306e\u65b9\u304c\u3044\u3044\n#######\u3053\u3053\u304b\u3089\u5929\u3077\u3089########\nn,m=list(map(int,input().split()))\nA=100*(n-m)+1900*m\np=pow(2,m)\n\n@lru_cache(maxsize=10**10)\ndef per(n):\n if n==1:\n return 1/p\n return (1-sum([per(i) for i in range(1,n)]))*(1/p)\n\nans=0\nfor i in range(1,2000):\n ans+= i*A*per(i)\nprint((round(ans)))\n", "n,m=list(map(int,input().split()))\na=(n-m)*100+1900*m\nprint((a*(2**m)))\n", "N,M = map(int,input().split())\nprint((1900*M+(N-M)*100)*2**M)", "n,m=list(map(int,input().split()))\nsend=2**m\ntime = 1900*m + 100*(n-m)\nprint((send*time))\n", "n,m = map(int,input().split())\nprint(((1900*m+100*(n-m))*2**m))", "N,M=list(map(int,input().split()))\nprint(((100*(N-M)+1900*M)*2**M))\n", "N,M = map(int,input().split())\n\nprint(int((M*1900 + (N-M)*100) * 2**M))", "n, m = map(int,input().split())\n\nt = m * 1900 + (n-m) * 100\nprint(t*2**m)", "n,m = map(int,input().split())\nprint(((n-m)*100+m*1900)*2**m)", "n, m = map(int, input().split())\nprint((n*100 + m*1800) * (2 ** m))", "# 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())\n# S = input()\n# n, *a = map(int, open(0))\nN, 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)]\n# S = 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\n# \u8a3c\u660e\u3067\u304d\u3066\u3044\u306a\u3044\u304c\u30012**M * t \u3068\u306a\u308b\u6c17\u304c\u3059\u308b\u3002\n# (t \u306f1\u56de\u306e\u5b9f\u884c\u306b\u304b\u304b\u308b\u6642\u9593[ms])\nprint(2 ** M * (1800 * M + 100 * N))", "N,M=map(int,input().split())\ndef f(a,r,c):\n return (a/(1-r)+(a*r)/(1-r)**2)*c\n\na=1/2**M\nr=(2**M-1)/2**M\nc=1900*M+100*(N-M)\n\nprint(int(f(a,r,c)))", "n,m = map(int,input().split())\nprint((1900*m+100*(n-m))*2**m)", "n, m = map(int, input().split())\n\n# ((n - m) * 100 + m * 1900) * 2^m\n\nprint(((n-m) * 100 + m * 1900) * pow(2, m))", "N, M = map(int, input().split())\nprint(((N-M)*100+M*1900)*(2**M))", "n, m = map(int, input().split())\n\nt = 2**m\n\nprint((m * 1900 + (n-m) * 100) * t)", "N, M = map(int,input().split())\nprint(((N - M) * 100 + M * 1900)* 2 ** M)", "n,m=map(int,input().split())\nres=2**m\nans=1900*m+100*(n-m)\nprint(ans*res)", "N, M = map(int, input().split())\nA = 1900*M + 100*(N-M)\n#print(A)\n\nans = A * 2**M\n\nprint(ans)", "N,M=map(int,input().split())\nprint((M*1900+100*(N-M))*(2**M))", "N,M = map(int,input().split())\nyes = 100\nno = 1900\nans = 0\nfor i in range(1,2**M+1):\n ans += (i*((M*no)+(N-M)*yes))/(i<<1)\nprint(int(ans)*2)", "N,M = map(int,input().split())\nfixT1 = 100*(N-M)\nfixT2 = 1900*(M)\ntrynum = 2**M\nprint((fixT1+fixT2)*trynum)", "n, m = map(int, input().split())\nprint(2**m*(1800*m + 100*n))"]
{"inputs": ["1 1\n", "10 2\n", "100 5\n"], "outputs": ["3800\n", "18400\n", "608000\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
15,892
c8114ef076322b83b0c40b941d72e6f7
UNKNOWN
You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print None instead. -----Constraints----- - 1 \leq |S| \leq 10^5 (|S| is the length of string S.) - S consists of lowercase English letters. -----Input----- Input is given from Standard Input in the following format: S -----Output----- Print the lexicographically smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print None instead. -----Sample Input----- atcoderregularcontest -----Sample Output----- b The string atcoderregularcontest contains a, but does not contain b.
["S = input()\nalphabet = ['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\nfor a in alphabet:\n if a not in S:\n print(a)\n return\n \nprint('None')\n\n\n", "s = input()\nans = 'None'\nfor i in range(97, 123):\n if chr(i) not in s:\n ans = chr(i)\n break\nprint(ans)", "S = input()\nfor c in \"abcdefghijklmnopqrstuvwxyz\":\n if c not in S:\n print(c)\n break\nelse:\n print(\"None\")\n", "import string\n\nS = set(input())\n\nresult = ''\nfor i in string.ascii_lowercase:\n if i not in S:\n print(i)\n break\nelse:\n print('None')", "import sys\nimport copy\nimport math\nimport itertools\nimport numpy as np\nS = input()\nfor i in \"abcdefghijklmnopqrstuvwxyz\":\n if S.count(i) == 0:\n print(i)\n return\n\nprint(\"None\")", "S = input()\nl = sorted(list(set(S)))\n\nans = \"\"\nfor i in range(len(l)):\n if ord(l[i]) != 97 + i:\n ans = chr(97+i)\n break\n elif i == 25 and l[i] == \"z\":\n ans = \"None\"\n\nif ans != \"\":\n print(ans)\nelse:\n print(chr(ord(l[-1])+1))", "S = str(input())\ns = 'abcdefghijklmnopqrstuvwxyz'\n\nfor i in s:\n if i not in S:\n print(i)\n return\nprint('None')", "import sys\ns = input()\n\nfor i in range(97, 123):\n st = chr(i)\n if st not in s:\n print(st)\n return\n\n \nprint(None)", "import string\n\ns = list(map(str, input()))\ns = list(set(s))\ns.sort()\n\nans = \"\"\narr = []\n\nalp = list(map(str, string.ascii_lowercase))\nfor char in s:\n alp.remove(char)\n\nif len(alp) == 0:\n print(\"None\")\nelse:\n print((alp[0]))\n", "import string\ns = input()\nt = set(s) ^ set(string.ascii_lowercase)\n\nfor i in string.ascii_lowercase:\n if set(i) & t:\n print(i)\n break\nelse:\n print(\"None\")", "S = str(input())\nal = [chr(ord('a') + i) for i in range(26)]\ndata = []\nfor x in S:\n if not x in data:\n data.append(x)\nans = list(set(al) ^ set(data))\nans.sort()\nif len(ans) == 0:\n print('None') \nelse:\n print(ans[0])", "s = list(input())\ns.sort()\nli =[]\nlis = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,\n 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]\n\nfor i in s:\n li.append(ord(i))\ncnt = 0\nfor i in lis:\n if i in li:\n cnt += 1\n else:\n print((chr(i)))\n return\nprint('None')\n", "A = ['a','s','d','f','g','h','j','k','l','z','x','c','v','b','n','m','q','w','e','r','t','y','u','i','o','p']\nS = list(set(input()))\nfor i in S:\n A.remove(i)\nA.sort()\ntry:\n print((A[0]))\nexcept:\n print(\"None\")\n", "s = input()\n\nalphabets = 'abcdefghijklmnopqrstuvwxyz'\n\nfor i in range(len(alphabets)):\n if not alphabets[i] in s:\n print(alphabets[i])\n return\n\nprint('None')", "import sys\nS = list(input())\ns = list(set(S))\ns.sort()\nalfa = list('abcdefghijklmnopqrstuvwxyz')\nans = 0\nif(len(s)==len(alfa)):\n print('None')\n return\nelse:\n for i in range(len(s)):\n if(s[i]!=alfa[i]):\n print(alfa[i])\n return\n print(alfa[len(s)])", "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()\nfor char in 'abcdefghijklmnopqrstuvwxyz':\n if char not in s:\n print(char)\n return\nelse:\n print('None')\n\n\n\n\n\n\n\n\n\n\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\nimport string\n\ndef main():\n a = string.ascii_lowercase\n s = s_input()\n for i in a:\n if i not in s:\n print(i)\n return\n print(\"None\")\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s=input()\nfor i in range(ord(\"a\"),ord(\"z\")+1):\n if chr(i) not in s:\n print(chr(i)) \n return\nprint(\"None\")", "from collections import Counter\n\nS = list(input())\nac = Counter(S)\n\nalp = 'abcdefghijklmnopqrstuvwxyz'\n\nfor a in alp:\n if not(a in ac):\n print(a)\n break\nelse:\n print('None')\n", "# 35\nimport string\n\nS = str(input())\n\nset1 = set()\nfor s in S:\n set1.add(s)\n\nset2 = set()\nfor alf in string.ascii_lowercase:\n set2.add(alf)\n\nlist = sorted(set2 - set1)\nif not list: print('None')\nelse: print(sorted(list)[0])", "S = input()\nalphabets = ['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']\nans = []\nfor alpha in alphabets:\n if S.count(alpha) > 0 :\n ans.append(1)\n else:\n ans.append(0)\n\nif sum(ans) == 26:\n print('None')\nelse:\n print((alphabets[ans.index(0)]))\n", "s = list(map(str,input()))\nalp = \"abcdefghijklmnopqrstuvwxyz\"\ns = set(s)\nfor i in range(26):\n if alp[i] not in s:\n print(alp[i])\n return\n elif i == 25:\n print(\"None\")", "s = input()\n\nalphabets = 'abcdefghijklmnopqrstuvwxyz'\n\nfor x in alphabets:\n if x in s:\n continue\n else:\n print(x)\n break\nelse:\n print('None')", "s = input()\nans = 'None'\nline = [0 for i in range(26)]\nfor i in s:\n line[ord(i)-97] += 1\nfor j in range(26):\n if line[j] == 0:\n ans = chr(j + 97)\n break\nprint(ans)", "li = list(\"abcdefghijknmlopqrstuvwxyz\")\nS = list(input())\nans = \"None\"\nfor l in li:\n if not l in S:\n ans = l\n break\nprint(ans)", "s = input()\nal = \"abcdefghijklmnopqrstuvwxyz\"\nfor i in al:\n if i not in s:\n print(i)\n break\nelse:\n print(\"None\")", "s = set(input())\na = \"abcdefghijklmnopqrstuvwxyz\"\nfor si in s:\n a = a.replace(si,\"\")\nprint(None if a==\"\" else a[0])", "s = list(input())\nimport collections\nimport sys\na = collections.Counter(s)\n\nfor i in range(97,97+26):\n if chr(i) not in a:\n print(chr(i))\n return\nelse:\n print(\"None\")", "S = input()\n\nimport string\nlst = list(string.ascii_lowercase)\nd = {lst[i]:i for i in range(len(lst))}\ncnt = [0]*len(lst)\n\nfor ch in S:\n cnt[d[ch]] = 1\n \nidx = -1\nfor i in range(len(cnt)):\n if cnt[i] == 0:\n idx = i\n break\n\nif idx == -1:\n print(\"None\")\nelse:\n print((lst[idx]))\n", "d = {}\nfor s in input():\n if s in d:\n d[s] += 1\n else:\n d[s] = 1\n\nfor a in 'abcdefghijklmnopqrstuvwxyz':\n if a not in d:\n print(a)\n return\n\nprint('None')", "l = set(\"abcdefghijklmnopqrstuvwxyz\")\ns = set(input())\nans = sorted(list(l^s))\nprint(\"None\" if len(ans)==0 else ans[0])", "s = input()\ns = set(s)\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']\nfor i in range(len(data)):\n if data[i] not in s:\n print(data[i])\n break\nelse:\n print('None') ", "S=input()\n\nalph=\"abcdefghijklmnopqrstuvwxyz\"\n\nfor i in alph:\n if i in S:\n alph=alph.replace(i,\"\")\n\nif len(alph)==0:\n print(\"None\")\nelse:\n print(alph[0])", "A = [0 for i in range(26)]\nS = input()\nfor s in S:\n A[ord(s)-97] = 1\nflag = False\nfor i in range(26):\n if A[i]==0:\n flag = True\n break\nif flag:\n print(chr(97+i))\nelse:\n print(\"None\")", "import string\n\ns = input()\nfor x in string.ascii_lowercase:\n\tif x not in s:\n\t\tprint(x)\n\t\tbreak\nelse:\n\tprint('None')", "s=input()\nres=\"None\"\nfor i in range(ord(\"a\"),ord(\"z\")+1):\n if chr(i) not in s:\n res=chr(i)\n break\nprint(res)", "s = input()\ns = list(set(s))\ns = sorted(s)\nalf = [chr(i) for i in range(97,97+26)]\nfor i in range(26):\n if alf[i] not in s:\n print((alf[i]))\n return\n \nprint('None')\n", "s=input()\nf=1\nfor i in 'abcdefghijklmnopqrstuvwxyz':\n if i not in s:\n print(i)\n f=0\n return\nif f:print('None')", "S = list(input())\nA = list('abcdefghijklmnopqrstuvwxyz')\nans = 'None'\nfor a in A:\n if a not in S:\n ans = a\n break\nprint(ans)", "c = [chr(i) for i in range(97, 97+26)]\ns = input()\nans = 'None'\nfor i in c:\n if i not in s:\n ans = i\n break\nprint(ans)", "def main():\n s=input()\n for x in range(ord('a'), ord('z')+1):\n c=chr(x)\n if c in s:\n continue\n else:\n print(c)\n return\n print('None')\nmain()", "S = sorted(list(set(input())))\n\nalphabet = list('abcdefghijklmnopqrstuvwxyz')\n\nfor i in range(len(alphabet)):\n if alphabet[i] not in S:\n print(alphabet[i])\n return\n\nprint('None')", "S=input()\na=[0]*26\nfor i in range(len(S)):\n tmp=ord(S[i])-ord('a')\n a[tmp]=1\n \nfor i in range(26):\n if a[i]==0:\n tmp=chr(ord('a')+i)\n print(tmp)\n break\nelse:\n print('None')\n", "S = list(input())\n\nS.sort()\n\nif S[0] != 'a':\n print('a')\nelif S[0] == 'a':\n for i in range(len(S)-1):\n if ord(S[i+1]) - ord(S[i]) == 0 or ord(S[i+1]) - ord(S[i]) == 1:\n pass\n else:\n res = ord(S[i]) + 1\n print((chr(res)))\n return\n \n res = ord(S[-1]) + 1\n\n if S[0] == 'a' and S[-1] == 'z':\n print('None')\n elif S[0] != 'a':\n print('a')\n else:\n print((chr(res)))\n", "# -*- coding: utf-8 -*-\n\nS = set(input())\naz = [chr(i) for i in range(ord('a'),ord('z')+1)]\n\nif len(S) >= 26:\n print(\"None\")\n return\n\nfor i in az:\n if i in S:\n pass\n else:\n print(i)\n return\n\n\n\n", "s = str(input())\nL =['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 s:\n if i in L:\n L.remove(i)\nif L == []:\n print('None')\nelse:\n print(L[0])", "# -*- coding: utf-8 -*-\n\nS = sorted(set(list(input())))\n\nans = 'None'\nfor keyword in list(\"abcdefghijklmnopqrstuvwxyz\"):\n hit = False\n for s in S:\n if s == keyword:\n hit = True\n break \n \n if hit == False:\n ans = keyword\n break\n\nprint(ans)\n\n", "alphabet = [chr(i) for i in range(97, 123)]\nS = set(list(input()))\nfor s in S:\n if s in alphabet: alphabet.remove(s)\n \nprint(alphabet[0]) if alphabet else print(\"None\")", "#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\nimport bisect\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())\nans = \"abcdefghijklmnopqrstuvwxyz\"\ns = input()\ns = sorted(list(set(s)))\nfor v in ans:\n flag = True\n for j in range(len(s)):\n if s[j] == v:\n flag = False\n if flag:\n print(v)\n return\nprint(None)\n", "S = input()\n\nabc = ['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\n\nfrom collections import defaultdict\n\nd = defaultdict(int)\nfor s in S:\n d[s] = 1\n\nfor a in abc:\n if d[a] == 0:\n print(a)\n return\nprint('None')", "s = input()\nalphabets = [0] * 26\n\nfor i in s:\n alphabets[ord(i) - ord(\"a\")] += 1\n\nfor i in range(26):\n if alphabets[i] == 0:\n print((chr(i + ord(\"a\"))))\n break\nelse:\n print(\"None\")\n", "s = list(input())\nflag = [0] * 26\n\nfor i in range(len(s)):\n flag[ord(s[i]) - 97] = 1\n\nc = 0\nfor i in range(26):\n if flag[i] == 0:\n print(chr(i + 97))\n break\n else:\n c += 1\nif c == 26:\n print(\"None\")", "S = input()\nN = len(S)\nfor i in range(26):\n for k in range(N):\n if S[k] == chr(97+i):\n break\n else:\n print(chr(97+i))\n return\nprint('None')", "S = input()\nl = sorted(list(set(S)))\n\nans = \"\"\nfor i in range(len(l)):\n if ord(l[i]) != 97 + i:\n ans = chr(97+i)\n break\n elif i == 25 and l[i] == \"z\":\n ans = \"None\"\n\nif ans != \"\":\n print(ans)\nelse:\n print((chr(ord(l[-1])+1)))\n", "alpha=\"abcdefghijklmnopqrstuvwxyz\"\nS=input()\nfor i in range(len(alpha)) :\n if alpha[i] not in S :\n print(alpha[i])\n return\nprint(\"None\")", "a=input()\ns=[0]*26\nfor i in range(len(a)):\n s[ord(a[i])-97]=1\nif sum(s)==26:\n print(\"None\")\nelse:\n print(chr(s.index(min(s))+97))", "s = set(input())\n\nfor i in range(26):\n if chr(i + ord(\"a\")) not in s:\n print((chr(i + ord(\"a\"))))\n break\nelse:\n print(\"None\")\n", "S = list(input())\nS = list(set(S))\n\nans = \"None\"\nfor i in range(97, 123):\n cnt = chr(i)\n if not cnt in S:\n ans = cnt\n break\n \nprint(ans)", "alpha = list('abcdefghijklmnopqrstuvwxyz')\ns = input()\nfor i in alpha:\n if not i in s:\n print(i)\n return\nprint('None')", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n alpha_data={}\n S = input()\n [alpha_data.update({chr(i):0}) for i in range(97, 97+26)]\n \n for s in S:\n if s in alpha_data:\n tmp=alpha_data[s]\n tmp+=1\n alpha_data[s]=tmp\n else:\n continue\n for i,v in alpha_data.items():\n if v==0:\n print(i)\n return\n print(\"None\")\n\ndef __starting_point():\n main()\n__starting_point()", "S = str(input())\n\nno_ans = \"None\"\nans_list = []\narufabet = [\"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\nfor i in range(len(arufabet)):\n if arufabet[i] not in S:\n ans_list.append(arufabet[i])\n\nif len(ans_list) == 0:\n print(no_ans)\nelse:\n print((ans_list[0]))\n", "S = [s for s in input()]\nli = list(set(S))\nli.sort()\n\nans = 'None'\nfor c in [chr(c) for c in range(97, 123)]:\n if c not in li:\n ans = c\n break\nprint(ans)\n", "S=input()\nfor i in \"abcdefghijklmnopqrstuvwxyz\":\n if not i in S:\n print(i)\n break\nelse:\n print(\"None\")", "s = input()\nfor i in range(97, 123):\n if chr(i) not in s:\n print(chr(i))\n break\nelse: print(\"None\")", "s = input()\nalpha = [\"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\"]\nl = list(set(alpha) - set(s))\nl.sort()\nprint(l[0] if len(l) != 0 else \"None\")", "s = set(input())\nalp = 'abcdefghijklmnopqrstuvwxyz'\nfor a in alp:\n if a not in s:\n print(a)\n return\nprint('None')", "s = input()\ncnt = 0\nfor i in range(26):\n if chr(97 + i) in s:\n cnt += 1\n if cnt == 26:\n print(\"None\")\n break\n else:\n print(chr(97+i))\n break", "S = input()\n\na = [True for _ in range(26)]\n\nfor s in S:\n a[ord(s) - ord(\"a\")] = False\n\nfor i, aa in enumerate(a):\n if aa:\n print((chr(i + ord(\"a\"))))\n return\n\nprint(\"None\")\n", "s=input()\nalphabet='abcdefghijklmnopqrstuvwxyz'\nfor i in alphabet:\n if i not in s:\n print(i)\n return\nprint('None')", "S = list(input())\na = list(\"abcdefghijklmnopqrstuvwxyz\")\nfor i in S:\n if i in a:\n a.remove(i)\n\nif a:\n print(a[0])\nelse:\n print(\"None\")", "S = list(input())\nL = len(S)\nSlist = set()\nfor i in range(L):\n Slist.add(ord(S[i]))\nSlist = list(Slist)\nSlist.sort()\nans = \"None\"\nj = 0\nL = len(Slist)\nfor i in range(97, 123):\n if Slist[j] == i:\n j += 1\n if j >= L and i+1 < 123:\n ans = chr(i+1)\n break\n continue\n ans = chr(i)\n break\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 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())\ns = input()\nlis = \"abcdefghijklmnopqrstuvwxyz\"\nfor i in range(len(lis)):\n if lis[i] in s:\n pass\n else:\n print((lis[i]))\n return\nprint('None')\n", "S=input()\nT=\"abcdefghijklmnopqrstuvwxyz\"\n\nfor c in T:\n if S.count(c)==0:\n print(c)\n break;\nelse:\n print(\"None\")\n", "S = set(list(input()))\ncf = [chr(ord(\"a\")+i) for i in range(26)]\n\nfor i in range(len(cf)):\n if cf[i] not in S:\n print(cf[i])\n return\nprint(\"None\")", "import string\n\nall_string = set(string.ascii_lowercase)\nS = set(input())\n\nans = sorted(list(all_string - S))\n\nprint(ans[0]) if ans != [] else print(\"None\")", "from collections import Counter\nS = list(input())\nS = Counter(S)\nif len(S) == 26:\n ans = \"None\"\nelse:\n A = [chr(i) for i in range(97, 97+26)]\n for i in A:\n if i in S:\n continue\n ans = i\n break\nprint(ans)\n", "S=input()\nX=set([s for s in 'abcdefghijklmnopqrstuvwxyz'])\nfor s in S:\n X.discard(s)\nX=list(X)\nX.sort()\nX.append('None')\nprint(X[0])", "s = input()\nr = set(map(chr, range(97, 97+26)))\nr = r - set(s)\nif len(r) == 0:\n print('None')\nelse:\n r = min(r)\n print(r)", "alphabets = [chr(ord('a') + i) for i in range(26)]\n\nfor a in list(input()):\n if a in alphabets:\n alphabets.remove(a)\n\n\nif alphabets:\n print((alphabets[0]))\nelse:\n print(\"None\")\n", "from string import ascii_lowercase\n\n\ndef answer(s: str) -> str:\n not_in_s = list(set(ascii_lowercase) - set(s))\n if not not_in_s:\n return 'None'\n not_in_s.sort()\n\n return not_in_s[0]\n\n\ndef main():\n s = input()\n print(answer(s))\n\n\ndef __starting_point():\n main()\n__starting_point()", "import sys\nalphabet = \"abcdefghijklmnopqrstuvwxyz\"\ns = set(sorted(input().strip()))\nfor i in alphabet:\n if not i in s:\n print(i)\n return\nprint(\"None\")\n\n\n", "s = str(input())\n\nalp = set(\"abcdefghijklmnopqrstuvwxyz\")\ns = set(s)\n#print(s & alp)\n\nif len(s & alp)==26:\n ans = \"None\"\nelse:\n lis = list(alp-s)\n lis.sort()\n ans = lis[0]\n\nprint(ans)\n", "print(\"None\" if len(s:=(set(list(\"abcdefghijklmnopqrstuvwxyz\"))-set(input())))==0 else sorted(list(s))[0])", "s = input()\nd_l = [chr(i) for i in range(97, 97+26)]\nans = None\nfor d in d_l:\n if d not in list(s):\n ans = d\n break\nprint(ans)", "print(min(set(map(chr,range(97,123)))-set(input())or['None']))", "s = input()\nalpabet = [chr(x) for x in range(97,123)]\ntry:\n for a in alpabet:\n s.index(a)\n else:\n print(None)\nexcept ValueError as e:\n print(a)", "import re\ns = str(input())\nl = list('abcdefghijklmnopqrstuvwxyz')\n\nfor i in l:\n if not re.search(i,s):\n print(i)\n break\nelse:\n print('None')", "s = input()\nalphabet = \"abcdefghijklmnopqrstuvwxyz\"\n\nfor i in alphabet:\n if i in s:\n alphabet = alphabet.replace(i,\"\")\n\nif len(alphabet) == 0:\n print(\"None\")\nelse:\n print(alphabet[0])", "s = sorted(set(input()))\na = len(set(s))\ns.append(0)\nfor i in range(26):\n if s[i] != chr(97+i):\n print(chr(97+i))\n break\nelse:\n print('None')", "import string\nS = set(input())\nfor i in range(97, 123):\n s = chr(i)\n if s not in S:\n print(s)\n break\nelse:\n print(None)", "S = input()\nfor c in \"abcdefghijklmnopqrstuvwxyz\":\n if c not in S:\n print(c)\n break\nelse:\n print(\"None\")\n", "s = sorted(list(set(input())))\n\nfor i in range(26):\n if chr(ord(\"a\") + i) not in s:\n print(chr(ord(\"a\") + i))\n break\nelse:\n print(\"None\")", "s = input()\ns = list(s)\ns = set(s)\nl = [chr(ord(\"a\")+i) for i in range(26)]\nans = 'None'\nfor i in l:\n if i not in s:\n ans = i\n break\nprint(ans)", "s = input()\nalphabet = 'abcdefghijklmnopqrstuvwxyz'\n\nfor i in alphabet:\n if i not in s:\n print(i)\n return\nprint('None')", "# -*- coding:utf-8 -*-\nS = input()\n\nalpahbet = \"abcdefghijklmnopqrstuvwxyz\"\nstring_list = []\nans = \"None\"\nfor s in S:\n if s not in string_list:\n string_list.append(s)\n\nfor a in alpahbet:\n if a not in string_list:\n ans = a\n break\n\nprint(ans)", "s=input()\n\nfor i in \"abcdefghijklmnopqrstuvwxyz\":\n if i not in s:\n print(i)\n break\nelse:\n print(\"None\")", "S = list(input())\nalpha = 'abcdefghijklmnopqrstuvwxyz'\n\nfor a in alpha:\n if S.count(a) == 0:\n print(a)\n break\nelse:\n print(\"None\")", "s = input()\nc = \"a\"\nwhile c <= \"z\":\n if s.find(c) == -1:\n print(c)\n break\n if c == \"z\":\n print(\"None\")\n c = chr(ord(c) + 1)\n\n", "import string\nL = ['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']\nS = set(input())\nfor i in L:\n if i not in S:\n print(i)\n break\nelse:\n print(None)"]
{"inputs": ["atcoderregularcontest\n", "abcdefghijklmnopqrstuvwxyz\n", "fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg\n"], "outputs": ["b\n", "None\n", "d\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
23,711
634dad7463a35b130a23521d332d921a
UNKNOWN
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l. You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i. Find B_i for each i = 1, 2, ..., N. -----Constraints----- - 2 \leq N \leq 200000 - N is even. - 1 \leq X_i \leq 10^9 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N X_1 X_2 ... X_N -----Output----- Print N lines. The i-th line should contain B_i. -----Sample Input----- 4 2 4 4 3 -----Sample Output----- 4 3 3 4 - Since the median of X_2, X_3, X_4 is 4, B_1 = 4. - Since the median of X_1, X_3, X_4 is 3, B_2 = 3. - Since the median of X_1, X_2, X_4 is 3, B_3 = 3. - Since the median of X_1, X_2, X_3 is 4, B_4 = 4.
["n = int(input())\nx = list(map(int,input().split()))\n\ny = sorted(x)\n\nans1 = y[n//2]\nans2 = y[n//2-1]\n\nfor i in x :\n if i < ans1 :\n print(ans1)\n else :\n print(ans2)\n", "import bisect\nn=int(input())\nx=list(map(int,input().split()))\nm=n//2\ny=sorted(x)\nfor i in range(n):\n if bisect.bisect_right(y,x[i])>m:\n print(y[m-1])\n else:\n print(y[m])", "n = int(input())\nx = list(map(int, input().split()))\n\nfor i in range(n):\n x[i] = (x[i], i)\n\nx.sort()\n\nanswers = [x[n//2 - 1][0]] * n\n\nans = x[n//2][0]\nfor i in range(n//2):\n answers[x[i][1]] = ans\n\nfor i in answers:\n print(i)", "n=int(input())\nx=list(map(int,input().split()))\ny=sorted(x)\nt,w=y[n//2-1],y[n//2]\nfor i in range(n):\n if x[i]<w:\n print(w)\n else:\n print(t)", "n = int(input())\nx = list(map(int,input().split()))\ny = sorted(x)\n#m = y[n//2-1:n//2+1]\nm_index = n//2-1\nm = y[m_index]\n\nfor i in range(n):\n if x[i] <= m:\n print(y[m_index+1])\n else:\n print(y[m_index])", "n=int(input())\na=[int(i) for i in input().split()]\n\nb=a[:]\na.sort()\n\none=a[n//2-1]\ntwo=a[n//2]\n\ndef get_median(i):\n if b[i]<=one:\n return two\n return one\n\nfor i in range(n):\n\tprint(get_median(i))", "def main():\n n = int(input())\n x = [int(xn) for xn in input().split()]\n x_sorted = sorted(x)\n idx_median = n // 2\n median_low = x_sorted[idx_median - 1]\n median_high = x_sorted[idx_median]\n for xn in x:\n print((median_high if xn <= median_low else median_low))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n=int(input())\nx=list(map(int,input().split()))\ny=sorted(x)\nk,l=y[n//2-1],y[n//2]\nfor i in range(n):\n if x[i]<=k:\n print(l)\n else:\n print(k)", "N = int(input())\nXS = [int(i) for i in input().split()]\n\nsxs = sorted(XS)\na1 = sxs[N//2-1]\na2 = sxs[N//2]\n\nfor i in range(N):\n x = XS[i]\n if x <= a1:\n print(a2)\n else:\n print(a1)\n", "N = int(input())\nN_List = list(map(int,input().split()))\nN_List_Sorted = sorted(N_List)\nB = N_List_Sorted[N//2]\nA = N_List_Sorted[N//2 - 1]\n\nif A == B:\n for i in range(N):\n print(A)\nelse:\n for i in range(N):\n if N_List[i] <= A:\n print(B)\n else:\n print(A)\n\n\n\n", "n = int(input())\nx = list(map(int,input().split()))\nlis = sorted(x)\nkey1 = lis[n//2-1]\nkey2 = lis[n//2]\nfor i in x:\n if i > key1:\n print(key1)\n else:\n print(key2)\n", "import statistics\n\nn = int(input())\nx = list(map(int, input().split()))\nxmd = statistics.median(x)\nxs = sorted(x)\nfor i in x:\n if i < xmd:\n print((xs[n // 2]))\n else:\n print((xs[n // 2 - 1]))\n", "N = int(input())\nA = list(map(int, input().split()))\nAA = sorted(A)\nX = AA[N//2 - 1]\nY = AA[N//2]\nfor i in range(N):\n if A[i] < Y:\n print(Y)\n if A[i] >= Y:\n print(X)", "import numpy as np\n\nN = int(input())\nX = list(map(int, input().split()))\nY = sorted(X)\nx = np.median(X)\nindex = N // 2\nm1 = Y[index]\nm2 = Y[index - 1]\n\nfor i in range(N):\n if X[i] < x:\n print(m1)\n else:\n print(m2)\n", "import copy\n\nN = int(input())\nX = list(map(int, input().split()))\n\nx = copy.deepcopy(X)\nx.sort()\n\nx1 = x[N // 2 - 1]\nx2 = x[N // 2]\n\nfor xx in X:\n if xx <= x1:\n print(x2)\n else:\n print(x1)", "#51 C - Many Medians\nN = int(input())\nX = list(map(int,input().split()))\nXsrt = sorted(X,reverse = False)\nXL = set(Xsrt[:N//2])\nXR = set(Xsrt[N//2:])\n\nans = []\nfor x in X:\n if x in XR:\n ans.append(Xsrt[N//2-1])\n elif x in XL:\n ans.append(Xsrt[N//2])\nfor a in ans:\n print(a)", "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 import statistics\n n = i_input()\n l = i_list()\n ml = min(l)\n Ml = max(l)\n ol = statistics.median(l)\n\n L = l.copy()\n\n L.remove(ml)\n pol = statistics.median(L)\n L.append(ml)\n\n L.remove(Ml)\n mol = statistics.median(L)\n L.append(Ml)\n\n ans = []\n\n for i in l:\n if i >= ol:\n ans.append(mol)\n else:\n ans.append(pol)\n\n for i in ans:\n print(i)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nX_list = list(map(int, input().split()))\ntmp = X_list.copy()\n\ntmp.sort()\na = tmp[int(N/2)-1]\nb = tmp[int(N/2)]\nfor i in range(N):\n if(X_list[i] <= a):\n print(b)\n else:\n print(a)", "N = int(input())\nX = list(map(int,input().split()))\nx = sorted(X)\nms = x[N//2-1]\nfor i in range(N):\n if X[i] > ms:\n print(ms)\n else:\n print(x[N//2])", "n = int(input())\nX = list(map(int, input().split()))\n\nx = list(enumerate(X))\n\nx.sort(key=lambda x: x[1])\nA = list([x[1] for x in x[n//2-1:n//2+1]])\n\nfor v in X:\n if v <= A[0]:\n print((A[1]))\n else:\n print((A[0]))\n", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 22 14:57:09 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nX = [int(x) for x in input().split()]\nY = X.copy()\nY.sort()\nupper = Y[N//2]\nlower = Y[N//2-1]\n\nfor i in range(N):\n if X[i] < upper:\n print(upper)\n else:\n print(lower)", "n = int(input())\nx = list(map(int, input().split()))\ny = sorted(x)\na = y[n // 2 - 1]\nb = y[n // 2]\nfor i in x:\n print((a, b)[i <= a])", "n = int(input())\nX = list(map(int, input().split()))\nx = sorted(X)\n\nres1 = x[n//2]\nres2 = x[n//2 -1]\n\nfor i in range(n):\n if X[i] >= res1:\n print(res2)\n elif X[i] <= res2:\n print(res1)", "N=int(input())\n*X,=map(int,input().split())\ns=sorted(X)\n\nt1=s[N//2-1]\nt2=s[N//2]\n\nfor x in X:\n if x<=t1:\n print(t2)\n else:\n print(t1)", "n=int(input())\nx=list(map(int,input().split()))\nst=sorted(x)\na=st[len(st)//2-1]\nb=st[len(st)//2]\n\nfor i in x:\n if i<=a:\n print(b)\n else:\n print(a)\n", "N, *X = list(map(int, open(0).read().split()))\nsorted_X = sorted(X)\nmedian_l = sorted_X[N // 2 - 1]\nmedian_r = sorted_X[N // 2]\n\nfor x in X:\n if x < median_l:\n print(median_r)\n elif x == median_l:\n print(median_r)\n elif x == median_r:\n print(median_l)\n else:\n print(median_l)\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\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())\nn = I()\nX = readInts()\nnya = sorted(X)\nm1 = nya[n//2-1]\nm2 = nya[n//2]\nfor x in X:\n if x <= m1:\n print(m2)\n else:\n print(m1)\n", "import numpy\nN = int(input())\nX = [int(x) for x in input().split()]\nS = sorted(X)\nm0 = numpy.median(S[:-1])\nm1 = numpy.median(S[1:])\n\nfor x in X:\n if x < m1:\n print((int(m1)))\n else:\n print((int(m0)))\n\n", "N = int(input())\nX = list(map(int, input().split()))\nXs = sorted(X)\nc = int(N/2)\na, b = Xs[c-1], Xs[c]\nfor i in range(N):\n\tif X[i] <= a:\n\t\tprint(b)\n\telse:\n\t\tprint(a)", "n = int(input())\nX = list(map(int, input().split()))\ns = sorted(X)\n\nmed_low = s[n//2 - 1]\nmed_high = s[n//2]\n\nfor x in X:\n if x <= med_low: print(med_high)\n else: print(med_low)", "N = int(input())\nX = [int(i) for i in input().split()]\nXs = list(sorted(X))\nfor x in X:\n if x > Xs[N // 2 - 1]:\n print((Xs[N // 2 - 1]))\n else:\n print((Xs[N // 2]))\n", "n = int(input())\nx = list(map(int, input().split()))\nw = tuple(x)\nx.sort()\nif x[(n//2)-1] == x[n//2]:\n for i in range(n):\n print(x[n//2])\nelse:\n for h in w:\n if h <= x[(n//2)-1]:\n print(x[n//2])\n else:\n print(x[(n//2)-1])", "N = int(input())\nXls = list(map(int,input().split()))\nX2ls = sorted(Xls)\nM1 = X2ls[N//2-1]\nM2 = X2ls[N//2]\nlsans = []\nfor i in range(N):\n if Xls[i] <= M1:\n M = M2\n else:\n M = M1\n lsans.append(M)\nfor i in lsans:\n print(i)", "#!/usr/bin/env python\nimport sys \nimport copy\ninput = sys.stdin.readline\n\nn = int(input())\nx = list(map(int, input().split()))\nxx = sorted(x)\n\nl = xx[(n-1)//2]\nr = xx[n//2]\nmid = (l+r)/2\n\nfor i in range(n):\n if x[i] >= mid:\n print(l)\n else:\n print(r)\n", "a = int(input())\nb = list(map(int,input().split()))\n\nc = sorted(b, reverse=True)\n\nm = int(a / 2) - 1\nanslist = [0] * a\nfor i, data in enumerate(b):\n if c[m] > data:\n anslist[i] = c[m]\n elif c[m] <= data:\n anslist[i] = c[m + 1]\n \nfor j in range(a):\n print(anslist[j])", "n = int(input())\nx = list(map(int, input().split()))\nx_sort = sorted(x)\nhalf_l = x_sort[(n-1)//2]\nhalf_r = x_sort[(n)//2]\n\nfor i in range(n):\n if x[i] <= half_l:\n print(half_r)\n else:\n print(half_l)\n", "n = int(input())\nx = list(map(int,input().split()))\nxs = sorted(x)\nm = (xs[n//2]+xs[n//2-1])/2\nfor i in range(n):\n if x[i]<=m:\n print(xs[n//2])\n else:\n print(xs[n//2-1])", "N = int(input())\nX = list(map(int, input().split()))\nX_sorted = sorted(X)\npre_med_index = (N // 2) - 1\npos_med_index = N // 2\nimport bisect\n\nfor i in range(N):\n if X[i] <= X_sorted[pre_med_index]:\n print((X_sorted[pos_med_index]))\n else:\n print((X_sorted[pre_med_index]))\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 = ini()\n x = inl()\n y = sorted(x)\n\n p = y[n // 2 - 1]\n q = y[n // 2]\n\n for i in range(n):\n if x[i] < q:\n print(q)\n else:\n print(p)\n\n\nsolve()\n", "N=int(input())\nX=list(map(int,input().split()))\nA=sorted(X)\nfor i in range(N):\n if X[i]<=A[N//2-1]:\n print(A[N//2])\n else:\n print(A[N//2-1])", "from decimal import Decimal\n\nn = int(input())\nx = list(map(int, input().split()))\n\ny = x.copy()\n\ny.sort()\n\nm1 = y[n//2]\nm2 = y[n//2 - 1]\nm = Decimal(m1 + m2) / Decimal(2) \n#print(m1, m2)\n\nfor z in x:\n if z <= m:\n print(m1)\n else:\n print(m2)", "N = int(input())\nX = list(map(int,input().split()))\nY = sorted(X)\nA = Y[N//2]\nB = Y[N//2-1]\nfor i in range(N):\n if X[i] <= B:\n print(A)\n else:\n print(B)", "n = int(input())\nx = list(map(int,input().split()))\n\nx_sort = sorted(x)\nlenth = len(x)\nlow = x_sort[int(lenth/2)-1]\nhigh = x_sort[int(lenth/2)]\n\nfor y in x:\n if y <= low:\n print(high)\n else:\n print(low)", "n = int(input())\nx = list(map(int,input().split()))\ny = x.copy()\ny.sort()\nz = set(x)\nt1 = y[n//2-1]\nt2 = y[n//2]\nidx = dict([])\nidx[y[0]] = 0\nl = y[0]\ncnt = 0\nfor i in y:\n if i == l:\n cnt += 1\n continue\n else:\n idx[i] = cnt\n l = i\n cnt += 1\n\nfor i in x:\n t = idx[i]\n if t<n//2:\n print(t2)\n else:\n print(t1)", "n=int(input())\nxlist=list(map(int,input().split()))\n\ntmpx=sorted(xlist)\nmed1,med2 = tmpx[n//2-1],tmpx[n//2]\n# print(x)\n# print(med1,med2)\n\nfor x in xlist:\n if x<=med1:\n print(med2)\n else:\n print(med1)\n\n", "import statistics\nn=int(input())\nx=list(map(int,input().split()))\ny=statistics.median(x)\nxs=sorted(x)\nfor i in x:\n if i<y:\n print((xs[n//2]))\n else:\n print((xs[n//2-1]))\n \n", "N=int(input())\n*X,=map(int,input().split())\ns=sorted(X)\n \nt1=s[N//2-1]\nt2=s[N//2]\n \nfor x in X:\n if x<=t1:\n print(t2)\n else:\n print(t1)", "import copy\nn = int(input())\na = [int(x) for x in input().split()]\nb = copy.copy(a)\nb.sort()\nm = (b[n//2] + b[n//2 - 1]) // 2\nfor i in range(n):\n if m < a[i]:\n print((b[n//2 - 1]))\n else:\n print((b[n//2]))\n", "N=int(input())\nX=list(map(int,input().split()))\nimport copy\nY=copy.copy(X)\nY.sort()\n\nif Y[N//2]==Y[N//2-1]:\n for i in range(N):\n print((Y[N//2]))\nelse:\n for i in range(N):\n if X[i]<=Y[N//2-1]:\n print((Y[N//2]))\n else:\n print((Y[N//2-1]))\n", "N = int(input())\nX = list(map(int, input().split()))\norg = X.copy()\n\nX.sort()\n\nright = int(N // 2)\nleft = right - 1\n\nmed = (X[left] + X[right]) / 2\n\nfor x in org:\n if x >= med:\n print((X[left]))\n else:\n print((X[right]))\n", "n=int(input())\nx=list(map(int,input().split()))\nans=sorted(x)\nans2=ans[n//2-1]\nans1=ans[n//2]\n\nfor i in range(n):\n if x[i]>=ans[n//2]:\n print(ans2)\n else:\n print(ans1)\n", "N = int(input())\nX = list(map(int, input().split()))\nmed1 = sorted(X)[N // 2 - 1]\nmed2 = sorted(X)[N // 2]\nfor i in range(N):\n tmp = X[i]\n if tmp <= med1:\n print(med2)\n else:\n print(med1)\n", "import numpy as np\n\nN = int(input())\nxl = [int(x) for x in input().split()]\n\nxlsorted = np.sort(xl)\nm1 = xlsorted[int(N/2)-1]\nm2 = xlsorted[int(N/2)]\n\nfor i in range(N):\n if xl[i] <= m1:\n print(m2)\n else:\n print(m1)\n", "N = int(input())\na = list(map(int,input().split()))\ns = list(sorted(a))\nind = {}\nfor i in range(N):\n if s[i] not in ind:\n ind[s[i]] = i\nfor i in range(N):\n if ind[a[i]] < N//2:\n print(s[N//2])\n else:\n print(s[N//2-1])", "n = int(input())\nx = list(map(int,input().split()))\nx_2 = sorted(x)\nm_1 = x_2[n//2-1]\nm_2 = x_2[n//2]\nfor i in range(n):\n if x[i] <= m_1:\n print(m_2)\n elif x[i] >= m_2:\n print(m_1)\n\n", "n = int(input())\nx = list(map(int,input().split()))\nl = sorted(x)\nans_1 = l[n//2 - 1]\nans_2 = l[n//2]\nfor i in x:\n if i <= ans_1:\n print(ans_2)\n else:\n print(ans_1)\n", "import bisect\n\nn = int(input())\nX = list(map(int, input().split()))\n\nsorted_x = sorted(X)\n\nl, r = sorted_x[n//2], sorted_x[n//2-1]\n\nfor x in X:\n if bisect.bisect_left(sorted_x, x) < n // 2:\n print(l)\n else:\n print(r)", "def getval():\n n = int(input())\n x = list(map(int,input().split()))\n return n,x \n\ndef main(n,x):\n y = sorted(x)\n a,b = y[(n-1)//2],y[(n-1)//2+1]\n for i in x:\n if i>a:\n print(a)\n else:\n print(b)\n\ndef __starting_point():\n n,x = getval()\n main(n,x)\n__starting_point()", "N = int(input())\nX = list(map(int,input().split()))\nY = sorted(X)\n\nm1=Y[N//2-1]\nm2=Y[N//2]\n\nmedians = [m2 if x < m2 else m1 for x in X]\nprint('\\n'.join(map(str,medians)))", "import math\nimport statistics\n\nn = int(input())\nxL = list(map(int, input().split(\" \")))\n\nxL2 = []\nfor i in range(n):\n xL2.append([i, xL[i]])\nxL2 = sorted(xL2, key=lambda x: x[1])\n\nif n % 2 == 0:\n center = n // 2\n centers = [xL2[center - 1], xL2[center]]\n for i in range(n):\n if i == centers[0][0] or i == centers[1][0]:\n print(statistics.median(xL[:i] + xL[i + 1:]))\n else:\n if centers[0][1] < xL[i]:\n print(centers[0][1])\n else:\n print(centers[1][1])\nelse:\n center = n // 2\n centers = [xL2[center - 1], xL2[center], xL2[center + 1]]\n for i in range(n):\n if i == centers[0][0] or i == centers[1][0] or i == centers[2][0]:\n print(statistics.median(xL[:i] + xL[i + 1:]))\n else:\n if centers[0][1] < xL[i]:\n print((centers[0][1] + centers[1][1]) / 2)\n else:\n print((centers[1][1] + centers[2][1]) / 2)", "n = int(input())\nx = list(map(int, input().split()))\nx2 = sorted(x)\nmid = n//2-1\nfor i in range(n):\n xi = x[i]\n if x2[mid] < xi:\n print((x2[mid]))\n else:\n print((x2[mid+1]))\n", "def main():\n n = int(input())\n x_lst = list(map(int, input().split()))\n x_sorted_lst = sorted(x_lst)\n\n median1 = x_sorted_lst[n // 2 - 1]\n median2 = x_sorted_lst[n // 2]\n\n if median1 == median2:\n lst = [median1] * n\n\n else:\n lst = []\n for i in range(n):\n x = x_lst[i]\n\n if x <= median1:\n lst.append(median2)\n elif median2 <= x:\n lst.append(median1)\n\n for i in range(n):\n print(lst[i])\n\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\nx = list(map(int, input().split()))\n\nnums = sorted(x)\nm1 = n//2-1\nm2 = n//2\nfor i in range(n):\n if x[i] <= nums[m1]: print(nums[m2])\n elif nums[m2] <= x[i]: print(nums[m1])", "import copy\n\ndef main():\n\tN = int(input())\n\tX = [int(x) for x in input().split(\" \")]\n\tsortedX = copy.deepcopy(X)\n\tsortedX.sort()\n\tcand = [sortedX[int(N / 2) - 1], sortedX[int(N / 2)]]\n\n\tfor xi in X:\n\t\tif xi <= cand[0]:\n\t\t\tprint((cand[1]))\n\t\telse:\n\t\t\tprint((cand[0]))\n\nmain()\n", "N = int(input())\nx = list(map(int, input().split()))\na = sorted(x)\np = int(N/2)-1\nl = a[p]\nfor i in range(N):\n n = p\n if x[i] <= l:\n n = p+1\n print(a[n])", "N = int(input())\nX = list(map(int,input().split()))\nY = sorted(X)\nmed = (Y[N//2] + Y[N//2-1])/2\nfor i in range(N):\n if X[i] <= med:\n print(Y[N//2])\n else:\n print(Y[N//2-1])", "import copy\nn = int(input())\nx = list(map(int,input().split()))\na = copy.deepcopy(x)\nx.sort()\nfor i in range(n):\n if x[int(n/2)-1]<a[i]:\n print((x[int(n/2)-1]))\n else:\n print((x[int(n/2)]))\n", "def main():\n N = int(input())\n X = list(map(int, input().split()))\n Y = X.copy()\n Y.sort()\n\n if N%2 == 0:\n mid1 = Y[N//2]\n mid2 = Y[N//2-1]\n for x in X:\n if x <= mid2:\n print(mid1)\n else:\n print(mid2)\n return\n\ndef __starting_point():\n main()\n\n__starting_point()", "# 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\nimport copy\n\nN = int(input())\n# S = input()\n# n, *a = map(int, open(0))\n# N, M = map(int, input().split())\nX = 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)]\n# S = 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\nX = [[i, x] for i, x in enumerate(X)]\nX = sorted(X, reverse=False, key=lambda x:x[1])\nX_ranked = copy.copy(X)\nX = [[l[0], i, l[1]] for i, l in enumerate(X)]\nX = sorted(X, reverse=False, key=lambda x:x[0])\n\nmed = len(X) // 2\n\nfor l in X:\n if l[1] < med:\n print((X_ranked[med][1]))\n else:\n print((X_ranked[med - 1][1]))\n", "n = int(input())\nx = list(map(int, input().split()))\ny = sorted(x)\n\nm = n // 2\np = y[m - 1]\nq = y[m]\nfor i in range(n):\n if p < x[i]:\n print(p)\n else:\n print(q)", "N = int(input())\nX = list(map(int,input().split()))\nsort_X = sorted(X)\n\nmid_ls = [sort_X[N//2-1],sort_X[N//2]]\n\nfor i in range(N):\n if X[i] >= mid_ls[1]:\n print(mid_ls[0])\n else:\n print(mid_ls[1])", "import copy\nN = int(input())\nX = list(map(int, input().split()))\nXsort = copy.copy(X)\nXsort.sort()\ncenterR = Xsort[N//2]\ncenterL = Xsort[N//2-1]\nfor i in range(N):\n if X[i] >= centerR:\n print(centerL)\n else:\n print(centerR)\n", "n = int(input())\nx = list(map(int, input().split()))\nx2 = sorted(x)\n\na = x2[n//2 - 1]\nb = x2[n//2]\n\nfor i in range(n):\n if x[i] <= a:\n print(b)\n else:\n print(a)", "#!/usr/bin/env python3\n\nimport numpy as np\n\n\nn = int(input())\nx = list(map(int, input().split()))\n\nmedian = np.median(x)\nx_sorted = sorted(x)\n\nindex = len(x)//2-1\n\nfor i in x:\n if i == median:\n print(i)\n elif i < median:\n print((x_sorted[index+1]))\n else:\n print((x_sorted[index]))\n", "N=int(input())\nX=list(map(int,input().strip().split()))\n\nY=sorted(X)\na=Y[N//2-1]\nb=Y[N//2]\nfor n in range(N):\n if X[n]<=a:\n print(b)\n else:\n print(a)", "N=int(input())\nX=list(map(int,input().split()))\nA=sorted(X)\nfor i in range(N):\n if X[i]<=A[N//2-1]:\n print((A[N//2]))\n else:\n print((A[N//2-1]))\n", "n=int(input())\nx=list(map(int,input().split()))\ny=sorted(x)\nk,l=y[n//2-1],y[n//2]\nfor i in range(n):\n if x[i]<=k:\n print(l)\n else:\n print(k)", "from copy import copy\nn, *x = list(map(int, open(0).read().split()))\na = []\nfor i, v in enumerate(x):\n a.append((v, i))\na.sort()\n\n# a[(i - 1)/ /2] , a[i // 2]\nans = [0] * n\nfor i in range(n):\n if i <= (n - 1) // 2:\n ans[a[i][1]] = a[n // 2][0]\n else:\n ans[a[i][1]] = a[(n - 1) // 2][0]\nfor y in ans:\n print(y)\n", "N = int(input())\nList = list(map(int,input().split()))\nA = sorted(List)\n\np,q=A[N//2-1:N//2+1]\n\nfor i in List:\n print(p if i>=q else q)", "import copy\nN = int(input())\nX = list(map(int, input().split()))\ntmp_X = copy.deepcopy(X)\ntmp_X.sort()\nm1 = tmp_X[N // 2]\nm2 = tmp_X[N // 2 - 1]\nfor x in X:\n if x < m1:\n print(m1)\n else:\n print(m2)", "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\")\n\nn = k()\nx = l()\np=sorted(x)\nmid = len(p)//2\nfor i in x:\n a = bisect.bisect(p,i)\n if a <= mid:\n print((p[mid]))\n else:\n print((p[mid-1]))\n", "'''\nCreated on 2020/08/29\n\n@author: harurun\n'''\ndef main():\n import copy\n import sys\n pin=sys.stdin.readline\n pout=sys.stdout.write\n perr=sys.stderr.write\n \n N=int(pin())\n X=list(map(int,pin().split()))\n t=(N+1)//2\n Y=sorted(X)\n ans1=Y[t-1]\n ans2=Y[t]\n median=ans1+ans2\n for i in range(N):\n s=X[i]\n if s==ans1:\n print(ans2)\n elif s==ans2:\n print(ans1)\n elif 2*s<median:\n print(ans2)\n elif 2*s>median:\n print(ans1)\n return \n\nmain()", "n = int(input())\nX = list(map(int, input().split()))\n\nsorted_x = sorted(X)\n\nl, r = sorted_x[n//2-1], sorted_x[n//2]\n\nfor x in X:\n if x < r:\n print(r)\n else:\n print(l)", "n = int(input())\nx = list(map(int, input().split()))\n\ny = sorted(x)\na = y[len(x)//2]\nb = y[(len(x)//2) - 1]\n\nfor i in range(n):\n if x[i] <= b:\n print(a)\n else:\n print(b)\n", "import statistics\nn = int(input())\nX = list(map(int, input().split()))\nX_ = sorted(X)\nmed = X_[n//2-1]\nmed_2 = X_[n//2]\nfor i in range(n):\n if X[i]>med:\n print(med)\n else:\n print(med_2)", "n = int(input())\nxn = list(map(int, input().split()))\nxn_s = sorted(xn)\nm1 = xn_s[n//2 - 1]\nm2 = xn_s[n//2]\nfor x in xn:\n if x <= m1:\n print(m2)\n else:\n print(m1)", "n = int(input())\nx = list(map(int, input().split()))\ny = sorted(x)\na = y[n // 2 - 1]\nb = y[n // 2]\nfor i in x:\n print((a, b)[i <= a])", "N = int(input())\nX = list(map(int,input().split()))\na = sorted(X)[N//2-1]\nb = sorted(X)[N//2]\n\nif a == b:\n for _ in range(N):\n print(a)\nelse:\n for i in range(N):\n if X[i] <= a:\n print(b)\n else:\n print(a)", "#!/usr/bin/env python3\n\ndef main():\n n = int(input())\n x = list(map(int, input().split()))\n ans = [0] * n\n x_sort = sorted(x)\n a = x_sort[1:n]\n a_med = a[n // 2 - 1]\n b = x_sort[0:n - 1]\n b_med = b[n // 2 - 1]\n for i in range(n):\n if x[i] < a_med:\n ans[i] = a_med\n else:\n ans[i] = b_med\n\n print(*ans, sep='\\n')\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "from copy import *\n\nN=int(input())\nX=list(map(int,input().split()))\nY=deepcopy(X)\nY.sort()\nmid1=Y[N//2-1]\nmid2=Y[N//2]\nfor i in range(N):\n if X[i]<=mid1:\n print(mid2)\n else:\n print(mid1)\n", "n=int(input())\nx=list(map(int,input().split()))\nfor i in range(n):\n x[i] = [x[i], i]\nx.sort(key=lambda x:x[0])\nfor i in range(n):\n if i < n//2:\n x[i] += [x[n//2][0]]\n else:\n x[i] += [x[n//2-1][0]]\n# x[i] = [value, init_index, b_i]\nx.sort(key=lambda x:x[1])\nfor i in range(n):\n print(x[i][2])", "n = int(input())\nxx = list(map(int, input().split()))\nyy = sorted(xx)\n\na = yy[n//2-1]\nb = yy[n//2]\n\nfor x in xx:\n if x <= a:\n print(b)\n elif x >= b:\n print(a)", "n = int(input())\n\nx = list(map(int, input().split()))\nx_sorted = sorted(x)\nmed_low = x_sorted[(n // 2) - 1]\nmed_upper = x_sorted[(n // 2)]\n\nfor i in range(n):\n if x[i] <= med_low:\n print(med_upper)\n else:\n print(med_low)\n", "import sys\nimport math\n\n\ninint = lambda: int(sys.stdin.readline())\ninintm = lambda: list(map(int, sys.stdin.readline().split()))\ninintl = lambda: list(inintm())\ninstrm = lambda: list(map(str, sys.stdin.readline().split()))\ninstrl = lambda: list(instrm())\n\n\nn = inint()\nX = inintl()\n\nX_sorted = sorted(X)\n\na, b = X_sorted[n//2-1],X_sorted[n//2]\n\nfor x in X:\n if x <= a:\n print(b)\n else:\n print(a)\n", "n = int(input())\nlst = list(map(int, input().split()))\n\nsorted_lst = sorted(lst)\nmini = sorted_lst[(n//2)-1]\nmaxi = sorted_lst[(n//2)]\nfor i in lst:\n if i <= mini:\n print(maxi)\n else:\n print(mini)", "n = int(input())\nl = list(map(int,input().split()))\nsorted_list = sorted(l)\nleft = sorted_list[n//2-1]\nright = sorted_list[n//2]\nfor i in l:\n if i <= left:\n print(right)\n else:\n print(left)", "n = int(input())\nx = list(map(int,input().split()))\ny = sorted(x)\nindex = n//2\n\nfor i in range(n):\n print(y[-index] if x[i]<y[index] else y[-index-1])", "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 main():\n n = ni()\n X = nl()\n X_s = sorted(X)\n mid = X_s[n // 2]\n del_mid = (X_s[:n // 2] + X_s[n // 2 + 1:])[(n - 1) // 2]\n for x in X:\n if x < mid:\n print(mid)\n elif x > mid:\n print((X_s[n // 2 - 1]))\n else:\n print(del_mid)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nX = list(map(int, input().split()))\nx = sorted(X)\nl = x[n//2-1]\nr = x[n//2]\nfor i in range(n):\n if X[i] <= l:\n print(r)\n else:\n print(l)\n"]
{"inputs": ["4\n2 4 4 3\n", "2\n1 2\n", "6\n5 5 4 4 3 3\n"], "outputs": ["4\n3\n3\n4\n", "2\n1\n", "4\n4\n4\n4\n4\n4\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
30,271
3dd08c0f784c132a07722506913faea8
UNKNOWN
We have N sticks with negligible thickness. The length of the i-th stick is A_i. Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle. -----Constraints----- - 4 \leq N \leq 10^5 - 1 \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 maximum possible area of the rectangle. If no rectangle can be formed, print 0. -----Sample Input----- 6 3 1 2 4 2 1 -----Sample Output----- 2 1 \times 2 rectangle can be formed.
["n=int(input())\na=[int(i) for i in input().split()]\n\n\na.sort()\n\ncount=0\n\n\ndef get_num(a):\n count=1\n taishou = a.pop()\n while a!=[]:\n second=a.pop()\n if taishou==second:\n count+=1\n else:\n a.append(second)\n break\n if count==1:\n return taishou,0\n elif count==2 or count==3:\n return taishou,1\n else:\n return taishou,2\n\none=0\ntwo=0\n\n\nwhile a!=[] and (one==0 or two==0):\n hen,length=get_num(a)\n if length==1:\n if one==0:\n one=hen\n else:\n two=hen\n elif length==2:\n if one==0:\n one=hen\n two=hen\n else:\n two=hen\n\nprint((one*two))\n\n", "N = int(input())\ndata = list(map(int, input().split()))\ndata.sort()\nans = []\nN -= 1\nwhile N > 0:\n if data[N] == data[N - 1]:\n ans.append(data[N])\n N -= 1\n N -= 1\n if len(ans) >= 2:\n break\n\nif len(ans) < 2:\n print((0))\nelse:\n print((ans[0] * ans[1]))\n\n", "n = int(input())\na = list(map(int, input().split()))\nfrom collections import Counter\na = Counter(a)\nlis = []\n \nfor i,j in a.items():\n lis += [i]*(j//2)\n \n#print(lis)\n \nlis.sort(reverse=True)\nif len(lis) <= 1:\n ans = 0\nelse:\n ans = lis[0]*lis[1]\n \nprint(ans)", "from collections import Counter\n\nn = int(input())\na = Counter(map(int, input().split()))\nxy = []\na = sorted(a.items(), key=lambda x: x[0], reverse=True)\nfor i in a:\n if len(xy) == 2:\n break\n if i[1] >= 4:\n xy.append(i[0])\n xy.append(i[0])\n break\n if i[1] >= 2:\n xy.append(i[0])\n\n else:\n pass\nprint(xy[0] * xy[1]) if len(xy) >= 2 else print(0)", "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = []\nfor k, v in a.items():\n b.extend([k] * (v // 2))\nelse:\n if 2 <= len(b):\n b.sort()\n print(b[-1] * b[-2])\n else:\n print(0)", "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = []\nfor k, v in a.items():\n for _ in range(v // 2):\n b.append(k)\nelse:\n if 2 <= len(b):\n b.sort()\n print(b[-1] * b[-2])\n else:\n print(0)", "from collections import Counter\nn=int(input())\na=list(map(int,input().split()))\n\nc=Counter(a)\ncan_make=[i[0] for i in c.items() if i[1]>=2]\ncan_make_square=[i[0] for i in c.items() if i[1]>=4]\ncan_make+=can_make_square\ncan_make.sort()\n\nif len(can_make)<2:\n print(0)\nelse:\n print(can_make[-1]*can_make[-2])", "n = int(input())\nA = list(map(int, input().split()))\nd = {0:4}\nfor a in A:\n d[a] = d.get(a, 0)+1\nlongest = 0\nfor i in d:\n if d[i]>=2:\n longest = max(longest, i)\nd[longest]-=2\n\nlongest_2nd = 0\nfor i in d:\n if d[i]>=2:\n longest_2nd = max(longest_2nd, i)\nprint(longest*longest_2nd)", "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = [0, 0]\nfor k, v in a.items():\n b.extend([k] * (v // 2))\nelse:\n b.sort()\n print(b[-1] * b[-2])", "n = int(input())\na = list(map(int,input().split()))\ndic = {}\nfor i in range(n):\n dic.setdefault(a[i],0)\n dic[a[i]] += 1\nans = []\nfor item in list(dic.items()):\n if item[1]>=2:\n ans.append(item[0])\nif len(ans)<=1:\n print((0))\nelse:\n ans.sort()\n if dic[ans[-1]]>=4:\n print((ans[-1]**2))\n else:\n print((ans[-1]*ans[-2]))\n", "N = int(input())\nA = sorted(list(map(int,input().split())))[::-1]\n\nfor n in range(N-1):\n if A[n]==A[n+1]:\n A[n+1]=0\n else:\n A[n]=0\n\nA = sorted(A)[::-1]\nprint(A[0]*A[1])", "import sys\nfrom collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nbox,box2,ans = [],[],0\nacnt = dict(Counter(a))\nacnt = sorted(acnt.items(), key=lambda x:x[0],reverse=True)\na_val = [acnt[x][1] for x in range(len(acnt))]\na_key = [acnt[y][0] for y in range(len(acnt))]\nfor i in range(len(a_val)):\n\tif a_val[i] >= 4:\n\t\tbox2.append(a_key[i]**2)\n\tif 2 <= a_val[i]:\n\t\tbox.append(a_key[i])\nbox.sort(reverse=True)\nif len(box2) >= 2:\t\n\tans = max(box2)\nif len(box) >= 2:\n print(max(ans,(box[0]*box[1])))\n return\nprint(0)", "import collections\nn=int(input())\na=list(map(int,input().split()))\nc = collections.Counter(a)\nb=[0,0]\nd=[0,0]\nfor i in c:\n if c[i]>=4:\n b.append(i)\n elif c[i]>=2:\n d.append(i)\nb.sort(reverse=True)\nd.sort(reverse=True)\nif b[0]>d[0]:\n print((b[0]*b[0]))\nelif b[0]<d[1]:\n print((d[0]*d[1]))\nelse:\n print((b[0]*d[0]))\n", "import sys\n\nN = int(input())\nA = list(map(int, input().split()))\n\nd = {}\na = []\nfor i in A:\n if i in d:\n d[i] += 1\n if d[i] == 2:\n a.append(i)\n d[i] = 0\n else:\n d[i] = 1\n\na.sort()\nif len(a) < 2:\n print(0)\nelse:\n print(a[-1]*a[-2])", "from collections import Counter as C\n\n_ = input()\na = C(map(int, input().split()))\n\nb = []\nfor k, v in a.items():\n b.extend([k] * (v // 2))\nelse:\n if 2 <= len(b):\n b.sort()\n print(b[-1] * b[-2])\n else:\n print(0)", "from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\ncounter = dict(Counter(A))\nfour = []\ntow = []\nfor key in counter.keys():\n if counter[key] >= 4:\n four.append(key)\n tow.append(key)\n elif counter[key]>=2:\n tow.append(key)\n\nif len(four) == 0 and len(tow) <= 1:\n print(0)\nelse:\n ans = 0\n four.sort(reverse=True)\n tow.sort(reverse=True)\n if len(four) >= 1:\n ans = max(ans, four[0]**2)\n if len(tow) >= 2:\n ans = max(ans, tow[1] * tow[0])\n print(ans)", "from collections import Counter\n\ninput()\nd = Counter(map(int, input().split()))\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n if j >= 4:\n ans.append(i)\n if j >= 2:\n ans.append(i)\nif len(ans) >= 2:\n print(ans[0] * ans[1])\nelse:\n print(0)", "import collections\nN=int(input())\nL=list(map(int,input().split()))\nc = collections.Counter(L)\nA=list(c.keys())\nB=list(c.values())\nR=list()\nfor i in range(len(A)):\n if B[i]>=2:\n R.append([A[i],B[i]])\nR=sorted(R,reverse=True)\nif len(R)==0:\n print(0)\n return\nif R[0][1]>=4:\n print(R[0][0]**2)\nelif len(R)<2:\n print(0)\nelse:\n print(R[0][0]*R[1][0])", "N=int(input())\nA=sorted(list(map(int,input().split())))\nl=[]\ns=set()\nfor i in range(N):\n if A[N-i-1] in s:\n l.append(A[N-i-1])\n s.discard(A[N-i-1])\n else:\n s.add(A[N-i-1])\nl.sort()\nprint(0 if len(l)<2 else l[-1]*l[-2])", "from collections import Counter\nn=int(input())\nc=Counter(list(map(int, input().split())))\nl=list()\nfor k,v in c.items():\n for _ in range(v//2):\n l.append(k)\n\nl.sort()\nl.reverse()\nif len(l)>=2:\n print(l[0]*l[1])\nelse:\n print(0)", "n = int(input())\na=list(map(int,input().split()))\n\na.sort(reverse = True)\nans = 0\nb = a.copy()\nb = list(set(b))\nb.sort(reverse = True)\nc = [0]*len(b)\nj = 0\nc[j] = 1\nfor i in range(1,n):\n if a[i-1] == a[i]:\n c[j] +=1\n else:\n j+=1\n c[j] +=1\nfor i in range(len(b)):\n if c[i] >= 4: \n \n ans = b[i]*b[i]\n break\n elif c[i] >= 2:\n for j in range(i+1,len(b)):\n if c[j] >= 2:\n ans = b[i]*b[j]\n break\n break\nprint(ans)", "n = int(input())\nA = tuple(map(int, input().split()))\nA = sorted(A, reverse=True)\nfrom collections import Counter\nCA = Counter(A)\n\nb = 0\nfor a in A:\n if CA[a] >= 2:\n CA[a] -= 2\n b = a\n break\n\nc = 0\nfor a in A:\n if CA[a] >=2:\n c = a\n break\nprint((b*c))\n", "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = [0] * 2\nfor k, v in a.items():\n if 4 <= v:\n b.append(k)\n if 2 <= v:\n b.append(k)\nelse:\n b.sort()\n print(b[-1] * b[-2])", "import collections\nN = int(input())\nlsA = list(map(int,input().split()))\ncounterA = collections.Counter(lsA)\nlsline = []\nfor i in counterA.keys():\n if counterA[i] >= 2:\n lsline.append(i)\nlsline.sort(reverse=True)\nif bool(lsline):\n if counterA[lsline[0]] >= 4:\n ans = lsline[0]*lsline[0]\n elif len(lsline) < 2:\n ans = 0\n else:\n ans = lsline[0]*lsline[1]\nelse:\n ans = 0\nprint(ans)", "N = int(input())\nA = list(map(int,input().split()))\n\ncount = {}\nrect = {}\nfor i in range(N):\n if A[i] in rect:\n rect[A[i]] += 1\n elif A[i] in count:\n rect[A[i]] = 2\n else:\n count[A[i]] = 1\n\nif len(rect) < 1:\n ans = 0\nelse:\n x = max(rect)\n if rect[x] >= 4:\n ans = x * x \n else:\n del rect[x]\n if len(rect) < 1:\n ans = 0\n else:\n y = max(rect)\n ans = x * y\nprint(ans)\n", "N=int(input())\nA=list(map(int,input().strip().split()))\n\nd={}\n\nfor n in range(N):\n if d.get(A[n])==None:\n d[A[n]]=1\n else:\n d[A[n]]+=1\n\nd=sorted(list(d.items()),reverse=True)\n\ncnt=0\nans=0\nfor i in range(len(d)):\n if cnt==0:\n if d[i][1]>=4:\n ans=d[i][0]**2\n break\n elif d[i][1]>=2:\n temp=d[i][0]\n cnt+=1\n else:\n if d[i][1]>=2:\n ans=temp*d[i][0]\n break\nprint(ans)\n", "with open(0) as f:\n N, *A = map(int, f.read().split())\n\npair = []\nunpair = set()\nfor a in A:\n if a in unpair:\n unpair.remove(a)\n pair.append(a)\n else:\n unpair.add(a)\npair.sort()\nprint(pair.pop()*pair.pop() if len(pair) > 1 else 0)", "n = int(input())\na = list(map(int, input().split()))\na.sort()\nl = []\nwhile a:\n x = a.pop()\n if not a:\n break\n if a[-1] == x:\n a.pop()\n l.append(x)\n if len(l) == 2:\n break\nif len(l) != 2:\n print(0)\nelse:\n print(l[0] * l[1])", "N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A, reverse = True)\n\nstore = 0\nbig = 0\n\nfor i in range (0, N-1):\n\tif store == 1:\n\t\tstore = 0\n\telse:\n\t\tif A[i] == A[i+1] and big == 0:\n\t\t\tbig = A[i]\n\t\t\tstore = 1\n\t\telif A[i] == A[i+1]:\n\t\t\tprint(A[i]*big)\n\t\t\treturn\n \nprint(0)", "from collections import Counter\n\nN=int(input())\nA=list(map(int,input().split()))\n\nc = Counter(A)\nmc=[]\nfor k in c.keys():\n if c[k]>=2:mc.append(k)\n \nif len(mc)==0:\n print(0)\n return\n\nelif len(mc)==1:\n if c[mc[0]]<4:\n print(0)\n return\n else:\n print(mc[0]**2)\n return\n \nmc = sorted(mc,reverse=True)\nif c[mc[0]] < 4:print(mc[0]*mc[1])\nelse:print(mc[0]**2)", "N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A, reverse = True)\nans = [0, 0]\nj = 0\nnow = -1\ncount = 1\nfor i in range(N):\n if A[i] == now:\n count += 1\n if count == 2:\n ans[j] = now\n if j == 1:\n print(ans[0] * ans[1])\n return\n j += 1\n if count == 4:\n print(now * now)\n return\n \n else:\n now = A[i]\n count = 1\n\nprint(0)", "import sys\n\nn,*a=list(map(int,sys.stdin.read().split()))\n\na.sort(reverse=True)\nc=0\nf=0\nans=[]\nfor i in range(n-1):\n if a[i]==a[i+1]:\n c+=1\n f+=1\n ans.append(a[i])\n else:\n f=0\n if (c>1 and f==1) or (c>2 and f==3):\n print((ans[0]*ans[-1]))\n return\nprint((0))\n \n \n", "#\n# abc071 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\n3 1 2 4 2 1\"\"\"\n output = \"\"\"2\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"4\n1 2 3 4\"\"\"\n output = \"\"\"0\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"10\n3 3 3 3 4 4 4 5 5 5\"\"\"\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 A.sort(reverse=True)\n l1 = l2 = 0\n for i in range(1, N):\n if l1 == 0:\n if A[i] == A[i-1]:\n l1 = A[i-1]\n else:\n if i < N-1 and A[i+1] == A[i]:\n l2 = A[i]\n break\n\n print((l1*l2))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "from collections import Counter as C\n\n_ = input()\n\nb = []\nfor k, v in C([int(x) for x in input().split()]).items():\n b.extend([k] * (v // 2))\nelse:\n if 2 <= len(b):\n b.sort()\n print(b[-1] * b[-2])\n else:\n print(0)", "def main():\n _ = int(input())\n a = [int(an) for an in input().split()]\n a.sort(reverse=True)\n line = -1\n lines = []\n for an in a:\n if line == an:\n lines.append(an)\n if len(lines) == 2:\n break\n line = -1\n else:\n line = an\n print((lines[0] * lines[1] if len(lines) == 2 else 0))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int, input().split()))\nnum_map = dict()\nfor i in range(n):\n if a[i] not in num_map:\n num_map[a[i]] = 1\n else:\n num_map[a[i]] += 1\n\nkeys = sorted(list(num_map.keys()), reverse=True)\n\ntwo_over = []\ncounter = 0\nres = 1\nfor i in keys:\n if num_map[i] >= 4:\n res *= i ** (2 - counter)\n counter += 2\n elif num_map[i] >= 2:\n counter += 1\n res *= i\n if counter >= 2:\n print(res)\n break\nelse:\n print((0))\n", "n=int(input())\na=list(map(int,input().split()))\nd={}\nsei=[]\ntyo=[]\nfor s in a:\n if s not in d:\n d[s]=0\n d[s]+=1\n \nfor t in a:\n if d[t]>=2:\n tyo.append(t)\n if d[t]>=4:\n sei.append(t)\n d[t]=0\n \nif len(sei)==0 and len(tyo)<=1:\n print(0)\n \nelse:\n tyos=0\n seis=0\n if len(tyo)>1:\n tyo=sorted(tyo)\n tyos+=tyo[-1]*tyo[-2]\n if len(sei)>0:\n sei=sorted(sei)\n seis+=sei[-1]**2\n \n print(max(tyos,seis))", "input()\nd = {}\nfor i in map(int, input().split()):\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n if len(ans) < 2 and j >= 4:\n ans.append(i)\n d[i] -= 2\n if len(ans) < 2 and j >= 2:\n ans.append(i)\n d[i] -= 2\n if len(ans) == 2:\n print(ans[0] * ans[1])\n break\nelse:\n print(0)", "input();a=list(map(int,input().split()));d={}\nfor i in a:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\nd={i:j for i,j in d.items() if j>1}\nif len(d)<2:\n print(0)\nelse:\n d=sorted(d.items(),key=lambda x:(-x[0],-x[1]))\n print(d[0][0]*d[1][0] if d[0][1]<4 else d[0][0]*d[0][0])", "n = int(input())\na = list(map(int, input().split()))\nfrom collections import Counter\na = Counter(a)\nlis = []\n\nfor i,j in a.items():\n lis += [i]*(j//2)\n\n#print(lis)\n\nlis.sort(reverse=True)\nif len(lis) <= 1:\n ans = 0\nelse:\n ans = lis[0]*lis[1]\n\nprint(ans)", "from collections import deque\n\nN = int(input())\nA = [int(i) for i in input().split()]\n\nA.sort(reverse=True)\nq = deque()\nfor i in range(N):\n q.append(A[i])\n\ns = []\nw = True\nwhile q:\n if len(q) == 1:\n break\n else:\n i = q.popleft()\n j = q.popleft()\n if i == j:\n s.append(i)\n else:\n q.appendleft(j)\n if len(s) == 2:\n print((s[0] * s[1]))\n w = False\n break\nif w:\n print((0))\n", "from collections import Counter\ndef main():\n n = int(input())\n A = list(map(int, input().split()))\n c = Counter(A)\n B = sorted([(k, v) for k, v in list(c.items()) if v >= 2], reverse = True, key = lambda x: x[0])\n if len(B) < 2:\n print((0))\n elif B[0][1] >= 4:\n print((B[0][0] ** 2))\n else:\n print((B[0][0] * B[1][0]))\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int,input().split()))\n\nd = {}\nfor i in a:\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\nd = sorted(d.items(), key=lambda x:x[0], reverse=True)\n\nm = len(d)\nans = 0\nflg = True\nfor i in range(m):\n k, v = d[i][0], d[i][1]\n if ans == 0:\n if v >= 4:\n ans = k**2\n flg = True\n break\n elif v >= 2:\n ans = k\n elif v >= 2:\n ans *= k\n flg = True\n break\nprint(ans) if flg else print(0)\n ", "N = int(input())\na = list(map(int,input().split()))\nc = {}\nd = [0,0]\nans = 0\n\nfor i in a:\n if i not in c:\n c[i]=0\n c[i]+=1\n\nfor i,v in zip(c.keys(),c.values()):\n if v >= 4:\n d.append(i)\n d.append(i)\n elif v >= 2:\n d.append(i)\n \nd.sort(reverse = True)\n\nif len(d) <= 3:\n ans = max(ans,0)\nelse:\n ans = max(ans,d[0]*d[1])\n\nprint(ans)", "def main():\n n = int(input())\n a_lst = list(map(int, input().split()))\n lst = [0, 0]\n\n a_lst.sort()\n a_lst.reverse()\n\n length = a_lst[0]\n count = 0\n for i in range(n):\n if a_lst[i] == length:\n count += 1\n\n if count == 2:\n lst.append(a_lst[i])\n count = 0\n\n if len(lst) == 4:\n break\n\n else:\n count = 1\n length = a_lst[i]\n\n area = lst[-1] * lst[-2]\n print(area)\n\n\ndef __starting_point():\n main()\n__starting_point()", "from collections import Counter\n \ninput()\nd = Counter(map(int, input().split()))\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n if j >= 4:\n ans.append(i)\n if j >= 2:\n ans.append(i)\nif len(ans) >= 2:\n print(ans[0] * ans[1])\nelse:\n print(0)", "N = int(input())\nA = list(map(int,input().split()))\n\ndic = {}\nfor a in A:\n if a in dic:\n dic[a] += 1\n else:\n dic[a] = 1\n \ndic = sorted(dic.items(), reverse=True)\n\nans = 1\ncheck = 0\nbool1 = False\nfor (i,j) in dic:\n cnt = j // 2\n for _ in range(cnt):\n ans *= i\n check += 1\n if check == 2:\n bool1 = True\n break\n if bool1:\n break\n\nprint(ans if ans != 1 else 0)", "N = int(input())\nA = [int(x) for x in input().split()]\nA.sort(reverse = True)\n\ns = []\ni = 0\nwhile i < N - 1:\n if len(s) == 2:\n break\n if A[i] == A[i + 1]:\n s.append(A[i])\n i += 2\n else:\n i += 1\n\nif len(s) == 2:\n print(s[0] * s[1])\nelse:\n print(0)", "n = int(input())\na = list(map(int,input().split()))\na.sort(reverse=True)\ni = 0\nc = 0\nx = 0\ny = 0 \nwhile i < len(a) - 1:\n\tif a[i] == a[i+1] and c == 0:\n\t\tx = a[i]\n\t\ti += 2\n\t\tc += 1\n\t\tcontinue\n\tif a[i] == a[i+1] and c == 1:\n\t\ty = a[i]\n\t\tbreak\n\ti += 1\nif x != 0 and y != 0:\n\tprint(x*y)\nelse:\n\tprint(0)", "n = int(input())\na = list(map(int,input().split()))\nimport collections\nb = collections.Counter(a).most_common()\nli4 = []\nli2 = []\nansli = []\nfor k in b:\n if k[1]>=4:\n li4 +=[k[0]]\n ansli += [k[0]**2]\n if k[1]>=2:\n li2 +=[k[0]]\n\nif len(li2)>=2:\n li22 = sorted(li2)\n ansli += [li22[-1]*li22[-2]]\nif ansli:\n print(max(ansli))\nelse:\n print(0)", "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)]\ndic = {}\nfor ai in al:\n dic[ai] = dic.get(ai, 0)+1\n\nedges = sorted(list(dic.items()), reverse=True)\nans = 0\npartial = False\ntemp = 0\nfor tup in edges:\n e, num = tup\n if num == 1:\n continue\n elif num == 2 or num == 3:\n if partial:\n ans = temp*e\n break\n else:\n partial = True\n temp = e\n else:\n if partial:\n ans = temp*e\n break\n else:\n ans = e**2\n break\nprint(ans)\n", "n = int(input())\na = list(map(int, input().split()))\n\nd = {}\nfor i in a:\n if i in d: d[i] += 1\n else: d[i] = 1\n\nt = 0\nans = []\nfor k,v in sorted(d.items(), key=lambda x: x[0], reverse=True):\n if v >= 4 and t == 0:\n print(k*k)\n return\n elif v >= 2:\n ans.append(k)\n t += 1\n if t == 2:\n print(ans[0]*ans[1])\n return\nprint(0)", "n = int(input())\na = list(map(int, input().split()))\nrods = []\ntmp = {}\nfor i in a:\n if i in tmp:\n tmp[i] += 1\n if tmp[i] >= 2:\n rods.append(i)\n tmp[i] = 0\n else:\n tmp[i] = 1\n\nrods.sort(reverse=True)\nif len(rods) >= 2:\n print(rods[0] * rods[1])\nelse:\n print(0)", "n = int(input())\nA = list(map(int, input().split()))\nA.sort()\nl = 0\nh = 0\ni = n-1\nwhile i >= 0:\n if i > 0 and A[i] == A[i-1] and l == 0:\n l = A[i]\n i -= 2\n elif i > 0 and A[i] == A[i-1] and h == 0:\n h = A[i]\n break\n else:\n i-=1\nprint (l*h)", "from collections import defaultdict\n\nN = int(input())\nA = list(map(int, input().split()))\nD = defaultdict(int)\nA.sort(reverse=True)\n\nfor i in A:\n D[i] += 1\n\nL = []\n\nfor i, x in D.items():\n if x >= 4:\n L.append(i)\n L.append(i)\n break\n elif x >= 2:\n L.append(i)\n\nif len(L) <= 1:\n print(0)\nelse:\n print(L[0]*L[1])", "N = int(input())\nA = [int(a) for a in input().split(\" \")]\n\nA.sort(reverse=True)\nl1 = 0\nc1 = 0\nl2 = 0\nc2 = 0\n\nL1 = 0\nL2 = 0\n\nfor i in range(len(A)):\n if L1 and L2:\n break\n elif L1:\n if l2 == A[i]:\n c2 += 1\n elif l2 != A[i]:\n l2 = A[i]\n c2 = 1\n if c2 == 2:\n L2 = l2\n else:\n if l1 == A[i]:\n c1 += 1\n elif l1 != A[i]:\n l1 = A[i]\n c1 = 1\n if c1 == 2:\n L1 = l1\n\nprint(L1 * L2)", "import collections\n\n_=input()\na=list(map(int,input().split()))\nc=collections.Counter(a)\nl=sorted(c.items(), key=lambda x: x[0])\nx=0\nfor i in l[::-1]:\n if i[1]>3:\n if x:\n print(i[0]*x)\n return\n else:\n print(i[0]*i[0])\n return\n elif i[1]>1:\n if x:\n print(i[0]*x)\n return\n else:\n x=i[0]\nprint(0)", "from collections import defaultdict\n\nN = int(input())\nA = list(map(int, input().split()))\nD = defaultdict(int)\n\nfor i in A:\n D[i] += 1\n\nL1 = [0, 0]\nL2 = [0]\n\nfor i, x in D.items():\n if x >= 4:\n L2.append(i)\n if x >= 2:\n L1.append(i)\n\nL1.sort(reverse=True)\nL2.sort(reverse=True)\n\nprint(max(L1[0]*L1[1], L2[0]**2))", "from collections import defaultdict\n\nd = defaultdict(int)\n\nn = int(input())\na = list(map(int, input().split()))\n\nans = []\nfor i in a:\n d[i] += 1\n if d[i] == 2:\n d[i] = 0\n ans.append(i)\nans.sort(reverse=True)\nif len(ans) >= 2:\n print((ans[0]*ans[1]))\nelse:\n print((0))\n", "from collections import Counter\nN = int(input())\nA = Counter(list(map(int, input().split())))\nB = dict(sorted(list(A.items()), reverse=True))\nans = []\nfor i, j in list(B.items()):\n if j >= 4:\n ans.append(i)\n ans.append(i)\n if j >= 2:\n ans.append(i)\nif len(ans) >= 2:\n print((ans[0] * ans[1]))\nelse:\n print((0))\n", "import collections\n\nN = int(input())\nA = list(map(int, input().split()))\n\nA = collections.Counter(A).most_common()\nN = len(A)\n\nans = [0]\n\nfor i in range(N):\n if A[i][1] >= 4:\n ans.append(A[i][0]**2)\n\nref = []\nfor j in range(N):\n if A[j][1] >= 2:\n ref.append(A[j][0])\nref = sorted(ref)\nif len(ref) >= 2:\n ans.append(ref[-2]*ref[-1])\n\nprint((max(ans)))\n", "n = int(input())\na1 = list(map(int, input().split()))\nfrom collections import Counter\na = Counter(a1).most_common()\nl = []\nfor i in range(len(a)):\n if 2 <= a[i][1]:\n for h in range(a[i][1]//2):\n l.append(a[i][0])\nl.sort()\nif 2 <= len(l):\n print(l[-1]*l[-2])\nelse:\n print(0)", "N=int(input())\nA=list(map(int,input().split()))\nA.sort()\n\ni=N-1\nans=1\ncount=0\nwhile i>=1:\n if A[i-1]==A[i]:\n ans*=A[i]\n i-=2\n count+=1\n else:\n i-=1\n if count==2:\n print(ans)\n break\nelse:\n print((0))\n", "import collections\n\nN = int(input())\na = [int(i) for i in input().split()]\ncheck = []\ndict = collections.Counter(a)\nfor a, b in dict.items():\n if b >= 2:\n check.append(a)\n\nif len(check) >=2:\n check.sort()\n if dict[check[-1]] >= 4:\n print(check[-1] ** 2)\n else:\n print(check[-1] * check[-2])\nelif len(check) == 1:\n if dict[check[-1]] >= 4:\n print(check[-1] ** 2)\n else:\n print(0)\nelse:\n print(0)", "N = int(input())\nA = list(map(int,input().split()))\nimport collections\na = collections.Counter(A)\nb = []\nfor i, j in a.items():\n if j >= 2:\n b.append([i,j])\nb.sort(reverse=True)\nif len(b) >= 1 and b[0][1] >= 4:\n print(b[0][0] ** 2)\nelif len(b) >= 2:\n print(b[0][0] * b[1][0])\nelse:\n print(0)", "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = []\nfor k, v in a.items():\n if 4 <= v:\n b.append(k)\n if 2 <= v:\n b.append(k)\nelse:\n if len(b) <= 1:\n print(0)\n else:\n b.sort()\n print(b[-1] * b[-2])", "from collections import deque\nn = int(input())\na = list(map(int, input().split()))\nnum_map = dict()\nfor i in range(n):\n if a[i] not in num_map:\n num_map[a[i]] = 1\n else:\n num_map[a[i]] += 1\n\nkeys = sorted(list(num_map.keys()), reverse=True)\n\nq = deque()\nfor i in keys:\n if num_map[i] >= 2:\n q.append([i, num_map[i]])\nres = 1\ncounter = 0\nwhile len(q) != 0:\n key, value = q.popleft()\n res *= key\n if value - 2 >= 2:\n q.appendleft([key, value - 2])\n counter += 1\n if counter == 2:\n print(res)\n break\nelse:\n print((0))\n", "from collections import defaultdict\nLineger_Dict = defaultdict(int)\nN = int(input())\nN_List = list(map(int,input().split()))\nfor i in N_List:\n Lineger_Dict[i] += 1\n\n \nRec = sorted([k for k,v in Lineger_Dict.items() if v >= 2] + [k for k,v in Lineger_Dict.items() if v >= 4])\nif len(Rec) < 2:\n print(0)\nelse:\n print(Rec[-1]*Rec[-2])", "import sys\nfrom collections import Counter\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, *A = list(map(int, read().split()))\n\n ans = 0\n counter = Counter(A)\n vec1 = [k for k, v in list(counter.items()) if v >= 2]\n vec2 = [k for k, v in list(counter.items()) if v >= 4]\n\n vec1.sort()\n if len(vec1) >= 2:\n ans = vec1[-2] * vec1[-1]\n\n vec2.sort()\n if len(vec2) >= 1:\n ans = max(ans, vec2[-1] ** 2)\n\n print(ans)\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import collections\nN = int(input())\nA = list(map(int,input().split()))\nc = collections.Counter(A)\nans = [i[0] for i in c.items() if i[1] >= 2]\nans.extend([i[0] for i in c.items() if i[1] >= 4])\nans.extend([0,0])\nans.sort(reverse=True)\nprint(ans[0]*ans[1])", "n = int(input())\na = sorted(list(map(int, input().split())))\ni = n - 1\np = 0\nq = 0\nwhile i > 0:\n if a[i] == a[i-1]:\n if p == 0:\n p = a[i]\n i -= 1\n else:\n q = a[i]\n break\n i -= 1\nprint(p*q)", "N = int(input())\na = list(map(int,input().split()))\n\na.sort()\na.reverse()\n\nc = [0,0]\ni = 0\n\nwhile i < N-1:\n if a[i] == a[i+1]:\n c.append(a[i])\n i+=2\n else:\n i+=1\n \nc.sort()\nc.reverse()\nprint(c[0]*c[1])", "N = int(input())\nA = [int(x) for x in input().split()]\nA.sort(reverse = True)\n\ns = []\ni = 0\nwhile i < N - 1:\n if A[i] == A[i + 1]:\n s.append(A[i])\n if len(s) == 2:\n print(s[0] * s[1])\n break\n i += 2\n else:\n i += 1\nelse:\n print(0)", "from collections import Counter\n\ninput()\nd = Counter(map(int, input().split()))\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n if len(ans) < 2 and j >= 4:\n ans.append(i)\n d[i] -= 2\n if len(ans) < 2 and j >= 2:\n ans.append(i)\n d[i] -= 2\n if len(ans) == 2:\n print(ans[0] * ans[1])\n break\nelse:\n print(0)", "N=int(input())\nA=sorted(list(map(int,input().split())),reverse=True)\ndef sameA(List):\n for i in range(len(List)):\n try:\n if List[i]==List[i+1]:\n ans=List[i]\n anslist=A[i+2:]\n return ans,anslist\n except IndexError:\n return False,False\na1,list1=sameA(A)\nif not a1==False:\n a2,list2=sameA(list1)\n if not a2==False:\n print(a1*a2)\n else:\n print(0)\nelse:\n print(0)", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tC\n# CreatedDate: 2020-09-04 15:20:21 +0900\n# LastModified: 2020-09-04 15:31:03 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\nfrom collections import Counter\n\n\ndef main():\n _ = int(input())\n a = list(map(int, input().split()))\n a_cnt = [[key, val] for key, val in list(Counter(a).items()) if val >= 2]\n if len(a_cnt) == 0:\n print((0))\n return\n a_cnt.sort(key=lambda x: x[0], reverse=True)\n if a_cnt[0][1] >= 4:\n print((a_cnt[0][0]**2))\n elif len(a_cnt) == 1:\n print((0))\n else:\n print((a_cnt[0][0]*a_cnt[1][0]))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nA = list(map(int, input().split()))\nA = sorted(A, reverse = True)\nL = []\ncnt = 0\ni = 0\nwhile i <= N-2:\n if A[i] == A[i+1]:\n L.append(A[i])\n i += 1\n cnt += 1\n if cnt == 2:\n break\n i += 1\nif len(L) == 2:\n print(L[0]*L[1])\nelse:\n print(0)", "n=int(input())\nl=list(map(int,input().split()))\nd={}\nfor a in l:\n if a in d:\n d[a]+=1\n else:\n d[a]=1\nks=sorted(d,reverse=True)\nf=0\nfor i,k in enumerate(ks):\n if d[k]>=4:\n print((k*k))\n return\n if d[k]>=2:\n f=k\n break\ns=0\nfor k in ks[i+1:]:\n if d[k]>=2:\n s=k\n break\nprint((f*s))\n", "from collections import Counter as C\n\n_ = input()\na = C([int(x) for x in input().split()])\n\nb = [0] * 2\nfor k, v in a.items():\n b.extend([k] * (v // 2))\nelse:\n b.sort()\n print(b[-1] * b[-2])", "N = int(input())\nA = list(map(int,input().split()))\nans = []\nflg = 0\n\nA.sort(reverse=True)\n\nfor i in range(N-1):\n if A[i] == A[i+1] and flg == 0:\n ans.append(A[i])\n flg = 1\n else:\n flg = 0\n\nif len(ans) > 1:\n print(ans[0]*ans[1])\nelse:\n print(0)", "from collections import Counter\nn = int(input())\na = list(map(int,input().split()))\nnum = Counter(a)\n\nif n == len(num)+1 or n == len(num):\n print((0))\n return\n\nans = []\n\nfor i in num:\n if num[i] >= 2:\n ans.append(i)\n if num[i] >= 4:\n ans.append(i) \nn = max(ans)\nans.pop(ans.index(max(ans)))\nm = max(ans)\nprint((n*m))\n", "from collections import Counter\nn = int(input())\na = Counter(list(map(int, input().split())))\na = [list(x) for x in a.items() if x[1]>=2]\na.sort(reverse=True, key=lambda x: (x[0], x[1]))\ncount = 0\nbase = 4\nfor i in range(len(a)):\n if count == 1:\n print(l*a[i][0])\n return\n else:\n l = a[i][0]\n count += 1\n\n if a[i][1]>=4:\n print(a[i][0]*a[i][0])\n return\n\nprint(0)", "from collections import Counter\n\ninput()\nd = Counter(map(int, input().split()))\nd = dict(sorted(d.items(), reverse=True))\nans = []\nfor i, j in d.items():\n if j >= 4:\n ans.append(i)\n if j >= 2:\n ans.append(i)\n if len(ans) >= 2:\n print(ans[0] * ans[1])\n break\nelse:\n print(0)", "import sys\nfrom collections import Counter\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, *A = list(map(int, read().split()))\n\n A.sort(reverse=True)\n\n i = 0\n w = h = 0\n while i < N - 1:\n if A[i] == A[i + 1]:\n if w == 0:\n w = A[i]\n else:\n h = A[i]\n break\n i += 2\n else:\n i += 1\n\n print((w * h))\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import heapq\nfrom collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nl = []\nfor i in set(a):\n if c[i] >= 2:\n for j in range(c[i]//2):\n l.append(i)\nif len(l) >= 2:\n print(heapq.nlargest(2, l)[0]*heapq.nlargest(2, l)[1])\nelse:\n print(0)", "from collections import Counter\n\ninput()\nans = [0, 0]\nfor i, j in list(Counter(list(map(int, input().split()))).items()):\n if j >= 4:\n ans.append(i)\n if j >= 2:\n ans.append(i)\nans.sort()\nprint((ans[-1] * ans[-2]))\n", "import collections\nN = int(input())\nA = sorted(collections.Counter(int(T) for T in input().split()).most_common(),reverse=True)\nFlag = False\nLS = 0\nSS = 0\nfor T in range(0,len(A)):\n if LS==0 and A[T][1]>=4:\n Sq = A[T][0]**2\n Flag = True\n break\n if A[T][1]>=2:\n if LS==0:\n LS = A[T][0]\n else:\n SS = A[T][0]\n Sq = LS*SS\n Flag = True\n break\nif Flag:\n print(Sq)\nelse:\n print(0)", "from collections import defaultdict\nn=int(input())\na=list(map(int,input().split()))\ndd=defaultdict(lambda:0)\nfor aa in a:\n dd[aa]+=1\nx,y=0,0\nfor k in sorted(dd.keys(), reverse=True):\n if x==0 and dd[k]>=2:\n x=k\n dd[k]-=2\n if y==0 and dd[k]>=2:\n y=k\n break\nprint(x*y)", "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\ndef main():\n n = i_input()\n a = i_list()\n\n a.sort()\n\n l = []\n start = a[0]\n cnt = 1\n for i in a:\n if i == start:\n cnt += 1\n else:\n start = i\n cnt = 1\n if cnt == 2:\n l.append(i)\n cnt = 0\n if cnt == 2:\n l.append(i)\n if len(l) < 2:\n print((0))\n else:\n print((l[-1]*l[-2]))\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "from collections import Counter\n\n\ndef solve():\n c = Counter(arr)\n four_edges = [k for k, v in list(c.items()) if v >= 4]\n two_edges = [k for k, v in list(c.items()) if 1 < v < 4]\n four_edges.append(0)\n two_edges.append(0)\n four_edges.sort(reverse=True)\n two_edges.sort(reverse=True)\n\n area_f = four_edges[0] * four_edges[0]\n if len(two_edges) >= 2:\n area_t = two_edges[0] * two_edges[1]\n else:\n area_t = 0\n area_t_t = two_edges[0] * four_edges[0]\n max_area = max(area_f, max(area_t, area_t_t))\n return max_area\n\n\nN = int(input())\narr = list(map(int, input().split()))\nres = solve()\nprint(res)\n", "n=int(input())\nL=list(map(int,input().split()))\nL.sort(reverse=True)\n\n\nimport collections\nd=collections.Counter(L)\nM=0\nm=[0,0]\nfor v in d:\n\tif d[v]>=4:\n\t\tM=max(M,v)\n\telif d[v]>=2:\n\t\tm.append(v)\nm.sort(reverse=True)\n\nprint(max(M**2,m[0]*m[1],M*m[0]))", "import sys\n\nN = int(input())\nA = list(map(int, input().split()))\nA = sorted(A, reverse=True)\n\ncnt = 0\nfor i in range(N-1):\n if A[i] - A[i+1] == 0:\n cnt +=1\nif cnt < 2:\n print(\"0\")\n return\n\nleng1 = 0\nleng2 = 0\ndiff = 10**9\n\ni = 0\nwhile diff != 0:\n diff = A[i] - A[i+1]\n i += 1 \nleng1= A[i]\n\nA.remove(leng1)\nA.remove(leng1)\n\ni = 0\ndiff = 10**9\nwhile diff != 0:\n diff = A[i] - A[i+1]\n i += 1 \nleng2= A[i]\n\nprint(leng1*leng2)", "import collections\n\n_, *a = map(int, open(0).read().split())\nc=collections.Counter(a)\ntmp=[]\nfor k,v in c.items():\n if v>3:\n tmp.append(k)\n if v>1:\n tmp.append(k)\ntmp.sort()\nprint(tmp[-1]*tmp[-2] if len(tmp) >1 else 0)", "from collections import Counter\n\ninput()\nans = []\nfor i, j in list(Counter(list(map(int, input().split()))).items()):\n if j >= 4:\n ans.append(i)\n if j >= 2:\n ans.append(i)\nif len(ans) >= 2:\n ans.sort()\n print((ans[-1] * ans[-2]))\nelse:\n print((0))\n", "import sys\nimport collections\n\nN = int(input())\nAN = list(map(int,input().split()))\n\ncount = collections.Counter(AN)\n\n\nedge1 = 0\nedge2 = 0\nfor c in sorted(list(count.keys()),reverse=True):\n if count[c] >= 4:\n if edge1 == 0:\n print((c*c))\n return\n else:\n print((edge1*c))\n return\n elif count[c] >= 2:\n if edge1 == 0:\n edge1 = c\n else:\n print((edge1*c))\n return\nelse:\n print((0))\n", "from collections import Counter\n\nn = int(input())\nA = list(map(int, input().split()))\ncnt_A = Counter(A)\n\nA_ = sorted([[k, v] for k, v in cnt_A.items() if v >= 2], reverse=True)\n\nif len(A_) == 0:\n print(0)\nelif A_[0][1] >= 4:\n print(A_[0][0] ** 2)\nelse:\n print(A_[0][0] * A_[1][0])", "N = int(input())\nA = [int(x) for x in input().split()]\n\npair = []\nunpair = set()\nfor a in A:\n if a in unpair:\n pair.append(a)\n unpair.remove(a)\n else:\n unpair.add(a)\n\npair.sort()\npair.reverse()\nif len(pair) <= 1:\n ans = 0\nelse:\n ans = pair[0] * pair[1]\nprint(ans)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 23 20:22:31 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nA = [int(x) for x in input().split()]\n\nA.sort(reverse=True)\n\nans = list()\ni = 0\nwhile i < N-1:\n if A[i] == A[i+1]:\n # print(\"A\")\n ans.append(A[i])\n i += 1\n if len(ans) == 2:\n break\n i += 1\n\nimport numpy as np\n#print(ans)\nif len(ans) < 2:\n print(0)\nelse:\n print(np.prod(ans))", "N = int(input())\n\nA = list(map(int, input().split()))\n\nA.sort()\n\ns1 = 0\ns2 = 0\n\nat = -1\natc = 0\n\nfor a in A:\n if at == a:\n atc += 1\n\n else:\n if atc >= 4:\n s1 = at\n s2 = at\n elif atc >= 2:\n s2 = s1\n s1 = at\n \n at = a\n atc = 1\n\nif atc >= 4:\n s1 = at\n s2 = at\nelif atc >= 2:\n s2 = s1\n s1 = at\n\nprint((s1 * s2))\n"]
{"inputs": ["6\n3 1 2 4 2 1\n", "4\n1 2 3 4\n", "10\n3 3 3 3 4 4 4 5 5 5\n"], "outputs": ["2\n", "0\n", "20\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
39,812
eb217179e15e554aace51d88149ca773
UNKNOWN
Some number of chocolate pieces were prepared for a training camp. The camp had N participants and lasted for D days. The i-th participant (1 \leq i \leq N) ate one chocolate piece on each of the following days in the camp: the 1-st day, the (A_i + 1)-th day, the (2A_i + 1)-th day, and so on. As a result, there were X chocolate pieces remaining at the end of the camp. During the camp, nobody except the participants ate chocolate pieces. Find the number of chocolate pieces prepared at the beginning of the camp. -----Constraints----- - 1 \leq N \leq 100 - 1 \leq D \leq 100 - 1 \leq X \leq 100 - 1 \leq A_i \leq 100 (1 \leq i \leq N) - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N D X A_1 A_2 : A_N -----Output----- Find the number of chocolate pieces prepared at the beginning of the camp. -----Sample Input----- 3 7 1 2 5 10 -----Sample Output----- 8 The camp has 3 participants and lasts for 7 days. Each participant eats chocolate pieces as follows: - The first participant eats one chocolate piece on Day 1, 3, 5 and 7, for a total of four. - The second participant eats one chocolate piece on Day 1 and 6, for a total of two. - The third participant eats one chocolate piece only on Day 1, for a total of one. Since the number of pieces remaining at the end of the camp is one, the number of pieces prepared at the beginning of the camp is 1 + 4 + 2 + 1 = 8.
["n=int(input())\nd,x=map(int,input().split())\nfor i in range(n):\n t=int(input())\n x+=(d+t-1)//t\nprint(x)", "N = int(input())\nD,X = list(map(int,input().split()))\ncon = 0\nfor i in range(N):\n a = int(input())\n if a != 1:\n for i in range(1 , D + 1):\n if i % a == 1:\n con += 1\n elif a == 1:\n con += D\nprint((X + con))\n \n", "N=int(input())\nD,X=map(int,input().split())\nA = [int(input()) for _ in range(N)]\n\nB=[0]*N\n\nfor i in range(N):\n if D%A[i]!=0:\n for j in range(D//A[i]+1):\n B[i]=1+D//A[i]\n else:\n B[i]=D//A[i]\nprint(sum(B)+X)", "n = int(input())\nd,x = list(map(int,input().split()))\nans = x\nl = []\nfor i in range(n):\n l.append(int(input()))\nfor i in l:\n ans += 1 + (d-1)//i\nprint(ans)\n \n", "n = int(input())\nd,x = map(int,input().split())\nlst = [int(input()) for _ in range(n)]\n\nres = x\nfor i in lst:\n res += ((d-1)//i) + 1\nprint(res)", "N = int(input())\nD, X = map(int, input().split())\nA = [int(input()) for _ in range(N)]\neat = lambda x: (D-1)//x+1\nans = sum(eat(a) for a in A) + X\nprint(ans)", "n, d, x, *a = map(int, open(0).read().split())\nans = x\nfor i in a:\n ans += (d - 1) // i + 1\nprint(ans)", "n = int(input())\nd, x = list(map(int, input().split()))\n\nchoco = []\nwhile True:\n\ttry:\n\t\tchoco.append(int(input()))\n\texcept EOFError:\n\t\tbreak\n\nchoco = [i * x + 1 for i in range(d) for x in choco if i * x + 1 <= d]\n\nprint((x + len(choco)))\n", "N=int(input())\nD,X=map(int,input().split())\nA=[int(input()) for _ in range(N)]\nfor i in range(N):\n cnt=0\n while A[i]*cnt+1<=D:\n cnt+=1\n X+=cnt\nprint(X)", "n = int(input())\nd,x = map(int, input().split())\nans = 0\nfor i in range(n):\n a = int(input())\n b = d//a\n c = d%a\n if c != 0:\n ans += b+1\n else:\n ans += b\nprint(ans+x)", "n=int(input())\nd,x=list(map(int, input().split()))\nans = x\nfor i in range(n):\n t = int(input())\n ans += d//t\n if d%t != 0:\n ans += 1\nprint(ans)\n", "n = int(input())\nd,x = map(int, input().split())\na=[]\nfor i in range(n):\n a.append(int(input()))\n\nans = 0\nfor i in a:\n cnt = 0\n days=1\n while days<=d:\n cnt+=1\n days+=i\n ans+=cnt\nprint(ans+x, flush=True)\n\n", "n = int(input())\nd, x = list(map(int, input().split()))\n\nres = x\nfor i in range(n):\n a = int(input())\n res += (d - 1) // a + 1\n\nprint(res)\n", "n, d, x, *a = map(int, open(0).read().split())\nfor i in a:\n x += 1 + (d - 1) // i\nprint(x)", "# -*- coding:utf-8 -*-\nN = int(input())\nD,X = map(int,input().split())\n\nA = []\nfor _ in range(N):\n A.append(int(input()))\n\nmember = len(A)\n\nChocolate = member + X\ndays = 1\n\nwhile days<=D:\n for single_member in A:\n if single_member*days + 1 <= D:\n Chocolate += 1\n days += 1\n\nprint(Chocolate)", "n = int(input())\nd,x = map(int,input().split())\ndata = [int(input()) for i in range(n)]\nans = n\nfor i in range(n):\n ans += (d - 1) // data[i]\nprint(ans + x)", "N = int(input())\nD, X = map(int, input().split())\n\nA = []\nfor n in range(N):\n buff = int(input())\n A.append(buff)\n\ndiv = 0\nfor n in range(N):\n if A[n] == 1:\n div += (D-1) //A[n]\n elif D % A[n] == 0:\n div += (D-1) //A[n]\n else:\n div += D //A[n]\n\ngoukei = X + div + N\n\nprint(goukei)", "N = int(input())\nD, X = list(map(int, input().split()))\nA = [0]*N\ncnt = 0\n\nfor i in range(N):\n A[i] = int(input())\n j = 0\n while j*A[i]+1 <= D:\n cnt += 1\n j += 1\nans = cnt + X\n\nprint(ans)\n", "n = int(input())\nd, x = map(int, input().split())\nfor i in range(n):\n x += (d - 1) // int(input()) + 1\nprint(x)", "n = int(input())\nd, x = map(int, input().split())\na = [int(input()) for _ in range(n)]\n\ntot = 0\nfor i in range(n):\n tot += int((d-1)/a[i])+1\ntot += x\nprint(tot)", "# ABC092\n# \u53c2\u52a0\u8005\nN = int(input())\n# D\u65e5\u9593\u306e\u5408\u5bbf\u3067X\u500b\u306e\u30c1\u30e7\u30b3\u304c\u6b8b\u3063\u305f\nD, X = list(map(int, input().split()))\n# \u53c2\u52a0\u8005i\u306f,1,Ai+1,2Ai+1..\u76ee\u306b\u30c1\u30e7\u30b3\u3092\u4e00\u3064\u98df\u3079\u308b\nA = [int(input()) for _ in range(N)]\n\neaten = 0\nfor i in range(N):\n day = 0\n cnt = 0\n while True:\n day = A[i]*cnt + 1\n if day <= D:\n eaten += 1\n cnt += 1\n else:\n break\nprint((eaten+X))\n", "n = int(input())\nd, x = map(int, input().split())\na = [int(input()) for _ in range(n)]\n\ncnt = x\nfor q in a:\n cnt += (d + q - 1) // q\nprint(cnt)", "N = int(input())\nD, X = map(int, input().split())\n\nfor _ in range(N):\n A = int(input())\n X += 1 + (D-1)//A\n\nprint(X)", "import math\n\nN = int(input())\nD, X = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n A = int(input())\n ans += math.ceil(D / A)\n\nprint((ans + X))\n", "n = int(input())\nd, x = map(int, input().split())\na = [int(input()) for i in range(n)]\nans = 0\nfor i in a:\n ans += ((d-1)//i)\n ans += 1\nprint(ans+x)", "n=int(input())\nd,x=map(int,input().split())\ncnt=n\nfor i in range(n):\n a=int(input())\n b = a+1\n while b <= d:\n cnt += 1\n b += a\nprint(cnt+x)", "N = int(input())\n\nD, X = map(int, input().split())\n\nchoco = 0\n\nfor i in range(N):\n A = int(input())\n choco += 1\n for j in range(1, 100):\n if A*j + 1 <= D:\n choco += 1\n else:\n break\n\nprint(choco+X)", "import sys\nn=int(input())\nd,x=map(int,input().split())\na=[int(input()) for i in range(n)]\n\nc=0\n\nfor i in a:\n p=(d-1)//i+1\n c+=p\n\n\nprint(c+x)", "import sys, math\nlines = [s.rstrip(\"\\n\") for s in sys.stdin.readlines()]\nn, = [int(num) for num in lines.pop(0).split(\" \")]\nd, x = [int(num) for num in lines.pop(0).split(\" \")]\na_list = [int(line) for line in lines]\nans = x\nfor a in a_list:\n ans += math.ceil(d / a)\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\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\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())\nn = I()\nD,X = readInts()\nans = 0\nfor i in range(n):\n a = I()\n ans += (D//a)+1 if D%a else D//a\nprint((X+ans))\n", "_, D, X, *A = list(map(int, open(0).read().split()))\n\nans = X\nfor a in A:\n ans += (D + a - 1) // a\nprint(ans)\n", "N = int(input())\nD,X = input().split()\nx = 0\nfor n in range(N):\n An = int(input())\n x += 1+(int(D)-1)//An\nc = x+int(X)\nprint(c)\n", "from typing import List\n\n\ndef answer(n: int, d: int, x: int, a: List[int]) -> int:\n eaten_chocolates = 0\n for i in range(n):\n eaten_chocolates += len(list(range(1, d + 1, a[i])))\n\n return eaten_chocolates + x\n\n\ndef main():\n n = int(input())\n d, x = list(map(int, input().split()))\n a = [int(input()) for _ in range(n)]\n print((answer(n, d, x, a)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nD,X = map(int,input().split())\nA = [int(input()) for _ in range(N)]\ncount=0\nfor a_i in A:\n count+=len(range(1,D+1,a_i))\nprint(count+X)", "n = int(input())\nd,x = map(int,input().split())\nL = list(int(input()) for _ in range(n))\ncnt = x+n\n\nfor i in range(n):\n tmp = (d-1)//L[i]\n cnt += tmp\nprint(cnt)", "n = int(input())\nd,x = map(int, input().split())\na = list(int(input()) for _ in range(n))\nans = 0\nfor i in range(n):\n p = (a[i]+1)-1\n ans += 1 + (d-1)//p\nprint(ans+x)", "n=int(input())\nd,x=map(int,input().split())\nres=x\nfor i in range(n):\n a=int(input())\n res+=(d-1)//a+1\n\nprint(res)", "n = int(input())\nd,x = map(int, input().split())\nans = x\nfor i in range(n):\n a = int(input())\n ans += 1+(d-1)//a\nprint(ans)", "n = int(input())\nd,x = map(int,input().split())\nli = []\nfor i in range(n):\n li.append(int(input()))\ncnt = 0\nfor i in li:\n day = 1\n while day <= d:\n day += i\n cnt += 1\nprint(cnt+x)", "import sys\n\nn = int(input())\nd,x = list(map(int,input().split()))\n\nfor i in range(n):\n a = int(input())\n for j in range(1,sys.maxsize,1):\n x += 1\n if a*j+1 > d:\n break\nprint(x)\n", "N=int(input())\nD,X=map(int,input().split())\nA=[int(input()) for i in range(N)]\n\ndef ans092(N:int, D:int, X:int, A:list):\n ans_int=0\n for i in range(N):\n j_count=0\n while True:\n if 1+A[i]*j_count<=D:\n ans_int+=1\n j_count+=1\n continue\n else:\n break\n return ans_int+X\n\nprint(ans092(N,D,X,A))", "import math\n\nn = int(input())\nd, x = map(int, input().split())\na = []\nfor i in range(n):\n a.append(int(input()))\n\ncount = 0\nfor num in a:\n count += math.ceil(d / num)\nprint(count + x)", "n=int(input())\nd,x=map(int,input().split())\nans=0\nfor i in range(n):\n a=int(input())\n if d%a==0:\n ans+=d//a\n else:\n ans+=d//a+1\nprint(ans+x)", "n = int(input())\nd, x = map(int, input().split())\na = []\n[a.append(int(input())) for i in range(n)]\ncnt = 0\nfor day in range(1, d+1):\n for eat in a:\n if (1+day*eat) <= d :\n cnt += 1\nprint(cnt+n+x)", "N = int(input())\nD, X = list(map(int, input().split()))\nA = [int(input()) for _ in range(N)]\n\nc = sum((D - 1) // a + 1 for a in A)\nprint((X + c))\n", "N=int(input())\nD,X=list(map(int,input().split()))\nans=X\nfor _ in range(N):\n A=int(input())\n ans+=(D-1)//A+1\nprint(ans)\n", "n = int(input())\nd,x = list(map(int,input().split()))\n\na = [int(input()) for _ in range(n)]\n\nsum = x\n\nfor i in range(n):\n if d%a[i] == 0:\n sum += d//a[i]\n else:\n sum += d//a[i] +1\n\nprint(sum)\n", "N=int(input())\nD,X=map(int,input().split())\nA= [int(input()) for i in range(N)]\ncount=0\nfor i in range(N):\n for j in range(100):\n if (A[i]*j)+1<=D:\n count+=1\nprint(count+X)", "n = int(input())\nd,x = map(int, input().split())\nc = 0\nfor i in range(n):\n a = int(input())\n c += (d-1)//a + 1\nprint(x+c)", "N = int(input())\nD, X = map(int,input().split())\nd = {}\nfor i in range(1,N+1):\n d[i] = int(input())\n\npieces = 0\nfor day in range(1,D+1):\n for person in range(1,N+1):\n if (day - 1) % d[person] == 0:\n pieces += 1\n \npieces += X\nprint(pieces)", "n = int(input())\nd, x = map(int, input().split())\na = [int(input()) for _ in range(n)]\n\nans = x\nfor i in a:\n ans += (d-1) // i + 1\nprint(ans)", "n=int(input())\nd,x=map(int,input().split())\na=[int(input()) for i in range(n)]\ncnt = x\nfor i in range(n):\n for j in range(d):\n if a[i]*j +1 <= d:\n cnt += 1\nprint(cnt)", "a=int(input())\nb,c=map(int,input().split())\ns=[]\ntotal=a+c\nfor i in range(a):\n s.append(int(input()))\nfor i in s:\n for j in range(2,b+1):\n if i==1:\n total+=1\n elif j%i==1:\n total+=1\nprint(total)", "N = int(input())\nD,Z = map(int,input().split())\ncnt = N\nfor i in range(N):\n A = int(input())\n day = 1 + A\n while day <= D:\n cnt += 1\n day += A\n\nprint(cnt + Z)", "from sys import stdin\n\nn = int(stdin.readline().strip())\nd, x = [int(x) for x in stdin.readline().split()]\n\na_lst = []\nfor _ in range(n):\n a_lst.append(int(stdin.readline().strip()))\n\nprint(sum([(d - 1) // a + 1 for a in a_lst]) + x)", "n = int(input())\nd, x = map(int, input().split())\na_l = [ int(input()) for _ in range(n) ]\n\nans = 0\nfor a in a_l:\n ans += (d-1)//a + 1\nprint(ans+x)", "N = int(input())\nD, X = [int(x) for x in input().split()]\nA = [int(input()) for _ in range(N)]\nans = X\nfor i in range(N):\n a = 1\n l = 1\n while a <= D:\n ans += 1\n a = l*A[i] + 1\n 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 d, x = Input()\n a = [int(input()) for _ in range(n)]\n ans = n\n\n for a_i in a:\n cnt = 1\n while True:\n flag = cnt * a_i + 1\n if flag > d:\n break\n ans += 1\n cnt += 1\n print(ans + x)\n\n\nmain()", "a=int(input())\nb,c=input().split()\nb=int(b)\nc=int(c)\ne=0\nd=[int(input()) for i in range(a)]\nfor i in range(a):\n e=e+int((b-1)/d[i])+1\nprint(e+c)", "n = int(input())\nd ,x = map(int,input().split())\na = [int(input()) for i in range(n)]\ncount = 0\nfor i in a:\n count += d // i + (0 if d % i == 0 else 1)\nprint(count+x)", "N = int(input())\nD, X = list(map(int, input().split()))\nsum = 0\nfor i in range(N):\n A = int(input())\n eat = 1+(D-1)//A\n sum += eat\nprint((X+sum))\n", "n = int(input())\nd,x = [int(t) for t in input().split()]\na = []\nfor i in range(n):\n a.append(int(input()))\nres = 0\nfor i in range(n):\n c = a[i]\n res += 1\n while c < d:\n res += 1\n c += a[i]\nres += x\nprint(res)", "n = int(input())\nd, x = map(int, input().split())\nans = 0\nfor i in range(n):\n a = int(input())\n cnt = 0\n for j in range(100):\n if j*a + 1 <= d:\n cnt += 1\n ans += cnt\nprint(ans + x)", "n = int(input())\nd, x = map(int, input().split())\nal = list(int(input()) for _ in range(n))\n\nans = x\n\nfor a in al:\n day = 1\n while day <= d:\n ans += 1\n day += a\n\nprint(ans)", "n=int(input())\nd,x=list(map(int,input().split()))\ncnt = 0\nfor i in range(n):\n a = int(input())\n p = 1\n while p <= d:\n p +=a\n cnt +=1\nprint((cnt+x))\n", "n = int(input())\nd, x = map(int, input().split())\nprint(sum([(d - 1) // int(input()) + 1 for _ in range(n)]) + x)", "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 main():\n n = ni()\n d, x = nm()\n ans = x\n for i in range(n):\n a = ni()\n ans += (d - 1) // a + 1\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nD, X = map(int, input().split())\nA = [int(input()) for i in range(N)]\n\ncnt = 0\nfor a in A:\n if D % a == 0:\n cnt += D // a\n else:\n cnt += D // a + 1\n\nprint(X+cnt)", "#!/usr/bin/env python3\n\nn = int(input())\nd, x = list(map(int, input().split()))\na = [int(input()) for i in range(n)]\n\nd -= 1\nans = 0\nfor i in a:\n ans += d//i+1\n\nprint((ans+x))\n", "N = int(input())\nD,X = map(int,input().split())\nA = [int(input()) for _ in range(N)]\ncount=0\nfor a_i in A:\n count+=len(list(range(1,D+1,a_i)))\nprint(count+X)", "n = int(input())\nd,x = list(map(int, input().split()))\nans = x\nfor _ in range(n):\n a = int(input())\n ans += (d + a - 1) // a\n\nprint(ans)", "n = int(input())\nd,x = map(int,input().split())\na = [int(input()) for i in range(n)]\nans = x\nfor i in range(n):\n j = 0\n while j*a[i]+1 <= d:\n ans += 1\n j += 1\nprint(ans)", "n=int(input())\nd,x=map(int,input().split())\na=[int(input())for _ in[0]*n]\nsm=0\nfor i in range(n):\n j=1\n while j<=d:\n sm+=1\n j=j+a[i]\nprint(sm+x)", "n = int(input())\nd,x = map(int, input().split())\na = [int(input()) for i in range(n)]\na_eat = []\nfor i in range(n):\n y = 1\n j = 1\n while j+a[i] <= d:\n y += 1\n j += a[i]\n a_eat.append(y)\n\nprint(sum(a_eat)+x)", "n=int(input())\nd,x=map(int,input().split())\nans=x\nfor i in range(n):\n ans += (d-1)//int(input())+1\nprint(ans)", "N=int(input())\nkazu=input().split(' ')\nD=int(kazu[0])\nX=int(kazu[1])\ndays=[]\ncount=0\nfor i in range(N):\n days.append(int(input()))\nfor i in range(N):\n a=0\n while 1:\n b=days[i]*a+1\n if b>D:\n break\n count=count+1\n a=a+1\nprint(count+X)", "from sys import stdin\ndef input():\n return stdin.readline().strip()\n\nn = int(input())\nd, x = map(int, input().split())\nfor _ in range(n):\n a = int(input())\n x += (d - 1) // a + 1\n\nprint(x)", "N=int(input())\nans=0\nD,X=list(map(int,input().split()))\nD-=1\n\nfor i in range(N):\n ans+=D//int(input())+1\nprint((ans+X))\n", "N = int(input())\nlst = input().split()\nD = int(lst[0])\n\nA = []\nfor i in range(N):\n A.append(int(input()))\n\ncount = int(lst[1])\n\nfor Ai in A:\n s = 1\n while s <= D:\n count += 1\n s += Ai\n\nprint(count)", "n = int(input())\nd, x = map(int, input().split())\n\nfor i in range(n):\n a = int(input())\n b = 1\n while b <= d:\n x += 1\n b += a\nprint(x)", "N = int(input())\nD, X = map(int, input().split())\nmass = 0\n\nfor n in range(N):\n A = int(input())\n i = 0\n day = 1\n while day <= D:\n day = i*A + 1\n i += 1\n\n mass += (i-1)\n\n\nresult = mass + X\nprint(result)", "N = int(input())\nD, X = list(map(int, input().split()))\nans = 0\nfor i in range(1, N+1):\n a = int(input())\n c = []\n for d in range(D):\n if d*a+1 > D:\n break\n c.append(d*a+1)\n ans += len(c)\n\nprint((ans+X))\n", "N = int(input())\nD, X = map(int, input().split())\nans = X\nfor i in range(N):\n A = int(input())\n ans += (D-1)//A + 1\nprint(ans)", "n = int(input())\nd, x = map(int, input().split())\nA = [int(input()) for _ in range(n)]\n\ncnt = 0\nfor a in A:\n for i in range(d):\n tmp = i * a + 1\n if tmp > d:\n break\n cnt += 1\nprint(cnt+x)", "N = int(input())\nD, X = list(map(int, input().split()))\nA=[]\nfor i in range(N):\n A.append(int(input()))\n \ntotal=0\nfor i in range(N):\n d = (D-1) // A[i]+1\n total+=d\n \nprint((total+X))\n", "def resolve():\n n = int(input())\n d, x = map(int, input().split())\n al = list()\n ans = 0\n for i in range(n):\n a = int(input())\n al.append(a)\n cl = list()\n for i in range(n):\n counter = 1\n day = 1\n while day + al[i] <= d:\n counter += 1\n day += al[i]\n cl.append(counter)\n ans = 0\n for i in cl:\n ans += i\n ans += x\n print(ans)\nresolve()", "n = int(input())\nd,x = map(int, input().split())\nc = 0\nfor i in range(n):\n a = int(input())\n for j in range(100):\n if a*j+1<=d:\n c+=1\n else:\n break\nprint(x+c)", "N = int(input())\nD,X = map(int,input().split())\nA = [int(input()) for _ in range(N)]\n\ncnt = 0\nfor i in range(N):\n day = 1\n while day <= D:\n cnt += 1\n day += A[i]\n \nprint(cnt + X)", "n = int(input())\nd, x = (int(i) for i in input().split())\nlist_a = [int(input()) for i in range(0, n)]\nans = x\nfor i in list_a:\n for j in range(1, d + 1):\n if i == 1:\n ans += d\n break\n elif j % i == 1: ans += 1\nprint(ans)", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n n = int(input())\n people=[]\n d,x = map(int,input().split())\n people=list([int(input()) for _ in range(n)])\n chocolates=[]\n choco=1\n\n for human in people:\n for day in range(1,d+1):\n if d >= human * day +1:\n choco+=1\n chocolates.append(choco)\n choco=1\n print(sum(chocolates)+x)\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\nd, x = map(int, input().split())\na = [int(input()) for _ in range(n)]\nc = 0\nfor i in range(n):\n c += (d - 1) // a[i] + 1\nprint(x + c)", "import sys\nfrom collections import deque\n#import numpy as np\nimport math\n#sys.setrecursionlimit(10**6)\ndef S(): return sys.stdin.readline().rstrip()\ndef SL(): return map(str,sys.stdin.readline().rstrip().split())\ndef I(): return int(sys.stdin.readline().rstrip())\ndef IL(): return map(int,sys.stdin.readline().rstrip().split())\n\ndef solve():\n return\n\ndef __starting_point():\n n = I()\n d,x = IL()\n days = 0\n for _ in range(n):\n a = I()\n tmp = 1\n count = 1\n while tmp<=d:\n days += 1\n tmp = count*a + 1\n count += 1\n ans = days + x\n print(ans)\n solve()\n__starting_point()", "n = int(input())\nd, x = list(map(int, input().split()))\nans = x\nfor i in range(n):\n a = int(input())\n if d - 1 > 0:\n ans += int((d - 1) / a) + 1\n else:\n ans += 1\n\nprint(ans)\n", "N = int(input())\nD, X = map(int, input().split())\ncount = X\nfor _ in range(N):\n A = int(input())\n count += (D-1) // A + 1\nprint(count)", "n = int(input())\nd, x = list(map(int, input().split()))\narr = []\nans = 0\nans += x\n\nfor _ in range(n):\n day_sum = 1\n keisu = 1\n num = int(input())\n\n while day_sum <= d:\n ans += 1\n keisu += 1\n day_sum += num\nprint(ans)\n", "def LI():\n return list(map(int, input().split()))\n\n\nN = int(input())\nD, X = LI()\nans = X\nfor _ in range(N):\n A = int(input())\n for i in range(100):\n if A*i+1 <= D:\n ans += 1\n continue\n break\nprint(ans)\n", "n = int(input())\nd,x = map(int, input().split())\nfor i in range(n):\n x += ((d-1)//int(input()) + 1)\nprint(x)", "n=int(input())\nd,x=map(int,input().split())\na=[int(input()) for _ in range(n)]\nans=x\nfor i in range(n):\n ans+=((d+a[i]-1)//a[i])\nprint(ans)", "N = int(input())\nD, X = map(int, input().split())\nA = []\nday = 1\n\nfor i in range(N):\n a = int(input())\n X += 1\n while True:\n day += a\n if day > D:\n break\n else:\n X += 1\n \n day = 1\n\nprint(X)", "import sys\nimport copy\nN=int(input())\na=[int(c) for c in input().split()]\nD=a[0]\nX=a[1]\na = [int(input()) for i in range(N)]\n\nchoco = 0\nfor i in range(N):\n cnt=0\n while cnt*a[i]+1<=D:\n choco+=1\n cnt+=1\n\nprint((choco+X))\n"]
{"inputs": ["3\n7 1\n2\n5\n10\n", "2\n8 20\n1\n10\n", "5\n30 44\n26\n18\n81\n18\n6\n"], "outputs": ["8\n", "29\n", "56\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
22,931
518fc7b2a073f74eff5ee05f10f5fc70
UNKNOWN
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total? Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different. -----Constraints----- - 0 \leq A, B, C \leq 50 - A + B + C \geq 1 - 50 \leq X \leq 20 000 - A, B and C are integers. - X is a multiple of 50. -----Input----- Input is given from Standard Input in the following format: A B C X -----Output----- Print the number of ways to select coins. -----Sample Input----- 2 2 2 100 -----Sample Output----- 2 There are two ways to satisfy the condition: - Select zero 500-yen coins, one 100-yen coin and zero 50-yen coins. - Select zero 500-yen coins, zero 100-yen coins and two 50-yen coins.
["a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\nans = 0\n\nfor i in range(a + 1):\n for j in range(b + 1):\n maisuuOf50 = (x - i * 500 - j * 100) / 50\n if 0 <= maisuuOf50 <= c:\n ans += 1\n\nprint(ans)\n", "def main():\n\n five_hundred = int(input())\n one_hundred = int(input())\n fifty = int(input())\n x = int(input())\n ans = 0\n for i in range(five_hundred + 1):\n for j in range(one_hundred + 1):\n for k in range(fifty + 1):\n if 500 * i + 100 * j + 50 * k == x:\n ans += 1\n\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "s=[int(input()) for _ in range(3)]\nA,B,C=s\nX=int(input())\n\ncnt=0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n tmp=500*i+100*j+50*k\n if tmp==X:\n cnt+=1\n\nprint(cnt)", "# -*- coding:utf-8 -*-\nA = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncnt = 0\nrest_X = 0\n\nfor i in range(0,A+1):\n rest_X = X - 500*i\n if rest_X == 0:\n cnt+=1\n break\n elif rest_X < 0:\n break\n for j in range(0,B+1):\n rest_X = X - 500*i\n rest_X = rest_X - (100*j)\n if rest_X == 0:\n cnt+=1\n break\n elif rest_X < 0:\n break\n \n if 50*C >= rest_X:\n cnt+=1\n\nprint(cnt)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\ncnt = 0\nfor i in range(0,A+1):\n for j in range(0,B+1):\n for k in range(0,C+1):\n price = 500 * i + 100 * j + 50 * k\n if price == X:\n cnt += 1\nprint(cnt)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\nans = 0\nfor i in range(a + 1):\n for j in range(b + 1):\n for k in range(c + 1):\n if 500 * i + 100 * j + 50 * k == x:\n ans += 1\nprint(ans)", "a, b, c, x = map(int, [input() for i in range(4)])\nans = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if i * 500 + j * 100 + k * 50 == x:\n ans += 1\nprint(ans)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\nans = 0\nfor aa in range(a + 1):\n for bb in range(b + 1):\n for cc in range(c + 1):\n if 500 * aa + 100 * bb + 50 * cc == x:\n ans += 1\nprint(ans)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncount = 0\n\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n if 500*i +100*j + 50*k == X:\n count += 1\n\nprint(\"{}\".format(count))", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncnt = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if 500 * i + 100 * j + 50 * k == x:\n cnt += 1\n \nprint(cnt)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\nans = 0\nfor i in range(a + 1):\n for j in range(b + 1):\n for k in range(c + 1):\n if i * 500 + j * 100 + k * 50 == x:\n ans += 1\n\nprint(ans)\n", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncnt = 0\n\nfor a_idx in range(a + 1):\n for b_idx in range(b + 1):\n for c_idx in range(c + 1):\n total = 500 * a_idx + 100 * b_idx + 50 * c_idx\n if (total == x): cnt += 1\n\nprint(cnt)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncount = 0\n# for a in range(A+1):\n# temp = X\n# if temp - 500 * a == 0:\n# count+=1\n# break\n# elif temp - 500 * a > 0:\n# temp -= 500 * a\n\n# for b in range(B+1):\n# temp_b = temp\n# if b != 0:\n# if temp_b - 100 * b == 0:\n# count+=1\n# break\n# elif temp_b - 100 * b > 0:\n# temp_b -= 100 * b\n\n# if C > 0:\n# temp_c = temp_b\n# for c in range(1,C+1):\n# if temp_c - 50 == 0:\n# count+=1\n# break\n# temp_c -= 50\n# if X < 500:\n# break\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n total = 500 * a + 100 * b + 50 * c\n if total == X:\n count+=1\n\nprint(count)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\nL = []\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n if 500*a + 100*b + 50*c == X:\n L.append((a,b,c))\nprint((len(L)))\n\n\n\n", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\nprint(sum(500*a + 100*b + 50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1)))", "a=int(input())\nb=int(input())\nc=int(input())\nsum_=int(input())\ncount=0\n\nfor i in range(0,a+1):\n for j in range(0,b+1): \n for k in range(0,c+1):\n check=500*i+100*j+50*k\n if(check==sum_):\n count+=1\nprint(count) \n", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\nans = 0\nfor i in range(a + 1):\n for j in range(b + 1):\n for k in range(c + 1):\n if i * 500 + j * 100 + k * 50 == x:\n ans += 1\nprint(ans)\n", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncnt = 0\n\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n Y = 500*i + 100*j + 50*k\n if Y == X:\n cnt += 1\n\nprint(cnt)", "def main():\n a, b, c, x = (int(input())+1 for _ in range(4))\n x -= 1\n\n ans = 0\n for i_a in range(a):\n for i_b in range(b):\n for i_c in range(c):\n if i_a * 500 + i_b * 100 + i_c * 50 == x:\n ans += 1\n print(ans)\n\n\nmain()", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncnt=0\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n if 500*a+100*b+50*c==X:\n cnt += 1\n \nprint(cnt)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\nres = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if 500*i + 100*j + 50*k == x:\n res += 1\nprint(res)", "A=int(input())\nB=int(input())\nC=int(input())\nX=int(input())\nans=0\nfor i in range(0,A+1):\n for j in range(0,B+1):\n for k in range(0,C+1):\n if 500*i+100*j+50*k==X:\n ans+=1\n\nprint(ans)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncnt = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if 500 * i + 100 * j + 50 * k == x:\n cnt += 1\nprint(cnt)", "with open(0) as f:\n a, b, c, x = map(int, f.read().split())\ncnt = 0\nfrom itertools import product\nfor i,j,k in product(range(a+1), range(b+1), range(c+1)):\n if 500*i + 100*j + 50*k == x:\n cnt += 1\nprint(cnt) ", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncnt = 0\nfor a in range(A+1):\n if X < 500*a:\n continue\n y = X-(500*a)\n if y == 0:\n cnt += 1\n continue\n for b in range(B+1):\n if y < b*100:\n continue\n z = y-(100*b)\n if z == 0:\n cnt += 1\n continue\n for c in range(C+1):\n w = z-(50*c)\n if w == 0:\n cnt += 1\n break\nprint(cnt)", "A=int(input())\nB=int(input())\nC=int(input())\nX=int(input())\n\nans=0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n if i*500+j*100+50*k==X:\n ans+=1\n\nprint(ans)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\nans = 0\nfor i in range(a + 1):\n for j in range(b + 1):\n for k in range(c + 1):\n if i* 500 + j * 100 + k * 50 == x:\n ans += 1\nprint(ans)", "a=int(input())\nb=int(input())\nc=int(input())\nx=int(input())\nif x%100>0 and c==0:\n print((0))\n return\nelse:\n a=min(a,x//500)\n b=min(b,x//100)\n c=min(c, x // 50)\n ans=0\n for i in range(a+1):\n for j in range(b+1):\n for c in range(c+1):\n if i*500+j*100+c*50==x:ans+=1\nprint(ans)\n", "A=int(input())\nB=int(input())\nC=int(input())\nX=int(input())\ncount=0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n if 500*i+100*j+50*k==X:\n count+=1\nprint(count)\n", "A = int(input()) + 1\nB = int(input()) + 1\nC = int(input()) + 1\nX = int(input())\n\ncount = 0\nfor a in range(A):\n for b in range(B):\n for c in range(C):\n if a * 500 + b * 100 + c * 50 == X:\n count += 1\n\nprint(count)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\ncount = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if x == 500 * i + 100 * j + 50 * k:\n count += 1\nprint(count)", "def answer(a: int, b: int, c: int, x: int) -> int:\n count = 0\n for i in range(0, a + 1):\n for j in range(0, b + 1):\n for k in range(0, c + 1):\n if x == i * 500 + j * 100 + k * 50:\n count += 1\n\n return count\n\n\ndef main():\n a = int(input())\n b = int(input())\n c = int(input())\n x = int(input())\n print(answer(a, b, c, x))\n\n\ndef __starting_point():\n main()\n__starting_point()", "a = int(input())\nb = int(input())\nc = int(input())\ng = int(input())\ntmp = []\nfor x in range(a+1):\n for y in range(b+1):\n for z in range(c+1):\n tmp.append(500*x + 100*y + 50*z)\nans = tmp.count(g)\nprint(ans)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\nans = 0\nfor i in range(0, A+1):\n for j in range(0, B+1):\n for k in range(0, C+1):\n if i*500 + j * 100 + k * 50 == X:\n ans += 1\n\nprint(ans)\n\n\n\n", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\nans = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if 500*i+100*j+50*k == x:\n ans += 1\nprint(ans)", "# coding: utf-8\n# Your code here!\n\na = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\nmax_a = min(int(x/500), a)\nmax_b = min(int(x/100), b)\nmax_c = min(int(x/50), c)\n\ncnt = 0\n\nfor i in range(max_a + 1) : \n for j in range(max_b + 1) : \n for k in range(max_c + 1) : \n if i*500 + j*100 + k*50 == x : \n cnt += 1\n \nprint(cnt)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\ncnt = 0\nfor i in range(a+1):\n for j in range(b+1):\n for ind in range(c+1):\n if 500*i + 100*j + 50*ind == x:\n cnt += 1\n\nprint(cnt)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\nans = 0\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n if(500*a + 100*b + 50*c) == X:\n ans += 1\nprint(ans)\n", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\nans = 0\n\nfor i in range(0,A+1):\n a = 500*i\n \n for j in range(0,B+1):\n b = 100*j\n \n for k in range(0,C+1):\n c = 50*k\n \n if a + b + c == X:\n ans += 1\n \nprint(ans)\n \n", "A = int(input())\nB = int(input())\nC = int(input())\nx = int(input())\nans = 0\n\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n if 500*a+100*b+50*c == x:\n ans += 1\n\nprint(ans)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\nans = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if 500*i + 100*j + 50*k == x:\n ans += 1\nprint(ans)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\ncount = 0\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n if 500*a + 100*b + 50*c == X:\n count += 1\nprint(count)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncnt = 0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n ans =500*i + 100*j + 50*k\n if ans == X:\n cnt += 1\n\nprint(cnt)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncount=0\n\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n if 500*i + 100*j + 50*k == X:\n count +=1\n\nprint(count)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\ncnt = 0\nsum = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n sum = 500 * i + 100 * j + 50 * k\n if sum == x:\n cnt += 1\nprint(cnt)", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n a = int(input())\n b = int(input())\n c = int(input())\n target = int(input())\n count=0\n\n for i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if (500*i)+(100*j)+(50*k)==target:\n count+=1\n else:\n continue\n print(count)\n\ndef __starting_point():\n main()\n__starting_point()", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\ncount = 0\n\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n sum = 500 * int(i) + 100 * int(j) + 50 * int(k)\n if sum == X:\n count += 1\n\nprint(count)", "# 34\nA = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\nans = 0\nfor a in range(0, A + 1):\n if 500 * a > X: continue\n for b in range(0, B + 1):\n if 500 * a + 100 * b > X: continue\n for c in range(0, C + 1):\n if 500 * a + 100 * b + 50 * c == X: ans +=1\n\nprint(ans)", "[a]=[int(i) for i in input().split()]\n[b]=[int(i) for i in input().split()]\n[c]=[int(i) for i in input().split()]\n[x]=[int(i) for i in input().split()]\nans=0\nfor ia in range(a+1):\n for ib in range(b+1):\n for ic in range(c+1):\n if(ia*500+ib*100+ic*50==x):\n ans+=1\nprint(ans)\n", "a_coins = int(input())\nb_coins = int(input())\nc_coins = int(input())\nx_num = int(input())\n\ndef money_match(a, b, c):\n money = 500 * a + 100 * b + 50 * c\n if money == x_num:\n return 1\n else:\n return 0\n \ncnt = 0\nfor a in range(a_coins+1):\n for b in range(b_coins+1):\n for c in range(c_coins+1):\n if money_match(a, b, c) == 1:\n cnt += 1\n \nprint(cnt)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncnt = 0\n\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if 500*i + 100*j + 50*k == x:\n cnt += 1\n\nprint(cnt)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\npat = 0\nfor a in range(A+1):\n\tfor b in range(B+1):\n\t\tfor c in range(C+1):\n\t\t\tif a*500+b*100+c*50 == X:\n\t\t\t\tpat += 1\nprint(pat)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncnt=0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n if X == 500*i + 100*j + 50*k:\n cnt+=1\n\nprint(cnt) \n", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())//50\n\nans = 0\nfor a, b, c in [(a, b, c) for a in range(A+1) for b in range(B+1) for c in range(C+1)]:\n if 10*a + 2*b + c == X:\n ans += 1\n\nprint(ans)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\nans = 0\n\nfor i in range(0, A+1, 1):\n for j in range(0, B+1, 1):\n for k in range(0, C+1, 1):\n if 500 * i + 100 * j + 50 * k == X:\n ans += 1\n \nprint(ans)", "A = input()\nB = input()\nC = input()\nX = input()\n\nA=int(A)\nB=int(B)\nC=int(C)\nX=int(X)\n\ncount=0\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n x=X-(500*a+100*b+50*c)\n \n if x==0:\n count=count+1\n\nprint(count)", "A,B,C,X = list(map(int,[input() for i in range(4)]))\n\nans = 0\n\nfor i in range(A+1):\n for j in range (B+1):\n for k in range(C+1):\n if i *500 + j * 100 + k * 50 == X:\n ans = ans + 1\nprint(ans)\n", "s = [int(input()) for i in range(4)]\nA = s[0]\nB = s[1]\nC = s[2]\nX = s[3]\nres = 0\ntotal = 0\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n total = 500*a + 100*b + 50*c\n# print(\"A:\"+str(a)+\" B:\"+str(b)+\" C:\"+str(c) + \"total:\"+str(total))\n if(total == X):res = res +1\nprint(res)", "getints = lambda: map(int, input().split())\na = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\nans = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n val = 500 * i + 100 * j + 50 * k\n if val == x:\n ans += 1\nprint(ans)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\nans = 0\n\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n if 500*a+100*b+50*c == X:\n ans += 1\n\nprint(ans)", "def solve(A, B, C, X):\n ans = 0\n for a in range(A + 1):\n for b in range(B + 1):\n for c in range(C + 1):\n total = 500 * a + 100 * b + 50 * c\n if total == X:\n ans += 1\n print(ans)\n\n\ndef __starting_point():\n A = int(input())\n B = int(input())\n C = int(input())\n X = int(input())\n solve(A, B, C, X)\n\n__starting_point()", "A=int(input())#500\u5186\u7389\nB=int(input())#100\u5186\u7389\nC=int(input())#50\u5186\u7389\nX=int(input())#\u5408\u8a08\u91d1\u984d\u300250\u306e\u500d\u6570\ncount=0\n\nfor a in range(0,A+1):\n for b in range(0,B+1):\n for c in range(0,C+1):\n if 500*a+100*b+50*c==X:\n count=count+1\nprint(count)\n", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\ncnt = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n p = 500*i + 100*j + 50*k\n if p == x:\n cnt +=1\nprint(cnt)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncount = 0\n\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if (500 * i) + (100 * j) + (50 * k) == x:\n count += 1\n\nprint(count)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncnt = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n cand = 500 * i + 100 * j + 50 * k\n if cand == x:\n cnt += 1\nprint(cnt)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncnt =0\nfor i in range(a + 1):\n for j in range(b + 1):\n for k in range(c + 1):\n if 500 * i + 100 * j + 50 * k == x:\n cnt += 1\n break\n elif 500 * i + 100 * j + 50 * k > x:\n break\nprint(cnt)", "n=[int(input()) for i in range(4)]\nprint(sum(0<=(n[3]-500*a-100*b)//50<=n[2] and (n[3]-500*a-100*b)%50==0 for a in range(n[0]+1) for b in range(n[1]+1)))", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\nans = 0\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n if a * 500 + b * 100 + c * 50 == X:\n ans += 1\nprint(ans)", "#!/usr/bin/env python3\n\na = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\nans = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n value = 500*i+100*j+50*k\n if value == x:\n ans += 1\n\nprint(ans)\n", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\nans = 0\nfor i in range(a+1):\n for j in range(b+1):\n if (x-(500*i + 100*j))%50==0 and ((x-(500*i+100*j))//50)<=c and (500*i+100*j)<=x:\n ans += 1\n #print(i, j)\nprint(ans)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\ncnt = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n total = i * 500 + j * 100 + k * 50\n if total == x:\n cnt += 1\nprint(cnt)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\nresult = 0\nfor i in range(0, A+1):\n for j in range(0, B+1):\n for k in range(0, C+1):\n coins = 500 * i + 100 * j + 50 * k\n if coins == X:\n result += 1\n\nprint(result)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\nans = 0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n if X == (500 * i) + (100 * j) + (50 * k):\n ans += 1\nprint(ans)\n", "A, B, C, X = [int(input()) for i in range(4)]\ncnt = 0\n\nfor a in range(A + 1):\n for b in range(B + 1):\n for c in range(C + 1):\n if 500 * a + 100 * b + 50 * c == X:\n cnt += 1\nprint(cnt)", "A = int(input())\nB = int(input())\nC = int(input())\nx = int(input())\nans = 0\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n total = 500*a + 100*b + 50*c\n if total==x:\n ans+=1\nprint(ans)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ncnt = 0\nfor i in range(A+1):\n X_ = X\n X_ -= 500*i\n for j in range(B+1):\n X__ = X_\n X__ -= 100*j\n for k in range(C+1):\n X___ = X__\n X___ -= 50*k\n if X___ == 0:\n cnt += 1\nprint(cnt)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncnt = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if 500*i + 100*j + 50*k == x:\n cnt += 1\n\nprint(cnt)\n", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncount = 0\nfor i in range(a + 1):\n for j in range(b + 1):\n for k in range(c + 1):\n if i * 500 + j * 100 + k * 50 == x:\n count += 1\nprint(count)", "a, b, c, x = map(int, [input() for i in range(4)])\nans = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if i * 500 + j * 100 + k * 50 == x:\n ans += 1\nprint(ans)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\nans = 0\n\nfor i in range(a+1):\n i *= 500\n for j in range(b+1):\n j *= 100\n for k in range(c+1):\n k *= 50\n sum = i + k + j\n if sum == x:\n ans += 1\n\nprint(ans)\n \n", "A,B,C,X = [int(input()) for _ in range(4)]\nans = 0\nfor a in range(A+1):\n for b in range(B+1):\n for c in range(C+1):\n if (500*a + 100*b + 50*c) == X:\n ans += 1\nprint(ans)", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\n\ncnt = 0\nfor an in range(a+1):\n for bn in range(b+1):\n for cn in range(c+1):\n if x == 500*an + 100*bn + 50*cn:\n cnt += 1\nprint(cnt)", "A=int(input())\nB=int(input())\nC=int(input())\nX=int(input())\ncount=0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n if 500*i+100*j+50*k==X: count+=1\nprint(count)", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nans=0\nfor i in range(0,a+1):\n for j in range(0,b+1):\n for k in range(0,c+1):\n if 500*i+100*j+50*k==d:\n ans+=1\nprint(ans)\n", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\nans = 0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n if(500*i+100*j+50*k)==X:\n ans += 1\nprint(ans)", "A, B, C, X = [int(input()) for i in range(4)]\nprint(sum(500*a + 100*b + 50*c == X for a in range(A+1) for b in range(B+1) for c in range(C+1)))", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\ncnt = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if i * 500 + j * 100 + k * 50 == x:\n cnt += 1\nprint(cnt)\n", "A=int(input())\nB=int(input())\nC=int(input())\nX=int(input())\nans=0\nfor i in range(0,A+1):\n for j in range(0,B+1):\n for k in range(C+1):\n if 500*i+100*j+50*k==X:\n ans+=1\nprint(ans) \n", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\ncnt = 0\n\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if i*500+j*100+k*50 == x:\n cnt += 1\n\nprint(cnt)", "a = int(input())\nb = int(input())\nc = int(input())\nx1 = int(input())\nx2 = 0\nans = 0\n\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n x2 = 500*i + 100*j + 50*k\n if (x2==x1):\n ans+=1\n\nprint(ans)\n", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\ncount=0\n\nfor a in range(0,A+1):\n for b in range(0,B+1):\n for c in range(0,C+1):\n total = 500*a + 100*b + 50*c\n if total == X:\n count = count+1\n\nprint(count)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\nx = 0\nfor a in range(A + 1):\n for b in range(B + 1):\n for c in range(C + 1):\n if 500*a + 100*b + 50*c == X:\n x += 1\nprint(x)", "a,b,c,x=[int(input()) for i in range(4)]\nans=0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if 500*i+100*j+50*k==x:\n ans += 1\nprint(ans)", "A = int(input())\nB = int(input())\nC = int(input())\nX = int(input())\n\ntotal = 0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n Ans = 500*i + 100*j + 50*k\n if Ans == X:\n total +=1\nprint(total)\n", "a = int(input())\nb = int(input())\nc = int(input())\nx = int(input())\nans = 0\nfor i in range(a+1):\n for j in range(b+1):\n for k in range(c+1):\n if 500*i + 100*j + 50*k == x:\n ans += 1\nprint(ans)", "(A, B, C, X) = [int(input()) for i in range(4)]\nways = 0\n\nmax_a = int( X / 500 )\nif A < max_a :\n max_a = A\nfor a in reversed(list(range( max_a+1))) :\n max_b = int( (X - 500 * a) / 100 )\n if B < max_b :\n max_b = B\n for b in reversed(list(range( max_b+1))) :\n c = int ( ( X - 500 * a - 100 * b ) / 50 )\n if c > C :\n break\n ways += 1\nprint(('%d' %ways )) ;\n", "a=int(input())\nb=int(input())\nc=int(input())\nx=int(input())\n\ncnt=0\nfor i in range(0,a+1):\n for j in range(0,b+1):\n for k in range(0,c+1):\n if 500*i+100*j+50*k==x:\n cnt+=1\nprint(cnt)", "a=int(input())\nb=int(input())\nc=int(input())\nx=int(input())\nans=0\nfor i in range (0,a+1):\n for j in range (0,b+1):\n for k in range (0,c+1):\n sum=i*500+j*100+k*50\n if sum==x:\n ans=ans+1\nprint(ans)", "A = int(input()) # 500\nB = int(input()) # 100\nC = int(input()) # 50\nX = int(input()) \n\ncount = 0\ntotal_price = 0\nfor i in range(A+1):\n for j in range(B+1):\n for k in range(C+1):\n total_price = 500 * i + 100*j + 50*k\n if total_price == X:\n count += 1\nprint(count)"]
{"inputs": ["2\n2\n2\n100\n", "5\n1\n0\n150\n", "30\n40\n50\n6000\n"], "outputs": ["2\n", "0\n", "213\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
27,787
ac39a650d758429f8a0243619be2fd14
UNKNOWN
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B. -----Constraints----- - -100≀A,B,C≀100 - A, B and C are all integers. -----Input----- Input is given from Standard Input in the following format: A B C -----Output----- If the condition is satisfied, print Yes; otherwise, print No. -----Sample Input----- 1 3 2 -----Sample Output----- Yes C=2 is not less than A=1 and not greater than B=3, and thus the output should be Yes.
["# 3 \u3064\u306e\u6574\u6570 A , B , C \u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n# \u6574\u6570 C \u304c A \u4ee5\u4e0a \u304b\u3064 B \u4ee5\u4e0b\u3067\u3042\u308b\u304b\u3092\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\nA,B,C = map(int,input().split())\n\nif C >= A and C <= B:\n print('Yes')\n\nelse:\n print('No')", "A,B,C = map(int,input().split())\n\nif A <= C and C <= B:\n print('Yes')\nelse:\n print('No')", "# A - Between Two Integers\n# https://atcoder.jp/contests/abc061/tasks/abc061_a\n\nA, B, C = list(map(int, input().split()))\n\nresult = 'No'\n\nif A <= C <= B:\n result = 'Yes'\n\nprint(result)\n", "a,b,c=map(int,input().split(\" \"))\nprint(\"Yes\") if a<=c and c<=b else print(\"No\")", "a, b, c = map( int, input().split())\n\nif a <= c <= b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c=map(int,input().split())\nif a<=c<=b:print('Yes')\nelse:print('No')", "a, b, c = map(int, input().split())\nif c >= a and c <= b:\n print(\"Yes\")\nelse:\n print(\"No\")", "A, B, C = map(int, input().split())\n\nif C >= A and C <= B:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c=map(int,input().split())\nprint(\"Yes\" if a<=c<=b else \"No\")", "# 3\u3064\u306e\u6574\u6570 A, B, C \u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n# \u6574\u6570 C \u304c A \u4ee5\u4e0a \u304b\u3064 B \u4ee5\u4e0b\u3067\u3042\u308b\u304b\u3092\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# \u2212100 \u2266 A, B, C \u2266 100\n# A, B, C \u306f\u5168\u3066\u6574\u6570\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 A, B, C \u3092\u53d6\u5f97\u3059\u308b\na, b, c = list(map(int, input().split()))\n\n# \u5224\u5b9a\u3057\u3066\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\nresut = \"ret\"\n\nif a <= c and b >= c:\n result = \"Yes\"\nelse:\n result = \"No\"\n\nprint(result)\n", "a,b,c = map(int,input().split())\nif a <= c and c <= b:\n print('Yes')\nelse:\n print('No')", "i = list(map(int,input().split()))\n\nif i[0]<=i[2]<=i[1]:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a,b,c=map(int,input().split())\nif a<=c<=b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c=map(int,input().split())\nprint(\"Yes\"if a<=c<=b else \"No\")", "a,b,c = list(map(int,input().split()))\nprint((\"Yes\" if a<=c<=b else \"No\"))\n", "# \u5404\u6570\u5024\u306e\u53d6\u5f97\nA,B,C = map(int,input().split())\n\n# \u6570\u5024\u3092\u6bd4\u8f03\u3057\u3066\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\nif C >= A \\\nand C <=B:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c=map(int,input().split())\nif a<=c and c<=b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = map(int, input().split())\n\nif a <= c <= b:\n print('Yes')\nelse:\n print('No')", "A, B, C = map(int, input().split())\n\nprint(\"Yes\" if A <= C and C <= B else \"No\")", "a,b,c = map(int,input().split())\n\nprint('Yes' if a <= c <= b else 'No')", "a,b,c = map(int,input().split())\nif a <= c <= b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c = map(int,input().split())\nif a <= c <= b:\n print('Yes')\nelse:\n print('No')", "a,b,c = map(int, input().split())\nans = 'Yes' if c >= a and c <= b else 'No'\nprint(ans)", "# 061_a\nA, B, C = list(map(int, input().split()))\nif (-100 <= A <= 100) and (-100 <= B <= 100) and (-100 <= C <= 100):\n if A <= C and C <= B:\n print('Yes')\n else:\n print('No')\n", "A,B,C = map(int, input().split())\n\nif C >= A and C <= B:\n print('Yes')\nelse:\n print('No')", "a,b,c = map(int,input().split())\nprint(\"Yes\" if a<=c<=b\n else \"No\")", "a,b,c = map(int,input().split())\nprint(\"Yes\" if a <= c and c <= b else \"No\")", "# 3\u3064\u306e\u6574\u6570A,B,C\u3002C\u304cA\u4ee5\u4e0a\u304b\u3064B\u4ee5\u4e0b\u304b\u5224\u5b9a\u3002\n\nA, B, C = map(int, input().split())\n\nif A <= C <= B:\n print('Yes')\nelse:\n print('No')", "A, B, C =map(int,input().split())\nif C >= A and C <= B:\n print(\"Yes\")\nelse:\n print(\"No\")", "# AtCoder abc061 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\na, b, c = list(map(int, input().split()))\n\n# \u5224\u5b9a\nif (c >= a) and (c <= b):\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a,b,c=map(int,input().split())\nif c>=a and c<=b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c = list(map(int,input().split()))\n#lis = list(map(int,input().split()))\nprint((\"Yes\" if a<=c<=b else \"No\"))\n\n\n\n\n", "A,B,C=list(map(int,input().split()))\nif C>=A and B>=C:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a,b,c=map(int,input().split())\nif (a<=c and c<=b):\n print('Yes')\nelse:\n print('No')", "a,b,c=map(int,input().split())\nif (a<=c)and(c<=b):\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c=map(int,input().split());print('NYoe s'[a<=c<=b::2])", "A,B,C=map(int,input().split())\nif C>=A and C<=B :\n print(\"Yes\")\nelse :\n print(\"No\")", "A, B, C = [int(i) for i in input().split()]\nif C >= A and C <= B:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "A, B, C = map(int, input().split())\n\nif A <= C and B >= C:\n print('Yes')\nelse:\n print('No')", "a, b, c = map(int, input().split())\nprint('Yes' if a<=c<=b else 'No')", "A,B,C=list(map(int,input().split()))\nif A<=C and C<=B:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a, b, c = map(int, input().split())\n\nif a <= c and c <= b:\n print('Yes')\nelse:\n print('No')", "a, b, c = map(int, input().split())\nprint('Yes' if a <= c <= b else 'No')", "a, b, c=map(int, input().split())\nif a<=c<=b:\n print('Yes')\nelse:\n print('No')", "A,B,C = map(int,input().split())\nprint(\"Yes\") if A<=C<=B else print(\"No\")", "a,b,c=map(int, input().split())\nprint(\"Yes\" if a<=c<=b else \"No\")", "A, B, C = list(map(int, input().split()))\nif A <= C <= B:\n print('Yes')\nelse:\n print('No')", "a,b,c = [int(x) for x in input().split()]\nif a <= c <= b:\n print(\"Yes\")\nelse:\n print(\"No\")", "A, B, C = list(map(int, input().split()))\n\nif A <= C <= B:\n print('Yes')\nelse:\n print('No')\n", "a,b,c=map(int,input().split())\n\nif c>=a and c<=b:\n ans=\"Yes\"\nelse:\n ans=\"No\"\nprint(ans)", "A, B, C = map(int, input().split())\n\nif (C >= A) and (C <= B):\n print( \"Yes\" )\nelse :\n print( \"No\" )", "A, B, C = map(int,input().split())\nprint(\"Yes\" if A <= C <= B else \"No\")", "A,B,C = map(int, input().split())\nprint('Yes' if A<=C<=B else 'No')", "a, b, c = map(int, input().split())\n\nif a <= c <= b:\n print('Yes')\nelse:\n print('No')", "a,b,c = map(int,input().split())\n\nif a<= c and b>=c:\n print('Yes')\nelse:\n print('No')", "A, B, C = map(int, input().split())\n\nif C >= A and C <= B:\n print('Yes')\nelse:\n print('No')", "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 a, b, c = MI()\n if a <= c and c <= b:\n print('Yes')\n else:\n print('No')\n\ndef __starting_point():\n main()\n__starting_point()", "# 061a\n\nA, B, C = list(map(int, input().split()))\n\nif C >= A and C <= B:\n print('Yes')\nelse:\n print('No')\n", "a = list(map(int,input().split()))\n\nprint('Yes' if a[0] <= a[2] <= a[1] else 'No')", "A,B,C=map(int,input().split())\nif (C>=A) & (C<=B):\n print(\"Yes\")\nelse:\n print(\"No\")", "a,b,c=map(int,input().split())\nif a<=c and c<=b:\n print(\"Yes\")\nelse:\n print(\"No\")", "A,B,C = map(int,input().split())\nprint(['No','Yes'][C>=A and B>=C])", "#\n# abc061 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 = \"\"\"1 3 2\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"6 5 4\"\"\"\n output = \"\"\"No\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"2 2 2\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n A, B, C = list(map(int, input().split()))\n if A <= C <= B:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "a, b, c = map(int, input().split())\nif a <= c <= b:\n print(\"Yes\")\nelse:\n print(\"No\")", "A,B,C = map(int,input().split())\n\nif A <= C <= B:\n print(\"Yes\")\nelse:\n print(\"No\")", "A, B, C = map(int,input().split())\n\nif B >= C >= A:\n print(\"Yes\")\nelse:\n print(\"No\")", "A,B,C = list(map(int, input().split()))\n\nif C >= A and C <= B:\n print(\"Yes\")\nelse:\n print(\"No\")", "# \u5165\u529b\nA, B, C = map(int, input().split())\n\n# \u51fa\u529b\nif -100 <= A and B and C <= 100:\n if C >= A and C <= B:\n print('Yes')\n else:\n print('No')", "a,b,c = map(int,input().split())\nif c >= a and c <= b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = list(map(int, input().split()))\n\nif (c >= a) and (c <= b):\n print('Yes')\nelse:\n print('No')\n", "A, B, C = map(int, input().split())\nif C >= A and C <= B:\n print(\"Yes\")\nelse:\n print(\"No\")", "# \u5165\u529b\nA, B, C =map(int,input().split())\n\n# \u51e6\u7406\nif C >=A and C <= B:\n print('Yes')\nelse:\n print('No')", "A, B, C = map(int,input().split())\nif (C>=A) and (C<=B):\n print('Yes')\nelse:\n print('No')", "a, b, c = map(int,input().split())\nprint('Yes') if a <= c <= b else print('No')\n", "S_list = list(map(int,input().split()))\n\nif S_list[1] - S_list[0] >= 0 and S_list[2]- S_list[0] >=0 and S_list[1] - S_list[2] >=0:\n result = \"Yes\"\nelse:\n result = \"No\"\nprint(result)\n", "a,b,c = map(int,input().split())\nprint(\"Yes\" if c>=a and c<=b else \"No\")", "a,b,c = map(int, input().split())\nif a <= c and c <= b:\n print('Yes')\nelse:\n print('No')", "a, b, c = list(map(int, input().split()))\nif a <= c <= b:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "#n = int(input())\na, b, c = 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 <= c <= b:\n print('Yes')\nelse:\n print('No')\n", "a,b,c = map(int,input().split())\nif a<=c<=b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a = list(map(int,input().split()))\n# b = list(map(int,input().split()))\n\nif a[0]<=a[2]<=a[1]:\n print(\"Yes\")\nelse:\n print(\"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############################################################\nA, B, C = lint()\nprint('Yes' if A <= C <= B else 'No')", "# A - Between Two Integers\n\n# \u6574\u6570A,B,C\u304c\u5165\u529b\u3055\u308c\u308b\n# C\u304cA\u4ee5\u4e0a\u304b\u3064B\u4ee5\u4e0b\u3067\u3042\u308b\u304b\u3092\u5224\u5b9a\u3059\u308b\n\n\nA,B,C = list(map(int,input().split()))\n\nif A<=C and B>=C:\n print('Yes')\nelse:\n print('No')\n", "a, b, c = list(map(int, input().split()))\n\nif a <= c and c <= b:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a,b,c=map(int,input().split())\nif a<=c and c<=b:\n print(\"Yes\")\nelse:\n print(\"No\")", "A, B, C = map(int, input().split())\nprint(\"Yes\" if C >= A and C <= B else \"No\")", "def iroha():\n a, b, c = list(map(int, input().split()))\n\n if a <= c and b >= c:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "# \u5165\u529b\nA, B, C = map(int, input().split())\n\n# C\u304cA\u4ee5\u4e0a\u304b\u3064B\u4ee5\u4e0b\u306a\u3089Yes\u3001\u9055\u3046\u306a\u3089No\nif A <= C <= B:\n print('Yes')\nelse:\n print('No')", "a, b, c = map(int, input().split())\nif c >= a and c <= b: print('Yes')\nelse: print('No')", "a,b,c = map(int,input().split())\nprint(\"Yes\" if a<=c<=b else \"No\")", "a=list(map(int,input().split()))\n\nif (a[2]>=a[0]) and (a[2]<=a[1]):\n print('Yes')\n \nelse:\n print('No')", "A, B, C = map(int, open(0).readline().split())\nprint('Yes' if A <= C <= B else 'No')", "a,b,c = map(int, input().split())\n\nif b >= c >= a:\n print(\"Yes\")\nelse:\n print(\"No\")", "'''\nabc061 A - Between Two Integers\nhttps://atcoder.jp/contests/abc061/tasks/abc061_a\n'''\n\ni = list(map(int, input().split()))\nif i[2] >= i[0] and i[1] >= i[2]:\n ans = 'Yes'\nelse:\n ans = 'No'\nprint(ans)\n", "a, b, c = map(int, input().split())\n\nif c>=a and c<=b:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c = map(int, input().split())\nif c >= a and c <= b:\n print('Yes')\nelse:\n print('No')", "A, B, C = map(int, input().split())\n\nif A <= C <= B:\n print('Yes')\nelse:\n print('No')", "a,b,c=map(int,input().split())\nprint(\"Yes\" if a<=c<=b else \"No\")"]
{"inputs": ["1 3 2\n", "6 5 4\n", "2 2 2\n"], "outputs": ["Yes\n", "No\n", "Yes\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,742
f6cac25b5a2a9bcebb7ba77f3bdd1c50
UNKNOWN
Akaki, a patissier, can make N kinds of doughnut using only a certain powder called "Okashi no Moto" (literally "material of pastry", simply called Moto below) as ingredient. These doughnuts are called Doughnut 1, Doughnut 2, ..., Doughnut N. In order to make one Doughnut i (1 ≀ i ≀ N), she needs to consume m_i grams of Moto. She cannot make a non-integer number of doughnuts, such as 0.5 doughnuts. Now, she has X grams of Moto. She decides to make as many doughnuts as possible for a party tonight. However, since the tastes of the guests differ, she will obey the following condition: - For each of the N kinds of doughnuts, make at least one doughnut of that kind. At most how many doughnuts can be made here? She does not necessarily need to consume all of her Moto. Also, under the constraints of this problem, it is always possible to obey the condition. -----Constraints----- - 2 ≀ N ≀ 100 - 1 ≀ m_i ≀ 1000 - m_1 + m_2 + ... + m_N ≀ X ≀ 10^5 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N X m_1 m_2 : m_N -----Output----- Print the maximum number of doughnuts that can be made under the condition. -----Sample Input----- 3 1000 120 100 140 -----Sample Output----- 9 She has 1000 grams of Moto and can make three kinds of doughnuts. If she makes one doughnut for each of the three kinds, she consumes 120 + 100 + 140 = 360 grams of Moto. From the 640 grams of Moto that remains here, she can make additional six Doughnuts 2. This is how she can made a total of nine doughnuts, which is the maximum.
["n,x=list(map(int,input().split()))\ny = [int(input()) for i in range(n)]\ny.sort()\nc = 0\nfor i in range(n):\n if c < x:\n c +=y[i]\n elif c > x:\n print((i-1))\n return\nd = sum(y)\nprint((((x-d)//y[0])+n))\n", "n,x=map(int,input().split())\na=[]\nfor i in range(n):\n m=int(input())\n a.append(m)\n x-=m\nwhile x>=min(a):\n x-=min(a)\n n+=1\nprint(n)", "n, x = map(int, input().split())\nm = [0] * n\nfor i in range(n): m[i] = int(input())\nfor i in range(n): x -= m[i]\nm.sort()\nans = n + x // m[0]\nprint(ans)", "n, x = map(int, input().split())\nm = [int(input()) for _ in range(n)]\nprint(n + (x - sum(m)) // min(m))", "import math\n# a=int(input())\n# b=input()\n# c=[]\n# for i in b:\n# c.append(i)\ne = list(map(int,input().split()))\n#f = list(map(int,input().split()))\nj = [int(input()) for _ in range(e[0])]\na = sum(j)\ncount=e[0]\nif a==e[1]:\n count+=0\nelse:\n count+=(e[1]-a)//min(j)\nprint(count)", "# -*- coding: utf-8 -*-\n\nN,X = map(int, input().split())\nmin_req = 0\nfor i in range(N):\n m = int(input())\n min_req += m\n if i==0:\n m_min = m\n else:\n if m_min > m:\n m_min = m\n\nnum = N + ((X - min_req) // m_min)\nprint(num)", "from typing import List\n\n\ndef answer(n: int, x: int, m: List[int]) -> int:\n x -= sum(m)\n count = len(m)\n count += x // min(m)\n\n return count\n\n\ndef main():\n n, x = map(int, input().split())\n m = [int(input()) for _ in range(n)]\n print(answer(n, x, m))\n\n\ndef __starting_point():\n main()\n__starting_point()", "N,X=list(map(int,input().split()))\nl=[int(input()) for i in range(N)]\nX-=sum(l)\nans=len(l)\nans+=X//min(l)\nprint(ans)", "n,x = map(int,input().split())\nlst = [int(input()) for _ in range(n)]\n\nmini = min(lst)\nre = x - sum(lst)\nprint(n + re // mini)", "n,x = list(map(int,input().split()))\nl = []\nans = 0\nfor i in range(n):\n l.append(int(input()))\nx -= sum(l)\nans += n\nans += x//min(l)\nprint(ans)\n", "def main():\n array = []\n lel = input()\n lel = lel.split()\n lel[0] = int(lel[0])\n lel[1] = int(lel[1])\n quantity = 0\n\n for item in range(lel[0]):\n array.append(int(input()))\n\n for item in array:\n lel[1] -= item\n quantity += 1\n quantity += lel[1]//min(array)\n\n print(quantity)\n\ndef __starting_point():\n # execute only if run as a script\n main()\n__starting_point()", "N, X = map(int, input().split())\na = list(int(input()) for _ in range(N))\ncount = 0\n\nfor i in range(N):\n X = X - a[i]\nif X / min(a) >= 1:\n count += X // min(a)\nprint(N+count)", "import sys\nn,x=map(int,input().split())\nm=[int(input()) for i in range(n)]\n\na=sum(m)\nb=min(m)\n\nk=x-a\nc=k//b+n\n\nprint(c)", "n, k = map(int, input().split())\nm = [int(input()) for _ in range(n)]\nprint(((k - sum(m))//min(m)) + n)", "n, x = map(int, input().split())\nm_list = []\n\nfor i in range(n):\n m = int(input())\n m_list.append(m)\n\nmod = x - sum(m_list)\nans = mod // min(m_list)\nprint(ans + len(m_list))", "n, x = map(int,input().split())\nm = []\nfor i in range(n):\n a = int(input())\n x -= a\n m.append(a)\n \nans = min(m)\nx = x // ans\nprint(x+n)", "N, X = map(int, input().split())\nM = [int(input()) for _ in range(N)]\nprint(N+(X-sum(M))//min(M))", "n,x = map(int,input().split())\nm =[]\nfor _ in range(n):\n m.append(int(input()))\nprint((x - sum(m))//min(m)+n)", "n,x = map(int,input().split())\nm = list(int(input()) for i in range(n))\nm.sort()\nz = sum(m)\nprint(n+(x-z)//m[0])", "n,x=map(int,input().split())\nm=[int(input()) for _ in range(n)]\nans=(x-sum(m))//min(m)\nprint(n+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, x = Input()\n m = [int(input()) for _ in range(n)]\n ans = n\n\n x -= sum(m)\n ans += x // min(m)\n\n print(ans)\n \n\nmain()", "n,x = list(map(int,input().split()))\nans = n\nmi = 10**4\nfor i in range(n):\n m = int(input())\n x -= m\n mi = min(m,mi)\nans += (x//mi)\nprint(ans)\n \n", "n, x = list(map(int, input().split()))\nmin_m = 1000\nres = 0\nfor i in range(n):\n m = int(input())\n min_m = min(m, min_m)\n x -= m\n res += 1\n\nres += x // min_m\nprint(res)\n", "n, x = map(int, input().split())\nm = []\nfor i in range(n):\n m.append(int(input()))\nans = 0\n\nx -= sum(m)\nans += n\nans += x // min(m)\n\nprint(ans)", "n, x = list(map(int, input().split()))\n\nm = [int(input()) for _ in range(n)]\n\nm.sort()\n\nprint(n + ((x - sum(m)) // m[0]))", "n,x = map(int, input().split())\nmini = 1000\namount = 0\nans = 0\nfor _ in range(n):\n m = int(input())\n mini = min(mini, m)\n x -= m\n ans +=1\nans += x//mini\nprint(ans)", "N,X = map(int,input().split())\nminN =10**5\nfor i in range(N):\n crt = int(input())\n if minN > crt:\n minN = crt\n X -= crt\nprint(N + X//minN)", "n,x=list(map(int,input().split()))\nmi=10**5+1\ns=0\nfor _ in range(n):\n a=int(input())\n s+=a\n if a<=mi:mi=a\nprint((n+(x-s)//mi))\n", "n, x = list(map(int, input().split()))\na = []\nfor i in range(n):\n a.insert(i, int(input()))\nx_rem = x - sum(a)\nm = x_rem // min(a)\nprint(n + m)", "n,x=map(int,input().split())\n\nm=[]\nfor i in range(n):\n m.append(int(input()))\n\ncnt = (x-sum(m))//min(m)\n\nans = n + cnt\nprint(ans)", "N,X = map(int,input().split())\nm = [int(input()) for _ in range(N)]\n\ngram = X - sum(m)\nans = N + gram // min(m)\n\nprint(ans)", "N, X = list(map(int, input().split()))\nM = [0 for _ in range(N)]\nfor i in range(N):\n M[i] = int(input())\n\nX -= (sum(M))\nans = len(M)\n\nans += (X // min(M))\nprint(ans)\n", "n,x=map(int,input().split())\nsum=0\ns=1000\nfor i in range(n):\n m=int(input())\n sum+=m\n s=min(s,m)\n\ny=x-(sum)\nz=y//s\nprint(n+z)", "n, k = map(int, input().split())\nm = []\nfor i in range(n):\n m.append(int(input()))\nrest = k - sum(m)\nprint(n + rest // min(m))", "N, X = map(int, input().split())\nm = [int(input()) for i in range(N)]\nm.sort()\nnokori = X - sum(m)\nNokori = nokori // m[0]\nprint(Nokori + N)", "N, X = map(int, input().split())\nm = [int(input()) for _ in range(N)]\n\nans = N\nX -= sum(m)\n\nans += X // min(m)\nprint(ans)", "N,X=list(map(int,input().split()))\nm=[int(input()) for _ in range(N)]\nm.sort()\nprint((N+(X-sum(m))//m[0]))\n", "n, x = map(int,input().split())\nL = list(int(input()) for _ in range(n))\nm = min(L)\ntmp = x - sum(L)\nans = n\nans += tmp//m\nprint(ans)", "def resolve():\n n, x = map(int, input().split())\n ml = list()\n for i in range(n):\n m = int(input())\n ml.append(m)\n ml.sort()\n c = 0\n for g in ml:\n if x-g < 0:\n break\n else:\n c += 1\n x -= g\n a = int(x/ml[0])\n c += a\n print(c)\nresolve()", "# coding: utf-8\n\nimport math\n\nn, x = map(int, input().split())\nminimum = 1000\ntotal = 0\nfor i in range(n):\n dounats = int(input())\n total += dounats\n if dounats <= minimum:\n minimum = dounats\nnow = x - total\na = math.floor(now / minimum)\nprint(n + a)", "n,x=map(int,input().split())\nM=[int(input()) for i in range(n)]\nprint((x-sum(M))//min(M)+n)", "#!/usr/bin/env python3\n\n\ndef main():\n N, X, *M = list(map(int, open(0).read().split()))\n print((N + ((X - sum(M)) // min(M))))\n\n\nmain()\n", "n,x = [int(x) for x in input().split()]\nm = []\nfor i in range(n):\n m.append(int(input()))\nx -= sum(m)\nres = n\nres += x // min(m)\nprint(res)\n", "n,x = map(int,input().split())\nm = [int(input()) for i in range(n)]\nq = x-sum(m)\n\nprint(n + q//min(m))", "n,x=map(int,input().split())\nm=[]\nfor i in range(n):\n m.append(int(input()))\nprint((x-sum(m))//min(m)+n)", "n,x = map(int,input().split())\nlist_m = list()\nall = 0\nfor i in range(n):\n m = int(input())\n all += m\n list_m.append(m)\nprint(n + int((x - all)/min(list_m)))", "n,x=map(int,input().split())\nm=[0]*n\nfor i in range(n):\n m[i]=int(input())\nx-=sum(m)\nprint(len(m)+x//min(m))", "n,x=map(int, input().split())\nl=[]\nfor i in range(n):\n m=int(input())\n l.append(m)\nprint(n+((x-sum(l))//min(l)))", "n,x = map(int,input().split())\nl=[]\nfor i in range(0,n):\n l.append(int(input()))\nx-=sum(l)\ncnt=x//min(l)\nprint(n+cnt)", "n,x = map(int, input().split())\nl = []\nfor i in range(n):\n l.append(int(input()))\nr = x-sum(l)\nprint(n+r//min(l))", "N, X = list(map(int, input().split()))\nM = [int(input()) for _ in range(N)]\n\nmin_M = min(M)\nsum_M = sum(M)\n\nprint((N+((X-sum_M)//min_M)))\n", "n, x = map(int, input().split())\nm = [int(input()) for _ in range(n)]\nprint(n + (x - sum(m)) // min(m))", "N,X=list(map(int,input().split()))\nryou=[]\nfor i in range(N):\n ryou.append(int(input()))\namari=X-sum(ryou)\nprint(N+amari//min(ryou))", "N,X=map(int, input().split())\nm, min_value, count, ans=[], 1000, 0, N\nfor i in range(N):\n m.append(int(input()))\n min_value = min(min_value, m[i])\n count += m[i]\nwhile True:\n if X-count >= min_value:\n count += min_value\n ans += 1\n else: break\nprint(ans)", "N,x = list(map(int,input().split()))\ndonuts = 0\ndonuts_min = 999999\ncounta = 0\n\nfor i in range(N):\n donuts = int(input())\n x -= donuts\n counta += 1\n if donuts_min >= donuts:\n \tdonuts_min = donuts\n else:\n pass\n \ncountb = x // donuts_min\nprint((counta + countb))\n", "N, X = list(map(int, input().split()))\nM = [int(input()) for _ in range(N)]\nans = N\nfor i in range(len(M)):\n X -= M[i]\nans += X // min(M)\nprint(ans)\n", "nx = list(map(int, input().split()))\nn, x = nx[0], nx[1]\nms = [int(input()) for _ in range(n)]\ndonuts = n\nx -= sum(ms)\nmin_donuts = min(ms)\nwhile x >= min_donuts:\n donuts += 1\n x -= min_donuts\n\nprint(donuts)\n", "N,X = map(int,input().split())\nmi=[int(input()) for _ in range(N)]\n \nprint(N+(X-sum(mi))//min(mi))", "n,x = map(int,input().split())\nm = [int(input()) for i in range(n)]\nm.sort()\ntemp = 0\nfor g in m:\n temp +=g\nprint((x - temp) // m[0] + len(m))", "n, x = map(int, input().split())\nm = [int(input()) for _ in range(n)]\n\nprint(n + (x-sum(m))//min(m))", "N, X = map(int, input().split())\nm = [int(input()) for i in range(N)]\n# print(m)\n\nans = 0\nX -= sum(m)\nans += N\nans += X // min(m)\nprint(ans)", "a,b=input().split()\na=int(a)\nb=int(b)\nc=[int(input()) for i in range(a)]\nc.sort()\nprint(a+int((b-sum(c))/c[0]))", "n,x=map(int,input().split())\na=[int(input()) for i in range(n)]\nmoney = sum(a)\nx -= money\nm = min(a)\ncnt = len(a)\nwhile 0 <= x:\n x -= m\n cnt += 1\nprint(cnt -1)", "n,x=list(map(int ,input().split()))\nsample_gram=0\nl1=[]\nfor i in range(0,n):\n m=int(input())\n sample_gram+=m\n l1.append(m)\n\nif(sample_gram > x):\n noofdonut=(sample_gram//x)\n print(int(noofdonut))\nelif(sample_gram==x):\n print(int(sample_gram/m))\nelif(sample_gram < x):\n initial_donut=n\n reamaning_gram=x-sample_gram\n l=[]\n for j in range(0,n):\n a=reamaning_gram/l1[j]\n l.append(int(a))\n\n print(initial_donut+int(max(l)))", "a,b = map(int,input().split())\nc = [int(input()) for i in range(a)]\nprint(a+((b-(sum(c)))//min(c)))", "n, x = map(int, input().split())\nm = [int(input()) for _ in range(n)]\nprint(n + (x - sum(m)) // min(m))", "n, x = list(map(int, input().split()))\nm = []\nfor _ in range(n):\n m.append(int(input()))\nm.sort()\n\ndef main():\n for i in range(n):\n if sum(m[0:i+1]) > x:\n print(i)\n return\n print(n)\n\nif sum(m) > x:\n main()\nelse:\n print((n + (x - sum(m)) // m[0]))\n", "n, x = [int(elem) for elem in input().split()]\n\nms = []\nfor i in range(n):\n m = int(input())\n ms.append(m)\n\nres = len(ms)\nx -= sum(ms)\nres += x // min(ms)\nprint(res)", "N, X = map(int, input().split())\nm_list = [int(input()) for i in range(N)]\n\ndonatu = 0\n\n# \u3068\u308a\u3042\u3048\u305am_list\u306e\u5408\u8a08\u3092X\u304b\u3089\u5f15\u304f\nsum_m_list = sum(m_list)\nX_nokori = X - sum_m_list\ndonatu += N\n\n# \u305d\u306e\u5f8cm_list\u306e\u6700\u5c0f\u5024\u3068\u6b8b\u3063\u305fX\u3067\u5272\u308a\u7b97\ndonatu = donatu + X_nokori // min(m_list)\n\nprint(donatu)", "N,X=map(int,input().split())\nm=[]\nfor i in range(N):\n m.append(int(input()))\nprint(len(m)+int((X-sum(m))/min(m)))", "n, x = (int(i) for i in input().split())\nlist_m = [int(input()) for i in range(0, n)]\ntmp = x - sum(list_m)\nprint(n + tmp // min(list_m))", "lst = input().split()\nN = int(lst[0])\nX = int(lst[1])\nlst = []\nfor i in range(N):\n lst.append(int(input()))\n\ncount = N\nX -= sum(lst)\n\ncount += (X // min(lst))\n\nprint(count)", "n,x = map(int,input().split())\nm = [int(input()) for _ in range(n)]\nprint((x-sum(m))//min(m)+n)", "n, x = map(int, input().split())\nm = [int(input()) for _ in range(n)]\n\nprint(n + (x - sum(m)) // min(m))", "# B\nn, x = map(int,input().split())\nmin_m=1000\ncount=0\nfor _ in range(n):\n m=int(input())\n min_m=min(min_m,m)\n x-=m\n count+=1\n\ncount+=x//min_m\nprint(count)", "N, X = list(map(int, input().split()))\nms = [int(input()) for i in range(N)]\nprint((N + (X - sum(ms)) // min(ms)))\n", "n, x = input().split(\" \")\nn = int(n)\nx = int(x)\n\nd = 0\nm = []\n\nfor i in range(n):\n m.append(int(input()))\nm.sort()\n\nfor i in range(n):\n if(x >= m[i]):\n d+=1\n x -= m[i]\n\nif x > m[0]:\n res = int(x/m[0])\n d += res\nprint(d)\n", "n,x=map(int,input().split())\ns=0\nl=1000\nfor i in range(n):\n m=int(input())\n s += m\n if m<l:\n l=m\nx -= s\nx //= l\nprint(n+x)", "N, X = [int(i) for i in input().split()]\nM = [int(input()) for _ in range(N)]\nprint((N + ((X - (sum(M))) // min(M))))\n", "N,X=list(map(int,input().split()))\n\nm=[]\n\nfor i in range(N):\n m.append(int(input()))\n\nprint(((X-sum(m))//min(m)+N))\n", "n,x = map(int,input().split())\nl = sorted([int(input()) for i in range(n) ])\nx-= sum(l)\nans = n\nans += x//l[0]\nprint(ans)", "n, x = map(int, input().split())\nm = []\nfor _ in range(n):\n m.append(int(input()))\ncount = 0\nx -= sum(m)\ncount += len(m)\nwhile x >= min(m):\n x -= min(m)\n count += 1\nprint(count)", "n,x=map(int,input().split())\n\nm=[0]*n\n\nfor i in range(n):\n m[i]=int(input())\n x-=m[i]\n\nprint(n+x//min(m))", "n, x = list(map(int, input().split()))\nm = []\nfor _ in range(n):\n m.append(int(input()))\n\na = 0\n\nfor i in m:\n x -= i\n a+=1\n\nwhile x >= min(m):\n x -= min(m)\n a+=1\n\nprint(a)\n", "N,X=map(int,input().split())\nsweet=[0]*N\nfor l in range(N):\n sweet[l]=int(input())\nS=sum(sweet)\nR=X-S\nA=min(sweet)\nC=R//A\nprint(N+C)", "n,x=map(int, input().split()) \nm=[int(input()) for i in range(n)]\nprint((x-sum(m))//(min(m))+n)", "n, x = map(int, input().split())\nm = []\nfor i in range(n):\n m.append(int(input()))\n x -= m[i]\n\ncounter = len(m)\nwhile(1):\n if x < 0:\n print(counter - 1)\n break\n else:\n x -= min(m)\n counter += 1", "n,x=map(int,input().split())\nm=[int(input()) for i in range(n)]\nres=n\nx-=sum(m)\nres+=x//min(m)\nprint(res)", "n,x = map(int,input().split())\nm = [int(input()) for _ in range(n)]\nprint(n+(x-sum(m))//min(m))", "n , x = map(int,input().split())\nm = [int(input()) for i in range(n)]\n\nprint(n + (x - sum(m))//min(m))", "N, X = map(int, input().split())\ndonut_list = []\nfor i in range(N):\n donut_list.append(int(input()))\n\ndonut_sum = sum(donut_list)\nX_remaining = X - donut_sum\ndonut_num = N\ndonut_num += int(X_remaining / min(donut_list))\n\nprint(donut_num)", "n,x = map(int,input().split())\nli = []\nfor i in range(n):\n li.append(int(input()))\nn1 = sum(li)\nn2 = min(li)\nn3 = len(li)\nprint(n3 + (x-n1)//n2)", "N, X = list(map(int, input().split()))\na = [int(input()) for _ in range(N)] \nsum_material = sum(a)\nb = min(a)\ncount = 0\nX = X - sum_material\nif X < b:\n print((len(a)))\nelse:\n while X >= b:\n X -= b\n count += 1\n print((len(a) + count))\n\n", "n,x=list(map(int ,input().split()))\nsample_gram=0\nl1=[]\nfor i in range(0,n):\n m=int(input())\n sample_gram+=m\n l1.append(m)\n\nif(sample_gram > x):\n noofdonut=(sample_gram//x)\n print(int(noofdonut))\nelif(sample_gram==x):\n print(int(sample_gram/m))\nelif(sample_gram < x):\n initial_donut=n\n reamaning_gram=x-sample_gram\n l=[]\n for j in range(0,n):\n a=reamaning_gram/l1[j]\n l.append(int(a))\n\n print(initial_donut+int(max(l)))", "n,x = map(int, input().split())\nm = [int(input()) for i in range(n)]\nm.sort()\nx = x-sum(m)\nprint(len(m)+x//m[0])", "n, x = map(int, input().split())\nm = [int(input()) for i in range(n)]\nprint(len(m) + (x - sum(m)) // min(m))", "n, x, *a = map(int, open(0).read().split())\nprint(n + (x - sum(a)) // min(a))", "n,x = map(int, input().split())\nm = [int(input()) for m in range(n)]\nprint(len(m)+(x-sum(m))//min(m))", "n,x=map(int,input().split())\ns=[int(input())for _ in range(n)]\np=(x-sum(s))//min(s)\nprint(p+n)"]
{"inputs": ["3 1000\n120\n100\n140\n", "4 360\n90\n90\n90\n90\n", "5 3000\n150\n130\n150\n130\n110\n"], "outputs": ["9\n", "4\n", "26\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
17,041
4a26cb7bcc739c50f2eca19739b7caae
UNKNOWN
You drew lottery N times. In the i-th draw, you got an item of the kind represented by a string S_i. How many kinds of items did you get? -----Constraints----- - 1 \leq N \leq 2\times 10^5 - S_i consists of lowercase English letters and has a length between 1 and 10 (inclusive). -----Input----- Input is given from Standard Input in the following format: N S_1 : S_N -----Output----- Print the number of kinds of items you got. -----Sample Input----- 3 apple orange apple -----Sample Output----- 2 You got two kinds of items: apple and orange.
["n=int(input())\nstring_list=[input() for i in range(n)]\ncount = len(set(string_list))\nprint(count)", "def resolve():\n n = int(input())\n s = [input() for _ in range(n)]\n print(len(set(s)))\nresolve()", "N = int(input())\nmyset = set([])\nfor i in range(N):\n S = input()\n myset.add(S)\nprint((len(myset)))\n", "N,*S=open(0);print(len(set(S)))", "N = int(input())\n\nmono = []\n\nfor i in range(N):\n S = input()\n mono.append(S)\n\nprint((len(set(mono))))\n", "n = int(input())\n\n\nl = []\nfor i in range(n):\n x =input() \n l.append(x)\n \ns = set(l) \n\nprint(len(s))", "N = int(input())\ns = [0] * N\n\nfor i in range(N):\n s[i] = input()\n\n\nd = set()\nfor v in s:\n d.add(v)\n\nprint((len(d)))\n\n", "n = int(input())\n\nans = []\n\nfor i in range(n):\n ans.append(input())\n\nprint(len(set(ans)))", "import collections\n\nN = int(input())\nS = [input() for _ in range(N)]\n\nc = collections.Counter(S)\n\nprint(len(list(c.keys())))", "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 = len(tmp)\n\nprint(res)\n", "n = int(input())\ns = []\nfor i in range(n):\n a = input()\n s += [a]\nprint(len(set(s)))", "N = int(input())\nse = set()\nfor i in range(N):\n set.add(se, input())\nprint((len(se)))\n", "import sys\n\nN = int(input())\nreward = set()\nfor i in range(N):\n S = input()\n reward.add(S)\n\nprint(len(reward))", "from typing import Set\n\n\ndef answer(n: int, s: Set[str]) -> int:\n return len(s)\n\n\ndef main():\n n = int(input())\n s = set(input() for _ in range(n))\n print((answer(n, s)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nS = set()\nfor _ in range(N):\n S.add(input())\nprint(len(S))\nreturn", "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 = i_input()\nss=[input() for _ in range(n)]\npr=set(ss)\nprint((len(pr)))\n\n", "print(len(set([input() for i in range(int(input()))])))", "N = int(input())\nS = set(input() for i in range(N))\n\nprint(len(S))", "N = int(input())\nS = [input() for i in range(N)]\n\nS = set(S)\n\nprint(len(S))", "N = int(input())\nS = []\nfor i in range(N):\n s = str(input())\n S.append(s)\n\nT = set(S)\nprint(len(T))", "n = int(input())\nprint(len(set([input() for i in range(n)])))", "N = int(input())\ngacha = set()\nfor _ in range(N):\n gacha.add(input())\nprint(len(gacha))", "n = int(input())\nL = list(input() for _ in range(n))\nUL = set(L)\nprint(len(UL))", "N=int(input())\nS=[]\nfor i in range(N):\n S.append(input())\nS=set(S)\nprint(len(S))", "n = int(input())\nl=[]\nfor i in range(n):\n l.append(input())\nl=set(l) \nprint(len(l))", "n = int(input())\na = []\n\nfor i in range(n):\n a.append(input())\n\na.sort()\nans = 1\n\nfor i in range(n-1):\n if a[i] != a[i+1]:\n ans += 1\n\nprint(ans)\n", "# ABC 164 C\nN = int(input())\ndic = {}\nfor i in range(N):\n s = str(input())\n if s not in dic:\n dic[s] = 'o'\nprint(len(dic))", "def __starting_point():\n\n n = int(input())\n ans = set()\n for s in range(n):\n cmd = input()\n ans.add(cmd)\n print((len(ans)))\n\n__starting_point()", "N = int(input())\n\nword_list = []\n\nfor i in range(N):\n word_list.append(input())\n\nprint(len(set(word_list)))", "N=int(input());print(len(set(input()for _ in[0]*N)))", "n=int(input())\na=set()\nfor i in range(n):\n b=input()\n a.add(b)\nprint(len(a))", "N = int(input())\nS = []\nfor i in range(N):\n S.append(str(input()))\n\nS.sort()\nans = 1\nfor i in range(N-1):\n if S[i] != S[i+1]:\n ans += 1\n\nprint(ans)\n\n", "print(len(set(input() for _ in range(int(input())))))", "N = int(input())\nse = set()\nfor i in range(N):\n se.add(input())\nprint((len(se)))\n", "n = int(input())\ns = [''] * n\nfor i in range(n):\n s[i] = input()\nprint((len(set(s))))\n", "n = int(input())\ns = []\nfor i in range(n):\n s.append(input())\nprint(len(set(s)))", "n = int(input())\ns = [input() for i in range(n)]\n\ns = set(s)\nprint((len(s)))\n", "N = int(input())\nd = {}\n\nfor i in range(N):\n d[input()] = 1\n\nprint(len(d))", "import collections\n\nn = int(input())\n\nss = [input() for i in range(n)]\nc = collections.Counter(ss)\nprint(len(c))", "n = int(input())\ns = set()\nfor i in range(n):\n s.add(input())\nprint((len(s)))\n", "N = int(input())\narray = [input() for i in range(N)]\narray = set(array)\nprint( len(array) )", "n = int(input())\nkeihin = {}\nfor i in range(n):\n moji = str(input())\n keihin.setdefault(moji,0)\n keihin[moji]+=1\nprint(len(keihin.keys()))", "N = int(input())\nS = [None] * N\nfor i in range(N):\n S[i] = input()\n\nS = set(S)\nprint((len(S)))\n", "from collections import Counter\n\nN = int(input())\nS = []\n\nfor i in range(N):\n s = input()\n S.append(s)\n\nS = Counter(S)\nprint(len(S))", "N = int(input())\nS = [str(input()) for i in range(N)]\ngocha = {}\nfor s in S:\n gocha[s] = 1\nprint(len(gocha))", "#ABC164\nN=int(input())\na = []\nfor i in range(N):\n a_temp = input()\n a.append(a_temp)\nprint(len(set(a)))", "N = int( input() )\n\ndics = {}\n\nfor _ in range(N):\n s = input()\n if s in dics:\n dics[s] += 1\n else:\n dics[s] = 1\nprint( len( dics.keys() ) )", "n = int(input())\ns = [input() for _ in range(n)] #\u30ea\u30b9\u30c8\u5185\u5305\u8868\u8a18\n\nss = set(s)\nans = len(ss)\nprint(ans)", "N = int(input())\npriseset = set()\nfor i in range(N):\n prise = input()\n priseset.add(prise)\nprint(len(priseset))", "def main():\n n = int(input())\n seen = []\n for i in range(n):\n item = input()\n seen.append(item)\n return len(list(set(seen)))\n\n\ndef __starting_point():\n print((main()))\n\n__starting_point()", "n = int(input())\ngacha = set()\n\nfor i in range(n):\n s = input()\n gacha.add(s)\n\nprint((len(gacha)))\n", "N = int(input())\nS = set()\nfor _ in range(N):\n s = input()\n S.add(s)\nprint(len(S))", "n = int(input())\nl=[]\nfor i in range(n):\n l.append(input())\nl=set(l) \nprint(len(l))", "n = int(input())\ndic = {}\nans = 0\n\nfor _ in range(n):\n x = input()\n if x not in dic:\n ans += 1\n dic[x] = 1\n\n\nprint(ans)", "n = int(input())\n\ns = [input() for _ in range(n)]\n\nprint((len(set(s))))\n\n", "n = int(input())\na = set()\nfor i in range(0, n):\n lst = input()\n a.add(lst)\n\nprint(len(a))", "import numpy as np\n\nN = int(input())\ndata_list = []\nfor i in range(N):\n si = input()\n data_list.append(si)\n\ndata_list = np.array(data_list)\nprint((len(np.unique(data_list))))\n\n", "n = int(input())\ns = [input() for _ in range(n)]\n\nprint((len(list(set(s)))))\n", "N = int(input())\n\nprise = []\nfor _ in range(N):\n prise.append(input())\n\nprise = list(set(prise))\nprint(len(prise))", "def gacha():\n N = int(input())\n S = {input() for i in range(N)}\n print(len(S))\n\ngacha()", "N = int(input())\n\n\nset_list = {}\n\nfor i in range(N):\n s = input()\n set_list[s] = True\nprint(len(set_list.keys()))", "n = int(input())\ns = set()\nfor i in range(n):\n s.add(input())\nprint(len(s))", "def __starting_point():\n\n n = int(input())\n A = []\n\n for _ in range(n):\n A.append(input())\n\n A.sort()\n\n ans = 1\n for i in range(n-1):\n if A[i] != A[i+1]:\n ans += 1\n print(ans)\n\n__starting_point()", "n = int(input())\n\nl = [''] * n\n\nfor i in range(n):\n l[i] = input()\n\nprint((len(list(set(l)))))\n", "N = int(input())\nS = {input() for _ in range(N)}\n\nprint((len(S)))\n", "n = int(input())\nd = {}\nfor _ in range(n):\n s = input()\n if not s in d.keys():\n d[s] = 1\nprint(len(d))", "# C\nfrom collections import Counter\n\nN = int(input())\nS = [input() for _ in range(N)]\n\ncounter = Counter(S)\n\nprint((len(list(counter.keys()))))\n\n", "import sys\nimport math\nfrom collections import defaultdict, deque, Counter\nfrom copy import deepcopy\nfrom bisect import bisect, bisect_right, bisect_left\nfrom heapq import heapify, heappop, heappush\n \ninput = sys.stdin.readline\ndef RD(): return input().rstrip()\ndef F(): return float(input().rstrip())\ndef I(): return int(input().rstrip())\ndef MI(): return map(int, input().split())\ndef MF(): return map(float,input().split())\ndef LI(): return list(map(int, input().split()))\ndef TI(): return tuple(map(int, input().split()))\ndef LF(): return list(map(float,input().split()))\ndef Init(H, W, num): return [[num for i in range(W)] for j in range(H)]\n \n \ndef main():\n N = I()\n D = defaultdict(int)\n ans = 0\n for i in range(N):\n temp = input().rstrip()\n if D[temp] == 0:\n D[temp]=1\n ans += 1\n print(ans)\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\na = {}\nfor i in range(n):\n s = input()\n if s not in a:\n a[s] = 1\n else:\n a[s] += 1\nprint(len(a))", "N = int(input())\nans = set()\nfor i in range(N):\n ans.add(input())\nprint(len(ans)) ", "import collections\nN = int(input())\na = [input() for i in range(N)]\nc = collections.Counter(a)\nprint((len(c)))\n", "N = int(input())\nS = set([input() for _ in range(N)])\n\nprint(len(S))", "n=int(input())\na=[]\nfor i in range(n):\n s=input()\n a.append(s)\nb=set(a)\nprint(len(b))", "n = int(input())\nunique_items = set()\nfor i in range(n):\n s = input()\n unique_items.add(s)\nprint((len(unique_items)))\n", "N = int(input())\nS = []\nfor i in range(N):\n s = str(input())\n S.append(s)\nT = set(S)\nprint(len(T))", "N = int(input())\nS = sorted([input() for _ in range(N)])\nans = 1\nfor i in range(N-1):\n if(S[i] != S[i+1]):\n ans += 1\nprint(ans)", "N=int(input())\ns=set()\nfor _ in range(N):\n S=input()\n s|={S}\nprint((len(s)))\n", "n = int(input())\nans = set()\nfor i in range(n):\n ans.add(input())\nprint(len(ans))", "N = int(input())\nS = set()\ncount = 0\nfor _ in range(N):\n s = input()\n S.add(s)\nprint(len(S))", "n=int(input())\nl=[]\nfor i in range(n):\n l.append(input())\n \nprint(len(set(l)))", "N = int(input())\nS = [input() for _ in range(N)]\n\ndic = {}\nfor i in range(N):\n dic[S[i]] = 0\n\nprint((len(list(dic.keys()))))\n", "n= int(input())\nresult_dict = {}\nfor i in range(n):\n n = input()\n if n in result_dict.keys():\n result_dict[n] += 1\n else:\n result_dict[n] = 0\nprint(len(result_dict.keys()))", "n = int(input())\nans = set()\nfor _ in range(n):\n ans.add(input())\nprint(len(ans))", "N=int(input())\nS=[input() for i in range(N)]\nprint(len(set(S)))", "n=int(input())\ns=[input() for _ in range(n)]\ns.sort()\ncount=1\nfor i in range(n-1):\n if s[i]!=s[i+1]:\n count+=1\nprint(count)", "n = int(input())\ns = [input() for i in range(n)]\n\na = set(s)\nprint((len(a)))\n", "N = int(input())\nS = [input() for i in range(N)]\nlist(set(S))\nprint(len(set(S)))", "n=int(input())\ns=[input() for i in range(n)]\n\ns=set(s)\ns=list(s)\nprint(len(s))", "n=int(input())\ns=set()\nfor i in range(n):\n s.add(input())\n\nprint(len(s))", "N = int(input())\nS = [input() for _ in range(N)]\n\nprint(len(set(S)))", "n=int(input())\na=set()\nfor i in range(n):\n b=input()\n a.add(b)\nprint(len(a))", "n = int(input())\nd = {}\nfor i in range(n):\n s = input()\n d[s] = d.get(s, 0) + 1\nprint(len(d))", "n = int(input())\ns = [input() for i in range(n)]\nans = set(s)\nprint(len(ans))", "from collections import Counter\n\nn = int(input())\n\nstring = [input() for i in range(n)]\n\nstring.sort()\n\ni = Counter(string)\n\nprint((len(i)))\n", "n=int(input())\nS=[]\nfor i in range(n):\n S.append(input())\nprint((len(list(set(S)))))\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect\n#from operator import itemgetter\n#from heapq import heappush, heappop\n#import numpy as np\n#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson\n#from scipy.sparse import csr_matrix\n#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN\nimport sys\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nnf = lambda: float(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnb = lambda: list(map(float, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nN = ni()\nd = {}\nfor i in range(N):\n S = ns()\n if S not in d.keys():\n d[S] = 1\n else:\n d[S] += 1\nprint(len(d))", "N = int(input())\nS = []\nfor _ in range(N):\n S.append(input())\nans = set(S)\nprint(len(ans))", "n = int(input())\ns = list(input() for _ in range(n))\nkeihin = set()\nfor i in s:\n keihin.add(i)\nprint(len(keihin))"]
{"inputs": ["3\napple\norange\napple\n", "5\ngrape\ngrape\ngrape\ngrape\ngrape\n", "4\naaaa\na\naaa\naa\n"], "outputs": ["2\n", "1\n", "4\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,473
69581512b85e14c04554cc7c0ef53f36
UNKNOWN
In AtCoder, a person who has participated in a contest receives a color, which corresponds to the person's rating as follows: - Rating 1-399 : gray - Rating 400-799 : brown - Rating 800-1199 : green - Rating 1200-1599 : cyan - Rating 1600-1999 : blue - Rating 2000-2399 : yellow - Rating 2400-2799 : orange - Rating 2800-3199 : red Other than the above, a person whose rating is 3200 or higher can freely pick his/her color, which can be one of the eight colors above or not. Currently, there are N users who have participated in a contest in AtCoder, and the i-th user has a rating of a_i. Find the minimum and maximum possible numbers of different colors of the users. -----Constraints----- - 1 ≀ N ≀ 100 - 1 ≀ a_i ≀ 4800 - 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 possible number of different colors of the users, and the maximum possible number of different colors, with a space in between. -----Sample Input----- 4 2100 2500 2700 2700 -----Sample Output----- 2 2 The user with rating 2100 is "yellow", and the others are "orange". There are two different colors.
["n = int(input())\na = list(map(int, input().split()))\n\nans = 0\nt = 400\nwhile t < 3201:\n for i in a:\n if i >= t-400 and i < t:\n ans += 1\n break\n t += 400\n\ns = 0\nfor i in a:\n if i >= 3200: s += 1\n\nif ans == 0: print(1, s)\nelse: print(ans, ans+s)", "n=int(input())\na=list(map(int,input().split()))\ncount=0\nans=1\ncolor_lis=[0,0,0,0,0,0,0,0]\nfor i in range(n):\n if a[i]//400>=8:\n count+=1\n else:\n color_lis[a[i]//400]=1\nans=sum(color_lis)\nif count>0:\n flag=1\nelse:\n flag=0\nans1 = max(flag,ans)\nans2 = ans+count\nprint(ans1,ans2)", "n=int(input())\na=list(map(int,input().split()))\n\ncolor=[]\nfree=0\nSans,Mans=0,0\nfor i in a:\n if i//400<8 and i//400 not in color:\n color.append(i//400)\n Sans+=1\n elif i>=3200:\n free+=1\n \n#Mans=Sans\n#if free+Sans>=8:\n # Mans=8\n#else:\n # Mans=Sans+free\n\nMans=Sans+free\nif Sans==0:\n Sans=1\nprint(Sans,Mans)", "n = int(input())\na = list(map(int,input().split()))\nrate = [0,399,799,1199,1599,1999,2399,2799,3199,4800]\ncnt = [0]*9\n\nfor i in a:\n for j in range(1,len(rate)+1):\n if rate[j-1] < i <= rate[j]:\n cnt[j-1] += 1\n\nfix = 0\nflex = 0\nfor i,result in enumerate(cnt):\n if i == 8:\n flex = cnt[i]\n elif result > 0:\n fix += 1\n\nif fix == 0 and flex >= 1:\n print(1,flex)\nelse:\n print(fix,fix+flex)", "N=int(input())\nList = list(map(int, input().split()))\nsumList = [0]*8\nmid = 0\nfor i in range(N):\n if 1<=List[i]<=399:\n sumList[0] += 1\n elif 400<= List[i] <=799:\n sumList[1] += 1\n elif 800 <= List[i] <= 1199:\n sumList[2] += 1\n elif 1200<= List[i] <=1599:\n sumList[3] += 1\n elif 1600<= List[i] <=1999:\n sumList[4] += 1\n elif 2000 <= List[i] <= 2399:\n sumList[5] += 1\n elif 2400 <= List[i] <= 2799:\n sumList[6] += 1\n elif 2800 <= List[i] <= 3199:\n sumList[7] += 1\n elif 3200 <= List[i]:\n mid += 1\nres1 = 8 - sumList.count(0)\nres2 = res1 + mid\nif res1 == 0 and mid > 0:\n res1 = 1\nprint(res1,res2)", "n=int(input())\na=list(map(int,input().split()))\nl = [0]*9\ncnt = 0\nfor i in a:\n if i <400:\n l[0] +=1\n elif i<800:\n l[1] +=1\n elif i < 1200:\n l[2] +=1\n elif i<1600:\n l[3] +=1\n elif i < 2000:\n l[4] +=1\n elif i<2400:\n l[5] +=1\n elif i < 2800:\n l[6] +=1\n elif i<3200:\n l[7] +=1 \n else:\n l[8] +=1\nfor i in range(8):\n if l[i] >=1:\n cnt +=1\n\nif cnt == 0:\n print(1,l[8])\nelse:\n print(cnt,cnt+l[8])", "N = int(input())\na = list(map(int, input().split()))\n\ncolor = []\nrainbow = 0\n\nfor i in range(N):\n if 1 <= a[i] <= 399:\n color.append('gray')\n elif 400 <= a[i] <= 799:\n color.append('brown')\n elif 800 <= a[i] <= 1199:\n color.append('green')\n elif 1200 <= a[i] <= 1599:\n color.append('sky')\n elif 1600 <= a[i] <= 1999:\n color.append('blue')\n elif 2000 <= a[i] <= 2399:\n color.append('yellow')\n elif 2400 <= a[i] <= 2799:\n color.append('orange')\n elif 2800 <= a[i] <= 3199:\n color.append('red')\n else:\n rainbow += 1\n color.append('all')\n\nif len(set(color)) == 1 and rainbow > 0:\n mini = 1\nelif rainbow == 0:\n mini = len(set(color))\nelse:\n mini = max(1, len(set(color))-1)\n\nif rainbow > 1:\n maxi = len(set(color)) + rainbow - 1\nelse:\n maxi = len(set(color))\n\nprint(mini, maxi)", "N=int(input())\nList = list(map(int, input().split()))\nsumList = [0]*8\nmid = 0\nfor i in range(N):\n if 1<=List[i]<=399:\n sumList[0] += 1\n elif 400<= List[i] <=799:\n sumList[1] += 1\n elif 800 <= List[i] <= 1199:\n sumList[2] += 1\n elif 1200<= List[i] <=1599:\n sumList[3] += 1\n elif 1600<= List[i] <=1999:\n sumList[4] += 1\n elif 2000 <= List[i] <= 2399:\n sumList[5] += 1\n elif 2400 <= List[i] <= 2799:\n sumList[6] += 1\n elif 2800 <= List[i] <= 3199:\n sumList[7] += 1\n elif 3200 <= List[i]:\n mid += 1\nres1 = 8 - sumList.count(0)\nres2 = res1 + mid\nif res1 == 0 and mid > 0:\n res1 = 1\nprint(res1,res2)", "n = int(input())\nrate = list(map(int, input().split()))\nv = [0] * 9\n\nfor i in range(n):\n c = int(rate[i]/400)\n if c >= 8:\n v[8] += 1\n else:\n v[c] = 1\ns = sum(v[:8])\nmi = max(1, s)\nma = s+v[8]\n\nprint(mi, ma)", "N = int(input())\nR = list(map(int, input().split()))\nX = [0]*8\np = 0\nfor r in R:\n if r >= 3200:\n p += 1\n else:\n X[r//400] = 1\n\ns = sum(X)\nif s == 0:\n print((str(1) + \" \" + str(p)))\nelse:\n print((str(s) + \" \" + str(s + p)))\n", "N = int(input())\nA = list(map(int,input().split()))\nR = [0]*9\n\nfor a in A:\n if a<400:\n R[0]+=1\n elif a<800:\n R[1]+=1\n elif a<1200:\n R[2]+=1\n elif a<1600:\n R[3]+=1\n elif a<2000:\n R[4]+=1\n elif a<2400:\n R[5]+=1\n elif a<2800:\n R[6]+=1\n elif a<3200:\n R[7]+=1\n else:\n R[8]+=1\n\nif sum(R[:-1])!=0:\n M = 8-R[:-1].count(0)+R[-1]\n m = 8-R[:-1].count(0)\n print(m,M)\nelse:\n print(1,R[-1])", "#8 C - Colorful Leaderboard\nN = int(input())\na = list(map(int,input().split()))\n\nseen = [False]*8\ncnt = 0\ncnt_3200 = 0\nfor i in a:\n i = i//400\n if i >= 8:\n cnt_3200 += 1\n elif (seen[i] == False):\n cnt += 1\n seen[i] = True\n \nif cnt == 0:\n print(1,cnt_3200)\nelse:\n print(cnt,cnt+cnt_3200)", "N=int(input())\nL=list(map(int,input().split()))\nL=[i//400 for i in L]\na=[i for i in L if i<8]\nb=[i for i in L if i>7]\na=len(set(a))\nb=len(b)\nif a==0:\n mi=1\n ma=b\nelse:\n mi=a\n ma=mi+b\nprint(mi,ma)", "a=int(input())\nb=list(map(int,input().split()))\nc=0\nd=0\ne=0\nf=0\ng=0\nh=0\ni=0\nj=0\nk=0\nx=0\nfor z in range(a):\n if b[z]<=399:\n c=c+1\n if 400<=b[z]<799:\n d=d+1\n if 800<=b[z]<=1199:\n e=e+1\n if 1200<=b[z]<=1599:\n f=f+1\n if 1600<=b[z]<=1999:\n g=g+1\n if 2000<=b[z]<=2399:\n h=h+1\n if 2400<=b[z]<=2799:\n i=i+1\n if 2800<=b[z]<=3199:\n j=j+1\n if b[z]>=3200:\n k=k+1\nif c!=0:\n x=x+1\nif d!=0:\n x=x+1\nif e!=0:\n x=x+1\nif f!=0:\n x=x+1\nif g!=0:\n x=x+1\nif h!=0:\n x=x+1\nif i!=0:\n x=x+1\nif j!=0:\n x=x+1\nif k+x>a:\n print(x,a)\nelif (c+d+e+f+g+h+i+j)==0 and k!=0:\n print(1,k)\nelse:\n print(x,k+x)", "N = int(input())\nA = list(map(int, input().split()))\n\ncnt = [0]*8\nc = 0\nfor a in A:\n if a <= 399:\n cnt[0] += 1\n elif a >= 400 and a <= 799:\n cnt[1] += 1\n elif a >= 800 and a <= 1199:\n cnt[2] += 1\n elif a >= 1200 and a <= 1599:\n cnt[3] += 1\n elif a >= 1600 and a <= 1999:\n cnt[4] += 1\n elif a >= 2000 and a <= 2399:\n cnt[5] += 1\n elif a >= 2400 and a <= 2799:\n cnt[6] += 1\n elif a >= 2800 and a <= 3199:\n cnt[7] += 1\n else:\n c += 1\n \nMin = len([i for i in cnt if i != 0])\nif c == 0:\n print(Min, Min)\nelse:\n Max = Min+c\n if Min == 0:\n print(1, Max)\n else:\n print(Min, Max)", "N=int(input())\na=list(map(int,input().split()))\nans=[0 for i in range(9)]\n\nfor i in range(N):\n temp=a[i]//400\n if temp>8:\n ans[8]+=1\n else:\n ans[temp]+=1\nnin=0\nfor i in range(8):\n if ans[i]!=0:\n nin+=1\nif nin==0 and ans[8]!=0:\n nin+=1\n nax=ans[8]\nelse:\n nax=nin+ans[8]\nprint(nin,nax)", "n=int(input())\na=list(map(int,input().split()))\na1=0\nb=0\nc=0\nd=0\ne=0\nf=0\ng=0\nh=0\nans=0\nfor i in range(n):\n if 1<=a[i]<=399:\n a1=1\n elif 400<=a[i]<=799:\n b=1\n elif 800<=a[i]<=1199:\n c=1\n elif 1200<=a[i]<=1599:\n d=1\n elif 1600<=a[i]<=1999:\n e=1\n elif 2000<=a[i]<=2399:\n f=1\n elif 2400<=a[i]<=2799:\n g=1\n elif 2800<=a[i]<=3199:\n h=1\n else:\n ans+=1\n\nx=a1+b+c+d+e+f+g+h\nif a1==b==c==d==e==f==g==h==0:\n print(1,ans)\nelse:\n print(x,x+ans)", "N = int(input())\na = list(map(int, input().split()))\n\ncolor = [0]*8\nfreer=0\n\nfor i in a:\n if i<3200:\n color[i//400]+=1\n else:\n freer+=1\n \nans_base = 8-color.count(0)\n\nif ans_base==0:\n ans_min = 1\nelse:\n ans_min = ans_base\n \nans_max = ans_base+freer\n \nprint(ans_min, ans_max)", "N = int(input())\nlsa = list(map(int,input().split()))\nlsb = []\njoker = 0\nfor i in lsa:\n if i >=1 and i <=399:\n lsb.append('1')\n elif i >=400 and i <=799:\n lsb.append('2')\n elif i >=800 and i <=1199:\n lsb.append('3')\n elif i >=1200 and i <=1599:\n lsb.append('4')\n elif i >=1600 and i <=1999:\n lsb.append('5')\n elif i >=2000 and i <=2399:\n lsb.append('6')\n elif i >=2400 and i <=2799:\n lsb.append('7')\n elif i >=2800 and i <=3199:\n lsb.append('8')\n elif i >=3200:\n joker += 1\ns1 = len(set(lsb)) \ns2 = s1+joker\nprint(max(s1,1),s2)", "n = int(input())\nplayer = list(map(int, input().split()))\nresult = [0] * 8\nfree_color = 0\nfor i in range(n):\n color = player[i] // 400\n if color < 8:\n result[color] = 1\n else:\n free_color += 1\nnum = 8 - result.count(0)\nprint((\"{} {}\".format(max(num, 1), num + free_color)))\n", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 22 04:19:50 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\nA = [int(x) for x in input().split()]\nd = [False]*8\ncount = 0\nans = 0\nfor a in A:\n if a//400 >= 8:\n count += 1\n else:\n if d[a//400] == False:\n ans += 1\n d[a//400] = True\n\nif count == 0:\n print(ans,ans)\nelse:\n if ans == 0:\n print(1,count)\n else:\n print(ans,ans+count)", "n = int(input())\na = list(map(int, input().split())) \n\narr = [0] * 9\nans = [0] * 2\n\nfor i in a:\n if i//400 < 8:\n arr[i//400] = 1\n else:\n arr[8] += 1\n\nleft = sum(arr[:8])\nright = arr[8]\n\nans[0] = left\n\nif left == 0:\n ans[0] = 1\n\nans[1] = left + right\n\nprint(*ans)", "n=int(input())\na=list(map(int,input().split()))\nb=[0]*8\nc=0\nfor x in a:\n if x<400:\n b[0]=1\n elif x<800:\n b[1]=1\n elif x<1200:\n b[2]=1\n elif x<1600:\n b[3]=1\n elif x<2000:\n b[4]=1\n elif x<2400:\n b[5]=1\n elif x<2800:\n b[6]=1\n elif x<3200:\n b[7]=1\n else:\n c+=1\nx=b.count(1)\nprint(max(x,1),x+c)", "n=int(input())\na=list(map(int,input().split()))\ncolor=[]\ncount,free=0,0\n\nfor i in range(n):\n c=a[i]//400\n if a[i]<3200 and c not in color:\n color.append(c)\n count+=1\n elif a[i]>=3200:\n free+=1\n \nmin,max=0,0\nif count==0:\n max=free\n min=1\nelse:\n max=count+free\n min=count\n \nprint(min,max)", "N,*A=map(int,open(0).read().split())\n\ncolors = [0 for i in range(8)]\ntyty = 0\n\nfor a in A:\n c = a//400\n if c>=8:\n tyty+=1\n else:\n colors[c]+=1\n\ncNum = 8-colors.count(0)\n \nminC = max(cNum,1)\nmaxC = cNum+tyty\n\nprint(minC,maxC)", "N = int(input())\nA = list(map(int,input().split()))\nL = []\nH = []\n\nfor i in range(N):\n a = A[i]//400\n if a > 7:\n H.append(a)\n else:\n L.append(a)\n\nif len(L) != 0:\n print(str(len(set(L)))+\" \"+str(len(set(L))+len(H)))\nelse:\n print(\"1 \"+str(len(H)))", "N = int(input())\na = list(map(int, input().split()))\n\nc = [0] * 9\nfor i in range(N):\n if a[i] >= 3200:\n c[8] += 1\n else:\n for j in range(8):\n if 400*j <= a[i] and a[i] <= 400 * (j + 1) -1:\n c[j] = 1\n\nmin1 = max(1, sum(c[:8]))\nmax1 = sum(c)\n\nprint(min1, max1)", "#\u4e0a\u9650\u306a\u3044\u3093\u304b\u3044\n#0\u8272\u306f\u306a\u304b\u3063\u305f\n'''\nCreated on 2020/10/01\n\n@author: harurun\n'''\nimport sys\npin=sys.stdin.readline\n\ndef main():\n N=int(pin())\n a=list(map(int,pin().split()))\n d=[0]*9\n for i in a:\n if i>=3200:\n d[-1]+=1\n continue\n d[i//400]+=1\n ans=0\n for i in d[:-1]:\n if i!=0:ans+=1\n if ans==0:\n print(f\"{1} {d[-1]}\")\n return\n print(f\"{ans} {ans+d[-1]}\")\n return\nmain()\n", "with open(0) as f:\n N, *a = list(map(int, f.read().split()))\nSet = set()\nfree = 0\nfor x in a:\n x //= 400\n if x < 8:\n Set.add(x)\n else:\n free += 1\n\nAns = [max(1, len(Set)), len(Set)+free]\nprint((*Ans))\n", "n = int(input())\na = list(map(int, input().split()))\nrates = [0] * 8\ncnt = 0\n\nfor i in range(n):\n if a[i] < 3200:\n rates[a[i] // 400] += 1\n else:\n cnt += 1\n \ncn = len(rates) - rates.count(0) #color number\nif sum(rates) == 0:\n cmin = 1\nelse:\n cmin = cn #color min\n\nif all([x < 3200 for x in a]):\n cmax = cn #color max\nelse:\n cmax = cn + cnt\n \nprint(cmin,cmax)", "import math\n\nN = int(input())\nA = [math.floor(a/400) if a < 3200 else 3200 for a in list(map(int, input().split()))]\n\nset_A = set([a for a in A if a != 3200])\nprint(*[max(1, len(set_A)), len(set_A) + A.count(3200)], sep=\" \")", "from sys import stdin, stdout # only need for big input\n\ndef get_level(n):\n return min( n // 400, 8)\n\ndef solve():\n n = int(input()) \n a = list(map(int, input().split()))\n level_num = dict()\n for i in range(9):\n level_num[i] = 0\n \n for contestant in a:\n lvl = get_level(contestant)\n level_num[lvl] += 1\n\n min_num = 0\n\n for lvl in level_num:\n if level_num[lvl] > 0 and lvl < 8:\n min_num += 1\n max_num = min_num + level_num[8]\n if min_num < 1:\n min_num = 1\n # if max_num > 8:\n # max_num = 8\n\n print(min_num, max_num)\n \n\n\n \n\ndef main():\n solve()\n\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\nN_List = list(map(int,input().split()))\nNR_List = [i // 400 for i in N_List]\nNumber_NRD = len(set([i for i in NR_List if i < 8]))\nNumber_NRU = len([i for i in NR_List if i >= 8])\nmax_p= Number_NRD + Number_NRU\nmin_p= (Number_NRD,1)[Number_NRD == 0]\nprint(str(min_p) + \" \" + str(max_p))", "n = int(input())\na = sorted(map(int,input().split()))\n\nc = [0] * 9\nfor num in a:\n if num < 400:\n c[0] += 1\n elif num < 800:\n c[1] += 1\n elif num < 1200:\n c[2] += 1\n elif num < 1600:\n c[3] += 1\n elif num < 2000:\n c[4] += 1\n elif num < 2400:\n c[5] += 1\n elif num < 2800:\n c[6] += 1\n elif num < 3200:\n c[7] += 1\n else:\n c[8] += 1\nmi = 0\nma = 0\nfor i in range(8):\n if c[i] >= 1:\n mi += 1\n ma += 1\nma += c[8]\nif mi == 0:\n if c[8] >= 1:\n mi += 1\nprint((str(mi) + \" \" + str(ma)))\n\n", "def cordtest(AAA):\n jisyo ={'H':0,'C':0,'G':0,'M':0,'B':0,'Y':0,'O':0,'R':0,'A':0}\n for i in AAA:\n \n if i <= 399:\n jisyo['H'] +=1\n elif 400 <= i <=799:\n jisyo['C'] +=1\n elif 800 <= i <=1199:\n jisyo['G'] +=1\n elif 1200 <= i <=1599:\n jisyo['M'] +=1\n elif 1600 <= i <=1999:\n jisyo['B'] +=1\n elif 2000 <= i <=2399:\n jisyo['Y'] +=1\n elif 2400 <= i <= 2799:\n jisyo['O'] +=1\n elif 2800 <= i <= 3199:\n jisyo['R'] +=1\n else:\n jisyo['A'] +=1\n maxi = 0\n mini = 0\n for i,j in jisyo.items():\n \n if i != 'A':\n if j >0:\n mini +=\t1\n else:\n maxi += j\n ans = maxi + mini\n if mini ==0:\n mini =1\n \n return print(mini,ans)\nN = int(input())\nAA = list(map(int,input().split()))\ncordtest(AA)\n \n \n ", "n=int(input())\na=list(map(int,input().split()))\n\nrate=[0]*9\nover=0\n\nfor i in a:\n for j in range(1,9):\n if 400*(j-1) <= i < 400*j:\n rate[j]=1\n break\n elif i >= 3200:\n over+=1\n break\n\nansmin = rate.count(1)\nansmax = rate.count(1)\nif ansmin == 0:\n ansmin=1\n\nif over > 0:\n ansmax += over\n \n#print(rate,over)\nprint(ansmin, ansmax)", "n = int(input())\nrates = map(int,input().split())\n\ncolors = set()\nover = 0\nfor rate in rates:\n if 1<=rate and rate<=399:\n colors.add(\"1-399\")\n if 400<=rate and rate<=799:\n colors.add(\"400-799\")\n if 800<=rate and rate<=1199:\n colors.add(\"800-1199\")\n if 1200<=rate and rate<=1599:\n colors.add(\"1200-1599\")\n if 1600<=rate and rate<=1999:\n colors.add(\"1600-1999\")\n if 2000<=rate and rate<=2399:\n colors.add(\"2000-2399\")\n if 2400<=rate and rate<=2799:\n colors.add(\"2400-2799\")\n if 2800<=rate and rate<=3199:\n colors.add(\"2800-3199\")\n if 3200<=rate:\n over+=1\n\nmin=len(colors)\nmax=min+over\n# if max>8:\n# max=8\nif min==0:\n min=1\nprint(min,max)", "N = int(input())\nA = list(map(int,input().split()))\n\ncolor = [0] * 9\n\nfor a in A:\n if a <= 399:\n color[0] = 1\n elif a <= 799:\n color[1] = 1\n elif a <= 1199:\n color[2] = 1\n elif a <= 1599:\n color[3] = 1\n elif a <= 1999:\n color[4] = 1\n elif a <= 2399:\n color[5] = 1\n elif a <= 2799:\n color[6] = 1\n elif a <= 3199:\n color[7] = 1\n else:\n color[8] += 1\n \nmax_num = sum(color)\nmin_num = max(1, sum(color[:-1]))\n \nprint(min_num, max_num)", "N = int(input())\na = list(map(int, input().split()))\n\nrate = set()\nover = 0\nfor ai in a:\n if ai >= 3200:\n over += 1\n else:\n rate.add(ai // 400)\n\nL = len(rate)\nprint(max(1, L), L + over)", "N = int(input())\nrate = list(map(int,input().split()))\ncnt = 0\nans = []\nfor i in range(N):\n if rate[i] >= 3200:\n cnt += 1\n else:\n ans.append(rate[i]//400)\ns_ans = set(ans)\nprint(max(len(s_ans),1),len(s_ans)+cnt)", "n = int(input())\na = list(map(int, input().split()))\n\nupper = [399, 799, 1199, 1599, 1999, 2399, 2799,3199, 4800]\nlower = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]\n\ncnt = 0\ntops = 0\nfor color in range(9)[::-1]:\n for i in range(n):\n if color == 8:\n if lower[color] <= a[i] <= upper[color]:\n tops += 1\n else:\n if lower[color] <= a[i] <= upper[color]:\n cnt += 1\n break\n\nprint(max(1, cnt), cnt + tops)", "N = int(input())\na = list(map(int, input().split()))\n\ncolor = [0] * 9\nfor i in range(N):\n if 1<=a[i]<=399: color[0]+=1\n elif 400<=a[i]<=799: color[1]+=1\n elif 800<=a[i]<=1199: color[2]+=1\n elif 1200<=a[i]<=1599: color[3]+=1\n elif 1600<=a[i]<=1999: color[4]+=1\n elif 2000<=a[i]<=2399: color[5]+=1\n elif 2400<=a[i]<=2799: color[6]+=1\n elif 2800<=a[i]<=3199: color[7]+=1\n elif 3200<= a[i]: color[8] += 1\n\ncount = 0\nfor i in range(8):\n if color[i] != 0:\n count += 1\nif count == 0:\n print(1, count+color[8])\nelse:\n print(count, count+color[8])", "#C - Colorful Leaderboard \nN = int(input())\na = list(map(int,input().split()))\n\nmini = 0\ncolor_list = []\nfor i in a:\n if (i//400)<8 and ((i//400 in color_list) == False):\n mini += 1\n color_list.append(i//400)\n\nmaxi = mini\nfor j in a:\n if j >= 3200:\n maxi += 1\nif mini == 0:#\u5fd8\u308c\u3066\u305f\n mini = 1\nprint(mini,maxi)", "n = int(input())\na = list(map(int,input().split()))\ncolors = [\"\u7070\u8272\",\"\u8336\u8272\",\"\u7dd1\u8272\",\"\u6c34\u8272\",\"\u9752\u8272\",\"\u9ec4\u8272\",\"\u6a59\u8272\",\"\u8d64\u8272\",\"\u305d\u306e\u4ed6\"]\ndic = {}\nfor i in colors:\n dic[i] = 0\nfor i in a:\n if i < 400:\n dic[\"\u7070\u8272\"] += 1\n elif i < 800:\n dic[\"\u8336\u8272\"] += 1\n elif i < 1200:\n dic[\"\u7dd1\u8272\"] += 1\n elif i < 1600:\n dic[\"\u6c34\u8272\"] += 1\n elif i < 2000:\n dic[\"\u9752\u8272\"] += 1\n elif i < 2400:\n dic[\"\u9ec4\u8272\"] += 1\n elif i < 2800:\n dic[\"\u6a59\u8272\"] += 1\n elif i < 3200:\n dic[\"\u8d64\u8272\"] += 1\n else:\n dic[\"\u305d\u306e\u4ed6\"] += 1\n\nans1 = 0\nans2 = 0\n\nfor i in colors:\n if i == \"\u305d\u306e\u4ed6\":\n if ans1 == 0:\n ans1 = 1\n ans2 = dic[i]\n break\n ans2 += dic[i]\n continue\n if dic[i] >= 1:\n ans1 += 1\n ans2 += 1\nprint(ans1,ans2)", "n = input()\na = list(map(int,input().split()))\n\ns = set()\nb = 0\nfor i in a:\n if i < 3200:\n s.add(i//400)\n else:\n b += 1\nelse:\n min = len(s)\n print(max(min, 1), min + b)", "n = int(input())\na = list(map(int, input().split()))\n\nrate = [0] * 8\ns = 0\n\nfor i in a:\n if i < 400:\n rate[0] = 1\n elif 400 <= i < 800:\n rate[1] = 1\n elif 800 <= i < 1200:\n rate[2] = 1\n elif 1200 <= i < 1600:\n rate[3] = 1\n elif 1600 <= i < 2000:\n rate[4] = 1\n elif 2000 <= i < 2400:\n rate[5] = 1\n elif 2400 <= i < 2800: \n rate[6] = 1\n elif 2800 <= i < 3200:\n rate[7] = 1\n elif 3200 <= i:\n s += 1\n\n\n\n \nans1 = 8-rate.count(0)\nans2 = ans1+s\nif ans1 == 0 and s != 0:\n ans1 = 1\n\n\nprint(ans1, ans2)", "n = int(input())\narr = list(map(int, input().split()))\n\ncolors = [0] * 8\nover = 0\n\nfor i in arr:\n if i >= 3200:\n over += 1\n else:\n colors[i // 400] += 1\n\nres = 8 - colors.count(0)\nif res:\n print(res, res+over)\nelse:\n print(1, over)", "n = int(input())\na = list(map(int,input().split()))\n\ncnt = [0] * 9\nfor i in a:\n x = min(i // 400, 8)\n if x >= 8:\n cnt[8] += 1\n else:\n cnt[x] = 1\n\nif sum(cnt[:8]) == 0:\n l = 1\n r = cnt[8]\nelse:\n l = sum(cnt[:8])\n r = l+cnt[8]\nprint(l, r)", "n = int(input())\na = list(map(int, input().split()))\n\np = set()\nq = 0\nfor i in range(n):\n if a[i] < 3200:\n p.add(a[i]//400)\n else:\n q += 1\n\np = len(p)\nprint(max(p, 1), p+q)", "n=int(input())\na=list(map(int,input().split()))\ndata=[0]*9\nfor i in a:\n if 1<=i<=399:\n data[0]+=1\n elif 400<=i<=799:\n data[1]+=1\n elif 800<=i<=1199:\n data[2]+=1\n elif 1200<=i<=1599:\n data[3]+=1\n elif 1600<=i<=1999:\n data[4]+=1\n elif 2000<=i<=2399:\n data[5]+=1\n elif 2400<=i<=2799:\n data[6]+=1\n elif 2800<=i<=3199:\n data[7]+=1\n elif 3200<=i:\n data[8]+=1\nmin=0\nfor i in range(8):\n if data[i]!=0:\n min+=1\nif min!=0:\n print(min,min+data[8])\nelse:\n print(1,data[8])", "N = int(input())\nA = list(map(int, input().split()))\nrate = {\"a\":0, \"b\":0, \"c\":0, \"d\":0, \"e\":0, \"f\":0, \"g\":0, \"h\":0}\nratez = {\"z\":0}\nfor i in range(N):\n if A[i] >=1 and A[i] <= 399:\n rate[\"a\"] += 1\n if A[i] >=400 and A[i] <= 799:\n rate[\"b\"] += 1\n if A[i] >=800 and A[i] <= 1199:\n rate[\"c\"] += 1\n if A[i] >=1200 and A[i] <= 1599:\n rate[\"d\"] += 1\n if A[i] >=1600 and A[i] <= 1999:\n rate[\"e\"] += 1\n if A[i] >=2000 and A[i] <= 2399:\n rate[\"f\"] += 1\n if A[i] >=2400 and A[i] <= 2799:\n rate[\"g\"] += 1\n if A[i] >=2800 and A[i] <= 3199:\n rate[\"h\"] += 1\n if A[i] >=3200:\n ratez[\"z\"] += 1\nkeys = [k for k, v in rate.items() if v != 0]\n\nif ratez[\"z\"] == 0:\n print(len(keys), len(keys))\nelif len(keys) == 0:\n print(1, ratez[\"z\"])\nelse:\n print(len(keys), len(keys)+ratez[\"z\"])", "n = int(input())\nA = list(map(int, input().split()))\n\nrate = [0 for _ in range(9)]\n\nfor a in A:\n if a < 400:\n rate[0] += 1\n elif a < 800:\n rate[1] += 1\n elif a < 1200:\n rate[2] += 1\n elif a < 1600:\n rate[3] += 1\n elif a < 2000:\n rate[4] += 1\n elif a < 2400:\n rate[5] += 1\n elif a < 2800:\n rate[6] += 1\n elif a < 3200:\n rate[7] += 1\n else:\n rate[8] += 1\n\nans = 0\nfor i in range(8):\n if rate[i] >= 1:\n ans += 1\nif ans == 0:\n print(1, rate[8])\nelse:\n print(ans, ans + rate[8])", "n=int(input())\na=list(map(int,input().split()))\nb=[0]*9\nfor i in range(n):\n if a[i]<400:\n b[0]+=1\n elif a[i]<800:\n b[1]+=1\n elif a[i]<1200:\n b[2]+=1\n elif a[i]<1600:\n b[3]+=1\n elif a[i]<2000:\n b[4]+=1\n elif a[i]<2400:\n b[5]+=1\n elif a[i]<2800:\n b[6]+=1\n elif a[i]<3200:\n b[7]+=1\n else:\n b[8]+=1\n \nmin=8-b[:8].count(0)\nmax=min+b[8]\n\nif min==0:\n min=1\nprint(min,max)", "N = int(input())\nA = list(map(int, input().split()))\nB = [i // 400 for i in A if i < 3200]\nif B == []:\n print(1, N)\nelif len(B) == N:\n C = len(set(B))\n print(C, C)\nelse:\n C = len(set(B))\n D = C + N - len(B)\n print(C, D)", "import numpy as np\nN = int(input())\na = np.array(list(map(int, input().split())))\na = a // 400\n\nover_3200 = a[np.where(a>=8)]\nnum_3200 = len(over_3200)\n\na = a[np.where(a<=7)]\na_list = np.unique(a)\nlen_a = len(a_list)\n\nif len_a == 0:\n min = 1\n num_3200 -= 1\nelse:\n min = len_a\n\nmax = min + num_3200\nprint(min, max)", "N = int(input())\nrate = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]\np = [0] * 9\n\nA = [int(a) for a in input().split(\" \")]\nA.sort()\n\nj = 0\nfor i in range(len(A)):\n while j < 8:\n if rate[j] <= A[i] < rate[j + 1]:\n p[j] = 1\n break\n else:\n j += 1\n else:\n p[8] = len(A[i:])\n break\n\nprint((str(max([sum(p[:8]), 1])) + \" \" + str(sum(p))))\n", "n = int(input())\na = list(map(int,input().split()))\n\ncnt = [0] * 9\nfor i in a:\n x = min(i // 400, 8)\n if x >= 8:\n cnt[8] += 1\n else:\n cnt[x] = 1\n\nif sum(cnt[:8]) == 0:\n l = 1\n r = cnt[8]\nelse:\n l = sum(cnt[:8])\n r = l+cnt[8]\nprint(l, r)", "def color(n):\n if n < 400:\n return '\u7070'\n elif n < 800:\n return '\u8336'\n elif n < 1200:\n return '\u7dd1'\n elif n < 1600:\n return '\u6c34'\n elif n < 2000:\n return '\u9752'\n elif n < 2400:\n return '\u9ec4'\n elif n < 2800:\n return '\u6a59'\n elif n < 3200:\n return '\u8d64'\n else:\n return None\n\n\nN = int(input())\na = list(map(int, input().split()))\n\ncolors = set()\nover = 0\n\nfor c in a:\n if color(c):\n colors.add(color(c))\n else:\n over += 1\n\nprint(max(1, len(colors)), end=' ')\nprint(len(colors)+over)", "n=int(input())\nl=list(map(int,input().split()))\n\nans=[0 for i in range(8)]\nrate_3200=0\n\nfor i in l:\n if 1<=i<=399:\n ans[0]+=1\n elif 400<=i<=799:\n ans[1]+=1\n elif 800<=i<=1199:\n ans[2]+=1\n elif 1200<=i<=1599:\n ans[3]+=1\n elif 1600<=i<=1999:\n ans[4]+=1\n elif 2000<=i<=2399:\n ans[5]+=1\n elif 2400<=i<=2799:\n ans[6]+=1\n elif 2800<=i<=3199:\n ans[7]+=1\n elif 3200<=i:\n rate_3200+=1\n \nif rate_3200==0:\n num=8-ans.count(0)\n print((\"{} {}\".format(num,num)))\nelse:\n count_0=ans.count(0)\n if count_0==8:\n min_num=1\n max_num=rate_3200\n else:\n min_num=8-count_0\n max_num=8-count_0+rate_3200\n print((\"{} {}\".format(min_num,max_num)))\n", "N = int(input())\na = list(map(int, input().split()))\ncolor = set()\nrainbow = 0\n\nfor n in range(N):\n if 1 <= a[n] < 400:\n color.add(\"gray\")\n elif 400 <= a[n] < 800:\n color.add(\"brown\")\n elif 800 <= a[n] < 1200:\n color.add(\"green\")\n elif 1200<= a[n] < 1600:\n color.add(\"water\")\n elif 1600 <= a[n] < 2000:\n color.add(\"blue\")\n elif 2000 <= a[n] < 2400:\n color.add('yellow')\n elif 2400 <= a[n] < 2800:\n color.add('orange')\n elif 2800 <= a[n] < 3200:\n color.add('red')\n else:\n rainbow += 1\n\nif len(color) == 0:\n\tcolor_min = 1 \n\tcolor_max = rainbow\nelse:\n color_min = len(color)\n color_max = color_min + rainbow\n\n \nprint(f'{color_min} {color_max}')\n", "n = int(input())\nal = list(map(int, input().split()))\nratel = [0,0,0,0,0,0,0,0,0]\n\ndef check(a):\n if 1 <= a <= 399:\n return 0\n elif 400 <= a <= 799:\n return 1\n elif 800 <= a <= 1199:\n return 2\n elif 1200 <= a <= 1599:\n return 3\n elif 1600 <= a <= 1999:\n return 4\n elif 2000 <= a <= 2399:\n return 5\n elif 2400 <= a <= 2799:\n return 6\n elif 2800 <= a <= 3199:\n return 7\n else:\n return 8\n\nfor a in al:\n i = check(a)\n ratel[i] += 1\n\n\nzeroc = 0\nratec = 0\nfor i in range(8):\n if ratel[i] == 0:\n zeroc += 1\n else:\n ratec += 1\n\nif ratel[8] == 0:\n print(ratec,ratec)\nelif 1 <= ratel[8] <= 8:\n if ratec == 0:\n print(1,ratel[8])\n elif ratel[8] < zeroc:\n print(ratec, ratec+ratel[8])\n elif ratel[8] >= zeroc:\n print(ratec,ratec+ratel[8])\nelse:\n if ratec == 0:\n print(1,ratel[8])\n else:\n print(ratec,ratec+ratel[8])", "n = int(input())\na = list(map(int,input().split()))\ncnt = [0]*8\nfree = 0\nfor i in range(n):\n if a[i] <= 3199:\n cnt[a[i]//400] += 1\n else:\n free += 1\nprint(max(1,8-cnt.count(0)),8-cnt.count(0)+free)", "N = int(input())\nA = list(map(int, input().split()))\ncin = [0, 0, 0, 0, 0, 0, 0, 0]\nkin = 0\npin = 0\nflag = 0\nfor i in A:\n if i < 3200:\n cin[i//400] += 1\n pin = 1\n else:\n kin += 1\n flag = 1\nif pin == 0:\n print(1, kin)\nelse:\n print(8-cin.count(0), 8-cin.count(0)+kin)", "N=int(input())\na=list(map(int,input().strip().split()))\n\nc=[0 for n in range(8)]\nf=0\nfor n in range(N):\n tmp=a[n]//400\n if tmp>=8:\n f+=1\n else:\n if c[tmp]==0:\n c[tmp]+=1\nMIN=max(sum(c),1)\nMAX=sum(c)+f\nprint((str(MIN)+\" \"+str(MAX)))\n", "def index(rate):\n if rate <= 3199:\n idx = rate // 400\n else:\n idx = 'free'\n return idx\n\n\ndef main():\n n = int(input())\n a_lst = list(map(int, input().split()))\n color_lst = [0] * 8\n\n free = 0\n for i in range(n):\n rate = a_lst[i]\n idx = index(rate)\n if idx == 'free':\n free += 1\n else:\n color_lst[idx] = 1\n\n types = 0\n for i in range(8):\n if color_lst[i] == 1:\n types += 1\n\n if types > 0:\n minimum = types\n else:\n minimum = 1\n\n maximum = types\n max_add = free\n maximum += max_add\n\n print(minimum, maximum)\n\n\ndef __starting_point():\n main()\n__starting_point()", "n=int(input())\na=list(map(int,input().split()))\nb=[]\nc=[0]*8\nd=0\nfor i in a:\n if i<3200:\n b.append(i)\n else:\n d+=1\nfor i in range(len(b)):\n for j in range(8):\n if 400*j<=b[i]<400*(j+1):\n c[j]=1\nprint(max(sum(c),1),sum(c)+d)", "from collections import defaultdict\nN = int(input())\na = list(map(int,input().split()))\nd = defaultdict(int)\nfor x in a:\n d[min(x//400, 8)] += 1\nmi = len(d.keys())\nif d[8] > 0 and mi >= 2:\n mi -= 1\nmx = d[8]+len([i for i in range(8) if i in d])\nprint(mi, mx)", "N = int(input())\na = [ int(v) for v in input().split(\" \") ]\n \nl = [0] * 9\n \nfor i in range(N):\n rate = a[i]\n \n if rate < 400:\n l[0] += 1\n elif rate < 800:\n l[1] += 1\n elif rate < 1200:\n l[2] += 1\n elif rate < 1600:\n l[3] += 1\n elif rate < 2000:\n l[4] += 1\n elif rate < 2400:\n l[5] += 1\n elif rate < 2800:\n l[6] += 1\n elif rate < 3200:\n l[7] += 1\n else:\n l[8] += 1\n \nuniq_n = 0\nfor i in range(8):\n if l[i] != 0:\n uniq_n += 1\n \nmin_v = 1 if uniq_n == 0 else uniq_n\nmax_v = uniq_n + l[8]\nprint(min_v, max_v)", "n = int(input())\n\na = list(map(int, input().split()))\n\nc = [0]*9\nfor i in a:\n t = i // 400\n if t < 8:\n c[t] = 1\n else:\n c[8] += 1\ncmin = max(sum(c[:-1]), min(c[8], 1))\ncmax = sum(c)\nprint(cmin, cmax)", "#\n# abc064 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 = \"\"\"4\n2100 2500 2700 2700\"\"\"\n output = \"\"\"2 2\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"5\n1100 1900 2800 3200 3200\"\"\"\n output = \"\"\"3 5\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\"\"\"\n output = \"\"\"1 1\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n A = list(map(int, input().split()))\n\n C = [0] * 9\n for a in A:\n for i in range(8):\n if 400*i <= a <= 400*i+399:\n C[i] = 1\n break\n else:\n C[8] += 1\n\n print(f\"{max(1, C[:8].count(1))} {C[:8].count(1)+C[8]}\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()"]
{"inputs": ["4\n2100 2500 2700 2700\n", "5\n1100 1900 2800 3200 3200\n", "20\n800 810 820 830 840 850 860 870 880 890 900 910 920 930 940 950 960 970 980 990\n"], "outputs": ["2 2\n", "3 5\n", "1 1\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
33,163
eb268666e59d4f5e6a03912dae5cab74
UNKNOWN
In "Takahashi-ya", a ramen restaurant, a bowl of ramen costs 700 yen (the currency of Japan), plus 100 yen for each kind of topping (boiled egg, sliced pork, green onions). A customer ordered a bowl of ramen and told which toppings to put on his ramen to a clerk. The clerk took a memo of the order as a string S. S is three characters long, and if the first character in S is o, it means the ramen should be topped with boiled egg; if that character is x, it means the ramen should not be topped with boiled egg. Similarly, the second and third characters in S mean the presence or absence of sliced pork and green onions on top of the ramen. Write a program that, when S is given, prints the price of the corresponding bowl of ramen. -----Constraints----- - S is a string of length 3. - Each character in S is o or x. -----Input----- Input is given from Standard Input in the following format: S -----Output----- Print the price of the bowl of ramen corresponding to S. -----Sample Input----- oxo -----Sample Output----- 900 The price of a ramen topped with two kinds of toppings, boiled egg and green onions, is 700 + 100 \times 2 = 900 yen.
["s = input()\nprint(s.count(\"o\")*100+700)", "print(input().count(\"o\")*100+700)", "s=input()\n\nnum=s.count('o')\n\nprint(700+100*num)", "# \u6587\u5b57\u5217\u306e\u5165\u529b\ns = input()\ncount = s.count(\"o\")\nprint(700 + 100 * count)", "s = input()\nres = 700\nfor i in s:\n if i == 'o':\n res += 100\nprint(res)", "S=input()\ns=S.count(\"o\")\n\nt=700+100*s\nprint(t)", "S=input()\nx=S.count(\"o\")\nprint(700+100*x)", "S = input()\nans = 700 + S.count('o') * 100\n\nprint(ans)", "s = input()\na = s.count('o')\nprint(700 + a * 100)", "print(eval(\"700\"+input().replace(\"x\",\"+0\").replace(\"o\",\"+100\")))", "S = input()\nprice = 700\nprint((price+S.count(\"o\")*100))\n", "S=input()\nans=700\nfor i in range(3):\n if S[i]==\"o\":\n ans+=100\nprint(ans)", "s = input()\n\nprint(700 + 100 * s.count('o'))", "s=input()\nprint(700+100*s.count('o'))", "s=input()\nprint(700+s.count(\"o\")*100)", "S = input()\np = 700\nfor s in S:\n if s == 'o':\n p += 100\nprint(p)", "s = list(input())\nprint((700 + s.count('o') * 100))\n", "print(700 + (input().count('o') * 100))", "print(700+input().count(\"o\")*100)", "s=input()\nprint(700+s.count(\"o\")*100)", "s = input()\ns = s.count('o')\nprint(700 + 100*s)", "S = input()\nramen_price = 700\nfor s in S:\n if s == \"o\":\n ramen_price += 100\n\nprint(ramen_price)", "n = input()\ncount = 0\nfor i in n:\n if i == \"o\":\n count += 1\nprint((700+count*100))\n", "print(700+100*(list(str(input())).count(\"o\")))", "S=list(str(input()))\nN=700\nfor i in range(3):\n if S[i]==\"o\":\n N+=100\nprint(N)", "# -*- coding: utf-8 -*-\n\nS = input()\n\ntotal = 700\nfor i in range(3):\n if S[i]=='o':\n total+=100\n\nprint(total)\n", "a = list(input())\ncount = 0\nfor i in range(0, len(a)):\n if a[i] == \"o\":\n count += 1\n\nprint((700 + count * 100))\n", "\nS = input()\ncnt = S.count('o')\ncnt *= 100\nprint(700+cnt)", "print(700 + int(input().count('o')) * 100)", "print(700+input().count(\"o\")*100)", "print(700+100*input().count('o'))", "li = list(input())\nc = 0\nfor i in li:\n if i == 'o':\n c += 1\nprint(700 + (c * 100))", "k = 0\ns = input()\nfor i in range(0 ,3):\n if s[i] == 'o':\n k = k + 1\nprint((700 + k * 100))\n", "s = str(input())\nans = 700\nfor i in range(3):\n if s[i] == \"o\":\n ans+=100\nprint(ans)\n", "str = input()\ncnt = 700\nif str[0]==\"o\" and str[1]==\"o\" and str[2]==\"o\":\n cnt = 1000\nelif (str[0]==\"o\" and str[1]==\"o\") or (str[1]==\"o\" and str[2]==\"o\") or(str[0]==\"o\" and str[2]==\"o\"):\n cnt = 900\nelif str[0]==\"o\" or str[1]==\"o\" or str[2]==\"o\":\n cnt = 800\nprint(cnt)", "s=input()\nans=0\nfor i in range(3):\n if s[i]=='o':ans=ans+1\nprint(700+100*ans)", "s = input()\ny = 700\nfor i in s:\n if i == \"o\":\n y += 100\nprint(y)", "s = input()\nx = 700\nfor i in range(3):\n if s[i] == \"o\":\n x += 100\n\nprint(x)", "s = list(input())\ncount = 700\nif s[0] == 'o':\n count += 100\nif s[1] == 'o':\n count += 100\nif s[2] == 'o':\n count += 100\n\nprint(count)\n", "s = input()\nans = 700 + 100 * s.count(\"o\")\nprint(ans)", "s = input()\nprint(s.count(\"o\")*100 + 700)", "S = input()\ncnt = S.count('o')\nprint(700+100*cnt)", "s = input()\nprint(700 + s.count('o') * 100)", "moji = str(input())\nprint(700 + moji.count(\"o\")*100)", "s=input()\nans= 100*s.count('o')+700\nprint(ans)", "s=input()\nprint((s.count('o'))*100+700)", "S = input()\nprint(700 + 100 * S.count('o'))", "ss = input()\nans = 700\nfor i in range(len(ss)):\n if ss[i]=='o':\n ans+=100\n\nprint(ans)\n", "S = input()\nprice = 700 + 100*S.count('o')\nprint(price)\n", "s = input()\nsum = 700\nfor i in range(3):\n if s[i] == \"o\":\n sum += 100\nprint(sum)\n", "S = input()\n\ns = S.count(\"o\")\n\nt = 700 + 100*s\nprint(t)\n", "S=input()\nk=0\nfor i in range(len(S)):\n if S[i]==\"o\":\n k=k+1\nprint(700+100*k)", "print(700+100*input().count(\"o\"))", "S = list(input())\nprint(700 + 100 * S.count(\"o\"))", "s = input()\nprint((s.count(\"o\")*100+700))\n", "s=input();\ncnt=s.count('o')\n\nprint((700+100*cnt))\n", "S=str(input())\nmaru_count=0\n#\u6ce8\u6587\u66f8\u306b\u66f8\u304b\u308c\u305f\u6587\u5b57\u5217S\u306b\u542b\u307e\u308c\u308bo\u306e\u6570\u3060\u3051\u3001\uff11\uff10\uff10\u5186\u52a0\u7b97\u3059\u308b\u3002\n\nfor i in S:\n if i=='o':\n maru_count=maru_count+1\n elif i=='x':\n maru_count=maru_count+0\n \n \nramen_price=700+100*maru_count\n\nprint(ramen_price)", "print(input().count('o')*100+700)", "s=input()\nprint(100*(s.count(\"o\"))+700)", "S = input()\nprint(700 + S.count(\"o\") * 100)", "s = input()\nres = 700\nfor i in range(3):\n if s[i] == \"o\":\n res += 100\n\nprint(res)\n", "s = input()\n\nif s == 'ooo':\n print(1000)\nelif s == 'oox' or s == 'oxo' or s == 'xoo':\n print(900)\nelif s == 'oxx' or s == 'xox' or s == 'xxo':\n print(800)\nelse:\n print(700)", "s = input()\nres = 700\nfor i in range(3):\n if s[i] ==\"o\":\n res += 100\nprint(res)", "n = input()\nprint(n.count(\"o\")*100+700)", "print((700 + 100 * input().count('o')))\n", "print((700+100*input().count('o')))\n", "S = str(input())\n\ncost = 700\nif S[0] == \"o\":\n cost += 100\nif S[1] == \"o\":\n cost += 100\nif S[2] == \"o\":\n cost += 100\n\nprint(cost)\n", "s = input()\nans = 700 + s.count('o')*100\nprint(ans)", "print(700+100*input().count('o'))", "S = list(input())\n\ncount = 0\n\nfor i in range(len(S)):\n if S[i] == 'o':\n count += 1\n \nprint(700 + count * 100)", "s = input()\n\nprint(700 + 100*s.count(\"o\"))", "#ABC081A\ns = input()\nprint(700+100*s.count(\"o\"))", "s = input()\na = int(s.count('o'))\nprint(int(700+a*100))", "print(input().count(\"o\") * 100 + 700)", "s = input()\nprint(700+100*s.count(\"o\"))", "s = input()\nprint(700+s.count('o')*100)", "S=input()\nresult=700\nfor s in S:\n if s == \"o\":\n result+=100\nprint(result)", "def main():\n s = input()\n print(700 + 100 * s.count(\"o\"))\n\n\nmain()", "s = str(input())\n\ncnt = 0\nfor i in range(3):\n if s[i] == \"o\":\n cnt += 1\n else: continue\n\nprint(700 + (100 * cnt))", "order_str = input()\nadditional_price = order_str.count('o') * 100\ntotal_price = 700 + additional_price\nprint(total_price)", "s = input()\na = 0\nif s[0] == 'o':\n a+=1\nif s[1] == 'o':\n a+=1\nif s[2] == 'o':\n a+=1\nprint((700+100*a))\n", "#!/usr/bin/env python3\n\n\ndef main():\n S = input()\n print((700 + 100 * S.count(\"o\")))\n\n\nmain()\n", "s = input()\np = 700\nfor i in range(3):\n if s[i] == 'o': p += 100\nprint(p)", "def resolve():\n s = input()\n ans = 700 + s.count(\"o\") * 100\n print(ans)\nresolve()", "print(input().count('o')* 100 + 700)", "s=input()\nprint(700+s.count('o')*100)", "s = input()\npl = s.count(\"o\")\nprint(700+pl*100)", "a = str(input())\n\nb = a.count(\"o\")\n\nprint(700 + b*100)", "S = input()\nn = S.count('o')\nprint(700 + 100 * n)", "toppings = len(list([x for x in list(input()) if x == 'o']))\n\nprint((toppings * 100 + 700))\n", "s = list(input())\na = 0\nfor i in s:\n if i == \"o\":\n a += 1\nprint(int(700+a*100))", "s = input()\n\nprint(700+s.count('o')*100)", "s=input(\"\")\nlist_s=list(s)\nprice=700\nmylist=[\"o\"]\nfor i in range(0,len(list_s)):\n if(list_s[i] in mylist):\n price+=100\n else:\n price+=0\n\nprint(price)", "S=input()\nprice=700\nfor i in range(3):\n if S[i]=='o':\n price=price+100\nprint(price)", "a=input()\nc=0\nif a[0]==\"o\":\n c=c+1\nif a[1]==\"o\":\n c=c+1\nif a[2]==\"o\":\n c=c+1\nprint(700+100*c)", "s = input()\n\np = 700\n\nfor x in s:\n if x == \"o\":\n p += 100\n\nprint(p)\n", "s = input()\nans = 700 + 100 * s.count(\"o\")\nprint(ans)", "s=input(\"\")\nlist_s=list(s)\nprice=700\nmylist=[\"o\"]\nfor i in range(0,len(list_s)):\n if(list_s[i] in mylist):\n price+=100\n else:\n price+=0\n\nprint(price)\n", "s = input()\nprint(100 * s.count('o') + 700)", "S = str(input())\n\na = S.count('o')\n\nprint(700 + a * 100)"]
{"inputs": ["oxo\n", "ooo\n", "xxx\n"], "outputs": ["900\n", "1000\n", "700\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
8,103
fb7b1cf40ea3a1e5e270297e92127e08
UNKNOWN
Two deer, AtCoDeer and TopCoDeer, are playing a game called Honest or Dishonest. In this game, an honest player always tells the truth, and an dishonest player always tell lies. You are given two characters a and b as the input. Each of them is either H or D, and carries the following information: If a=H, AtCoDeer is honest; if a=D, AtCoDeer is dishonest. If b=H, AtCoDeer is saying that TopCoDeer is honest; if b=D, AtCoDeer is saying that TopCoDeer is dishonest. Given this information, determine whether TopCoDeer is honest. -----Constraints----- - a=H or a=D. - b=H or b=D. -----Input----- The input is given from Standard Input in the following format: a b -----Output----- If TopCoDeer is honest, print H. If he is dishonest, print D. -----Sample Input----- H H -----Sample Output----- H In this input, AtCoDeer is honest. Hence, as he says, TopCoDeer is honest.
["# \u5165\u529b\na, b = input().split()\n\n# \u51fa\u529b\n# a = 'H' \u306e\u3068\u304dat\u304f\u3093\u306f\u6b63\u76f4\u8005\nif a == 'H' and b == 'H':\n print('H')\nelif a == 'D' and b == 'H':\n print('D')\nelif a == 'H' and b =='D':\n print('D')\nelif a == 'D' and b == 'D':\n print('H')", "a,b = input().split()\nif a == b:\n print('H')\nelse:\n print('D')", "a,b=map(str,input().split())\nif a==\"H\" :\n print(b)\nelse :\n if b==\"H\" :\n print(\"D\")\n else :\n print(\"H\")", "a, b = input().split()\nprint('H' if a==b else 'D')", "a, b = input().split()\nif a == \"H\" and b == \"H\" or a == \"D\" and b == \"D\":\n print(\"H\")\nelse:\n print(\"D\")\n", "# A - HonestOrDishonest\n\n# a, b\u306b\u305d\u308c\u305e\u308c\u6587\u5b57'H','D'\u304c\u5165\u529b\u3055\u308c\u308b\u306e\u3067\u3001'H'\u304b'D'\u3092\u5224\u5b9a\u3057\u51fa\u529b\u3059\u308b\n\n\na, b = input().split()\n\nif a == 'H':\n if b == 'H':\n print('H')\n elif b == 'D':\n print('D')\nelif a == 'D':\n if b == 'H':\n print('D')\n elif b == 'D':\n print('H')\n", "# \u30b7\u30ab\u306eAtCoDeer\u304f\u3093\u3068TopCoDeer\u304f\u3093\u304c\u300c\u6b63\u76f4\u8005\u304b\u5618\u3064\u304d\u304b\u300d\u30b2\u30fc\u30e0\u3092\u3057\u3066\u3044\u307e\u3059\u3002\n# \u3053\u306e\u30b2\u30fc\u30e0\u3067\u306f\u3001\u6b63\u76f4\u8005\u306f\u5e38\u306b\u307b\u3093\u3068\u3046\u306e\u3053\u3068\u3092\u8a00\u3044\u3001\u5618\u3064\u304d\u306f\u5e38\u306b\u5618\u3092\u8a00\u3044\u307e\u3059\u3002\n# \u6587\u5b57 a \u3068 b \u304c\u5165\u529b\u3068\u3057\u3066\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n# \u3053\u308c\u3089\u306f\u305d\u308c\u305e\u308c H \u304b D \u306e\u3069\u3061\u3089\u304b\u3067\u3059\u3002\n# a=H \u306e\u3068\u304d\u3001AtCoDeer\u304f\u3093\u306f\u6b63\u76f4\u8005\u3067\u3059\u3002\n# a=D \u306e\u3068\u304d\u3001AtCoDeer\u304f\u3093\u306f\u5618\u3064\u304d\u3067\u3059\u3002\n# b=H \u306e\u3068\u304d\u3001AtCoDeer\u304f\u3093\u306f\u300cTopCoDeer\u304f\u3093\u306f\u6b63\u76f4\u8005\u3060\u300d\u3068\u767a\u8a00\u3057\u3066\u3044\u307e\u3059\u3002\n# b=D \u306e\u3068\u304d\u3001AtCoDeer\u304f\u3093\u306f\u300cTopCoDeer\u304f\u3093\u306f\u5618\u3064\u304d\u3060\u300d\u3068\u767a\u8a00\u3057\u3066\u3044\u307e\u3059\u3002\n#\n# \u3053\u308c\u3089\u304b\u3089\u5224\u65ad\u3057\u3066\u3001TopCoDeer\u304f\u3093\u304c\u6b63\u76f4\u8005\u304b\u3069\u3046\u304b\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# a='H' \u307e\u305f\u306f 'D'\n# b='H' \u307e\u305f\u306f 'D'\n\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089\u6587\u5b57\u5217 a \u3068 b \u3092\u53d6\u5f97\u3059\u308b\ninput_a, input_b = list(map(str,input().split()))\n\nreslut = \"ret\"\n\n# TopCoDeer\u304f\u3093\u304c\u6b63\u76f4\u8005\u304b\u3069\u3046\u304b\u5224\u5b9a\u3057\u3001\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\u3002\n# \u203b \u6b63\u76f4\u8005==\"H\"\u3001\u5618\u3064\u304d==\"D\"\nif input_a == \"H\": # AtCoDeer\u304f\u3093\u304c\u6b63\u76f4\u8005\u306e\u5834\u5408\n if input_b == \"H\":\n result = \"H\"\n elif input_b == \"D\":\n result = \"D\"\nelif input_a == \"D\": # AtCoDeer\u304f\u3093\u304c\u5618\u3064\u304d\u8005\u306e\u5834\u5408\uff08\u6761\u4ef6\u5897\u3048\u305f\u6642\u3088\u3046\u306belif\u306b\u3057\u305f\uff09\n if input_b == \"H\":\n result = \"D\"\n elif input_b == \"D\":\n result = \"H\"\nelse:\n reslut = \"I don't Know.\"\n\nprint(result)\n\n\n", "a, b = map(str, input().split())\n\nif a == b:\n print(\"H\")\nelif a != b:\n print(\"D\")", "a,b = map(str,input().split())\nif a == \"H\":\n print(b)\nelse:\n if b == \"H\":\n print(\"D\")\n else:\n print(\"H\")", "a,b = input().split()\n\nif a == \"H\":\n print(b)\nelse:\n if b == \"H\":\n print(\"D\")\n else:\n print(\"H\")", "a,b=input().split()\nprint(\"H\" if a==b else \"D\")", "a,b = input().split()\n\nif a == b:\n print(\"H\")\nelse:\n print(\"D\")", "a, b = map(str, input().split())\n\nif a == 'H' and b == 'H' or a == 'D' and b == 'D':\n print('H')\nelse:\n print('D')", "a, b = input().split()\n\nif a == 'H':\n print(b)\nelif a == 'D':\n print('HD'[int(not 'HD'.index(b))])", "'''\nabc056 A - Honest Or Dishonest\nhttps://atcoder.jp/contests/abc056/tasks/abc056_a\n'''\n\na, b = input().split()\n\nif a == 'H': #AtCoDeer\u6b63\u76f4\n if b == 'H': #AtCoDeer\u304f\u3093\u300cTopCoDeer\u304f\u3093\u306f\u6b63\u76f4\u300d\n TopCoDeer = 'H'\n else:\n TopCoDeer = 'D'\nelse:\n if b == 'H':\n TopCoDeer = 'D'\n else:\n TopCoDeer = 'H'\nprint(TopCoDeer)\n", "a, b = input().split()\nhd = \"HD\"\nprint((hd[(hd.index(a) + hd.index(b)) % 2]))\n", "a, b = input().split()\nif a == b:\n print('H')\nelse:\n print('D')", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\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 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############################################################\na, b = lstr()\nprint('H' if a == b else 'D')", "a,b = input().split()\nprint((\"H\" if (a==\"H\" and b==\"H\") or (a==\"D\" and b==\"D\") else \"D\"))\n", "a,b=map(str,input().split())\nif (a == \"H\" and b == \"H\") or (a == \"D\" and b == \"D\"):\n print(\"H\")\nelse:\n print(\"D\")", "# AtCoder abc056 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\na, b = list(map(str, input().split()))\n\nif a == b:\n print(\"H\")\nelse:\n print(\"D\")\n", "a,b=input().split()\nif a == b:\n print(\"H\")\nelse:\n print(\"D\")", "A,B = input().split()\n\nprint('H') if (A == 'D' and B == 'D') or (A == 'H' and B == 'H') else print('D')", "a, b = input().split()\nif a == \"H\" and b == \"H\":\n print(\"H\")\nelif a == \"D\" and b == \"D\":\n print(\"H\")\nelse:\n print(\"D\")", "a, b = map(str, input().split())\n\nif a == 'H' and b == 'H':\n print('H')\nelif a == 'D' and b == 'D':\n print('H')\nelse:\n print('D')", "a,b = input().split()\nprint(('H' if a==b else 'D'))\n", "# A - HonestOrDishonest\n# https://atcoder.jp/contests/abc056/tasks/abc056_a\n\na, b = list(map(str, input().split()))\n\nh = 'H'\nd = 'D'\n\nresult = h\n\nif a == h:\n if b == d:\n result = d\nelse:\n if b == h:\n result = d\n else:\n result = h\n\nprint(result)\n", "print(('HD'[len(set(input()))%2]))\n\n", "a,b=map(str,input().split())\nif a==\"H\" and b==\"H\":\n print(\"H\")\nelif a==\"D\" and b==\"D\":\n print(\"H\")\nelse:\n print(\"D\")", "# AtCoder abc056 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\na, b = list(map(str, input().split()))\n\n# \u5224\u5b9a\n# if ((a == \"H\") and (b == \"H\")) or ((a == \"D\") and (b == \"D\")):\n# print(\"H\")\n# else:\n# print(\"D\")\nif a == b:\n print(\"H\")\nelse:\n print(\"D\")\n", "# a atcooderkun\u306e\u771f\u507d b atcooderkun\u306e\u8a00\u52d5\n# # b=H at\u300cTOP\u672c\u5f53\u300d\u3000b=D at\u300cTOP\u5618\u3060\uff01\n# \u5bfe\u5fdc\u95a2\u4fc2\u3000\u3007\u3000\u00d7\n# \u3000\u3000\u3000\u3000\u3000\u3000\u3000\u00d7\u3000\u3007\n\na, b = input().split()\n\nif a==b:\n print(\"H\")\nelse:\n print(\"D\")", "# \u5165\u529b\na,b = map(str, input().split())\n\n# HH\u3068DD\u306fH\u3001\u305d\u308c\u4ee5\u5916\u306fD\nif a == 'H' and b == 'H':\n print('H')\nelif a == 'D' and b == 'D':\n print('H')\nelse:\n print('D')", "a, b = input().split()\nif a == b:\n print(\"H\")\nelse:\n print(\"D\")", "a,b = input().split()\n\nprint(\"H\" if a == b else \"D\")", "s = input().split()\nif s[0] == s[1]:\n print(\"H\")\nelse:\n print(\"D\")", "a, b = list(map(str, input().split()))\n\nif a == 'H':\n if b == 'H':\n print('H')\n else:\n print('D')\nelse:\n if b == 'H':\n print('D')\n else:\n print('H')\n", "#ABC056A\na,b = input().split()\nprint(\"H\" if (a==\"H\" and b==\"H\") or (a==\"D\" and b==\"D\") else \"D\")", "a, b = input().split()\n\nif a == 'H':\n if b == 'H':\n print('H') \n else:\n print('D')\nelse:\n if b == 'H':\n print('D')\n else:\n print('H')", "a, b = input().split()\n\nif a == 'H':\n if b == 'H':\n print('H')\n else:\n print('D')\nelse:\n if b == 'H':\n print('D')\n else:\n print('H')", "a,b=input().split()\nprint(\"H\" if a==b else\"D\")", "deck = [\"H\",\"D\"]\na,b = input().split()\nif deck.index(a) == 0:\n print(b)\nelif deck.index(b) == 0:\n print(deck[1])\nelse:\n print(deck[0])", "a, b = input().split()\n\nif a == \"D\" and b == \"D\":\n print(\"H\")\nelif a == \"H\" and b == \"H\":\n print(\"H\")\nelif a == \"D\" or b == \"D\":\n print(\"D\")", "a,b=map(str,input().split())\nif a=='H': print(b)\nelif b=='H': print(a)\nelse:print('H')", "a, b = input().split()\nif a == \"H\":\n print(b)\nelse:\n if b == \"H\":\n print(\"D\")\n else:\n print(\"H\")", "a,b = (input().split())\n\nif (a == 'H' and b == 'H') or (a == 'D' and b == 'D'):\n print('H')\n\nelif (a == 'H' and b == 'D') or (a == 'D' and b == 'H'):\n print('D')", "a,b=input().split()\nif a==b:print('H')\nelse:print('D')", "a, b = input().split()\nif a == \"H\":\n print(b)\nelse:\n if b == \"H\":\n print(\"D\")\n else:\n print(\"H\")\n", "a,_,b = input()\nif a==\"H\"and b==\"H\":\n print(\"H\")\nelif a==\"H\"and b==\"D\":\n print(\"D\")\nelif a==\"D\"and b==\"H\":\n print(\"D\")\nelse:\n print(\"H\")", "a, b = input().split()\nprint('H' if a == b else 'D')", "# a=H\u306e\u3068\u304db=H\u3067\u6b63\u76f4\u8005\u3001a=D\u306e\u6642b=D\u3067\u6b63\u76f4\u8005\n\na, b = map(str, input().split())\nif a == b:\n print('H')\nelse:\n print('D')", "a,b=input().split()\nif(a==\"H\" and b==\"D\"):\n\tprint(\"D\")\nelif(a==\"D\" and b==\"H\"):\n\tprint(\"D\")\nelif(a==\"H\" and b==\"H\"):\n\tprint(\"H\")\nelif(a==\"D\" and b==\"D\"):\n\tprint(\"H\")\n", "a,b=input().split()\nx= a==\"H\"\ny= b==\"H\"\nif x^y:\n print(\"D\")\nelse:\n print(\"H\")\n", "S =input().replace(\"H\",\"0\")\nS = S.replace('D','1')\nS_list = list(map(int,S.split()))\n\nif S_list[0] ^ S_list[1] == 0 :\n result = \"H\"\nelse:\n result = \"D\"\nprint(result)", "# A - HonestOrDishonest\ndef main():\n a, b = input().split()\n\n if a == 'H':\n if b == 'H':\n print('H')\n else:\n print('D')\n else:\n if b == 'H':\n print('D')\n else:\n print('H')\n \n \ndef __starting_point():\n main()\n__starting_point()", "a,b=map(str,input().split())\nif a==\"H\":\n print(b)\n return\nelse:\n if b==\"H\":\n print(\"D\")\n else:\n print(\"H\")", "a,b = input().split()\n\nif (a == 'H' and b == 'H') or (a == 'D' and b == 'D'):\n print('H')\nelse:\n print('D')", "a, b = input().split()\nif a == 'H':\n print(b)\nelse:\n if b == 'D':\n print('H')\n else:\n print('D')", "a,b = input().split()\nif a == 'H' and b == 'H':\n print('H')\nelif a == 'H' and b == 'D':\n print('D')\nelif a == 'D' and b == 'H':\n print('D')\nelse:\n print('H')", "a, b = input().split()\nprint(\"H\" if a == b else \"D\")", "a,b = map(str,input().split())\n\nprint('H' if a == b else 'D')", "say = ''.join(input().split())\nif say=='HH' or say== 'DD':\n print('H')\nelse:\n print('D')", "# \u5165\u529b\na, b = map(str,input().split())\n\n# \u51e6\u7406\nif a == b:\n TopCoDeer = 'H'\nelse:\n TopCoDeer = 'D'\n\n# \u51fa\u529b\nprint(TopCoDeer)", "a, b = input().split()\nprint(\"DH\"[a == b])", "a,b = list(map(str,input().split()))\nif a == 'H' and b== 'H':\n print('H')\nelif a == 'H' and b== 'D':\n print('D')\nelif a == 'D' and b== 'H':\n print('D')\nelse:\n print('H')\n", "a, b = input().split()\n\nif a == 'H':\n if b == 'H':\n print('H')\n else:\n print('D')\nelse:\n if b == 'H':\n print('D')\n else:\n print('H')\n", "a, b = input().split()\n\nif a == 'H' and b == 'H':\n print('H')\nelif a == 'H' and b == 'D':\n print('D')\nelif a == 'D' and b == 'H':\n print('D')\nelse:\n print('H')\n", "a,b=map(str,input().split())\n\nif a=='H':\n a=1\nelse:\n a=0\nif b=='H':\n b=1\nelse:\n b=0\n\nif a^b==0:\n print('H')\nelse :\n print('D')", "s={'H':0,'D':1}\nt=0\na=input().split()\n\nfor i in range(2):\n t+=s[a[i]]\n \nif t%2!=0:\n print('D')\n \nelse:\n print('H')", "# \u6587\u5b57\u5217\u3092\u53d6\u5f97\na,b = map(str,input().split())\n\n# \u6761\u4ef6\u306b\u6cbf\u3063\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u51fa\u529b\nif a == b:\n print(\"H\")\nelse:\n print(\"D\")", "a,b=input().split()\nif(a==\"H\" and b==\"D\"):\n\tprint(\"D\")\nelif(a==\"D\" and b==\"H\"):\n\tprint(\"D\")\nelif(a==\"H\" and b==\"H\"):\n\tprint(\"H\")\nelif(a==\"D\" and b==\"D\"):\n\tprint(\"H\")\n", "# \u30b7\u30ab\u306eAtCoDeer\u304f\u3093\u3068TopCoDeer\u304f\u3093\u304c\u300c\u6b63\u76f4\u8005\u304b\u5618\u3064\u304d\u304b\u300d\u30b2\u30fc\u30e0\u3092\u3057\u3066\u3044\u307e\u3059\u3002\n# \u3053\u306e\u30b2\u30fc\u30e0\u3067\u306f\u3001\u6b63\u76f4\u8005\u306f\u5e38\u306b\u307b\u3093\u3068\u3046\u306e\u3053\u3068\u3092\u8a00\u3044\u3001\u5618\u3064\u304d\u306f\u5e38\u306b\u5618\u3092\u8a00\u3044\u307e\u3059\u3002\n# \u6587\u5b57 a \u3068 b \u304c\u5165\u529b\u3068\u3057\u3066\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n# \u3053\u308c\u3089\u306f\u305d\u308c\u305e\u308c H \u304b D \u306e\u3069\u3061\u3089\u304b\u3067\u3059\u3002\n# a=H \u306e\u3068\u304d\u3001AtCoDeer\u304f\u3093\u306f\u6b63\u76f4\u8005\u3067\u3059\u3002\n# a=D \u306e\u3068\u304d\u3001AtCoDeer\u304f\u3093\u306f\u5618\u3064\u304d\u3067\u3059\u3002\n# b=H \u306e\u3068\u304d\u3001AtCoDeer\u304f\u3093\u306f\u300cTopCoDeer\u304f\u3093\u306f\u6b63\u76f4\u8005\u3060\u300d\u3068\u767a\u8a00\u3057\u3066\u3044\u307e\u3059\u3002\n# b=D \u306e\u3068\u304d\u3001AtCoDeer\u304f\u3093\u306f\u300cTopCoDeer\u304f\u3093\u306f\u5618\u3064\u304d\u3060\u300d\u3068\u767a\u8a00\u3057\u3066\u3044\u307e\u3059\u3002\n#\n# \u3053\u308c\u3089\u304b\u3089\u5224\u65ad\u3057\u3066\u3001TopCoDeer\u304f\u3093\u304c\u6b63\u76f4\u8005\u304b\u3069\u3046\u304b\u5224\u5b9a\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# a='H' \u307e\u305f\u306f 'D'\n# b='H' \u307e\u305f\u306f 'D'\n\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089\u6587\u5b57\u5217 a \u3068 b \u3092\u53d6\u5f97\u3059\u308b\ninput_a, input_b = list(map(str,input().split()))\n\nreslut = \"ret\"\n\n# TopCoDeer\u304f\u3093\u304c\u6b63\u76f4\u8005\u304b\u3069\u3046\u304b\u5224\u5b9a\u3057\u3001\u7d50\u679c\u3092\u51fa\u529b\u3059\u308b\u3002\n# \u203b \u6b63\u76f4\u8005==\"H\"\u3001\u5618\u3064\u304d==\"D\"\nif input_a == \"H\": # AtCoDeer\u304f\u3093\u304c\u6b63\u76f4\u8005\u306e\u5834\u5408\n if input_b == \"H\":\n result = \"H\"\n elif input_b == \"D\":\n result = \"D\"\nelif input_a == \"D\": # AtCoDeer\u304f\u3093\u304c\u5618\u3064\u304d\u8005\u306e\u5834\u5408\uff08\u6761\u4ef6\u5897\u3048\u305f\u6642\u3088\u3046\u306belif\u306b\u3057\u305f\uff09\n if input_b == \"H\":\n result = \"D\"\n elif input_b == \"D\":\n result = \"H\"\nelse:\n reslut = \"I don't Know.\"\n\nprint(result)\n\n\n", "a,b=input().split();print([['H','D'][b=='H'],b][a=='H'])", "a,b = input().split()\nprint(\"H\" if a == b else \"D\")", "# 056_a\na, b = input().split()\nif (a == 'H' or a == 'D') and (b == 'H' or b == 'D'):\n if a == 'H':\n if b=='H':\n print('H')\n else:\n print('D')\n if a == 'D':\n if b=='H':\n print('D')\n else:\n print('H')\n", "a,b=input().split()\nif a==b:\n print(\"H\")\nelse:\n print(\"D\")", "a = input().split()\nif (a[0] == 'H' and a[1] == 'H') or (a[0] == 'D' and a[1] == 'D'):\n print('H')\nelse:\n print('D')", "a, b = input().split()\nprint(\"H\" if a == b else \"D\")", "a, b = input().split()\nhd = \"HD\"\nif a == \"H\":\n print(b)\nelse:\n print((hd[hd.index(b) - 1]))\n", "#56\na,b=input().split()\nif (a=='H' and b=='H'):\n print('H')\nelif (a=='H' and b=='D'):\n print('D')\nelif (a=='D' and b=='H'):\n print('D')\nelse:\n print('H')", "a,b=input().split();print(['HD'.replace(b,''),b][a=='H'])", "a, b = map(str,input().split())\n\nif a == \"H\" and b == \"H\" or a == \"D\" and b == \"D\":\n print(\"H\")\nelse:\n print(\"D\")", "a, b = input().split()\nprint('H' if (a == 'H') ^ (b == 'D') else 'D')", "# \u5165\u529b\na,b = map(str, input().split())\n\nif a == 'H' and b == 'H':\n print('H')\nelif a == 'D' and b == 'D':\n print('H')\nelse:\n print('D')", "a, b = map(str, input().split())\n\nif (a == \"H\" and b == \"H\") or (a == \"D\" and b == \"D\"):\n print(\"H\")\nelse:\n print(\"D\")", "a,b=input().split()\nif a==b==\"H\" or a==b==\"D\":\n print(\"H\")\nelse:\n print(\"D\")", "a, b = map(str, input().split())\n\nif a == 'H':\n if b == 'H':\n ans = 'H'\n else:\n ans = 'D'\nelse:\n if b == 'H':\n ans = 'D'\n else:\n ans = 'H'\n\nprint(ans)", "a, b = input().split()\nprint(\"DH\"[a==b])", "print(\"HD\"[len(set(input().split()))-1])", "a, b = input().split()\n\nif a == 'H' and b == 'H':\n result = 'H'\n \nif a == 'D' and b == 'H':\n result = 'D'\n \nif a == 'D' and b == 'D':\n result = 'H'\n \nif a == 'H' and b == 'D':\n result = 'D'\n \nprint(result)", "a, b = map(str, input().split())\n\nif (a == b == 'H') or (a == b == 'D'):\n print('H')\nelse:\n print('D')", "a, b = input().split()\nif a == b:\n print('H')\nelse:\n print('D')", "# 056a\n\n# a=H, b=H TCD\u541b\u306f\u6b63\u76f4\u8005\n# a=H, b=D TCD\u541b\u306f\u5618\u3064\u304d\n# a=D, b=H TCD\u541b\u306f\u5618\u3064\u304d\n# a=D, b=D TCD\u541b\u306f\u6b63\u76f4\u8005\n\na, b = list(map(str, input().split()))\n\nif a == 'H' and b == 'H':\n print('H')\nelif a == 'H' and b == 'D':\n print('D')\nelif a == 'D' and b == 'H':\n print('D')\nelse:\n print('H')\n", "a, b = input().split()\nprint((\"D\", \"H\")[a == b])", "a,b = input().split()\nif a=='H':\n\tif b == 'H':\n\t\tprint('H')\n\telse:\n\t\tprint('D')\nelse:\n\tif b == 'H':\n\t\tprint('D')\n\telse:\n\t\tprint('H')\n", "#n = int(input())\na, b = list(map(str,input().split()))\n#l = list(map(int,input().split()))\n#l = [list(map(int,input().split())) for i in range(n)]\n\nif a == b:\n print('H')\nelse:\n print('D')\n", "#!/usr/bin/env python3\n\ndef main():\n a, b = input().split()\n print((\"H\" if a == b else \"D\"))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a, b = list(map(str, input().split()))\nif a == b:\n print('H')\nelse:\n print('D')\n", "a, b = input().split()\n\nif a == 'H':\n if b == 'H':\n print('H')\n else:\n print('D')\nelse:\n if b == 'H':\n print('D')\n else:\n print('H')\n", "a,b=input().split(\" \")\nif a==\"H\":print(b)\nelif b==\"D\":print(\"H\")\nelse: print(\"D\")", "a,b=input().split()\nif a==\"H\" and b==\"H\":\n print(\"H\")\nelif a==\"H\" and b==\"D\":\n print(\"D\")\nelif a==\"D\" and b==\"H\":\n print(\"D\")\nelse:\n print(\"H\")"]
{"inputs": ["H H\n", "D H\n", "D D\n"], "outputs": ["H\n", "D\n", "H\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
19,654
6456d6eea6e1335afc145e61cf9d001d
UNKNOWN
Sitting in a station waiting room, Joisino is gazing at her train ticket. The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive). In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds. The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted. -----Constraints----- - 0≀A,B,C,D≀9 - All input values are integers. - It is guaranteed that there is a solution. -----Input----- Input is given from Standard Input in the following format: ABCD -----Output----- Print the formula you made, including the part =7. Use the signs + and -. Do not print a space between a digit and a sign. -----Sample Input----- 1222 -----Sample Output----- 1+2+2+2=7 This is the only valid solution.
["\nS = input()\n\na = int(S[0])\nb = int(S[1])\nc = int(S[2])\nd = int(S[3])\n\nif a+b+c+d==7:\n print('{}+{}+{}+{}=7'.format(a,b,c,d))\nelif a+b+c-d==7:\n print('{}+{}+{}-{}=7'.format(a,b,c,d))\nelif a+b-c+d==7:\n print('{}+{}-{}+{}=7'.format(a,b,c,d))\nelif a+b-c-d==7:\n print('{}+{}-{}-{}=7'.format(a,b,c,d))\nelif a-b+c+d==7:\n print('{}-{}+{}+{}=7'.format(a,b,c,d))\nelif a-b+c-d==7:\n print('{}-{}+{}-{}=7'.format(a,b,c,d))\nelif a-b-c-d==7:\n print('{}-{}-{}-{}=7'.format(a,b,c,d))\nelif a-b-c+d==7:\n print('{}-{}-{}+{}=7'.format(a,b,c,d))", "#!/usr/bin/env python3\nimport itertools\nimport sys\nsys.setrecursionlimit(10**6)\n\na, b, c, d = [int(i) for i in str(input())]\n\nfor i, j, k in itertools.product([1, -1], repeat=3):\n if a+b*i+c*j+d*k == 7:\n break\n\nif i == 1:\n i = \"+\"\nelse:\n i = \"-\"\nif j == 1:\n j = \"+\"\nelse:\n j = \"-\"\nif k == 1:\n k = \"+\"\nelse:\n k = \"-\"\n\nprint((\"{}{}{}{}{}{}{}=7\".format(a, i, b, j, c, k, d)))\n", "# -*- coding: utf-8 -*-\n\nnum = list(input())\n\nop = ['+','-']\n\nfor op1 in op:\n if op1 == '+':\n res1 = int(num[0]) + int(num[1])\n else:\n res1 = int(num[0]) - int(num[1])\n for op2 in op:\n if op2 == '+':\n res2 = res1 + int(num[2])\n else:\n res2 = res1 - int(num[2])\n for op3 in op:\n if op3 == '+':\n res3 = res2 + int(num[3])\n else:\n res3 = res2 - int(num[3])\n\n if res3 == 7:\n ans = num[0]+op1+num[1]+op2+num[2]+op3+num[3]+\"=7\"\n print(ans)\n return \n", "ABCD = input()\n\nA = int(ABCD[0])\nB = int(ABCD[1])\nC = int(ABCD[2])\nD = int(ABCD[3])\n\nif 7 == A+B+C+D:\n print(f'{A}+{B}+{C}+{D}=7')\nelif 7 == A+B+C-D:\n print(f'{A}+{B}+{C}-{D}=7')\nelif 7 == A+B-C-D:\n print(f'{A}+{B}-{C}-{D}=7')\nelif 7 == A-B-C-D:\n print(f'{A}-{B}-{C}-{D}=7')\nelif 7 == A+B-C+D:\n print(f'{A}+{B}-{C}+{D}=7')\nelif 7 == A-B-C+D:\n print(f'{A}-{B}-{C}+{D}=7')\nelif 7 == A-B+C+D:\n print(f'{A}-{B}+{C}+{D}=7')\nelif 7 == A-B+C-D:\n print(f'{A}-{B}+{C}-{D}=7')\n", "# coding: utf-8\n# Your code here!\n\n\n\n\ndef insert_str(target, i, char):\n return target[:i] + char + target[i:]\n\ndef calc(target, i):\n nonlocal ans\n \n if ans != \"\":\n return\n \n if i == 7:\n if eval(target) == 7:\n ans = target+\"=7\"\n return ans\n return\n calc(insert_str(target, i, \"+\"), i+2)\n calc(insert_str(target, i, \"-\"), i+2)\n \nS = input()\nN = len(S)\nans = \"\"\ncalc(S, 1)\n\n\nprint(ans)\n\n\n\n\n", "a,b,c,d=map(int,input())\nif a+b-c+d == 7:\n print('%d+%d-%d+%d=7' %(a,b,c,d))\n return\nelif a+b-c-d == 7:\n print('%d+%d-%d-%d=7' %(a,b,c,d))\n return\nelif a-b-c+d == 7:\n print('%d-%d-%d+%d=7' %(a,b,c,d))\n return\nelif a-b-c-d == 7:\n print('%d-%d-%d-%d=7' %(a,b,c,d))\n return\nelif a+b+c+d ==7:\n print('%d+%d+%d+%d=7' %(a,b,c,d))\n return\nelif a+b+c-d ==7:\n print('%d+%d+%d-%d=7' %(a,b,c,d))\n return\nelif a-b+c+d ==7:\n print('%d-%d+%d+%d=7' %(a,b,c,d))\n return\nelif a-b+c-d ==7:\n print('%d-%d+%d-%d=7' %(a,b,c,d))\n return", "s = input()\nans1=s[0]\n\ndef solve(i,tmp,ans):\n nonlocal ans1\n if i==3:\n if tmp==7:\n ans1=ans\n return True\n else:\n return False\n \n if solve(i+1,tmp+int(s[i+1]),ans+\"+\"+s[i+1]): return True\n if solve(i+1,tmp-int(s[i+1]),ans+\"-\"+s[i+1]): return True\n\nif solve(0,int(s[0]),ans1):\n print(ans1+\"=7\")", "n=input()\n\nfor i in range(2 ** 3):\n \n\n co=[\"-\",\"-\",\"-\"]\n\n for j in range(3):\n if ((i>>j)&1):\n co[2-j]=\"+\"\n\n eq=n[0]+co[0]+n[1]+co[1]+n[2]+co[2]+n[3]\n\n\n if eval(eq)==7:\n ans=eq\n\nprint(ans,end=\"\")\nprint(\"=7\")\n", "def dfs(i,sum1,sum2):\n nonlocal ans\n #print(sum1,sum2)\n if i == 4 and sum1 != 7:\n return 0\n elif i == 4 and sum1 == 7:\n ans = sum2 + \"=7\"\n else:\n dfs(i + 1,sum1 - int(s[i]),sum2 + \"-\" +s[i])\n dfs(i + 1,sum1 + int(s[i]),sum2 + \"+\" +s[i])\n\nans = \"\"\ns = input()\ndfs(1,int(s[0]),s[0])\nprint(ans)", "def kumiawase(S,op,i=0,x=0):\n if i ==4:\n if x == 7:\n print(op+'=7')\n return True\n else:\n return False\n \n if kumiawase(S,op+'+'+S[i],i+1,x+int(S[i])): return True\n \n if kumiawase(S,op+'-'+S[i],i+1,x-int(S[i])): return True\n \nS = input()\n\nkumiawase(S,S[0],1,int(S[0]))", "import itertools\nL = ['+', '-']\ns = list(input())\nfor l in itertools.product(L, repeat=3):\n if 7 == eval(s[0]+l[0]+s[1]+l[1]+s[2]+l[2]+s[3]):\n print(s[0]+l[0]+s[1]+l[1]+s[2]+l[2]+s[3]+'=7')\n break", "a,b,c,d=input()\ns='+-'\nfor p in s:\n for q in s:\n for r in s:\n f=a+p+b+q+c+r+d\n if eval(f)==7:print(f+'=7');return", "# coding = SJIS\n\nn = str(input())\na = int(n[0])\nb = int(n[1])\nc = int(n[2])\nd = int(n[3])\n\nif a + b + c + d == 7:\n ans = str(a) + \"+\" + str(b) + \"+\" + str(c) + \"+\" + str(d)\nelif a + b + c - d == 7:\n ans = str(a) + \"+\" + str(b) + \"+\" + str(c) + \"-\" + str(d)\nelif a + b - c + d == 7:\n ans = str(a) + \"+\" + str(b) + \"-\" + str(c) + \"+\" + str(d)\nelif a + b - c - d == 7:\n ans = str(a) + \"+\" + str(b) + \"-\" + str(c) + \"-\" + str(d)\nelif a - b + c + d == 7:\n ans = str(a) + \"-\" + str(b) + \"+\" + str(c) + \"+\" + str(d)\nelif a - b + c - d == 7:\n ans = str(a) + \"-\" + str(b) + \"+\" + str(c) + \"-\" + str(d)\nelif a - b - c + d == 7:\n ans = str(a) + \"-\" + str(b) + \"-\" + str(c) + \"+\" + str(d)\nelif a - b - c - d == 7:\n ans = str(a) + \"-\" + str(b) + \"-\" + str(c) + \"-\" + str(d)\n\nprint(ans + \"=7\")", "a,b,c,d = list(input())\nsign = '+-'\nfor i in range(2):\n for j in range(2):\n for k in range(2):\n if eval(a+sign[i]+b+sign[j]+c+sign[k]+d)==7:\n print(str(a+sign[i]+b+sign[j]+c+sign[k]+d)+'=7')\n return", "from itertools import combinations\n\ns = input()\n\nans = ['-','-','-']\nfor i in range(4):\n for comb in combinations(range(3),i):\n temp = int(s[0])\n for j in range(3):\n if j in comb:\n temp += int(s[j+1])\n else:\n temp -= int(s[j+1])\n if temp==7:\n for j in comb:\n ans[j] = \"+\"\n break \nprint(\"{a}{op1}{b}{op2}{c}{op3}{d}=7\".format(a=s[0],op1=ans[0],b=s[1],op2=ans[1],c=s[2],op3=ans[2],d=s[3]))", "import itertools\n\nads = [\"+\",\"+\",\"+\",\"-\",\"-\",\"-\"]\ns = input()\nq = list(itertools.permutations(ads, 3))\n\nfor j in range(len(q)):\n ans = int(s[0])\n al = \"\"\n for k in range(3):\n if q[j][k] == \"+\":\n ans += int(s[k+1])\n else:\n ans -= int(s[k+1])\n al += q[j][k]\n al += s[k+1]\n if ans == 7:\n print(s[0]+al+\"=7\")\n break", "def main():\n S = list(input())\n A, B, C, D = list(map(int, S))\n if A+B+C+D == 7:\n print((\"{}+{}+{}+{}=7\".format(A, B, C, D)))\n return\n if A+B+C-D == 7:\n print((\"{}+{}+{}-{}=7\".format(A, B, C, D)))\n return\n if A+B-C+D == 7:\n print((\"{}+{}-{}+{}=7\".format(A, B, C, D)))\n return\n if A+B-C-D == 7:\n print((\"{}+{}-{}-{}=7\".format(A, B, C, D)))\n return\n if A-B+C+D == 7:\n print((\"{}-{}+{}+{}=7\".format(A, B, C, D)))\n return\n if A-B+C-D == 7:\n print((\"{}-{}+{}-{}=7\".format(A, B, C, D)))\n return\n if A-B-C+D == 7:\n print((\"{}-{}-{}+{}=7\".format(A, B, C, D)))\n return\n if A-B-C-D == 7:\n print((\"{}-{}-{}-{}=7\".format(A, B, C, D)))\n return\n\ndef __starting_point():\n main()\n\n__starting_point()", "import itertools\nx = input()\nfor v in itertools.product([\"+\", \"-\"], repeat=3):\n t = x[0]+v[0]+x[1]+v[1]+x[2]+v[2]+x[3]\n if eval(t) == 7: break\nprint(t+\"=7\")", "a, b, c, d = list(map(int, list(input())))\nif a + b + c + d == 7:\n print((\"{}+{}+{}+{}=7\".format(a, b, c, d)))\nelif a + b + c - d == 7:\n print((\"{}+{}+{}-{}=7\".format(a, b, c, d)))\nelif a + b - c + d == 7:\n print((\"{}+{}-{}+{}=7\".format(a, b, c, d)))\nelif a - b + c + d == 7:\n print((\"{}-{}+{}+{}=7\".format(a, b, c, d)))\nelif a + b - c - d == 7:\n print((\"{}+{}-{}-{}=7\".format(a, b, c, d)))\nelif a - b - c + d == 7:\n print((\"{}-{}-{}+{}=7\".format(a, b, c, d)))\nelif a - b + c - d == 7:\n print((\"{}-{}+{}-{}=7\".format(a, b, c, d)))\nelif a - b - c - d == 7:\n print((\"{}-{}-{}-{}=7\".format(a, b, c, d)))\n", "a,b,c,d=input()\ns='+-'\nfor p in s:\n for q in s:\n for r in s:\n f=a+p+b+q+c+r+d\n if eval(f)==7:print(f+'=7');return", "N = input()\nn = str(N)\na = int(n[0])\nb = int(n[1])\nc = int(n[2])\nd = int(n[3])\n\nif a + b + c + d == 7:\n ans = str(a) + \"+\" + str(b) + \"+\" + str(c) + \"+\" + str(d)\nelif a + b + c - d == 7:\n ans = str(a) + \"+\" + str(b) + \"+\" + str(c) + \"-\" + str(d)\nelif a + b - c + d == 7:\n ans = str(a) + \"+\" + str(b) + \"-\" + str(c) + \"+\" + str(d)\nelif a + b - c - d == 7:\n ans = str(a) + \"+\" + str(b) + \"-\" + str(c) + \"-\" + str(d)\nelif a - b + c + d == 7:\n ans = str(a) + \"-\" + str(b) + \"+\" + str(c) + \"+\" + str(d)\nelif a - b + c - d == 7:\n ans = str(a) + \"-\" + str(b) + \"+\" + str(c) + \"-\" + str(d)\nelif a - b - c + d == 7:\n ans = str(a) + \"-\" + str(b) + \"-\" + str(c) + \"+\" + str(d)\nelif a - b - c - d == 7:\n ans = str(a) + \"-\" + str(b) + \"-\" + str(c) + \"-\" + str(d)\n\nprint(ans + \"=7\")", "n = input()\nN = [int(i) for i in n]\nfor i in range(8):\n n = format(i, '03b')\n ans = N[0]\n msg = str(N[0])\n for j in range(3):\n if n[j] == '0':\n ans += N[j+1]\n msg += '+' + str(N[j+1])\n else:\n ans -= N[j+1]\n msg += '-' + str(N[j+1])\n if ans == 7:\n print(msg + \"=7\")\n break", "A,B,C,D = map(int,input())\ntfs = []\nrt = str(A)\nfor bt in (True, False):\n for ct in (True, False):\n for dt in (True, False):\n tfs.append([bt,ct,dt])\nfor bt,ct,dt in tfs:\n tmp=7-A\n tmp = tmp-B if bt else tmp+B\n tmp = tmp-C if ct else tmp+C\n tmp = tmp-D if dt else tmp+D\n if tmp == 0:\n rt+=\"+\" if bt else \"-\"\n rt+=str(B)\n rt+=\"+\" if ct else \"-\"\n rt+=str(C)\n rt+=\"+\" if dt else \"-\"\n rt+=str(D)\n rt+=\"=7\"\n break\n\nprint(rt)", "n = input()\nN = [int(i) for i in n]\nfor i in range(8):\n n = format(i, '03b')\n ans = N[0]\n msg = str(N[0])\n for j in range(3):\n if n[j] == '0':\n ans += N[j+1]\n msg += '+' + str(N[j+1])\n else:\n ans -= N[j+1]\n msg += '-' + str(N[j+1])\n if ans == 7:\n print(msg + \"=7\")\n break", "# \u89e3\u304d\u76f4\u3057\ndef add(i, b):\n if i:\n return \"-\" + str(b)\n else:\n return \"+\" + str(b)\ndef main():\n S = input()\n a, b, c, d = int(S[0]), int(S[1]), int(S[2]), int(S[3])\n ans = \"\"\n for i in range(2):\n for j in range(2):\n for k in range(2):\n if a + (-1)**i * b + (-1)**j * c + (-1)**k * d == 7:\n ans += str(a)\n ans += add(i, b)\n ans += add(j, c)\n ans += add(k, d)\n ans += \"=7\"\n print(ans)\n return\nmain()", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tC\n# CreatedDate: 2020-09-26 23:24:58 +0900\n# LastModified: 2020-09-26 23:33:37 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\n\n\ndef main():\n L = input()\n if int(L[0]) + int(L[1]) + int(L[2]) + int(L[3]) == 7:\n print((\"{}+{}+{}+{}=7\".format(L[0], L[1], L[2], L[3])))\n\n elif int(L[0]) + int(L[1]) + int(L[2]) - int(L[3]) == 7:\n print((\"{}+{}+{}-{}=7\".format(L[0], L[1], L[2], L[3])))\n\n elif int(L[0]) + int(L[1]) - int(L[2]) + int(L[3]) == 7:\n print((\"{}+{}-{}+{}=7\".format(L[0], L[1], L[2], L[3])))\n\n elif int(L[0]) - int(L[1]) + int(L[2]) + int(L[3]) == 7:\n print((\"{}-{}+{}+{}=7\".format(L[0], L[1], L[2], L[3])))\n\n elif int(L[0]) + int(L[1]) - int(L[2]) - int(L[3]) == 7:\n print((\"{}+{}-{}-{}=7\".format(L[0], L[1], L[2], L[3])))\n\n elif int(L[0]) - int(L[1]) + int(L[2]) - int(L[3]) == 7:\n print((\"{}-{}+{}-{}=7\".format(L[0], L[1], L[2], L[3])))\n\n elif int(L[0]) - int(L[1]) - int(L[2]) + int(L[3]) == 7:\n print((\"{}-{}-{}+{}=7\".format(L[0], L[1], L[2], L[3])))\n\n elif int(L[0]) - int(L[1]) - int(L[2]) - int(L[3]) == 7:\n print((\"{}-{}-{}-{}=7\".format(L[0], L[1], L[2], L[3])))\n\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "S = input()\nA,B,C,D = int(S[0]),int(S[1]),int(S[2]),int(S[3])\n\nif A+B+C+D == 7:\n print(str(A) + \"+\" + str(B) + \"+\" + str(C) + \"+\" + str(D) + \"=7\")\n \nelif A+B+C-D == 7:\n print(str(A) + \"+\" + str(B) + \"+\" + str(C) + \"-\" + str(D) + \"=7\")\n \nelif A+B-C+D == 7:\n print(str(A) + \"+\" + str(B) + \"-\" + str(C) + \"+\" + str(D) + \"=7\")\n \nelif A+B-C-D == 7:\n print(str(A) + \"+\" + str(B) + \"-\" + str(C) + \"-\" + str(D) + \"=7\")\n \nelif A-B+C+D == 7:\n print(str(A) + \"-\" + str(B) + \"+\" + str(C) + \"+\" + str(D) + \"=7\")\n \nelif A-B+C-D == 7:\n print(str(A) + \"-\" + str(B) + \"+\" + str(C) + \"-\" + str(D) + \"=7\")\n \nelif A-B-C+D == 7:\n print(str(A) + \"-\" + str(B) + \"-\" + str(C) + \"+\" + str(D) + \"=7\")\n \nelse:\n print(str(A) + \"-\" + str(B) + \"-\" + str(C) + \"-\" + str(D) + \"=7\")", "a, b ,c, d = input()\nS = '+-'\nfor i in S:\n for j in S:\n for k in S:\n left = a + i + b + j + c + k + d\n if eval(left) == 7:\n print(left + '=7')\n return", "ABCD = list(input())\n\na, b, c, d = int(ABCD[0]), int(ABCD[1]), int(ABCD[2]), int(ABCD[3])\n\nif a+b+c+d == 7:\n print('{0}+{1}+{2}+{3}=7'.format(a, b, c, d))\nelif a+b+c-d == 7:\n print('{0}+{1}+{2}-{3}=7'.format(a, b, c, d))\nelif a+b-c+d == 7:\n print('{0}+{1}-{2}+{3}=7'.format(a, b, c, d))\nelif a-b+c+d == 7:\n print('{0}-{1}+{2}+{3}=7'.format(a, b, c, d))\nelif a-b-c+d == 7:\n print('{0}-{1}-{2}+{3}=7'.format(a, b, c, d))\nelif a+b-c-d == 7:\n print('{0}+{1}-{2}-{3}=7'.format(a, b, c, d))\nelif a-b+c-d == 7:\n print('{0}-{1}+{2}-{3}=7'.format(a, b, c, d))\nelif a-b-c-d == 7:\n print('{0}-{1}-{2}-{3}=7'.format(a, b, c, d))", "A = list(map(int, list(input())))\n\ndef sign(x):\n return \"+\" if x == 1 else \"-\"\nfor i in [1,-1]:\n for j in [1,-1]:\n for k in [1,-1]:\n if A[0] + A[1] * i + A[2] * j + A[3] * k == 7:\n print(str(A[0]) + sign(i) + str(A[1]) + sign(j) +str(A[2]) + sign(k) + str(A[3]) + \"=7\")\n return", "n = input()\nN = [int(i) for i in n]\nfor i in range(8):\n n = format(i, '03b')\n ans = N[0]\n msg = str(N[0])\n for j in range(3):\n if n[j] == '0':\n ans += N[j+1]\n msg += '+' + str(N[j+1])\n else:\n ans -= N[j+1]\n msg += '-' + str(N[j+1])\n if ans == 7:\n print(msg + \"=7\")\n break", "from itertools import product\n\n\nA, B, C, D = list(input())\nfor x, y, z in product([\"+\", \"-\"], repeat=3):\n eqn = A + x + B + y + C + z + D\n if eval(eqn) == 7:\n print(f\"{eqn}=7\")\n break", "def some(num):\n return \"+\" if num==0 else \"-\"\n\n\ndef main():\n a, b, c, d = map(int, input())\n for i in range(2):\n for j in range(2):\n for v in range(2):\n op1 = some(i); op2=some(j); op3=some(v)\n if eval(f\"a{op1}b{op2}c{op3}d\") == 7:\n print(f\"{a}{op1}{b}{op2}{c}{op3}{d}=7\")\n return\n\n\nmain()"]
{"inputs": ["1222\n", "0290\n", "3242\n"], "outputs": ["1+2+2+2=7\n", "0-2+9+0=7\n", "3+2+4-2=7\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,043
91af0090d9c1127da5d4684f5cce50d0
UNKNOWN
A company has N members, who are assigned ID numbers 1, ..., N. Every member, except the member numbered 1, has exactly one immediate boss with a smaller ID number. When a person X is the immediate boss of a person Y, the person Y is said to be an immediate subordinate of the person X. You are given the information that the immediate boss of the member numbered i is the member numbered A_i. For each member, find how many immediate subordinates it has. -----Constraints----- - 2 \leq N \leq 2 \times 10^5 - 1 \leq A_i < i -----Input----- Input is given from Standard Input in the following format: N A_2 ... A_N -----Output----- For each of the members numbered 1, 2, ..., N, print the number of immediate subordinates it has, in its own line. -----Sample Input----- 5 1 1 2 2 -----Sample Output----- 2 2 0 0 0 The member numbered 1 has two immediate subordinates: the members numbered 2 and 3. The member numbered 2 has two immediate subordinates: the members numbered 4 and 5. The members numbered 3, 4, and 5 do not have immediate subordinates.
["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 = i_input()\naa=i_list()\nshain=[0]*n\nfor a in aa:\n shain[a-1]+=1\nfor s in shain:\n print(s)\n\n\n", "import collections\n\nn = int(input())\nli = list(map(int,input().split()))\nres = [0]*(n+1)\nfor i in li:\n res[i]+=1\n# count = collections.Counter(li)\n# print(count)\nfor i in range(1,len(res)):\n print((res[i]))\n# print(\"0\")\n", "# coding=utf-8\n\ndef __starting_point():\n N = int(input())\n li = list(map(int, input().split()))\n\n ans = [0] * (N+1)\n\n for i in range(len(li)):\n ans[li[i]] += 1\n\n #print(ans)\n\n for i in range(1, N+1):\n print((ans[i]))\n\n__starting_point()", "n = int(input())\na = [0, 0] + list(map(int, input().split()))\n\nno_buka = [0 for _ in range(n + 1)]\n\nfor i in range(2, n + 1):\n no_buka[a[i]] += 1\n\nfor j in range(1, n + 1):\n print((no_buka[j]))\n", "n = int(input())\nA = list(map(int, input().split()))\n\nans = [0] * n\n\nfor a in A:\n ans[a-1] += 1\n\nfor i in ans:\n print(i)", "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\nn=k()\nl=l()\na=[]\nfor i in range(n):\n a.append(0)\nfor i in range(n-1):\n a[l[i]-1]+=1\nfor i in range(n):\n print((a[i]))\n", "N = int(input())\narray = list(map(int,input().split()))\nans = [0]*N\nfor i in array:\n ans[i-1] += 1\n\nfor i in range(N):\n print( ans[i] )", "n = int(input())\na = list(map(int, input().split()))\nl = [0] * (n+1)\n\nfor i in a:\n l[i] += 1\n\nfor i in range(1,n+1):\n print(l[i])", "n = int(input())\na = list(map(int, input().split()))\na.append(0)\na.sort()\n\nflg = [0 for i in range(n)]\nfor i in range(n):\n flg[a[i]] += 1\nfor i in range(n-1):\n print(flg[i+1])\n\nprint(0)", "import collections as c\nn=int(input());t=c.Counter(map(int,input().split()))\nfor i in range(1,n+1): print([0,t[i]][i in t]) ", "from collections import Counter\n\nN = int(input())\nA = list([int(x) for x in input().split()])\n\nresult = dict(Counter(A))\n\nfor i in range(1, N+1):\n if i in result:\n print((result[i]))\n else:\n print((0))\n\n", "N = int(input())\nA = list(map(int,input().split()))\nans = [0] * N\nfor i in range(N-1):\n ans[A[i] - 1] += 1\nfor i in range(N):\n print(ans[i])", "N = int(input())\nA = list(map(int, input().split()))\n\nlis = [0] * N\nfor i in range(N - 1):\n lis[(A[i] - 1)] += 1\n\nfor i in range(N):\n print((lis[i]))\n", "n = int(input())\nA = list(map(int,input().split()))\nfor i in range(n-1) :\n A[i] = A[i] - 1\nres = [[] for i in range(n)]\n\nfor i in range(n-1) :\n res[A[i]].append(i)\n\nfor i in range(n) :\n print(len(res[i]))", "N = int(input())\ndct = {}\nA = list(map(int, input().split()))\nfor a in A:\n if a in dct.keys():\n dct[a] += 1\n else:\n dct[a] = 1\nfor n in range(1, N+1):\n print(dct.get(n, 0))", "n=int(input())\na=list(map(int,input().split()))\nans=[0]*(n+1)\n\nfor i in range(n-1):\n ans[a[i]]+=1\nans.pop(0)\nfor j in ans:\n print(j)", "N = int(input())\nA = list(map(int,input().split()))\nans_list = [0]*N\n\nfor i in range(N-1):\n ans_list[A[i]-1] += 1\n \nfor j in range(N):\n print(ans_list[j])", "N=int(input())\nA=list(map(int,input().split()))\nA_count=[0]*N\nfor i in range(N-1):\n A_count[A[i-1]-1]+=1\nfor i in range(N):\n print(A_count[i])", "N = int(input())\nA = [0]*(N)\nfor i in input().split():\n A[int(i)-1] = A[int(i)-1]+1\nfor i in A:\n print(i)\n", "N=int(input())\nA=list(map(int,input().split()))\ncnt=[0 for i in range(N)]\nfor i in range(N-1):\n cnt[A[i]-1]+=1\nfor i in range(N):\n print((cnt[i]))\n", "def main():\n N = int(input())\n A = list(map(int,input().split()))\n list_a = [0]*N\n for i in range(len(A)):\n list_a[A[i]-1] += 1\n\n for i in range(N):\n print((list_a[i]))\n\nmain()\n", "n={i+1:0 for i in range(int(input()))}\nfor i in map(int,input().split()): n[i]+=1\n[print(i) for i in n.values()]", "n = int(input())\na = list(map(int,input().split()))\n\nb = [0]*n\n\nfor i in range(len(a)):\n b[a[i]-1] += 1\n\nfor i in range(n):\n print((b[i]))\n", "import sys\nreadline = sys.stdin.readline\n\nN = int(readline())\nA = list(map(int,readline().split()))\n\nans = [0] * N\n\nfor i in range(len(A)):\n ans[A[i] - 1] += 1\n \nfor a in ans:\n print(a)", "N = int(input())\nA = [int(i) for i in input().split()]\nans = [0]*N\nfor i in range(N-1):\n ans[A[i]-1] += 1\nfor i in ans:\n print(i)", "# import math\n# import statistics\na=int(input())\n#b,c=int(input()),int(input())\n# c=[]\n# for i in a:\n# c.append(i)\n# e1,e2 = map(int,input().split())\nf = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\n\nf.sort()\ncount=1\nans=[0 for i in range(a)]\n\nfor i in range(len(f)-1):\n if f[i]==f[i+1]:\n count+=1\n else:\n ans[f[i]-1]=count\n count=1\nif count>=1:\n ans[f[-1]-1]=count\nfor i in ans:\n print(i)", "B=[0]*int(input())\nfor a in map(int,input().split()):B[a-1]+=1\nfor b in B:print(b)", "N = int(input())\nA = list(map(int, input().split()))\n\nresult = [0] * N\n\nfor a in A:\n result[a-1] += 1\n \nfor i in range(N):\n print((result[i]))\n", "N=int(input())\nA=list(map(int,input().split()))\nB=[0]*N\nfor i in range(0,N-1):\n B[A[i]-1]+=1\n\nfor i in range(N):\n print((B[i]))\n", "# Begin Header {{{\nfrom math 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 accumulate, product, permutations, combinations, combinations_with_replacement\n# }}} End Header\n# _________\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u3053\u3053\u304b\u3089\uff01\uff01___________\nn = int(input())\nA = list(map(int, input().split()))\nb = [0]*(n+1)\nfor i in A:\n b[i]+=1\nfor i in range(1, n+1):\n print((b[i]))\n", "from collections import Counter\nN = int(input())\nA = list(map(int, input().split()))\nC = Counter(A)\nfor i in range(1, N+1):\n print(C[i])", "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 = [[] for i in range(n + 1)]\nres = 0\n\nfor i in range(1, n):\n tmp[A[i - 1]].append(i + 1)\nres = \"\\n\".join([str(len(r)) for r in tmp[1:]])\n\nprint(res)\n", "import copy\nn=int(input())\nA=list(map(int,input().split()))\nL=[0]*n\n\nfor x in A:\n L[x-1] += 1\nfor i in L:\n print(i)\n", "import collections\n\n\ndef main() -> None:\n n = int(input())\n boss_dict = collections.Counter(tuple(map(int, input().split())))\n\n for i in range(n):\n print((boss_dict[i+1] if boss_dict[i+1] else 0))\n\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int,input().split()))\nc=[0]*n\nfor i in a:\n c[i-1] +=1\nfor i in c:\n print(i)", "import collections\nN = int(input())\na = list(map(int, input().split()))\nl = [0]* N\n\nfor i in range(N-1):\n #print(i, a[i]-1)\n l[a[i]-1] += 1\n#print(l)\nfor j in range(N):\n print((l[j]))\n", "from typing import List\n\n\ndef answer(n: int, a: List[int]) -> List[int]:\n result = [0] * n\n for i in a:\n result[i - 1] += 1\n return result\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n for i in answer(n, a):\n print(i)\n\n\ndef __starting_point():\n main()\n__starting_point()", "import collections\n\nN=int(input())\nA=list(map(int,input().split()))\nc=collections.Counter(A)\n\nfor i in range(1,N+1):\n print((c[i]))\n", "def calc(n, m):\n import collections\n edict = dict()\n for i in range(1, len(m) + 2):\n edict[i] = []\n for j in range(len(m)):\n edict[m[j]].append(j)\n for k in edict:\n print((len(edict[k])))\n\n\ndef main():\n n = int(input())\n employees = list(int(v) for v in input().split())\n return calc(n, employees)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nalst = list(map(int, input().split()))\nans = [0 for _ in range(n)]\nfor a in alst:\n ans[a - 1] += 1\nprint(*ans, sep = \"\\n\")", "n = int(input())\nans = [0] * n\na = list(map(int, input().split()))\nfor i in range(n - 1):\n ans[a[i] - 1] += 1\nprint(*ans, sep='\\n')\n", "n=int(input())\nl=list(map(int,input().split()))\na=[]\nfor i in range(n):\n a.append(0)\nfor i in range(n-1):\n a[l[i]-1]+=1\nfor i in range(n):\n print(a[i])", "n = int(input())\na = list(map(int, input().split()))\nans = [0 for _ in range(n)]\nfor i in a:\n ans[i-1] += 1\n\nfor m in ans:\n print(m)\n", "# author: Taichicchi\n# created: 12.09.2020 19:50:20\n\nfrom collections import Counter\nimport sys\n\nN = int(input())\n\nA = list(map(int, input().split()))\n\n\nc = Counter(A)\n\nfor i in range(N):\n print((c[i + 1]))\n", "N = int(input())\nA = list(map(int, input().split()))\n\nans = [0] * N\n\nfor i in range(N - 1):\n\tans[A[i] - 1] += 1\nfor i in range(N):\n\tprint(ans[i])", "n=[0]*int(input())\nfor i in map(int,input().split()): n[i-1]+=1\nprint(*n,sep=\"\\n\") ", "import sys\nimport math\nfrom collections import defaultdict, deque, Counter\nfrom copy import deepcopy\nfrom bisect import bisect, bisect_right, bisect_left\nfrom heapq import heapify, heappop, heappush\n \ninput = sys.stdin.readline\ndef RD(): return input().rstrip()\ndef F(): return float(input().rstrip())\ndef I(): return int(input().rstrip())\ndef MI(): return map(int, input().split())\ndef MF(): return map(float,input().split())\ndef LI(): return list(map(int, input().split()))\ndef TI(): return tuple(map(int, input().split()))\ndef LF(): return list(map(float,input().split()))\ndef Init(H, W, num): return [[num for i in range(W)] for j in range(H)]\n \n \ndef main():\n N = I()\n L = LI()\n D = [0]*N\n\n for index, num in enumerate(L[::-1]):\n D[num-1]+=1\n for i in D:\n print(i)\n \ndef __starting_point():\n main()\n__starting_point()", "n=int(input())\nans=[0]*n\nl=list(map(int,input().split()))\nfor i in range(n-1):\n ans[l[i]-1]+=1\nfor i in range(n):\n print(ans[i])", "N = int(input())\nA = [0] * 2 + list(map(int, input().split()))\n\nl = [0] * (N + 1)\nfor i in range(2, N + 1):\n l[A[i]] += 1\n\nfor i in range(1, N + 1):\n print((l[i]))\n", "n = int(input())\na = list(map(int,input().split()))\n\nemp = [0]*(n+1)\n\nfor i in range(len(a)):\n emp[a[i]] += 1\n\nfor i in range(1,n+1):\n print((emp[i]))\n", "import sys\n\ninput = sys.stdin.readline\nN = int(input())\nA = list(map(int, input().split()))\n\nans = [0] * N\nfor a_i in A:\n ans[a_i-1] += 1\n\nfor a in ans:\n print(a)", "from collections import Counter\n\nn = int(input())\na = list(map(int,input().split()))\n\ns = Counter(a)\n\nfor i in range(1,n+1):\n print(s[i])", "n = int(input())\n\nA = list(map(int, input().split()))\n\nB = [0 for i in range(n)]\nfor i in range(n-1):\n B[A[i]-1] += 1\nfor i in range(n):\n print (B[i])", "import collections as c\nn,t=int(input()),c.Counter(map(int,input().split()))\nfor i in range(1,n+1): print([0,t[i]][i in t])", "n = int(input())\na =list(map(int,input().split()))\nb = sorted(a)\nc = [0]*n\nfor i in range(0,n-1):\n c[a[i]-1]+=1\nfor i in range(n):\n print(c[i])", "n = int(input())\nA = list(map(int, input().split()))\nli = [0]*(n+1)\nfor i in range(n-1):\n b = A[i]-1\n li[b]+=1\nfor i in range(n):\n print(li[i])", "n = int(input())\na = [int(s) for s in input().split()]\nb = [0] * n\nfor i in a:\n b[i - 1] += 1\n\nfor i in b:\n print(i)", "n = int(input())\na = list(map(int, input().split()))\nnumber_buka = [0]*n\n\nfor i in a:\n number_buka[i-1] += 1\n\nfor j in number_buka:\n print(j) ", "N = int(input())\nA = list(map(int, input().split()))\nanswer = [0] * N\n\nfor i in A:\n answer[i-1] += 1\n\nfor n in answer:\n print(n)", "n = int(input())\nemployees = input().split(\" \")\nemployees_changed = []\nfor i in range(0, len(employees)):\n\temployees_changed.append(int(employees[i]))\n\nans = [0] * (n+1)\nfor x in employees_changed:\n\tans[x] += 1\n\nfor i in range(1, n+1, 1):\n print((ans[i]))\n# Compotitive Programming\n", "N = int(input())\nA = list(map(int, input().split()))\n\nans = [0] * N\n\nfor i in A:\n ans[i-1] += 1\n\nfor j in ans:\n print(j)", "n=int(input())\na=list(map(int,input().split()))\nc=[0 for _ in range(n)]\nfor i in range(len(a)):\n c[a[i]-1]+=1\nfor j in range(len(c)):\n print((c[j]))\n \n", "def resolve():\n n = int(input())\n ans = [0]*n\n a = list(map(int,input().split()))\n for i in a:\n ans[i-1] += 1\n for i in ans:\n print(i)\nresolve()", "n = int(input())\na = list(map(int, input().split()))\n\nans = [0] * n\n\nfor x in a:\n ans[x-1] += 1\n\n\nfor x in ans:\n print(x)", "N = int(input())\nA = list(map(int, input().split()))\nbuka = [0]*N\nfor a in A:\n buka[a-1] += 1\nfor x in buka:\n print(x)", "N = int(input())\nA = list(map(int,input().split()))\n\nANS = []\nfor i in range(N):\n ANS.append(0)\n\n\nfor i in range(N-1):\n ANS[A[i]-1] += 1\n\nfor i in range(N):\n print(ANS[i])", "n=int(input())\nw=list(map(int,input().split()))\na=[0]*(n)\n\nfor i in range(n-1):\n a[w[i]-1]+=1\n\nfor j in range(n):\n print(a[j])", "n = int(input())\na = [int(x) for x in input().split()]\nm = {i : 0 for i in range(1, n+1)}\n\nfor i, x in enumerate(a):\n m[x] += 1\n\nfor x in range(1, n+1):\n print(m[x])", "num = int(input())\ntable = list(map(int, input().split()))\ntable2 = []\nfor i in range(num):\n table2.append(0)\n\nfor j in range(len(table)):\n table2[table[j]-1] += 1\n\nfor k in table2:\n print(k)\n", "n=int(input())\na=list(map(int,input().split()))\n\nc=[0]*n\n\nfor i in range(len(a)):\n c[a[i]-1]=c[a[i]-1]+1\n\nfor i in c:\n print(i)", "n = int(input())\na = list(map(int,input().split()))\n\nb = [0]*n\n\nfor i in range(n-1):\n b[a[i]-1] += 1\n\nfor j in range(len(b)):\n print((b[j]))\n", "n = int(input())\na = list(map(int, input().split()))\nl = [0] * n\nfor i in range(n-1):\n l[a[i]-1] += 1\nfor i in range(n):\n print(l[i])", "n = int(input())\na = [0] + list(map(int,input().split()))\nl = [0]*n\nfor i in a:\n l[i-1] += i\nfor j in range(n):\n l[j] = int(l[j]/(j+1))\nfor k in l:\n print(k,end=\"\\n\")", "n = int(input())\na = list(map(int, input().split()))\n\nans = [0] * (n+1)\n\nfor x in a:\n ans[x] += 1\n\nfor i in range(1, n+1, 1):\n print((ans[i]))\n", "n = int(input())\na = list(map(int,input().split()))\nans = [0 for i in range(n)]\nfor i in a:\n ans[i-1] += 1\nfor i in ans:\n print(i)", "n = int(input())\na = list(map(int, input().split()))\nd = dict()\nfor i in range(n):\n d[i] = 0\nfor e in a:\n d[e-1] += 1\nfor i in range(n):\n print(d[i])", "n = int(input())\n\na = [0 for _ in range(n-1)]\na = [int(s) for s in input().split()]\n\nd = {}\n\nfor i in range(n-1):\n boss = a[i]\n d[boss] = d.setdefault(boss,0) + 1\n\nfor i in range(n):\n ans = d.setdefault(i+1,0)\n print(ans)\n\n\n", "N = int(input())\nhie_list = list(map(int, input().split()))\n\nhie_dic = {}\n\nfor i in range(N - 1):\n hie_dic[i + 1] = 0\n hie_dic[hie_list[i]] += 1\n\nfor i in range(N - 1):\n print(hie_dic[i + 1])\nprint(0)", "import collections\nn = int(input())\na = list(map(int,input().split()))\nc = collections.Counter(a)\nfor i in range(1, n+1):\n print(c[i])", "n = int(input())\na = list(map(int,input().split()))\nfrom collections import Counter\nl = Counter(a)\nfor i in range(n):\n print(l[i+1])", "N = int(input())\nA = list(map(int, input().split()))\n\nans = [0 for _ in range(N)]\n\nfor a in A:\n ans[a-1] += 1\nfor i in ans:\n print(i)", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect\n#from operator import itemgetter\n#from heapq import heappush, heappop\n#import numpy as np\n#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson\n#from scipy.sparse import csr_matrix\n#from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN\nimport sys\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nnf = lambda: float(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnb = lambda: list(map(float, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nN = ni()\nA = na()\nd = collections.Counter(A)\nfor i in range(1, N+1):\n print(d[i])", "#ABC163\nimport collections\nN=int(input())\nA =list(map(int,input().split()))\nc = collections.Counter(A)\nfor i in range(N):\n print(c[i+1])", "n = int(input())\naa = [0]+list(map(int, input().split()))\nbuka = [0]*n\n\nfor i in range(1, n):\n buka[aa[i]-1] += 1\n\nfor i in range(n):\n print(buka[i])", "n=[0]*int(input())\nfor i in map(int,input().split()): n[i-1]+=1\nprint(*n,sep='\\n')", "def __starting_point():\n\n n = int(input())\n A = list(map(int,input().split()))\n\n B = [0]*n\n for a in A:\n B[a-1] += 1\n for b in B:\n print(b)\n\n\n__starting_point()", "N = int(input())\nA = list(map(int,input().split()))\n#A.reverse()\nans = [0 for _ in range(N)]\nfor i in reversed(range(N-1)):\n #\u4ecai\u756a\u76ee(0index)\u306e\u793e\u54e1\n boss = A[i]-1 #0index\n ans[boss] += 1\n #print(ans,i,boss)\nfor x in ans:\n print(x)", "n = int(input())\nA = list(map(int,input().split()))\nL = [0]*n\nfor i in range(n-1):\n L[A[i]-1] += 1\nfor l in L:\n print(l)"]
{"inputs": ["5\n1 1 2 2\n", "10\n1 1 1 1 1 1 1 1 1\n", "7\n1 2 3 4 5 6\n"], "outputs": ["2\n2\n0\n0\n0\n", "9\n0\n0\n0\n0\n0\n0\n0\n0\n0\n", "1\n1\n1\n1\n1\n1\n0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,784
9b875472787638c02345c9d1d24bff20
UNKNOWN
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X. -----Constraints----- - X is an integer. - 1≀X≀10^9 -----Input----- The input is given from Standard Input in the following format: X -----Output----- Print the earliest possible time for the kangaroo to reach coordinate X. -----Sample Input----- 6 -----Sample Output----- 3 The kangaroo can reach his nest at time 3 by jumping to the right three times, which is the earliest possible time.
["x=int(input())\nans=0\na=0\nfor i in range(1,x+1):\n a+=i\n ans+=1\n if a>=x:\n print(ans)\n break", "import math\nx = int(input())\nans = math.ceil((-1 + math.sqrt(8 * x + 1)) / 2)\nprint(ans)", "x = int(input())\nt= 0\nwhile t*(t+1)//2 < x:\n t += 1\nprint(t)", "import math\nx = int(input())\n\ncnt = 0\nwhile x > 0:\n cnt += 1\n x -= cnt\nprint(cnt)\n", "x=int(input())\na=0\nfor i in range(x+1):\n if a+i>=x:\n print(i)\n break\n else:\n a+=i", "'''\nCreated on 2020/08/28\n\n@author: harurun\n'''\ndef main():\n import sys\n pin=sys.stdin.readline\n pout=sys.stdout.write\n perr=sys.stderr.write\n \n X=int(pin())\n i=1\n while i<=X:\n if i*(i+1)>=2*X:\n print(i)\n return \n i+=1\n return \nmain()", "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\nX = INT()\n\nA = []\ntmp = 0\nfor i in range(1, X+1):\n tmp += i\n A.append(tmp)\n if tmp >= X:\n print(i)\n break\n", "x = int(input())\n\ncur = 0\nfor i in range(0, 45000):\n cur += i\n if x <= cur:\n print(i)\n break", "x = int(input())\na = 0\nfor i in range(1,10**10):\n a += i\n if a >= x :\n print(i)\n break\n", "X=int(input())\nN=1\nwhile N*(N+1)//2<X:\n N+=1\nprint(N)\n", "def solve():\n X = int(input())\n now = 0\n for i in range(X + 1):\n now += i\n if now >= X:\n return i\n\nprint((solve()))\n", "x = int(input())\n\nub = 10**9\nlb = 0\n\nwhile ub - lb > 1:\n mid = (lb + ub) // 2\n if mid*(mid+1)//2 >= x:\n ub = mid\n else:\n lb = mid\nprint(ub)", "x=int(input())\ns=0\nfor i in range(1,x+1):\n s += i\n if s>=x:\n print(i)\n return", "x = int(input())\n\ncnt = 0\ns = 0\n\nfor i in range(1, x+1):\n cnt += 1\n s += i\n if s >= x:\n break\n\nprint(cnt)", "#43 C - Go Home\nX = int(input())\n\nsum_i = 0\nfor i in range(1,10**5):\n sum_i += i\n if sum_i >= X:\n ans = i\n break\nprint(ans)", "x=int(input())\nans=0\nwhile True:\n if ans*(ans+1)/2 >= x:\n print(ans)\n break\n ans+=1\n", "x = int(input())\n\nres = 0\ni = 1\nwhile res < x:\n res += i\n i += 1\n\nprint(i-1)", "import math\nX = int(input())\nruto = math.ceil(math.sqrt(2*X))+1\nkari = ruto**2+ruto\nans=1\nfor i in range(ruto-1, 0, -1):\n if i**2+i < 2*X:\n ans = i+1\n break\n kari = i**2+i\nprint(ans)\n", "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\n\nx = ni()\ntmp = 0\nfor i in range(1,10**9):\n tmp+=i\n if tmp>=x:\n break\nprint(i)\n", "n=int(input())\nans = 0\nAns = 1\n\nwhile ans < n:\n ans += Ans\n Ans += 1\nprint(Ans-1)", "X = int(input())\nfrom itertools import count\nfor t in count(1,1):\n if (t-1)*t >= 2*(X-t):\n print(t); break", "x = int(input())\n\nfor i in range(1, x+1):\n if i * (i + 1)//2 >= x:\n print(i)\n break\n", "X = int(input())\n\nt = 0\nSum = 0\nwhile Sum < X:\n t += 1\n Sum += t\n\nprint(t)", "x = int(input())\nans = int((x * 2) ** 0.5)\nwhile 1:\n if ans * (ans + 1) // 2 >= x:\n print(ans)\n break\n ans += 1", "x=int(input())\na=0\nfor i in range(x+1):\n if a+i>=x:\n print(i)\n break\n else:\n a+=i\n", "x = int(input())\ni = 1\ntmp = 0\nwhile tmp < x:\n tmp += i\n i += 1\nprint(i-1)", "x = int(input())\n\nt = 0\nwhile True:\n if not (t*(t+1))/2 >= x:\n t += 1\n else:\n break\nprint(t)\n", "x = int(input())\nplace = 0\ni = 1\n\nwhile 1:\n if place + i >= x:\n print(i)\n break\n else:\n place += i\n i += 1", "x = int(input())\n\ni=1\nwhile i*(i+1)//2 < x:\n i+=1\n\nprint(i)", "X=int(input())\nt=int((2*X)**0.5)+1\nans=0\nfor i in range(t,0, -1):\n if X <= i*(i+1)/2:\n ans=i\n else:\n break\nprint(ans)", "x = int(input())\nn = 1\nwhile n*(n+1)//2 < x: n += 1\nprint(n)", "X = int(input())\n\nL = [0]\nfor i in range(1, 10 ** 5):\n L.append(L[i - 1] + i)\n\nans = 0\nfor i in range(1, X + 1):\n # print(L[i])\n if L[i] >= X:\n ans = i\n break\n\n\nprint(ans)\n", "x = int(input())\n\nok = x\nng = -1\nwhile ok - ng > 1:\n mid = (ok + ng) // 2\n if mid * (mid + 1) // 2 >= x:\n ok = mid\n else:\n ng = mid\n\nprint(ok)", "x = int(input())\ni = 0\ntmp = 0\nwhile tmp < x:\n tmp += i + 1\n i += 1\nprint(i)", "from math import floor\nX = int(input())\n\nfor n in range(1,floor(X/2)+2):\n if n * (n + 1) //2 >= X:\n ans = n\n break\n \nprint(ans)", "import math\nX = int(input())\nP = math.ceil((-1+(1+8*X)**(1/2))/2)\nprint(P)", "X = int(input())\n\ncnt = 0\ns = 0\nfor i in range(1, X+1):\n cnt += 1\n s += i\n if s >= X:\n break\n\nprint(cnt)\n", "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 main():\n x = ni()\n d = 0\n for i in range(1, x + 1):\n d += i\n if d >= x:\n print(i)\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "def get_index(n):\n i=1\n while True:\n if n<=piramid(i):\n return i-1\n i+=1\n\ndef piramid(n):\n return n*(n+1)//2\n\nn=int(input())\nindex=get_index(n)\n\nprint(index+1)", "x=int(input())\nans,k,i=0,1,0\nwhile 1:\n ans+=k\n if ans>=x:\n break\n k+=1\nprint(k)", "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: map(int, INPUT().split())\nS_MAP = lambda: 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 X = INT()\n\n i = 1\n ans = 0\n while 1:\n X -= i\n ans += 1\n if X <= 0: break\n i += 1\n\n print(ans)\n\n\ndef __starting_point():\n main()\n__starting_point()", "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\nX = INT()\n\nA = []\nfor i in range(1, 2 * (int(sqrt(X))+1)):\n a = i * (i + 1) // 2\n # print(a)\n if a <= X:\n A.append(a)\n else:\n ans = len(A)\n mi = A.pop()\n ma = a\n break\n# print(mi, ma)\n# print(ans)\nif mi == X:\n print(ans)\nelse:\n print((ans+1))\n \n \n\n\n\n\n\n\n", "n = int(input())\ntmp = 0\nfor i in range(1, n + 1):\n tmp += i\n if tmp >= n:\n print(i)\n break", "X = int(input())\n\nimport math as m\n\nt = int(m.sqrt(X*2))\nif t*(t+1)/2 < X:\n t += 1\n\nprint(t)", "N=int(input())\nfor i in range(1,N//2+10):\n\ttmp=((i+1)*(i))//2\n\tif N-tmp==0:\n\t\tprint(i)\n\t\treturn\n\tif N-tmp<i+1:\n\t\tprint(i+1)\n\t\treturn", "x = int(input())\n\nans = 0\n\nfor t in range(10**9):\n if (t*(1+t))//2 >= x:\n ans = t\n break\n \nprint(ans)\n", "x = int(input())\ni = 1\nwhile True:\n if (i+1)*i//2 >= x:\n print(i)\n break\n i += 1\n\n", "n = int(input())\n\nfor i in range(1,n+1):\n if n <= i * (i + 1) / 2:\n print(i)\n break", "i=1\nimport copy\nX=int(input())\ns=0\nwhile True:\n s+=copy.copy(i)\n if s>=X:\n print(i)\n return\n i+=1\n", "X = int(input())\ni = 0\n\nwhile i <= X:\n c = (i*(i+1)) / 2\n if c >= X:\n print(i)\n break\n i += 1", "X = int(input())\nX2 = X*2\nk = 1\nwhile True:\n if k*(k+1) >= X2:\n print(k)\n return\n k += 1\n\n", "x = int(input())\n\ncnt = 0\ni = 0\nwhile i < x:\n i += cnt\n cnt += 1\nprint(cnt - 1)", "import math\nx = int(input())\n\ni = math.ceil((-1 + math.sqrt(1 + 8 * x)) / 2)\n\nprint(i)", "X = int(input())\na = 0\nb = 1\nwhile a < X:\n a += b\n b += 1\nprint(b-1)", "x = int(input())\n\nsum = 0\nfor i in range(1,100000):\n sum += i\n if sum >= x:\n print(i)\n break", "#!/usr/bin/env python3\n\n\ndef main():\n x = int(input())\n n = 0\n i = 1\n while n < x:\n n += i\n i += 1\n print((i - 1))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "x = int(input())\nans = 0\nk = 0\nt = 0\nwhile k < x:\n k = t * (t + 1) / 2\n t += 1\nans = t - 1\nprint(ans)", "x = int(input())\nans = 0\npos = 0\nwhile pos < x:\n pos += ans+1\n ans += 1\nprint(ans)\n", "X = int(input())\n\nfor i in range(1,100000):\n if X <= i*(i+1)//2:\n print(i)\n break", "x=int(input())\nt=0\np=0\nwhile p<x:\n t+=1\n p+=t\nprint(t)", "# C - Go Home\ndef main():\n x = int(input())\n cnt = 0\n for i in range(x + 1):\n cnt += i\n if cnt >= x:\n print(i)\n return\n \ndef __starting_point():\n main()\n__starting_point()", "x=int(input())\nfor i in range(1,x+1):\n if x<=(i*(i+1))//2:\n print(i)\n break", "x = int(input())\n\n# 1, 2, 3, ... , n\u306e\u7dcf\u548c\u304cX\u4ee5\u4e0a\u306a\u3089\u3070\u3001\n# \u9069\u5f53\u306b\u4fdd\u6301\u3092\u3044\u308c\u308b\u3053\u3068\u3067\u305f\u3069\u308a\u7740\u3051\u308b\n# \u7dcf\u548c\u306e\u516c\u5f0f\u306f(1 + n)*n//2\n\nans = 0\nwhile True:\n if ((1+ans)*ans)//2 >= x:\n print(ans)\n return\n ans+=1", "import math\n\ndef goukei(n):\n return int(n*(n+1)/2)\n\nx = int(input())\ntmp = int(math.sqrt(2 * x))\n#print(tmp,goukei(tmp))\nwhile goukei(tmp)<x:\n tmp += 1\n\nprint(tmp)", "x = int(input())\nsn = 0\nfor i in range(1, 10 ** 5):\n sn = sn + i\n if sn >= x:\n print(i)\n break\n", "X = int(input())\ncnt = 0\ndist = 0\nwhile dist < X:\n cnt += 1\n dist += cnt\nprint(cnt)", "x=int(input())\nfor n in range(1,x+1):\n s=n*(n+1)/2\n if s>=x:\n print(n)\n return\n", "X = int(input())\ndef sum_num(x):\n A = [0]\n counter = 0\n for i in range(1,10**7):\n counter += i\n A.append(counter)\n if A[-2] <= x <= counter:\n return A\n\nprint(len(sum_num(X))-1)", "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 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 = 1\nans = 0\ninf = float(\"inf\")\nal = \"abcdefghijklmnopqrstuvwxyz\"\nAL = al.upper()\n\nN = k()\n \nfor i in range(1,N+1):\n if 2*N <= (i+1)*i:\n print(i)\n break", "x = int(input())\nfor i in range(1000000000):\n if x <= i*(i+1)/2:\n print(i)\n return\n", "X=int(input())\nSUM=0\nfor i in range(1,10**6):\n SUM += i\n if SUM >= X:\n print(i)\n return", "N = int(input())\nans = 0\nCN = 0\nwhile CN < N:\n ans += 1\n CN += ans\n\nprint(ans)", "import sys\nX=int(input())\n\nif not ( 1 <= X <= 10**9 ): return\nres=0\ncount=0\nfor I in range(1,X+1):\n count += 1\n res += count\n if res >= X:\n print(count)\n return", "x = int(input())\n\ni=1\ncum=[0]\nwhile cum[-1] < 10**9:\n cum+=[cum[-1]+i]\n i+=1\n\nimport bisect\nindex = bisect.bisect_left(cum, x)\n\nprint(index)", "x = int(input())\nmax = 0\ntotal = 0\nfor i in range(1,x+1):\n total += i\n if total >=x:\n max = i\n break\nprint(max)", "x = int(input())\nans = 0\nwhile ans * (ans+1) / 2 < x:\n ans += 1\nprint(ans)", "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd\nfrom itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left\nfrom heapq import heappush, heappop\nfrom functools import reduce\nfrom decimal import *\ndef input(): return sys.stdin.readline().strip()\ndef INT(): return int(input())\ndef MAP(): return list(map(int, input().split()))\ndef LIST(): return list(map(int, input().split()))\ndef ZIP(n): return list(zip(*(MAP() for _ in range(n))))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10 ** 9 + 7\n\nX = Decimal(INT())\nprint((((Decimal(-1)+(8*X).sqrt())/Decimal(2)).quantize(Decimal(\"0\"), rounding=ROUND_CEILING)))\n", "x=int(input())\n\nnum=0\ncnt=0\n\nfor i in range(1,10**9):\n num+=i\n cnt+=1\n if num>=x:\n break\n \nprint(cnt)", "N=int(input())\nfor i in range(1,10**5):\n if (i*(i+1))//2>=N:\n print(i)\n return", "x=int(input())\nfor i in range(1,10**5):\n if x<=(i*(i+1))//2:\n print(i)\n break", "def main():\n x = int(input())\n\n answer = 0\n tmp = 0\n for i in range(10 ** 9):\n tmp += i\n if tmp >= x:\n answer = i\n break\n\n print(answer)\n\n\ndef __starting_point():\n main()\n__starting_point()", "import math\nprint(math.ceil( (math.sqrt(1 + 8 * int(input())) - 1) / 2 ))", "x = int(input())\nans = 0\ni = 0\nwhile True:\n i += 1\n x -= i\n ans += 1\n if x <= 0:\n break\nprint(ans)\n", "from math import sqrt\nx = int(input())\n\nprint((int(-(-(-1+sqrt(1+8*x))//2))))\n", "X = int(input())\nCnt = 0\nSum = 0\nwhile Sum<X:\n Cnt += 1\n Sum += Cnt\nprint(Cnt)", "x=int(input())\nans=0\nres=1\nwhile ans<x:\n ans+=res\n res+=1\nprint(res-1)", "s=int(input())\nn=1\ns2=0\nwhile True:\n s2=n*(n+1)//2\n if s2>=s:\n print(n)\n break\n else:\n n=n+1", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 29 15:44:49 2020\n\n@author: liang\n\"\"\"\n\nX = int(input())\n\nans = 0\ntmp = 0\ni = 1\nwhile True:\n tmp += i\n if tmp >= X:\n print(i)\n break\n i += 1", "x = 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)]\nt = 0\nc = 0\n\nwhile True:\n if c >= x:\n break\n t += 1\n c += t\n\nprint(t)\n", "X=int(input())\nm=0\nans=0\nfor i in range(1,X+1):\n if X<=m:break\n m+=i\n ans+=1\nprint(ans)", "x = int(input())\nk = 0\nfor i in range(1, x+1):\n k+=i\n if k >= x:\n print(i)\n return\n", "import math\nX = int(input())\nn = math.ceil((math.sqrt(1+8*X) - 1)/2)\nans = n\nprint(ans)\n", "X = int(input())\n\ni = 0\ncnt = 0\nwhile cnt < X:\n cnt += i + 1\n i += 1\nprint(i)\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\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())\nx = I()\nt = 0\nwhile (t*(t+1))/2 < x:\n t += 1\nprint(t)\n", "x=int(input())\n#\u968e\u5dee\u6570\u5217\ny,i=1,1\nwhile y<x:\n i+=1\n y+=i\nprint(i)", "X = int(input())\n\npos = 0\ni = 0\nwhile pos < X:\n i += 1\n pos += i\nprint(i)", "X = int(input())\n\ntime = 0\npos = 0\nwhile pos < X:\n time += 1\n pos += time\n\nprint(time)\n", "X = int(input())\n\nfor p in range(100000):\n if p * (p + 1) // 2 >= X:\n break\n\nprint(p)"]
{"inputs": ["6\n", "2\n", "11\n"], "outputs": ["3\n", "2\n", "5\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,146
5415f0072b78795f216c38940af2b1a5
UNKNOWN
We call a 4-digit integer with three or more consecutive same digits, such as 1118, good. You are given a 4-digit integer N. Answer the question: Is N good? -----Constraints----- - 1000 ≀ N ≀ 9999 - N is an integer. -----Input----- Input is given from Standard Input in the following format: N -----Output----- If N is good, print Yes; otherwise, print No. -----Sample Input----- 1118 -----Sample Output----- Yes N is good, since it contains three consecutive 1.
["n = input()\nprint(\"Yes\" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else \"No\")", "N = list(input())\nif N[0] == N[1] and N[0] == N[2]:\n print('Yes')\nelif N[1] == N[2] and N[2] == N[3]:\n print('Yes')\nelse:\n print('No')\n", "# 079a\n\ndef atc_079a(input_value: str) -> str:\n n = 3\n for i in range(0, len(input_value) + 1 - n):\n for j in range(1, n):\n if input_value[i] != input_value[i + j]:\n break\n if j == n - 1:\n return \"Yes\"\n return \"No\"\n\ninput_value = input()\nprint((atc_079a(input_value)))\n", "s = input()\nif s[0] == s[1] == s[2] or s[1] == s[2] == s[3]:\n print(\"Yes\")\nelif s[0] == s[1] == s[2] == s[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\n\n\nprint((\"Yes\" if N[0] == N[1] == N[2] or N[1] == N[2] == N[3] else \"No\"))\n", "N = input()\n\ndata_list = str(N)\n\nif data_list[0] == data_list[1] == data_list[2]:\n print('Yes')\nelif data_list[1] == data_list[2] == data_list[3]:\n print('Yes')\nelif data_list[0] == data_list[1] == data_list[2] == data_list[3]:\n print('Yes')\nelse:\n print('No')\n\n", "N = input()\n\nif N[0] == N[1] and N[1] == N[2]:\n print(\"Yes\")\nelif N[1] == N[2] and N[2] == N[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = str(input())\n\nif N[0] == N[1] == N[2]:\n print('Yes')\nelif N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')", "x = input()\nif x[1] == x[2] and (x[0] == x[1] or x[2] == x[3] ):\n print('Yes')\nelse:\n print('No')", "n = input()\ncnt = 1\nfor i in range(len(n)-1):\n if n[i] == n[i+1]:\n cnt += 1\n else:\n cnt = 1\n if cnt >= 3:\n print(\"Yes\")\n return\n \nprint('No')", "# 079_a\nN=int(input())\n# if 1<=N and N<=9999:\n#\nn=str(N)\nif (n[0]==n[1] and n[1]==n[2]) or (n[1]==n[2] and n[2]==n[3]):\n print('Yes')\nelse:\n print('No')", "N = input()\ncheck = False\nfor i in range(2):\n if N[i:i+3] == N[i] * 3:\n check = True\n \nprint(\"Yes\" if check else \"No\")", "S=input()\nif S[0]==S[1]==S[2] or S[1]==S[2]==S[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "s = input()\nif s[0] == s[1] == s[2] or s[1] == s[2] == s[3]:\n print('Yes')\nelse:\n print('No')", "a,b,c,d = input()\nif (a==b==c) or (b==c==d):\n\tprint(\"Yes\")\nelse:\n\tprint(\"No\")", "N = str(input())\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n result = 'Yes'\nelse:\n result = 'No'\n\nprint(result)", "n = str(input())\nif n[0] == n[1] == n[2] or n[3] == n[1] == n[2]:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3] :\n print('Yes')\nelse:\n print('No')\n\n", "N = input()\nanswer = list(N)\n\nif answer[0] == answer[1] == answer[2]:\n print(\"Yes\")\nelif answer[1] == answer[2] == answer[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "X = input()\n\nif X[0] == X[1] == X[2] or X[1] == X[2] == X[3]:\n print('Yes')\nelse:\n print('No')\n", "N = str(input())\n\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n result = \"Yes\"\nelse:\n result = \"No\"\n\nprint(result)\n", "n = input()\n\nif n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:\n print('Yes')\nelse:\n print('No')", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = str(int(input()))\n\nflag = False\nif n[0] == n[1] and n[1] == n[2]:\n flag = True\nif n[1] == n[2] and n[3] == n[2]:\n flag = True\n\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "a=input()\nif a[0]==a[1]==a[2] or a[1]==a[2]==a[3]:print(\"Yes\")\nelse:print(\"No\")", "# A - Good Integer\n# https://atcoder.jp/contests/abc079/tasks/abc079_a\n\ns = input()\n\nif len(set(s[:3])) == 1 or len(set(s[1:])) == 1:\n print('Yes')\nelse:\n print('No')\n", "N=input()\n#N\u306ei\u6587\u5b57\u76ee\u3068i\uff0b1\u6587\u5b57\u76ee\u304c\u540c\u3058\u3067\u3042\u308c\u3070\u30ab\u30a6\u30f3\u30c8\u3092\u5897\u3084\u3059\u3002\nj_count=0\nfor i in range(0,3):\n if N[i]==N[i+1]:\n j_count+=1\nif j_count>=2 and N[1]==N[2]:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "N = input()\ns1 = N[1:len(N)]\ns2 = N[0:len(N) - 1]\nisOk = True\nfor i in range(1, len(N)-1):\n if s1[i] != s1[i - 1]:\n isOk = False\n break\n else:\n continue\n\nif isOk:\n print('Yes')\n return\n\nisOk = True\nfor i in range(1, len(N)-1):\n if s2[i] != s2[i - 1]:\n isOk = False\n break\n else:\n continue\n\nif isOk:\n print('Yes')\nelse:\n print('No')\n", "n = input()\nprint(('Yes' if n[0]==n[1]==n[2] or n[1]==n[2]==n[3] else 'No'))\n", "n = input()\nprint(\"Yes\" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else \"No\") ", "n = list(input())\nlist01 = list(set(n[0:3]))\nlist02 = list(set(n[1:4]))\nif len(list01) == 1 or len(list02) == 1:\n print('Yes')\nelse:\n print('No')", "N = input()\n\nif N[0] == N[1] ==N[2] or N[1] == N[2] == N[3] :\n print( \"Yes\" )\nelse:\n print( \"No\" )", "N = list(map(str, input()))\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3] :\n print('Yes')\nelse:\n print('No')", "s = input()\nprint((\"Yes\" if (s[1]==s[2] and (s[0]==s[1] or s[3]==s[1])) else \"No\"))\n", "def main():\n x = input()\n\n if len(set(x[:3])) == 1 or len(set(x[1:])) == 1:\n print(\"Yes\")\n else:\n print(\"No\")\n\nmain()", "numbers = input()\n\nif numbers[1] == numbers[2]:\n if numbers.count(numbers[1]) >= 3:\n print(\"Yes\")\n return\n\nprint(\"No\")\n", "N = input()\n\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')", "N = input()\nif N[1] == N[2]:\n if N[0] == N[1] or N[2] == N[3]:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "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\nA = S()\n\nif A[0] == A[1] == A[2] or A[1] == A[2] == A[3]:\n print(\"Yes\")\nelse:\n print(\"No\")\n\n\n", "N = input()\n\nif N[0] == N[1] == N[2] == N[3]:\n print('Yes')\nelif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')", "n = input('')\n# \u540c\u3058\u6570\u5b57\u304c3\u304b4\u500b\nif n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:\n print('Yes')\nelse:\n print('No')", "def atc_079a(input_value: str) -> str:\n n = 3\n for i in range(0, len(input_value) + 1 - n):\n for j in range(1, n):\n if input_value[i] != input_value[i + j]:\n break\n if j == n - 1:\n return \"Yes\"\n return \"No\"\n\n\ninput_value = input()\nprint(atc_079a(input_value))", "def iroha():\n num = list(input())\n count = 0\n head = num[0]\n\n for i, char in enumerate(num):\n if head == num[i]:\n count += 1\n if count >= 3:\n print('Yes')\n return\n else:\n count = 1\n head = num[i]\n \n print('No')\n \n\n\ndef __starting_point():\n iroha()\n\n__starting_point()", "N = input()\n\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "N=list(input())\n\nif N[0]==N[1]==N[2] or N[1]==N[2]==N[3]:\n print('Yes')\nelse:\n print('No')\n\n", "N = input('')\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3] or N[0] == N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')", "li = list(input())\n\nif li[0] == li[1] and li[1] == li[2]:\n print('Yes')\nelif li[1] == li[2] and li[2] == li[3]:\n print('Yes')\nelif li[0] == li[1] and li[0] == li[2] and li[0] == li[3]:\n print('Yes')\nelse:\n print('No')\n", "s = input()\nif len(set(s[:3])) == 1 or len(set(s[1:])) == 1:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "N = input()\nprint('Yes' if (N[0] == N[1] == N[2]) or (N[1] == N[2] == N[3]) else 'No')", "n=input()\nif n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:print('Yes')\nelse:print('No')", "S = input()\nif len(list(set(S[:-1]))) == 1 or len(list(set(S[1:]))) == 1:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\n\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')\n", "n=input()\nif len(set(n[:3]))==1 or len(set(n[1:4]))==1:\n print(\"Yes\")\nelse:\n print(\"No\")", "n=list(input())\nif len(set(n[:3]))==1 or len(set(n[1:]))==1:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c, d = input()\nprint('Yes' if a == b == c or b == c == d else 'No')", "n = str(input())\n\nif n[0] == n[1] == n[2] or n[1] == n[2] == n[3]:\n print('Yes')\n \nelse:\n print('No')", "n = input()\nif n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\nif (n[0] == n[1] == n[2]) or (n[1] == n[2] == n[3]):\n print('Yes')\nelse:\n print('No')\n", "import sys\nn = input()\ncand = [str(i) + str(i) + str(i) for i in range(10)]\nfor ci in cand:\n if n.count(ci) >= 1:\n print(\"Yes\")\n return\nprint(\"No\")", "n = input()\n\nif n[0] == n[1] and n[1] == n[2]:\n print('Yes')\nelif n[1] == n[2] and n[2] == n[3]:\n print('Yes')\nelse:\n print('No')", "a = input()\nif a[0] == a[1] == a[2] or a[1] == a[2] == a[3]:\n print('Yes')\nelse:\n print('No')", "\nN = str(input())\n\nif N[0] == N[1] and N[1] == N[2] :\n print('Yes')\n\nelif N[1] == N[2] and N[2] == N[3]:\n print('Yes')\n\nelse:\n print('No')\n", "#!/usr/bin/env python3\n\ndef main():\n a, b, c, d = input()\n print((\"Yes\" if a == b == c or b == c == d else \"No\"))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = input()\ngood_ints = (str(i) * 3 for i in range(9 + 1))\nanswer = ''\n\nfor good_int in good_ints:\n if good_int in N:\n answer = 'Yes'\n break\n \nprint(answer if answer else 'No')", "# 4\u6841\u306e\u6570\u5b57\u30673\u3064\u4ee5\u4e0a\u9023\u7d9a\u3059\u308b\u304b\u5224\u5b9a\n\nN = list(input())\n# print(N)\n\nif N[0] == N[1] and N[0] == N[2]:\n print('Yes')\nelif N[1] == N[2] and N[1] == N[3]:\n print('Yes')\nelse:\n print('No')\n", "#79\nn=list(input())\nif (n[0]==n[1]==n[2] or n[1]==n[2]==n[3]):\n print('Yes')\nelse:\n print('No')", "N=input()\nif (N[0]==N[1] and N[1]==N[2]) or (N[1]==N[2] and N[2]==N[3]):\n print(\"Yes\")\nelse:\n print(\"No\")\n", "# ABC079A\nn = input()\nprint(\"Yes\" if n[0]==n[1]==n[2] or n[3]==n[1]==n[2] else \"No\")", "n=input()\n\nif n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "s = input()\nif (s[0]==s[1] and s[1]==s[2]) :\n print(\"Yes\")\nelif (s[1]==s[2] and s[2]==s[3]) :\n print(\"Yes\")\nelse:\n print(\"No\")", "N=input()\nj_count=0\nfor i in range(0,3):\n if N[i]==N[i+1]:\n j_count+=1\nif j_count>=2 and N[1]==N[2]:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n=int(input())\n\nif (n//10)%111==0 or (n%1000)%111==0:\n ans=\"Yes\"\nelse:\n ans=\"No\"\n\nprint(ans)", "N = input()\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')\n", "integer = input()\nif integer[0] == integer[1] == integer[2] or integer[1] == integer[2] == integer[3]:\n print('Yes')\nelse:\n print('No')", "#\n# abc079 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 = \"\"\"1118\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"7777\"\"\"\n output = \"\"\"Yes\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"1234\"\"\"\n output = \"\"\"No\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = input()\n\n if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print(\"Yes\")\n else:\n print(\"No\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "N = input()\nfor i in range(10):\n if N.count(str(i)*3):\n print('Yes')\n return\nprint('No')\n", "a,b,c,d=input()\nprint((\"Yes\" if a==b==c or b==c==d else \"No\"))\n", "N = input()\n\no1 = set(N[0:3])\no2 = set(N[1:])\no3 = set(N)\n\n\nprint(\"Yes\" if len(o1) == 1 or len(o2) == 1 or len(o3) == 1 else \"No\")", "# \u6570\u5024\u306e\u53d6\u5f97\nN = str(input())\n\n# \u6570\u5024\u306e\u691c\u8a3c\nf_cnt = (N[:3]).count(N[:1])\nl_cnt = (N[1:]).count(N[3:])\nif f_cnt == 3\\\nor l_cnt == 3:\n print(\"Yes\")\nelse:\n print(\"No\")", "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=S()\n\nif A[0] == A[1] == A[2] or A[1] == A[2] == A[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "a, b, c, d = input()\nprint(\"Yes\" if a==b==c or b==c==d else \"No\")", "S = input()\nans = False\nfor i in range(len(S)):\n if S[1] == S[2] == S[3] or S[0] == S[1] == S[2]:\n ans = True\nif ans:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input().rstrip()\nprint(['No', 'Yes'][int(len(set(n[:3])) == 1 or len(set(n[1:])) == 1)])", "n = input()\nif n[1] == n[2]:\n if n[0]==n[1] or n[2]==n[3]:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "n=input()\na=[]\nfor i in range(len(n)):\n a.append(n[i])\n\nif (a[0]==a[1]) & (a[1]==a[2]) or (a[3]==a[2]) and (a[2]==a[1]) :\n print(\"Yes\")\nelse:\n print(\"No\")\n", "# A - Good Integer\n# \u6a19\u6e96\u5165\u529bN\n\nN = input()\nmy_list = []\nj = 0\n\nfor i in N:\n my_list.append(i)\n\nif my_list[0] == my_list[1] == my_list[2] or my_list[1] == my_list[2] == my_list[3]:\n print('Yes')\nelse:\n print('No')\n", "n = input()\narr = []\nfor i in range(10):\n s = \"\"\n for j in range(3):\n s += str(i)\n arr.append(s)\n\nif n[0:3] in arr or n[1:4] in arr:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = input()\n\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "'''\n\u554f\u984c\uff1a\n 1118 \u306e\u3088\u3046\u306a\u30013 \u3064\u4ee5\u4e0a\u306e\u540c\u3058\u6570\u5b57\u304c\u9023\u7d9a\u3057\u3066\u4e26\u3093\u3060\n 4 \u6841\u306e\u6574\u6570\u3092 \u826f\u3044\u6574\u6570 \u3068\u3057\u307e\u3059\u3002\n\n 4 \u6841\u306e\u6574\u6570N \u304c\u4e0e\u3048\u3089\u308c\u308b\u306e\u3067\u3001N \u304c \u826f\u3044\u6574\u6570 \u304b\u3069\u3046\u304b\u3092\u7b54\u3048\u3066\u304f\u3060\u3055\u3044\u3002\n'''\n\n'''\n\u5236\u7d04\uff1a\n 1000 \u2266 N \u2266 9999\n \u5165\u529b\u306f\u6574\u6570\u304b\u3089\u306a\u308b\n'''\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 N \u3092\u53d6\u5f97\u3059\u308b\nn = int(input())\nlist_n = list(str(n))\n\nresult = \"\"\n\nif (list_n[0] == list_n[1]) and (list_n[1] == list_n[2]):\n result = \"Yes\"\nelif (list_n[1] == list_n[2]) and (list_n[2] == list_n[3]):\n result = \"Yes\"\nelse:\n result = \"No\"\n\nprint(result)\n", "n=list(input())\nif n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\nn = str(n)\n# n\u306e\u4e8c\u6841\u76ee\u3068\u4e09\u6841\u76ee\u304c\u540c\u3058\u3067\u3001\u305d\u308c\u304c\u4e00\u6841\u76ee\u304b\u56db\u6841\u76ee\u304c\u3068\u540c\u3058\u306a\u3089Yes\nif n[1] == n[2]:\n if n[0] == n[1] or n[2] == n[3]:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "N = input()\ngood_ints = (str(i) * 3 for i in range(9 + 1))\n\nfor good_int in good_ints:\n if good_int in N:\n print('Yes')\n return\n\nprint('No')", "N = input()\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')", "N = input()\n\n# 3\u3064\u4ee5\u4e0a\u306e\u540c\u3058\u6570\u5b57\u304c\u9023\u7d9a\u3057\u3066\u4e26\u3093\u3060 4\u6841\u306e\u6574\u6570\u3092 \u826f\u3044\u6574\u6570 \u3068\u3057\u307e\u3059\u3002\n# N \u304c\u826f\u3044\u6574\u6570 \u306a\u3089\u3070 Yes \u3092\u3001\u305d\u3046\u3067\u306a\u3051\u308c\u3070 No \u3092\u51fa\u529b\u305b\u3088\u3002\n\nif N[1] == N[2]:\n if N[0] == N[1] or N[2] == N[3]:\n print(\"Yes\")\n else:\n print(\"No\")\nelse:\n print(\"No\")", "# coding = SJIS\n\nn = str(input())\n\nif n[0] == n[1] and n[1] == n[2]:\n print(\"Yes\")\nelif n[1] == n[2] and n[2] == n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = input()\n\nif n[0] == n[1] and n[1] == n[2] or n[1] == n[2] and n[2] == n[3]:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "N = input()\n\nfor i in range(2):\n if N[i:i+3] == 3 * N[i]:\n print('Yes')\n return\n\nprint('No')", "a=input()\nb=set(a[:-1]);c=set(a[1:])\n\nif len(b)==1 or len(c)==1:\n print('Yes')\nelse:\n print('No')\n", "S = input()\nprint('Yes' if S[0] == S[1] == S[2] or S[1] == S[2] == S[3] else 'No')", "N = input('')\nif N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:\n print('Yes')\nelse:\n print('No')", "n = list(input())\n\nif n[0] == n[1] and n[1] == n[2]:\n print('Yes')\nelif n[1] == n[2] and n[2] == n[3]:\n print('Yes')\nelif n[0] == n[1] == n[2] == n[3]:\n print('Yes')\nelse:\n print('No')"]
{"inputs": ["1118\n", "7777\n", "1234\n"], "outputs": ["Yes\n", "Yes\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,111
ea3a037da3c7eb16035d04e0b58cebb1
UNKNOWN
The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower. He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i. To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar. How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different. -----Constraints----- - 1 \leq N \leq 10^5 - 1 \leq A_i \leq 10^9(1\leq i\leq N) - 1 \leq B_i \leq 10^9(1\leq i\leq N) - 1 \leq C_i \leq 10^9(1\leq i\leq N) - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N A_1 ... A_N B_1 ... B_N C_1 ... C_N -----Output----- Print the number of different altars that Ringo can build. -----Sample Input----- 2 1 5 2 4 3 6 -----Sample Output----- 3 The following three altars can be built: - Upper: 1-st part, Middle: 1-st part, Lower: 1-st part - Upper: 1-st part, Middle: 1-st part, Lower: 2-nd part - Upper: 1-st part, Middle: 2-nd part, Lower: 2-nd part
["n = int(input())\na_list = sorted([int(x) for x in input().split()])\nb_list = sorted([int(x) for x in input().split()])\nc_list = sorted([int(x) for x in input().split()])\n\nimport bisect\nsum = 0\nfor b in b_list:\n b_num = bisect.bisect_left(a_list,b)\n c_num = bisect.bisect_right(c_list,b)\n sum += b_num*(len(c_list)-c_num)\nprint(sum)", "N = int(input())\nA = [int(a) for a in input().split(\" \")]\nB = [int(b) for b in input().split(\" \")]\nC = [int(c) for c in input().split(\" \")]\n\nA.sort()\nB.sort()\nC.sort()\n\ncombiBC = [0] * len(B)\n# combiBC[i] : number of combination of B, C when B[i] is selected\n\nic = 0\nlc = len(C)\nfor ib in range(len(B)):\n\tb = B[ib]\n\twhile ic < lc:\n\t\tc = C[ic]\n\t\tif b >= c:\n\t\t\tic += 1\n\t\telse:\n\t\t\tcombiBC[ib] = lc - ic\n\t\t\tbreak\n\nsumCombiBC = []\nfor i in range(len(combiBC)):\n\tif i == 0:\n\t\tsumCombiBC.append(combiBC[-1])\n\telse:\n\t\tsumCombiBC.insert(0, combiBC[-i-1] + sumCombiBC[0])\n\ncnt = 0\nib = 0\nfor ia in range(len(A)):\n\ta = A[ia]\n\twhile ib < len(B):\n\t\tb = B[ib]\n\t\tif a >= b:\n\t\t\tib += 1\n\t\telse:\n\t\t\tcnt += sumCombiBC[ib]\n\t\t\tbreak\n\nprint(cnt)", "N = int(input())\nA = [int(x) for x in input().split()]\nB = [int(x) for x in input().split()]\nC = [int(x) for x in input().split()]\n\nimport bisect as bs\nimport numpy as np\nA.sort()\nC.sort()\n#B_a:b\u672a\u6e80\u306eA\u306e\u30d1\u30fc\u30c4\u6570\u3001B_c:b\u8d85\u306eC\u306e\u30d1\u30fc\u30c4\u6570\nB_a = np.array([bs.bisect_left(A,b) for b in B]) \nB_c = np.array([N-bs.bisect_right(C,b) for b in B])\nans = np.dot(B_a, B_c)\nprint(ans)", "from bisect import bisect_left, bisect_right\nN = int(input())\nA, B, C = [sorted(map(int, input().split())) for _ in range(3)]\nprint(sum(bisect_left(A,b)*(N-bisect_right(C,b)) for b in B))", "import bisect\n\nn = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\nans = 0\n\nfor b in B:\n a = bisect.bisect_left(A, b)\n c = bisect.bisect_right(C, b)\n ans += a*(n-c)\n\nprint(ans)", "import bisect\nN=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\na=sorted(A)\nb=sorted(B)\nc=sorted(C)\nans=0\nfor i in range(len(b)):\n index_a=bisect.bisect_left(a,b[i])\n index_c=bisect.bisect_right(c,b[i])\n ans+=(index_a*(len(c)-index_c))\nprint(ans)", "N = int(input())\n\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\nans = i = j = 0\n\nimport bisect\n\nfor b in B:\n i = bisect.bisect_left(A,b)\n j = N - bisect.bisect_right(C,b)\n ans += i * j\nprint(ans)", "import sys\nimport math\nimport itertools\nimport collections\nfrom collections import deque\nfrom collections import defaultdict\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\nMOD2 = 998244353\nINF = float('inf')\ninput = lambda: sys.stdin.readline().strip()\n\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\ndef main():\n N = NI()\n A = NLI()\n B = NLI()\n C = NLI()\n \n A = sorted(A)\n C = sorted(C)\n \n ans = 0\n \n for b in B:\n \n\n A_ng = -1 #ng:\u3068\u308a\u5f97\u308b\u6700\u5c0f\u306e\u5024-1\n A_ok = len(A) #ok:\u3068\u308a\u5f97\u308b\u6700\u5927\u306e\u5024+1\n\n while (abs(A_ok - A_ng) > 1):\n A_mid = (A_ok + A_ng) // 2\n\n if A[A_mid] >= b:#\u8a08\u7b97\u306e\u7d50\u679c\u3001mid\u304c\u6761\u4ef6\u3092\u6e80\u305f\u3059\u306a\u3089ok\u306bmid\u3092\u4ee3\u5165\u3002\u305d\u3046\u3067\u306a\u3051\u308c\u3070ng\u306bmid\u3092\u4ee3\u5165\u3002\n A_ok = A_mid\n else:\n A_ng = A_mid\n \n C_ng = -1 #ng:\u3068\u308a\u5f97\u308b\u6700\u5c0f\u306e\u5024-1\n C_ok = len(C) #ok:\u3068\u308a\u5f97\u308b\u6700\u5927\u306e\u5024+1\n\n while (abs(C_ok - C_ng) > 1):\n C_mid = (C_ok + C_ng) // 2\n\n if C[C_mid] > b:#\u8a08\u7b97\u306e\u7d50\u679c\u3001mid\u304c\u6761\u4ef6\u3092\u6e80\u305f\u3059\u306a\u3089ok\u306bmid\u3092\u4ee3\u5165\u3002\u305d\u3046\u3067\u306a\u3051\u308c\u3070ng\u306bmid\u3092\u4ee3\u5165\u3002\n C_ok = C_mid\n else:\n C_ng = C_mid\n \n \n len_C = len(C)\n \n ans += A_ok * (len_C-C_ok)\n \n print(ans)\ndef __starting_point():\n main()\n__starting_point()", "import bisect\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\n\nA.sort()\nC.sort()\n\nans = 0\nfor b in B:\n l = bisect.bisect_left(A, b)\n r = bisect.bisect_right(C, b)\n ans += l * (len(C) - r)\n\nprint(ans)", "import bisect\nn = int(input())\n\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\n\n\nans = 0\nfor i in range(n):\n B = b[i]\n b_in = bisect.bisect_left(a,B)\n if b_in == 0:\n continue\n c_in = bisect.bisect_right(c,B)\n c_cnt = n - c_in\n ans += b_in*c_cnt\n\nprint(ans)", "# \u4e8c\u5206\u63a2\u7d22\nimport bisect\n\n#################\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\n\n#\u30ea\u30b9\u30c8\u3092\u30bd\u30fc\u30c8\na=sorted(a)\nb=sorted(b)\nc=sorted(c)\n\ncount=0\n#a[i]\u306e\u500b\u6570\nfor i in range(n):\n a_count = bisect.bisect_left(a, b[i])\n c_count = bisect.bisect_right(c, b[i])\n count+=a_count*(len(c)-c_count)\n\nprint(count)\n", "import bisect\nN = int(input())\nlsA = list(map(int,input().split()))\nlsB = list(map(int,input().split()))\nlsC = list(map(int,input().split()))\nlsA.sort()\nlsB.sort()\nlsC.sort()\nans = 0\nfor i in range(N):\n B = lsB[i]\n indexA = bisect.bisect(lsA,B-1)\n indexC = N - bisect.bisect(lsC,B)\n ans += indexA*indexC\nprint(ans)", "from bisect import bisect,bisect_left\nN=int(input())\nA=sorted(list(map(int,input().split())))\nB=sorted(list(map(int,input().split())))\nC=sorted(list(map(int,input().split())))\nans=0\nfor b in B:\n i=bisect_left(A,b)\n j=bisect(C,b)\n ans+=i*(N-j)\nprint(ans)", "import bisect\n\nn = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort()\nB.sort()\nC.sort()\n\ncnt = 0\nfor b in B:\n i = bisect.bisect_left(A, b)\n j = bisect.bisect_right(C, b)\n cnt += i * (n-j)\n\nprint(cnt)", "def binary_search(lst, t, i):\n left = -1\n right = len(lst)\n\n while abs(right - left) > 1:\n mid = (left + right) // 2\n if i == 0:\n if lst[mid] < t:\n left = mid\n else:\n right = mid\n elif i == 1:\n if lst[mid] > t:\n right = mid\n else:\n left = mid\n\n return left\n\n\ndef main():\n n = int(input())\n A = sorted(list(map(int, input().split())))\n B = sorted(list(map(int, input().split())))\n C = sorted(list(map(int, input().split())))\n ans = 0\n\n for b in B:\n a = binary_search(A, b, 0)\n c = binary_search(C, b, 1)\n ans += (a + 1) * (n - c - 1)\n\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "from bisect import *\nn=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\nans=0\nfor b in B:\n ans+=(n-bisect(C,b))*bisect_left(A,b)\nprint(ans)", "import bisect as bs\n\ndef main():\n with open(0) as f:\n N = int(f.readline())\n A = sorted(list(map(int, f.readline().split())))\n B = list(map(int, f.readline().split()))\n C = sorted(list(map(int, f.readline().split())))\n\n ans = 0\n for b in B:\n ans += bs.bisect_left(A, b) * (N-bs.bisect_right(C, b))\n print(ans)\n\nmain()", "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\n\nb=sorted(b)\nc=sorted(c)\n\nfrom bisect import bisect_right\n\nd=[]\nfor i in range(n):\n index = bisect_right(c,b[i]) \n\n d.append(n-index)\n\nimport numpy as np\ns=sum(d)\ncum=np.cumsum(d)\n\nans=0\nfor j in range(n):\n dex = bisect_right(b,a[j])\n if dex==0:\n ans+=s\n elif dex==n:\n continue\n else:\n ans+=s-cum[dex-1]\n\nprint(ans)\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\ndef main():\n n = i_input()\n a = i_list()\n b = i_list()\n c = i_list()\n a.sort()\n b.sort()\n c.sort()\n\n al = []\n bl = [0]\n import bisect\n\n for k,i in enumerate(b):\n x = bisect.bisect(c, i)\n bl.append(bl[k]+(n-x))\n\n ans = 0\n\n for i in a:\n x = bisect.bisect(b,i)\n ans += bl[-1] - bl[x]\n print(ans)\n\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import bisect\n\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nans = 0\nfor b in B:\n a = bisect.bisect_left(A,b)\n c = bisect.bisect_right(C,b)\n ans += a*(N-c)\n\nprint(ans)", "def bs_left(list, target):\n low = 0\n high = len(list)\n\n while low < high:\n mid = (low + high) // 2\n if target > list[mid]:\n low = mid + 1\n else:\n high = mid\n return low\n\ndef bs_right(list, target):\n low = 0\n high = len(list)\n while low < high:\n mid = (low + high) // 2\n if target < list[mid]:\n high = mid\n else:\n low = mid + 1\n return low\n\nn = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nC.sort()\n\nans = 0\nfor b in B:\n ans += (bs_left(A, b) * (n - bs_right(C, b)))\nprint(ans)\n\n", "from bisect import bisect_left\nfrom numpy import cumsum\n\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\nB_ = [0]*N\nans = 0\nstart = 0\nfor i, b in enumerate(B):\n j = bisect_left(A, b, start)\n B_[i] = j\n start = j\nB_ = cumsum(B_)\nstart = 0\nfor c in C:\n i = bisect_left(B, c, start)\n start = i\n if i != 0:\n ans += B_[i-1]\nprint(ans)\n", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\n\na_index = 0\nb_index = 0\nc_index = 0\n\nbc = []\nwhile(b_index < len(b) and c_index < len(c)):\n if b[b_index] < c[c_index]:\n bc.append(len(c)-c_index)\n b_index += 1\n else:\n c_index += 1\n # print(b_index, c_index)\n\nif len(bc) == 0:\n print((0))\n return\n\nbc_sum = [bc[-1]]\nfor i in reversed(bc[:-1]):\n bc_sum.append(i+bc_sum[-1])\nbc_sum = list(reversed(bc_sum))\n\n# print(bc)\n# print(bc_sum)\na_index = 0\nb_index = 0\nc_index = 0\nans = []\nwhile(a_index < len(a) and b_index < len(b) and b_index < len(bc_sum)):\n if a[a_index] < b[b_index]:\n # ans.append(sum(bc[b_index:]))\n ans.append(bc_sum[b_index])\n a_index += 1\n else:\n b_index += 1\n # print(a_index, b_index)\n\n# print(bc)\nprint((sum(ans)))\n", "n=int(input())\nalist=list(map(int, input().split()))\nblist=list(map(int, input().split()))\nclist=list(map(int, input().split()))\nalist.sort()\nblist.sort()\nclist.sort()\nimport bisect\nans=0\nfor b in blist:\n num1=n-bisect.bisect(clist,b)\n num2=bisect.bisect_left(alist,b)\n ans+=num1*num2\nprint(ans)", "import bisect\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort()\nB.sort()\nC.sort()\n\nans = 0\n\nfor b in B:\n a_count = bisect.bisect_left(A, b)\n c_count = N - bisect.bisect_right(C, b)\n ans += a_count * c_count\nprint(ans)\n", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\n\na_index = 0\nb_index = 0\nc_index = 0\n\nbc = []\nwhile(b_index < len(b) and c_index < len(c)):\n if b[b_index] < c[c_index]:\n bc.append(len(c)-c_index)\n b_index += 1\n else:\n c_index += 1\n # print(b_index, c_index)\n\nif len(bc) == 0:\n print((0))\n return\n\nbc_sum = [bc[-1]]\nfor i in reversed(bc[:-1]):\n bc_sum.append(i+bc_sum[-1])\nbc_sum = list(reversed(bc_sum))\n\nif len(bc_sum) != len(bc):\n print(bc)\n print(bc_sum)\n return\n# print(bc)\n# print(bc_sum)\na_index = 0\nb_index = 0\nc_index = 0\nans = []\nwhile(a_index < len(a) and b_index < len(b) and b_index < len(bc_sum)):\n if a[a_index] < b[b_index]:\n # ans.append(sum(bc[b_index:]))\n ans.append(bc_sum[b_index])\n a_index += 1\n else:\n b_index += 1\n # print(a_index, b_index)\n\n# print(bc)\nprint((sum(ans)))\n", "#!/usr/bin/env python3\ndef main():\n from bisect import bisect, bisect_left\n\n N = int(input())\n A = sorted([int(x) for x in input().split()])\n B = [int(x) for x in input().split()]\n C = sorted([int(x) for x in input().split()])\n\n print((sum([bisect_left(A, b) * (N - bisect(C, b)) for b in B])))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "from bisect import bisect_left, bisect_right\n\nn = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nans = 0\n# print(A)\n# print(B)\n# print(C)\nfor i in range(n):\n b = B[i]\n pos_a = bisect_left(A, b)\n pos_c = bisect_right(C, b)\n ans += pos_a * (n - pos_c)\n # print(b, pos_a, pos_c)\nprint(ans)\n", "from bisect import bisect, bisect_left\n\n\ndef bin_search(n):\n\n a = list(map(int, input().split()))\n b = list(map(int, input().split()))\n c = list(map(int, input().split()))\n\n a.sort()\n c.sort()\n\n ans = 0\n\n for i in range(n):\n upper_b = bisect_left(a, b[i])\n under_b = n - bisect(c, b[i])\n ans += upper_b * under_b\n return ans\n\n\ndef __starting_point():\n n = int(input())\n print((bin_search(n)))\n\n__starting_point()", "#\n# abc077 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\nimport bisect\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 = \"\"\"2\n1 5\n2 4\n3 6\"\"\"\n output = \"\"\"3\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"3\n1 1 1\n2 2 2\n3 3 3\"\"\"\n output = \"\"\"27\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\"\"\"\n output = \"\"\"87\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n C = list(map(int, input().split()))\n\n A.sort()\n B.sort()\n C.sort()\n\n ans = 0\n for b in B:\n an = bisect.bisect_left(A, b)\n cn = N - bisect.bisect_right(C, b)\n ans += an*cn\n\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "from bisect import bisect\nimport random\n\n\ndef binary_search(L, n, i, j):\n # print(L, n, i, j)\n low = i\n high = j\n\n while low <= high:\n mid = (low + high) //2\n guess = L[mid]\n # if guess == n:\n # return mid\n if guess > n:\n high = mid -1\n else:\n low = mid + 1\n # print(low)\n return low\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n# N = 10 ** 5\n# A = [random.randint(1, 10**9) for _ in range(N)]\n# B = [random.randint(1, 10**9) for _ in range(N)]\n# C = [random.randint(1, 10**9) for _ in range(N)]\n\nA.sort()\nB.sort()\nC.sort()\n\nans = 0\ni, j = 0, 0\n\nA_ind = []\nB_cum = [0]\n\nfor a in A:\n # i = binary_search(B, a, i, N-1)\n i = bisect(B, a)\n A_ind.append(i)\n\ns = 0\nfor b in B:\n # j = binary_search(C, b, j, N-1)\n j = i = bisect(C, b)\n s += N-j\n B_cum.append(s)\n\nfor a in A_ind:\n ans += B_cum[-1] - B_cum[a]\nprint(ans)\n\n", "# -*- coding: utf-8 -*-\n\ndef get_input() -> tuple:\n \"\"\"\n \u6a19\u6e96\u5165\u529b\u3092\u53d6\u5f97\u3059\u308b.\n\n Returns:\\n\n tuple: \u6a19\u6e96\u5165\u529b\n \"\"\"\n N = int(input())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n C = list(map(int, input().split()))\n\n return N, A, B, C\n\n\ndef get_lb(l: list, key: int) -> int:\n \"\"\"\n l[index] > key\u3068\u306a\u308b\u6700\u5c0f\u306eindex\u3092\u6c42\u3081\u308b.\n\n Args:\\n\n l (list): \u30ea\u30b9\u30c8\n key (int): \u6574\u6570\n\n Returns:\\n\n int: l[index] > key\u3068\u306a\u308b\u6700\u5c0f\u306eindex\n \"\"\"\n low = -1\n high = len(l)\n while 1 < high - low:\n mid = (low + high) // 2\n guess = l[mid]\n if guess > key:\n high = mid\n else:\n low = mid\n return high\n\n\ndef get_ub(l: list, key: int) -> int:\n \"\"\"\n l[index] < key\u3068\u306a\u308b\u6700\u5927\u306eindex\u3092\u6c42\u3081\u308b.\n\n Args:\\n\n l (list): \u30ea\u30b9\u30c8\n key (int): \u6574\u6570\n\n Returns:\\n\n int: l[index] < key\u3068\u306a\u308b\u6700\u5927\u306eindex\n \"\"\"\n low = -1\n high = len(l)\n while 1 < high - low:\n mid = (low + high) // 2\n guess = l[mid]\n if guess < key:\n low = mid\n else:\n high = mid\n return low\n\n\ndef main(N: int, A: list, B: list, C: list) -> None:\n \"\"\"\n \u30e1\u30a4\u30f3\u51e6\u7406.\n\n Args:\\n\n N (int): \u30d1\u30fc\u30c4\u306e\u6570(1 <= N <= 10**5)\n A (list): \u4e0a\u90e8\u306e\u30d1\u30fc\u30c4\u306e\u30b5\u30a4\u30ba(1 <= A_i <= 10**9)\n B (list): \u4e2d\u90e8\u306e\u30d1\u30fc\u30c4\u306e\u30b5\u30a4\u30ba(1 <= B_i <= 10**9)\n C (list): \u4e0b\u90e8\u306e\u30d1\u30fc\u30c4\u306e\u30b5\u30a4\u30ba(1 <= C_i <= 10**9)\n \"\"\"\n # \u4e8b\u524d\u306b\u30ea\u30b9\u30c8\u3092\u30bd\u30fc\u30c8\u3057\u3066\u304a\u304f\n A = sorted(A)\n B = sorted(B)\n C = sorted(C)\n\n # \u6c42\u89e3\u51e6\u7406\n ans = 0\n for i in range(N):\n B_i = B[i]\n ans += (get_ub(A, B_i) + 1) * (N - get_lb(C, B_i))\n\n # \u7d50\u679c\u51fa\u529b\n print(ans)\n\n\ndef __starting_point():\n # \u6a19\u6e96\u5165\u529b\u3092\u53d6\u5f97\n N, A, B, C = get_input()\n\n # \u30e1\u30a4\u30f3\u51e6\u7406\n main(N, A, B, C)\n\n__starting_point()", "def solve():\n def bin_l(arr, key):\n l = 0\n r = len(arr) - 1\n while l <= r:\n mid = (l + r)//2\n if arr[mid] > key:\n r = mid - 1\n else:\n l = mid + 1\n \n if l < len(arr):\n return l\n else:\n return None\n \n def bin_s(arr, key):\n l = 0\n r = len(arr) - 1\n while l <= r:\n mid = (l + r) // 2\n if arr[mid] >= key:\n r = mid - 1\n else:\n l = mid + 1\n \n if r >= 0 :\n return r\n else:\n return None\n \n n = int(input())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n C = list(map(int,input().split()))\n A = sorted(A)\n C = sorted(C)\n \n sum = 0\n for b in B:\n a = bin_s(A, b)\n c = bin_l(C, b)\n a = a + 1 if a is not None else None\n c = n - c if c is not None else None\n if a is not None and c is not None:\n sum += a*c\n \n print(sum)\n\ndef __starting_point():\n solve()\n\n__starting_point()", "import bisect\n\nN=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\nans=0\nfor i in range(N):\n x=bisect.bisect_left(A,B[i])\n y=N-bisect.bisect_right(C,B[i])\n ans+=x*y\nprint(ans)\n", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\n\na_index = 0\nb_index = 0\nc_index = 0\n\nbc = [0]*n\n# bc = []\nwhile(b_index < len(b) and c_index < len(c)):\n if b[b_index] < c[c_index]:\n # bc.append(len(c)-c_index)\n bc[b_index] = len(c)-c_index\n b_index += 1\n else:\n c_index += 1\n # print(b_index, c_index)\n\nif len(bc) != len(b):\n return\n\n\nif len(bc) == 0:\n print((0))\n return\n\nbc_sum = [bc[-1]]\nfor i in reversed(bc[:-1]):\n bc_sum.append(i+bc_sum[-1])\nbc_sum = list(reversed(bc_sum))\n\n# print(bc)\n# print(bc_sum)\na_index = 0\nb_index = 0\nc_index = 0\nans = []\nwhile(a_index < len(a) and b_index < len(b) and b_index < len(bc_sum)):\n if a[a_index] < b[b_index]:\n # ans.append(sum(bc[b_index:]))\n ans.append(bc_sum[b_index])\n a_index += 1\n else:\n b_index += 1\n # print(a_index, b_index)\n\n# print(bc)\nprint((sum(ans)))\n", "from bisect import bisect_left\nfrom itertools import accumulate\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA.sort()\nB.sort()\nbs = [0]*N\nfor i in range(N):\n b = B[i]\n ai = bisect_left(A, b)\n bs[i] = ai\nbs = [0]+list(accumulate(bs, lambda x,y:x+y))\nans = 0\nfor i in range(N):\n c = C[i]\n bi = bisect_left(B, c)\n ans += bs[bi]\nprint(ans)", "from bisect import*\n(n,), a, b, c = [sorted(map(int, o.split())) for o in open(0)]\nprint(sum(bisect_left(a, i) * (n - bisect(c, i)) for i in b))", "from bisect import *\nN = int(input())\nA = sorted(map(int, input().split()))\nB = sorted(map(int, input().split()))\nC = sorted(map(int, input().split()))\n\ncnt = []\n\nfor b in B:\n cnt.append(bisect_left(A, b) * (N - bisect_right(C, b)))\nprint((sum(cnt)))\n", "from bisect import bisect, bisect_left\n\nN = int(input())\nA, B, C = (sorted(map(int, input().split())) for _ in range(3))\n\nans = 0\nfor b in B:\n ans += bisect_left(A, b) * (N - bisect(C, b))\n\nprint(ans)", "n=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nimport bisect as bi\nans=0\nfor i in range(n):\n q=B[i]\n oka= bi.bisect_left(A,q)\n okb= n- bi.bisect_right(C,q)\n ans+=oka*okb\nprint(ans)", "n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\n\n#\u30ea\u30b9\u30c8\u3092\u30bd\u30fc\u30c8\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\n\n# x\u4ee5\u4e0a\u306e\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\ndef lower_bound(arr , x):\n l = 0\n r = len(c)\n for j in range(30):\n mid = (l + r) // 2\n # print(l , r , mid)\n if x <= arr[mid]:\n r = mid\n else:\n l = mid\n return r\n\n\ncount = 0\nfor i in range(n):\n a_count = lower_bound(a , b[i])\n c_count = len(c) - lower_bound(c , b[i] + 1)\n count += a_count * c_count\n\nprint(count)\n", "N = int(input())\nA = sorted(list(map(int,input().split())))\nB = sorted(list(map(int,input().split())))\nC = sorted(list(map(int,input().split())))\nans = 0\nimport bisect\nb = []\nfor i in B:\n x = bisect.bisect_right(C,i)\n b.append(N-x)\ny = sum(b)\nc = [y]\nfor i in range(1,N):\n y -= b[i-1]\n c.append(y)\nc.append(0)\nfor i in A:\n a = bisect.bisect_right(B,i)\n ans += c[a]\nprint(ans)", "def lb(k, a):\n n = len(a)\n l, u = 0, n\n while l < u:\n m = (l + u) // 2\n if k < a[m]:\n u = m\n else:\n l = m + 1\n return l\n\ndef ub(k, a):\n n = len(a)\n l, u = -1, n - 1\n while l < u:\n m = (l + u + 1) // 2\n if a[m] < k:\n l = m\n else:\n u = m - 1\n return l\n\nN = int(input())\nA = sorted([int(x) for x in input().split()])\nB = sorted([int(x) for x in input().split()])\nC = sorted([int(x) for x in input().split()])\n\nres = 0\nfor i in range(N):\n j = ub(B[i], A)\n k = lb(B[i], C)\n res += (j + 1)*(N - k)\n\nprint(res)", "import copy\nimport math\nimport time\nimport statistics\nimport math\nimport itertools\nimport bisect\n\n# a = get_int()\ndef get_int():\n return int(input())\n# a = get_string()\ndef get_string():\n return input()\n# a_list = get_int_list()\ndef get_int_list():\n return [int(x) for x in input().split()]\n# a_list = get_string_list():\ndef get_string_list():\n return input().split()\n# a, b = get_int_multi()\ndef get_int_multi():\n return list(map(int, input().split()))\n# a_list = get_string_char_list()\ndef get_string_char_list():\n return list(str(input()))\n# print(\"{} {}\".format(a, b))\n# for num in range(0, a):\n# a_list[idx]\n# a_list = [0] * a\n'''\nwhile (idx < n) and ():\n\n idx += 1\n'''\n\ndef main():\n start = time.time()\n n = get_int()\n\n a_list = get_int_list()\n b_list = get_int_list()\n c_list = get_int_list()\n\n a_list.sort()\n b_list.sort()\n c_list.sort()\n\n a_count = []\n b_count = []\n b_count2 = []\n\n idx = 0\n for a in a_list:\n idx = bisect.bisect_right(b_list, a, idx)\n a_count.append(idx)\n\n idx = 0\n for b in b_list:\n idx = bisect.bisect_right(c_list, b, idx)\n b_count.append(idx)\n\n ruikei = 0\n for i in range(n-1, -1, -1):\n ruikei += n - b_count[i]\n b_count2.append(ruikei)\n\n b_count2.sort(reverse=True)\n\n ans = 0\n for a in a_count:\n if a == n:\n continue\n ans += b_count2[a]\n\n print(ans)\n #print(time.time() - start)\n\ndef __starting_point():\n main()\n\n\n\n__starting_point()", "from bisect import bisect,bisect_left\nN=int(input())\nA=sorted(list(map(int,input().split())))\nB=sorted(list(map(int,input().split())))\nC=sorted(list(map(int,input().split())))\nans=0\nfor b in B:\n i=bisect_left(A,b)\n j=bisect(C,b)\n ans+=i*(N-j)\nprint(ans)", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\n\na_index = 0\nb_index = 0\nc_index = 0\n\nbc = [0]*n\n# bc = []\nwhile(b_index < len(b) and c_index < len(c)):\n if b[b_index] < c[c_index]:\n # bc.append(len(c)-c_index)\n bc[b_index] = len(c)-c_index\n b_index += 1\n else:\n c_index += 1\n # print(b_index, c_index)\n\nif len(bc) != len(b):\n return\n\n\nif len(bc) == 0:\n print((0))\n return\n\nbc_sum = [bc[-1]]\nfor i in reversed(bc[:-1]):\n bc_sum.append(i+bc_sum[-1])\nbc_sum = list(reversed(bc_sum))\n\n# print(bc)\n# print(bc_sum)\na_index = 0\nb_index = 0\nc_index = 0\nans = []\nwhile(a_index < len(a) and b_index < len(b)):\n if a[a_index] < b[b_index]:\n # ans.append(sum(bc[b_index:]))\n ans.append(bc_sum[b_index])\n a_index += 1\n else:\n b_index += 1\n # print(a_index, b_index)\n\n# print(bc)\nprint((sum(ans)))\n", "import bisect\n \nn = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\nans = 0\n \nfor b in B:\n a = bisect.bisect_left(A, b)\n c = bisect.bisect_right(C, b)\n ans += a*(n-c)\n \nprint(ans)", "import bisect\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\n\nA.sort()\nB.sort()\nC.sort()\n\npat = 0\n\nfor i in B:\n numA = bisect.bisect_left(A,i)\n numC = bisect.bisect(C,i)\n pat += numA * (len(C)-numC)\n\nprint(pat)", "def II(): return int(input())\ndef LII(): return list(map(int, input().split()))\n\nn=II()\nalist=LII()\nblist=LII()\nclist=LII()\n\nalist.sort()\nblist.sort()\nclist.sort()\n\n#\u3042\u308bb\u3088\u308a\u5c0f\u3055\u3044a\u306e\u6570\ndef count_a(b):\n ok,ng = -1,n\n def is_ok(i):\n return alist[i]<b\n while abs(ok-ng)>1:\n mid = (ok+ng)//2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n return ok+1\n\ndef count_c(b):\n ok,ng = n,-1\n def is_ok(i):\n return clist[i]>b\n while abs(ok-ng)>1:\n mid = (ok+ng)//2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n return n-ok\n\nresult=0\nfor b in blist:\n result += count_a(b) * count_c(b)\n\nprint(result)", "import bisect\n\n_ = input()\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\nC = [int(i) for i in input().split()]\n\nA.sort()\nC.sort()\n\nans = 0\nfor b in B:\n a = bisect.bisect_left(A, b)\n c = len(C) - bisect.bisect_right(C, b)\n ans += a * c\nelse:\n print(ans)", "n = int(input())\na = sorted(list(map(int,input().split())))\nb = sorted(list(map(int,input().split())))\nc = sorted(list(map(int,input().split())))\nbl = [0]*n\nblli = [0]*n\nal = [0]*n\nalli = [0]*n\nimport bisect\n\nfor i in range(n):\n bl[i]=n-bisect.bisect(c,b[i])\n\nblli[0] = sum(bl)\nfor i in range(n-1):\n blli[i+1] = blli[i]-bl[i]\n \nfor i in range(n):\n al[i]=n-bisect.bisect(b,a[i])\n\nfor i in range(n):\n if al[i]!=0:\n alli[i] = blli[-al[i]]\n\nprint(sum(alli))", "import bisect\nn = int(input())\na, b, c = map(list, [sorted(list(map(int, input().split()))) for i in range(3)])\nans = 0\nfor i in range(n):\n ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))\nprint(ans)", "# coding:UTF-8\nimport sys\nfrom math import factorial\n\nMOD = 10 ** 9 + 7\nINF = 10000000000\n\ndef binary_search_section(list, min, max):\n low = 0\n high = len(list) - 1\n upper = len(list)\n lower = -1\n while low <= high:\n mid = (low + high) // 2\n guess = list[mid]\n if guess >= min:\n high = mid - 1\n else:\n low = mid + 1\n lower = mid\n low = 0\n high = len(list) - 1\n while low <= high:\n mid = (low + high) // 2\n guess = list[mid]\n if guess > max:\n high = mid - 1\n upper = mid\n else:\n low = mid + 1\n\n return [lower, upper]\n\ndef main():\n # ------ \u5165\u529b ------#\n # 1\u884c\u5165\u529b\n n = int(input()) # \u6570\u5b57\n aList = list(map(int, input().split())) # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n bList = list(map(int, input().split())) # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n cList = list(map(int, input().split())) # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n\n # ------ \u51e6\u7406 ------#\n aListSorted = sorted(aList)\n bListSorted = sorted(bList)\n cListSorted = sorted(cList)\n\n result = 0\n # for a in aListSorted:\n # sec = binary_search_section(bListSorted, a+1, bListSorted[-1])\n # for j in range(sec[0]+1, len(bListSorted)):\n # b = bListSorted[j]\n # sec2 = binary_search_section(cListSorted, b+1, cListSorted[-1])\n # result += len(cListSorted) - (sec2[0] + 1)\n for b in bListSorted:\n sec = binary_search_section(aListSorted, aListSorted[0], b-1)\n sec2 = binary_search_section(cListSorted, b+1, cListSorted[-1])\n result += (sec[1] - sec[0] - 1)*(sec2[1] - sec2[0] - 1)\n\n # ------ \u51fa\u529b ------#\n print((\"{}\".format(result)))\n # if flg == 0:\n # print(\"YES\")\n # else:\n # print(\"NO\")\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n=int(input())\na=list(map(int, input().split()))\nb=list(map(int, input().split()))\nc=list(map(int, input().split()))\na=sorted(a)\nc=sorted(c)\nans=0\nimport bisect\nfor i in b:\n t=bisect.bisect_left(a, i)\n q=bisect.bisect_right(c, i)\n ans+=t*(n-q)\nprint(ans)\n", "import bisect\nn=int(input())\na=sorted(list(map(int,input().split())))\nb=sorted(list(map(int,input().split())))\nc=sorted(list(map(int,input().split())))\nans=0\nfor i in b:\n A=bisect.bisect_left(a,i)\n B=len(b)-bisect.bisect_right(c,i)\n ans+=A*B\nprint(ans)", "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort()\nB.sort()\nC.sort()\n\ndef bin_serch(array,num):\n head = 0\n tail = len(array)\n while head < tail:\n center = (head + tail) // 2\n if num < array[center]:\n tail = center\n else:\n head = center + 1\n return head\n\nBC = [0 for _ in range(len(B))]\nfor i in range(len(B)):\n BC[i] = len(C) - bin_serch(C,B[i])\n \ns = 0\nfor i in range(len(BC)-1, -1, -1):\n s += BC[i]\n BC[i] = s\n\nans = 0\nfor a in A:\n b = bin_serch(B,a)\n if b < len(B):\n ans += BC[b]\n \nprint(ans)", "import bisect\n\nn = int(input())\nal = sorted(list(map(int, input().split())))\nbl = sorted(list(map(int, input().split())))\ncl = sorted(list(map(int, input().split())))\nans = 0\n\nfor b in bl:\n i = bisect.bisect_left(al, b)\n j = bisect.bisect_right(cl, b)\n ans += i*(n-j)\n\nprint(ans)", "import bisect\n\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\ncnt = 0\n\nfor b in B:\n a = bisect.bisect_left(A,b)\n c = bisect.bisect_right(C,b)\n cnt += a * (len(C)-c)\n\nprint(cnt)", "import bisect\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\na.sort()\nb.sort()\nc.sort()\nans = 0\nfor i in b:\n p = bisect.bisect_left(a, i)\n q = bisect.bisect_right(c, i)\n ans += (p*(n-q))\n \nprint(ans)", "from bisect import bisect, bisect_left\n\nN = int(input())\nA = sorted(map(int, input().split()))\nB = sorted(map(int, input().split()))\nC = sorted(map(int, input().split()))\n\nC_accum = [0]\nfor b in B:\n C_accum.append(C_accum[-1] + N - bisect(C, b))\n\nans = 0\nfor a in A:\n i = bisect(B, a)\n ans += C_accum[-1] - C_accum[i]\n\nprint(ans)", "import bisect\n\nN=int(input())\nA = sorted(list(map(int,input().split())))\nB = sorted(list(map(int,input().split())))\nC = sorted(list(map(int,input().split())))\n\ncount=0\nfor i in range(N):\n a_cand = bisect.bisect_right(A,B[i]-1)\n c_cand = N-bisect.bisect_right(C,B[i])\n count += a_cand*c_cand\nprint(count)\n", "import bisect\nn=int(input())\na = list(map(int, input(\"\").split()))\nb = list(map(int, input(\"\").split()))\nc = list(map(int, input(\"\").split()))\nout=0\na.sort()\nb.sort()\nc.sort()\nfor i in b:\n na = bisect.bisect_left(a,i)\n nc = bisect.bisect(c,i)\n out += na * (len(c)-nc)\nprint(out)", "import sys\nread = sys.stdin.read\n#readlines = sys.stdin.readlines\nfrom bisect import bisect, bisect_left\nfrom itertools import accumulate\ndef main():\n data = list(map(int, read().split()))\n n = data[0]\n a = data[1:n + 1]\n b = data[n + 1: n * 2 + 1]\n c = data[n * 2 + 1:]\n a.sort()\n b.sort()\n c.sort()\n b2 = [bisect_left(a, be) for be in b]\n b2a = list(accumulate(b2))\n b2a = [0] + b2a\n ans = sum([b2a[bisect_left(b, ce)] for ce in c])\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "import bisect\nn = int(input())\nX = sorted(list(map(int,input().split())))\nY = sorted(list(map(int,input().split())))\nZ = sorted(list(map(int,input().split())))\nprint(sum(bisect.bisect_left(X,b) * (n-bisect.bisect_right(Z,b)) for b in Y))", "import bisect\nn = int(input())\na = sorted(list(map(int, input().split())))\nb = sorted(list(map(int, input().split())))\nc = sorted(list(map(int, input().split())))\nans = 0\nfor i in range(n):\n aa = bisect.bisect_left(a,b[i])\n ca = n-bisect.bisect_right(c,b[i])\n ans += aa * ca\nprint(ans)\n", "import numpy as np\nN = int(input())\nA = np.array(input().split(), dtype=np.int32)\nB = np.array(input().split(), dtype=np.int32)\nC = - np.array(input().split(), dtype=np.int32)\n \nA.sort()\nB.sort()\nC.sort()\n \ncnt_A = np.searchsorted(A,B,side='left')\ncnt_C = np.searchsorted(C,-B,side='left')\n \nanswer = (cnt_A * cnt_C).sum()\nprint(answer)", "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nB.sort()\nC.sort()\nimport bisect\n\nans = 0\n\nfor i in range(N):\n b = B[i]\n a_idx = bisect.bisect_left(A, b)\n # print(b_idx)\n if a_idx == 0: continue\n c_idx = bisect.bisect_right(C, b)\n c_cnt = N - c_idx\n ans += a_idx * c_cnt\nprint(ans)\n", "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nA_cnt = [1] * N\nA_sum = [i+1 for i in range(N)]\nA_sum.append(0)\nB_cnt = [0] * N\nB_sum = [0] * N\nC_cnt = [0] * N\nC_sum = [0] * N\n\nfor i in range(N):\n key = B[i]\n ok = -1\n ng = N\n while abs(ok - ng) > 1:\n mid = (ok + ng) // 2\n if A[mid] < key:\n ok = mid\n else:\n ng = mid\n B_cnt[i] = A_sum[ok]\n\nB_sum[0] = B_cnt[0]\nfor i in range(1, N):\n B_sum[i] = B_sum[i-1] + B_cnt[i]\nB_sum.append(0)\n\nfor i in range(N):\n key = C[i]\n ok = -1\n ng = N\n while abs(ok - ng) > 1:\n mid = (ok + ng) // 2\n if B[mid] < key:\n ok = mid\n else:\n ng = mid\n C_cnt[i] = B_sum[ok]\n\nC_sum[0] = C_cnt[0]\nfor i in range(1, N):\n C_sum[i] = C_sum[i-1] + C_cnt[i]\n\nprint((C_sum[-1]))\n\n# print(A)\n# print(B)\n# print(C)\n# print(A_cnt)\n# print(B_cnt)\n# print(C_cnt)\n# print(A_sum)\n# print(B_sum)\n# print(C_sum)\n", "n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\n\n#\u30ea\u30b9\u30c8\u3092\u30bd\u30fc\u30c8\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\n\n# x\u4ee5\u4e0a\u306e\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\ndef lower_bound(arr , x):\n l = 0\n r = len(c)\n for j in range(30):\n mid = (l + r) // 2\n # print(l , r , mid)\n if x <= arr[mid]:\n r = mid\n else:\n l = mid\n return r\n\n\ncount = 0\nfor i in range(n):\n a_count = lower_bound(a , b[i])\n c_count = len(c) - lower_bound(c , b[i] + 1)\n count += a_count * c_count\n\nprint(count)\n", "from bisect import *\n\nn = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\nans = 0\nfor b in B:\n index_A = bisect_left(A, b)\n index_C = bisect_right(C, b)\n ans += index_A * (n - index_C)\nprint(ans)", "from bisect import bisect_right\nfrom itertools import accumulate\n\n\nN = int(input())\nA = sorted(map(int, input().split()))\nB = sorted(map(int, input().split()))\nC = sorted(map(int, input().split()))\n\nB_to_C = [0] * (N + 1)\nfor i in range(N):\n idx = bisect_right(C, B[i])\n B_to_C[i + 1] = N - idx\nB_to_C = list(accumulate(B_to_C))\n\nans = 0\nfor i in range(N):\n idx = bisect_right(B, A[i])\n ans += B_to_C[N] - B_to_C[idx]\nprint(ans)\n", "def bin_l(arr, key):\n l = 0\n r = len(arr) - 1\n while l <= r:\n mid = (l + r)//2\n if arr[mid] > key:\n r = mid - 1\n else:\n l = mid + 1\n \n if l < len(arr):\n return l\n else:\n return None\n\ndef bin_s(arr, key):\n l = 0\n r = len(arr) - 1\n while l <= r:\n mid = (l + r) // 2\n if arr[mid] >= key:\n r = mid - 1\n else:\n l = mid + 1\n \n if r >= 0 :\n return r\n else:\n return None\n \nn = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA = sorted(A)\nC = sorted(C)\n\nsum = 0\nfor b in B:\n a = bin_s(A, b)\n c = bin_l(C, b)\n a = a + 1 if a is not None else None\n c = n - c if c is not None else None\n if a is not None and c is not None:\n sum += a*c\n\nprint(sum)", "import bisect\nn=int(input())\na,b,c=map(list,[sorted(list(map(int, input().split()))) for i in range(3)])\nans=0\nfor i in range(n):\n ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))\nprint(ans)", "import bisect\nN = int(input())\ntop = list(map(int,input().split()))\nmiddle = list(map(int,input().split()))\t\nbottom = list(map(int,input().split()))\t\n\ntop.sort()\nmiddle.sort()\nbottom.sort()\n\nans = 0\nfor i in middle:\n can_put_upstair = bisect.bisect_left(top,i)\n can_put_downstair = N - bisect.bisect_right(bottom,i)\n #print(can_put_upstair,can_put_downstair)\n ans += can_put_upstair*can_put_downstair\n\nprint(ans)\n", "import bisect\n \nN=int(input())\nb1=0\nd=0\n\nans=0\n \nA=list(map(int, input().split()))\nA=sorted(A)\nB=list(map(int, input().split()))\nB=sorted(B, reverse=True)\nC=list(map(int, input().split()))\nC=sorted(C)\nD=[]\nE=[]\n\nfor b in B:\n d=d+len(C)-bisect.bisect_right(C,b)\n D.append(d)\n\nD=sorted(D, reverse= True) \nB=sorted(B)\n\nfor a in A:\n if 0 <= bisect.bisect_right(B,a) <= len(D)-1:\n ans += D[bisect.bisect_right(B,a)]\nprint(ans)", "def isOK(index, key, in_ls):\n if key<in_ls[index]: return True\n else: return False\n\ndef bs(in_ls, key):\n ng = -1\n ok = len(in_ls)\n while 1<abs(ok - ng):\n mid = (ng + ok)//2\n if isOK(mid, key, in_ls): ok = mid\n else: ng = mid\n return ok\n\ndef main():\n n = int(input())\n a_list = list(map(int, input().split(\" \")))\n b_list = list(map(int, input().split(\" \")))\n c_list = list(map(int, input().split(\" \")))\n #a < b < c\n\n a_sorted = list(sorted(a_list))\n b_sorted = list(sorted(b_list))\n c_sorted = list(sorted(c_list))\n\n bc_dict = {}\n score = 0\n score_list = [0 for i in range(n)]\n for i, b in enumerate(b_sorted[::-1]):\n ok = bs(c_sorted, b)\n score+=n - ok\n score_list[n-i-1]+=score\n\n total = 0\n for a in a_sorted:\n ok = bs(b_sorted, a)\n if ok==n:\n continue\n total+=score_list[ok]\n\n print(total)\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nimport bisect\nAs = list(range(N+1))\n\nBs = [0] * N\ns = 0\nfor i,b in enumerate(B):\n ind = bisect.bisect_left(A,b)\n s += As[ind]\n Bs[i] = s\nBs = [0] + Bs\nCs = [0] * N\nans = 0\nfor i,c in enumerate(C):\n ind = bisect.bisect_left(B,c)\n ans += Bs[ind]\n\nprint(ans)\n\n", "def bin_src_l(arr, key):\n l = 0\n r = len(arr) - 1\n while l <= r:\n mid = (l + r) // 2\n if arr[mid] > key:\n r = mid - 1\n else:\n l = mid + 1\n \n if l < len(arr):\n return l\n else:\n return None\n\ndef bin_src_s(arr, key):\n l = 0\n r = len(arr) - 1\n while l <= r:\n mid = (l + r) // 2\n if arr[mid] >= key:\n r = mid - 1\n else:\n l = mid + 1\n \n if r >= 0 :\n return r\n else:\n return None\n\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA = sorted(A)\nC = sorted(C)\n\nsum = 0\nfor b in B:\n a = bin_src_s(A, b)\n c = bin_src_l(C, b)\n a = a + 1 if a is not None else None\n c = N - c if c is not None else None\n if a is not None and c is not None:\n sum += a * c\n \nprint(sum)", "import bisect\nimport sys\n\nN = int(input())\nA = list(map(int, sys.stdin.readline().rstrip().split()))\nB = list(map(int, sys.stdin.readline().rstrip().split()))\nC = list(map(int, sys.stdin.readline().rstrip().split()))\n\nA.sort()\nC.sort()\n\nans = 0\nfor b in B:\n cnt1 = bisect.bisect_left(A, b)\n cnt2 = len(C) - bisect.bisect(C, b)\n\n ans += cnt1 * cnt2\n\nprint(ans)", "def abc077c_snuke_festival():\n import bisect\n n = int(input())\n a = sorted(list(map(int, input().split())))\n b = sorted(list(map(int, input().split())))\n c = sorted(list(map(int, input().split())))\n total = 0\n for i in range(n):\n b_size = b[i]\n j = bisect.bisect_left(a, b_size)\n j = n - j\n k = bisect.bisect_right(c, b_size)\n\n total += (n - j) * (n - k)\n print(total)\n\n\nabc077c_snuke_festival()", "N = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\nA.append(float(\"INF\"))\nAB = [0] * (N+1)\nj = 0\nfor i in range(N):\n while A[j] < B[i]:\n j += 1\n if j == N:\n break\n AB[i+1] = AB[i] + j\n\nans = 0\nB.append(float(\"INF\"))\nj = 0\nfor i in range(N):\n while B[j] < C[i]:\n j += 1\n if j == N:\n break\n ans += AB[j]\n\nprint(ans)", "import bisect\n\nimport sys\nstdin=sys.stdin\n\nip=lambda: int(sp())\nfp=lambda: float(sp())\nlp=lambda:list(map(int,stdin.readline().split()))\nsp=lambda:stdin.readline().rstrip()\nyp=lambda:print('Yes')\nnp=lambda:print('No')\n\nn=ip()\na=lp()\nb=lp()\nc=lp()\n\na.sort()\nb.sort()\nc.sort()\nans=0\n\nfor i in range(n):\n x=bisect.bisect_left(a,b[i])\n y=bisect.bisect_right(c,b[i])\n ans+=x*(n-y)\n \nprint(ans)\n\n\n", "def main():\n import bisect\n\n N = int(input())\n upper = list(map(int, input().split()))\n middle = list(map(int, input().split()))\n lower = list(map(int, input().split()))\n\n upper.sort()\n middle.sort()\n lower.sort()\n\n cnt = 0\n\n for i in range(N):\n mid = middle[i]\n index_up = bisect.bisect_left(upper, mid)\n index_low = bisect.bisect_right(lower, mid)\n \n cnt += index_up * (N - index_low)\n \n print(cnt)\n\n\ndef __starting_point():\n main()\n__starting_point()", "#!/usr/bin/env python3\ndef main():\n from bisect import bisect\n\n N = int(input())\n A = sorted([int(x) for x in input().split()])\n B = sorted([int(x) for x in input().split()])\n C = sorted([int(x) for x in input().split()])\n\n lst = [N - bisect(C, b) for b in B]\n lst = lst[::-1]\n tmp_lst = [lst[0]]\n for i in lst[1:]:\n tmp_lst.append(i + tmp_lst[-1])\n tmp_lst = tmp_lst[::-1]\n\n ans = 0\n for a in A:\n res = bisect(B, a)\n ans += tmp_lst[res] if res < N else 0\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "#!/usr/bin/env python3\ndef main():\n from bisect import bisect, bisect_left\n\n N = int(input())\n A = sorted([int(x) for x in input().split()])\n B = sorted([int(x) for x in input().split()])\n C = sorted([int(x) for x in input().split()])\n\n print((sum([bisect_left(A, b) * (N - bisect(C, b)) for b in B])))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nA_list = list(map(int, input().split()))\nB_list = list(map(int, input().split()))\nC_list = list(map(int, input().split()))\nA_list = sorted(A_list)\nB_list = sorted(B_list)\nC_list = sorted(C_list)\ncnt = 0\n\ndef is_ok(arg): #\u3000B\u3000\u3088\u308a\u5c0f\u3055\u3044\u6700\u5927\u306e\u3000A\n return A_list[arg] < B_list[i]\n\ndef bisect(ng, ok):\n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok(mid):\n ok = mid\n else:\n ng = mid\n return ok\n\ndef is_ok2(arg): #\u3000B\u3000\u3088\u308a\u5927\u304d\u3044\u6700\u5c0f\u306e\u3000A\n return C_list[arg] > B_list[i]\n\ndef bisect2(ng, ok):\n while (abs(ok - ng) > 1):\n mid = (ok + ng) // 2\n if is_ok2(mid):\n ok = mid\n else:\n ng = mid\n return ok\n\nfor i in range(n): #B\u3092\u56fa\u5b9a\n #B\u3088\u308a\u5c0f\u3055\u3044A\u3092\u63a2\u3059\n A_key = bisect(len(A_list), 0)\n if A_list[A_key] < B_list[i]:\n #B\u3088\u308a\u5927\u304d\u3044C\u3092\u63a2\u3059\n C_key = bisect2(-1, len(C_list)-1)\n if B_list[i] < C_list[C_key]:\n #print(A_key, i, C_key, A_list[A_key], B_list[i], C_list[C_key])\n cnt += (n-C_key)*(A_key+1)\n\nprint(cnt)\n", "import bisect\n\nn = int(input())\na = sorted(list(map(int, input().split())))\nb = sorted(list(map(int, input().split())))\nc = sorted(list(map(int, input().split())))\nans = 0\nfor i in b:\n an = bisect.bisect_left(a, i)\n cn = n - bisect.bisect_right(c, i)\n ans += an * cn\n\nprint(ans)\n", "import bisect\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\n\nA = sorted(A)\nB = sorted(B)\nC = sorted(C)\n#print(A,B,C)\nCount_A = [0]*N\nCount_C = [0]*N\nfor i in range(N):\n # A Count\n Count_A[i] = bisect.bisect_left(A,B[i])\n # C Count\n Count_C[i] = N-bisect.bisect(C,B[i])\n#print(Count_A,Count_C)\nPatterns = 0\nfor i in range(N):\n Patterns=Patterns+Count_A[i]*Count_C[i]\n \nprint(Patterns)", "N = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\ndef binary1(L, R, list_, threshold):\n while L + 1 < R:\n x = (L + R)//2\n if list_[x] < threshold:\n L = x \n else:\n R = x\n return L\n\ndef binary2(L, R, list_, threshold):\n while L + 1 < R:\n x = (L + R)//2\n if list_[x] > threshold:\n R = x \n else:\n L = x\n return L\n\nans = []\nfor b in B:\n L = -1\n R = N\n a = binary1(L, R, A, b) + 1\n c = N - binary2(L, R, C, b) - 1\n ans.append(a*c)\nprint((sum(ans)))\n", "import bisect\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\nans=0\nfor b in B:\n a_index = bisect.bisect_left(A, b)\n c_index = bisect.bisect_right(C, b)\n ans += a_index * (N-c_index)\n \nprint(ans)", "import bisect\nn = int(input())\nA = sorted(list(map(int, input().split())))\nB = list(map(int, input().split()))\nC = sorted(list(map(int, input().split())))\n\ncnt = 0\nfor b in B:\n i = bisect.bisect_left(A, b)\n j = n-bisect.bisect_right(C, b)\n cnt += i*j\n\nprint(cnt)\n", "import bisect\nimport itertools\n\nN = int(input()) # \u305d\u308c\u305e\u308c\u306e\u30d1\u30fc\u30c4\u306e\u6570\nA = list(map(int, input().split())) # \u5c0f\u3055\u3044\nB = list(map(int, input().split())) # \u4e2d\u304f\u3089\u3044\nC = list(map(int, input().split())) # \u5927\u304d\u3044\n\n# C\u306f\u4e26\u3073\u66ff\u3048\u4e0d\u8981\nA.sort()\nB.sort()\n\n# B\u306e\u5404\u8981\u7d20\u3067A\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u8fd4\u3063\u3066\u304d\u305findex\u3092\u5148\u306b\u4fdd\u6709\u3057\u3066\u304a\u304f\nb_counts = [0] * N\nfor i in range(N):\n b_count = bisect.bisect_left(A, B[i])\n b_counts[i] = b_count\n\ncumsum_b_counts = list(itertools.accumulate(b_counts))\ncumsum_b_counts = [0] + cumsum_b_counts\n\n# C\u306e\u5404\u8981\u7d20\u3067B\u3092\u4e8c\u5206\u63a2\u7d22\u3002\u4e0a\u8a18\u3067\u4fdd\u6709\u3057\u3066\u304a\u3044\u305fb_counts\u3092\u6d3b\u7528\u3059\u308b\ntotal = 0\nfor c in C:\n count = bisect.bisect_left(B, c)\n total += cumsum_b_counts[count]\n\nprint(total)\n\n", "import bisect\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nc.sort()\n\nans = 0\nfor B in b:\n i = bisect.bisect_left(a, B)\n j = bisect.bisect_right(c, B)\n ans += i * (n - j)\n\nprint(ans)", "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\na=sorted(a)\nb=sorted(b)\nc=sorted(c)\nc.insert(0,-1)\nc.append(10**10)\nB=[0]*n\nans=0\nfor i in range(n):\n x=b[i]\n l=0\n r=n+1\n while r-l>1:\n m=(l+r)//2\n if c[m]>x:\n r=m\n elif c[m]<=x:\n l=m\n B[i]=n-l\ng=[0]*n\n\n\ng[n-1]=B[n-1]\nfor i in range(n-1):\n g[-2-i]=g[-1-i]+B[-2-i]\ng.append(0)\n\nb.insert(0,-1)\nb.append(10**10)\nfor i in range(n):\n x=a[i]\n l=0\n r=n+1\n while r-l>1:\n m=(l+r)//2\n if b[m]>x:\n r=m\n elif b[m]<=x:\n l=m\n ans+=g[l]\nprint(ans)\n", "def upper_bound(A, x):\n s, t = -1, len(A)\n while t - s > 1:\n m = (s+t)//2\n if A[m] > x:\n t = m\n else:\n s = m\n \n return t\n\ndef lower_bound(A, x):\n s, t = -1, len(A)\n while t - s > 1:\n m = (s+t)//2\n if A[m] >= x:\n t = m\n else:\n s = m\n \n return t\n\n\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\nans = 0\nfor b in B:\n ans += lower_bound(A, b) * (N - upper_bound(C, b))\n\nprint(ans)", "import bisect\nn = int(input())\nA = list(map(int, input().split(' ')))\nB = list(map(int, input().split(' ')))\nC = list(map(int, input().split(' ')))\n\nA.sort()\nB.sort()\nC.sort()\nans = 0\nfor j in range(n):\n i = bisect.bisect_left(A, B[j])\n k = n - bisect.bisect_right(C, B[j])\n ans += int(i*k)\nprint(ans)", "from bisect import *\n\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\ncnt = []\n\nfor b in B:\n cnt.append(bisect_left(A,b) * (N - bisect_right(C,b)))\nprint((sum(cnt)))\n\n", "import bisect\nn = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\nb_ans = [0] * len(b)\nfor i in range(len(b)):\n b_ans[i] = bisect.bisect_left(a, b[i])\n\nruiseki_b = [0]\nfor i in range(len(b_ans)):\n ruiseki_b.append(ruiseki_b[i] + b_ans[i])\nans = 0\nfor i in range(len(c)):\n ans += ruiseki_b[bisect.bisect_left(b, c[i])]\nprint(ans)\n", "from bisect import bisect_left, bisect_right\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort()\nC.sort()\n\ncnt = 0\nfor b in B:\n cnt += bisect_left(A, b) * (N - bisect_right(C, b))\nprint(cnt)"]
{"inputs": ["2\n1 5\n2 4\n3 6\n", "3\n1 1 1\n2 2 2\n3 3 3\n", "6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\n"], "outputs": ["3\n", "27\n", "87\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
56,564
95683f2da5f8b6e2255948bf3142f053
UNKNOWN
In programming, hexadecimal notation is often used. In hexadecimal notation, besides the ten digits 0, 1, ..., 9, the six letters A, B, C, D, E and F are used to represent the values 10, 11, 12, 13, 14 and 15, respectively. In this problem, you are given two letters X and Y. Each X and Y is A, B, C, D, E or F. When X and Y are seen as hexadecimal numbers, which is larger? -----Constraints----- - Each X and Y is A, B, C, D, E or F. -----Input----- Input is given from Standard Input in the following format: X Y -----Output----- If X is smaller, print <; if Y is smaller, print >; if they are equal, print =. -----Sample Input----- A B -----Sample Output----- < 10 < 11.
["x,y=input().split()\nif ord(x)<ord(y):print('<')\nelif ord(x)>ord(y):print('>')\nelse:print('=')", "X, Y = input().split()\n\ntemp = \"ABCDEF\"\n\nif temp.index(X) > temp.index(Y):\n print(\">\")\nelif temp.index(X) == temp.index(Y):\n print(\"=\")\nelse:\n print(\"<\")", "l = list(input().split())\nif len(set(l))==1: print('=')\nelif l==sorted(l): print('<')\nelse: print('>')", "X, Y = map(ord, input().split())\nif X < Y:\n print('<')\nelif X > Y:\n print('>')\nelse:\n print('=')", "x,y=input().split()\nif ord(x)>ord(y):\n print(\">\")\nelif ord(x)==ord(y):\n print(\"=\")\nelse:\n print(\"<\")", "X,Y = map(ord,input().split())\n\nif X > Y:\n print('>')\nelif X < Y:\n print('<')\nelse:\n print('=')", "x, y = map(str, input().split())\n\nif x < y:\n print(\"<\")\nelif x > y:\n print(\">\")\nelif x == y:\n print(\"=\")", "x,y=input().split()\nif x==y:\n print(\"=\")\nelif x<y:\n print(\"<\")\nelse:\n print(\">\")", "x, y = list(map(str,input().split()))\nl = ['A','B','C','D','E','F']\n\nprint((['=', '<', '>'][l.index(y) > l.index(x) or -(l.index(y) < l.index(x))]))\n", "X, Y = map(str, input().split())\nif X < Y:\n print('<')\nelif X > Y:\n print('>')\nelse:\n print('=')", "# 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= list(map(str,input().split()))\n# f = 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\n\nlis=[\"A\",\"B\", \"C\", \"D\", \"E\", \"F\"]\nif lis.index(A)<lis.index(B):\n print(\"<\")\nelif lis.index(A)==lis.index(B):\n print(\"=\")\nelse:\n print(\">\")\n\n", "lst = input().split()\nX = lst[0]\nY = lst[1]\nlst.sort()\n\nif X == Y:\n print('=')\nelif X == lst[0]:\n print('<')\nelse:\n print('>')", "a,b =input().split()\nif a == b:\n print(\"=\")\nelif a < b:\n print(\"<\")\nelse:\n print(\">\")\n", "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=LS()\nX=A[0]\nY=A[1]\nif X < Y:\n print(\"<\")\nelif X==Y:\n print(\"=\")\nelse:\n print(\">\")", "a,b=input().split();print(\"=<>\"[(a!=b)+(a>b)])", "x, y = input().split()\nif x > y:\n print(\">\")\nelif x == y:\n print(\"=\")\nelse:\n print(\"<\")", "X,Y=map(str,input().split())\nif X>Y :\n print(\">\")\nelif X==Y :\n print(\"=\")\nelse :\n print(\"<\")", "a,b=input()[0::2]\nprint(\"<\"if a<b else\">\"if a>b else\"=\")", "a, b = input().split()\nif a > b:\n print('>')\nelif a < b:\n print('<')\nelse:\n print('=')", "x,y = input().split()\nans = \"=\"\nif x < y: ans = \"<\"\nelif x > y: ans = \">\"\nprint(ans)", "X, Y = input().split()\nif X == Y:\n print('=')\nelif X > Y:\n print('>')\nelse:\n print('<')", "#78\ndata=list(input().split())\nif data[0]<data[1]:\n print('<')\nelif data[0]>data[1]:\n print('>')\nelse:\n print('=')", "a,b = map(str,input().split())\nif a == b:\n print(\"=\")\nelif a<b:\n print(\"<\")\nelse:\n print(\">\")", "x, y = map(str, input().split())\n#print(int(ord(x)), int(ord(y)))\nif x < y:\n print(\"<\")\nelif x == y:\n print(\"=\")\nelse:\n print(\">\")", "X, Y = input().split()\n\nif X < Y:\n print('<')\nelif X > Y:\n print('>')\nelse:\n print('=')", "x,y = input().split()\nif ord(x)<ord(y):\n print(\"<\")\nelif ord(x)==ord(y):\n print(\"=\")\nelse:\n print(\">\")", "x, y = input().split()\nprint(\"<\" if x < y else \"=\" if x == y else \">\")", "x, y = input().split()\nif ord(x) < ord(y):\n print('<')\nelif ord(x) > ord(y):\n print('>')\nelse:\n print('=')", "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\nA = LS()\nX = A[0]\nY = A[1]\nif X < Y:\n print(\"<\")\nelif X == Y:\n print(\"=\")\nelse:\n print(\">\")", "a,b=input().split();print(['=','<','>'][(a!=b)+(a>b)])", "a, b = input().split()\n\nif a < b:\n print('<')\nelif a>b:\n print('>')\nelse:\n print('=')", "X, Y = input().split()\n\nif X == Y:\n print('=')\nelif X > Y:\n print('>')\nelse:\n print('<')\n", "x,y=input().split()\nprint('<' if x<y else '>' if x>y else '=')", "# coding = SJIS\n\nx, y = list(map(str, input().split()))\nalp = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\"]\n\nif alp.index(x) < alp.index(y):\n print(\"<\")\nelif alp.index(x) > alp.index(y):\n print(\">\")\nelse:\n print(\"=\")\n", "import math\nX,Y=input().split()\nX=ord(X)\nY=ord(Y)\nif X==Y:\n print(\"=\")\nelif X>Y:\n print(\">\")\nelse:\n print(\"<\")\n\n", "A,B =(ord(x) for x in input().split())\n\n\nif A<B: \n print('<')\nelif A>B:\n print('>')\nelse:\n print('=')\n \n", "X, Y = input().split()\nif X < Y:\n print(\"<\")\nif X > Y:\n print(\">\")\nif X == Y:\n print(\"=\")", "a,b = input().split()\n\nif ord(a) < ord(b):\n print(\"<\")\nelif ord(a) > ord(b):\n print(\">\")\nelse:\n print(\"=\")", "x,y = input().split()\nif x < y:\n print('<')\nelif x == y:\n print('=')\nelse:\n print('>')", "x,y=map(str,input().split())\nif x<y:\n print('<')\nelif x==y:\n print('=')\nelse:\n print('>')", "#ABC078A\nx,y = input().split()\nprint(\"<\" if x<y else \"=\" if x==y else \">\")", "x, y = map(str, input().split())\nprint(\"<\" if x < y else \">\" if x > y else \"=\")", "x,y=list(map(str,input().split()))\nif x==y:\n print(\"=\")\nelif x<y:\n print(\"<\")\nelse:\n print(\">\")\n \n", "def iroha():\n a, b = input().split()\n exmap = {'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}\n aa = exmap[a]\n bb = exmap[b]\n if aa < bb:\n print(\"<\")\n elif aa > bb:\n print(\">\")\n else:\n print(\"=\")\n\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "x,y = input().split()\nif x > y:\n print('>')\nelif x < y:\n print('<')\nelse:\n print('=')", "def alp_num(alp):\n alp_lst = list('ABCDEF')\n\n num = alp_lst.index(alp)\n return num\n\n\ndef main():\n x, y = map(str, input().split())\n num1 = alp_num(x)\n num2 = alp_num(y)\n\n if num1 < num2:\n com_ope = '<'\n elif num1 == num2:\n com_ope = '='\n else:\n com_ope = '>'\n\n print(com_ope)\n\n\ndef __starting_point():\n main()\n__starting_point()", "X, Y = input().split()\nif X > Y:\n ans = '>'\nelif X < Y:\n ans = '<'\nelse:\n ans = '='\nprint(ans)", "x, y = input().split()\n\nif ord(x) < ord(y):\n print('<')\nelif ord(x) > ord(y):\n print('>')\nelse:\n print('=')\n", "x,y = input().split()\nif ord(x) < ord(y):\n print(\"<\")\nelif ord(x) > ord(y):\n print(\">\")\nelse:\n print(\"=\")", "A, B = input().split()\nprint('<' if A < B else \"=\" if A == B else '>')", "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\na,b = input().split()\nif a < b:\n print('<')\nelif a > b:\n print('>')\nelse:\n print('=')\n", "x,y=map(str,input().split())\n\nif int(ord(x))<int(ord(y)):\n ans='<'\nelif int(ord(x))>int(ord(y)):\n ans='>'\nelse:\n ans='='\nprint(ans)", "X, Y = input().split()\nalphabet = ['A', 'B', 'C', 'D', 'E', 'F']\nx_i = 0\ny_i = 0\nfor i in range(6):\n if alphabet[i] == X:\n x_i = i\n if alphabet[i] == Y:\n y_i = i\nif x_i < y_i:\n print('<')\nelif x_i > y_i:\n print('>')\nelse:\n print('=')\n", "x, y = list(map(str, input().split()))\n\ndict_num = {'A': 10,\n 'B': 11,\n 'C': 12,\n 'D': 13,\n 'E': 14,\n 'F': 15}\n\nif dict_num[x] == dict_num[y]:\n print('=')\nelif dict_num[x] > dict_num[y]:\n print('>')\nelse:\n print('<')\n", "A=1\nB=2\nC=3\nD=4\nE=5\nF=6\nX,Y=input().split()\nif X<Y:\n print(\"<\")\nelif X>Y:\n print(\">\")\nelif X==Y:\n print(\"=\")", "A, B = input().split()\nif A > B: \n print('>')\nelif A == B:\n print('=')\nelse:\n print('<')\n", "X, Y = input().split()\n\nif X < Y:\n print(\"<\")\nelif X == Y:\n print(\"=\")\nelse:\n print(\">\")\n", "X,Y=input().split()\nprint(\"<\"if X<Y else \">\" if X>Y else \"=\")", "X, Y = [x for x in input().split()]\n\nif ord(X) < ord(Y):\n print('<')\nelif ord(X) == ord(Y):\n print('=')\nelse:\n print('>')\n", "a, b = input().split()\n\ndict = {\n 'A':0,\n 'B':1,\n 'C':2,\n 'D':3,\n 'E':4,\n 'F':5\n}\na = dict[a]\nb = dict[b]\n\nif a < b:\n ans = '<'\nelif b < a:\n ans = '>'\nelse:\n ans = '='\n \nprint(ans)\n", "x,y=map(str,input().split())\nif x>y:\n print(\">\")\nelif x==y:\n print(\"=\")\nelse:\n print(\"<\")", "X, Y = [ int('0x' + i, base = 16) for i in input().split()]\nif X > Y:\n print('>')\nelif X < Y:\n print('<')\nelse:\n print('=')", "x,y = map(str,input().split())\n\nif x > y:\n print('>')\n \nelif x == y:\n print('=')\n \nelse:\n print('<')", "def main():\n a, b = input().split(\" \")\n\n if a > b: print(\">\")\n elif a < b: print(\"<\")\n else: print(\"=\")\n\n\nmain()", "a,b = input().split()\n\nif a > b:\n print('>')\nelif a == b:\n print('=')\nelse:\n print('<')", "x,y = map(str,input().split())\nif ord(x) > ord(y):\n print(\">\")\nelif x == y:\n print(\"=\")\nelse:\n print(\"<\")", "x, y = input().split()\nif x == y:\n print(\"=\")\nelif ord(x) > ord(y):\n print(\">\")\nelse:\n print(\"<\")", "x,y=input().split()\nprint(\"<\" if x<y else \">\" if x>y else \"=\")", "A, B = input().split()\nif ord(A) > ord(B):\n print('>')\nelif ord(A) < ord(B):\n print('<')\nelse:\n print('=')", "x,y=input().split()\nprint(\"<\" if x<y else \">\" if x>y else \"=\")", "x,y=input().split()\nif x<y:\n print(\"<\")\nelif x>y:\n print(\">\")\nelse:\n print(\"=\")", "x,y=map(str,input().split())\nif ord(x)<ord(y):\n print(\"<\")\nelif ord(x)>ord(y):\n print(\">\")\nelse:\n print(\"=\")", "X, Y = input().split()\n\nprint(\">\" if X > Y else \"=\" if X == Y else \"<\")", "X,Y = input().split()\nprint(\"<\" if X < Y else \">\" if Y < X else \"=\")", "x, y = input().split()\nif x > y:\n print(\">\")\nelif x == y:\n print(\"=\")\nelse:\n print(\"<\")\n", "X,Y=map(str,input().split())\nif X<Y:\n ans=\"<\"\nelif X>Y:\n ans=\">\"\nelse:\n ans=\"=\"\nprint(ans)", "a=input().split()\nb=sorted(a)\n\nif a!=b:\n print('>')\n \nelif a[0]==a[1]:\n print('=')\n \nelse:\n print('<')\n \n\n\n", "X, Y = input().split()\nx_i = ord(X)\ny_i = ord(Y)\nif x_i < y_i:\n print('<')\nelif x_i > y_i:\n print('>')\nelse:\n print('=')\n", "a,b = input().split()\n\nif a < b:\n print('<')\nelif a == b:\n print('=')\nelse:\n print('>')\n", "A,B=input().split()\n\nmydict = {\"A\":10, \"B\":11, \"C\":12, \"D\":13, \"E\":14, \"F\":15}\n\nprint('>') if mydict[A] > mydict[B] else print('<') if mydict[A] < mydict[B] else print('=')\n", "a, b = input().split()\nif a == b:\n print('=')\nelif a > b:\n print('>')\nelse:\n print('<')", "X, Y = input().split()\nif X > Y:\n print(\">\")\nelif Y > X:\n print(\"<\")\nelse:\n print(\"=\")", "x = list(map(str,input().split()))\n\nif(x[0]>x[1]):\n print('>')\nelse:\n if(x[0]<x[1]):\n print('<')\n else:\n print('=')\n", "x, y = list(map(ord, input().split()))\nif x > y:\n print(\">\")\nelif x == y:\n print(\"=\")\nelse:\n print(\"<\")\n", "x, y = map(str, input().split())\nif x < y:\n print('<')\nelif x > y:\n print('>')\nelse:\n print('=')", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nx, y = list(map(str, input().split()))\n\nx = int(\"0x\"+x, 16)\ny = int(\"0x\"+y, 16)\n\nif x > y:\n print(\">\")\nelif x == y:\n print(\"=\")\nelse:\n print(\"<\")\n", "x,y = input().split()\nif x<y:\n print('<')\nelif x>y:\n print('>')\nelse:\n print('=')", "x,y = map(lambda x: int(x,16),input().split())\nans = \"=\"\nif x < y: ans = \"<\"\nelif x > y: ans = \">\"\nprint(ans)", "a,b=input().split()\nif a<b:\n print(\"<\")\nelif a>b:\n print(\">\")\nelse:\n print(\"=\")", "A, B = map(str, input().split())\n\nif A > B:\n print(\">\")\nelif A < B:\n print(\"<\")\nelse:\n print(\"=\")", "X,Y=input().split()\nif X<Y:\n print(\"<\")\nelif X>Y:\n print(\">\")\nelse:\n print(\"=\")\n", "array = [\"A\",\"B\",\"C\",\"D\",\"E\",\"F\"]\nX,Y = input().split()\nprint(\"<\") if array.index(X)<array.index(Y) else print(\">\") if array.index(X)>array.index(Y) else print(\"=\")", "x,y = input().split()\nif x<y:\n print('<')\nelif x>y:\n print('>')\nelse:\n print('=')\n", "import sys\n\nX, Y = sys.stdin.readline().strip().split()\nif X == Y:\n print(\"=\")\nelif X < Y:\n print(\"<\")\nelse:\n print(\">\")", "a,b = input().split()\na = a.replace(\"A\",\"10\").replace(\"B\",\"11\").replace(\"C\",\"12\").replace(\"D\",\"13\").replace(\"E\",\"14\").replace(\"F\",\"15\")\nb = b.replace(\"A\",\"10\").replace(\"B\",\"11\").replace(\"C\",\"12\").replace(\"D\",\"13\").replace(\"E\",\"14\").replace(\"F\",\"15\")\nif int(a) == int(b):\n print(\"=\")\nelif int(a) > int(b):\n print(\">\")\nelif int(a) < int(b):\n print(\"<\")", "x,y = input().split()\nif x > y:\n print('>')\nif x < y:\n print('<')\nif x == y:\n print('=')", "a,b=input().split(\" \")\nif a==b:print(\"=\")\nelif a<b:print(\"<\")\nelse:print(\">\")", "x,y = list(map(ord,input().split()))\nprint((\"<\" if x < y else \">\" if x > y else \"=\"))\n", "x,y = map(str,input().split())\nal = list(\"ABCDEF\")\nx = al.index(x)\ny = al.index(y)\nif x>y:\n print(\">\")\nelif x<y:\n print(\"<\")\nelse:\n print(\"=\")", "x, y = list(map(str, input().split()))\n\nif x < y:\n print(\"<\")\nelif x > y:\n print(\">\")\nelse:\n print(\"=\")\n"]
{"inputs": ["A B\n", "E C\n", "F F\n"], "outputs": ["<\n", ">\n", "=\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
14,673
2bc32ce571234152ffcafce3135c7432
UNKNOWN
You are given an H Γ— W grid. The squares in the grid are described by H strings, S_1,...,S_H. The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W). . stands for an empty square, and # stands for a square containing a bomb. Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square. (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.) He decides to replace each . in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square. Print the strings after the process. -----Constraints----- - 1 \leq H,W \leq 50 - S_i is a string of length W consisting of # and .. -----Input----- Input is given from Standard Input in the following format: H W S_1 : S_H -----Output----- Print the H strings after the process. The i-th line should contain a string T_i of length W, where the j-th character in T_i corresponds to the square at the i-th row from the top and j-th row from the left in the grid (1 \leq i \leq H, 1 \leq j \leq W). -----Sample Input----- 3 5 ..... .#.#. ..... -----Sample Output----- 11211 1#2#1 11211 For example, let us observe the empty square at the first row from the top and first column from the left. There is one bomb square adjacent to this empty square: the square at the second row and second column. Thus, the . corresponding to this empty square is replaced with 1.
["# \u611a\u76f4\nh, w = map(int, input().split())\ntable = [list(input()) for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if table[i][j] == \".\":\n num = 0\n for y in [-1, 0, 1]:\n for x in [-1, 0, 1]:\n if 0 <= i + y < h and 0 <= j + x < w:\n if table[i + y][j + x] == \"#\":\n num += 1\n table[i][j] = str(num)\nfor t in table:\n print(\"\".join(t))", "h,w=map(int,input().split())\nl = [input() for _ in range(h)]\nk = [['#' for x in range(w) ] for _ in range(h)]\ndx = [0,0,1,-1,1,1,-1,-1]\ndy = [1,-1,0,0,1,-1,1,-1]\nfor i in range(h):\n for j in range(w):\n if l[i][j] == '.':\n cnt = 0\n for di in range(8):\n x = j+dx[di]\n y = i+dy[di]\n if x<0 or y<0 or x >=w or y >=h:\n continue\n if l[y][x] == '#':\n cnt +=1\n k[i][j] = cnt\nfor i in range(h):\n print(''.join(map(str, k[i])))", "import sys\nH, W = map(int, input().split())\nif H == 1:\n if W == 1:\n s = input()\n if s == \"#\":\n print(\"#\")\n else:\n print(0)\n else:\n cnt = [0 for _ in range(W)]\n s = list(input())\n for w in range(W):\n if w == 0:\n cnt[w] += s[w+1] == \"#\"\n elif w == W-1:\n cnt[w] += s[w-1] == \"#\"\n else:\n cnt[w] += s[w+1] == \"#\"\n cnt[w] += s[w-1] == \"#\"\n for w in range(W):\n if s[w] == \"#\":\n cnt[w] = \"#\"\n ans = map(str, cnt)\n print(\"\".join(ans))\n return\nif W == 1:\n cnt = [0 for _ in range(H)]\n s = []\n for h in range(H):\n s.append(input())\n for h in range(H):\n if h == 0:\n cnt[h] += s[h+1] == \"#\"\n elif h == H-1:\n cnt[h] += s[h-1] == \"#\"\n else:\n cnt[h] += s[h-1] == \"#\"\n cnt[h] += s[h+1] == \"#\"\n for h in range(H):\n if s[h] == \"#\":\n print(\"#\")\n else:\n print(cnt[h])\n return\n \nS = []\ncnt = [[0 for _ in range(W)] for _ in range(H)]\nfor h in range(H):\n s = list(input())\n for w in range(W):\n if w == 0:\n cnt[h][w] += s[w+1] == \"#\"\n elif w == W-1:\n cnt[h][w] += s[w-1] == \"#\"\n else:\n cnt[h][w] += s[w+1] == \"#\"\n cnt[h][w] += s[w-1] == \"#\"\n S.append(s)\n \nfor h in range(H):\n for w in range(W):\n if h == 0:\n cnt[h][w] += S[h+1][w] == \"#\"\n if w == 0:\n cnt[h][w] += S[h+1][w+1] == \"#\"\n elif w == W-1:\n cnt[h][w] += S[h+1][w-1] == \"#\"\n else:\n cnt[h][w] += S[h+1][w-1] == \"#\"\n cnt[h][w] += S[h+1][w+1] == \"#\"\n elif h == H-1:\n cnt[h][w] += S[h-1][w] == \"#\"\n if w == 0:\n cnt[h][w] += S[h-1][w+1] == \"#\"\n elif w == W-1:\n cnt[h][w] += S[h-1][w-1] == \"#\"\n else:\n cnt[h][w] += S[h-1][w-1] == \"#\"\n cnt[h][w] += S[h-1][w+1] == \"#\"\n else:\n cnt[h][w] += S[h+1][w] == \"#\"\n if w == 0:\n cnt[h][w] += S[h+1][w+1] == \"#\"\n elif w == W-1:\n cnt[h][w] += S[h+1][w-1] == \"#\"\n else:\n cnt[h][w] += S[h+1][w-1] == \"#\"\n cnt[h][w] += S[h+1][w+1] == \"#\"\n cnt[h][w] += S[h-1][w] == \"#\"\n if w == 0:\n cnt[h][w] += S[h-1][w+1] == \"#\"\n elif w == W-1:\n cnt[h][w] += S[h-1][w-1] == \"#\"\n else:\n cnt[h][w] += S[h-1][w-1] == \"#\"\n cnt[h][w] += S[h-1][w+1] == \"#\"\n \nfor h in range(H):\n s = S[h]\n for w in range(W):\n if s[w] == \"#\":\n cnt[h][w] = \"#\"\n ans = map(str, cnt[h])\n print(\"\".join(ans))", "H,W = map(int,input().split())\n\nS = [input() for _ in range(H)]\nM = [[\"\"]*W for _ in range(H)]\n\ndef bomb_cnt(i,j):\n min_h = max(0,i-1)\n max_h = min(i+2,H)\n min_w = max(0,j-1)\n max_w = min(j+2,W)\n cnt = 0\n for k in range(min_h,max_h):\n for g in range(min_w,max_w):\n if (S[k][g] == \"#\"):\n cnt += 1\n \n return str(cnt)\n\nfor i in range(H):\n for j in range(W):\n if S[i][j] == \"#\":\n M[i][j] = \"#\"\n else:\n M[i][j] = bomb_cnt(i,j)\n \n \nfor i in range(H):\n print(*M[i],sep=\"\")", "h, w = list(map(int, input().split()))\ns = [list(map(str, input())) for i in range(h)]\nans = s\n\ndi = [1, 0, -1, 0, 1, -1, -1, 1]\ndj = [0, 1, 0, -1, 1, 1, -1, -1]\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n continue\n cnt = 0\n for d in range(8):\n if i + di[d] <0 or i + di[d] > h - 1 or j + dj[d] < 0 or j + dj[d] > w - 1:\n continue\n if s[i + di[d]][j +dj[d]] == '#':\n cnt += 1\n ans[i][j] = cnt\n\nfor i in range(h):\n print((''.join(map(str, ans[i]))))\n", "H,W=map(int,input().split())\nS=[]\nfor i in range(H):\n S.append(list(input()))\nfor j in range(H):\n for p in range(W):\n if S[j][p]==\".\":\n c=0\n for h,w in [(1,0),(0,1),(-1,0),(0,-1),(1,1),(-1,-1),(-1,1),(1,-1)]:\n if 0<=j+h<=H-1 and 0<=p+w<=W-1 and S[j+h][p+w]==\"#\":\n c+=1\n S[j][p]=c\nfor i in S:\n print(*i,sep=\"\")", "def resolve():\n h,w=map(int,input().split())\n s=[]\n for _ in range(h):\n s.append(list(input()))\n dx=[-1,-1,-1,0,0,1,1,1]\n dy=[-1,0,1,-1,1,-1,0,1]\n for x in range(h):\n for y in range(w):\n if s[x][y]=='#':\n for k in range(8):\n nx=x+dx[k]\n ny=y+dy[k]\n if not(nx<h and 0<=nx and ny<w and 0<=ny) or s[nx][ny]=='#':\n continue\n if s[nx][ny]=='.':\n s[nx][ny]='1'\n else:\n s[nx][ny]=str(ord(s[nx][ny])-ord('0')+1)\n for i in range(h):\n for j in range(w):\n if s[i][j]=='.':\n s[i][j]='0'\n for i in range(h):\n print(''.join(s[i]))\nresolve()", "H,W=map(int,input().split())\nS=[list(input()) for _ in range(H)]\n\ndi=[1,1,0,-1,-1,-1,0,1]\ndj=[0,1,1,1,0,-1,-1,-1]\n\nfor i in range(H):\n for j in range(W):\n ans=0\n if S[i][j]=='#':\n continue\n for k in range(8):\n ni=i+di[k]\n nj=j+dj[k]\n if ni<0 or nj<0 or ni>=H or nj>=W:\n continue\n if S[ni][nj]=='#':\n ans+=1\n S[i][j]=str(ans)\nfor i in range(H):\n for j in range(W):\n print(S[i][j],end='')\n print()\n", "import numpy as np\nH, W = map(int, input().split())\nS = []\npad = list('.'* (W+2))\nS.append(pad)\nfor i in range(H):\n _S = list(input())\n _S = ['.'] + _S +[ '.']\n S.append(_S)\nS.append(pad)\nS = np.array(S)\n\nfor h in range(1, H+1):\n for w in range(1, W+1):\n if S[h, w] == '#':\n print('#', end='')\n else:\n print(np.sum(S[h-1:h+2, w-1:w+2]=='#'), end=\"\")\n print()\n\n ", "h,w = map(int,input().split())\nl = [[\".\"]*(w+2)]\nfor i in range(h):\n l.append([\".\"] + [i for i in input()] + [\".\"])\nl.append([\".\"]*(w+2))\n \ndef count(i,j):\n if l[i][j] == \"#\":\n return \"#\"\n c = 0\n for n in range(i-1,i+2):\n for m in range(j-1,j+2):\n if l[n][m] == \"#\":\n c += 1\n return str(c)\n \nans = [\"\".join([count(i,j) for j in range(1,1+w)]) for i in range(1,1+h)]\n \nprint(\"\\n\".join(ans))", "h, w = map(int, input().split())\ns = []\nt = []\nfor i in range(h):\n s.append(input())\n\nfor i in range(h):\n t.append([])\n for j in range(w):\n mines = 0\n if s[i][j] == '.':\n if i > 0 and j > 0:\n if s[i - 1][j - 1] == '#':\n mines += 1\n if i < h - 1 and j > 0:\n if s[i + 1][j - 1] == '#':\n mines += 1\n if i > 0 and j < w - 1:\n if s[i - 1][j + 1] == '#':\n mines += 1\n if i < h - 1 and j < w - 1:\n if s[i + 1][j + 1] == '#':\n mines += 1\n if i > 0:\n if s[i - 1][j] == '#':\n mines += 1\n if i < h - 1:\n if s[i + 1][j] == '#':\n mines += 1\n if j > 0:\n if s[i][j - 1] == '#':\n mines += 1\n if j < w - 1:\n if s[i][j + 1] == '#':\n mines += 1\n t[i].append(str(mines))\n else:\n t[i].append('#')\n\nfor i in range(len(t)):\n print(''.join(t[i]))", "H,W=map(int,input().split())\nS=[input() for _ in range(H)]\nans=[[0]*W for _ in range(H)]\nx=(-1,0,1,-1,0,1,-1,0,1)\ny=(1,1,1,0,0,0,-1,-1,-1)\nfor i in range(H):\n for j in range(W):\n if S[i][j]==\".\":\n for k in range(9):\n a=i+y[k]\n b=j+x[k]\n if 0<=a<H and 0<=b<W:\n if S[a][b]==\"#\":\n ans[i][j]+=1\nfor i in range(H):\n for j in range(W):\n if S[i][j]==\"#\":\n print(\"#\",end=\"\")\n else:\n print(ans[i][j],end=\"\")\n print()\n", "from itertools import product as pro\nh, w = list(map(int, input().split()))\ns = [list(input()) for i in range(h)]\nans = [[\"#\"] * len(s[0]) for i in range(len(s))]\nvisited = []\n\ndef dfs(p):\n if p in visited or s[p[0]][p[1]] == \"#\":\n return None\n\n temp = [1 if s[y+p[0]][x+p[1]] == '#' else 0 for (y, x) in pro([-1, 0, 1], [-1, 0, 1]) if 0 <= x+p[1] < len(s[0]) and 0 <= y+p[0] < len(s)]\n s[p[0]][p[1]] = sum(temp)\n\n\nfor i in range(len(s)):\n for j in range(len(s[0])):\n dfs([i, j])\n\n\nfor i in s:\n print((''.join(map(str, i))))\n", "# -*- coding: utf-8 -*-\n\ndef get_count(S, H, W, i, j):\n num = 0\n start_i = start_j = -1\n end_i = end_j = 2\n if W == 1:\n start_i = 0 \n end_i = 1\n else:\n if i == 0:\n start_i = 0\n elif i == W-1:\n end_i = 1\n if H == 1:\n start_j = 0\n end_j = 1\n else:\n if j == 0:\n start_j = 0\n elif j == H-1:\n end_j = 1\n\n for y in range(start_j, end_j, 1):\n for x in range(start_i, end_i, 1):\n if S[j+y][i+x] == \"#\":\n num += 1\n\n return num\n\n\nH,W = list(map(int, input().split()))\nS = []\nfor i in range(H):\n S.append(list(input()))\n\nfor y in range(H):\n for x in range(W):\n if S[y][x] == \".\":\n num = get_count(S, H, W, x, y)\n S[y][x] = str(num)\n\nfor y in range(H):\n print((\"\".join(S[y]))) \n", "from itertools import product\nh, w = map(int, input().split())\nG = [list(input()) for _ in range(h)]\nfor y, x in product(range(h), range(w)):\n if G[y][x]=='.':\n G[y][x]=0\n for dy, dx in product(range(-1, 2), repeat=2):\n ny = y+dy\n nx = x+dx\n if 0 <= ny < h and 0 <= nx < w:\n G[y][x] += G[ny][nx]=='#'\nfor g in G:\n print(*g, sep='')\n", "h,w = list(map(int,input().split()))\nm = [input() for _ in range(h)]\nvx=[0,1,1,1,0,-1,-1,-1]\nvy=[1,1,0,-1,-1,-1,0,1]\nans=[['#']*w for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if m[i][j]=='#':\n ans[i][j]='#'\n continue\n count=0\n for k in range(8):\n ny=vy[k]+i\n nx=vx[k]+j\n if 0<=ny and ny<h and 0<=nx and nx<w:\n if m[ny][nx]=='#':\n count+=1\n ans[i][j]=str(count)\nfor i in ans:\n print((''.join(i)))\n", "h,w = map(int, input().split())\ns = []\nfor _ in range(h):\n\ts.append(list(input()))\n \nif (h == 1)&(w==1):\n if s[0][0] == \".\":\n s[0][0] = \"0\"\n\nelif (h == 1)&(w!=1):\n for j in range(w):\n if j == 0:\n s[0][j] = s[0][j].replace(\".\",str(s[0][j+1].count(\"#\")))\n elif j == w-1:\n s[0][j] = s[0][j].replace(\".\",str(s[0][j-1].count(\"#\")))\n else:\n s[0][j] = s[0][j].replace(\".\",str([s[0][j-1],s[0][j+1]].count(\"#\")))\n\nelif (h != 1)&(w==1):\n for i in range(h):\n if i == 0:\n s[i][0] = s[i][0].replace(\".\",str(s[i+1][0].count(\"#\")))\n elif i == h-1:\n s[i][0] = s[i][0].replace(\".\",str(s[i-1][0].count(\"#\")))\n else:\n s[i][0] = s[i][0].replace(\".\",str([s[i-1][0],s[i+1][0]].count(\"#\")))\nelse:\n for i in range(len(s)):\n if i == 0:\n for j in range(w):\n if j == 0:\n s[i][j] = s[i][j].replace(\".\",str([s[i][j+1],s[i+1][j],s[i+1][j+1]].count(\"#\")))\n elif j == w-1:\n s[i][j] = s[i][j].replace(\".\",str([s[i][j-1],s[i+1][j],s[i+1][j-1]].count(\"#\")))\n else:\n s[i][j] = s[i][j].replace(\".\",str([s[i][j-1],s[i][j+1],s[i+1][j],s[i+1][j+1],s[i+1][j-1]].count(\"#\")))\n elif i == h-1:\n for j in range(w):\n if j == 0:\n s[i][j] = s[i][j].replace(\".\",str([s[i][j+1],s[i-1][j],s[i-1][j+1]].count(\"#\")))\n elif j == w-1:\n s[i][j] = s[i][j].replace(\".\",str([s[i][j-1],s[i-1][j],s[i-1][j-1]].count(\"#\")))\n else:\n s[i][j] = s[i][j].replace(\".\",str([s[i][j-1],s[i][j+1],s[i-1][j],s[i-1][j+1],s[i-1][j-1]].count(\"#\")))\n else:\n for j in range(w):\n if j == 0:\n s[i][j] = s[i][j].replace(\".\",str([s[i][j+1],s[i-1][j],s[i-1][j+1],s[i+1][j],s[i+1][j+1]].count(\"#\")))\n elif j == w-1:\n s[i][j] = s[i][j].replace(\".\",str([s[i][j-1],s[i-1][j],s[i-1][j-1],s[i+1][j],s[i+1][j-1]].count(\"#\")))\n else:\n s[i][j] = s[i][j].replace(\".\",str([s[i][j-1],s[i][j+1],s[i-1][j],s[i-1][j+1],s[i-1][j-1],s[i+1][j],s[i+1][j+1],s[i+1][j-1]].count(\"#\")))\n\nfor k in s:\n print(\"\".join(k))", "import numpy as np\nH, W = map(int, input().split())\nmat = []\nfor h in range(H):\n row = []\n A = list(input())\n for a in A:\n if a == '.':\n row.append(0)\n elif a == '#':\n row.append('#')\n mat.append(row)\n\nfor i in range(H):\n for j in range(W):\n if mat[i][j] != '#':\n for h, w in zip([0,1,1,1,0,-1,-1,-1],[1,1,0,-1,-1,-1,0,1]):\n if i+h >= 0 and i+h < H and j+w >= 0 and j+w < W:\n if mat[i+h][j+w] == '#':\n mat[i][j] += 1\nfor i in mat:\n print(*i, sep='')\n", "import copy\n\nh, w = map(int, input().split())\ns = [input() for _ in range(h)]\n\na = []\nfor i in range(-1, 2):\n for j in range(-1, 2):\n a.append((i, j))\n\nans = [[0]*w for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n ans[i][j] = '#'\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '.':\n cnt = 0\n for y, x in a:\n iy, jx = i+y, j+x\n if 0 <= iy < h and 0 <= jx < w:\n if s[iy][jx] == '#':\n cnt += 1\n ans[i][j] = cnt\nfor i in ans:\n print(''.join(map(str, i)))", "h, w = map(int, input().split())\ns = []\nfor i in range(h):\n s.append(input())\n\np = [[0] * (w + 2) for i in range(h + 2)]\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n p[i][j] += 1\n p[i][j+1] += 1\n p[i][j+2] += 1\n p[i+1][j] += 1\n p[i+1][j+2] += 1\n p[i+2][j] += 1\n p[i+2][j+1] += 1\n p[i+2][j+2] += 1\n\nfor m in range(1, h+1):\n for n in range(1, w+1):\n i = m - 1\n j = n - 1\n if s[i][j] == '#':\n p[m][n] ='#'\n\nfor m in range(1, h+1):\n print(''.join(map(str, p[m][1:w+1])))", "h,w = [int(x) for x in input().split()]\nm = [[\".\"] * (w + 2)]\nfor i in range(h):\n m.append([\".\"] + list(input()) + [\".\"])\nm.append(m[0])\n#print(m,sep = \"\\n\")\n\ndef check(x,y):\n res = 0\n for i in range(3):\n for j in range(3):\n if m[x-1+i][y-1+j] == \"#\":\n res += 1\n return str(res)\n\nfor i in range(1,h+1):\n for j in range(1,w+1):\n if m[i][j] == \".\":\n m[i][j] = check(i,j)\nans = []\nfor i in range(h):\n ans.append(m[i+1][1:w+1])\nfor i in range(h):\n print(\"\".join(ans[i]))", "H,W = map(int,input().split())\ns = []\nfor i in range(H):\n a = list(input())\n s.append(a)\nfor i in range(H):\n for j in range(W):\n count = 0\n if s[i][j] == \".\":\n for k in range(i-1,i+2):\n for l in range(j-1,j+2):\n if (0 <= k <= H-1) and (0 <= l <= W-1) and s[k][l] == \"#\":\n count += 1\n s[i][j] = str(count)\nfor i in range(H):\n print(\"\".join(s[i]))", "H, W = [int(i) for i in input().split()]\nSS = [input() for _ in range(H)]\n\ndef s(y, x):\n if x >= W or x < 0 or y >= H or y < 0:\n return 0\n\n return 1 if SS[y][x] == '#' else 0\n\nfor i in range(H):\n S = SS[i]\n l = []\n for j in range(W):\n c = S[j]\n if c == '.':\n l.append(str(sum([s(i-1, j-1), s(i-1, j), s(i-1, j+1), s(i, j-1), s(i, j+1), s(i+1, j-1), s(i+1, j), s(i+1, j+1)])))\n else:\n l.append('#')\n print((''.join(l)))\n", "def period_to_zero(value:str):\n if value == \".\":\n return 0\n return value\n\nH,W = map(int, input().split())\nS = list()\nS.append([0]*(W+2))\nfor i in range(H):\n s = list()\n s.append(0)\n s.extend(list(map(period_to_zero, list(input()))))\n s.append(0)\n S.append(s)\nS.append([0]*(W+2))\n\nfor i in range(1, len(S)-1):\n s_prev = S[i-1]\n s_current = S[i]\n s_next = S[i+1]\n for j in range(1, len(s_current)-1):\n if s_current[j] != \"#\":\n s_current[j] = (s_prev[j-1:j+2] + s_next[j-1:j+2] + [s_current[j-1], s_current[j+1]]).count(\"#\")\n \nfor i in range(1, len(S)-1):\n s = S[i]\n print(*s[1:len(s)-1],sep=\"\")", "h, w = map(int, input().split())\n\ns = [['.']*(w+2)]+ [list('.'+ input() + '.') for i in range(h)] + [['.']*(w+2)]\na = [[0]*w for i in range(h)]\n\n\nfor i in range(1, h+1):\n for j in range(1,w+1):\n if s[i][j] == '#':\n a[i-1][j-1] = '#'\n else:\n b = [s[i-1][j-1],s[i-1][j], s[i-1][j+1], s[i][j-1], s[i][j+1], s[i+1][j-1], s[i+1][j], s[i+1][j+1]]\n c = b.count('#')\n \n a[i-1][j-1] = c\n\nfor i in range(h):\n a[i] = [str(x) for x in a[i]]\n print(''.join(a[i]))", "h, w = map(int, input().split())\ns = [list(input()) for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if s[i][j] == \".\":\n c = 0\n for x in range(-1, 2):\n for y in range(-1, 2):\n if x == 0 and y == 0:\n continue\n else:\n if 0 <= i+y and 0 <= j+x and i+y < h and j+x < w:\n if s[i+y][j+x] == \"#\":\n c += 1\n s[i][j] = str(c)\nfor a in range(h):\n print(\"\".join(s[a]))", "h,w=map(int,input().split())\na=[input() for i in range(h)]\nb=[]\nc=0\nfor i in range(h):\n for j in range(w):\n if a[i][j]=='#':\n b.append(\"#\")\n else:\n for k in a[max(0,i-1):min(h,i+2)]:\n c+=k[max(0,j-1):min(w,j+2)].count(\"#\")\n b.append(str(c))\n c=0\n \nd=\"\".join(b)\nfor i in range(h):\n print(d[i*w:(i+1)*w])", "h,w=map(int,input().split())\ns=[\".\"*(w+2)]\nfor i in range(h):\n s.append(\".\"+input()+\".\")\ns.append(\".\"*(w+2))\ndx=[-1,0,1,1,1,0,-1,-1]\ndy=[1,1,1,0,-1,-1,-1,0]\nans=[]\nfor i in range(1,h+1):\n wp=\"\"\n for j in range(1,w+1):\n if s[i][j]==\"#\":\n wp+=\"#\"\n continue\n count=0\n for k in range(8):\n if s[i+dy[k]][j+dx[k]]==\"#\":\n count+=1\n wp+=str(count)\n ans.append(wp)\nprint(*ans,sep=\"\\n\")", "h,w = map(int, input().split())\nl = [[] for _ in range(h+2)]\nl[0] = list(\".\"*(w+2))\nl[h+1] = list(\".\"*(w+2))\nfor i in range(1,h+1):\n l[i] = list((\".\" + input() + \".\"))\nfor j in range(1,h+1):\n for k in range(1,w+1):\n c = []\n if l[j][k] == \".\":\n c += [l[j-1][k-1], l[j-1][k], l[j-1][k+1], l[j][k-1], l[j][k+1], l[j+1][k-1], l[j+1][k], l[j+1][k+1]]\n l[j][k] = str(c.count(\"#\"))\nfor i in range(1,h+1):\n ln = l[i][1:w+1]\n s = \"\".join(ln)\n print(s)", "H, W = map(int, input().split())\n\nS = [[\"\" for w in range(W)] for h in range(H)]\n\nfor h in range(H):\n S[h] = list(input())\n\nfor h in range(H):\n for w in range(W):\n if S[h][w] == \"#\":\n continue\n ymin = max(0, h - 1)\n ymax = min(H, h + 2)\n xmin = max(0, w - 1)\n xmax = min(W, w + 2)\n\n S[h][w] = 0\n for y in range(ymin, ymax):\n S[h][w] += S[y][xmin:xmax].count(\"#\")\n\nfor h in range(H):\n for w in range(W):\n print(S[h][w], end=\"\")\n print(\"\")", "import sys, itertools\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 H, W = LI()\n s = [list(S()) for _ in range(H)]\n\n for i, j in itertools.product(list(range(H)), list(range(W))):\n if s[i][j] != '#':\n cnt = 0\n for k, l in itertools.product(list(range(-1, 2)), repeat=2):\n if 0 <= i + k < H and 0 <= j + l < W:\n if s[i+k][j+l] == '#':\n cnt += 1\n s[i][j] = str(cnt)\n\n for i in s:\n print((''.join(i)))\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "H, W = map(int, input().split())\nS = [input() for i in range(H)]\n\nfor h in range(H):\n new_s = ''\n for w in range(W):\n if S[h][w] == '#': \n new_s += '#'\n continue\n count = 0\n ary = [-1, 0, 1]\n for i in ary:\n for j in ary:\n if h+i < 0 or h+i >= H or w+j < 0 or w+j >=W: continue\n if S[h+i][w+j] == '#':\n count += 1\n new_s += str(count)\n \n S[h] = new_s\n\nfor s in S:\n print(s)", "h,w = map(int, input().split())\nsl = []\nbl = [[\"\" for _ in range(w)] for _ in range(h)]\n\nfor i in range(h):\n s = input()\n sl.append(s)\n\ndef scheck(s):\n if s == \"#\":\n return 1\n else:\n return 0\n \ndef check(i,j,sl):\n cnt = 0\n for k in range(-1,2):\n for l in range(-1,2):\n if h > i+k >= 0 and w > j+l >= 0:\n cnt += scheck(sl[i+k][j+l])\n return str(cnt)\n\nfor i in range(h):\n for j in range(w):\n if sl[i][j] == \".\":\n bl[i][j] = check(i,j,sl)\n else:\n bl[i][j] = \"#\"\n\nfor b in bl:\n t = ''.join(b)\n print(t)", "# coding:utf-8\nh, w = map(int, input().split())\ns = [list(input()) for _ in range(h)]\nans = [[0] * w for _ in range(h)]\nx = [-1, 0, 1, -1, 1, -1, 0, 1]\ny = [-1, -1, -1, 0, 0, 1, 1, 1]\n\n# print(s)\n\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n ans[i][j] = '#'\n else:\n for k in range(len(x)):\n if 0 <= (i + x[k]) < h and 0 <= (j + y[k]) < w and s[i + x[k]][j + y[k]] == '#':\n ans[i][j] += 1\n\nfor i in range(h):\n print(*ans[i], sep='')\n", "h,w=map(int,input().split())\nl=[]\nfor i in range(h):\n s=list(input().replace(\".\",\"0\"))\n l.append(s)\nfor i in range(h):\n for j in range(w):\n if l[i][j]==\"#\":\n for x in range(i-1,i+2):\n for y in range(j-1,j+2):\n if 0<=x<=h-1 and 0<=y<=w-1:\n if l[x][y]!=\"#\":\n l[x][y] = str(int(l[x][y]) + 1)\nfor i in range(h):\n print(\"\".join(l[i]))", "H, W = list(map(int, input().split()))\nmasu = [[\".\" for _ in range(W+2)] for _ in range(H+2)]\n\nfor i in range(H):\n masu[i+1][1:W+1] = input()\n \nresult = [[0 for _ in range(W)] for _ in range(H)]\nfor i in range(1, H+1):\n for j in range(1, W+1):\n if masu[i][j] == '#':\n result[i-1][j-1] = '#'\n else:\n x = masu[i-1][j-1:j+2]+masu[i][j-1:j+2]+masu[i+1][j-1:j+2]\n cnt = x.count('#')\n result[i-1][j-1] = cnt\nfor s in result:\n s = list(map(str, s))\n print((\"\".join(s)))\n", "H,W=map(int,input().split())\nf = []\nfor _ in range(H):\n f.append(list(input()))\n\ndx = [ 0, 1, 1, 1, 0,-1, -1, -1]\ndy = [-1, -1, 0, 1, 1, 1, 0, -1]\nfor h in range(H):\n for w in range(W):\n if f[h][w] == '#':\n continue\n cnt = 0\n for i in range(8):\n nw = w + dx[i]\n nh = h + dy[i]\n if nw < 0 or W <= nw or nh < 0 or H <= nh:\n continue\n if f[nh][nw] == '#':\n cnt += 1\n f[h][w] = str(cnt)\n\nfor row in f:\n print(''.join(row))", "h, w = list(map(int, input().split()))\ns = []\nfor i in range(h):\n s.append(list(input()))\n \ndx = [1, 0, -1, 0, 1, -1, 1, -1]\ndy = [0, 1, 0, -1, 1, 1, -1, -1]\n\nfor i in range(h):\n for j in range(w):\n if s[i][j] == \"#\":\n continue\n \n tmp = 0\n for k in range(8):\n ni = i + dx[k]\n nj = j + dy[k]\n \n if ni < 0 or ni >= h:\n continue\n if nj < 0 or nj >= w:\n continue\n if s[ni][nj] == \"#\":\n tmp += 1\n s[i][j] = str(tmp)\n\nfor i in range(h):\n print((\"\".join(s[i])))\n", "H, W = map(int, input().split())\nS = [[a for a in input()] for _ in range(H)]\nd = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]\nfor i in range(H):\n for j in range(W):\n if S[i][j] == \"#\": continue\n c = 0\n for ii, jj in d:\n ni = i + ii\n nj = j + jj\n if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == \"#\":\n c += 1\n S[i][j] = str(c)\nfor s in S:\n print(\"\".join(s))", "h,w=map(int,input().split())\nl=[list(input()) for i in range(h)]\n\nans=[[0]*w for i in range(h)]\n\nfor i in range(h):\n for j in range(w):\n if l[i][j]=='#':\n ans[i][j]='#'\n else:\n for p in range(-1,2):\n for q in range(-1,2):\n if 0<=i+p<h and 0<=j+q<w and l[i+p][j+q]=='#':\n ans[i][j]+=1\n \nfor i in range(h):\n print(*ans[i],sep='')\n", "from collections import Counter\nimport math\nimport statistics\nimport itertools\na,b=map(int,input().split())\n# b=input()\n# c=[]\n# for i in a:\n# c.append(int(i))\n# A,B,C= map(int,input().split())\n# f = list(map(int,input().split()))\ng = [list(map(lambda x: '{}'.format(x), list(input()))) 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\n\nfor i in range(a):\n for k in range(b):\n count=0\n if g[i][k]==\".\":\n if k-1>=0:\n if g[i][k-1]==\"#\":\n count+=1\n if i-1>=0:\n if g[i-1][k]==\"#\":\n count+=1\n if i-1>=0 and k-1>=0:\n if g[i-1][k-1]==\"#\":\n count+=1\n if k+1<=b-1:\n if g[i][k+1]==\"#\":\n count+=1\n if i+1<=a-1:\n if g[i+1][k]==\"#\":\n count+=1\n if i+1<=a-1 and k+1<=b-1:\n if g[i+1][k+1]==\"#\":\n count+=1\n if i-1>=0 and k+1<=b-1:\n if g[i-1][k+1]==\"#\":\n count+=1\n if i+1<=a-1 and k-1>=0:\n if g[i+1][k-1]==\"#\":\n count+=1\n g[i][k]=str(count)\n\n\nfor i in g:\n print(\"\".join(i))", "H,W=list(map(int,input().split()))\nl=[list(input()) for i in range(H)]\nans_l=[[0]*W for i in range(H)]\nfor i in range(H):\n for j in range(W):\n if l[i][j] == \".\":\n tmp=0\n for x in range(max(0,j-1),min(W-1,j+1)+1):\n for y in range(max(0,i-1),min(H-1,i+1)+1):\n if l[y][x]==\"#\":\n tmp+=1\n ans_l[i][j]=str(tmp)\n else:\n ans_l[i][j]=\"#\"\nfor i in ans_l:\n print(*i,sep=\"\")", "h, w = list(map(int, input().split()))\ntable = []\nfor i in range(h):\n line = input()\n table.append(line)\n\nfor i in range(h):\n line = \"\"\n for j in range(w):\n hs = max(0, i - 1)\n he = min(h - 1, i + 1)\n ws = max(0, j - 1)\n we = min(w - 1, j + 1)\n counter = 0\n for hi in range(hs, he + 1):\n for wi in range(ws, we + 1):\n if table[hi][wi] == \"#\":\n counter += 1\n if table[i][j] == \"#\":\n line += \"#\"\n else:\n line += str(counter)\n print(line)\n", "h, w = (int(x) for x in input().split())\ns = []\nans = []\nrev = \"\"\nfor row in range(1, h+1):\n for col, t in enumerate(input()):\n s.append([(row,col+1),t])\n\nfor index, factor in enumerate(s):\n count =0\n if factor[1] != \"#\":\n if w == 1:\n for point in [index-1, index+1]:\n if 0 <= point and point < len(s) and s[point][1] == \"#\":\n count += 1\n elif (index+1)%w == 1:\n for point in [index +1,index -w+1, index -w, index +w, index +w+1]:\n if 0 <= point and point < len(s) and s[point][1] == \"#\":\n count += 1\n elif (index+1)%w == 0:\n for point in [index -1,index -w, index -w-1, index +w-1, index +w]:\n if 0 <= point and point < len(s) and s[point][1] == \"#\":\n count += 1\n else:\n for point in [index -1, index +1,index -w+1, index -w, index -w-1, index +w-1, index +w, index +w+1]:\n if 0 <= point and point < len(s) and s[point][1] == \"#\":\n count += 1\n ans.append(count)\n else:\n ans.append(\"#\")\n\nwhile(ans != []):\n for num in range(w):\n rev += str(ans[0])\n del ans[0]\n rev += \"\\n\"\n\nprint(rev)", "h,w = list(map(int, input().split()))\ns = list()\nt = list()\na = [0 for i in range(w+2)]\ns.append(a)\nfor i in range(h):\n b = str(input())\n c = list(('0'+b+'0').replace('.','0').replace('#','1'))\n d = list(map(int, c))\n s.append(d)\n t.append(b)\ns.append(a)\n\nfor j in range(1,h+1):\n for k in range(1,w+1):\n if s[j][k] == 0:\n cnt = 0\n cnt = (s[j-1][k-1]+s[j-1][k]+s[j-1][k+1]) + (s[j][k-1]+s[j][k+1]) + (s[j+1][k-1]+s[j+1][k]+s[j+1][k+1])\n t[j-1] = t[j-1].replace('.', str(cnt), 1)\n \n else:\n continue\nfor i in range(h):\n print((t[i]))\n", "dx = [1, 0, -1, 0, 1, -1, -1, 1]\ndy = [0, 1, 0, -1, 1, 1, -1, -1]\n\n# \u5165\u529b\nH, W = map(int, input().split())\nS = [input() for _ in range(H)]\n\n# Python3 \u3067\u306f str \u578b\u306e\u8981\u7d20\u306e\u66f8\u304d\u63db\u3048\u306f\u3067\u304d\u306a\u3044\n# \u7b54\u3048\u3092\u683c\u7d0d\u3059\u308b\u4e8c\u6b21\u5143\u914d\u5217\u3092\u5225\u9014\u7528\u610f\u3059\u308b ('.' \u306e\u3068\u3053\u308d\u306f 0)\nresult = [[0 if v == '.' else '#' for v in row] for row in S]\n\n# \u5404\u30de\u30b9 (i, j) \u306b\u3064\u3044\u3066\u9806\u306b\u51e6\u7406\nfor i in range(H):\n for j in range(W):\n if S[i][j] != '.':\n continue\n for d in range(8):\n ni = i + dx[d]\n nj = j + dy[d]\n if ni < 0 or ni >= H or nj < 0 or nj >= W:\n continue\n if S[ni][nj] == '#':\n result[i][j] += 1\n\nfor row in result:\n print(*row, sep = '')", "H, W = map(int,input().split())\n\nmas = [list(map(str,input())) for _ in range(H)]\nmas2 = [[0 for _ in range(W+2)] for __ in range(H+2)]\n\nfor i in range(1,H+1):\n for j in range(1,W+1):\n if mas[i-1][j-1] == '#':\n mas2[i][j] = -9\n mas2[i+1][j] += 1\n mas2[i+1][j-1] += 1\n mas2[i][j-1] += 1\n mas2[i-1][j-1] += 1\n mas2[i-1][j] += 1\n mas2[i-1][j+1] += 1\n mas2[i][j+1] += 1\n mas2[i+1][j+1] += 1\n\nmas3 = [l[1:-1] for l in mas2[1:-1]]\n\nfor k in range(H):\n print(*[\"#\" if i < 0 else i for i in mas3[k]],sep=\"\")", "H, W = (int(x) for x in input().split())\nS = [input() for _ in range(H)]\nans = [''] * H \nfor i in range(H):\n for j in range(W):\n if S[i][j] == '#':\n ans[i] += '#'\n continue\n bom = 0\n for k in range(3):\n for l in range(3):\n if 0 <= i-1+k < H and 0 <= j-1+l < W:\n if S[i-1+k][j-1+l] == '#':\n bom += 1\n ans[i] += str(bom)\nfor s in ans:\n print(s)\n \n", "m, n = map(int,input().split())\n\ndx = [1,1,0,-1,-1,-1,0,1]\ndy = [0,1,1,1,0,-1,-1,-1]\n\nS = [input() for i in range(m)]\n\nfor i in range(m):\n for j in range(n):\n num = 0\n if not S[i][j] == '#' :\n for d in range(8):\n nx = i + dx[d]\n ny = j + dy[d]\n if nx < 0 or nx >= m :\n continue\n if ny < 0 or ny >= n :\n continue\n if S[nx][ny] == '#' :\n num += 1\n A = list(S[i])\n A[j] = str(num)\n S[i] = \"\".join(A)\n \nfor i in range(m):\n print(S[i])", "H, W = map(int, input().split())\nm = [] \n\nfor i in range(H):\n s=input()\n t = []\n for i in s:\n t.append(1 if i == \"#\" else 0)\n m.append(t)\n \nfor i in range(H):\n for j in range(W):\n if m[i][j] == 1:\n print(\"#\", end=\"\")\n continue\n count = 0\n if i !=0 :\n count += m[i-1][j]\n if j != 0:\n count += m[i-1][j-1]\n if j != W-1:\n count += m[i-1][j+1]\n if i != H-1:\n count += m[i+1][j]\n if j != 0:\n count += m[i+1][j-1]\n if j != W-1:\n count += m[i+1][j+1]\n if j != 0:\n count += m[i][j-1]\n if j != W-1:\n count += m[i][j+1]\n print(count, end=\"\")\n print()\n\n \n ", "X,Y = map(int,input().split())\nF = list(list(input()) for _ in range(X))\nDX = [-1,-1,-1,0,0,1,1,1]\nDY = [-1,0,1,-1,1,-1,0,1]\n\nfor i in range(X):\n for j in range(Y):\n if F[i][j] == '.':\n cnt = 0\n for k in range(8):\n x = i + DX[k]\n y = j + DY[k]\n if 0 <= x < X and 0 <= y < Y and F[x][y] == '#':\n cnt += 1\n F[i][j] = str(cnt)\n \nfor f in F:\n print(''.join(f))", "H, W = map(int, input().split())\nL = ['.' + input() + '.' for _ in range(H)]\nL = ['.' * (W + 2)] + L + ['.' * (W + 2)]\nA = []\nfor i in range(1, H + 1):\n S = \"\"\n for j in range(1, W + 1):\n if L[i][j] == '.':\n t = [L[i-1][j-1], L[i-1][j], L[i-1][j+1], L[i][j+1], L[i+1][j+1], L[i+1][j], L[i+1][j-1], L[i][j-1]]\n S += str(t.count('#'))\n else:\n S += '#'\n A.append(S)\n[print(i) for i in A]", "import typing\nfrom typing import List, Counter\nfrom itertools import product\nclass Grid:\n def __init__(self, field: List[str]):\n self.setField(field)\n \n def setField(self, field) -> None:\n self.column: int = len(field)\n self.row: int = len(field[0])\n self.field: List[List[str]] = [list(line) for line in field]\n\n def searchBomb(self) -> None:\n for i,j in product(range(self.column), range(self.row)):\n conn = tuple((i-1+k//3, j-1+k%3) for k in range(9))\n conn = tuple((x,y) for x,y in conn if 0<=x<self.column and 0<=y<self.row)\n if self.field[i][j] == '.':\n self.field[i][j] = str(Counter(self.field[x][y] for x,y in conn)['#'])\n \n def print(self) -> None:\n for line in self.field:\n print(''.join(line))\n\ndef main():\n with open(0) as f:\n H, W = map(int, f.readline().split())\n S = [line.strip() for line in f.readlines()]\n grid = Grid(S)\n grid.searchBomb()\n grid.print()\n\ndef __starting_point():\n main()\n__starting_point()", "h,w = map(int,input().split())\ns = [list(input()) for i in range(h)]\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '.':\n m = 0\n if i-1 >= 0 and j-1 >= 0:\n if s[i-1][j-1] == '#':\n m += 1\n if i-1 >= 0:\n if s[i-1][j] == '#':\n m += 1\n if i-1 >= 0 and j+1 < w:\n if s[i-1][j+1] == '#':\n m += 1\n if j-1 >= 0:\n if s[i][j-1] == '#':\n m += 1\n if j+1 < w:\n if s[i][j+1] == '#':\n m += 1\n if i+1 < h and j-1 >= 0:\n if s[i+1][j-1] == '#':\n m += 1\n if i+1 < h:\n if s[i+1][j] == '#':\n m += 1\n if i+1 < h and j+1 < w:\n if s[i+1][j+1] == '#':\n m += 1\n s[i][j] = str(m)\nfor i in range(h):\n z = list(s[i])\n print(''.join(z))", "h,w = map(int,input().split())\ngrid = [\"\"]*h\nfor i in range(h):\n grid[i] = list(input())\n# print(grid)\nsearch = [(row,col) for row in range(-1,2) for col in range(-1,2) if not(row == 0 and col == 0)]\n# print(search)\n\nfor i in range(h):\n ans = \"\"\n for j in range(w):\n if(grid[i][j] == \".\"):\n bomb = 0\n for k in range(8):\n row,col = search[k]\n if(0<=i+row<h and 0<=j+col<w):\n if(grid[i+row][j+col] == \"#\"):\n bomb += 1\n grid[i][j] = bomb\n ans+=str(grid[i][j])\n print(ans)", "l = [int(c) for c in input().split()]\nH = l[0]\nW = l[1]\nS = [input() for c in range(H)]\n\nfor i in range(H):\n for j in range(W):\n if S[i][j]==\".\":\n cnt = 0\n for k in range(3):\n for m in range(3):\n if 0 <= i-1+k and i-1+k <= H-1 and 0 <= j-1+m and j-1+m <= W-1:\n if S[i-1+k][j-1+m] == \"#\":\n cnt+=1\n S[i]=S[i][:j]+str(cnt)+S[i][j+1:]\n print(S[i])", "import numpy as np\n\nh,w = map(int,(input().split()))\ns = [list(map(str,input())) for i in range(h)]\nl = [[0]*(w+2) for i in range(h+2)]\n\n\ndef addFlag(i,j):\n for x in range(3):\n for y in range(3):\n if l[i+x][j+y] != '#':\n l[i+x][j+y] += 1\n \nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n l[i+1][j+1] = '#'\n addFlag(i,j)\n\nl = np.delete(l,[0,h+1],0)\nl = np.delete(l,[0,w+1],1)\n\n\nfor i in l:\n ans = ''.join(map(str,i))\n print(ans)", "h, w = map(int, input().split())\na = [input() for i in range(h)]\nfor i in range(h):\n b = \"\"\n for j in range(w):\n if a[i][j] == \"#\":\n b += \"#\"\n else:\n b += str(sum(k[max(0, j-1):min(w, j+2)].count(\"#\") for k in a[max(0, i-1):min(h, i+2)]))\n print(b)", "H,W=map(int, input().split())\nS=[list(input()) for i in range(H)]\n\ndh = [0,1,-1,0,1,-1,-1,1]\ndw = [1,0,0,-1,1,1,-1,-1]\n\nfor h in range(H):\n for w in range(W):\n if S[h][w] == \"#\":\n continue\n else:\n cnt = 0\n for k in range(8):\n next_h = h+dh[k]\n next_w = w+dw[k]\n if not(0<= next_h <= H-1) or not(0<= next_w <= W-1):\n continue\n elif S[next_h][next_w] == \"#\":\n cnt += 1\n S[h][w] = str(cnt)\n \nfor s in S:\n print(\"\".join(s))", "h,w=list(map(int,input().split()))\ns=[input() for i in range(h)]\nss=[[0 for _ in range(w+2)] for _ in range(h+2)]\nfor j in range(w):\n for i in range(h):\n ss[i+1][j+1]=s[i][j]\ns=[[0 for _ in range(w)] for _ in range(h)]\nfor j in range(1,w+1):\n for i in range(1,h+1):\n for a in range(-1,2):\n for b in range(-1,2):\n if a==0 and b ==0:\n continue\n if ss[i+a][j+b]=='#':\n s[i-1][j-1]+=1\nfor j in range(w):\n for i in range(h):\n if ss[i+1][j+1]=='#':\n s[i][j]='#'\nfor i,d in enumerate(s):\n d=list(map(str,d))\n print((''.join(d)))\n", "def solve():\n H, W = list(map(int, input().split()))\n S = [input() for i in range(H)]\n\n for i in range(H):\n S[i] = list(S[i])\n\n for i in range(H):\n for k in range(W):\n\n if S[i][k]!=\"#\":\n\n c = 0; #counter\n\n if i>0 and k>0 and S[i-1][k-1]==\"#\": # upper left\n c += 1\n\n if i>0 and S[i-1][k]==\"#\": # right above\n c += 1\n\n if i>0 and k<W-1 and S[i-1][k+1]==\"#\": # upper right\n c+= 1\n\n if k>0 and S[i][k-1]==\"#\": # left\n c += 1\n \n if k<W-1 and S[i][k+1]==\"#\": # right\n c += 1\n\n if i<H-1 and k>0 and S[i+1][k-1]==\"#\": # lower left\n c += 1\n\n if i<H-1 and S[i+1][k]==\"#\": # right under\n c += 1\n\n if i<H-1 and k<W-1 and S[i+1][k+1]==\"#\": # lower right\n c += 1\n\n S[i][k] = str(c)\n\n for i in range(H):\n print((\"\".join(S[i])))\n\n\ndef __starting_point():\n solve()\n\n\n__starting_point()", "import copy\n\nh, w = list(map(int, input().split()))\ns = [list(input()) for _ in range(h)]\n\ndir = [(i, j) for i in range(-1, 2) for j in range(-1, 2)]\nans = copy.deepcopy(s)\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '.':\n cnt = 0\n for y, x in dir:\n iy, jx = i+y, j+x\n if 0 <= iy < h and 0 <= jx < w:\n if s[iy][jx] == '#':\n cnt += 1\n ans[i][j] = cnt\nfor i in ans:\n print((''.join(map(str, i))))\n", "#!/usr/local/bin/python3\n# https://atcoder.jp/contests/abc075/tasks/abc075_b\n\nH, W = map(int, input().split())\nS = [list(input()) for _ in range(H)]\n\n\ndef check(S, i, j):\n if S[i][j] == '#':\n return '#'\n\n num = 0\n for _i in range(max(0, i-1), min(H, i+2)):\n for _j in range(max(0, j-1), min(W, j+2)):\n if S[_i][_j] == '#':\n num += 1\n return str(num)\n\n\nfor i in range(H):\n for j in range(W):\n S[i][j] = check(S, i, j)\n\nfor i in range(H):\n for j in range(W):\n print(S[i][j], end=\"\")\n print()\n", "h, w = map(int, input().split())\ns = []\nfor _ in range(h):\n s.append(list(input()))\nfor i in range(h):\n for j in range(w):\n a = 0\n if s[i][j] == '.':\n for k in range(i - 1, i + 2):\n for l in range(j - 1, j + 2):\n if (0 <= k and k <= h - 1) and (0 <= l and l <= w - 1) and s[k][l] == '#':\n a += 1\n s[i][j] = str(a)\nfor m in range(h):\n print(''.join(s[m]))", "h,w = map(int,input().split())\ns = [[0]*(w+2)]\nfor i in range(h):\n s += [[0]+list(input())+[0]]\ns += [[0]*(w+2)]\n\n\nfor i in range(1,h+1):\n for j in range(1,w+1):\n cnt = 0\n if s[i][j]== \"#\":\n continue\n if s[i][j+1]==\"#\":\n cnt += 1\n if s[i][j-1] == \"#\":\n cnt += 1\n if s[i-1][j] == \"#\":\n cnt += 1\n if s[i-1][j+1] == \"#\":\n cnt += 1\n if s[i-1][j-1] == \"#\":\n cnt += 1\n if s[i+1][j] == \"#\":\n cnt += 1\n if s[i+1][j-1] == \"#\":\n cnt += 1\n if s[i+1][j+1] == \"#\":\n cnt += 1\n s[i][j] = cnt\n \nfor k in range(1,h+1):\n print(*s[k][1:-1],sep=\"\")", "import numpy as np\n\n\ndef get_num_bomb(arr, i, j):\n \"\"\"\n docstring\n \"\"\"\n temp_arr = np.full([arr.shape[0] + 2, arr.shape[1] + 2], False)\n temp_arr[1:1 + arr.shape[0], 1:1 + arr.shape[1]] = arr[:, :]\n slice = temp_arr[i:i + 3, j:j + 3]\n return slice.sum()\n\n\nh, w = tuple([int(x) for x in input().split(\" \")])\narr = []\nret_arr = [[0] * w for i in range(h)]\nfor i in range(h):\n x = list([(False if x == \".\" else True) for x in input()])\n # x = list(map(lambda x: x, input()))\n arr.append(x)\narr = np.array(arr)\n# print(arr)\nfor i in range(h):\n for j in range(w):\n if arr[i, j] == True:\n ret_arr[i][j] = \"#\"\n else:\n ret_arr[i][j] = get_num_bomb(arr, i, j)\nfor lis in ret_arr:\n print((\"\".join(list([str(x) for x in lis]))))\n", "h,w = list(map(int, input().split()))\nS = [input() for _ in range(h)]\nS = ['.' + s + '.' for s in S]\nS = ['.'*(w+2)] + S + ['.'*(w+2)]\nfor i in range(1, h+1):\n l = ''\n for j in range(1, w+1):\n if S[i][j] == '#':\n l += '#'\n else:\n l += str([S[i-1][j-1], S[i-1][j],S[i-1][j+1],S[i][j+1],S[i+1][j+1],S[i+1][j],S[i+1][j-1],S[i][j-1]].count('#'))\n print(l)\n\n\n\n\n", "H, W = map(int, input().split())\nx = [list(map(str, list(input()))) for l in range(H)]\n\n#\u4e21\u7aef\u306b\u30c9\u30c3\u30c8\u3092\u8ffd\u52a0\nfor i in range(len(x)):\n x[i].insert(0, \".\")\n x[i].append(\".\")\n#\u6700\u4e0a\u90e8\u3068\u6700\u4e0b\u90e8\u306e\u884c\u306b\u30c9\u30c3\u30c8\u3092\u8ffd\u52a0\nx.insert(0, [\".\"]*(W+2))\nx.append([\".\"]*(W+2))\n\n#3*3\u21925*5 from[1][1] to[3][3] to[H][W]\ntmp = 0\nfor i in range(1, H+1):\n for j in range(1, W+1):\n if x[i][j] == \"#\":\n x[i][j] = \"#\"\n continue\n if x[i-1][j-1] == \"#\":\n tmp += 1\n if x[i-1][j] == \"#\":\n tmp += 1\n if x[i-1][j+1] == \"#\":\n tmp += 1\n if x[i][j-1] == \"#\":\n tmp += 1\n if x[i][j+1] == \"#\":\n tmp += 1\n if x[i+1][j-1] == \"#\":\n tmp += 1\n if x[i+1][j] == \"#\":\n tmp += 1\n if x[i+1][j+1] == \"#\":\n tmp += 1\n x[i][j] = str(tmp)\n tmp = 0\n#\u6700\u4e0a\u90e8\u3068\u6700\u4e0b\u90e8\u306e\u884c\u306e\u30c9\u30c3\u30c8\u3092\u524a\u9664\ndel x[0]\ndel x[-1]\n#\u4e21\u7aef\u306e\u30c9\u30c3\u30c8\u3092\u524a\u9664\nfor i in range(len(x)):\n del x[i][0]\n del x[i][-1]\n\nfor i in range(len(x)):\n print(''.join(x[i]))", "import sys\n\ninput = sys.stdin.readline\nH, W = map(int, input().split())\nS = [(input()) for _ in range(H)]\nT = [[0 for _ in range(W)] for _ in range(H)]\n\nfor h in range(H):\n for w in range(W):\n for i in range(h - 1, h + 2):\n for j in range(w - 1, w + 2):\n if i < 0 or j < 0 or i >= H or j >= W:\n continue\n else:\n if S[h][w] == '#':\n T[h][w] = -1\n elif S[i][j] == '#':\n T[h][w] += 1\n\nfor t in T:\n print((''.join(map(str, t))).replace('-1', '#'))", "h, w = list(map(int, input().split()))\nans = [[0 for _ in range(w+2)] for _ in range(h+2)]\n\nfor i in range(h):\n S = input()\n for j, s in enumerate(S):\n if s == \"#\":\n ans[i+1][j+1] = \"#\"\n if ans[i][j+1] != \"#\":\n ans[i][j+1] += 1\n if ans[i+1][j] != \"#\":\n ans[i+1][j] += 1\n if ans[i][j] != \"#\":\n ans[i][j] += 1\n if ans[i+1][j + 2] != \"#\":\n ans[i+1][j + 2] += 1\n if ans[i][j + 2] != \"#\":\n ans[i][j + 2] += 1\n if ans[i + 2][j+1] != \"#\":\n ans[i + 2][j+1] += 1\n if ans[i + 2][j + 2] != \"#\":\n ans[i + 2][j + 2] += 1\n if ans[i + 2][j] != \"#\":\n ans[i + 2][j] += 1\n\nfor a in ans[1:-1]:\n print((\"\".join(map(str, a))[1:-1]))\n", "#6 B - Minesweeper\nH,W = map(int,input().split())\nS = [list(input()) for _ in range(H)]\n\ndh = [0,1,0,-1,1,-1,1,-1]\ndw = [1,0,-1,0,1,-1,-1,1]\n\nfor h in range(H):\n for w in range(W):\n #\u30de\u30b9(h,w)\u306b\u3064\u3044\u3066\n if S[h][w] == '#':\n continue\n else:\n cnt= 0\n for v in range(8):\n nxt_h = h + dh[v]\n nxt_w = w + dw[v]\n if not(-1<nxt_h<H) or not(-1<nxt_w<W):\n continue\n elif S[nxt_h][nxt_w] == '#':\n cnt += 1\n S[h][w] = str(cnt)\nif H==1 and W==1:\n print(0)\nelse:\n for i in S:\n print(''.join(i))", "H, W = list(map(int, input().split()))\ngrid = []\n\nfor _ in range(H):\n grid.append([s for s in input()])\n\nfor i in range(H):\n for j in range(W):\n r_ij = grid[i][j]\n if r_ij == \"#\":\n continue\n c_ij = 0\n if 1<=i<=H-1 and 1<=j<=W-1:\n if grid[i-1][j-1] == \"#\":\n c_ij += 1\n if 1<=i<=H-1 and 0<=j<=W-1:\n if grid[i-1][j] == \"#\":\n c_ij += 1\n if 1<=i<=H-1 and 0<=j<=W-2:\n if grid[i-1][j+1] == \"#\":\n c_ij += 1\n if 0<=i<=H-1 and 1<=j<=W-1:\n if grid[i][j-1] == \"#\":\n c_ij += 1\n if 0<=i<=H-1 and 0<=j<=W-2:\n if grid[i][j+1] == \"#\":\n c_ij += 1\n if 0<=i<=H-2 and 1<=j<=W-1:\n if grid[i+1][j-1] == \"#\":\n c_ij += 1\n if 0<=i<=H-2 and 0<=j<=W-1:\n if grid[i+1][j] == \"#\":\n c_ij += 1\n if 0<=i<=H-2 and 0<=j<=W-2:\n if grid[i+1][j+1] == \"#\":\n c_ij += 1\n grid[i][j] = str(c_ij)\n\nstr_list = [\"\".join(s) for s in grid]\nfor s in str_list:\n print(s)\n", "h, w = map(int, input().split())\ns = [list(input()) for _ in range(h)]\n# ans = [[0]*w for _ in range(h)]\n\nimport copy\n\ndir = [(i, j) for i in range(-1, 2) for j in range(-1, 2)]\nans = copy.deepcopy(s)\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '.':\n cnt = 0\n for y, x in dir:\n iy, jx = i+y, j+x\n if 0 <= iy < h and 0 <= jx < w:\n if s[iy][jx] == '#':\n cnt += 1\n ans[i][j] = cnt\n\n\n\n\nfor i in range(h):\n moji = map(str,ans[i])\n print(\"\".join(moji))", "h, w = map(int, input().split())\n\nsl = [list(input()) for _ in range(h)]\nans = [[0]*(w+2) for _ in range(h+2)]\n# print(sl,ans)\n\nfor i in range(h):\n for j in range(w):\n row = i+1\n col = j+1\n # print(sl[i][j])\n if sl[i][j] == '#':\n ans[row][col] = '#'\n if ans[row-1][col] != '#':ans[row-1][col] += 1\n if ans[row+1][col] != '#':ans[row+1][col] += 1\n if ans[row][col-1] != '#':ans[row][col-1] += 1\n if ans[row][col+1] != '#':ans[row][col+1] += 1\n if ans[row-1][col-1] != '#':ans[row-1][col-1] += 1\n if ans[row-1][col+1] != '#':ans[row-1][col+1] += 1\n if ans[row+1][col-1] != '#':ans[row+1][col-1] += 1\n if ans[row+1][col+1] != '#':ans[row+1][col+1] += 1\n\n\n\nfor i in range(h+2):\n if i != 0 and i != h+1:\n print(*ans[i][1:-1], sep='')\n", "import sys\n\nH, W = map(int, input().split())\nl = []\nfor i in range(H):\n l.append(list(input()))\n\nfor i in range(H):\n for j in range(W):\n c=0\n \n if l[i][j]==\"#\":\n pass\n \n else:\n # \u5de6\u4e0a\n if 0<i and 0<j and l[i-1][j-1]=='#':\n c+=1\n # \u4e0a\n if 0<i and l[i-1][j]=='#':\n c+=1\n # \u53f3\u4e0a\n if 0<i and j<W-1 and l[i-1][j+1]=='#':\n c+=1\n # \u5de6\n if 0<j and l[i][j-1]=='#':\n c+=1\n # \u53f3\n if j<W-1 and l[i][j+1]=='#':\n c+=1\n # \u5de6\u4e0b\n if i<H-1 and 0<j and l[i+1][j-1]=='#':\n c+=1\n # \u4e0b\n if i<H-1 and l[i+1][j]=='#':\n c+=1\n # \u53f3\u4e0b\n if i<H-1 and j<W-1 and l[i+1][j+1]=='#':\n c+=1\n \n # \u5730\u96f7\u96a3\u63a5\u6570\u3092\u8a18\u8f09\n l[i][j]=str(c)\n\n# \u51fa\u529b\nfor i in range(H):\n print(''.join(l[i]))", "import itertools\nH,W=map(int,input().split())\nS=[list(input()) for _ in range(H)]\n\nfor x,y in itertools.product(range(W),range(H)):\n if S[y][x]==\".\":\n res=0\n for i,j in itertools.product(range(-1,2),range(-1,2)):\n if 0<=x+i and x+i<W and 0<=y+j and y+j<H:\n if S[y+j][x+i]==\"#\":\n res+=1\n \n S[y][x]=res\n\nfor j in range(H):\n L=[str(a) for a in S[j]]\n print(''.join(L))", "h, w = list(map(int, input().split()))\nfield = [list(input()) for _ in range(h)]\ndx = [1, 0, -1, 0, 1, -1, -1, 1]\ndy = [0, 1, 0, -1, 1, 1, -1, -1]\nfor i in range(h):\n for j in range(w):\n if field[i][j] == \"#\":\n continue\n num = 0\n for k in range(8):\n ni = i + dy[k]\n nj = j + dx[k]\n if ni < 0 or h <= ni:\n continue\n if nj < 0 or w <= nj:\n continue\n if field[ni][nj] == \"#\":\n num += 1\n field[i][j] = str(num)\nfor out in field:\n print((\"\".join(out)))\n", "dx = [1, 0, -1, 0, 1, -1, -1, 1]\ndy = [0, 1, 0, -1, 1, 1, -1, -1]\n\n# \u5165\u529b\nH, W = map(int, input().split())\nS = [input() for _ in range(H)]\n\n# \u5404\u30de\u30b9 (i, j) \u306b\u3064\u3044\u3066\u9806\u306b\u51e6\u7406\nfor i in range(H):\n for j in range(W):\n if S[i][j] != '.':\n continue\n counter = 0\n for d in range(8):\n ni = i + dx[d]\n nj = j + dy[d]\n if ni < 0 or ni >= H or nj < 0 or nj >= W:\n continue\n if S[ni][nj] == '#':\n counter += 1\n S[i] = S[i].replace('.', str(counter), 1)\n\nfor row in S:\n print(row)", "h,w=map(int,input().split())\ns=[list(input()) for i in range(h)]\n\ndata=[[0]*w for i in range(h)]\nfor i in range(h):\n for j in range(w):\n if s[i][j]=='#':\n data[i][j]='#'\n else:\n for p in range(-1,2):\n for q in range(-1,2):\n if 0<=i+p<h and 0<=j+q<w and s[i+p][j+q]=='#':\n data[i][j]+=1\nfor i in range(h):\n print(*data[i],sep='')", "# 0: \u4e0b\u30011: \u53f3\u30012: \u4e0a\u30013: \u5de6\u30014: \u53f3\u4e0b\u30015: \u53f3\u4e0a\u30016: \u5de6\u4e0a\u30017: \u5de6\u4e0b\ndx = [1, 0, -1, 0, 1, -1, -1, 1]\ndy = [0, 1, 0, -1, 1, 1, -1, -1]\n\n# \u5165\u529b\nH, W = map(int, input().split())\nS = [input() for _ in range(H)]\n\n# Python3 \u3067\u306f str \u578b\u306e\u8981\u7d20\u306e\u66f8\u304d\u63db\u3048\u306f\u3067\u304d\u306a\u3044\n# \u7b54\u3048\u3092\u683c\u7d0d\u3059\u308b\u4e8c\u6b21\u5143\u914d\u5217\u3092\u5225\u9014\u7528\u610f\u3059\u308b ('.' \u306e\u3068\u3053\u308d\u306f 0 \u3068\u3059\u308b)\nresult = [[0 if v == '.' else '#' for v in row] for row in S]\n\n# \u5404\u30de\u30b9 (i, j) \u306b\u3064\u3044\u3066\u9806\u306b\u51e6\u7406\nfor i in range(H):\n for j in range(W):\n if S[i][j] != '.':\n continue\n for d in range(8):\n ni = i + dx[d]\n nj = j + dy[d]\n if ni < 0 or ni >= H or nj < 0 or nj >= W:\n continue\n if S[ni][nj] == '#':\n result[i][j] += 1\n\nfor row in result:\n # \u51fa\u529b\u5f62\u5f0f\u306b\u5408\u308f\u305b\u3066\u51fa\u529b\n print(*row, sep = '')", "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n ans = []\n b = \"#\"\n h, w = map(int, input().split())\n s = [input().rstrip('\\n') for _ in range(h)]\n for y in range(h):\n ans.append([])\n for x in range(w):\n if s[y][x] == b:\n ans[y].append(b)\n else:\n ans[y].append(0)\n for y in range(h):\n for x in range(w):\n if s[y][x] == b:\n if y > 0 and x > 0 and ans[y-1][x-1] != b:\n ans[y-1][x-1] += 1\n if y > 0 and ans[y-1][x] != b:\n ans[y-1][x] += 1\n if y > 0 and x < w - 1 and ans[y-1][x+1] != b:\n ans[y-1][x+1] += 1\n if x > 0 and ans[y][x-1] != b:\n ans[y][x-1] += 1\n if x < w - 1 and ans[y][x+1] != b:\n ans[y][x+1] += 1\n if y < h - 1 and x > 0 and ans[y+1][x-1] != b:\n ans[y+1][x-1] += 1\n if y < h - 1 and ans[y+1][x] != b:\n ans[y+1][x] += 1\n if y < h - 1 and x < w - 1 and ans[y+1][x+1] != b:\n ans[y+1][x+1] += 1\n for y in range(h):\n for x in range(w):\n if ans[y][x] == 0 and s[y][x] == b:\n ans[y][x] = \"#\"\n else:\n ans[y][x] = str(ans[y][x])\n print(''.join(ans[y]))\n\ndef __starting_point():\n main()\n__starting_point()", "H,W = list(map(int,input().split()))\ns = []\nfor i in range(H):\n a = list(input())\n s.append(a)\nfor i in range(H):\n for j in range(W):\n count = 0\n if s[i][j] == \".\":\n for k in range(i-1,i+2):\n for l in range(j-1,j+2):\n if (0 <= k <= H-1) and (0 <= l <= W-1) and s[k][l] == \"#\":\n count += 1\n s[i][j] = str(count)\nfor i in range(H):\n print((\"\".join(s[i])))\n", "lst = input().split()\nH = int(lst[0])\nW = int(lst[1])\n\nfield = []\nfor i in range(H):\n l = []\n s = input()\n for j in range(W):\n l.append(s[j])\n field.append(l)\n\ndef count(x, y):\n result = 0\n for P in [[x-1, y-1], [x, y-1], [x+1, y-1], [x-1, y], [x+1, y], [x-1, y+1], [x, y+1], [x+1, y+1]]:\n try:\n if (0 <= P[0]) and (0 <= P[1]) and (field[P[1]][P[0]] == '#'):\n result += 1\n except:\n pass\n return result\n\nfor i in range(H):\n for j in range(W):\n if field[i][j] == '.':\n field[i][j] = str(count(j, i))\n\ndef list2str(L):\n result = ''\n for t in L:\n result += t\n return result\n\nfor I in field:\n print(list2str(I))", "h,w=map(int,input().split())\ns=[list(input()) for i in range(h)]\n\ndx=[-1,0,1,-1,1,-1,0,1]\ndy=[-1,-1,-1,0,0,1,1,1]\n\nresult = [[0]*w for _ in range(h)]\nfor y in range(h):\n for x in range(w):\n if s[y][x] == '#':\n result[y][x] = '#'\n continue\n\n count = 0\n for i in range(8):\n x_round = x + dx[i]\n y_round = y + dy[i]\n \n if x_round < 0 or w <= x_round or y_round < 0 or h <= y_round:\n continue\n \n if s[y_round][x_round] == '#':\n count += 1\n\n result[y][x] = count\n\nfor y in range(h):\n for x in range(w):\n print(result[y][x], end='')\n print('')\n", "def mapt(fn, *args):\n return tuple(map(fn, *args))\n\n\ndef Input():\n return mapt(int, input().split(\" \"))\n\n\ndef check(i, j, s):\n bomb = 0\n for x, y in [(i+1, j), (i-1, j), (i, j+1), (i, j-1), (i-1, j-1), (i-1, j+1), (i+1, j-1), (i+1, j+1)]:\n if s[x][y] == \"#\":\n bomb += 1\n return str(bomb)\n\n\ndef main():\n h, w = Input()\n p = [\"x\"] * (w + 2)\n s = [p] + [[\"x\"] + list(input()) + [\"x\"] for i in range(h)] + [p]\n for i in range(1, h + 1):\n ans = \"\"\n for j in range(1, w + 1):\n if s[i][j] == \".\":\n ans += check(i, j, s)\n else:\n ans += \"#\"\n print(ans)\n\n\nmain()", "def sarch(i,j):\n cnt=0\n i1=[i-1,i,i+1]\n j1=[j-1,j,j+1]\n for x in range(3):\n for y in range(3):\n if S[i1[x]][j1[y]]==\"#\":\n cnt+=1\n return cnt\n\nimport numpy as np\nH,W=map(int,input().split())\nS=np.array([list(str(input())) for i in range(H)])\n\n\ngyo_0=np.array([\".\"]*W)\nretu_0=np.array([[\".\"]]*(H+2))\n\nS=np.vstack((gyo_0,S))\nS=np.vstack((S,gyo_0))\nS=np.hstack((retu_0,S))\nS=np.hstack((S,retu_0))\n\nfor i in range(1,H+1):\n for j in range(1,W+1):\n if S[i][j]==\".\":\n S[i][j]=sarch(i,j)\n print(S[i][j],end=\"\")\n print()", "h,w = list(map(int,input().split()))\nl = [[\".\"]*(w+2)]\nfor i in range(h):\n l.append([\".\"] + [i for i in input()] + [\".\"])\nl.append([\".\"]*(w+2))\n\ndef count(i,j):\n if l[i][j] == \"#\":\n return \"#\"\n c = 0\n for n in range(i-1,i+2):\n for m in range(j-1,j+2):\n if l[n][m] == \"#\":\n c += 1\n return str(c)\n\nans = [\"\".join([count(i,j) for j in range(1,1+w)]) for i in range(1,1+h)]\n\nprint((\"\\n\".join(ans)))\n", "h,w = map(int, input().split())\nm=[]\n\nfor i in range(h):\n m.append(input())\n\nans=[[\"#\"]*(w) for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n cnt = 0\n if h > i-1 >= 0:\n if m[i-1][j] == \"#\":\n cnt += 1\n if w > j-1 >=0 and m[i-1][j-1] == \"#\":\n cnt += 1\n if w > j+1 >=0 and m[i-1][j+1] == \"#\":\n cnt += 1\n if h > i+1 >= 0:\n if m[i+1][j] == \"#\":\n cnt += 1\n if w > j-1 >=0 and m[i+1][j-1] == \"#\":\n cnt += 1\n if w > j+1 >=0 and m[i+1][j+1] == \"#\":\n cnt += 1\n \n if w > j-1 >=0 and m[i][j-1] == \"#\":\n cnt += 1\n if w > j+1 >=0 and m[i][j+1] == \"#\":\n cnt += 1\n if m[i][j] != \"#\":\n ans[i][j] = str(cnt)\n\nfor i in range(h):\n print(\"\".join(ans[i]))", "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\n\nh, w = rm()\ns = [rr() for _ in range(h)]\nx = [0, 0, 1, -1, 1, 1, -1, -1]\ny = [1, -1, 0, 0, 1, -1, 1, -1]\nans = ['']*h\nfor i in range(h):\n for j in range(w):\n if s[i][j] == '#':\n ans[i] += '#'\n else:\n c = 0\n for dx, dy in zip(x, y):\n if 0 <= i + dx < h and 0 <= j + dy < w:\n if s[i+dx][j+dy] == '#':\n c += 1\n ans[i] += str(c)\nfor i in ans:\n print(i)\n\n\n\n\n", "h,w = map(int,input().split())\nm = [input() for _ in range(h)]\nvx = [0,1,1,1,0,-1,-1,-1]\nvy = [1,1,0,-1,-1,-1,0,1]\nans = [['#']*w for _ in range(h)]\nfor i in range(h):\n for j in range(w):\n if m[i][j] == '#':\n ans[i][j] = '#'\n continue\n count = 0\n for k in range(8):\n ny = vy[k] + i\n nx = vx[k] + j\n if 0<=ny and ny<h and 0<=nx and nx<w:\n if m[ny][nx] == '#':\n count += 1\n ans[i][j] = str(count)\nfor i in ans:\n print(''.join(i))", "h, w = map(int, input().split())\ns = [input() for i in range(h)]\n\nans =[]\nfor row in s:\n ans.append(list(row))\n \ndxy = [(-1, -1), (-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1)]\nfor x in range(h):\n for y in range(w):\n if s[x][y] == \"#\":\n continue\n c = 0\n for dx, dy in dxy:\n if x +dx < 0 or x +dx > h-1 or y + dy < 0 or y + dy > w-1:\n continue\n else:\n if s[x + dx][y + dy] == \"#\":\n c += 1\n ans[x][y] = c\nfor row in ans:\n print(\"\".join(list(map(str, row))))", "from collections import deque\nh, w = map(int, input().split())\nmine = [[] for _ in range(h+2)]\nmine[0] = deque([\".\" for _ in range(w+2)])\nmine[-1] = deque([\".\" for _ in range(w+2)])\nfor i in range(h):\n mine[i+1] = deque(list(input()))\n mine[i+1].append(\".\")\n mine[i+1].appendleft(\".\")\nfor i in range(1, h+1):\n for j in range(1, w+1):\n if mine[i][j] == \"#\":\n print(\"#\", end=\"\")\n else:\n counter = 0\n for k in range(-1, 2):\n for l in range(-1, 2):\n if (k or l) and mine[i+k][j+l] == \"#\":\n counter += 1\n print(counter, end=\"\")\n print()", "h,w = map(int,input().split())\ns = [list(input()) for _ in range(h)]\nbomb_count = 0\nfor i in range(h):\n for j in range(w):\n if s[i][j] == \"#\":\n continue\n else:\n for k in range(3):\n for l in range(3):\n a = i-1+k\n b = j-1+l\n if a < 0:\n continue\n elif a > h-1:\n continue\n if b < 0:\n continue\n elif b > w-1:\n continue\n if s[a][b] == \"#\":\n bomb_count += 1\n s[i][j] = str(bomb_count)\n bomb_count = 0\nfor i in range(h):\n print(\"\".join(s[i]))", "\ndef mine_count(x, y, ans):\n ans[y][x] = 0\n for nx, ny in (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1), (-1, 0), (-1, 1):\n if 0 <= y+ny < H and 0 <= x+nx < W:\n if ans[y+ny][x+nx] == \"#\":\n ans[y][x] += 1\n return ans\n\n\nH, W = map(int, input().split())\nS = [list(input()) for _ in range(H)]\nans = S\nfor i in range(H):\n for j in range(W):\n if S[i][j] == \".\":\n ans = mine_count(j, i, ans)\n\nfor row in ans:\n for item in row:\n print(item, end=\"\")\n print()\n", "h,w=map(int, input().split())\ns=[\".\"*(w+2)]\nfor i in range(h):\n s.append(\".\"+input()+\".\")\ns.append(\".\"*(w+2))\nd=[-1,0,1]\nfor i in range(1,h+1):\n new=\"\"\n for j in range(1,w+1):\n if s[i][j]==\"#\":\n new=new+\"#\"\n else:\n count=0\n for k in range(3):\n for l in range(3):\n if s[i+d[k]][j+d[l]]==\"#\":\n count+=1\n new=new+str(count)\n print(new)", "H,W = map(int,input().split())\nS = [list(input()) for _ in range(H)]\n\nans = [[0 for _ in range(W)] for _ in range(H)]\nmove = [(-1,-1),(-1,0),(-1,1),(0,-1),(0,1),(1,-1),(1,0),(1,1)]\n\nfor i in range(H):\n for j in range(W):\n if S[i][j] == \"#\":\n ans[i][j] = \"#\"\n else:\n for x, y in move:\n nx, ny = i+x, j+y\n if nx < 0 or H <= nx or ny < 0 or W <= ny:\n continue\n elif S[nx][ny] == \"#\":\n ans[i][j] += 1\n \nfor a in ans:\n for i in range(W):\n a[i] = str(a[i])\n print(\"\".join(a))", "h, w = map(int, input().split())\ns = [list(input()) for i in range(h)]\nans = [[0] * (w + 2) for i in range(h + 2)]\n\nfor i in range(1, h + 1):\n for j in range(1, w + 1):\n if s[i - 1][j - 1] == \"#\":\n ans[i - 1][j - 1] += 1\n ans[i - 1][j] += 1\n ans[i - 1][j + 1] += 1\n ans[i][j - 1] += 1\n ans[i][j + 1] += 1\n ans[i + 1][j - 1] += 1\n ans[i + 1][j] += 1\n ans[i + 1][j + 1] += 1\n\ndel ans[0]\ndel ans[-1]\nfor i in range(h):\n del ans[i][0]\n del ans[i][-1]\nfor i, _ in enumerate(s):\n tmp = \"\"\n for j, word in enumerate(_):\n if word == \"#\":\n tmp += \"#\"\n else:\n tmp += str(ans[i][j])\n print(tmp, end=\"\\n\")\n", "H, W = map(int, input().split())\nL = []\nfor i in range(H):\n S = list(input())\n L.append(S)\n\nfor i in range(H):\n for j in range(len(L[i])):\n if L[i][j] == '.':\n cnt = 0\n for k in range(-1, 2):\n for l in range(-1, 2):\n if ((i+k) < H) and ((j+l) < len(L[i])) and ((j+l) >= 0) and ((i+k) >= 0):\n if L[i+k][j+l] == '#':\n cnt += 1\n L[i][j] = str(cnt)\n\nfor i in range(len(L)):\n print(''.join(L[i]))", "H, W = map(int,input().split())\nS = []\nfor _ in range(H):\n S.append(list(input()))\nfor i in range(H):\n for j in range(W):\n if S[i][j] == '.':\n cnt = 0\n for k in range(-1, 2):\n for l in range(-1, 2):\n if 0 <= i + k < H and 0 <= j + l < W and S[i+k][j+l] == '#':\n cnt += 1\n S[i][j] = str(cnt)\nfor i in range(H):\n print(''.join(S[i]))"]
{"inputs": ["3 5\n.....\n.#.#.\n.....\n", "3 5\n#####\n#####\n#####\n", "6 6\n#####.\n#.#.##\n####.#\n.#..#.\n#.##..\n#.#...\n"], "outputs": ["11211\n1#2#1\n11211\n", "#####\n#####\n#####\n", "#####3\n#8#7##\n####5#\n4#65#2\n#5##21\n#4#310\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
69,660
5975973213b5b544269a2c4126b963db
UNKNOWN
We have two desks: A and B. Desk A has a vertical stack of N books on it, and Desk B similarly has M books on it. It takes us A_i minutes to read the i-th book from the top on Desk A (1 \leq i \leq N), and B_i minutes to read the i-th book from the top on Desk B (1 \leq i \leq M). Consider the following action: - Choose a desk with a book remaining, read the topmost book on that desk, and remove it from the desk. How many books can we read at most by repeating this action so that it takes us at most K minutes in total? We ignore the time it takes to do anything other than reading. -----Constraints----- - 1 \leq N, M \leq 200000 - 1 \leq K \leq 10^9 - 1 \leq A_i, B_i \leq 10^9 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N M K A_1 A_2 \ldots A_N B_1 B_2 \ldots B_M -----Output----- Print an integer representing the maximum number of books that can be read. -----Sample Input----- 3 4 240 60 90 120 80 150 80 150 -----Sample Output----- 3 In this case, it takes us 60, 90, 120 minutes to read the 1-st, 2-nd, 3-rd books from the top on Desk A, and 80, 150, 80, 150 minutes to read the 1-st, 2-nd, 3-rd, 4-th books from the top on Desk B, respectively. We can read three books in 230 minutes, as shown below, and this is the maximum number of books we can read within 240 minutes. - Read the topmost book on Desk A in 60 minutes, and remove that book from the desk. - Read the topmost book on Desk B in 80 minutes, and remove that book from the desk. - Read the topmost book on Desk A in 90 minutes, and remove that book from the desk.
["def solve():\n N,M,K = map(int, input().split())\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n ret = 0\n\n A_cusum = [0]\n A_border_index = 0 # \u8d85\u3048\u308b\u3068\u304d\u306eindex\n for a_ in A:\n A_end = A_cusum[-1]\n if A_end+a_ > K:\n break\n\n A_cusum.append(A_end+a_)\n \n A_border_index = len(A_cusum)-1\n ret = A_border_index\n\n B_cusum = [0]\n B_border_index = 0\n \n while A_border_index >= 0 and B_border_index < M:\n\n while B_border_index < M:\n B_end = B_cusum[-1]\n b_ = B[B_border_index]\n\n if A_cusum[A_border_index]+B_end+b_ > K:\n break\n\n B_cusum.append(B_end+b_)\n B_border_index += 1\n\n ret = max(ret, A_border_index+B_border_index)\n A_border_index -= 1\n\n print(ret)\n \nsolve()", "n,m,k=map(int,input().split())\na=[int(x) for x in input().split()]\nb=[int(x) for x in input().split()]\n\nca,cb=[0],[0]\nfor i in range(n):\n ca.append(ca[i]+a[i])\nfor i in range(m):\n cb.append(cb[i]+b[i])\n\nans,j=0,m \nfor i in range(n+1):\n if ca[i]>k: break;\n while cb[j]>k-ca[i]: j-=1;\n ans=max(ans,i+j)\n\nprint(ans)", "n,m,k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\na = [0]\nb = [0]\n\nfor i in range(n):\n a.append(a[i]+ A[i])\nfor i in range(m):\n b.append(b[i] + B[i])\n# print(a)\n# print(b)\n# print(a[3])\nans=0\nj = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nfrom itertools import accumulate\nfrom bisect import bisect\ndef main():\n n, m, k = map(int, input().split())\n a = tuple(accumulate(map(int, input().split())))\n b = tuple(accumulate(map(int, input().split())))\n r = bisect(b, k)\n\n for i1, ae in enumerate(a):\n if k < ae:\n break\n r = max(r, bisect(b, k - ae) + i1 + 1)\n print(r)\n\ndef __starting_point():\n main()\n__starting_point()", "from bisect import *\nn,m,k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n# A\u306e\u7d2f\u7a4d\u548c\u3092\u4fdd\u5b58\u3057\u3066\u304a\u304f\n# \u5404A\u306e\u8981\u7d20\u306b\u3064\u3044\u3066\u3001B\u304c\u4f55\u518a\u8aad\u3081\u308b\u304b\u4e8c\u5206\u63a2\u7d22\u3059\u308b\u3002\n# \u8a08\u7b97\u91cf: AlogB\nA.insert(0, 0)\n\nfor i in range(1,len(A)):\n A[i] += A[i-1]\nfor i in range(1, len(B)):\n B[i] += B[i-1]\n\nans = 0\nfor i in range(len(A)):\n rest_time = k - A[i]\n if rest_time >= 0:\n numb = bisect_right(B, rest_time)\n anstmp = i + numb \n ans = max(ans, anstmp)\nprint(ans)", "import bisect\nn, m, k = map(int, input().split())\naaa = list(map(int, input().split()))\nbbb = list(map(int, input().split()))\nsum_a = [0] * (n + 1)\nsum_b = [0] * (m + 1)\n\nfor i in range(n):\n sum_a[i + 1] = sum_a[i] + aaa[i]\n\nfor j in range(m):\n sum_b[j + 1] = sum_b[j] + bbb[j]\n\nans = 0\nfor i in range(n + 1):\n if sum_a[i] > k:\n break\n tmp = bisect.bisect_right(sum_b, k - sum_a[i])\n ans = max(ans, i + tmp - 1)\nprint(ans)", "n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nsum_a = [0]\nsum_b = [0]\n\ncounta = 0\nfor x in a:\n counta += x\n if counta <= k:\n sum_a.append(counta)\n else:\n break\n\ncountb = 0\nfor y in b:\n countb += y\n if countb <= k:\n sum_b.append(countb)\n else:\n break\n\n\nn = len(sum_b)\n\nans = 0\n\nfor i in range(len(sum_a)):\n for j in reversed(range(n)):\n if sum_a[i] + sum_b[j]<= k:\n ans = max(ans,i+j)\n n = j+1\n break\n else:\n break\n\n\nprint(ans)", "def binary_search(arr, num):\n left = 0\n right = len(arr)-1\n while right-left > 0:\n mid = (left+right) // 2\n if arr[mid] > num:\n right = mid\n else:\n left = mid + 1\n if arr[left] > num:\n return left\n else:\n return len(arr)\n\ndef main():\n n, m, k = map(int , input().split())\n a_books = list(map(int , input().split()))\n b_books = list(map(int , input().split()))\n a_cum_sum = [0] * (n+1)\n b_cum_sum = [0] * (m+1)\n\n for i in range(n):\n a_cum_sum[i+1] = a_cum_sum[i] + a_books[i]\n for i in range(m):\n b_cum_sum[i+1] = b_cum_sum[i] + b_books[i]\n ans = 0\n for i in range(n+1):\n if a_cum_sum[i] > k:\n break\n rest = k - a_cum_sum[i]\n index = binary_search(b_cum_sum, rest)\n ans = max(ans, i+index-1)\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "n,m,k=map(int,input().split())\na=[int(x) for x in input().split()]+[10**9+5]\nb=[int(x) for x in input().split()]+[10**9+5]\n\ncnt=i=0\nfor ai in a:\n if cnt+ai>k: break;\n cnt+=ai; i+=1; \n\nj=0\nfor bi in b:\n if cnt+bi>k: break;\n cnt+=bi; j+=1;\n \nans=s=i+j\nfor i in reversed(range(i)):\n s-=1; cnt-=a[i];\n while cnt+b[j]<=k:\n s+=1; cnt+=b[j]; j+=1;\n ans=max(ans,s)\n \nprint(ans)", "import itertools\nimport bisect\nn,m,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nca=[0]+list(itertools.accumulate(a))\ncb=[0]+list(itertools.accumulate(b))\nans=0\nfor i in range(n+1):\n if k<ca[i]:\n break\n j=bisect.bisect(cb,k-ca[i])\n ans=max(i-1+j,ans)\nprint(ans)\n", "def main():\n n, m, k = list(map(int, input().split()))\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n\n s = sum(B)\n ans = 0\n i, j = 0, m - 1\n while i < n:\n if s <= k:\n ans = max(ans, i + j + 1)\n s += A[i]\n i += 1\n else:\n if j < 0:\n break\n s -= B[j]\n j -= 1\n\n if s <= k:\n ans = max(ans, n + j + 1)\n\n print(ans)\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\n \nfor i in range(M):\n b.append(b[i] + B[i])\n ans, j = 0, M\n\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)", "N,M,K = map(int,input().split())\nlsA = list(map(int,input().split()))\nlsB = list(map(int,input().split()))\n\nlsAN = [0]\nsumA = 0\nfor i in range(N):\n sumA += lsA[i]\n lsAN.append(sumA)\nlsBN = [0]\nsumB = 0\nfor i in range(M):\n sumB += lsB[i]\n lsBN.append(sumB)\nj = M\nans = 0\nfor i in range(N+1):\n if lsAN[i] > K:\n break\n while lsBN[j] > K - lsAN[i]:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)", "# author: Taichicchi\n# created: 15.09.2020 21:14:18\n\nimport sys\n\nN, M, K = list(map(int, input().split()))\n\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na = [0]\nb = [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans = 0\nj = M\n\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n", "N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n\na=[0]\nb=[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n\n#print(a)\n#print(b)\n\nans=0\nj=M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j-=1\n #print(i,j)\n ans=max(ans,i+j)\nprint(ans)", "from collections import deque\nfrom itertools import accumulate\nn,m,k = map(int,input().split())\na_list = list(accumulate(list(map(int,input().split()))))\na_list = [0]+a_list\nb_list = list(accumulate(list(map(int,input().split()))))\nb_list = [0]+b_list+[float('inf')]\ncnt_list = []\n\nfor i in range(len(a_list)) :\n t = k\n cnt = 0\n a = a_list[i]\n if t < a :\n continue\n t -= a\n cnt += i\n\n ok = 0\n no = m+2\n while no != ok+1 :\n center = (ok+no)//2\n\n if t >= b_list[center] :\n ok = center\n if t < b_list[center] :\n no = center\n cnt += ok\n cnt_list.append(cnt)\n\nans = max(cnt_list)\nprint(ans)", "n, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA = [0]\nB = [0]\nans = 0\nfor i in range(n):\n A.append(A[i] + a[i])\nfor i in range(m):\n B.append(B[i] + b[i])\nj = m\nfor i in range(n + 1):\n if A[i] > k:\n break\n while(A[i] + B[j] > k):\n # print('i: {}, j: {}'.format(i, j))\n j -= 1\n ans = max(ans, i + j)\nprint(ans)\n", "N, M, K= map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\n\nAsum=[0]\nBsum=[0]\n\nfor i in range(N):\n Asum.append(Asum[-1]+A[i])\n \nfor i in range(M):\n Bsum.append(Bsum[-1]+B[i])\n \nm=0\nj=M\n\nfor i in range(len(Asum)):\n if Asum[i]>K:\n break\n while Asum[i]+Bsum[j]>K:\n j-=1\n if m<i+j:\n m=i+j\n \nprint(m)", "n,m,k=map(int,input().split())\narr1=list(map(int,input().split()))\narr2=list(map(int,input().split()))\n\nacum1=[0]\nfor i in range(n):\n acum1.append(acum1[-1]+arr1[i])\nacum2=[0]\nfor i in range(m):\n acum2.append(acum2[-1]+arr2[i])\nans=0\nj=m\nfor i in range(n+1):\n if acum1[i]>k:\n break\n while acum2[j]>k-acum1[i] and j>0:\n j-=1\n ans=max(ans,i+j)\nprint(ans)", "from itertools import accumulate\nfrom bisect import bisect_right\nN, M, K = map(int,input().split())\nA = [0]+list(accumulate(map(int,input().split()), lambda x,y:x+y))\nB = [0]+list(accumulate(map(int,input().split()), lambda x,y:x+y))\nans = 0\nfor i in range(N+1):\n left = K-A[i]\n if left < 0:\n break\n j = bisect_right(B, left)\n ans = max(ans, i+j-1)\nprint(ans)", "def getval():\n n,m,k = map(int,input().split())\n A = list(map(int,input().split()))\n B = list(map(int,input().split()))\n a = [A[0]]\n b = [B[0]]\n for i in range(0,n-1):\n a.append(a[i]+A[i+1])\n for i in range(0,m-1):\n b.append(b[i]+B[i+1])\n return n,m,k,a,b\n\ndef main(n,m,k,a,b):\n idxa = 0\n ans = 0\n t = 0\n while a[idxa]<=k and idxa<n:\n idxa += 1\n if idxa==n:\n break\n ans = idxa\n idxa -= 1\n t = a[idxa]\n for i in range(m):\n t = a[idxa] + b[i]\n if t<=k:\n ans = max(ans,idxa+i+2)\n else:\n flag = False\n while t>k:\n idxa -= 1\n if idxa<0:\n a.append(0)\n break\n t = a[idxa]+b[i]\n ans = max(ans,idxa+i+2)\n\n print(ans)\n\ndef __starting_point():\n n,m,k,a,b = getval()\n main(n,m,k,a,b)\n__starting_point()", "import bisect\nimport itertools\nn,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nca=[0]+list(itertools.accumulate(a))\ncb=[0]+list(itertools.accumulate(b))\nans=0\nfor i in range(n+1):\n bk=ca[i]\n if bk<=k:\n j=bisect.bisect(cb,k-bk)\n ans=max(ans,i+j-1)\n else:\n break\nprint(ans)", "n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nasum=[0]\nbsum=[0]\nfor i in range(n):\n asum.append(asum[-1]+a[i])\nfor i in range(m):\n bsum.append(bsum[-1]+b[i])\nans=0\nfor i in range(n+1):\n if asum[i]>k:\n break\n while asum[i]+bsum[m]>k and m>0:\n m-=1\n ans=max(ans,i+m)\nprint(ans)", "n, m, k = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i] + A[i])\n\nfor i in range(m):\n b.append(b[i] + B[i])\n\nans, j = 0, m\nfor i in range(n + 1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)", "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nC, D = [0], [0]\nfor i in range(N):\n C.append(C[-1] + A[i])\nfor i in range(M):\n D.append(D[-1] + B[i])\n\nans = 0\nfor i in range(N + 1):\n T = K - C[i]\n l, r = 0, M + 1\n while r - l > 1:\n m = (l + r) // 2\n if D[m] <= T: l = m\n else: r = m\n if T >= 0: ans = max(ans, i + l)\nprint(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, k = [int(i) for i in input().split()]\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\n\ntmp = sum(A)\ncnt = len(A)\nres = 0\n\nA = deque(A)\nB = deque(B)\n\nwhile True:\n if tmp <= k:\n res = max(res, cnt)\n if len(B) <= 0:\n break\n b = B.popleft()\n tmp += b\n cnt += 1\n else:\n if len(A) <= 0:\n break\n a = A.pop()\n tmp -= a\n cnt -= 1\n\nprint(res)\n", "import numpy as np\nimport bisect\nN,M,K= list(map(int, input().split()))\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\nif A[0]>K and B[0]>K:print((0));return\n\nAsum=[0]\nfor i in range(N):\n if Asum[-1]+A[i]<=K:\n Asum.append(Asum[-1]+A[i]) \n else:break\n \nBsum=[0]\nfor j in range(M):\n if Bsum[-1]+B[j]<=K:\n Bsum.append(Bsum[-1]+B[j])\n else:break\n #AAsum=[]\n#for i in range(len(Asum)):\n# AAsum.append(K-Asum[i])\n\n#print(Asum)\n#print(AAsum)\n#print(Bsum)\n\nC=[]\nfor i in range(len(Asum)):\n C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)\n\n#print(Asum)\n#print(AAsum)\n#print(Bsum)\n#print(C)\nprint((max(C)))\n#176882\n", "n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = [0]*(n+1)\nd = [0]*(m+1)\nfor i in range(n):\n c[i+1] = a[i]+c[i]\nfor i in range(m):\n d[i+1] = b[i]+d[i]\nfor i in range(m+1)[::-1]:\n if d[i] <= k:\n x = i\n break\nans = x\nfor i in range(1,n+1):\n while c[i] + d[x] > k:\n if x >= 1:\n x -= 1\n else:\n break\n if c[i] + d[x] <= k:\n ans = max(ans,i+x)\nprint(ans)", "n,m,k=map(int,input().split())\na=[int(x) for x in input().split()]\nb=[int(x) for x in input().split()]\n\nc=[0]\nfor i in range(n):\n if c[i]+a[i]<=k:\n c.append(c[i]+a[i])\n else:\n break\n\nd=[0]\nfor i in range(m):\n if d[i]+b[i]<=k:\n d.append(d[i]+b[i])\n else:\n break\n\ne=0\nf=len(d)-1\nfor i in range(len(c)):\n for j in range(f,-1,-1):\n if c[i]+d[j]<=k:\n if i+j>e:\n e=i+j\n f=j\n break\nprint(e)", "import bisect\nN,M,K = map(int,input().split()) \nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nfor i in range(1,N):\n A[i] += A[i-1]\nfor i in range(1,M): \n B[i] += B[i-1]\nma = bisect.bisect(A,K)\nfor m in range(0,M):\n if B[m]>K:\n break \n n = bisect.bisect(A,K-B[m])\n if ma < n + m + 1:\n ma = n + m + 1 \nprint(ma)", "def main():\n line1 = input()\n line2 = input()\n line3 = input()\n n, m, k = list(map(int, line1.split()))\n a = [0] + list(map(int, line2.split()))\n b = [0] + list(map(int, line3.split()))\n mark1, mark2 = 0, 0\n for i in range(1, len(a)):\n a[i] += a[i-1]\n if a[i] > k:\n mark1 = i\n break\n for i in range(1, len(b)):\n b[i] += b[i-1]\n if b[i] > k:\n mark2 = i\n break\n if mark1:\n a = a[:mark1]\n if mark2:\n b = b[:mark2]\n ans = 0\n for i in range(len(a)):\n target = k - a[i]\n tmp = 0\n low, high = 0, len(b)\n while low < high:\n mid = (low + high) // 2\n if b[mid] <= target:\n tmp = mid\n low = mid + 1\n else:\n high = mid - 1\n ans = max(ans, i + tmp)\n print(ans)\n return\n\ndef __starting_point():\n main()\n__starting_point()", "import sys\ninput = sys.stdin.readline # for speed up\nsys.setrecursionlimit(10**7)\n\nn,m,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\n\naa=[0]*(len(a)+1)\nbb=[0]*(len(b)+1)\n\nfor ii in range(len(a)):\n aa[ii+1]=aa[ii]+a[ii]\nfor ii in range(len(b)):\n bb[ii+1]=bb[ii]+b[ii]\n\"\"\"\nprint(a)\nprint(aa)\nprint(b)\nprint(bb)\n\"\"\"\nr=0\njmax=len(bb)-1\nfor ii in range(len(aa)):\n if aa[ii]>k:\n break\n for jj in range(jmax,-1,-1):\n if bb[jj]>k-aa[ii]:\n pass\n else:\n r=max(r,ii+jj)\n #print(r,ii,jj)\n jmax=jj\n break\nprint(r)\n", "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ncurr = 0\nA_index = 0\nB_index = 0\nwhile curr + A[A_index] <= K:\n curr += A[A_index]\n A_index += 1\n if A_index == N:\n break\n\nwhile curr + B[B_index] <= K:\n curr += B[B_index]\n B_index += 1\n if B_index == M:\n break\n\nans = A_index + B_index\n\nwhile A_index:\n A_index -= 1\n curr -= A[A_index]\n if B_index == M:\n break\n while curr + B[B_index] <= K:\n curr += B[B_index]\n B_index += 1\n if B_index == M:\n break\n ans = max(ans, A_index + B_index)\n\nprint(ans)", "from bisect import bisect_right\n\nn, m, k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\ncnt = 0\na_cum = [0] * (n + 1)\nb_cum = [0] * (m + 1)\n\nfor i in range(n):\n a_cum[i+1] = a_cum[i] + a[i]\nfor i in range(m):\n b_cum[i+1] = b_cum[i] + b[i]\n\nfor i in range(n+1):\n a_cnt = i\n rest = k - a_cum[i]\n if rest < 0:\n break\n b_cnt = bisect_right(b_cum,rest) - 1 \n cnt = max(cnt, a_cnt + b_cnt)\n\nprint(cnt)", "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0]*(N+1), [0]*(M+1)\nfor i in range(N):\n\ta[i+1] = a[i] + A[i] \nfor i in range(M):\n\tb[i+1] = b[i] + B[i]\n \nans, j = 0, M\nfor i in range(N + 1):\n\tif a[i] > K:\n\t\tbreak\n\twhile b[j] > K - a[i]:\n\t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)", "n,m,k=map(int,input().split());A,B=eval(\"[0]+[*map(int,input().split())],\"*2);s=t=x=0;j=m\nfor i in range(n+1):s+=A[i];A[i]=s\nfor i in range(m+1):t+=B[i];B[i]=t\nfor i in range(n+1):\n if A[i]>k:break\n while B[j]>k-A[i]:j-=1\n x=max(x,i+j)\nprint(x)", "n,m,k = list(map(int,input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA,B = [0],[0]\n \nfor i in range(n):\n A.append(a[i] + A[i])\nfor i in range(m):\n B.append(b[i] + B[i])\n \nnum,x = 0,m\n \nfor i in range(len(A)):\n if A[i] > k:\n break\n while A[i] + B[x] > k:\n x -= 1\n num = max(num, i + x)\n \nprint(num)\n", "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nSA =[0]\nSB =[0]\nfor i in range(len(A)):\n SA.append(SA[i] + A[i])\nfor j in range(len(B)):\n SB.append(SB[j] + B[j])\n\nl = M\nans = 0\nfor k in range(N+1):\n if SA[k] > K:\n break\n while SA[k] + SB[l] > K:\n l -= 1\n ans = max(ans, k + l)\nprint(ans)", "N , M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na,b=[0],[0]\nfor i in range(N): a.append(a[i] + A[i])\nfor i in range(M): b.append(b[i] + B[i])\nans,j=0,M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)", "from itertools import accumulate\nimport bisect\n\nN, M, K = map(int, input().split())\nA=[0]+list(accumulate(map(int,input().split())))\nB=[0]+list(accumulate(map(int,input().split())))\n\nX = 0\nY_num = [0]*(N+1)\n\nfor i in range(N+1):\n if A[i] <= K:\n X = bisect.bisect_right(B, K-A[i])\n Y_num[i] = i + X - 1\n\nprint(max(Y_num))", "\nN, M , K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nRA = [0]\nRB = [0]\n\ntmp = 0\nfor i in range(N):\n tmp += A[i]\n RA.append(tmp)\n\ntmp = 0\nfor i in range(M):\n tmp += B[i]\n RB.append(tmp)\n#print(RA)\n#print(RB)\n\nans = 0\nbest = M\nfor i in range(N+1):\n if RA[i]>K:\n break\n while RB[best] > K - RA[i]:\n best -= 1\n ans = max(ans, i + best)\n\nprint(ans)\n", "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(N):\n\ta.append(a[i] + A[i])\nfor i in range(M):\n\tb.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n\tif a[i] > K:\n\t\tbreak\n\twhile b[j] > K - a[i]:\n\t\tj -= 1\n\tans = max(ans, i + j)\nprint(ans)", "N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na,b = [0],[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\nans,j = 0,M\nfor i in range(N+1):\n if a[i] > K:\n break\n while b[j] > K -a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)", "def getmax(x,y):\n if x>y:\n return x\n else:\n return y\nN,M,K = list(map(int,input().split()))\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\n\na,b = [0],[0]\nfor i in range(N): #a[i]\u306b\u306fA\u306e\u672c\u3092i\u518a\u8aad\u3093\u3060\u6642\u306e\u6642\u9593\u304c\u305d\u308c\u305e\u308c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\uff0e\n a.append(a[i]+A[i]) #\u8a08\u7b97\u91cf\u3092\u6e1b\u3089\u3059\u305f\u3081\uff0ca[i]\uff081\u518a\u524d\u307e\u3067\u306b\u304b\u304b\u308b\u6642\u9593\uff09\u3092\u7528\u3044\u308b\nfor i in range(M):\n b.append(b[i]+B[i])\n\nans,j = 0,M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j] > K-a[i]: #B\u306e\u672c\u3092\u8aad\u3093\u3060\u5834\u5408\u306e\u51e6\u7406\u306f\u3053\u3053\u3067\u5b9f\u884c\u3055\u308c\u308b\uff0e\n j -=1\n ans = max(ans, i+j)\nprint(ans)\n", "import sys\ninput = sys.stdin.readline # for speed up\nsys.setrecursionlimit(10**7)\n\nn,m,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\naa=[0]*(len(a)+1)\nbb=[0]*(len(b)+1)\n\nfor ii in range(len(a)):\n aa[ii+1]=aa[ii]+a[ii]\nfor ii in range(len(b)):\n bb[ii+1]=bb[ii]+b[ii]\n \nii=0\njmax=0\nr=0\nfor jj in range(len(aa)):\n if aa[jj]>k:\n break\n else:\n r=ii+jj\n jmax=jj\n \nfor ii in range(len(bb)):\n for jj in range(jmax,-1,-1):\n if bb[ii]>k-aa[jj]:\n pass\n else:\n jmax=jj\n r=max(r,ii+jj)\n break\n\"\"\"\nfor ii in range(m+1):\n print(c[ii])\n\"\"\" \n\nprint(r)\n", "n, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nsum_as = [0]\nsum_bs = [0]\n\nfor i in range(n):\n sum_as.append(sum_as[i]+a[i])\nfor i in range(m):\n sum_bs.append(sum_bs[i]+b[i])\n\nans = 0\ni = 0\nj = m\n\nwhile i<=n and sum_as[i] <= k:\n while sum_bs[j] > k-sum_as[i]:\n j -= 1\n ans = max(ans, i+j)\n i += 1\nprint(ans)\n", "N, M, K = map(int, input().split())\nA = [0] + list(map(int, input().split()))\nB = [0] + list(map(int, input().split()))\nfor i in range(1, N+1):\n A[i] += A[i-1]\n\ni = N\ntotal = 0\nans = 0\nfor j in range(M+1):\n total += B[j]\n while i >= 0 and A[i]+total > K:\n i -= 1\n if A[i]+total <= K:\n ans = max(ans, i+j)\n\nprint(ans)", "n, m ,k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\na, b = [0], [0]\nfor i in range(n):\n a.append(a[i]+A[i])\nfor i in range(m):\n b.append(b[i]+B[i])\n\nans, j = 0, m\nfor i in range(n+1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)\n", "N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n \na=[0]\nb=[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n \n#print(a)\n#print(b)\n \nans=0\nj=M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j-=1\n #print(i,j)\n ans=max(ans,i+j)\nprint(ans)", "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\n\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)", "from bisect import bisect\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nSA = [0] * (N + 1)\nSB = [0] * (M + 1)\nfor i in range(N):\n SA[i+1] = SA[i] + A[i]\nfor i in range(M):\n SB[i+1] = SB[i] + B[i]\nresult = 0\nfor x in range(N+1):\n if SA[x] > K:\n break\n y = bisect(SB, K - SA[x]) - 1\n result = max(result, x + y)\nprint(result)", "import bisect\n\nN,M,K=list(map(int,input().split()))\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nsum1=[0]\nsum2=[0]\nfor i in range(N):\n sum1.append(sum1[-1]+A[i])\nfor i in range(M):\n sum2.append(sum2[-1]+B[i])\n\nans=0\nfor i in range(N+1):\n if sum1[i]>K:\n break\n ans=max(ans,i+bisect.bisect_right(sum2,K-sum1[i])-1)\nprint(ans)\n", "# Begin Header {{{\nfrom math 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 accumulate, product, permutations, combinations, combinations_with_replacement\n# }}} End Header\n# _________\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306f\u3053\u3053\u304b\u3089\uff01\uff01___________\nn, m, k = list(map(int, input().split()))\nA = list(accumulate(list(map(int, input().split()))))\nB = list(accumulate(list(map(int, input().split()))))\nA=[0]+A\nB=[0]+B\nans = []\nfor i in range(n+1):\n c = bisect_right(B, k-A[i])-1\n if c!=-1:\n ans.append(c+i)\nprint((max(ans)))\n", "import itertools\nimport bisect\nn,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nca=[0]+list(itertools.accumulate(a))\ncb=[0]+list(itertools.accumulate(b))\nans=0\nfor i in range(n+1):\n wk=ca[i]\n if wk>k:\n break\n else:\n j=bisect.bisect(cb,k-ca[i])\n ans=max(ans,i+j-1)\nprint(ans)", "n,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nsum_a = [0]\nsum_b = [0]\n\ncounta = 0\nfor x in a:\n counta += x\n if counta <= k:\n sum_a.append(counta)\n else:\n break\n\ncountb = 0\nfor y in b:\n countb += y\n if countb <= k:\n sum_b.append(countb)\n else:\n break\n\n\nn = len(sum_b)\n\nans = 0\n\nfor i in range(len(sum_a)):\n for j in reversed(range(n)):\n if sum_a[i] + sum_b[j]<= k:\n ans = max(ans,i+j)\n n = j+1\n break\n else:\n break\n\n\nprint(ans)", "from bisect import bisect\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nSA = [0] * (N + 1)\nSB = [0] * (M + 1)\nfor i in range(N):\n SA[i+1] = SA[i] + A[i]\nfor i in range(M):\n SB[i+1] = SB[i] + B[i]\n\nresult = 0\ny = M\nfor x in range(N+1):\n if SA[x] > K:\n break\n while y >= 0 and SA[x] + SB[y] > K:\n y -= 1\n result = max(result, x + y)\nprint(result)", "from itertools import accumulate as a\nN,M,K=map(int,input().split());l=[0]\nP=l+list(a(map(int,input().split())))\nQ=l+list(a(map(int,input().split())))\ni=j=0\nf=lambda:P[i]+Q[j]<=K\nwhile(i<=N)and f():i+=1\nwhile i>=0:\n i-=1\n while(j<=M)and f():j+=1 \n l+=[i+j-1]\nprint(max(l))", "import sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nimport numpy as np\ndef main():\n n, m, k = map(int, input().split())\n a = np.array(readline().split(), np.int64)\n b = np.array(readline().split(), np.int64)\n aa = np.zeros(n + 1, np.int64)\n ba = np.zeros(m + 1, np.int64)\n aa[1:] = a.cumsum()\n ba[1:] = b.cumsum()\n aa = aa[aa <= k]\n ba = ba[ba <= k]\n rs = np.searchsorted(ba, k - aa, side='right') - 1\n rs += np.arange(len(aa))\n r = rs.max()\n print(r)\n\ndef __starting_point():\n main()\n__starting_point()", "from itertools import accumulate\nimport bisect\n\nn, m, k = map(int, input().split())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\na_acc = [0] + list(accumulate(a)) # a\u30920\u518a\u8aad\u3080=1\u518a\u3082\u8aad\u307e\u306a\u3044\u5834\u5408\u304c\u3042\u308b\u306e\u3067\u3001[0]\u3092\u5148\u982d\u306b\u8ffd\u52a0\u3057\u307e\u3059\nb_acc = list(accumulate(b)) # bisect_right\u3067\u306f\u3001x\u4ee5\u4e0b\u306e\u8981\u7d20\u304c\u3044\u304f\u3064\u3042\u308b\u304b\uff1f\u3092\u6c42\u3081\u308b\u306e\u3067\u3001\u3053\u3061\u3089\u306b0\u306f\u5165\u308c\u307e\u305b\u3093\n\nans = 0\nfor an in range(n + 1):\n rem = k - a_acc[an]\n if rem < 0:\n # a\u3092\u3053\u308c\u4ee5\u4e0a\u8aad\u3081\u307e\u305b\u3093\n break\n\n bn = bisect.bisect_right(b_acc, rem)\n ans = max(ans, an + bn)\n\nprint(ans)", "N,M,K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na = [0]\nb = [0]\n\nfor i in range(N):\n a.append(a[i] + A[i])\nfor j in range(M):\n b.append(b[j] + B[j])\nans = 0\nj = M\nfor i in range(N+1):\n if a[i] > K:\n break\n while a[i] + b[j] > K:\n j -= 1\n ans = max(ans, i+j)\nprint(ans)", "#tsundoku\nn,m,k = list(map(int,input().split()))\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nreadtime_a = [0]\nreadtime_b = [0]\nfor i in range(n):\n readtime_a.append(readtime_a[i]+a[i])\nfor i in range(m):\n readtime_b.append(readtime_b[i]+b[i])\n\n#print(readtime_a)\n#print(readtime_b)\n\ncnt = [0]\nimport bisect\n\nfor i in range(n+1):\n if readtime_a[i] > k:\n continue\n else:\n #print(i,bisect.bisect(readtime_b,k-readtime_a[i])-1,k-readtime_a[i])\n \n cnt.append(i-1 + bisect.bisect(readtime_b,k-readtime_a[i]))\n\nprint((max(cnt)))\n", "N, M, K = map(int, input().split())\nA = [0] + list(map(int, input().split()))\nB = [0] + list(map(int, input().split()))\nASum, BSum = [0] * (N + 1), [0] * (M + 1)\nASum[0], BSum[0] = A[0], B[0]\nAOver, BOver = -1, -1\nfor i in range(1, N + 1):\n ASum[i] = ASum[i-1] + A[i]\n if AOver == -1 and ASum[i] > K: AOver = i - 1\nfor i in range(1, M + 1):\n BSum[i] = BSum[i-1] + B[i]\n if BOver == -1 and BSum[i] > K: BOver = i - 1\nif AOver == -1: AOver = N\nif BOver == -1: BOver = M\nans = 0\nimport bisect\nfor i in reversed(range(AOver + 1)):\n if i + BOver <= ans: break\n time = K - ASum[i]\n ans = max(ans, i + bisect.bisect_right(BSum, time) - 1)\n\nprint(ans)", "n, m, k = list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\nb = [0] + list(map(int, input().split()))\nfor i in range(1, n + 1):\n a[i] += a[i - 1]\nfor i in range(1, m + 1):\n b[i] += b[i - 1]\nans, j = 0, m\nfor i in range(n + 1):\n if a[i] > k: \n break\n while a[i] + b[j] > k:\n j -= 1\n if i + j > ans:\n ans = i + j\nprint(ans)\n\n", "N, M, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\nb = 0\ntb = 0\n\nfor i in range(M):\n if tb + B[i] > K:\n break\n tb += B[i]\n b = i+1\n\nans = [0, b]\nm = b\na = 0\nta = 0\n\nfor i in range(N):\n if ta + A[i] > K:\n break\n a = i+1\n ta += A[i]\n while True:\n if ta + tb > K:\n if b == 0:break\n b -= 1\n tb -= B[b]\n else:\n if a + b > m:\n m = a + b\n ans = [a, b]\n break\n\nprint((ans[0]+ans[1]))\n\n\n", "from sys import stdin\nnii=lambda:map(int,stdin.readline().split())\nlnii=lambda:list(map(int,stdin.readline().split()))\nfrom bisect import bisect_right\nfrom itertools import accumulate\n\nn,m,k=nii()\na=lnii()\nb=lnii()\nar=[0]+list(accumulate(a))\nbr=list(accumulate(b))\n\nans=0\nfor i in range(n+1):\n time=ar[i]\n if time>k:\n break\n t_ans=i\n inx=bisect_right(br,k-time)\n t_ans+=inx\n ans=max(ans,t_ans)\nprint(ans)", "from itertools import accumulate\nfrom bisect import bisect_left\n\nri = lambda S: [int(v) for v in S.split()]\n\n\ndef rii():\n return ri(input())\n\n\nN, M, K = rii()\nA = rii()\nB = rii()\n\ni = j = 0\n\npA = [0] + list(accumulate(A))\npB = [0] + list(accumulate(B))\n\nans = 0\nfor i, a in enumerate(pA):\n br = 0\n if K >= a:\n r = K - a\n br = i\n \n if r:\n j = bisect_left(pB, r)\n if j != len(pB):\n if pB[j] > r:\n j -= 1\n br += j\n \n ans = max(ans, br)\n\nprint(ans)", "import itertools\nn,m,k=map(int,input().split())\na=list(itertools.accumulate(list(map(int,input().split()))))\nb=list(itertools.accumulate(list(map(int,input().split()))))\na.insert(0,0)\na=[a[-i-1] for i in range(n+1)]\nb.insert(0,0)\nj=0\nans=0\nfor i in range(n+1):\n if a[i]<=k and j!=m+1:\n while a[i]+b[j]<=k:\n j+=1\n if j==m+1:\n break\n ans=max(ans,n-i+j-1)\nprint(ans)", "n,m,k = list(map(int,input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA,B = [0],[0]\n\nfor i in range(n):\n A.append(a[i] + A[i])\nfor i in range(m):\n B.append(b[i] + B[i])\n\nnum,x = 0,m\n\nfor i in range(n+1):\n if A[i] > k:\n break\n while A[i] + B[x] > k:\n x -= 1\n num = max(num, i + x)\n \nprint(num)\n\n\n", "n, m, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nimport itertools as it\nsa = [0] + list(it.accumulate(a))\nsb = [0] + list(it.accumulate(b))\nmaxi = 0\nj = m \nfor i in range(n+1):\n if sa[i] <= k:\n while sa[i] + sb[j] > k:\n j -= 1\n maxi = max(maxi, i + j)\n\nprint(maxi)\n\n\n\n\n", "n,m,k = map(int,input().split())\nshelfA = list(map(int,input().split()))\nshelfB = list(map(int,input().split()))\nprodA = [0]*(n+1)\nprodB = [0]*(m+1)\nfor i in range(1,n+1):\n prodA[i] = prodA[i-1] + shelfA[i-1]\nfor i in range(1,m+1):\n prodB[i] = prodB[i-1] + shelfB[i-1]\n\nans = -1\nj = m\nfor i in range(n+1):\n if(prodA[i]>k):\n break\n while(prodB[j] > k - prodA[i]):\n # print(prodB[j],j,k-prodA[i])\n j-=1\n # print(ans)\n ans = max(ans,i+j)\n\n\n\nprint(ans)", "def binary_search(arr, num):\n left = 0\n right = len(arr)-1\n while right-left > 0:\n mid = (left+right) // 2\n if arr[mid] > num:\n right = mid\n else:\n left = mid + 1\n if arr[left] > num:\n return left\n else:\n return len(arr)\n\ndef main():\n n, m, k = map(int , input().split())\n a_books = list(map(int , input().split()))\n b_books = list(map(int , input().split()))\n b_cum_sum = [0] * (m+1)\n for i in range(m):\n b_cum_sum[i+1] = b_cum_sum[i] + b_books[i]\n current = 0\n ans = 0\n for i in range(n+1):\n if i > 0:\n current += a_books[i-1]\n if current > k:\n break\n rest = k - current\n index = binary_search(b_cum_sum, rest)\n ans = max(ans, i+index-1)\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "N, M, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\ncumsum_a = [0] * (N + 1)\ncumsum_b = [0] * (M + 1)\n\nfor i in range(1, N + 1):\n cumsum_a[i] = cumsum_a[i - 1] + A[i - 1]\n\nfor i in range(1, M + 1):\n cumsum_b[i] = cumsum_b[i - 1] + B[i - 1]\n\nans = 0\nbi = M\nfor i in range(N+1):\n for j in range(bi, -1, -1):\n t = cumsum_a[i] + cumsum_b[j]\n if t <= K:\n ans = max(ans, i + j)\n bi = j\n break\n\nprint(ans)\n", "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\ns = sum(B)\nans = 0\ni, j = 0, M - 1\nwhile i < N:\n #print(s, i, j)\n if s <= K:\n ans = max(ans, i + j + 1)\n s += A[i]\n i += 1\n else:\n if j < 0: break\n s -= B[j]\n j -= 1\nif s <= K:\n ans = max(ans, N + j + 1)\nprint(ans)", "N, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\na, b = [0], [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nfor i in range(M):\n b.append(b[i] + B[i])\nans, j = 0, M\nfor i in range(N + 1):\n if a[i] > K:\n break\n while b[j] > K - a[i]:\n j -= 1\n ans = max(ans, i + j)\nprint(ans)", "import sys\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nimport numpy as np\ndef main():\n n, m, k = map(int, input().split())\n a = np.array(readline().split(), np.int64)\n b = np.array(readline().split(), np.int64)\n aa = a.cumsum()\n ba = b.cumsum()\n r = np.searchsorted(ba, k, side='right') \n for i1, aae in enumerate(aa):\n if k < aae:\n break\n r = max(r, np.searchsorted(ba, k - aae, side='right') + i1 + 1)\n print(r)\n\ndef __starting_point():\n main()\n__starting_point()", "#172 \u7dd1\nfrom itertools import accumulate\nN,M,K=map(int,input().split())\nAlist=list(map(int,input().split()))\nBlist=list(map(int,input().split()))\ncumsum=list(accumulate(Alist))\nans=0\nnum=0\nflag=0\nflag1=0\nfor i in range(N):\n if cumsum[i]>K:\n suma=cumsum[i-1]\n break\nelse:\n flag1=True\n ans+=1\n num+=1\n suma=cumsum[i]\nans+=i #index\u6ce8\u610f\nnum+=i\nk=0\nwhile suma+Blist[k]<=K:\n suma+=Blist[k]\n k+=1\n num+=1\n if k==M:\n print(num)\n return\nans=max(ans,num)\nfor j in range(i+1):\n if flag1:\n suma-=Alist[i-j]\n else:\n suma-=Alist[i-1-j]\n num-=1\n while suma+Blist[k]<=K:\n suma+=Blist[k]\n k+=1\n num+=1\n ans=max(ans,num)\n if k>=M:\n flag=True\n break\n if flag:\n break\nans=max(ans,num)\nprint(ans)", "import sys\ndef input(): return sys.stdin.readline().rstrip()\nfrom itertools import accumulate\ndef main():\n n, m, k = map(int,input().split())\n A = [0] + list(map(int,input().split()))\n B = [0] + list(map(int,input().split()))\n A = list(accumulate(A))\n B = list(accumulate(B))\n ans = 0\n j = m\n for i in range(n + 1):\n if A[i] > k:\n break\n while A[i] + B[j] > k:\n j -= 1\n ans = max(ans, i + j)\n print(ans)\n\n\ndef __starting_point():\n main()\n__starting_point()", "n, m, k = list(map(int, input().split()))\naa = list(map(int, input().split()))\nbb = list(map(int, input().split()))\nasum = [0]\nbsum = [0]\n\nfor i in range(len(aa)):\n asum.append(asum[i]+aa[i])\nfor i in range(len(bb)):\n bsum.append(bsum[i]+bb[i])\n\nj = len(bsum)-1\nans = 0\nfor i in range(len(asum)):\n while j >= 0:\n if k >= asum[i] + bsum[j]:\n ans = max(ans, i+j)\n break\n else:\n j -= 1\n\n\nprint(ans)\n", "n,m,k = list(map(int,input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nA,B = [0],[0]\n \nfor i in range(n):\n A.append(a[i] + A[i])\nfor i in range(m):\n B.append(b[i] + B[i])\n \nnum,x = 0,m\n \nfor i in range(len(a)+1):\n if A[i] > k:\n break\n while A[i] + B[x] > k:\n x -= 1\n num = max(num, i + x)\n \nprint(num)\n \n", "N, M, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\n\n\ndef get_integral(nums):\n integral = [0]\n for i in range(0, len(nums)):\n integral.append(integral[i] + nums[i])\n\n return integral\n\n\nintegral_a = get_integral(A)\nintegral_b = get_integral(B)\n\nans = 0\nbestj = M\nfor i in range(N+1):\n ta = integral_a[i]\n if ta > K:\n break\n while ta + integral_b[bestj] > K:\n bestj -= 1\n\n best = i + bestj\n ans = max(best, ans)\n\nprint(ans)\n\n\n", "n,m,k = list(map(int, input().split()))\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\n\nfrom itertools import accumulate\nimport bisect\ncumsum_a = list(accumulate(a))\ncumsum_b = list(accumulate(b))\n\nans = 0\nfor i in range(1, n+1):\n if cumsum_a[i-1] > k:\n break\n \n cnt_b = bisect.bisect(cumsum_b, k - cumsum_a[i-1])\n ans = max(ans, i + cnt_b)\n\nfor i in range(1, m+1):\n if cumsum_b[i-1] > k:\n break\n \n cnt_a = bisect.bisect(cumsum_a, k - cumsum_b[i-1])\n ans = max(ans, i + cnt_a)\n\nprint(ans)", "import bisect\n\nN,M,K=map(int,input().split())\narr1=list(map(int,input().split()))\narr2=list(map(int,input().split()))\n\nA=[0]\nfor i in range(N):\n A.append(arr1[i]+A[-1])\nB=[0]\nfor i in range(M):\n B.append(arr2[i]+B[-1])\n\nans=0\nfor i in range(N+1):\n if A[i]>K:\n break\n j=bisect.bisect_right(B,K-A[i])-1\n ans=max(ans,i+j)\nprint(ans)", "from bisect import bisect_left\nN, M, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nSA = [0] * (N + 1)\nSB = [0] * (M + 1)\nfor i in range(N):\n SA[i+1] = SA[i] + A[i]\nfor i in range(M):\n SB[i+1] = SB[i] + B[i]\nresult = 0\nfor x in range(N+1):\n if SA[x] > K:\n break\n y = bisect_left(SB, K - SA[x] + 1) - 1\n result = max(result, x + y)\nprint(result)", "N,M,K=map(int,input().split())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\n \na=[0]\nb=[0]\nfor i in range(N):\n a.append(a[i]+A[i])\nfor i in range(M):\n b.append(b[i]+B[i])\n \n#print(a)\n#print(b)\n \nans=0\nj=M\nfor i in range(N+1):\n if a[i]>K:\n break\n while b[j]>K-a[i]:\n j-=1\n #print(i,j)\n ans=max(ans,i+j)\nprint(ans)", "def main(N, M, K, A, B):\n #print(f'K: {K}, A: {A}, B: {B}')\n\n Ai = [0]\n for i in range(N):\n Ai.append(Ai[i]+A[i])\n #print(f'Ai: {Ai}')\n\n Bj = [0]\n for j in range(M):\n Bj.append(Bj[j]+B[j])\n #print(f'Bj: {Bj}')\n\n ans = 0\n # len(A) = N+1, len(B) = M+1\n best_i = 0\n for j in range(M+1):\n tmp = 0\n for i in range(best_i, N+1):\n #print(f'i: {N-i}, j: {j}')\n #if Ai[N-i] + Bj[M-j] <= K:\n if Ai[N-i] + Bj[j] <= K:\n #tmp = N - i + M - j\n tmp = N - i + j\n best_i = i\n break\n #print(f'tmp: {tmp}')\n if tmp > ans:\n ans = tmp\n\n return ans\n \n\ndef __starting_point():\n N, M, K = list(map(int, input().split()))\n A = list(map(int, input().split()))\n B = list(map(int, input().split()))\n print((main(N, M, K, A, B)))\n\n\n__starting_point()", "n,m,k=map(int,input().split())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nx,i,j=0,0,0\na.append(10**9+1)\nb.append(10**9+1)\nwhile x+a[i]<=k:\n x+=a[i]\n i+=1\nmaxs=i\nfor c in range(n+m):\n if x+b[j]<=k:\n x+=b[j]\n j+=1\n maxs=max(maxs,i+j)\n else:\n if i>0:\n x=max(0,x-a[i-1])\n i-=1\nprint(maxs)", "import numpy as np\nimport bisect\nN,M,K= map(int, input().split())\nA=list(map(int, input().split()))\nB=list(map(int, input().split()))\nif A[0]>K and B[0]>K:print(0);return\n\nAsum=[0]\nfor i in range(N):\n if Asum[-1]+A[i]<=K:\n Asum.append(Asum[-1]+A[i]) \n else:break\nBsum=[0]\nfor j in range(M):\n if Bsum[-1]+B[j]<=K:\n Bsum.append(Bsum[-1]+B[j])\n else:break\n\nC=[]\nfor i in range(len(Asum)):\n C.append(bisect.bisect(Bsum,K-Asum[i])+i-1)\nprint(max(C))", "N,M,K = map(int,input().split())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\na = [0]\nfor i in range(N):\n a.append(a[i] + A[i])\nak = [i-K for i in a]\nb = [0]\nfor i in range(M):\n b.append(b[i] - B[i])\nimport bisect\nans = 0\nfor i in range(M+1):\n k = bisect.bisect_right(ak,b[i])\n if k > 0:\n ans = max(k+i-1,ans)\nprint(ans)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 7 11:05:00 2020\n\n@author: liang\n\"\"\"\n\n\"\"\"\n\u7247\u5074\u3092\u56fa\u5b9a\u3057\u3066\u3001\u305d\u308c\u305e\u308c\u306e\u30b1\u30fc\u30b9\u306b\u5bfe\u3057\u3066\u6700\u9069\u89e3\u3092\u6c42\u3081\u308b\n\u305d\u308c\u305e\u308c\u306e\u30b1\u30fc\u30b9\u306b\u3064\u3044\u3066\nindex(b_i) =< index(b_i-1)\n\u3067\u3042\u308b\u304b\u3089\u3001b\u306e\u6700\u5927\u5024best\u3092\u4fdd\u5b58\u3057\u3066\u63a2\u7d22\u3059\u308b\u3053\u3068\u3067\u91cd\u8907\u63a2\u7d22\u3092\u56de\u907f\u3067\u304d\u308b\n\"\"\"\nN, M, K = map(int, input().split())\n\nA = [0] + [int(x) for x in input().split()]\nB = [0] + [int(x) for x in input().split()]\n\ns_b = 0\nfor i in range(M+1):\n s_b += B[i]\n if s_b > K:\n s_b -= B[i]\n best = i - 1\n break\nelse:\n best = M\nres = best\n#print(res)\ns_a = 0\nfor i in range(N+1):\n # print(\"i\", i)\n s_a += A[i]\n if s_a > K:\n break\n for j in reversed(range(best+1)):\n #print(\"j\",j)\n if s_b <= K - s_a:\n if i + j > res:\n res = i + j\n best = j\n #print(i, j, s_a, s_b)\n break\n else:\n s_b -= B[j]\n \nprint(res)", "import numpy as np\nn, m, k = map(int, input().split())\nli_a = np.array(list(map(int, input().split())))\nli_b = np.array(list(map(int, input().split())))\na_i, b_i = np.hstack([np.array([0]),li_a.cumsum()]), np.hstack([np.array([0]),li_b.cumsum()])\n\nj = m\nans = 0\nfor i in range(n+1):\n if a_i[i]>k:\n break\n while(b_i[j] > k - a_i[i]):\n j -= 1\n ans = max(ans, i+j)\nprint(ans)", "n, m, k = list(map(int, input().split()))\na = [0] + list(map(int, input().split()))\nb = [0] + list(map(int, input().split()))\n\nfor i in range(1, n + 1):\n a[i] += a[i - 1]\n\nfor i in range(1, m + 1):\n b[i] += b[i - 1]\n\nans = 0\n\nb_cnt = m\n\nfor a_cnt in range(n + 1):\n if a[a_cnt] > k:\n continue\n\n while a[a_cnt] + b[b_cnt] > k:\n b_cnt -= 1\n\n ans = max(ans, a_cnt + b_cnt)\n\nprint(ans)\n\n", "from itertools import accumulate\nimport bisect\nn,m,k = map(int,input().split())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\na_c = [0] + list(accumulate(a))\nb_c = [0] + list(accumulate(b))\n\nresult = []\n\nfor i in range(n+1):\n if k >= a_c[i]:\n k_temp = k - a_c[i]\n b_idx = bisect.bisect_left(b_c, k_temp+1)\n result.append(i + b_idx - 1)\n else:\n pass\nresult.append(0)\nprint(max(result))", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect\n#from operator import itemgetter\n#from heapq import heappush, heappop\n#import numpy as np\n#import sympy\n#from scipy.sparse.csgraph import breadth_first_order, depth_first_order, shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson\n#from scipy.sparse import csr_matrix\nfrom decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN\nimport sys\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\nstdin = sys.stdin\n\nni = lambda: int(ns())\nnf = lambda: float(ns())\nna = lambda: list(map(int, stdin.readline().split()))\nnb = lambda: list(map(float, stdin.readline().split()))\nns = lambda: stdin.readline().rstrip() # ignore trailing spaces\n\nN, M, K = na()\nA = na()\nB = na()\nnow = 0\nct = 0\nx = -1\ny = 0\nans = 0\nfor i in range(N):\n if A[i] + now <= K:\n now += A[i]\n ct += 1\n x += 1\n else:\n break\nres = K - now\nans = ct\nwhile y < M:\n if res - B[y] >= 0:\n ct += 1\n ans = max(ct, ans)\n res -= B[y]\n y += 1\n elif res - B[y] < 0 and x >= 0:\n res += A[x]\n ct -= 1\n x -= 1\n else:\n break\nprint(ans)", "n, m , k = map(int, input().split())\n\na = list(map(int, input().split()))\n\nb = list(map(int, input().split()))\n\nA, B = [0], [0]\n\nfor i in range(n):\n A.append(A[i] + a[i])\nfor i in range(m):\n B.append(B[i] + b[i])\n\nans, j = 0, m\n\nfor i in range(n+1):\n if A[i] > k:\n break\n while B[j] > k - A[i]:\n j -= 1\n ans = max(ans,i+ j)\nprint(ans)", "n,m,k = map(int,input().split())\ntmp_a = list(map(int,input().split()))\ntmp_b = list(map(int,input().split()))\na = [0]\nb = [0]\nfor i in range(n):\n a.append(a[i]+tmp_a[i])\nfor i in range(m):\n b.append(b[i]+tmp_b[i])\n#print(a)\n#print(b)\nans = 0\nj = m\nfor i in range(n+1):\n if a[i] > k:\n break\n while b[j] > k - a[i]:\n j -= 1\n ans = max(ans,i+j)\nprint(ans)", "from itertools import accumulate\nimport bisect\nn, m, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nA = list(accumulate(A, initial=0))\nB = list(accumulate(B, initial=0))\nans = 0\nfor i, a in enumerate(A):\n remain = k - a\n if remain < 0:\n break\n tmp = i\n tmp += bisect.bisect_right(B, remain) - 1\n ans = max(ans, tmp)\nprint(ans)\n", "n, m, k = list(map(int, input().split(\" \")))\na = [int(i) for i in input().split(\" \")]\nb = [int(i) for i in input().split(\" \")]\nA = [0]\nB = [0]\nfor i in a:\n if A[-1] > k:\n break\n A.append(A[-1] + i)\nfor i in b:\n if B[-1] > k:\n break\n B.append(B[-1] + i)\n\nans = 0\nj = len(B) - 1\n\nfor i in range(len(A)):\n if A[i] > k:\n break\n while A[i] + B[j] > k:\n j -= 1\n ans = max(ans, i + j)\n\nprint(ans)\n", "n, m, k = list(map(int, input().split()))\naArr = list(map(int, input().split()))\nbArr = list(map(int, input().split()))\n\nt = sum(bArr)\nans = 0\nj = m\n\nfor i in range(n + 1):\n while j > 0 and t > k:\n j -= 1\n t -= bArr[j]\n if t > k:\n break\n ans = max(ans, i + j)\n if i == n:\n break\n t += aArr[i]\n\nprint(ans)\n"]
{"inputs": ["3 4 240\n60 90 120\n80 150 80 150\n", "3 4 730\n60 90 120\n80 150 80 150\n", "5 4 1\n1000000000 1000000000 1000000000 1000000000 1000000000\n1000000000 1000000000 1000000000 1000000000\n"], "outputs": ["3\n", "7\n", "0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
50,757
1e2ca9b397d6dc0024bc4968e0247f8e
UNKNOWN
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively. Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas. -----Constraints----- - 1 ≀ A, B, C ≀ 5000 - 1 ≀ X, Y ≀ 10^5 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: A B C X Y -----Output----- Print the minimum amount of money required to prepare X A-pizzas and Y B-pizzas. -----Sample Input----- 1500 2000 1600 3 2 -----Sample Output----- 7900 It is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.
["a,b,c,x,y = list(map(int,input().split()))\n\nif (a + b) <= 2 * c:\n print((a * x + b * y))\nelse:\n max_c = max(x,y)\n min_c = min(x,y)\n AB = 2 * c * max_c\n if x > y:\n SP = ((x - min_c) * a) + (2 * c * min_c)\n else:\n SP = ((y - min_c) * b) + (2 * c * min_c)\n print((min(AB,SP)))\n", "A, B, C, X, Y = map(int, input().split())\nans = float('INF')\nfor k in range(0, 2*max(X, Y)+1, 2):\n i = max(0, X - int(k/2))\n j = max(0, Y - int(k/2))\n ans = min(ans, A*i + B*j + C*k)\nprint(ans)", "# 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())\n# S = input()\n# n, *a = map(int, open(0))\nA, B, C, X, Y = 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)]\n# S = 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 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\nif 2 * C > A + B:\n print(A * X + B * Y)\nelse:\n if X > Y:\n print(min(2 * C * X, 2 * C * Y + A * (X - Y)))\n else:\n print(min(2 * C * Y, 2 * C * X + B * (Y - X)))", "A,B,C,X,Y,=list(map(int,input().split()))\nans=10000000000000\nfor i in range(0,max(X,Y)+1):\n ans=min(ans,2*i*C+max(0,X-i)*A+max(0,Y-i)*B)\nprint(ans)\n", "import sys\n\ninput = sys.stdin.readline\na, b, c, x, y= map(int, input().split())\nab = 2*c\ncount_x = 0\ncount_y = 0\nbuy_a = 0\nbuy_b = 0\nbuy_c = 0\n\nif ab < a+b:\n min_count = min(x,y)\n count_x = min_count\n count_y = min_count\n buy_c = 2*min_count\n if x - count_x > 0:\n if ab > a:\n buy_a += x - count_x\n else:\n buy_c += 2 * (x - count_x)\n \n elif y - count_y > 0:\n if ab > b:\n buy_b += y - count_y\n else:\n buy_c += 2*(y - count_y)\nelse:\n min_count = min(x,y)\n if min_count == x:\n buy_a = min_count\n if ab > b:\n buy_b += y\n else:\n buy_c += 2 * y\n else:\n buy_b = min_count\n if ab > a:\n buy_a += x\n else:\n buy_c += 2 * x\n\nprint(buy_a * a + buy_b * b + buy_c * c)", "A,B,C,X,Y = list(map(int,input().split()))\n\nresult = []\n\nif X > Y:\n result.append(A * X + B * Y + C * 0)\n result.append(A * (X - Y) + B * 0 + C * 2 * min(X,Y))\n result.append(A * 0 + B * 0 + C * 2 * max(X,Y))\nelif X < Y:\n result.append(A * X + B * Y + C * 0)\n result.append(A * 0 + B * ( Y - X ) + C * 2 * min(X,Y))\n result.append(A * 0 + B * 0 + C * 2 * max(X,Y))\nelse:\n result.append(A * X + B * Y + C * 0)\n result.append(A * 0 + B * 0 + C * 2 * max(X,Y))\n\nprint((min(result)))\n", "a,b,c,X,Y = map(int,input().split())\n\nmin1 = 10**10\nfor z in range(0,200001,2):\n x = max(0,X-z//2)\n y = max(0,Y-z//2)\n min1 = min(min1,a*x + b*y + c*z)\n\nprint(min1)", "def LI():\n return list(map(int, input().split()))\na,b,c,x,y = LI()\n\n\nans = float('INF')\n\nfor i in range(max(x,y)+1):\n ans = min(ans, a*max(0, x-i) + b*max(0, y-i) + c*2*i)\n\nprint(ans)", "a, b, c, x, y = map(int, input().split())\n\nans1 = x * a + y * b\n\nmin_xy = min(x, y)\nans2 = min_xy * 2 * c + (x - min_xy) * a + (y - min_xy) * b\n\nmax_xy = max(x, y)\nans3 = max_xy * 2 * c\n\nprint(min(ans1, ans2, ans3))", "A, B, C, X, Y = list(map(int, input().split()))\n\nans =0\n\nif A + B > 2 * C:\n ans += 2 * C * min(X,Y) \n if X > Y:\n ans += (X-Y) * min(2*C, A)\n else:\n ans += (Y-X) *min(2*C, B)\nelse:\n ans = A * X + B* Y\nprint(ans)", "a, b, c, x, y = map(int,input().split())\n\nmast = max(x,y)\nans = float('INF')\n\nfor i in range(mast+1):\n price = a * max(x-i,0) + b * max(y-i,0) + c *2 *i\n ans =min(ans,price) \n \nprint(ans)", "a,b,c,x,y=map(int,input().split())\n\nif a+b<=2*c:\n print(a*x+b*y)\nelse:\n if x<=y:\n if b<=2*c:\n print(2*c*x+b*(y-x))\n else:\n print(2*c*y)\n else:\n if a<=2*c:\n print(2*c*y+(x-y)*a)\n else:\n print(2*c*x)", "a, b, c, x, y = map(int, input().split())\n\nif x > y:\n cost = min(x*a+y*b, max(x, y)*2*c, y*2*c + (x-y)*a)\nelse:\n cost = min(x*a+y*b, max(x, y)*2*c, x*2*c + (y-x)*b)\n\nprint(cost)", "a, b, c, x, y = map(int, input().split())\n\nA_B = (a*x)+(b*y)\nAB = 2*c*max(x, y)\n\nif x == y:\n C = c*2*x\nelif x > y:\n C = (c*2*y) + a*(x-y)\nelse:\n C = (c*2*x) + b*(y-x)\n\nprint(min(A_B, AB, C))", "#!/usr/bin/env python3\n\ndef II(): return int(input())\ndef MII(): return list(map(int, input().split()))\ndef LII(): return list(map(int, input().split()))\n\ndef main():\n A, B, C, X, Y = MII()\n\n ans = A * X + B * Y\n for i in range(0, max(X, Y)+1):\n ans = min(ans, max(A * (X - i), 0) + max(B * (Y - i), 0) + C * 2 * i)\n\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "import math\n\nA, B, C, X, Y = map(int, input().split())\n\nans = A * X + B * Y\n\nif (A + B) / 2 < C:\n pass\nelse:\n for i in range(max(X * 2, Y * 2)+1):\n j = max(0, X - int(i / 2))\n k = max(0, Y - int(i / 2))\n\n ans = min(ans, i * C + j * A + k * B)\n\nprint(ans)", "a,b,c,x,y=map(int,input().split())\nif a+b<=2*c:\n print(a*x+b*y)\nelse:\n print(c*2*min(x,y)+min(max(a*(x-y),b*(y-x)),c*2*abs(x-y)))", "a, b, c, x, y = map(int, input().split())\nn = a * x + b * y\nm = 2 * c * max(x, y)\n\np = b if x < y else a\nl = 2 * c * min(x, y) + p * abs(x-y)\n\nans = min(n, min(m, l))\nprint(ans)", "a,b,c,x,y=list(map(int,input().split()))\n\n\nmoneys=[]\nfor i in range(0,max(x,y)*2+1,2):\n apizza=x-int(i/2)\n bpizza=y-int(i/2)\n if apizza<0:\n apizza=0\n if bpizza<0:\n bpizza=0\n money=apizza*a+bpizza*b+i*c\n moneys.append(money)\n\nprint((min(moneys)))\n", "a_price,b_price,ab_price,num_a,num_b = list(map(int, input().split()))\ntotal = 0\n\nif a_price + b_price < 2 * ab_price:\n\ttotal = a_price * num_a + b_price * num_b\n\nelif a_price + b_price >= 2 * ab_price:\n\tif num_a >= num_b:\n\t\tif a_price > ab_price * 2:\n\t\t\ttotal = ab_price * 2 * num_a\n\t\telse:\n\t\t\ttotal = ab_price * 2 * num_b + a_price * (num_a - num_b)\n\telse:\n\t\tif b_price > ab_price * 2:\n\t\t\ttotal = ab_price * 2 * num_b\n\t\telse:\n\t\t\ttotal = ab_price * 2 * num_a + b_price * (num_b - num_a)\n\nprint(total)\n\n", "A,B,C,X,Y = map(int,input().split())\nsumAB = A+B\nif sumAB >= 2*C:\n minXY = min(X,Y)\n ans = min(X,Y)*2*C\n X -= minXY\n Y -= minXY\n if X != 0:\n ans += X*min(A,2*C)\n elif Y !=0:\n ans += Y*min(B,2*C)\n print(ans)\n\nelse:\n print(A*X+Y*B)", "A, B, C, X, Y = map(int, input().split())\nans = 2*(5000*10**5)\nfor Z in range(10**5+1):\n total = A*max(X-Z, 0)+B*max(Y-Z, 0)+2*C*Z\n ans = min(total,ans)\nprint(ans)", "def slove():\n A,B,C,X,Y = map(int,input().split())\n \"\"\"\n possible combinations are below.\n A * x + B * y \n if x < y: B * abs(x-y) + C * min(x,y) * 2\n if x > y: A * abs(x-y) + C * min(x,y) * 2\n C * max(x,y) * 2\n \"\"\"\n ans1 = A * X + B * Y\n if X<Y:\n ans2 = B * abs(X-Y) + C * 2 * min(X,Y)\n else:\n ans2 = A * abs(X-Y) + C * 2 * min(X,Y)\n \n ans3 = C * 2 * max(X,Y)\n print(min(ans1,ans2,ans3)) \n\ndef __starting_point():\n slove()\n__starting_point()", "\nA,B,C,X,Y = list(map(int, input().split()))\n\nans1 = (2*C)*min(X,Y) + A*(X-min(X,Y)) + B*(Y-min(X,Y))\nans2 = A*X + B*Y\nans3 = 2*C*max(X,Y)\n\nans = min(ans1,ans2,ans3)\nprint(ans)\n\n", "###########\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\na, b, c, x, y = map(int,input().split())\n\nn = a*x+b*y\nm = c * 2 * max(x,y)\np = a if x>y else b\nl = c*2*min(x,y)+p*abs(x-y)\nans = min(n,min(m,l))\n\nprint(ans)", "l = list(map(int, input().split()))\nA, B, C, X, Y = l[0], l[1], l[2], l[3], l[4]\ns_1, s_2, s_3 = 0, 0, 0\n\ns_1 = A*X + B*Y\n\nmaxv = max([X, Y])\ns_2 = 2*C*max([X, Y])\nif X >= Y:\n s_3 = 2*C*Y + A*(X-Y)\nelse:\n s_3 = 2*C*X + B*(Y-X)\n\nprint((min([s_1, s_2, s_3])))\n", "\n\nA, B, C, X, Y = list(map(int,input().split()))\n\nans = 0\n\nab_total = (C*2) * max(X,Y)\n\nif C*2 < A+B:\n ans += min(X,Y) * (C*2)\n if X > Y:\n ans += (X - Y) * A\n else:\n ans += (Y - X) * B\nelse:\n ans = A*X + B*Y\n\nif ab_total < ans:\n print(ab_total)\nelse:\n print(ans)\n", "\n\n\na,b,c,x,y = list(map(int,input().split()))\n\nprice = a * x + b * y\n\n\nfor i in range(max(x,y) + 1):\n ab = 2 * i\n cand = ab * c + a * max(0, x - i) + b * max(0, y-i)\n\n price = min(price, cand)\n\nprint(price)\n \n", "import math\na, b, c, x, y = list(map(int, input().split(' ')))\nans = float('inf')\nc = c*2\nfor i in range(max(x, y)+1):\n ans = min(ans, a*max(0, x-i)+b*max(0,y-i)+c*i)\nprint(ans)\n", "#n = int(input())\na, b, c, x, y = list(map(int, input().split()))\n#al = list(map(int, input().split()))\n#al=[list(input()) for i in range(n)]\nmn = a*x+b*y\nfor i in range(0, max(x, y)+1):\n mn = min(mn, max(x-i, 0)*a+max(y-i, 0)*b+2*i*c)\nprint(mn)\n", "A,B,C,X,Y = map(int,input().split())\nmoneys = []\n\nfor i in range(0,2*max(X,Y)+1,2):\n if X-i//2 >= 0 and Y-i//2 >= 0:\n moneys.append((X-i//2)*A + (Y-i//2)*B + C*i)\n elif X-i//2 >= 0 and Y-i//2 < 0:\n moneys.append((X-i//2)*A + C*i)\n elif X-i//2 < 0 and Y-i//2 >= 0:\n moneys.append((Y-i//2)*B + C*i)\n else:\n moneys.append(C*i)\n \nprint(min(moneys))", "A, B, C, X, Y = map(int, input().split())\n\nans = 10 ** 9\n\nfor c in range(max(X, Y)+1):\n a = max(X - c, 0)\n b = max(Y - c, 0)\n\n cost = A * a + B * b + C * 2 * c\n ans = min(cost, ans)\n\nprint(ans)", "a,b,c,x,y = map(int,input().split())\n\npiza_min = min(x,y)\n\nplan1 = c*piza_min*2 + a*(x-piza_min) + b*(y-piza_min)\nplan2 = a*x + b*y\nplan3 = c*max(x,y)*2\n\nprint(min(plan1,plan2,plan3))", "a,b,c,x,y=map(int,input().split())\nif (a+b)>2*c:\n if x>y:\n if a>2*c:\n print(y*2*c+(x-y)*c*2)\n else:\n print(y*2*c+(x-y)*a)\n\n else:\n if b>2*c:\n print(x*2*c+(y-x)*c*2)\n else:\n print(x*2*c+(y-x)*b)\nelse:\n print(x*a+y*b)", "a,b,c,x,y = list(map(int, input().split()))\n\nm = min(x,y)\nc2 = min(a+b, 2*c)\nans = c2*m\nx -= m\ny -= m\nif x:\n ans += min(a, 2*c)*x\nif y:\n ans += min(b, 2*c)*y\nprint(ans)\n", "a,b,c,x,y = list(map(int, input().split()))\nans = int(1e9)\nfor i in range(max(x,y)*2+1):\n ans = min(ans, c*i+a*max(0, x-i//2)+b*max(0, y-i//2))\n\nprint(ans)\n", "a,b,c,x,y = list(map(int,input().split()))\nif x<y:\n a,b,x,y=b,a,y,x\n\nif a+b<2*c:\n ans=a*x+b*y\nelse:\n if a>2*c:\n ans = c*2*x\n else:\n ans = c*2*y + a*(x-y)\nprint(ans)\n", "a, b, c, x, y = list(map(int, input().split()))\nsum = a + b\nif x > y:\n cost = a\nelse:\n cost = b\n\n\nif sum > 2 * c:\n if x == y:\n total = 2 * x * c\n pass\n else:\n total = 2 * min(x, y) * c\n num = (max(x, y)-min(x, y))\n if cost * num < 2 * num * c:\n total += cost * num\n else:\n total += 2 * num * c\n\nelif sum == 2 * c:\n if x == y:\n total = x * 2 * c\n pass\n else:\n total = min(x, y) * 2 * c\n num = (max(x, y)-min(x, y))\n if cost * num < 2 * c * num:\n total += cost * num\n else:\n total += num * 2 * c\nelse:\n total = a * x + b * y\n\nprint(total)\n", "a, b, c, x, y = list(map(int, input().split()))\n\nans = [a * x + b * y]\n\nif x >= y:\n ans.append(2 * c * y + (x - y) * a)\n ans.append(2 * c * x)\nelse:\n ans.append(2 * c * x + (y - x) * b)\n ans.append(2 * c * y)\n\nprint((min(ans)))\n", "a, b, c, x, y = map(int, input().split())\nans = 0\nans += 2*c*min(x, y)\nif x < y:\n ans += (y-x)*b\nelse:\n ans += (x-y)*a\n\nans = min(ans, a*x+b*y)\nprint(min(ans, 2*c*max(x, y)))", "A,B,C,X,Y=map(int,input().split())\ndpr=min(A+B,2*C)\nApr=min(A,2*C)\nBpr=min(B,2*C)\n\ndam=dpr*min(X,Y)\nif X>=Y:\n sam=Apr*(X-Y)\nelse:\n sam=Bpr*(Y-X)\n \nprint(dam+sam)", "A, B, C, X, Y = map(int, input().split())\nans = 5000 * 1000000\nfor i in range(0, max(X, Y)*2 + 1, 2): \n x = max(0, X - i//2)\n y = max(0, Y - i//2)\n ans = min(ans, A*x + B*y + C*i)\nprint(ans)", "# C - Half and Half\nA,B,C,X,Y = map(int,input().split())\n\n# AB \u30d4\u30b6\u3092\u8cb7\u308f\u306a\u3044\u5834\u5408\npay1 = X*A + Y*B\n# A \u30d4\u30b6 \u3092 AB \u30d4\u30b6\u3067\u4f5c\u308b\u5834\u5408\npay2 = 10**10\nif Y >= X:\n pay2 = C*2*X + B*(Y-X)\n# B \u30d4\u30b6\u3092 AB \u30d4\u30b6\u3067\u4f5c\u308b\u5834\u5408\npay3 = 10**10\nif X >= Y:\n pay3 = A*(X-Y) + C*2*Y\n# AB \u30d4\u30b6\u3067\u5168\u90e8\u4f5c\u308b\u5834\u5408\npay4 = C*max(X,Y)*2\nprint(min(pay1,pay2,pay3,pay4))", "A, B, C, X, Y = map(int, input().split())\n\nprice = 0\n\nm = min(A + B , C * 2)\nn = min(X, Y)\nprice += m * n\n\nd = max(X, Y) - min(X, Y)\nif d != 0:\n if X > Y:\n price += min(A, C * 2) * d\n else:\n price += min(B, C * 2) * d\n\nprint(price)", "3\n#coding: utf-8\n\nA, B, C, X, Y = (int(x) for x in input().split())\n\nret = 0\nif A + B > C * 2:\n m = min(X, Y)\n X -= m\n Y -= m\n ret += m * C * 2\n\nif X > 0:\n if A > C * 2:\n ret += X * C * 2\n else:\n ret += X * A\n\nif Y > 0:\n if B > C * 2:\n ret += Y * C * 2\n else:\n ret += Y * B\n\nprint(ret)\n", "A,B,C,X,Y=map(int,input().split())\n\nab = min(2*C, A+B)\na = min(2*C, A)\nb = min(2*C, B)\n\nif X <= Y:\n ans = X * ab + (Y - X) * b\nelse:\n ans = Y * ab + (X - Y) * a\nprint(ans)", "A,B,C,X,Y = list(map(int,input().split()))\nif A+B<=2*C:\n print((A*X+B*Y))\nelse:\n if X>=Y:\n if 2*C*Y+A*(X-Y)>=2*C*X:\n print((2*C*X))\n else:\n print((2*C*Y+A*(X-Y)))\n else:\n if 2*C*X+B*(Y-X)>=2*C*Y:\n print((2*C*Y))\n else:\n print((2*C*X+B*(Y-X)))\n", "a,b,c,x,y=map(int,input().split())\np = a*x + b*y\nq = 2*c*max(x,y)\nr = 2*c*x + b*(y-x)\ns = 2*c*y + a*(x-y)\nif x >=y:\n print(min(p,q,s))\nelse:\n print(min(p,q,r))", "a, b, c, x, y = list(map(int, input().split()))\n\nans = 10**10\nfor i in range(10**5+1):\n price = a*max(x-i, 0) + b*max(y-i, 0)+ i*2*c \n ans = min(ans, price)\nprint(ans)\n", "A,B,C,X,Y=map(int,input().split())\n\nans=0\nif C*2<=A+B:\n mi=min(X,Y)\n ans=mi*C*2\n if Y<=X:\n ans+=min(A*(X-mi),2*C*(X-mi))\n else:\n ans+=min(B*(Y-mi),2*C*(Y-mi))\nelse:\n ans=A*X+B*Y\nprint(ans)", "# -*- coding: utf-8 -*-\n\nA,B,C,X,Y = list(map(int, input().split()))\n\nans = 10000 * 10**5\nfor z in range(10**5+1):\n x = max(X-z, 0)\n y = max(Y-z, 0)\n yen = A*x + B*y + 2*C*z\n if ans > yen:\n ans = yen\n\nprint(ans)\n", "a, b, c, x, y = map(int, input().split())\nprint(min(a*x+b*y, 2*c*x + b*max(0,y-x), 2*c*y + a*max(0, x-y)))", "A, B, C, X, Y = map(int, input().split())\nans = float(\"inf\")\nfor i in range(0, max(X, Y)*2 + 1, 2): \n x = max(0, X - i//2)\n y = max(0, Y - i//2)\n ans = min(ans, A*x + B*y + C*i)\nprint(ans)", "a,b,c,x,y = [int(x) for x in input().split()]\nres = 0\nif a + b > 2 * c:\n res += min(x,y) * 2 * c\n if x == min(x,y):\n if b > 2 * c:\n res += (y - min(x,y)) * 2 * c\n else:\n res += (y - min(x,y)) * b\n else:\n if a > 2 * c:\n res += (x - min(x,y)) * 2 * c\n else:\n res += (x - min(x,y)) * a\nelse:\n res += a * x\n res += b * y\nprint(res)", "A, B, C, X, Y = list(map(int, input().split()))\nans = 10**10\nfor i in range(10**5+1):\n ans = min(ans, A*max(X-i, 0)+B*max(Y-i, 0)+2*C*i)\nprint(ans)\n", "# C\nA,B,C,X,Y = list(map(int,input().split()))\nans = 0\nif 2*C >= A + B:\n ans = A*X+B*Y \nelse:\n x = min(X,Y)\n ans = min(X,Y)*(2*C)\n if (X-x)*A + (Y-x)*B > (X+Y-2*x)*(2*C):\n ans += (X+Y-2*x)*(2*C)\n else:\n ans += (X-x)*A + (Y-x)*B\nprint(ans)\n", "a, b, c, x, y = map(int, input().split(' '))\n\nc = int(c*2)\nm = float('inf')\nfor i in range(10**5+1):\n m = min(m, a*max(0, x-i)+b*max(0,y-i)+c*i)\nprint(m)", "a,b,c,x,y = list(map(int, input().split()))\n\nmincost = a*x+b*y\nfor z in range(max(x,y)+1):\n x_ = max(0, x-z)\n y_ = max(0, y-z)\n cost = 2*c*z + a*x_ + b*y_\n mincost = min(mincost, cost)\n\nprint(mincost)\n", "a, b, c, x, y = map(int, input().split())\n\nab = a * x + b * y\ncc = c * 2 * max(x, y)\nabcc = c * 2 * min(x, y) + (b if x < y else a) * abs(x - y)\n\nprint(min(ab, cc, abcc))", "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, x, y = Input()\n\n if a + b < c * 2:\n print(a * x + b * y)\n return\n\n if x == y:\n print(c * x * 2)\n else:\n if x > y:\n temp = x - y\n print(min(2*c*x, 2*c*y+temp*a))\n else:\n temp = y - x\n print(min(2*c*y, 2*c*x+temp*b))\n\n\nmain()", "A,B,C,X,Y =map(int,input().split())\nres = 2 * C * max(X,Y)\nif X > Y:\n res = min(2 * C * Y + (X-Y) * A,res)\nelse:\n res = min(2 * C * X + (Y-X) * B,res)\nres = min(A*X+B*Y,res)\n\nprint(res)", "a,b,c,x,y=map(int,input().split())\nprint(min(a*x+b*y,(max(x,y)*c*2),min(x,y)*c*2+max(0,x-min(x,y))*a+max(0,y-min(x,y))*b))", "import math\n\nA, B, C, X, Y = list(map(int, input().split()))\n\nmin_sum = A*X+B*Y\nfor c in range(0, (max(X, Y)*2)+1, 2):\n s = (max(X-math.floor(c/2), 0))*A + (max(Y-math.floor(c/2), 0))*B + c*C\n if s < min_sum:\n min_sum = s\nprint(min_sum)\n", "a, b, c, x, y = map(int, input().split())\n\nif a >= 2*c and b >= 2*c:\n print(max(x, y) * 2*c)\nelif a >= 2*c:\n print(x * 2*c + max(0, (y - x) * b))\nelif b >= 2*c:\n print(y * 2*c + max(0, (x - y) * a))\nelif a + b > 2*c and x < y:\n print(x * 2*c + (y - x) * b)\nelif a + b > 2*c:\n print(y * 2*c + (x - y) * a)\nelse:\n print(x * a + y * b)", "a, b, c, x, y = map(int,input().split())\nans = 1e10\nfor k in range(100010):\n ans = min(( 2 * c * k + max(x - k, 0) * a + max(y - k, 0) * b ),ans)\nprint(int(ans))", "a,b,c,x,y = map(int, input().split())\n\n# set x >= y\nif x < y: \n x,y = y,x\n a,b = b,a\n\nprice_1 = a*x + b*y\nprice_2 = a*(x-y) + 2*c*y\nprice_3 = 2*c*x\n\nprint(min(price_1, price_2, price_3))", "a, b, c, x, y = map(int, input().split())\n\nres = a*x + b*y\nfor i in range(1, max(x, y)+1):\n ab = i*2\n cand = ab*c + a*max(0, x-i) + b*max(0, y-i)\n\n res = min(res, cand)\n\nprint(res)", "A,B,C,X,Y=map(int, input().split())\nans=A*X+B*Y\na=0\nb=0\n\nfor i in range(1,1+2*max(X,Y)):\n if X-i/2<0:\n a=0\n else:\n a=X-i/2\n if Y-i/2<0:\n b=0\n else:\n b=Y-i/2\n ans = min(ans, A*a+B*b+C*i)\n \nprint(int(ans))", "a,b,c,x,y=map(int,input().split())\nresult=[]\nif(x>y):\n result.append(a*x+b*y)\n result.append(a*(x-y)+2*c*y)\n result.append(2*c*x)\nelif(x<y):\n result.append(a*x+b*y)\n result.append(b*(y-x)+2*c*x)\n result.append(2*c*y)\nelse:\n result.append(a*x+b*y)\n result.append(2*c*x)\nprint(min(result))", "A, B, C, X, Y = map(int, input().split())\n\ndif = abs(X - Y)\nrem = max(X, Y)\nif rem == X:\n E = A\nelse:\n E = B\n\ncom = rem - dif\nans = 0\n\nD = A + B\nif D < C * 2:\n ans += D * com\nelse:\n ans += C * com * 2\n\nif E < C * 2:\n ans += E * dif\nelse:\n ans += C * dif * 2\n\nprint(ans)", "A, B, C, X, Y = map(int, input().split())\n\nmini = float('inf')\n\nfor i in range(10**6 + 1):\n calc = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B\n if calc < mini:\n mini = calc\n\nprint(mini) ", "A,B,C,X,Y=map(int,input().split())\nif A+B<2*C:\n ans=A*X+B*Y\nelse:\n if X<=Y:\n ans=C*2*X\n if 2*C<=B:\n ans+=2*C*(Y-X)\n else:\n ans+=B*(Y-X)\n else:\n ans=C*2*Y\n if 2*C<=A:\n ans+=2*C*(X-Y)\n else:\n ans+=A*(X-Y)\nprint(ans)", "a,b,c,x,y = map(int,input().split())\nans = 0\nab = min(a+b,c*2)\ntemp = min(x,y)\nans += ab*temp\nx -= temp\ny -= temp\nans += min(a,c*2)*x \nans += min(b,c*2)*y\nprint(ans)", "A, B, C, X, Y = list(map(int, input().split()))\nans = 10000000000\ncost = 0\n\n# C for both A and B\ncost = max(X, Y) * C * 2\nans = min(ans, cost)\n\nif X > Y:\n cost = Y * C * 2\n cost1 = cost + (X - Y) * A\n cost2 = cost + (X - Y) * C * 2\n cost = min(cost1, cost2)\n ans = min(ans, cost)\nelse:\n cost = X * C * 2\n cost1 = cost + (Y - X) * B\n cost2 = cost + (Y - X) * C * 2\n cost = min(cost1, cost2)\n ans = min(ans, cost)\n\ncost = A * X + B * Y\nans = min(ans, cost)\n\nprint(ans)", "a, b, c, x, y = map(int,input().split())\nif x >= y:\n ans = min(a*x + b*y, a*(x-y) + 2*c*y, 2*c*x)\nelse:\n ans = min(a*x + b*y, b*(y-x) + 2*c*x, 2*c*y)\nprint(ans)", "a, b, c, x, y = map(int, input().split())\nans = 0\nif a+b >= c*2:\n ans = min(x,y)*c*2\n if x>y:\n if a > c*2:\n ans += c*2*(x-y)\n else:\n ans += a*(x-y)\n else:\n if b > c*2:\n ans += c*2*(y-x)\n else:\n ans += b*(y-x)\n\nelse:\n ans = a*x+b*y\nprint(ans)", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n a,b,c,x,y = map(int,input().split())\n ans1=99999999999999999999999999\n if a+b>2*c:\n if x > y:\n ans1=2*c*y+a*(x-y)\n elif y > x:\n ans1=2*c*x+b*(y-x)\n ans2=c*2*max(x,y)\n ans3=a*x+b*y\n print(min(ans1,ans2,ans3))\n\ndef __starting_point():\n main()\n__starting_point()", "A, B, C, X, Y = list(map(int, input().split()))\n\nans = float(\"inf\")\nfor c in range(200_001):\n cost = c * C\n cost += A * max(0, X - c // 2)\n cost += B * max(0, Y - c // 2)\n ans = min(ans, cost)\nprint(ans)\n", "A,B,C,X,Y = map(int,input().split())\nmin_xy = min(X,Y)\nmax_xy = max(X,Y)\nans1 = 2*C*min_xy + A*(X-min_xy)+B*(Y-min_xy)\nans2 = A*X+B*Y\nans3 = 2*C*max_xy\nprint(min(ans1,ans2,ans3))", "a,b,c,x,y = list(map(int, input().split()))\n\nans = a*x + b*y\nfor i in range(1, max(x,y)+1):\n C = 2*i*c + a*max(0,x-i) + b*max(0,y-i)\n ans = min(ans, C)\nprint(ans)\n", "A, B, C, X, Y = list(map(int,input().split()))\n\nmin_p = 100000000000000\nfor c in range(0, max(X, Y)*2+1):\n a = X - int(c / 2)\n b = Y - int(c / 2)\n\n if a < 0 :\n a = 0\n if b < 0:\n b = 0\n\n p = A*a+B*b+C*c\n min_p = min(min_p, p)\nprint(min_p)\n", "a, b, c, x, y = map(int, input().split())\n\nanswer = 7000000000\nfor i in range(100001):\n amount = i*2*c + max(0, x-i)*a + max(0, y-i)*b\n if answer > amount:\n answer = amount\nprint(answer)", "a, b, c, x, y = list(map(int, input().split()))\nmmin = -1\n\n\ndef maxint(x, y: int) -> int:\n if x > y:\n return x\n else:\n return y\n\n\nmax = maxint(x, y)\nfor i in range(0, max+1):\n tmp = 2*c*i + a*(maxint(0, x-i))+b*(maxint(0, y-i))\n if mmin == -1:\n mmin = tmp\n continue\n if tmp < mmin:\n mmin = tmp\nprint(mmin)\n", "A, B, C, X, Y = map(int, input().split())\n\nimport math\nsaishou = math.inf\n\ntemp = 0\n\nfor i in range (0, X+1):\n\ttemp = A*i+C*2*(X-i)\n\tif X-i < Y:\n\t\tif 2*C <= B:\n\t\t\ttemp+=2*C*(Y-(X-i))\n\t\telse:\n\t\t\ttemp+=B*(Y-(X-i))\n\tif saishou > temp:\n\t\tsaishou = temp\n \nprint(saishou)", "a, b, c, x, y = list(map(int, input().split()))\n\nc *= 2\nt = 0\n\nif a+b > c:\n v = min([x,y])\n t = v * c\n x, y = x-v, y-v\n\n if x>0:\n if a<c:\n t = t + a*x\n else:\n t = t + c*x\n elif y>0:\n if b<c:\n t = t + b*y\n else:\n t = t + c*y\nelse:\n t = a*x + b*y\n\nprint(t)\n", "a, b, c, x, y = map(int, input().split())\nif x > y:\n cost = min(a*x + b*y, x*c*2, y*c*2 + (x-y)*a)\nelse:\n cost = min(a*x + b*y, y*c*2, x*c*2 + (y-x)*b)\n\nprint(cost)", "A, B, C, X, Y = map(int,input().split())\nans = float('inf')\nfor i in range(0, max(X,Y)+1):\n num = i*2*C + max(0, X-i)*A + max(0, Y-i)*B\n ans = min(ans, num)\nprint(ans)", "a,b,c,x,y = map(int,input().split())\nans = 0\nif a >= c*2:\n y -= x\n ans += c*2*x\n x = 0\nif b >= c*2 and y > 0:\n ans += c*2*y\n x -= y\n y = 0\nelif a+b >= c*2:\n t = min(max(x,0),max(y,0))\n x -= t\n y -= t\n ans += t*2*c\nif y > 0:\n ans += b * y\nif x > 0:\n ans += a*x\nprint(ans)", "a,b,c,x,y = map(int,input().split())\nc *= 2\nans = 10 ** 16\nfor i in range(max(x,y)+1):\n m = 0\n m += (a*(max(0,x-i)))+(b*(max(0,y-i)))+(c*i)\n ans = min(ans,m)\nprint(ans)", "A, B, C, X, Y = list(map(int, input().split()))\nans = float('INF')\nfor i in range(0, 2*max(X, Y)+1, 2):\n ans = min(ans, int(A*max(0, X-i/2)+B*max(0, Y-i/2)+C*i))\nprint(ans)\n", "import sys\ndef readint():\n return int(sys.stdin.readline())\n\ndef readints():\n return tuple(map(int,sys.stdin.readline().split()))\n\ndef readintslist(n):\n return [tuple(map(int,sys.stdin.readline().split())) for _ in range(n)]\n\ndef main():\n a,b,c,x,y = readints()\n\n a_pizza = [a*i for i in range(x+1)]\n b_pizza = [b*i for i in range(y+1)]\n ab_pizza = [2*c*i for i in range(max(x,y)+1)]\n\n ans = []\n for i in range(max(x,y)+1):\n ans.append(a_pizza[max(x-i,0)]+b_pizza[max(y-i,0)]+ab_pizza[i])\n print(min(ans))\ndef __starting_point():\n main()\n__starting_point()", "A, B, C, X, Y = map(int, input().split())\n\nans = max(A, B, C) * (X + Y)\nfor i in range(max(X, Y) * 2 + 1):\n price = i * C\n price += max(X - i//2, 0) * A\n price += max(Y - i//2, 0) * B\n ans = min(ans, price)\n # print(i, X-i//2, Y-i//2, price, ans)\nprint(ans)", "import math\na, b, c, x, y = map(int, input().split(' '))\nans = float('inf')\nc = c*2\nfor i in range(max(x, y)+1):\n if i > x:\n price = b*(y-i) + c*i\n elif i > y:\n price = a*(x-i) + c*i\n else:\n price = a*(x-i) + b*(y-i) + c*i\n\n if ans > price:\n ans = price\nprint(ans)", "a,b,c,x,y=map(int,input().split())\np = a*x + b*y\nq = 2*c*max(x,y)\nr = 2*c*x + b*(y-x)\ns = 2*c*y + a*(x-y)\nif x >=y:\n print(min(p,q,s))\nelse:\n print(min(p,q,r))", "a,b,c,x,y = map(int,input().split())\nans = 0\nif a >= c*2:\n y -= x\n ans += c*2*x\n x = 0\nif b >= c*2 and y > 0:\n ans += c*2*y\n x -= y\n y = 0\nelif a+b >= c*2:\n t = min(max(x,0),max(y,0))\n x -= t\n y -= t\n ans += t*2*c\nif y > 0:\n ans += b * y\nif x > 0:\n ans += a*x\nprint(ans)", "A,B,C,X,Y=map(int,input().split())\nif 2*C <= A+B:\n price= 2*C\nelse:\n price = A+B\nmaxN = max(X,Y)\nminiN = min(X,Y)\nres = miniN * price\nresidue = maxN - miniN\nif residue == 0:\n print(res)\nelif X > Y:\n res+= min(residue*A, residue*2*C)\n print(res)\nelif Y > X:\n res += min(residue*B, residue*2*C)\n print(res)", "A,B,C,X,Y = map(int,input().split())\nans = 10**10\nfor k in range(max(X,Y)+1):\n i = max((X-k),0)\n j = max((Y-k),0)\n price = A*i + B*j + C*2*k\n ans = min(ans,price)\n\nprint(ans)", "A, B, C, X, Y = list(map(int, input().split()))\n\nif A+B <= 2*C:\n print((A*X+B*Y))\nelse:\n if X <= Y:\n print((min(2*C*Y, 2*C*X+B*(Y-X))))\n else:\n print((min(2*C*X, 2*C*Y+A*(X-Y))))\n", "# coding: utf-8\n\n\ndef main():\n A, B, C, X, Y = list(map(int, input().split()))\n ans = 0\n min_p = min(X, Y)\n d = X - Y\n\n if A + B > 2 * C:\n ans += 2 * C * min_p\n else:\n ans += (A + B) * min_p\n\n if d > 0:\n if A > 2 * C:\n ans += 2 * C * d\n else:\n ans += A * d\n elif d < 0:\n if B > 2 * C:\n ans += 2 * C * -d\n else:\n ans += B * -d\n\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "A,B,C,X,Y=map(int,input().split())\n\np_A=A*X\np_B=B*Y\ntotal=p_A+p_B\n\nif X>Y:\n\ta=X-Y\n\tab=Y*C*2\n\ttotal_ab=C*X*2\n\ttotal_1=ab+a*A\n\tprint(min(total_1,total,total_ab))\n\nelif X<Y:\n\tb=Y-X\n\tab=X*C*2\n\ttotal_ab=C*Y*2\n\ttotal_2=ab+b*B\n\tprint(min(total_2,total,total_ab))\n\nelif X==Y:\n\tab=C*X*2\n\tprint(min(ab,total))"]
{"inputs": ["1500 2000 1600 3 2\n", "1500 2000 1900 3 2\n", "1500 2000 500 90000 100000\n"], "outputs": ["7900\n", "8500\n", "100000000\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
29,400
b875b9f77a17feaa2523ce9c53ab2118
UNKNOWN
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7. -----Constraints----- - 1≀N≀10^3 -----Input----- The input is given from Standard Input in the following format: N -----Output----- Print the number of the positive divisors of N!, modulo 10^9+7. -----Sample Input----- 3 -----Sample Output----- 4 There are four divisors of 3! =6: 1, 2, 3 and 6. Thus, the output should be 4.
["N = int(input())\nmod = 1000000007\nfrom collections import Counter\nY = Counter()\nfor i in range(2, N+1):\n M = i\n for j in range(2,i+1):\n while M % j == 0:\n Y[j] += 1\n M //= j\n\ndef product(X):\n res = 1\n for x in X:\n res *= x + 1\n res %= mod\n return res \n\nans = product(Y.values())\nprint(ans)", "# \u9ad8\u901f\u7d20\u56e0\u6570\u5206\u89e3\n# \"\"\"2\u4ee5\u4e0a\u306e\u6574\u6570n => [[\u7d20\u56e0\u6570, \u6307\u6570], ...]\u306e2\u6b21\u5143\u30ea\u30b9\u30c8\"\"\"\n\ndef 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\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\nn=int(input())\n\ncount=[0]*(n+1)\nfor i in range(1,n+1):\n if i==1:\n pass\n else:\n soinsuu_list=factorization(i)\n for soinsu,jisu in soinsuu_list:\n count[soinsu]+=jisu\nans=1\nmod=10**9+7\nfor i in count:\n ans*=(i+1)\n ans=ans%mod\nprint(ans)\n", "import math\nprime = [2, 3, 5]\nfor i in range(7, 1001, 2):\n sqi = math.sqrt(i)\n for j in prime:\n if i % j == 0:\n break\n if sqi < j:\n prime.append(i)\n break\n\ndef legendre(n, p):\n if n == 0:\n return 0\n else:\n return n // p + legendre(n // p, p)\n\nN = int(input())\npower_of_prime = [legendre(N, p) for p in prime]\n\ncnt = 1\nfor i in range(len(power_of_prime)):\n cnt = (cnt * (power_of_prime[i] + 1)) % 1000000007\nprint(cnt)\n", "from collections import deque\n\np=10**9+7\ndef primelist(n):\n l=deque([2])\n stack=deque()\n t=1\n for x in range(3,n+1,2):\n flag=0\n for y in tuple(l):\n if x%y==0:\n flag=1\n break\n if flag==0:\n l.append(x)\n return l\n\ndef main():\n n=int(input())\n l=primelist(n)\n ans=1\n while l:\n q=l.pop()\n s=0\n c=1\n while n//(q**c):\n s+=n//(q**c)\n c+=1\n ans=ans*(s+1) % p\n print(ans)\n\nmain()\n", "x = int(input())\na = []\ndef cont(y):\n n = 0\n while True:\n if n - int(y ** (1/2)) + 1 == 0:\n a.append(y)\n break\n \n for j in range(2,int(y ** (1/2)) + 1):\n if y % j == 0:\n y = y // j\n a.append(j)\n n = 0\n break\n else:\n n = n + 1\n\nans = 1\nfor k in range(2, x + 1):\n cont(k)\nfor h in range(2, x + 1):\n ans = ans * (a.count(h) + 1)\n\nprint(ans % 1000000007)", "from collections import defaultdict\n\n\n# \u7d20\u56e0\u6570\u5206\u89e3\nd = defaultdict(int)\n\n\ndef prime_factorize(n):\n while n % 2 == 0:\n d[2] += 1\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n d[f] += 1\n n //= f\n else:\n f += 2\n if n != 1:\n d[n] += 1\n return\n\n\nN = int(input())\nMOD = int(1e9) + 7\nans = 1\nfor i in range(1, N+1):\n prime_factorize(i)\nfor v in d.values():\n ans = ans * (v + 1) % MOD\nprint(ans)", "import math\nN = int(input())\nm = math.factorial(N)\nA = 1000*[1]\nans = 1\n\nfor n in range(2,1001):\n while m%n==0:\n m//=n\n A[n]+=1\n\nfor a in A:\n ans*=a\n\nprint(ans%(10**9+7))", "import collections\n\nn = int(input())\nmod = 10**9+7\n\ndef 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\nd = collections.defaultdict(int)\nfor i in range(2,n+1):\n for j in factorization(i):\n d[j[0]] += j[1]\n\nans = 1\nfor v in d.values():\n ans *= (v+1)\nprint(ans%mod)", "import math\n\nn = int(input())\nif n == 1:\n print((1))\n return\ndp = [0] * (n+1)\nmod = 10**9+7\n\ndef sieve_of_erastosthenes(num):\n input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]\n input_list[0] = input_list[1] = False\n input_list[2] = input_list[3] = input_list[5] = True\n sqrt = math.sqrt(num)\n\n for serial in range(3, num, 2):\n\n if serial >= sqrt:\n return input_list\n\n for s in range(serial ** 2, num, serial): \n input_list[s] = False\n\nprime = sieve_of_erastosthenes(1000)\nprime = [i for i, t in enumerate(prime) if t]\n\nfor i in range(2, n+1):\n v = i\n while v < n+1:\n dp[i] += 1\n v += i\n\ndp2 = [0] * (n+1)\nfor p in prime:\n v = p\n k = 1\n while v < n+1:\n dp2[p] += dp[v]\n v *= p\n k += 1\n\nans = 1\nfor i in range(n+1):\n ans = (ans * (dp2[i]+1)) % mod\nprint(ans)\n", "from collections import defaultdict\n\ndef prime_factorization(n):\n arr=[]\n temp=n\n for i in range(2,int(n**0.5)+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 \n if temp!=1:\n arr.append([temp,1])\n \n if arr==[]:\n arr.append([n,1])\n \n return arr\n\nN=int(input())\nmod=10**9+7\nprimes=defaultdict(int)\nfor n in range(1,N+1):\n for num,cnt in prime_factorization(n):\n primes[num]+=cnt\n\nans=1\nfor n,cnt in primes.items():\n if n==1:\n continue\n ans*=cnt+1\n ans%=mod\nprint(ans)", "from collections import defaultdict\n\nN = int(input())\n\nprime_counts = defaultdict(int)\n\nfor i in range(2, N + 1):\n n = i\n for p in prime_counts:\n while True:\n if n % p == 0:\n prime_counts[p] += 1\n n = n // p\n else:\n break\n if n > 1:\n prime_counts[n] += 1\n\nd = 1\nfor c in prime_counts.values():\n d *= (1 + c)\nprint(d % (10 ** 9 + 7))", "mod = 1000000000 + 7\n\ndef 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\nn = int(input())\ndat = [0] * 2000 # \u7d04\u6570\u3068\u3057\u3066\u6c42\u3081\u3089\u308c\u305f\u3042\u308b\u6570\u306e\u5408\u8a08\n\n# N! \u306e\u5404\u8981\u7d20\u306e\u7d20\u56e0\u6570\u5206\u89e3\u3092\u3059\u308b\nres = 1\nfor i in range(1, n + 1):\n d = factorization(i)\n for j in range(len(d)):\n dat[d[j][0]] += d[j][1]\n\nfor i in range(2, n + 1):\n res *= (dat[i] + 1)\n res %= mod\n\nprint(res)", "from math import factorial\n\nn = int(input())\nf = factorial(n)\n\nmod = 10 ** 9 + 7\n\ndef primes(n):\n is_prime = [True] * (n + 1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n ** 0.5) + 1):\n if not is_prime[i]:\n continue\n for j in range(i * 2, n + 1, i):\n is_prime[j] = False\n return [i for i in range(n + 1) if is_prime[i]]\n\nans = 1\nfor p in primes(n):\n temp = 1\n while f % p == 0:\n temp += 1\n f //= p\n ans = (ans * temp) % mod\nprint(ans)\n", "import collections\n\nn = int(input())\nmod = 10**9 + 7\ndef 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 \n if temp!=1:\n arr.append([temp, 1])\n \n if arr==[]:\n arr.append([n, 1])\n \n return arr\n\ntmp = collections.defaultdict(int)\n\nfor i in range(1, n+1):\n for j , k in factorization(i):\n tmp[j] += k\n\nans = 1\nfor tei, si in list(tmp.items()):\n if tei == 1:\n continue\n else:\n ans *= si + 1\n ans %= mod\n\nprint(ans)\n", "N = int(input())\nmod = 10**9 + 7\n\ndef factorization(n):\n arr, 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\nA = {}\nfor i in range(1, N+1):\n arr = factorization(i)\n for k, v in arr:\n if k != 1:\n if k not in A:\n A[k] = v\n else:\n A[k] += v\n\nans = 1\nfor v in A.values():\n ans *= v + 1\n ans %= mod\n\nprint(ans)", "N = int(input())\nA = [a for a in range(2, N+1)]\nT = 1\nwhile len(A)>0:\n X = A[0]\n T *= sum(N//(X**i) for i in range(1, 11))+1\n A = [a for a in A if a%A[0]]\nprint(T%(10**9+7))", "prime = [False] * 1001\n\nfor i in range(2,1001):\n\tif prime[i] == False:\n\t\tfor j in range(i*i,1001,i):\n\t\t\tprime[j]=True\n\nn = int(input())\n\ncnt = [0] * 1001\nfor i in range(2,n+1):\n\tfor j in range(2,n+1):\n\t\tif prime[j] == False:\n\t\t\tval = i\n\t\t\twhile val%j==0:\n\t\t\t\tcnt[j]+=1\n\t\t\t\tval/=j\n\nans=1\n\nfor x in cnt:\n\tans*=(x+1)\n\tans%=1000000007\n\nprint(ans)", "import collections\nn = int(input())\nx = []\ndef factorization(n):\n d = []\n while n % 2 == 0:\n d.append(2)\n n /= 2\n f = 3\n while f*f <= n:\n if n % f == 0:\n d.append(int(f))\n n /= f\n else:\n f += 2\n if n != 1:\n d.append(n)\n return d\n\nfor i in range(n, 1, -1):\n x += factorization(i)\n\nc = collections.Counter(x)\nl = list(c.values())\nans = 1\n\nfor i in range(len(l)):\n ans *= 1 + l[i]\n\nprint(ans % (7+10**9))", "n = int(input())\na = [1] * n\nans = 1\n\nfor i in range(1,n+1):\n b = 2\n \n while i != 1:\n if i % b == 0:\n i //= b\n a[b-1] += 1\n else:\n b += 1\n \nfor i in a:\n if 1 < i:\n ans *= i\n ans %= 10**9 + 7\n \nprint(ans)", "mod=10**9+7\nimport math\nn=int(input())\nans=1\nl=[0]*n\nfor ii in range(2,n+1):\n i=ii\n for j in range(2,int(math.sqrt(i))+1):\n if i%j==0:\n cnt=0\n while i%j==0:\n cnt+=1;i//=j\n l[j-1]+=cnt\n if i!=1:\n l[i-1]+=1\nfor i in l:\n ans*=(i+1)\n ans%=mod\nprint(ans)\n", "def prime_factorize(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\n\nN=int(input())\ntotal=1\nans=1\ninf=10**9+7\ntotal=[0]*1000\nfor i in range(1,N+1):\n temp=prime_factorize(i)\n for j in range(len(temp)):\n total[temp[j]-1]+=1\n\n\nfor i in range(1000):\n ans*=total[i]+1\n ans%=inf\nprint(ans)", "import math\n\nn = int(input())\nif n == 1:\n print((1))\n return\ndp = [0] * (n+1)\nmod = 10**9+7\n\ndef sieve_of_erastosthenes(num):\n input_list = [False if i % 2 == 0 or i % 3 == 0 or i % 5 == 0 else True for i in range(num)]\n input_list[0] = input_list[1] = False\n input_list[2] = input_list[3] = input_list[5] = True\n sqrt = math.sqrt(num)\n\n for serial in range(3, num, 2):\n\n if serial >= sqrt:\n return input_list\n\n for s in range(serial ** 2, num, serial): \n input_list[s] = False\n\nprime = sieve_of_erastosthenes(1000)\nprime = [i for i, t in enumerate(prime) if t]\n\nfor i in range(2, n+1):\n v = i\n while v < n+1:\n dp[i] += 1\n v += i\n\ndp2 = [0] * (n+1)\nfor p in prime:\n v = p\n k = 1\n while v < n+1:\n dp2[p] += dp[v]\n v *= p\n k += 1\n\nans = 1\nfor i in range(n+1):\n ans = (ans * (dp2[i]+1)) % mod\nprint(ans)\n", "n = int(input())\n\narr = [0] * (n+1)\n\nfor i in range(1,n+1):\n x = []\n while i % 2 == 0:\n x.append(2)\n i = i // 2\n f = 3\n while f * f <= i:\n if i % f == 0:\n x.append(f)\n i = i // f\n else:\n f += 2\n if i != 1:\n x.append(i)\n\n for k in range(len(x)):\n arr[x[k]] += 1\n\nans = 1\nfor i in range(len(arr)):\n ans *= (arr[i] + 1)\nprint((ans % (10**9 + 7)))\n", "import math\nN = int(input())\nans = 1\nq = [1 for i in range(N + 1)]\nfor i in range(2,N + 1):\n k = i\n for i2 in range(2,i + 1):\n while k % i2 == 0:\n k /= i2\n q[i2] += 1\n \nfor i in range(N + 1):\n ans *= q[i]\n ans %= 10 ** 9 + 7\n\nprint(ans)", "N=int(input())\nl=[0]*1000\ndef divisor_enu(N):\n l=[]\n for i in range(2,int(N**0.5)+1):\n cnt=0\n if N%i==0:\n while N%i==0:\n cnt+=1\n N//=i\n l.append((i,cnt))\n if N != 1:\n l.append((N,1))\n return l\nfor i in range(1,N+1):\n s=divisor_enu(i)\n for j in s:\n l[j[0]]+=j[1]\nans=1\nmod=10**9+7\nfor i in l:\n if 0<i:\n ans=ans*(i+1)%mod\nprint(ans)", "n = int(input())\n\nji = {}\nans = 1\nm = 1000000007\nfor i in range(n):\n tmp = i + 1\n j = 2\n while tmp != 1:\n if tmp % j == 0:\n if not j in ji:\n ji[j] = 0\n \n ji[j] += 1\n tmp /= j\n else:\n j += 1 \n\nfor i in list(ji.values()):\n ans *= (i + 1)\n ans %= m\n \n\nprint(ans)\n", "n=int(input())\nd={}\nfor x in range(2,n+1):\n while x%2<1:\n x//=2\n d[2]=d.get(2,0)+1\n for i in range(3,int(x**0.5)+1,2):\n while x%i<1:\n x//=i\n d[i]=d.get(i,0)+1\n if x<2: break\n if x>1: d[x]=d.get(x,0)+1\na=1\nfor v in d.values(): a=a*(v+1)%(10**9+7)\nprint(a)", "def make_prime_table(n):\n sieve = list(range(n + 1))\n sieve[0] = -1\n sieve[1] = -1\n for i in range(4, n + 1, 2):\n sieve[i] = 2\n for i in range(3, int(n ** 0.5) + 1, 2):\n if sieve[i] != i:\n continue\n for j in range(i * i, n + 1, i * 2):\n if sieve[j] == j:\n sieve[j] = i\n return sieve\n\n\ndef prime_factorize(n):\n result = []\n while n != 1:\n p = prime_table[n]\n e = 0\n while n % p == 0:\n n //= p\n e += 1\n result.append((p, e))\n return result\n\n\nN = int(input())\n\nm = 1000000007\n\nprime_table = make_prime_table(N)\n\nt = [0] * (N + 1)\nfor i in range(2, N + 1):\n for p, e in prime_factorize(i):\n t[p] += e\n\nresult = 1\nfor i in range(2, N + 1):\n if t[i] == 0:\n continue\n result = result * (t[i] + 1) % m\nprint(result)\n", "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\nMOD = 10 ** 9 + 7\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 sieve(n):\n is_prime = [True for _ in range(n+1)]\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n**0.5)+1):\n if is_prime[i]:\n for j in range(i*2, n+1, i):\n is_prime[j] = False\n return [i for i in range(n+1) if is_prime[i]]\n\ndef primeFactorization(n, primes):\n ans = []\n temp = n\n for p in primes:\n while temp%p == 0:\n ans.append(p)\n temp //= p\n if temp > 1:\n ans.append(temp)\n return collections.Counter(ans)\n\ndef resolve():\n N = I()\n\n primes = sieve(N)\n cnt = collections.Counter()\n \n for i in range(2, N + 1):\n pf = primeFactorization(i, primes)\n for k, v in list(pf.items()):\n cnt[k] += v\n\n ans = 1\n for i in list(cnt.values()):\n ans *= (i + 1)\n ans %= MOD\n\n print(ans)\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "n = int(input())\nmod = 10**9+7\n\ndef factors(N):\n factors = []\n while N%2 == 0:\n factors.append(2)\n N //=2\n\n for f in range(3, int(N**0.5)+ 1, 2):\n while N%f == 0:\n factors.append(f)\n N //= f\n if N != 1:\n factors.append(N)\n return factors\n\ncd = dict()\nfor i in range(1, n+1):\n facs = factors(i)\n for f in facs:\n cd.setdefault(f, 0)\n cd[f] += 1\n\nans = 1\nfor key, v in list(cd.items()):\n ans *= (v+1)\n ans %= mod\n\nprint(ans)\n", "# \u30a8\u30e9\u30c8\u30b9\u30c6\u30cd\u30b9\u306e\u7be9, \u7d20\u56e0\u6570\u5206\u89e3\ndef make_prime_table(n):\n sieve = list(range(n + 1))\n sieve[0] = -1\n sieve[1] = -1\n for i in range(2, int(n ** 0.5) + 1):\n if sieve[i] != i:\n continue\n for j in range(i * i, n + 1, i):\n if sieve[j] == j:\n sieve[j] = i\n return sieve\n\n\ndef prime_factorize(n):\n result = []\n while n != 1:\n p = prime_table[n]\n c = 0\n while n % p == 0:\n n //= p\n c += 1\n result.append((p, c))\n return result\n\n\nN = int(input())\n\nm = 1000000007\n\nprime_table = make_prime_table(N)\n\nt = [0] * (N + 1)\nfor i in range(2, N + 1):\n for p, e in prime_factorize(i):\n t[p] += e\n\nresult = 1\nfor i in range(2, N + 1):\n if t[i] == 0:\n continue\n result = result * (t[i] + 1) % m\nprint(result)\n", "n = int(input())\ndiv_map = dict()\nmod = 10 ** 9 + 7\n\nfor i in range(1, n + 1):\n is_prime_number = True\n for j in range(2, int(i ** (1 / 2)) + 1):\n if i % j == 0:\n is_prime_number = False\n break\n if is_prime_number:\n if i not in div_map:\n div_map[i] = 1\n else:\n div_map[i] += 1\n else:\n j = 2\n while i != 1:\n if i % j == 0:\n if j not in div_map:\n div_map[j] = 1\n else:\n div_map[j] += 1\n i //= j\n else:\n j += 1\n\n\nres = 1\ndiv_map[1] = 0\nfor key, value in list(div_map.items()):\n res = res * (value + 1) % mod\n\nprint((res % mod))\n", "n = int(input())\n\nji = {}\nans = 1\nfor i in range(n):\n tmp = i + 1\n j = 2\n while tmp != 1:\n if tmp % j == 0:\n if not j in ji:\n ji[j] = 0\n \n ji[j] += 1\n tmp /= j\n else:\n j += 1 \n\nfor i in list(ji.values()):\n ans *= (i + 1)\n\nprint((ans % 1000000007))\n", "n = int(input())\ncounter = [0]*(n+1)\nfor i in range(2, n+1):\n num = i\n j = 2\n while j*j <= num:\n cnt = 0\n while num%j == 0:\n counter[j] += 1\n num //= j\n j += 1\n if num != 1:\n counter[num] += 1\nans = 1\nfor i in range(n+1):\n if counter[i] > 0:\n ans *= counter[i] + 1\n ans %= int(1e9+7)\nprint(ans)\n \n", "#!/usr/bin/env python3\n\nn = int(input())\nmod = 10**9+7\n\nis_prime = [True for _ in range(1100)]\nis_prime[0] = is_prime[1] = False\nfor i in range(2, 1100):\n if not is_prime[i]: continue\n for j in range(i*i, 1100, i): \n is_prime[j] = False\n\nind = []\n\nfor p in range(2, 1100):\n if is_prime[p]:\n cnt = 0 \n for m in range(2, n+1):\n while m%p == 0:\n m //= p\n cnt += 1\n if cnt != 0:\n ind.append(cnt)\n\n#print('ind =', ind)\nans = 1 \nfor i in range(len(ind)):\n ans *= (ind[i]+1)\n\nprint((ans%mod))\n", "import math\nn=int(input())\nmod=10**9+7\nans=1\ncnt=[0]*1000\nfor i in range(2,n+1):\n x=i\n for j in range(2,int(math.sqrt(n))+1):\n while x%j==0:\n cnt[j]+=1\n x/=j\n if x!=1:\n cnt[int(x)]+=1\nfor i in cnt:\n if i!=0:\n ans*=(i+1)\n ans%=mod\nprint(int(ans))", "from collections import Counter\n\ndef factor(n):\n Ret = []\n for i in range(2, n + 1):\n while n % i == 0:\n n = n // i\n Ret.append(i)\n if len(Ret) == 0:\n return [n, ]\n else:\n return Ret\n\nn = int(input())\nfact = []\n\nfor i in range(2, n + 1):\n fact += factor(i)\n\nans = 1\nfor k, v in Counter(fact).items():\n ans *= v + 1\n ans %= 10**9 + 7\nprint(ans)", "MOD = 10**9+7\nmemo = [0]*10000\n\nN = int(input())\n\ndef primeLst(k):\n acc = []\n if k == 1:\n return acc\n f = 2\n while f * f <= k:\n if k % f == 0:\n acc.append(f)\n k //= f\n else:\n f += 1\n if k != 1:\n acc.append(k)\n return acc\n\nfor i in range(N):\n l = primeLst(i+1)\n for x in l:\n memo[x] += 1\n\nres = 1\nfor i in range(1,N):\n res *= memo[i+1] + 1\n res %= MOD\n\nprint(res)", "N = int(input())\nfrom collections import defaultdict\narr = defaultdict(int)\nfor i in range(2,N+1):\n temp = i\n f = True\n for j in range(2, int(-(-i**0.5//1))+1):\n if temp%j==0:\n cnt=0\n while temp%j==0:\n cnt+=1\n temp //= j\n f = False\n arr[j] += cnt\n if temp!=1:\n f = False\n arr[temp] += 1\n if f:\n arr[i] += 1\nans = 1\nfor i in arr.values():\n ans *= i+1\n ans %= 10**9 + 7\nprint(ans)", "import sys\nfrom collections import Counter\n\nread = sys.stdin.read\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\nsys.setrecursionlimit(10 ** 9)\nINF = 1 << 60\nMOD = 1000000007\n\n\ndef main():\n N = int(readline())\n\n N_MAX = N\n\n min_factor = list(range(N_MAX + 1))\n min_factor[2::2] = [2] * (N_MAX // 2)\n for i in range(3, int(N_MAX ** 0.5) + 2, 2):\n if min_factor[i] != i:\n continue\n for j in range(i * i, N_MAX + 1, 2 * i):\n if min_factor[j] > i:\n min_factor[j] = i\n\n def prime_factorize_fast(n):\n a = Counter()\n while n != 1:\n a[min_factor[n]] += 1\n n //= min_factor[n]\n\n return a\n\n factors = Counter()\n\n for n in range(2, N + 1):\n factors += prime_factorize_fast(n)\n\n ans = 1\n for v in list(factors.values()):\n ans = ans * (v + 1) % MOD\n\n print(ans)\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "def PrimeDecomp(N,ConcFlag):\n if ConcFlag:\n if N<=1:\n return [1],1\n else:\n I = 2\n PrimeDec = []\n DivCount = 1\n while I*I<=N:\n Cnt = 0\n while N%I==0:\n N //= I\n PrimeDec.append(I)\n DivCount *= (Cnt+1)\n I += 1\n if N>=2:\n PrimeDec.append(N)\n DivCount *= 2\n return PrimeDec,DivCount \n else:\n if N<=1:\n return [1],[1],1\n else:\n I = 2\n PrimeDec = []\n PrimeCnt = []\n DivCount = 1\n while I*I<=N:\n Cnt = 0\n while N%I==0:\n N //= I\n Cnt += 1\n if Cnt>=1:\n PrimeDec.append(I)\n PrimeCnt.append(Cnt)\n DivCount *= (Cnt+1)\n I += 1\n if N>=2:\n PrimeDec.append(N)\n PrimeCnt.append(1)\n DivCount *= 2\n return PrimeDec,PrimeCnt,DivCount\n\ndef DivisorFactorial(N,FactDec,FactCnt,MemoFlag,Mod,ModFlag):\n if MemoFlag:\n if N<=1:\n FDivCnt = 1\n return FactDec,FactCnt,FDivCnt\n else:\n PrimeDec,PrimeCnt,_ = PrimeDecomp(N,False)\n for TP in range(0,len(PrimeDec)):\n if PrimeDec[TP] in set(FactDec):\n FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]\n else:\n FactDec.append(PrimeDec[TP])\n FactCnt.append(PrimeCnt[TP])\n FDivCnt = 1\n for TF in FactCnt:\n FDivCnt = [FDivCnt*(TF+1),(FDivCnt*(TF+1))%Mod][ModFlag]\n return FactDec,FactCnt,FDivCnt\n else:\n if N<=1:\n FDivCnt = 1\n return FactDec,FactCnt,FDivCnt\n else:\n for TN in range(2,N+1): \n PrimeDec,PrimeCnt,_ = PrimeDecomp(TN,False)\n for TP in range(0,len(PrimeDec)):\n if PrimeDec[TP] in set(FactDec):\n FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]\n else:\n FactDec.append(PrimeDec[TP])\n FactCnt.append(PrimeCnt[TP])\n FDivCnt = 1\n for TF in FactCnt:\n FDivCnt = [FDivCnt*(TF+1),(FDivCnt*(TF+1))%Mod][ModFlag]\n return FactDec,FactCnt,FDivCnt\nFactDec,FactCnt,FDivCnt = DivisorFactorial(int(input()),[],[],False,10**9+7,True)\nprint(FDivCnt)", "import math\nimport collections\n\nn = int(input())\n\nfactorial = 1\ndivisor = []\nans = 1\n\n\n# \u7d20\u6570\u3092\u6c42\u3081\u308b\u95a2\u6570\ndef get_prime(num):\n if num <= 1:\n return\n for i in range(2, num+1):\n while num % i == 0:\n divisor.append(i)\n num //= i\n\n\n# \u7d04\u6570\u306e\u6570 = (\u7d20\u6570x\u306e\u500b\u6570+1)(\u7d20\u6570y\u306e\u500b\u6570+1)(\u7d20\u6570z\u306e\u500b\u6570+1)...\n# \u65b9\u91dd\uff1a\u5165\u529b\u5024\u3092\u7d20\u56e0\u6570\u5206\u89e3\u3057\u3001\u5404\u7d20\u56e0\u6570\u306e\u500b\u6570\u3092\u6c42\u3081\u308b\n\n# n-i\u306e\u7d20\u56e0\u6570\u3092\u6c42\u3081\u308b\nfor j in range(2, n+1):\n get_prime(j)\n\n# print(divisor)\n\n# \u5404\u7d20\u56e0\u6570\u306e\u7d44\u307f\u5408\u308f\u305b\u6570\u3092\u6c42\u3081\u308b\ncount = collections.Counter(divisor)\n\nfor k in count.most_common():\n temp = list(k)[1]\n ans = ans * (temp + 1)\n\nans = ans % (10 ** 9 + 7)\n\nprint(ans)", "from math import sqrt\nn = int(input())\nd = {}\nmod = 10**9+7\nfor i in range(1,n):\n m = i+1\n\n for j in range(2, int(sqrt(i+1))+1):\n if m%j==0:\n while m%j==0:\n d[j] = d.get(j, 0)+1\n m //= j\n if m>1:\n d[m] = d.get(m,0)+1\n \nans = 1\nfor i in d:\n ans *= d[i]+1\n ans %= mod\nprint(ans)", "N = int(input())\n\nmod = 10 ** 9 + 7\n\n\ndef primes(n):\n is_prime = [True] * (n + 1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n**0.5) + 1):\n if not is_prime[i]:\n continue\n for j in range(i * 2, n + 1, i):\n is_prime[j] = False\n return [i for i in range(n + 1) if is_prime[i]]\n\n\nL = primes(N)\n\nans = [0] * (N + 1)\nfor i in range(2, N + 1):\n for j in L:\n if i < j:\n break\n while True:\n if i % j == 0:\n i //= j\n ans[j] += 1\n else:\n break\n\nans_num = 1\nfor i in range(2, N + 1):\n if ans[i] >= 1:\n ans_num *= ans[i] + 1 % mod\nprint((ans_num % mod))\n", "n = int(input())\ns = 1\nans = 1\nfor i in range(1, n+1):\n s *= i\nfor i in range(2, n+1):\n k = 1\n while s % i == 0:\n s = s // i\n k += 1\n ans *= k\nprint(ans % (10 ** 9 + 7))", "d={}\nfor i in range(int(input())+1):\n for j in d:\n while i%j<1: d[j]+=1; i//=j\n if i>1: d[i]=2\na=1\nfor v in d.values(): a=a*v%(10**9+7)\nprint(a)", "def erat(n):\n n+=1\n l=[1 for _ in range(n)]\n l[0],l[1]=0,0\n for i in range(4,n,2):\n l[i]=0\n for i in range(9,n,6):\n l[i]=0\n for i in range(6,n,6):\n if l[i-1]:\n for j in range((i-1)*(i-1),n,i-1):\n l[j]=0\n if l[i+1]:\n for j in range((i+1)*(i+1),n,i+1):\n l[j]=0\n return l\nprime=[]\nfor i in range(1001):\n if erat(1000)[i]:\n prime.append(i)\nn=int(input())\nu=[0]*1001\nfor i in range(1,n+1):\n for j in prime:\n while i%j==0:\n i//=j\n u[j]+=1\nans=1\nfor i in u:\n ans*=i+1\nprint(ans%(10**9+7))", "from operator import mul\nfrom functools import reduce\ndef PrimeDecomp(N,ConcFlag):\n if ConcFlag:\n if N<=1:\n return [1],1\n else:\n I = 2\n PrimeDec = []\n DivCount = 1\n while I*I<=N:\n Cnt = 0\n while N%I==0:\n N //= I\n PrimeDec.append(I)\n DivCount *= (Cnt+1)\n I += 1\n if N>=2:\n PrimeDec.append(N)\n DivCount *= 2\n return PrimeDec,DivCount \n else:\n if N<=1:\n return [1],[1],1\n else:\n I = 2\n PrimeDec = []\n PrimeCnt = []\n DivCount = 1\n while I*I<=N:\n Cnt = 0\n while N%I==0:\n N //= I\n Cnt += 1\n if Cnt>=1:\n PrimeDec.append(I)\n PrimeCnt.append(Cnt)\n DivCount *= (Cnt+1)\n I += 1\n if N>=2:\n PrimeDec.append(N)\n PrimeCnt.append(1)\n DivCount *= 2\n return PrimeDec,PrimeCnt,DivCount\n\ndef DivisorFactorial(N,FactDec,FactCnt,MemoFlag):\n if MemoFlag:\n if N<=1:\n FDivCnt = 1\n return FactDec,FactCnt,FDivCnt\n else:\n PrimeDec,PrimeCnt,_ = PrimeDecomp(N,False)\n for TP in range(0,len(PrimeDec)):\n if PrimeDec[TP] in set(FactDec):\n FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]\n else:\n FactDec.append(PrimeDec[TP])\n FactCnt.append(PrimeCnt[TP])\n FDivCnt = reduce(mul,[(T+1) for T in FactCnt])\n return FactDec,FactCnt,FDivCnt\n else:\n if N<=1:\n FDivCnt = 1\n return FactDec,FactCnt,FDivCnt\n else:\n for TN in range(2,N+1): \n PrimeDec,PrimeCnt,_ = PrimeDecomp(TN,False)\n for TP in range(0,len(PrimeDec)):\n if PrimeDec[TP] in set(FactDec):\n FactCnt[FactDec.index(PrimeDec[TP])] += PrimeCnt[TP]\n else:\n FactDec.append(PrimeDec[TP])\n FactCnt.append(PrimeCnt[TP])\n FDivCnt = reduce(mul,[(T+1) for T in FactCnt])\n return FactDec,FactCnt,FDivCnt\n \nN = int(input())\nFactDec,FactCnt,FDivCnt = DivisorFactorial(N,[],[],False)\nprint(FDivCnt%(10**9+7))", "import sys\nN = int(input())\n\ndef prime_factorize(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\n\nres = []\nresult = 1\nfor I in range(2,N+1):\n res += prime_factorize(I)\nfor J in set(res):\n result *= res.count(J) + 1\nprint(result % (10**9+7))", "import sys;input = lambda : sys.stdin.readline()\nimport collections\nN = int(input())\nd = collections.Counter()\nif N == 1:\n print(1)\nelse:\n for n in range(2, N + 1):\n while n % 2 == 0:\n d[2] += 1\n n //= 2\n i = 3\n while i * i <= n:\n if n % i == 0:\n while n % i == 0:\n d[i] += 1\n n //= i\n i += 2\n if n > 1:\n d[n] += 1\n ans = 1\n for k, v in d.items():\n ans = (ans * (v + 1)) % 1000000007\n print(ans)", "MOD = 10 ** 9 + 7\ndef prime_factorize(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\nn = int(input())\ncnt = [0]*10000\nsum = []\nfor i in range(2, n + 1):\n sum += prime_factorize(i)\n\nfor x in sum:\n cnt[x] += 1\nans = 1\nfor i in range(len(cnt)):\n if cnt[i] > 0:\n ans *= (cnt[i]+1)\nprint(ans % MOD)", "from collections import Counter\ndef f(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\n\nn = int(input())\nif n == 1:\n print(1)\n return\nd = {}\nmod = 10**9+7\nd[2] = 1\nfor i in range(3, n+1):\n x = f(i)\n c = Counter(x)\n for j in c.keys():\n if j not in d:\n d[j] = c[j]\n else:\n d[j] += c[j]\n d[j] = d[j] % mod\nans = 1\nfor i in d.keys():\n ans *= d[i]+1\nprint(ans%mod)", "import math\n\ndef 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\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\nn = int(input())\n\nex = [1]*1001\nans = 1\n\nfor i in range(2, n+1):\n n_fact = factorization(i)\n for j, k in n_fact:\n ex[j] += k\n\nfor i in ex:\n ans *= i\n ans %= (10**9+7)\nprint(ans)", "from collections import defaultdict\nmod = 10**9+7\n\ndef factorize(n):\n out=[]\n i = 2\n while 1:\n if n%i==0:\n out.append(i)\n n //= i\n else:\n i += 1\n if n == 1:break\n if i > int(n**.5+3):\n out.append(n)\n break\n \n return out\n \nN=int(input())\n\nif N==1:\n print(1)\n return\n\ncount = defaultdict(int)\nfor i in range(2,N+1):\n f = factorize(i)\n for j in range(len(f)):\n count[f[j]] += 1\n \nans = 1\nfor k in count.keys():\n ans *= count[k]+1 % mod\n \nprint(ans % mod)", "import collections\nn = int(input())\nt = 1\nfor i in range(1,n+1):\n t *= i\ndef prime_factorize(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\n\nc = collections.Counter(prime_factorize(t))\nans = 1\nfor _, v in c.items():\n ans *= (v + 1)\nprint(ans%(10**9+7))", "def prime_fact(N):\n M = N\n primes = []\n K = 2\n\n while K*K <= M:\n while N%K == 0:\n primes.append(K)\n N = N//K\n K += 1\n \n if N != 1:\n primes.append(N)\n\n return primes\n\nN = int(input())\nnums = [0]*1000\nans = 1\n\nfor i in range(2,N+1):\n P = prime_fact(i)\n for j in range(len(P)):\n nums[P[j]-1] += 1\n\nfor k in range(1000):\n ans = ans*(nums[k]+1)%1000000007\n\nprint(ans)", "import math\nn=int(input())\nans=1\ndic={}\nfor i in range(2,n+1):\n tmp=i\n for j in range(2,i+1):\n while tmp%j==0:\n tmp//=j\n if j in dic:\n dic[j]+=1\n else:\n dic[j]=1\nfor v in dic.values():\n ans=(ans*(v+1))%(10**9+7)\nprint(ans)", "def factrial(n): # \u8a66\u3057\u5272\u308a\u7b97\u6cd5\u3067\u7d20\u56e0\u6570\u5206\u89e3\n factors = []\n while n%2 == 0:\n factors.append(2)\n n //= 2\n \n for i in range(3, int(n**0.5)+1):\n while n%i == 0:\n factors.append(i)\n n //= i\n \n if n != 1: factors.append(n)\n \n return factors\n\n\nn = int(input())\nmod = 10**9+7\n\nd = {}\nfor i in range(1, n+1): # 1\u301cn\u307e\u3067\u306e\u5404\u5024\u3092\u7d20\u56e0\u6570\u5206\u89e3\n fac = factrial(i)\n for j in fac: # \u5206\u89e3\u3057\u3066\u53d6\u5f97\u3057\u305f\u8981\u7d20\u306e\u56de\u6570\u3092\u30ab\u30a6\u30f3\u30c8\n if j in d: d[j] += 1\n else: d[j] = 1\n\nans = 1\nfor k,v in d.items():\n # \u53d6\u5f97\u3057\u305f\u8981\u7d20\u306b1\u3092\u8db3\u3057\u305f\u5024\u3092\u5408\u8a08\u5024\u306b\u304b\u3051\u5408\u308f\u305b\u308b\n # \u7d04\u6570\u3068\u3057\u3066\"1\"\u306f\u30ab\u30a6\u30f3\u30c8\u3055\u308c\u3066\u3044\u306a\u3044\u70ba\u3001\u3053\u306e\u30bf\u30a4\u30df\u30f3\u30b0\u3067\u8ffd\u52a0\u3059\u308b\n ans *= (v+1) \n ans %= mod\nprint(ans)", "mod = 1000000000 + 7\n\ndef 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\nn = int(input())\ndat = [0] * 2000 # \u7d04\u6570\u3068\u3057\u3066\u6c42\u3081\u3089\u308c\u305f\u3042\u308b\u6570\u306e\u5408\u8a08\n\n# N! \u306e\u5404\u8981\u7d20\u306e\u7d20\u56e0\u6570\u5206\u89e3\u3092\u3059\u308b\nres = 1\nfor i in range(1, n + 1):\n d = factorization(i)\n for j in range(len(d)):\n dat[d[j][0]] += d[j][1]\n\nfor i in range(2, n + 1):\n res *= (dat[i] + 1)\n res %= mod\n\nprint(res)", "import math\nN = int(input())\nmod = 1000000007\nx = [1 for _ in range(1001)]\nSum = 1\n\nfor i in range(1, N + 1):\n z = i\n for j in range(2, int(math.sqrt(N)) + 1):\n while z % j == 0:\n x[j] += 1\n z = int(z / j)\n if z != 1:\n x[z] += 1\n\nfor i in x:\n Sum *= i\n Sum %= mod\n\nprint(Sum)\n", "import math\nurl = \"https://atcoder.jp//contests/abc052/tasks/arc067_a\"\n\n\ndef get_list_eratosthenes(n):\n if n < 2:\n return [0]*(n+1)\n prime = [1]*(n+1)\n prime[0] = prime[1] = 0\n for i in range(2, int(n**0.5) + 1):\n if not prime[i]: continue\n for j in range(i * 2, n + 1, i):\n prime[j] = 0\n return prime\n\n\ndef main():\n N = int(input())\n tmp = N\n primes = get_list_eratosthenes(N)\n ans = 1\n for p in range(2, N+1):\n if primes[p] == 0: continue\n cur = p\n num = 0\n while cur <= N:\n num += N // cur\n cur *= p\n ans *= (num + 1)\n ans %= 10**9+7\n print(ans)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nis_prime = [True] * 1005\nMOD = 10 ** 9 + 7\nis_prime[0] = is_prime[1] = False\nfactors = []\nfor i in range(2, n + 1):\n if is_prime[i]:\n cnt = 0\n for j in range(i * i, n + 1, i):\n is_prime[j] = False\n i_init = i\n while i <= n:\n cnt += n // i\n i *= i_init\n factors.append(cnt)\nans = 1\nfor x in factors:\n ans = ans * (x + 1) % MOD\nprint(ans)", "import sys\nimport math\nn = int(input())\nif n == 1:\n print(1)\n return\nprime_list = []\n #2\u304b\u3089n\u307e\u3067\u306e\u6570\u5b57\u3092search_list\u306b\u5165\u308c\u308b\nsearch_list = list(range(2,n+1))\nwhile True:\n #search_list\u306e\u5148\u982d\u306e\u5024\u304c\u221an\u306e\u5024\u3092\u8d85\u3048\u305f\u3089\u51e6\u7406\u7d42\u4e86\n if search_list[0] > math.sqrt(n):\n #prime_list\u306bsearch_list\u3092\u7d50\u5408\n prime_list.extend(search_list)\n break\n else:\n #search_list\u306e\u5148\u982d\u3092prime_list\u306b\u5165\u308c\u308b\n head_num = search_list[0]\n prime_list.append(head_num)\n #search_list\u306e\u5148\u982d\u3092pop\u3059\u308b\n search_list.pop(0)\n #head_num\u306e\u500d\u6570\u3092\u53d6\u308a\u9664\u304f\n search_list = [num for num in search_list if num % head_num != 0]\n#print(prime_list)\n########\u3053\u3053\u304b\u3089\u672c\u554f\u3092\u89e3\u304f#########\nans = 1\nfor x in prime_list:\n tmp = 0\n nl = 1\n while(x**nl <= n):\n tmp += n//(x**nl)\n nl += 1\n ans *= tmp+1\nif ans >= 10**9+7:\n ans %= (10**9+7)\nprint(ans)", "MOD = 10 ** 9 + 7\n\ndef sieve(n):\n srn = int(n ** 0.5) + 1\n f = [False] * (srn + 1)\n res = []\n for i in range(2, srn + 1):\n if f[i]:\n continue\n res.append(i)\n for j in range(2 * i, srn + 1, i):\n f[j] = True\n return res\n\ndef trial_division(n):\n res = dict()\n for i in range(2, n+1):\n m = i\n for p in pn:\n while m % p == 0:\n res[p] = res.get(p, 0) + 1\n m //= p\n if m == 1:\n break\n if m > 1:\n res[m] = res.get(m, 0) + 1\n return res\n\nN = int(input())\npn = sieve(N)\nfn = trial_division(N)\nres = 1\nfor f in fn.values():\n res *= (f + 1)\n res %= MOD\nprint(res)", "n = int(input())\nprime_lst = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]\nlst = [0 for _ in range(n)]\nfor i in range(1, n + 1):\n a = i\n for num in prime_lst:\n while a % num == 0:\n lst[num - 1] += 1\n a //= num\n if a != 1:\n lst[a - 1] += 1\nans = 1\nMOD = 10 ** 9 + 7\nfor num in lst:\n ans *= (num + 1)\n ans %= MOD\nprint(ans)", "#!/usr/bin/env python3\nimport sys\nfrom functools import reduce\n\nMOD = 1000000007 # type: int\n\n\ndef solve(N: int):\n from itertools import chain\n from collections import Counter\n from functools import reduce\n pu = PrimeUtil(N+1)\n c = Counter(chain.from_iterable(pu.factor_iter(i) for i in range(2, N+1)))\n return reduce(lambda a,b: a*(b+1)%MOD, list(c.values()), 1)\n\nclass PrimeUtil:\n\n def __init__(self, size):\n self.size = size\n self._init_table()\n \n def _init_table(self):\n from itertools import takewhile\n self._is_prime = [True] * self.size\n self._is_prime[0] = False\n self._is_prime[1] = False\n for i in takewhile(lambda x: x*x<=self.size, list(range(self.size))):\n if not self._is_prime[i]:\n continue\n for j in range(i+i, self.size, i):\n self._is_prime[j] = False\n\n def prime_iter(self):\n return [x for x in range(self.size) if self._is_prime[x]]\n\n def primes(self):\n return tuple(self.prime_iter())\n\n def factor_iter(self, n):\n from itertools import takewhile\n m = n\n for p in self.prime_iter():\n while m % p == 0:\n yield p\n m //= p\n if m == 1:\n return\n \n def factors(self, n):\n return tuple(self.factor_iter(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 N = int(next(tokens)) # type: int\n print((solve(N)))\n\ndef test():\n import doctest\n doctest.testmod()\n\ndef __starting_point():\n #test()\n main()\n\n__starting_point()", "n=int(input())\ntemp=[1,1]+[0]*(n-2)\nfor i in range(3,n+1):\n for j in range(2,i):\n while i%j==0:\n i=i//j\n temp[j-1]+=1\n if i!=1:\n temp[i-1]+=1\nans=1\nfor i in range(n-1):\n ans=(ans*(temp[i+1]+1))%(10**9+7)\nprint(ans)\n", "n=int(input())\nif n==1:\n print(1)\n return\nl=[0]*(n+1)#\u7d04\u65700~1000\u306e\u5404\u7dcf\u6570\nfor i in range(2,n+1):\n x=i\n j=2\n while j<n+1:\n if x%j==0:\n x//=j\n l[j]+=1\n else:\n j+=1\n#print(l)\nans=1\nfor i in range(len(l)):\n ans*=(l[i]+1)\n ans%=(10**9 +7)\nprint(ans)", "def p_factorize(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\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\n\n\nMOD = 10**9 + 7\nN = int(input())\nif N == 1:\n print(1)\nelse:\n prime = {}\n for i in range(2, N + 1):\n for p, n in p_factorize(i):\n try:\n prime[p] += n\n except KeyError:\n prime[p] = n\n ans = 1\n for n in prime.values():\n ans *= n + 1\n ans %= MOD\n\n print(ans)", "from collections import Counter\nfrom math import factorial\nN = int(input())\nMOD = 10 ** 9 + 7\n\ndef prime(n):\n b = 2\n while b * b <= n:\n while n % b == 0:\n n //= b\n a.append(b)\n b += 1\n if n > 1:\n a.append(n)\n\na = []\nprime(factorial(N))\nA = Counter(a)\nX = 1\nfor k, v in A.items():\n X *= (v + 1) % MOD\nprint(X % MOD)", "n=int(input())\nm=10**9+7\np=[1 for i in range(10000)]\np[0]=0\np[1]=0\nfor i in range(2,n+1):\n if p[i]==1:\n for j in range(i*i,n+1,i):\n p[j]=0\nans=1\nfor i in range(2,n+1):\n if p[i]:\n c=0\n k=i\n while n//k>0:\n c=c+(n//k)%m\n k=k*i\n ans=(ans*((c+1)%m))%m\nprint((ans%m))\n \n \n \n \n", "n = int(input())\narr = dict()\nk = set()\nfor h in range(2,n+1):\n i = h\n for j in range(2,int(-(-i**0.5//1))+1):\n if i%j == 0:\n cnt = 0\n while i%j == 0:\n cnt += 1\n i //= j\n if j not in arr:\n arr[j] = cnt\n k.add(j)\n else:\n arr[j] += cnt\n if i != 1:\n if i in arr:\n arr[i] += 1\n else:\n arr[i] = 1\n k.add(i)\nans = 1\nfor num in k:\n ans *= (arr[num]+1)\n ans = ans%(10**9+7)\nprint(ans)", "primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, \n 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,\n 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,\n 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229,\n 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283,\n 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359,\n 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431,\n 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491,\n 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, \n 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, \n 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, \n 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, \n 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, \n 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, \n 947, 953, 967, 971, 977, 983, 991, 997] \n\ndef nCr(n,r):\n N = 1\n R = 1\n for m in range(n-r,n+1):\n N *= m\n \n for m in range(2,r+1):\n R *= m\n \n return N//R\n \n\nn = int(input())\nprimes = [p for p in primes if p <= n]\nnumpow = []\nfor p in primes:\n i = 1\n tmp = 0\n divisor = p\n while divisor <= n:\n tmp += (n // divisor)\n i += 1\n divisor = p**i\n numpow.append(tmp)\n\nimport math \nnumpow = [i+1 for i in numpow]\ny = math.prod(numpow)\nprint((y % (10**9+7)))\n", "n = int(input())\ns = 1\nans = 1\nfor i in range(1, n+1):\n s *= i\nfor i in range(2, n+1):\n k = 1\n while s % i == 0:\n s = s // i\n k += 1\n ans *= k\nprint(ans % (10 ** 9 + 7))", "import math\nMOD=10**9+7\nN=int(input())\nans=1\nprime=set()\nprime.add(2)\nnumofdiv=[0]*(N+2)\nfor h in range(2,N+1):\n flag=1\n for j in prime:\n if h%j==0:\n flag=0\n break\n if flag==1:\n prime.add(h)\n\nfor i in range(2,N+1):\n for p in prime:\n while(i%p==0):\n numofdiv[p]+=1\n i//=p\n#print(numofdiv)\nfor q in range(N+2):\n ans*=numofdiv[q]+1\n ans%=MOD\nprint(ans)\n", "n = int(input())\n\nt = [0] * (n+1)\nfor j in range(2, n+1):\n y = j\n for i in range(2, n+1):\n while y % i == 0:\n t[i] += 1\n y = y//i\nans = 1\np = 10**9 + 7\nfor i in t:\n if i != 0:\n ans *= (i+1)\n ans %= p\nprint(ans)", "n = int(input())\nl = {}\nans = 1\n\nfor i in range(2, n + 1):\n for j in range(2, i + 1):\n if i%j == 0:\n cnt = 0\n while i%j == 0:\n i //= j\n cnt += 1\n if j in l:\n v = l[j]\n l[j] = cnt + v\n else:\n l[j] = cnt\nfor i in l.values():\n ans = ans*(i + 1)%(10**9 + 7)\n\nprint(ans)", "def bunkai(n):\n b = 2\n fct = []\n while b * b <= n:\n while n % b == 0:\n n //= b\n fct.append(b)\n b = b + 1\n if n > 1:\n fct.append(n)\n return fct\n\nn=int(input())\ns=[0]*(n+1)\nfor i in range(1,n+1):\n fact=bunkai(i)\n for j in fact:\n s[j]+=1\nans=1\n\nfor i in range(0,n+1):\n ans*=(s[i]+1)\n ans%=10**9+7\n\nprint(ans)\n\n\n\n\n", "n=int(input())\n\nsosuu = [2]\nA = 1000\nfor L in range(3, A, 2): # 2 \u4ee5\u5916\u306e\u7d20\u6570\u306f\u5947\u6570\u306a\u306e\u3067\n for L2 in sosuu:\n if L % L2 == 0:\n break # \u7d20\u6570\u3067\u306a\u3044\u3053\u3068\u304c\u308f\u304b\u3063\u305f\u3089\u305d\u308c\u4ee5\u4e0a\u30eb\u30fc\u30d7\u3059\u308b\u5fc5\u8981\u306f\u306a\u3044\n else: # break \u3067\u629c\u3051\u308b\u3053\u3068\u304c\u306a\u304b\u3063\u305f\u3089 L \u306f\u7d20\u6570\uff08Python \u7279\u6709\u306e\u5236\u5fa1\u69cb\u6587\uff09\n sosuu.append(L)\nans=[]\n\nfor i in sosuu:\n ch=1\n x=i\n while x<=n:\n ch+=n//x\n x=x*i\n \n ans.append(ch)\n\nans1=1\nmod=10**9+7\nfor j in ans:\n ans1=(ans1*j)%mod\n \nprint(ans1)", "a = int(input())\nb = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]\nc = [0 for _ in range(a)]\nfor i in range(1, a + 1):\n d = i\n for e in b:\n while d % e == 0:\n c[e - 1] += 1\n d //= e\n if d != 1:\n c[d - 1] += 1\nf = 1\ng = 10 ** 9 + 7\nfor h in c:\n f *= (h + 1)\n f %= g\nprint(f)", "N=int(input())\np=10**9+7\n\ndef primeryNum(n):\n n_=int(n**0.5)\n ary=list(range(n+1))\n ary[1]=0 \n for a in ary:\n if a>n_: break\n elif a==0: continue\n \n for i in range(a*2,n+1,a):\n ary[i]=0 \n return ary\n\nprimeryN=primeryNum(N)\n\ndivN=[0]*(N+1)\nfor pn in primeryN:\n if pn==0:\n continue\n # print(pn)\n i=1\n cnt=0\n while (pn**i<=N):\n cnt+=(N//pn**i)\n i+=1\n divN[pn]=cnt\n\n# print(divN)\nans=1\nfor d in divN:\n if d==0:\n continue\n ans=(ans*(d+1))%p\nprint(ans)", "from math import factorial\n\nn = int(input())\nf = factorial(n)\n\nmod = 10 ** 9 + 7\n\ndef primes(n):\n is_prime = [True] * (n + 1)\n is_prime[0] = False\n is_prime[1] = False\n for i in range(2, int(n ** 0.5) + 1):\n if not is_prime[i]:\n continue\n for j in range(i * 2, n + 1, i):\n is_prime[j] = False\n return [i for i in range(n + 1) if is_prime[i]]\n\nans = 1\nfor p in primes(n):\n temp = 1\n while f % p == 0:\n temp += 1\n f //= p\n ans = (ans * temp) % mod\nprint(ans)", "import math\nimport collections\nN = int(input())\n# N!\u306e\u7d04\u6570\u306e\u500b\u6570\u309210**9+7\u3067\u5272\u3063\u305f\u3042\u307e\u308a\u3092\u51fa\u3059\nnums = [i for i in range(2, N + 1)]\n\n\ndef prime_factorization(num):\n sqrt_num = math.sqrt(num)\n prime_numbers = []\n for i in range(2, int(sqrt_num) + 1):\n # print(num)\n while num % i == 0:\n # print(num)\n num = num / i\n prime_numbers.append(i)\n if num != 1:\n prime_numbers.append(int(num))\n\n return prime_numbers\n\n\n# print(nums)\nnums_counter = {}\nfor num in nums:\n prime_numbers = prime_factorization(num)\n # print(prime_numbers)\n for prime_num in prime_numbers:\n # print(nums_counter)\n # print(prime_num in nums_counter)\n if prime_num in nums_counter:\n nums_counter[prime_num] += 1\n else:\n nums_counter[prime_num] = 1\n\nans = 1\nfor key, value in list(nums_counter.items()):\n ans *= (value + 1)\n ans %= 10**9 + 7\n\nprint(ans)\n", "N = int(input())\nmod = 1000000007\nfrom collections import defaultdict as dd\nY = dd(lambda:1)\nfor i in range(2, N+1):\n M = i\n for j in range(2,i+1):\n while M % j == 0:\n Y[j] += 1\n M //= j\n\ndef product(X):\n res = 1\n for x in X:\n res *= x\n res %= mod\n return res \n\nans = product(list(Y.values()))\nprint(ans)\n", "import collections\nimport numpy\nn = int(input())\nx = []\ndef factorization(n):\n d = []\n while n % 2 == 0:\n d.append(2)\n n /= 2\n f = 3\n while f*f <= n:\n if n % f == 0:\n d.append(int(f))\n n /= f\n else:\n f += 2\n if n != 1:\n d.append(n)\n return d\n\nfor i in range(n, 1, -1):\n x += factorization(i)\n\nc = collections.Counter(x)\nl = list(c.values())\nans = 1\n\nfor i in range(len(l)):\n ans *= 1 + l[i]\n\nprint(ans % (7+10**9))", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 30 01:24:22 2020\n\n@author: liang\n\"\"\"\n\nMOD = 10**9 + 7\nN = int(input())\ndata = [i for i in range(2,N+1)]\ntable = list()\n\n#\u7d20\u6570\u30ea\u30b9\u30c8\nwhile data:\n tmp = data[0]\n table.append(tmp)\n data = [i for i in data if i%tmp != 0]\n \n#print(table)\nres = dict()\nfor i in range(2,N+1):\n for t in table:\n if i%t == 0:\n if t not in res:\n res[t] = 1\n tmp = i\n while tmp%t == 0:\n res[t] += 1\n tmp //= t \n \nans = 1\nfor r in res.values():\n ans *= r\n ans %= MOD\n#print(res)\nprint(ans)", "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 prime_fact(n):\n root = int(math.sqrt(n))\n prime_dict = {}\n for i in range(2, root+1):\n cnt = 0\n while n % i == 0:\n cnt += 1\n n = n // i\n if cnt:\n prime_dict[i] = cnt\n if n != 1:\n prime_dict[n] = 1\n return prime_dict\n\n\ndef main():\n N = NI()\n D = defaultdict(int)\n if N == 1:\n print(1)\n return\n\n for n in range(2, N+1):\n ND = prime_fact(n)\n for p, a in list(ND.items()):\n D[p] += a\n\n ans = 1\n for p, a in list(D.items()):\n ans = ans * (a+1) % MOD\n print(ans)\n\n\ndef __starting_point():\n main()\n__starting_point()", "MOD = 10 ** 9 + 7\n\ndef sieve(n):\n srn = int(n ** 0.5) + 1\n f = [False] * (srn + 1)\n res = []\n for i in range(2, srn + 1):\n if f[i]:\n continue\n res.append(i)\n for j in range(2 * i, srn + 1, i):\n f[j] = True\n return res\n\ndef trial_division(n):\n res = dict()\n for i in range(2, n+1):\n m = i\n pn = sieve(m)\n for p in pn:\n while m % p == 0:\n res[p] = res.get(p, 0) + 1\n m //= p\n if m > 1:\n res[m] = res.get(m, 0) + 1\n return res\n\nN = int(input())\nfn = trial_division(N)\nres = 1\nfor f in fn.values():\n res *= (f + 1)\n res %= MOD\nprint(res)", "N=int(input())\ntable=[True for _ in range(N+1)]\ntable[0]=False\ntable[1]=False\nfor i in range(2,N+1):\n if table[i]==False:\n continue\n for j in range(2,N//i):\n table[i*j]=False\np=[]\nfor i in range(N+1):\n if table[i]:\n p.append(i)\n\nn=len(p)\ncnt=[0 for _ in range(n)]\nfor i in range(2,N+1):\n x=i\n j=0\n while x>1:\n while x%p[j]==0:\n cnt[j]+=1\n x//=p[j]\n j+=1\nans=1\nMOD=1000000007\nfor i in range(n):\n ans*=cnt[i]+1\n ans%=MOD\nprint(ans)\n", "n=int(input())\nd={i:0 for i in range(2,n+1)}\ndef prime_factorize(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\nfor i in range(2,n+1):\n for j in prime_factorize(i):\n d[j]+=1\na=1\nfor v in d.values():\n a=a*(v+1)\nprint(a%(10**9+7))", "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)]\n\ndef prime_factorize(n):\n n_origin=n+0\n primelist=[]\n a=2\n while a*a<=n_origin:\n if n%a!=0:\n a+=1\n continue\n ex=0\n while n%a==0:\n ex+=1\n n=n//a\n primelist.append([a,ex])\n a+=1\n if n!=1:\n primelist.append([n,1])\n return primelist\nex={}\nmod=10**9+7\nfor i in range(2,n+1):\n res=prime_factorize(i)\n for p,e in res:\n ex[p]=ex.get(p,0)+e\n\nans=1\nfor k, v in ex.items():\n ans=(ans*(v+1))%mod\nprint(ans)", "import collections\nN = int(input())\nls = [0]+[0]*N\ncouterls = collections.Counter(ls)\nfor i in range(1,N+1):\n for j in range(2,N+1):\n if i % j == 0:\n while i % j == 0:\n couterls[j] += 1\n i = i // j\n elif i == 1:\n break\n else:\n pass\nans = 1\ncouterls.pop(0)\nfor i in couterls.values():\n ans = (ans * (i+1) ) % (10**9+7)\nprint(ans)", "import collections\ndef make_divisors(n):\n divisors = []\n for i in range(1, int(n**0.5)+1):\n if n % i == 0:\n divisors.append(i)\n if i != n // i:\n divisors.append(n//i)\n\n divisors.sort()\n return divisors\ndef 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\n if temp!=1:\n arr.append([temp, 1])\n\n if arr==[]:\n arr.append([n, 1])\n\n return arr\ndef main():\n dd = collections.defaultdict(int)\n n = int(input())\n MOD = 10**9 + 7\n\n for i in range(1,n+1):\n k=factorization(i)\n for j in k:\n dd[j[0]]+=j[1]\n res = 1\n for j in list(dd.keys()):\n if(j!=1):\n res *= (dd[j]+1)%MOD\n res%=MOD\n print(res)\n\ndef __starting_point():\n main()\n\n__starting_point()", "def factrial(n):\n factors = []\n while n%2 == 0:\n factors.append(2)\n n //= 2\n \n for i in range(3, int(n**0.5)+1, 2):\n while n%i == 0:\n factors.append(i)\n n //= i\n \n if n != 1: factors.append(n)\n \n return factors\n\n\nn = int(input())\nmod = 10**9+7\n\nd = {}\nfor i in range(1,n+1):\n fac = factrial(i)\n for j in fac:\n if j in d: d[j] += 1\n else: d[j] = 1\n\nans = 1\nfor k,v in d.items():\n ans *= (v+1)\n ans %= mod\nprint(ans)", "def factorize(n):\n #https://python.ms/factorize/#%E5%AE%9F%E8%A3%85\n fct = [] # prime factor\n b, e = 2, 0 # base, exponent\n while b * b <= n:\n while n % b == 0:\n n = n // b\n e = e + 1\n if e > 0:\n fct.append([b, e])\n b, e = b + 1, 0\n if n > 1:\n fct.append([n, 1])\n return fct\n\nn = int(input())\n\nnum = 1\nfor i in range(1,n+1):\n num *= i\n\nfact = factorize(num)\n#print(fact)\nans = 1\nfor i in range(len(fact)):\n ans *= (fact[i][1]+1)\n\nprint(ans%(10**9+7))", "import math\nN = int(input())\n\ndef factrize(N):\n L={}\n for n in range(2,N+1):\n L[n]=0\n while N % n == 0:\n L[n]+=1\n N = N/n\n return L\n\nf_ = {}\nfor n in range(2,int(N)+1):\n f_[n]=0\n \nfor n in range(1,N+1):\n F=factrize(n)\n for f in F.keys():\n f_[f]+=F[f]\n \nans=1\nfor f in f_.keys():\n if f_[f] != 0:\n ans=ans*(f_[f]+1)\n \nprint(ans%((10**9)+7))", "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\nN=int(input())\nmod=10**9+7\nif N==1:\n print(1)\nelse:\n ans=1\n dp=[0]*1001\n for i in range(2,N+1):\n p=factorization(i)\n for i,j in p:\n dp[i]+=j\n for i in range(1001):\n ans*=(dp[i]+1)\n ans%=mod\n print(ans)", "import math\n\ndef is_prime(n):\n if(n == 1):\n return False\n \n for i in range(2, int(math.sqrt(n))+1):\n if(n%i == 0):\n return False\n \n return True\n\nsosu = []\nfor i in range(1, 1001):\n if(is_prime(i)):\n sosu.append(i) \n\nN = int(input())\nmod = 10**9+7\nx = math.factorial(N)\na = 1\n\nfor i in range(len(sosu)):\n cnt = 0\n if(sosu[i] > x):\n break\n while (x%sosu[i]==0):\n x = x//sosu[i]\n cnt += 1\n if(cnt):\n a *= (cnt+1)\n a %= mod\n\nprint(a)"]
{"inputs": ["3\n", "6\n", "1000\n"], "outputs": ["4\n", "30\n", "972926972\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
62,236
d3ca4703625401579c3928f804673799
UNKNOWN
You are given a positive integer X. Find the largest perfect power that is at most X. Here, a perfect power is an integer that can be represented as b^p, where b is an integer not less than 1 and p is an integer not less than 2. -----Constraints----- - 1 ≀ X ≀ 1000 - X is an integer. -----Input----- Input is given from Standard Input in the following format: X -----Output----- Print the largest perfect power that is at most X. -----Sample Input----- 10 -----Sample Output----- 9 There are four perfect powers that are at most 10: 1, 4, 8 and 9. We should print the largest among them, 9.
["x=int(input())\nm=-1000\nif 1<=x<=3:\n print((1))\n return\nelse:\n for b in range(2,x+1):\n for p in range(2,11):\n if x>=b**p:\n m=max(m,b**p)\n \n\nprint(m)\n\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\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())\nx = I()\nans = -1\nfor b in range(1,x+2):\n for p in range(2, x+2):\n if b**p > x:\n break\n ans = max(ans, b**p)\nprint(ans)\n", "from math import *\n\nx = int(input())\n\nlst1 = list(range(2, int(sqrt(1000)) + 1))\nlst2 = [1, 1000]\n\nfor n in lst1:\n i = 2\n while n ** i < 1000:\n lst2.append(n ** i)\n i += 1\n\nlst2 = list(set(lst2))\nlst2.sort()\n\nfor i in range(len(lst2)):\n if x < lst2[i]:\n print(lst2[i - 1])\n return\n\nprint(lst2[-1])", "x = int(input())\n\nans = [1]\nfor i in range(2, 1001):\n p = 2\n while i**p <= 1000:\n ans.append(i**p)\n p += 1\nwhile not x in ans:\n x -= 1\nprint(x)", "x = int(input())\n# p >= 2, b >= 1\nif x == 1:\n ans = 1\nelse:\n ans = 0\n for i in range(1, x+1):\n for j in range(2, x+1):\n e = i**j\n if e <= x:\n ans = max(ans, e)\n else:\n break\nprint(ans)", "n = int(input())\nt = [1, 4, 8, 9, 16, 25, 27, 32, 36, 49, 64, 81, 100,\n 125, 121, 128, 144, 169, 196, 216, 225, 243, 256,\n 289, 324, 343, 361, 400, 441, 484, 512, 529, 576,\n 625, 676, 729, 784, 841, 900, 961, 1000, 1024, 1296]\n\nres = 0\nfor tt in t:\n res = tt if tt <= n else res\nprint(res)\n", "\nX = int(input())\n\ni = 2\n\nans = 1\nwhile i < X:\n power = 2\n while power <= X:\n if pow(i,power) <= X:\n ans = max(ans,pow(i,power))\n else:\n break\n power += 1\n i += 1\nprint(int(ans))", "x = int(input())\nans = 1\nfor i in range(2,int(x ** 0.5) + 1):\n k = 1\n temp = 1\n while temp<=x:\n ans = max(ans,temp)\n temp = i ** k\n k += 1\nprint(ans)", "x = int(input())\nans = 1\ncnt = 1\nfor i in range(1,x):\n cnt = i\n for j in range(9):\n cnt *= i\n if cnt > x:\n break\n if cnt > ans:\n ans = cnt\nprint(ans)", "n = int(input())\ns = set()\nfor i in range(1, 32):\n s.add(i ** 2)\n\nfor i in range(1, 11):\n s.add(i ** 3)\n\nfor i in range(1, 7):\n s.add(i ** 4)\n\nfor i in range(1, 5):\n s.add(i ** 5)\n s.add(i ** 6)\n s.add(i ** 7)\n s.add(i ** 8)\n s.add(i ** 9)\n s.add(i ** 10)\n\nt = list(s)\nt.sort()\nt = [x for x in t if x <= 1000]\n\nres = 0\nfor tt in t:\n res = tt if tt <= n else res\nprint(res)", "X = int(input())\n\nans = 0\nfor i in range(1, int(X**0.5)+1):\n for j in range(2, 1000):\n tmp = pow(i, j)\n if tmp > X:\n break\n ans = max(ans, tmp)\n\nprint(ans)", "x = int(input())\n\nans = [1]\nfor i in range(2, 1001):\n p = 2\n while i**p <= 1000:\n ans.append(i**p)\n p += 1\nwhile not x in ans:\n x -= 1\nprint(x)", "x = int(input())\nprint((max([pow(i, j) for i in range(1, 32)\n for j in range(2, 10) if pow(i, j) <= x])))\n", "n = int(input())\nans = 1\nfor i in range(1,n):\n for j in range(2,n):\n if i ** j <= n:\n ans = max(ans,i ** j)\n else:\n break\nprint(ans)", "x = int(input())\na = 1\nfor i in range(2, x + 1):\n for j in range(1, x + 1):\n if j ** i <= x:\n a = max(a, j ** i)\n else:\n break\nprint(a)", "X = int(input())\nn = 1\nif X<=3:\n print(1)\nelif X==4:\n print(4)\nelse:\n n = 4\n for i in range(2,int(X**0.5)+1):\n b = i\n k = 1\n while b**k<=X:\n k += 1\n k -= 1\n if k>=2:\n n = max(n,b**k)\n print(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\nx = ri()\nmax_ = 0\nfor i in range(int(x**0.5), 0, -1):\n for j in range(1, 10):\n if i**j <= x:\n max_ = max(i**j, max_)\n else:\n break\nprint(max_)\n\n\n\n\n\n\n\n\n\n\n", "x = int(input())\nc=1\nfor b in range(1,x):\n for p in range(2,x):\n if b**p<=x:c=max(c,b**p)\n else:break\nprint(c)", "b=[0]*1001\nx=int(input())\nb[1]=1\nfor i in range(2,1000,1):\n j=i*i\n while j<1001:\n b[j]=1\n j*=i\nfor i in range(x,0,-1):\n if b[i]==1:\n print(i)\n break", "def solve(X):\n ans = 1\n\n for i in range(1, 32):\n for j in range(2, 11):\n tmp = i ** j\n if tmp <= X and ans < tmp:\n ans = tmp\n\n return ans\n\n\ndef __starting_point():\n X = int(input())\n print((solve(X)))\n\n__starting_point()", "def answer(x: int) -> int:\n if x < 4 :\n return 1\n\n result = 1\n for b in range(2, x + 1):\n for p in range(2, x + 1):\n exp = pow(b, p)\n if exp <= x:\n result = max(result, exp)\n else:\n break\n\n return result\n\n\ndef main():\n x = int(input())\n print((answer(x)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "X = int(input())\nS = set([1])\nfor i in range(2,X):\n b = 2\n while(i**b<=X):\n S.add(i**b)\n b += 1\n\nans = max(S)\nprint(ans)", "x = int(input())\nexpotential = [0] * (x + 1)\nexpotential[1] = 1\nfor b in range(2, x+1):\n\tt = b * b\n\twhile(t <= x):\n\t\texpotential[t] = 1\n\t\tt *= b\nfor i in range(x, 0, -1):\n\tif expotential[i]:\n\t\tprint(i)\n\t\tbreak", "x = int(input())\nans = 1\nfor i in range(1,x+1):\n for j in range(2,11):\n if i**j <= x:\n ans = max(ans,i**j)\n else:\n break\nprint(ans)", "X = int(input())\nans = 1\nfor i in range(2, 32):\n for j in range(2, 10):\n if i ** j > X:\n continue\n ans = max(ans, i ** j)\nprint(ans)\n", "import sys, math\nlines = [s.rstrip(\"\\n\") for s in sys.stdin.readlines()]\nx, = [int(num) for num in lines.pop(0).split(\" \")]\nmax_base = int(math.sqrt(x))\nmax = 1\nfor base in range(2, max_base + 1):\n i = 2\n while True:\n tmp_max = base ** i\n if tmp_max <= x:\n if tmp_max > max:\n max = tmp_max\n i += 1\n else:\n break\nprint(max)\n", "x = int(input())\nans = 1\nfor b in range(2,int(x**0.5)+1):\n for p in range(2,10):\n c = b**p\n if c > x:\n break\n ans = max(ans,c)\nprint(ans)", "x = int(input())\nans = 0\nfor i in range(x):\n for j in range(2,10): \n if i**j <= x:\n ans = max(ans,i**j)\n #print(ans,i,j)\n else:\n break\n\nif ans == 0:\n ans = 1\n\nprint(ans)", "x = int(input())\ntmp = 1\nfor b in range(1, x):\n for p in range(2,x):\n if b**p <= x:\n tmp = max(tmp, b**p)\n else:\n break\nprint(tmp)\n\n", "X = int(input())\nres_list = [1]\n\nfor i in range(1,X):\n for j in range(2,X):\n if i ** j <= X:\n res_list.append(i ** j)\n else:\n break\n\nprint(max(res_list))", "x=int(input())\nans = 0\nfor i in range(1,32):\n for j in range(2,11):\n if i**j <= x:\n ans = max(ans,i**j)\nprint(ans)", "x = int(input())\npr = [1]\nfor i in range(2,32):\n for j in range(2,10):\n if (i**j <= 1000)&(i**j not in pr):\n pr.append(i**j)\nprint(max([k for k in pr if k <= x]))", "X = int(input())\nlst = [1]\nfor i in range(2, 32):\n for j in range(2, 10):\n x = i ** j\n if x <= 1000:\n lst.append(x)\nif X in lst:\n print(X)\nelse:\n lst.append(X)\n lst2 = sorted(lst)\n n = lst2.index(X)\n print(lst2[n-1])", "x = int(input())\n\nans = 0\nif x <=2:\n ans = x\nelse:\n for i in range(1, x+1):\n for j in range(2, x+1):\n if i**j <= x:\n ans = max(ans, i**j)\n elif i**j > x:\n break\n\nprint(ans)\n", "x = int(input())\nif x == 1000:\n print(1000)\n return\nlist_exp = []\nmax_b = int(1000 ** 0.5)\nmax_p = 0\nwhile True:\n if 2 ** max_p > 1000:\n break\n else: max_p += 1\n\nfor b in range(1, max_b + 1):\n for p in range(2, max_p):\n if b ** p <= 1000: list_exp.append(b ** p)\n else: break\nlist_exp.sort()\nfor i in range(0, len(list_exp)):\n if list_exp[i] <= x: continue\n else:\n print(list_exp[i - 1])\n break", " \nX=int(input())\n\nif X==1:\n print((1))\n return\n\ndef prime_factorize(n):\n a = []\n while n % 2 == 0:\n a.append(2)\n n //= 2\n f = 3\n while f * f <= n:\n if n % f == 0:\n a.append(f)\n n //= f\n else:\n f += 2\n if n != 1:\n a.append(n)\n return a\n\nwhile True:\n a=prime_factorize(X)\n temp=[]\n c=1\n sw=True\n if len(a)==1:\n sw=False\n for i in range(len(a)-1):\n if a[i]!=a[i+1]:\n temp.append(c)\n c=0\n c+=1\n temp.append(c)\n\n for j in range(len(temp)-1):\n if temp[j]!=temp[j+1] or temp[j]==1:\n sw=False\n if sw==True: \n print(X)\n return\n X-=1\n", "X=int(input())\nans=1\nfor i in range(2,int(X**0.5)+1):\n x=i\n while x<=X:\n ans=max(ans,x)\n x*=i\nprint(ans)\n", "X = int(input())\nexps = []\nfor b in range(1,34):\n for p in range(2,11):\n x = b**p\n if x < 1001:\n exps.append(x)\nexps = list(set(exps))\nexps.sort()\nfor a in exps[::-1]:\n if X >= a:\n print(a)\n break", "X = int(input())\n\nans = 1\nfor i in range(2, X+1):\n t = i*i\n while t <= X:\n ans = max(ans, t)\n t *= i\n\nprint(ans)", "import bisect\nx = int(input())\na = 2\nb = 2\nk = {1}\n\nwhile a <= 31:\n\twhile pow(a, b) <= 1000:\n\t\tk.add(pow(a, b))\n\t\tb += 1\n\tb = 2\n\ta += 1\n\nkl = list(k)\nkl.sort()\nprint(kl[bisect.bisect_right(kl, x)-1])", "N = int(input())\nans = 0\nfor i in range(1, N + 1):\n for j in range(2, 20):\n if i ** j > N:\n continue\n ans = max(i ** j, ans)\nprint(ans)\n", "X = int(input())\n\nans = 0\nfor i in range(1, int(X**0.5)+1):\n for j in range(2, 1000):\n tmp = pow(i, j)\n if tmp > X:\n break\n ans = max(ans, tmp)\n\nprint(ans)", "x = int(input())\nli = []\nfor i in range(1,100):\n for j in range(2,12):\n if i ** j <= x:\n if i**j not in li:\n li.append(i**j)\nprint(max(li))", "def main():\n X = int(input())\n ans = 1\n for i in range(2, X+1):\n for j in range(2, 11):\n if i**j > X:\n break\n else:\n ans = max(ans, i**j)\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n n = int(input())\n answers=[]\n\n if n<=3:\n print(n)\n return\n\n for b in range(2,n):\n #b**2\u304b\u3089b**10\u307e\u3067\u8abf\u3079\u308b\n for p in range(2,11):\n if b**p > n:\n break\n elif b**p <=n:\n answers.append(b**p)\n else:\n continue\n print(max(answers))\n \n\ndef __starting_point():\n main()\n__starting_point()", "x = int(input())\nans = 1\nfor i in range(1,x):\n for j in range(2,x):\n if i**j <= x :\n ans = max(ans,i**j)\n else : break\n\nprint(ans)", "x=int(input())\nc=1\nfor b in range(1,x):\n for p in range(2,x):\n if b**p<=x:\n c=max(c,b**p)\n else:\n break\nprint(c)", "import math\nX = int(input())\nbeki = []\nbeki.append(1)\nXruto = math.sqrt(X)\nXruto = math.floor(Xruto)\nfor i in range(2, Xruto+1):\n for j in range(10):\n a = pow(i, j)\n if a <= X:\n beki.append(a)\n else:\n break\nprint((max(beki)))\n", "a = int(input())\nans = 0\ni = 1\nwhile i*i <= a:\n for j in range(1, 1000):\n if i**j <= a and ans < i**j:\n ans = i**j\n if i**j > a:\n break;\n i += 1\nprint(ans)", "x=int(input())\nres=0\nfor b in range(x+1):\n for p in range(2,x+2):\n if res<(b**p)<=x:\n res=b**p\n elif b**p>x:\n break\nprint(res)\n\n", "import math\nX = int(input())\nans = 1\nY = math.floor(math.sqrt(X))\nfor i in range(2, Y+1):\n for j in range(2, 10):\n a = i**j\n if a <= X:\n ans = max(ans, a)\nprint(ans)\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 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\nnum = []\ninf = float(\"inf\")\nal = \"abcdefghijklmnopqrstuvwxyz\"\nAL = al.upper()\n\nN = k()\nif N == 1:\n print(1)\n return\n \nfor i in range(N,-1,-1):\n for j in range(1,int(N**0.5)+1):\n for k in range(2,11):\n if j**k == i:\n print(i)\n return", "x = int(input())\n\ntable = [False] * -~x\ntable[1] = True\nfor i in range(2, 32):\n j = i * i\n while j <= x:\n table[j] = True\n j *= i\n\nprint((max(i for i in range(x + 1) if table[i])))\n", "import math\nX=int(input())\n\ndef check_p(X,b):\n\tp = 0\n\twhile b**(p+1) <= X:\n\t\tp+=1\n\treturn b**p\n\nans=1\nfor b in range(2,int(math.sqrt(X))+1):\n\tans = max(ans,check_p(X,b))\n\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 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\nimport bisect\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())\nx = I()\nans = 1\nfor b in range(2,1001):\n for p in range(2,24):\n if b**p <= x:\n ans = max(ans,b**p)\n else:\n break\nprint(ans)\n", "x = int(input())\nans = 1\nfor i in range(x):\n for j in range(2,10): \n if i**j <= x:\n ans = max(ans,i**j)\n #print(ans,i,j)\n else:\n break\n\nprint(ans)", "#!/usr/bin/env python3\n\ndef main():\n x = int(input())\n ans = 0\n for b in range(1, 1000):\n for p in range(2, 10):\n if x >= b ** p:\n ans = max(ans, b ** p)\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "X = int(input())\nans = 1\nfor i in range(2, X + 1):\n for j in range(2, X + 1):\n a = i ** j\n if a > X:\n break\n elif a > ans:\n ans = a\nprint(ans)", "x=int(input())\nc=1\nfor b in range(1,32):\n for p in range(2,10):\n if b**p<=x:\n c=max(c,b**p)\n else:break\nprint(c)", "x = int(input())\nans = 0\nfor i in range(1,32):\n for j in range(2,10):\n if i**j <= x:\n ans = max(ans,i**j)\nprint(ans)", "x = int(input())\nex = [0 for i in range(1001)]\nex[1] = 1\n\nfor i in range(2, 1001):\n tmp = i * i\n while tmp <= 1000:\n ex[tmp] = 1\n tmp *= i\n \nfor i in range(x, 0, -1):\n if ex[i] == 1:\n print(i)\n break\n", "a = int(input())\nprint(max(j ** i for j in range(32) for i in range(2, 10) if j ** i <= a))", "n=int(input())\nans=1\nfor b in range(2,100):\n tmp=b\n for p in range(2,10):\n tmp*=b\n if tmp<=n :\n ans=max(ans,tmp)\nprint(ans)", "n = int(input())\nprint(max([pow(i, j) for i in range(1, 32)\n for j in range(2, 10) if pow(i, j) <= n]))", "x = int(input())\n\nans = 1\nfor i in range(2, int(x**(1/2)//1+1)):\n v = 1\n while v*i <= x:\n v *= i\n ans = max(ans, v)\nprint(ans)", "from bisect import bisect_right\n\n\ncands = []\nfor i in range(2, 400):\n cur = i\n while cur * i <= 1000:\n cands.append(cur * i)\n cur *= i\ncands.sort()\n\nX = int(input())\nif X == 1:\n print((1))\nelse:\n print((cands[bisect_right(cands, X) - 1]))\n", "x=int(input())\nans = 0\nfor i in range(2,11):\n for j in range(1,x+1):\n if x>=j**i:\n ans = max(ans,j**i)\nprint(ans)", "x = int(input())\nmax_val = 1\nfor i in range(1, x):\n for j in range(2, x): \n val = i ** j\n if val > x:\n break\n elif val > max_val:\n max_val = val\nprint(max_val)", "X = int(input())\n\nmaxi = 0\n\nif X < 4:\n print(1)\n return\n\nfor i in range(1, X+1):\n for j in range(2, X+1):\n if i**j <= X and i**j >= maxi:\n maxi = i**j\n if i**j > X:\n break\n\nprint(maxi)", "x = int(input())\n\nans = 0\nfor i in range(1, 100):\n for j in range(2, 100):\n y = pow(i, j)\n if y <= x:\n ans = max(ans, y)\n\nprint(ans)\n", "X=int(input())\nans=0\nfor i in range(X+1):\n if i*i<=X:\n sum=i*i\n for j in range(X):\n if i**j>X:\n break\n sum=max(sum,i**j)\n else:\n break\n ans=max(ans,sum)\n\nprint(ans)", "X = int(input())\ncnt = 1\nfor b in range(1,X):\n for p in range(2,X):\n if b**p <= X:\n cnt = max(cnt, b**p)\n else: break\nprint(cnt)", "x = int(input())\nans = 0\nfor i in range(1, 100):\n for j in range(2, 10):\n a = i**j\n if a <= x and x-a <= x-ans:\n ans = a\nprint(ans)", "X = int(input())\nans = []\nfor i in range(1,X+1):\n A = 0\n p = 2\n if i == 1:\n ans.append(1)\n else:\n while True:\n A = i**p\n if A <= X:\n ans.append(A)\n p += 1\n else:\n break\nprint(max(ans))", "X = int(input())\n\ni = 2\n\nans = 1\nwhile i < X:\n power = 2\n while i**power <= X:\n ans = max(ans,i**power)\n power += 1\n i += 1\nprint(int(ans))", "n = int(input())\nimport math as m\nif n < 4:\n print((1))\n return\n \nperfect = 1\nfor b in range(2,int(n**0.5)+1):\n p = int(m.log(n,b))\n x = b**(p+1)\n if x > n:\n x = b**p\n perfect = max(perfect,x)\n #print(b,x)\n if perfect == n:\n break\n\nprint(perfect)\n", "ans = []\nX = int(input())\nfor i in range(1,50):\n for j in range(2,20):\n if (i ** j)<= X:\n ans.append(i**j)\nprint(max(ans))", "X = int(input())\n\nmax_expo = 1\n\nfor p in range(2,10):\n for b in range(X):\n if max_expo < (b**p) <= X:\n max_expo = (b**p)\nprint(max_expo)", "import bisect\na = int(input())\nb = [1]\nfor i in range(2,34):\n j = 2\n while i**j <= 1000:\n b.append(i**j)\n j += 1\nc = sorted(b)\nindex = bisect.bisect_right(c,a)\nprint((c[index-1]))\n\n", "import sys\n \nX = int(sys.stdin.readline())\nans = 0\nfor i in range(X+1):\n for j in range(2, 11):\n tmp = pow(i, j)\n if tmp <= X:\n ans = max(ans, tmp)\nprint(ans)", "n = int(input())\na = {1}\nfor b in range(2,n):\n p = 2\n x = b**p\n while x <= n:\n a.add(x)\n x = b**p\n p += 1\n\nprint(max(a))", "X = int(input())\nb = 2\np = 2\nans = 1\nfor b in range(1, X+1):\n for p in range(2, X+1):\n beki = b ** p\n if beki <= X:\n ans = max(ans, beki)\n else:\n break\nprint(ans)\n", "x=int(input())\nans=0\nif x==1:\n print(1)\n return\nfor i in range(1,x):\n for j in range(2,10):\n if i**j<=x:\n ans=max(ans,i**j)\n else:\n break\nprint(ans)", "import math\nX = int(input())\n\nls = []\nfor i in range(2,math.floor(math.sqrt(X))+1):\n for j in range(2,10):\n if i ** j <= X:\n ls.append(i ** j)\n \nprint(max(ls) if ls else 1)", "X = int(input())\nans = []\nans.append(1)\nfor i in range(2, X):\n a = i*i\n while a <= X:\n ans.append(a)\n a *= i\nprint((max(ans)))\n", "x = int(input())\nans = 1\nfor p in range(2, x+1):\n for b in range(1, x+1):\n if b**p <= x:\n ans = max(ans, b**p)\n else:\n break\nprint(ans)", "import math\ndef resolve():\n x = int(input())\n sqrt_x = int(math.sqrt(x))\n al = list()\n for i in range(2, 10):\n for j in range(sqrt_x, 0, -1):\n if j**i <= x:\n al.append(j**i)\n break\n al = sorted(al)\n print(al[-1])\nresolve()", "X=int(input())\nans=0\nfor i in range(1,32):\n for j in range(2,10):\n tmp=i**j\n if ans<tmp<=X:\n ans=tmp\nprint(ans)", "x = int(input())\nans = 1000000\nfor b in range(1,32):\n for p in range(2,10):\n if x-b**p < 0:\n continue\n ans = min(ans,abs(x-(b**p)))\nprint((x-ans))\n", "x = int(input())\nmx = 0\nfor b in range(1, int(1000 ** 0.5) + 1):\n for p in range(2, 10):\n if mx < b ** p <= x:\n mx = b ** p\nprint(mx)", "X = int(input())\nans = [1]\nfor i in range(2,X+1):\n p = 2\n while i**p <= X:\n ans.append(i**p)\n p += 1\nprint(max(ans))", "x = int(input())\n\nans = 1\nfor i in range(2, x):\n if i * i > x:\n break\n\n now = i\n while now * i <= x:\n now *= i\n if now > ans:\n ans = now\n\nprint(ans)", "a=int(input())\nd=0\ne=0\nfor i in range(40):\n b=i+2\n while b<=a:\n b=b*(i+2)\n e=e+1\n c=b/(i+2)\n if e>1:\n if d<=c:\n d=c\n e=0\n else:\n e=0\nif d==0:\n print(1)\nelse:\n print(int(d))", "import math\nx = int(input())\n\nres = 1\nfor b in range(2, math.ceil(math.sqrt(x))):\n p = 2\n while b**(p+1) <= x:\n p += 1\n res = max(res, b ** p)\nprint(res)", "X = int(input())\n\ni = 2\nans = 1\nwhile i < X:\n power = 2\n while pow(i,power) <= X:\n ans = max(ans,pow(i,power))\n power += 1\n i += 1\nprint(int(ans))", "x = int(input())\nans = 0\nfor i in range(x+1):\n for j in range(2,10):\n if i**j <=x:\n ans = max(ans,i**j)\nprint(ans)\n", "import math\nX = int(input())\nlist1 = []\n\nfor i in range(2,X+1):\n for j in range(2,int((X + 1)/2)):\n a = math.log10(i)/math.log10(j)\n if a.is_integer():\n list1.append(i)\nif list1 == []:\n print((1))\nelse:\n print((max(list1)))\n", "import sys\nn=int(input())\n\nans=[]\n\nif n==1:\n print('1')\n return\n\nfor i in range(n//2):\n for j in range(n//2):\n if i**j<=n:\n ans.append(i**j)\n\nprint(max(ans))"]
{"inputs": ["10\n", "1\n", "999\n"], "outputs": ["9\n", "1\n", "961\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
24,766
4e41905c84173428b511a7cb97af3624
UNKNOWN
An X-layered kagami mochi (X β‰₯ 1) is a pile of X round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, you have a 3-layered kagami mochi; if you put just one mochi, you have a 1-layered kagami mochi. Lunlun the dachshund has N round mochi, and the diameter of the i-th mochi is d_i centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have? -----Constraints----- - 1 ≀ N ≀ 100 - 1 ≀ d_i ≀ 100 - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N d_1 : d_N -----Output----- Print the maximum number of layers in a kagami mochi that can be made. -----Sample Input----- 4 10 8 8 6 -----Sample Output----- 3 If we stack the mochi with diameters of 10, 8 and 6 centimeters from bottom to top in this order, we have a 3-layered kagami mochi, which is the maximum number of layers.
["N = int(input())\nds = []\nmochidan = 0\nfor i in range(N):\n ds.append(int(input()))\n\nwhile ds:\n tmp = max(ds)\n ds = [j for j in ds if j < tmp]\n mochidan += 1\n\nprint(mochidan)", "N=int(input())\nd=set()\nfor _ in range(N):\n d.add(int(input()))\nprint((len(d)))\n", "N = int(input())\nint_list = []\nfor _ in range(N):\n int_list.append(int(input()))\nint_list.sort()\nprint(len(set(int_list)))", "n = int(input())\nl = [input() for i in range(n)]\nprint((len(set(l))))\n", "N = int(input())\nd = []\nfor i in range(N):\n d.append(int(input()))\n\ndic = {}\n\nfor i in range(N):\n if d[i] in dic:\n dic[d[i]] += 1\n else:\n dic[d[i]] = 1\n\nprint(len(dic))", "print(len(set([int(input()) for i in range(int(input()))])))", "N=int(input())\nz=[]\nfor num in range(101):\n z.append(0)\ncounter=0\nwhile counter < N:\n d=int(input())\n z[d]=1\n counter+=1\nresult=sum(z)\nprint(result)", "num = int(input())\na = []\n\nfor i in range(num):\n n = int(input())\n a.append(n)\n \nmyset = set(a)\n\nlen_list = len(frozenset(myset))\n\nprint(len_list)\n", "N = int(input())\nd_list = []\nHeight = 0\nfor i in range(N):\n d_list.append(int(input()))\nwhile d_list != []:\n MAX_Value = max(d_list)\n while MAX_Value == max(d_list):\n d_list.remove(MAX_Value)\n if d_list == [] :\n break\n Height +=1\nprint(Height)", "n = int(input())\na = set()\nfor _ in range(n):\n a.add(int(input()))\nprint((len(a)))\n", "n = int(input())\nd = set()\nfor i in range(n):\n d.add(int(input()))\nprint(len(d))", "i = input()\n\nl = []\n\nfor n in range(int(i)):\n n = input()\n l.append(n)\n\nl = list(set(l))\n\nprint((len(l)))\n", "n = int(input())\nlist_d = sorted([int(input()) for i in range(0, n)], reverse=True)\nlist_ans = []\nfor i in range(0, len(list_d)):\n if list_d[i] not in list_ans:\n list_ans.append(list_d[i])\nprint(len(list_ans))", "N=int(input())\nd = [int(input()) for i in range(N)]\n\nprint(len(set(d)))", "n = int(input())\nkey = []\nans = 0\nfor _ in range(n):\n s = int(input())\n if s not in key:\n key.append(s)\n ans += 1\nprint(ans)\n", "n = int(input())\n\nprint(\n len(\n set(\n [\n int(input()) for _ in range(n)\n ]\n )\n )\n)", "import sys\ndef input(): return sys.stdin.readline().rstrip()\n\nN = int(input())\nD = []\nfor i in range(N):\n d = int(input())\n D.append(d)\n\nD_set = set(D)\nans = len(D_set)\n\nprint(ans)", "# https://atcoder.jp/contests/abc085/tasks/abc085_b\n# 2\u5206\u63a2\u7d22\u6728\u3092\u4f7f\u3046\u3089\u3057\u3044\u304c\u30fb\u30fb\u30fb\u30fb\u3053\u308c\u306f\u78ba\u304b\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u306f\u306a\u304f\u3001\u5b9f\u88c5\u65b9\u6cd5\u3092\u6c17\u3092\u3064\u3051\u308c\u3070\u7c21\u5358\u306b\u5b9f\u88c5\u3067\u304d\u305f\u6c17\u304c\u3059\u308b\u3002\nN = int(input())\nD = [int(input()) for _ in range(N)]\nD.sort()\ncount = 1\nfor i in range(1, len(D)):\n if D[i] != D[i - 1]:\n count += 1\nprint(count)\n", "from typing import List\n\n\ndef answer(n: int, d: List[int]) -> int:\n return len(set(d))\n\ndef main():\n n = int(input())\n d = list(int(input()) for _ in range(n))\n print(answer(n,d))\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\nq = len(list(set([int(input()) for i in range(n)])))\nprint(q)", "n,*l = map(int,open(0).read().split())\nprint(len(set(l)))", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\nd = [int(input()) for i in range(n)]\n\nprint((len(set(d))))\n", "n = int(input())\na = sorted([input() for i in range(n)])\nc = 1\nfor i in range(n - 1):\n if a[i] < a[i + 1]:\n c += 1\nprint(c)\n", "from sys import stdin\nn = int(stdin.readline().rstrip())\na = [0]*n\nfor x in range(n):\n a[x] = int(stdin.readline().rstrip())\n\na.sort(reverse = True)\n\nsum = 1\n\nfor x in range(n-1):\n if a[x] > a[x+1]:\n sum += 1\nprint(sum)", "n = int(input())\nd = set(list([int(input()) for i in range(n)]))\nprint((len(d)))\n", "n = int(input())\ndata = [int(input()) for i in range(n)]\nprint(len(set(data)))", "N = int(input())\nd = []\nfor i in range(N):\n d.append(int(input()))\n\nd.sort(reverse=True)\n\nstep = 1\nfor i in range(N-1):\n if d[i] > d[i+1]:\n step +=1\n\nprint(step)", "num = int(input())\n\ntable = []\nfor i in range(num):\n table.append(int(input()))\n\nsetting = set(table)\nprint(len(setting))", "N = int(input())\nnum_list = []\nfor n in range(N):\n num = int(input())\n num_list.append(num)\nans = len(set(num_list))\nprint(ans)", "N = int(input())\nd = []\nfor _ in range(N):\n d.append(int(input()))\nd.sort(reverse=True)\n\ntop = 101\nans = 0\n\nfor d_ in d:\n if d_ < top:\n ans += 1\n top = d_\n\nprint(ans)", "N = int(input())\nmoti_list = [int(input()) for i in range(N)]\n\nmoti_list.sort(reverse=True)\ntower = 1\nfor j in range(N - 1):\n if moti_list[j] > moti_list[j + 1]:\n tower += 1\n\nprint(tower)", "N = input()\nN = int(N)\nli = []\nfor i in range(N):\n li.append(input())\n\nans = 0\na = []\nb = 0\nfor i in range(101):\n a.append(i - i)\n\nfor i in range(N):\n b = li[i]\n b = int(b)\n a[b] = 1\n\nfor i in range(101):\n ans += a[i]\nprint(ans)", "n = int(input())\nst = set()\nfor i in range (0, n):\n a = input()\n st.add(a)\nprint(len(st))", "N = int(input())\nnums =[int(input()) for i in range(N)]\nprint(len(set(nums)))", "#85B\nn=int(input())\ndata=[]\nfor i in range(0,n):\n data.append(int(input()))\nres=sorted(data)\nc=1\nfor j in range(1,n):\n if res[j]!=res[j-1]:\n c=c+1\nprint(c)", "N = int(input())\na = list(input() for i in range(N))\n\nprint(len(set(a)))", "n = int(input())\nd = [int(input()) for i in range(n)]\n\nprint(len(set(d)))", "n = int(input())\nd = set(int(input()) for i in range(n))\n\nprint((len(d)))\n", "n = int(input())\nd = [input() for _ in range(n)]\nans = len(set(d))\nprint(ans)", "# coding: utf-8\n# Your code here!\n\nn = int(input())\nD = []\nfor i in range(n) : \n D.append(int(input()))\nD = set(D)\n\nprint(len(D))", "n = int(input())\nd = [int(input()) for i in range(n)]\nd = sorted(d, reverse=True)\nans = 0\nlast = 101\nfor i in d:\n if i < last:\n ans+=1\n last = i\nprint(ans) ", "n,*d=map(int,open(0).read().split())\nprint(len(set(d)))", "def main():\n n = int(input())\n d = set(int(input()) for _ in range(n))\n print(len(d))\n\n\nmain()", "N = int(input())\n\nList = list(int(input()) for i in range(N))\n\nprint(len(set(List)))", "N=int(input())\nd=[int(input()) for i in range(N)]\n\noriginal=[]\nfor i in d:\n if i not in original:\n original.append(i)\nprint((len(original)))\n", "n = int(input())\nd = [input() for i in range(n)]\nprint(len(set(d)))", "n = int(input())\nlst = []\nfor i in range(n):\n d = int(input())\n lst.append(d)\nres = sorted(list(set(lst)))\nprint(len(res))", "n = int(input())\nd = []\nfor i in range(n):\n d.append(int(input()))\n \nprint(len(set(d)))", "n=int(input())\nn_list=[]\nfor i in range(n):\n n_list.append(int(input()))\n\nprint(len(set(n_list)))", "N = int(input())\nd = [int(input()) for i in range(N)]\nd.sort(reverse=True)\nans = 0\nind = 100000\nfor i in range(N):\n if d[i] < ind:\n ans += 1\n ind = d[i]\nprint(ans)", "N = int(input())\nA = sorted([input() for _ in range(N)])\nprint((len(set(A))))\n", "N=int(input())\ns={int(input()) for _ in range(N)}\nprint((len(s)))\n", "n=int(input())\nd=[int(input()) for i in range(n)]\nprint(len(set(d)))", "N=int(input())\nlist=[input() for i in range(0,N)]\n\nprint(len(set(list)))", "n=int(input())\nd=[int(input()) for _ in range(n)]\nprint((len(set(d))))\n", "N = int(input())\nd = set()\nfor i in range(N):\n a = int(input())\n d.add(a)\nprint(len(d))", "#!/usr/bin/env python3\n\ndef main():\n n = int(input())\n print((len(set([int(input()) for i in range(n)]))))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nans = len(set([input() for _ in range(n)]))\nprint(ans)", "with open(0) as f:\n N, *d = list(map(int, f.read().split()))\nd = list(set(d))\nprint((len(d)))\n", "n = int(input())\nd = [int(input()) for _ in range(n)]\nprint(len(set(d)))", "def get_unique_list(seq):\n seen = []\n return [x for x in seq if x not in seen and not seen.append(x)]\n\nn=int(input())\na=[]\nfor i in range(n):\n a.append(int(input()))\n\nb=get_unique_list(a)\nprint(len(b))", "N = int(input())\nD = sorted([int(input()) for _ in range(N)], reverse=True)\ncnt = 1\nfor i in range(len(D)-1):\n if D[i] <= D[i+1]:\n pass\n else:\n cnt += 1\nprint(cnt)", "n = int(input())\nl = list([])\nfor i in range(n):\n l.append(int(input()))\n \ns = set(l)\nprint(len(s))", "# https://atcoder.jp/contests/abc085/tasks/abc085_b\n\n\"\"\"\n\u4e0a\u306e\u307b\u3046\u304c\u9905\u304c\u5c0f\u3055\u304f\u306a\u308b\u3088\u3046\u306b\u91cd\u306d\u308b\n\u2192 \u540c\u3058\u30b5\u30a4\u30ba\u306e\u9905\u306f\u4f7f\u3048\u306a\u3044\n\n\u540c\u3058\u30b5\u30a4\u30ba\u306e\u9905\u306f1\u3064\u3060\u3051\u4f7f\u3063\u3066\uff08\u91cd\u8907\u3092\u6392\u9664\u3057\u3066\uff09\n\u5927\u304d\u3044\u3082\u306e\u304b\u3089\u91cd\u306d\u3066\u3044\u3051\u3070\u3044\u3044\n\n\u4f55\u6bb5\u91cd\u306d\u3089\u308c\u308b\u304b\n= \u4f55\u7a2e\u985e\u306e\u30b5\u30a4\u30ba\u306e\u9905\u304c\u3042\u308b\u304b\n\"\"\"\n\nn = int(input())\nmochi_set = set()\nfor i in range(n):\n size = int(input())\n mochi_set.add(size)\n\nprint((len(mochi_set)))\n", "n = int(input())\nd = [int(input()) for _ in range(n)]\nprint(len(set(d)))", "n=int(input())\nd=[int(input()) for i in range(n)]\nd=list(set(d))\nprint(len(d))", "print(len(set(input()for _ in range(int(input())))))", "n = int(input())\nd = []\n\nfor i in range(n):\n d.append(int(input()))\n\nprint((len(set(d))))\n", "n=int(input())\nk=[]\nfor i in range(n):\n d = int(input())\n k.append(d)\nprint(len(set(k)))", "N = int(input())\n\nm = []\nfor i in range(N):\n m.append(int(input()))\n\nm = sorted(set(m))\nprint(len(m))", "N = int(input())\nd = []\nfor i in range(N):\n d.append(int(input()))\ncnt = 0\nfor i in range(1,101):\n qual = 0\n for j in d:\n if i == j:\n qual = 1\n if qual == 1:\n cnt += 1\nprint(cnt)", "N = int(input())\nmoti_list = []\nfor i in range(N):\n moti_list.append(int(input()))\n\nmoti_list.sort(reverse=True)\ntower = 1\nfor j in range(N - 1):\n if moti_list[j] > moti_list[j + 1]:\n tower += 1\n\nprint(tower)", "N = int(input())\nd = [int(input()) for i in range(N)]\n\nl = []\nfor i in range(N):\n if d[i] not in l:\n l.append(d[i])\n \nprint(len(l))", "N = int(input())\n\nd=[]\nfor i in range(N):\n\td.append(int(input()))\n\ndset = set(d)\nprint(len(dset))", "n = int(input())\nprint((len(set(list([int(input()) for i in range(n)])))))\n", "N = int(input())\nD = []\nfor i in range(N):\n D.append(int(input()))\n\ncount = 0\npreMax = 0\nfor i in range(N):\n if len(D) == 0:\n break\n if preMax != max(D):\n count += 1\n preMax = max(D)\n D.remove(max(D))\n\nprint(count)", "N = int(input())\nd = {}\ndupli = 0\nfor _ in range(N):\n i = input()\n if i in d:\n d[i] += 1\n dupli += 1\n else:\n d[i] = 0\nprint(str(N-dupli))", "n = int(input())\nli = []\nfor i in range(n):\n li.append(int(input()))\nli.sort(reverse=True)\n\ncnt = 1\nfor i in range(n-1):\n if li[i] > li[i+1]:\n cnt += 1\n\nprint(cnt)", "N=int(input())\nd=[int(input()) for _ in range(N)]\nprint((len(set(d))))\n", "N = int(input())\nd = []\nfor i in range(0,N):\n d += [int(input())]\n\nd.sort(reverse=True)\n\nans = 0\n\nx = max(d)+1\nfor i in range(0,N):\n \n if d[i] < x:\n ans += 1\n x = d[i]\n\nprint(ans)", "N = int(input())\nlst = []\n\nfor i in range(N):\n lst.append(input())\n\nprint(len(set(lst)))", "n = int(input())\ns = [int(input()) for i in range(n)]\nprint(len(list(set(s))))", "N = int(input())\nd_lst = []\nD_lst = []\ncnt = 0\nfor i in range(N):\n d = int(input())\n d_lst.append(d)\n\nfor j in range(max(d_lst)+1):\n D = d_lst.count(j)\n D_lst.append(D)\n if D == 0:\n pass\n else:\n cnt += 1\nprint(cnt)", "N = int(input())\nd = [int(input()) for _ in range(N)]\nd.sort()\n\nans = N\nfor i in range(N-1):\n if d[i] == d[i+1]:\n ans -= 1\n \nprint(ans)", "n = int(input())\nprint(len(set([int(input()) for i in range(n)])))", "n = int(input())\nD = []\nfor _ in range(n):\n d = int(input())\n D += [d]\nprint(len(set(D)))", "n = int(input())\nd = list()\nans = 0\nfor i in range(n):\n d.append(int(input()))\n if d[i] not in d[:i]:\n ans += 1\n\nprint(ans)", "N = int(input())\n\nList = sorted(list(set(list(int(input()) for i in range(N)))))\n\nprint((len(List)))\n\n", "N = int(input())\nd = []\nfor i in range(N):\n d.append(int(input()))\n\nnum = [0]*(max(d)+1)\nfor i in range(N):\n num[d[i]] +=1\n\nres = 0\n\nfor i in range(max(d)+1):\n if num[i]:\n res += 1\n\nprint(res)", "N=int(input())\nD = []\nfor _ in range(N):\n d = int(input())\n D.append(d)\n\nD_num=list(set(D))\nprint(len(D_num))", "n = int(input())\nd = []\nfor i in range(n):\n d.append(int(input()))\n\nprint(len(set(d)))", "N = int(input())\nlist1 = []\nfor i in range(N):\n list1.append(int(input()))\n\nset1 = set(list1)\nans = len(set1)\nprint(ans)\n", "n = int(input())\nd = []\nfor num in range(n):\n i = int(input())\n d.append(i)\nsd = set(d)\nprint(len(sd))", "#!/user/bin/env pypy3\nimport sys\nfrom typing import List\n\n\ndef fast_input():\n return sys.stdin.readline()[:-1]\n\n\ndef solve(mochi_list: List[int]) -> int:\n sorted_mochi_list = sorted(mochi_list)\n kagamimochi = set(sorted_mochi_list)\n return len(kagamimochi)\n\n\ndef main():\n n = int(fast_input())\n d = []\n for i in range(n):\n d.append(int(fast_input()))\n result = solve(d)\n print(result)\n\n\nmain()\n", "n = int(input())\nprint(len(set(map(int, [input() for i in range(n)]))))", "def kagami_mochi():\n n = int(input())\n d = []\n for _ in range(n):\n d.append(int(input()))\n d.sort()\n d_unique = list(set(d))\n print(len(d_unique))\ndef __starting_point():\n kagami_mochi()\n__starting_point()", "N = int(input())\nd = list([0]*N)\nfor i in range(N):\n d[i] = int(input())\nd = set(d)\nprint(len(d))", "N=int(input())\nd=[input() for i in range(N)]\ndef ans085(N:int, d:str):\n d=map(int,d)\n return(len(set(d)))\nprint(ans085(N,d))"]
{"inputs": ["4\n10\n8\n8\n6\n", "3\n15\n15\n15\n", "7\n50\n30\n50\n100\n50\n80\n30\n"], "outputs": ["3\n", "1\n", "4\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
14,591
f0771fb39cae16fa27197778dccfd529
UNKNOWN
Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string s (that is, a consecutive part of s). Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of s that starts with A and ends with Z. -----Constraints----- - 1 ≦ |s| ≦ 200{,}000 - s consists of uppercase English letters. - There exists a substring of s that starts with A and ends with Z. -----Input----- The input is given from Standard Input in the following format: s -----Output----- Print the answer. -----Sample Input----- QWERTYASDFZXCV -----Sample Output----- 5 By taking out the seventh through eleventh characters, it is possible to construct ASDFZ, which starts with A and ends with Z.
["s = input()\nfirst_a_index = s.index('A')\nlast_z_index = len(s) - list(reversed(s)).index('Z')\nprint(last_z_index - first_a_index)", "s = input()\nstart = len(s)\nend = 0\nans = 0\n\nfor i in range(len(s)):\n if s[i] == 'A':\n start = min(start , i)\n if s[i] == 'Z':\n end = max(end, i)\n ans = end - start + 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)\n# mod = 10**9 + 7\n#mod = 9982443453\nmod = 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())\ns = input()\nA_idx = s.index('A')\nZ_idx = s[::-1].index('Z')\nln = len(s)\nprint((ln - Z_idx - A_idx))\n", "s = input()\nst = en = 0\nfor i in range(len(s)):\n if s[i] == \"A\":\n st = i\n break\nfor i in range(1,len(s)):\n if s[-i] == \"Z\":\n en = len(s) - i + 1\n break\nprint(en-st)", "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############################################################\nt = si()\nn = len(t)\nfor s in range(n):\n if t[s] == 'A':\n break\n\nfor e in range(n - 1, -1, -1):\n if t[e] == 'Z':\n break\n\nprint(e - s + 1)", "s=input()\nS=len(s)\nmi=[]\nma=[]\nfor i in range(S):\n if s[i]=='A':\n mi.append(i)\n elif s[i]=='Z':\n ma.append(i)\nprint(max(ma)-min(mi)+1)", "import sys\n\nmin_a_index, max_z_index = sys.maxsize, 0\n\nfor index, c in enumerate(list(input())):\n if c == \"A\" and index < min_a_index:\n min_a_index = index\n if c == \"Z\" and index > max_z_index:\n max_z_index = index\n\nprint((max_z_index - min_a_index + 1))\n", "s = input()\nprint(s.rfind('Z')-s.find('A')+1)", "s = input()\na = len(s)\nz = 0\nfor i in range(len(s)):\n if s[i] == \"A\":\n a = min(a,i)\n if s[i] == \"Z\":\n z = max(z,i)\n\nprint(z-a+1)", "s=input()\nprint((len(s)-s[::-1].index('Z'))-s.index('A'))", "s = input()\na = len(s)\nz = 0\nfor i,e in enumerate(reversed(s)):\n if e == \"A\":\n a = len(s) - i -1 \nfor i,e in enumerate(s):\n if e == \"Z\":\n z = i\n\nprint(z-a+1)", "s = input()\n\nfirst_index = s.index('A', 0)\nlast_index = 0\n\nfor i in range(1, len(s)):\n if s[-i] == 'Z':\n last_index = len(s) - i\n break\n\nprint(last_index - first_index + 1)", "import math\n# s=int(input())\nb=input()\nc=[]\nfor i in b:\n c.append(i)\n#a = list(map(int,input().split()))\n#b = list(map(int,input().split()))\n\na1=c[c.index(\"A\"):]\na2=[i for i, x in enumerate(a1) if x==\"Z\"]\nprint(len(a1[:a2[-1]+1]))", "a=input()\nfor i in range(len(a)):\n if(a[i]=='A'):\n b=i\n break\nfor j in range(len(a)-1,-1,-1):\n if(a[j]=='Z'):\n c=j\n break\nprint((c-b+1))\n", "s = list(input())\n\nfor i,j in enumerate(s):\n if j == 'A':\n a = i\n break\nfor i,j in enumerate(s):\n if j == 'Z':\n z = i\nprint(z-a+1)", "s=input()\nn=len(s)\nt=[]\nfor i in range(n):\n t.append(s[n-1-i])\na=s.index('A')\nz=t.index('Z')\nprint(n-z-a)", "n = input()\na = n.find(\"A\")\nz = n.rfind(\"Z\")\nprint(z-a+1)", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n S = input()\n search_string=['A','Z']\n position=[]\n\n#A\u3092\u63a2\u3059\n for i,s in enumerate(S):\n if s==search_string[0]:\n position.append(i)\n break\n\n#Z\u3092\u63a2\u3059\n for r_i,r_s in enumerate(reversed(S)):\n if r_s==search_string[1]:\n position.append(len(S)-r_i)\n break\n\n print(position[1]-position[0])\n\ndef __starting_point():\n main()\n__starting_point()", "S=input()\nleft=0\nwhile S[left]!='A':\n left+=1\nright=len(S)-1\nwhile S[right]!='Z':\n right-=1\nprint((right-left+1))\n", "s=input()\ni = s.index(\"A\")\nj = len(s)-s[::-1].index(\"Z\")\nprint(len(s[i:j]))", "def resolve():\n \"\"\"\u300cA*Z\u300d\u3068\u3044\u3046\u6587\u5b57\u5217\u3067\u6700\u9577\u306e\u9577\u3055\u3092\u51fa\u529b\u3059\u308b\n = \u4e00\u756a\u5de6\u306eA\u3068\u4e00\u756a\u53f3\u306eZ\u3067\u3067\u304d\u308b\u6587\u5b57\u5217\n \"\"\"\n s = input()\n start_index = s.index(\"A\")\n end_index = s.rindex(\"Z\")\n output = end_index - start_index + 1\n print(output)\n\nresolve()", "s = input()\nfor i in range(len(s)):\n if s[i] == 'A':\n p = i\n break\nfor i in range(1,len(s)+1):\n if s[-i] == 'Z':\n q = i-1\n break\nprint(len(s) -(p+q))", "s = input()\nsta = []\nfin = []\nfor i in range(len(s)):\n if s[i] == 'A':\n sta.append(i)\n elif s[i] == 'Z':\n fin.append(i)\nprint(max(fin)-min(sta)+1)", "s = input()\n\nfor i, x in enumerate(s):\n if x == \"A\":\n break\n\nfor j, x in enumerate(s[::-1]):\n if x == \"Z\":\n break\n\nprint((len(s) - i - j))\n", "s=list(input())\ns_inv=list(reversed(s))\na=s.index('A')\nz=s_inv.index('Z')\nprint(len(s)-a-z)", "s = str(input())\nstrFindA = ''\nstrFindZ = ''\n\nfor i in range(len(s)):\n if s[i] == \"A\":\n strFindA = s[i:]\n break\n\nfor i in reversed(range(len(strFindA))):\n if strFindA[i] == \"Z\":\n strFindZ = strFindA[:i+1]\n break\n\nprint(len(strFindZ))", "def main():\n s = input()\n start = 200000\n end = 0\n for i in range(len(s)):\n if s[i] == 'A' and start > i:\n start = i\n elif s[i] == 'Z' and end < i:\n end = i\n print(end - start + 1)\n\n\n\ndef __starting_point():\n main()\n__starting_point()", "s = input()\n\nfirst = s.index('A')\nend = s.rindex('Z')\n\nans = end - first + 1\nprint(ans)", "s = input()\n\na = s.index('A')\nz = len(s) - s[::-1].index('Z')\nprint(z - a)", "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()\nleft = s.index('A')\nright = s.rindex('Z')\nprint((right-left+1))\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "s = input()\nn = len(s)\na = 0\nz = n - 1\n\nfor i in range(n):\n if s[i] == \"A\":\n a = i\n break\n\nfor i in range(n):\n if s[i] == \"Z\":\n z = i\n\nprint((z - a + 1))\n", "s = input()\n\nf = s.find('A')\nl = len(s) - s[::-1].find('Z')\nprint(l - f)", "import sys\ninput = sys.stdin.readline\n\n\ndef read():\n s = input().strip()\n return s,\n\n\ndef solve(s):\n a, z = 0, len(s)-1\n while s[a] != \"A\":\n a += 1\n while s[z] != \"Z\":\n z -= 1\n return z-a+1\n\n\ndef __starting_point():\n inputs = read()\n print((solve(*inputs)))\n\n__starting_point()", "S = input()\nans = S.rfind(\"Z\") - S.find(\"A\") + 1\nprint(ans)", "s = input()\n\ndef first_A(s):\n for i in range(len(s)):\n if s[i] == \"A\":\n return i\n \ndef last_Z(s):\n for i in range(len(s)):\n if s[-(i+1)] == \"Z\":\n return -(i+1)+len(s)\n \nprint(last_Z(s) - first_A(s) + 1)", "s = input()\nsr = s[::-1]\n\nfor i in range(len(s)):\n if s[i] == \"A\" :\n st = i+1\n break\n\nfor i in range(len(s)):\n if sr[i] == \"Z\":\n en = len(s)-i\n break\n\nprint(en - st + 1)", "a = input()\nfor i in range(len(a)):\n if a[i] == \"A\":\n b = i\n break\nfor j in range(len(a)):\n if a[j] == \"Z\":\n c = j\nprint((c-b+1))\n", "s = input()\nstart = s.find('A')\nend = s.rfind('Z',start)\nprint(end - start + 1)", "s=input()\nb=s.index(\"A\")\na=[i for i, x in enumerate(s) if x == 'Z']\nprint(a[-1]-b+1)", "s = input()\na_number = 0\nz_number = 0\n\nfor i in range(len(s)):\n if s[i] == 'A':\n a_number = i\n break\n\nfor j in reversed(range(len(s))):\n if s[j] == 'Z':\n z_number = j\n break\n\nprint(z_number - a_number + 1)", "S = input()\nans = -S[::-1].find(\"Z\") - S.find(\"A\")+len(S)\nprint(ans)\n", "a=input()\nprint(a.rindex(\"Z\")-a.index(\"A\")+1)", "s = input()\nprint(s.rfind(\"Z\")-s.find(\"A\")+1)", "retu = input()\nkari = 0\nflag = False\nfor i in range(len(retu)):\n if flag:\n kari += 1\n if retu [i] == 'Z':\n an = kari\n elif retu[i] == 'A':\n flag = True\n kari += 1\nprint(an)", "s=list(input())\nfor i in range(len(s)):\n if s[i]==\"A\":\n start=i\n break\nfor j in reversed(range(0,len(s))):\n if s[j]==\"Z\":\n last=j\n break\nprint(last-start+1)", "#53 B\ndata=list(input())\ni=0\nj=1\nwhile data[i]!='A':\n i=i+1\nwhile (data[-j]!='Z' and len(data)-j>i):\n j=j+1\nprint(len(data)-i-j+1)", "s=input()\nx=s.find('A')\ns2=s[x:]\ny=s.rfind('Z')\nprint(y-x+1)", "S = input()\ns_list = []\nfor n in S:\n s_list.append(n)\n\na = (s_list.index(\"A\"))+1\n\ns_list.reverse()\nz = (-(s_list.index(\"Z\")+1))\n\nprint(len(S[a:z])+2)", "s = input()\nsize = len(s)\nfor i in range(size):\n if s[i] == 'A':\n head = i\n for j in range(size):\n if s[-1-j] == 'Z':\n tail = j \n break\n break \nprint(size-head-tail)", "s = list(input())\nfor i in range(len(s)):\n if s[i] == \"A\":\n a = i\n break\nfor j in range(len(s)-1, 0, -1):\n if s[j] == \"Z\":\n b = j\n break\nprint(b-a+1)", "s = input()\nprint((s.rfind('Z') - s.find('A') + 1))\n", "s = input()\n\nl = s.index('A')\nr = len(s)-s[::-1].index('Z')\nprint((len(s[l:r])))\n", "S = input()\nN = len(S)\na = 1\nz = 1\nfor i in range(N):\n if S[i] == \"A\":\n break\n else:\n a += 1\n\nfor j in range(1, N+1):\n if S[-j] == \"Z\":\n break\n else:\n z += 1\nans = N - a - z + 2\nprint(ans)", "def main():\n s = input()\n a = len(s); z = 0\n for i, t in enumerate(s):\n if t == 'A':\n a = min(a, i)\n if t == 'Z':\n z = max(z, i)\n ans = z-a+1\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\n\nind_A = 0\nwhile s[ind_A] != 'A':\n ind_A += 1\nind_Z = len(s)\nwhile s[ind_Z - 1] != 'Z':\n ind_Z -= 1\n\nprint(ind_Z - ind_A)", "a=input()\nb=a[::-1]\np=0\n\nfor i in range(len(a)):\n if a[0] !='A':\n a=a[1:]\n else:\n break\n \nfor i in range(len(a)):\n if a[-1] !='Z':\n a=a[:-1]\n else:\n break\n \n \nprint(len(a))", "s = input()\n\nprint((s.rindex('Z') - s.index('A') + 1))\n", "s = input()\na_idx = None\nfor i, c in enumerate(list(s)):\n if c == 'A':\n a_idx = i\n break\nz_idx = None\nfor i, c in enumerate(reversed(list(s))):\n if c == 'Z':\n z_idx = len(s) -i\n break\nprint(len(s[a_idx:z_idx]))", "import re\ns = input()\nsmax=0\nres = re.search(r\"A[A-Z]*Z\",s)\nprint(len(res.group()))", "S = input()\n\nleft = -1\n\nfor i,s in enumerate(S):\n if s == 'A':\n left = i\n break\n\nright = len(S)+1\nfor i in range(len(S)-1, -1, -1):\n if S[i] == 'Z':\n right = i\n break\n\nif left < right:\n print(right-left+1)", "s = input()\nstart = 0\ngoal = 1\nwhile s[start] != \"A\":\n start += 1\nwhile s[-goal] != \"Z\":\n goal += 1\nprint(len(s)-goal-start+1)", "s = input()\nx = s.find('A')\ny = s.rfind('Z')\nprint(y-x+1)", "s = input()\nprint(s.rfind('Z')-s.find('A')+1)", "s = input()\nstart = s.find('A')\nend = s.rfind('Z',start)\nprint(end - start + 1)", "s = input()\na = 0\nz = 0\nfor i in range(len(s)):\n if s[i]==\"A\":\n a = i \n break\nfor i in range(len(s)-1,-1,-1):\n if s[i]==\"Z\":\n z = i \n break \nprint(z-a+1)", "s=input()\nprint((s.rfind('Z')-s.find('A')+1))\n", "s = input()\nlengs = s.rfind(\"Z\") - s.find(\"A\")\nprint(lengs+1)", "s = list(input())\ns_inv = list(reversed(s))\na = s.index('A')\nb = s_inv.index('Z')\nprint(len(s)-a-b)", "s = input()\n\na_index = s.find('A')\nz_index = s.rfind('Z')\n \nprint(z_index - a_index + 1)", "s = input()\n\nfirst_A_find = s.find(\"A\")\nend_Z_find = s.rfind(\"Z\") + 1\n\nprint(end_Z_find - first_A_find)", "s = input()\nprint(s.rfind('Z') - s.find('A') + 1)", "s = input()\na, z = len(s), 0\nfor i in range(len(s)):\n if s[i] == 'A':\n a = min(i, a)\n elif s[i] == 'Z':\n z = max(i, z)\n\nprint(z-a+1)", "s = input()\na = s.find('A')\nz = s.rfind('Z')\nprint(z - a + 1)", "s = input()\nprint(s.rfind(\"Z\")-s.find(\"A\")+1)", "s=input()\nprint(s.rfind(\"Z\")-s.find(\"A\")+1)", "s=list(input())\n\nfor i in range(len(s)):\n if(s[i]=='A'):\n a=i\n break\n\nfor i in range(len(s)-1,-1,-1):\n if(s[i]=='Z'):\n z=i\n break\n\nprint(z-a+1)", "s = list(input())\nt = s.copy()\nt.reverse()\nprint(len(s)-t.index(\"Z\")-s.index(\"A\"))", "s = input()\n\na = s.index('A')\nz = len(s) - s[-1::-1].index('Z')\nprint(z - a)", "s = input()\nbegin = 0\nend = 0\nfor i in range(len(s)):\n if s[i]=='A':\n begin = i\n break\nfor i in range(len(s)-1,-1,-1):\n if s[i]=='Z':\n end = i\n break\nprint(end-begin+1)", "def answer(s: str) -> int:\n return s.rfind('Z') - s.find('A') + 1\n\n\ndef main():\n s = input()\n print((answer(s)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "a=input()\nfor i in range(len(a)):\n if a[i]==\"A\":\n b=i\n break\nfor k in range(len(a)):\n if a[-k-1]==\"Z\":\n c=k\n break\nprint(len(a)-c-b)", "s = input()\nst = s.find(\"A\")\nfor i in range(len(s)):\n n = len(s)-i-1\n t = s[n]\n if t == \"Z\":\n en = n\n break\nprint((en - st + 1))\n", "s = input()\n\nmax_len = 0\npast = -1\nfor i in range(len(s)):\n if s[i] == 'A' and past == -1:\n past = i\n continue\n if s[i] == 'Z':\n max_len = max(max_len, i - past + 1)\n\nprint(max_len)\n", "s = input()\nn = len(s)\nfirst, last = 0,0\n\nfor i in range(n):\n b,f = i+1, n-i\n if s[-1-i] == 'A':\n first = f\n if s[i] == 'Z':\n last = b\n\n# print(first, last)\nprint((last - first+1))\n", "s = input()\n\nfor i in range(len(s)):\n if s[i] == 'A':\n start = i\n break\n\nfor i in range(1, len(s) + 1):\n if s[(-1) * i] == 'Z':\n end = i\n break\n\nprint(len(s) - end - start + 1)", "s = list(input())\n\nwhile s[0] != 'A' or s[-1] != 'Z':\n if s[0] == 'A':\n s.pop()\n elif s[-1] == 'Z':\n s.pop(0)\n else:\n s.pop(0)\n s.pop()\n\nprint(len(s))", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(s: str):\n A = min((i for i, c in enumerate(s) if c == \"A\"), default=len(s))\n Z = max((i for i, c in enumerate(s) if c == \"Z\"), default=0)\n return max(0, Z - 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 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 = input()\na = s.find('A')\nz =s.rfind('Z')\nprint(z-a+1)", "s = input()\nans = [\"\",\"\"]\nfor i in range(len(s)):\n if s[i] == \"A\" and ans[0] == \"\":\n ans[0] = i+1\n if ans[0] != \"\" and s[i]==\"Z\":\n ans[1] = i+1\nprint(ans[1]-ans[0]+1)", "s=str(input())\nfor i in range(len(s)):\n if s[i]==\"A\":\n a=i\n break\nt=s[::-1]\nfor j in range(len(s)):\n if t[j]==\"Z\":\n b=j\n break\n\nprint(len(s)-a-b)", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(s: str):\n return s.rfind(\"Z\") - s.find(\"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 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 = input()\n\na = s.find('A')\nb = s.rfind('Z')\n\nprint(b - a + 1)", "s = input()\nfront = s.find(\"A\")\nback = s.rfind(\"Z\")\nprint(back+1 - front)", "s = str(input())\na = len(s)\nz = 0\nfor i in range(len(s)):\n if s[i] == 'A':\n a = min(a, i)\n if s[i] == 'Z':\n z = max(z, i)\n\nprint((z - a + 1))\n\n", "s = input()\n\ni = s.find(\"A\")\nj = s.rfind(\"Z\")\n\nprint(j + 1 - i)", "s=input()\nfor i in range(len(s)):\n if s[i]==\"A\":\n s=s[i:]\n break\nfor j in range(1,len(s)):\n if s[-j]==\"Z\":\n s=s[:-j]+\"Z\"\n break\nprint(len(s))", "s = input()\n\nfirst_index = s.index('A', 0)\nlast_index = 0\nfor i, ss in enumerate(s):\n if ss == 'Z':\n last_index = i\n\nprint(last_index - first_index + 1)", "s = input()\nn = len(s)\n\nfor i in range(n-1):\n if s[i] == \"A\":\n break\n \nfor j in range(1,n)[::-1]:\n if s[j] == \"Z\":\n break\n \nprint(len(s[i:j+1]))", "s = input()\n\nfirst = s.find(\"A\")\nend = s.rfind(\"Z\")\n\nlength = end - first + 1\nprint(length)"]
{"inputs": ["QWERTYASDFZXCV\n", "ZABCZ\n", "HASFJGHOGAKZZFEGA\n"], "outputs": ["5\n", "4\n", "12\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,639
86c3bf3691cc7cf44541f5c5231b81ae
UNKNOWN
There are N positive integers written on a blackboard: A_1, ..., A_N. Snuke can perform the following operation when all integers on the blackboard are even: - Replace each integer X on the blackboard by X divided by 2. Find the maximum possible number of operations that Snuke can perform. -----Constraints----- - 1 \leq N \leq 200 - 1 \leq A_i \leq 10^9 -----Input----- Input is given from Standard Input in the following format: N A_1 A_2 ... A_N -----Output----- Print the maximum possible number of operations that Snuke can perform. -----Sample Input----- 3 8 12 40 -----Sample Output----- 2 Initially, [8, 12, 40] are written on the blackboard. Since all those integers are even, Snuke can perform the operation. After the operation is performed once, [4, 6, 20] are written on the blackboard. Since all those integers are again even, he can perform the operation. After the operation is performed twice, [2, 3, 10] are written on the blackboard. Now, there is an odd number 3 on the blackboard, so he cannot perform the operation any more. Thus, Snuke can perform the operation at most twice.
["n = int(input())\na = list(map(int, input().split()))\n\ncnt = 0\nfor i in range(n):\n cnt = cnt | a[i]\n\nj = 0\nans = 0\nwhile 1:\n if (cnt >> j & 1 == 0):\n ans += 1\n j += 1\n else:\n break\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\nl = []\nfor i in a:\n cnt = 0\n while i%2 == 0:\n cnt +=1\n i //=2\n l.append(cnt)\nprint(min(l))", "n = int(input())\na = list(map(int, input().split()))\n\nans = 1000\nfor i in range(n):\n x = a[i]\n shift = 0\n while(x%2==0):\n x = int(x/2)\n shift+=1\n ans = min(ans, shift)\n if ans == 0:\n break\nprint(ans)", "#81B\nN=int(input())\ndata=map(int,input().split())\ndef wareru(n):\n p=0\n while n%2==0:\n n=n//2\n p=p+1\n return p\nprint(min(map(wareru,data)))", "n = int(input())\na = list(map(int, input().split()))\ncount = 0\n\nwhile True:\n\todd = False\n\tfor x in range(n):\n\t\tif a[x] % 2 != 0:\n\t\t\todd = True\n\t\t\tbreak\n\t\telse:\n\t\t\ta[x] //= 2\n\tif odd: break\n\tcount += 1\n\nprint(count)", "num = int(input())\nnu_list = [int(v) for v in input().split()]\ncount = 0\n#print(nu_list)\nbool = True\nwhile bool == True:\n for i in range(len(nu_list)):\n if nu_list[i] % 2 != 0:\n bool = False\n break\n else:\n nu_list[i] = nu_list[i] // 2\n if bool == True:\n count += 1 \nprint(count)", "N=input()\na=list(map(int,input().split()))\nres=10**9\n\nfor i in a:\n count=0\n while i%2==0:\n count+=1\n i=i/2\n if count<res:\n res=count\nprint(res)", "N = int(input())\nA = [int(i) for i in input().split()]\nB = A.copy()\nOK = True\ncount = 0\nwhile OK:\n for c in range(N):\n if A[c] % 2 == 0:\n A[c] = A[c] // 2\n if A[-1] == (B[-1] / (2 ** (count+1))):\n count += 1\n else:\n OK = False\n break\nprint(count)", "n = int(input())\nA = list(map(int, input().split()))\n\nK = 0\nwhile all(a%2 == 0 for a in A):\n A = [a/2 for a in A]\n K += 1\n \nprint(K)\n", "n=int(input())\na=list(map(int,input().split()))\ncount=-1\nfor j in range(10**5):\n count+=1\n for i in range(n):\n if a[i]%2!=0:\n print(count)\n return\n a[i]//=2\n \nprint(count)", "n = int(input())\na = list(map(int, input().split()))\n\ncnt = 0\n\nwhile True:\n exist_odd = False\n for index in range(len(a)):\n if a[index] % 2 != 0:\n exist_odd = True\n a[index] /= 2\n \n if exist_odd: break\n \n cnt = cnt + 1\n\nprint(cnt)", "import re\ninput()\nAn=input().split()\nprint(min(len((re.findall(\"0+$\",bin(int(a)))+[\"\"])[0]) for a in An))", "N = int(input())\n\nl = list(map(int, input().split()))\n\ncounter = 0\nflag = 1\n\nwhile flag == 1:\n\tfor i in range(len(l)):\n\t\tif l[i] % 2 != 0:\n\t\t\tflag = 0\n\t\t\tbreak\n\t\telse:\n\t\t\tl[i] = int(l[i] / 2)\n\tif flag == 1:\n\t\tcounter += 1\n\nprint(counter)", "n = int(input())\na = list(map(int, input().split()))\n# count = 0\n# list a[i]\u304c\u5076\u6570\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3002\u30eb\u30fc\u30d7\u306f\u3068\u308a\u3042\u3048\u305a\u7701\u7565\u3059\u308b\n\nexist_odd = False\n# in_if = 0\nin_for = 0\n# in_while = 0\nwhile exist_odd == False:\n for i in range(n):\n if a[i] % 2 != 0:\n exist_odd = True\n if n != i:\n in_for -= 1\n break\n else:\n a[i] = a[i] / 2\n # in_if += 1\n # print(in_if)\n in_for += 1\nprint(in_for)", "N = int(input())\nA = list(map(int, input().split()))\ncnt = 0\n\nflag = True\nwhile flag:\n for i in range(N):\n if A[i]%2 == 0:\n A[i]//=2\n else:\n flag = False\n break\n else:\n cnt += 1\n continue\nprint(cnt)\n", "n = int(input())\na_list = list(map(int, input().split()))\nnew_list = []\nans = 0\nwhile True:\n for i in a_list:\n if i % 2 == 1:\n break\n else:\n a = i // 2\n new_list.append(a)\n if len(new_list) < n:\n break\n ans += 1\n a_list = new_list\n new_list = []\n\nprint(ans)", "import numpy as np\n\nN = int(input())\nA = list(map(int,input().split()))\n\nans = 0\n\ndef func1(n):\n return n/2\n\ndef func2(n):\n return n%2\n\ni = 0\nwhile i == 0:\n \n x = list(map(func2,A))\n \n if sum(x) == 0:\n ans += 1\n A = list(map(func1,A))\n else:\n break\n\nprint(ans)\n\n\n", "n = int(input())\na = list(map(int,input().split()))\n\ndef devide(a,c,n):\n even = True\n for i in range(n):\n if a[i] % 2 != 0:\n even = False\n else:\n a[i] = int(a[i] / 2)\n return devide(a,c+1,n) if even else c\nprint(devide(a,0,n))", "def main():\n n = int(input())\n a = list(map(int, input().split(\" \")))\n ans = 0\n while True:\n for i in range(n):\n if a[i] % 2 != 0:\n return ans\n a[i] = a[i] // 2\n ans += 1\n\n\nprint(main())", "num = int(input())\n \nvals = list(map(int,input().split()))\n \ncnt = 0\nflag = True\nwhile(flag):\n\tfor i in range(num):\n\t\tif vals[i] % 2 == 1:\n\t\t\tprint(cnt)\n\t\t\tflag = False\n\t\t\tbreak\n\t\telse:\n\t\t\tvals[i] = vals[i] / 2\n\tcnt += 1", "n = int(input())\na = list(map(int,input().split()))\n\ncount = 0\nwhile True:\n flg = False\n for i in range(n):\n if a[i] % 2 != 0:\n flg = True\n if flg:\n break\n \n for j in range(n):\n a[j] /= 2\n count += 1\nprint(count)", "N = int(input())\nA = list(map(int,input().split()))\nans = 0\nwhile 1:\n flg = 0\n for i in range(N):\n if A[i] % 2 == 0:\n A[i] /= 2\n else:\n flg = 1\n break\n if flg == 1:\n break\n ans += 1\nprint(ans)", "n = input()\na = list(map(int,input().split()))\nans = float(\"inf\")\nfor i in a:\n ans = min(ans, len(bin(i)) - bin(i).rfind(\"1\") - 1)\nprint(ans)", "import numpy as np\n\nN = int(input())\narr = np.array(list(map(int, input().split())))\ncnt = 0\nwhile True:\n if np.sum(arr%2) > 0:\n break\n else:\n arr = arr/2\n cnt += 1\nprint(cnt)\n \n", "N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\n\nwhile True:\n exist_odd = False\n for n in range(N):\n if A[n] % 2 == 1:\n exist_odd = True\n break\n else:\n A[n] //= 2\n if exist_odd: break\n ans += 1\n\nprint(ans)\n", "n = int(input())\na = list(map(int, input().split()))\nans = 0\nwhile True:\n for i in range(n):\n if a[i] % 2 == 1:\n print(ans)\n return\n else:\n a[i] /= 2\n ans += 1\nprint(ans)\n", "N=int(input())\nA=list(map(int,input().split()))\ndef rec(A):\n B=[0]*N\n for i in range(N):\n if A[i] % 2 != 0: return 0\n B[i] = A[i] / 2\n return rec(B)+1\nprint(rec(A))", "n = int(input())\na = list(map(int, input().split()))\ncnt = 0\n\nwhile all(i%2==0 for i in a):\n a = [i//2 for i in a]\n cnt+=1\n\nprint(cnt)\n", "n = int(input())\na = list(map(int, input().split()))\nres = 0\nwhile all(i % 2 == 0 for i in a):\n a = [i/2 for i in a]\n res += 1\nprint(res)", "n = int(input())\na = list(map(int,input().split()))\nx = 0\nt = True\nwhile t:\n for i in range(n):\n if a[i] % 2 == 1:\n t = False\n a[i] /= 2\n x += 1\nprint(x-1)", "N = int(input())\nA = list([0]*N)\nA = list(map(int, input().split()))\n\ncnt = 0\nflag = False\nwhile 1:\n for i in range(N):\n if A[i] % 2 != 0:\n flag = True\n break\n A[i] = A[i] /2\n if flag:\n break\n cnt += 1\nprint(cnt)", "N = int(input())\nA = list(map(int, input().split()))\n\ni = 1\nescape = False\nwhile 1:\n for j in range(N):\n if A[j] % (2 ** i) == 0:\n pass\n else:\n escape = True\n break\n else:\n i += 1\n \n if escape:\n break\n \nprint((i - 1))\n", "N = int(input())\nA = list(map(int, input().split()))\ncount = 0\nroop = True\n\nwhile roop == True:\n for i in range(N):\n if A[i] % 2 == 0:\n A[i] /= 2\n else:\n roop = False\n break\n \n if roop == True:\n count += 1\nprint(count)\n\n\n\n", "N=int(input())\nA=list(map(int,input().split()))\nans_list = []\n\nfor n in A:\n temp = n\n count = 0\n while temp % 2 == 0:\n temp /= 2\n count = count + 1\n ans_list.append(count)\n \nprint(min(ans_list))", "n = int(input())\na = list(map(int, input().split()))\ncount = 0\n# list a[i]\u304c\u5076\u6570\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af\u3002\u30eb\u30fc\u30d7\u306f\u3068\u308a\u3042\u3048\u305a\u7701\u7565\u3059\u308b\n\nexist_odd = False\nwhile exist_odd == False:\n for i in range(n):\n if a[i] % 2 != 0:\n exist_odd = True\n if n != i:\n count -= 1\n break\n else:\n a[i] = a[i] / 2\n count += 1\n # print(count)\nprint(count)", "N=int(input())\nA=list(map(int,input().split()))\ncount=0\n \nwhile all(a%2==0 for a in A):\n A=[a//2 for a in A]\n count+=1\n \nprint(count)", "def f(n, a):\n count = 0\n while True:\n for i in range(n):\n if a[i] % 2 == 0:\n a[i] = a[i] / 2\n else :\n return count\n count += 1\n\nn = int(input())\na = [int(s) for s in input().split()]\nprint(f(n,a))", "import numpy as np\nn = int(input())\nA = np.array(input().split(), np.int64)\n\ncnt = 0\nwhile np.all(A % 2 == 0):\n A = A // 2\n cnt += 1\nprint(cnt)\n", "N = int(input())\na = list(int(x) for x in input().split())\n\nans = 0\nflag = True\nwhile flag:\n for i in range(N):\n if a[i]%2 == 0:\n a[i]/=2\n else:\n flag = False\n break\n if flag:\n ans+=1\n\nprint(ans)", "N = int(input())\nnums = [int(s) for s in input().split()]\ni = 0\ncnt = 0\nwhile True:\n if i == N:\n i = 0\n cnt += 1\n if nums[i % N] % 2 == 1:\n break\n nums[i % N] //= 2\n i += 1\nprint(cnt)", "import numpy as np\nN=int(input())\nA=list(map(int,input().split()))\nA=np.array(A)\n\ncount=0\nflag=True\nwhile flag:\n for i in range(N):\n if A[i]%2==1:\n flag=False\n A=A/2\n if flag:\n count+=1\nprint(count)", "N=int(input())\nA=list(map(int,input().split()))\n\ncnt=0\nflag=True\nwhile flag:\n for i in range(N):\n if A[i]%2==0:\n A[i]//=2\n else:\n flag=False\n break\n else:\n cnt+=1\n continue\n break\nprint(cnt)\n", "def resolve():\n _ = int(input())\n a = list(map(int, input().split()))\n res = 0\n while all(i % 2 == 0 for i in a):\n res += 1\n a = list(map(lambda x: x / 2, a))\n print(res)\n\nresolve()", "n = int(input())\na = list(map(int, input().split()))\nt = True\nans = 0\nwhile t:\n for i in range(n):\n if a[i] % 2 == 1:\n t = False\n break\n else:\n a[i] /= 2\n if t:\n ans += 1\nprint(ans)\n\n", "#!/usr/bin/env python3\nimport math\nimport sys\nsys.setrecursionlimit(10**6)\n\n\nn = int(input())\na = list(map(int, input().split()))\n\nans = 10**10\n\nfor i in a:\n tmp = 0\n while(i % 2 != 1):\n tmp += 1\n i = i//2\n # print(tmp)\n ans = min(ans, tmp)\n\nprint(ans)\n", "n = int(input())\nlist_a = [int(i) for i in input().split()]\nans = 0\nflag = True\nwhile flag:\n for i in range(0, len(list_a)):\n if list_a[i] % 2 == 0:\n list_a[i] = list_a[i] // 2\n else:\n flag = False\n break\n\n if i == len(list_a) - 1:\n ans += 1\n\nprint(ans)", "n = int(input())\nls = list(map(int,input().split()))\nans = float(\"inf\")\nfor i in range(n):\n p = 1\n while True:\n if ls[i] / (2 ** p) % 1 == 0:\n p += 1\n else:\n p -= 1\n break\n if p < ans:\n ans = p\nprint(ans)", "N = int(input())\nA = list(map(int,input().split()))\nans = 10**9\nfor x in A:\n if x % 2 == 1:\n print(0)\n return\n c = 0\n while x % 2 == 0:\n x //= 2\n c += 1\n ans = min(ans, c)\nprint(ans)", "def main():\n\n n = int(input())\n nums = list(map(int, input().split()))\n ans = 0\n flg = True\n while flg:\n for i in range(len(nums)):\n if nums[i] % 2 == 0:\n num = nums[i] / 2\n nums[i] = num\n else:\n flg = False\n break\n if flg:\n ans += 1\n\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\nA_lst = list(map(int, input().split()))\ncnt = 0\nA_lst_c = []\nfor i in range(N):\n while A_lst[i] % 2 == 0:\n A_lst[i] //= 2\n cnt += 1\n if i == 0:\n pass\n else:\n cnt = cnt - A_lst_c[i-1]\n A_lst_c.append(cnt)\nA_lst_c_min = min(A_lst_c)\nprint(A_lst_c_min)", "N = int(input())\nA = list(map(int, input().split()))\n\ndef cnt(x):\n ret = 0\n while x%2 == 0:\n ret += 1\n x //= 2\n return ret\n\nans = 30\nfor a in A:\n ans = min(ans, cnt(a))\n\nprint(ans)", "n = int(input())\nA = [0]*n\nL = list(map(int,input().split()))\nfor i in range(n):\n cnt = 0\n while L[i] % 2 == 0:\n L[i] = L[i]/2\n cnt += 1\n A[i] = cnt\nprint(min(A))", "n = int(input())\na = list(map(int, input().split()))\nans = 0\nfor ans in range(31):\n for i,A in enumerate(a):\n if A%2:\n print(ans)\n return\n a[i] //= 2\n", "import sys\nn = input()\nli = list(map(int,input().split()))\n\n# \u9ed2\u677f\u306b\u304b\u304b\u308c\u3066\u3044\u308b\u6587\u5b57\u306f\u5168\u90e8\u5076\u6570\u304b\uff1f\nfor i in li:\n if i % 2 != 0:\n print(\"0\")\n return\n\n# \u9ed2\u677f\u306b\u304b\u304b\u308c\u3066\u3044\u308b\u6587\u5b57\u3092\u5168\u90e82\u3067\u5272\u3063\u3066\u3044\u304f\ncount = 0\n\nwhile(True):\n for index, item in enumerate(li):\n if item % 2 == 0:\n li[index] = item / 2\n else:\n print(count)\n return\n count += 1", "hoge = input()\nint_line = [int(i) for i in input().split()]\n\ncnt = 0\nflag = False\n\nwhile True:\n for m, i in enumerate(int_line):\n if i % 2 == 0:\n int_line[m] = i/2\n else:\n flag = True\n if flag == True:\n print(cnt)\n break\n else:\n cnt += 1", "N = int(input())\nA = list(map(int, input().split()))\n\ncount = 0\nexist_odd = False\n\nwhile True:\n for i in range(N):\n if A[i] % 2 != 0:\n exist_odd = True\n\n if exist_odd:\n break\n\n for i in range(N):\n A[i] /=2\n\n count +=1\n\nprint(count)", "n = int(input())\na = list(map(int,input().split()))\nans = 0\nflag = False\n\nwhile flag == False:\n for i in range(n):\n if a[i]%2 == 0:\n a[i] /= 2\n else:\n flag = True\n break\n else:\n ans += 1\n\nprint(ans)", "n = int(input())\ndata = list(map(int,input().split()))\nbool = True\ncount = 0\nwhile bool:\n for i in range (n):\n if data[i] % 2 != 0:\n bool = False\n data[i] = data[i] // 2\n if bool == False:\n print(count)\n count += 1\n", "N = int(input())\nA = list(map(int,input().split()))\ncount = 0\nroop = True\n\nwhile roop == True:\n for i in range(N):\n if A[i] % 2 == 0:\n A[i] /= 2\n else:\n roop = False\n break\n if roop == True:\n count += 1\nprint(count)", "n = int(input())\naa = list(map(int, input().split()))\nans = 100\nfor i in range(n):\n x = 0\n while aa[i] > 0:\n if aa[i] % 2 != 0:\n break\n aa[i] //= 2\n x += 1\n ans = min(ans, x)\nprint(ans)\n", "n = int(input())\nli = list(map(int, input().split()))\nb = float('inf')\nfor a in li:\n c = 0\n while a%2 == 0:\n a = a/2\n c += 1\n b = min(b,c)\nprint(b)\n \n", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\nimport numpy as np\n\ndef main():\n n = input()\n A = np.array(input().split(),dtype=np.int32)\n answer=0\n\n while np.all(A%2==0):\n A//=2\n answer+=1\n print(answer)\n\ndef __starting_point():\n main()\n__starting_point()", "getints = lambda: map(int, input().split())\nn = int(input())\na = list(getints())\nans = 10 ** 9\nfor x in a:\n cnt = 0\n while x % 2 == 0:\n x /= 2\n cnt += 1\n ans = min(ans, cnt)\nprint(ans)", "n = int(input())\nary = list(map(int, input().split()))\n\ndef count_ops(ary):\n count = 0\n\n while 1:\n for i, v in enumerate(ary):\n if v % 2 == 1:\n return count\n else:\n ary[i] = v/2\n\n count += 1\n \n return count\n \nprint((count_ops(ary)))\n", "from typing import List\n\n\ndef answer(n: int, a: List[int]) -> int:\n count = 1\n while all(i % 2 ** count == 0 for i in a):\n count += 1\n return count - 1\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()))\nx = 0\nt = True\nwhile t:\n for i in range(n):\n if a[i] % 2 == 1:\n t = False\n else:\n a[i] /= 2\n x += 1\nprint(x-1)", "N = int(input())\nA = list(map(int, input().split()))\n\ncount = 0\nwhile True:\n for i in range(N):\n if A[i] % 2 != 0:\n break\n A[i] = A[i] / 2\n else:\n count+=1\n continue\n break\nprint(count)", "import sys\n\n\ndef solve(N, A):\n count = 0\n while True:\n for i in range(N):\n if A[i] % 2 > 0:\n print(count)\n return\n A[i] = A[i] / 2\n count += 1\n \n\ndef __starting_point():\n N = int(input())\n A = list(map(int, input().split()))\n solve(N, A)\n\n__starting_point()", "n = int(input())\na = [int(x.strip()) for x in input().split()]\nch,ans = 0,0\nflg = 'OK'\nwhile flg == 'OK':\n for x in a:\n if x % 2 == 0:\n ch += 1\n else:\n break\n if ch == n:\n flg = 'OK'\n ch = 0\n ans += 1\n a = list(map(lambda x:int(x/2),a)) # list\u95a2\u6570\u306b\u30cd\u30b9\u30c8\u3057\u306a\u3044\u3068map\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067NG\u306b\u306a\u308b\n else:\n flg = 'NG'\nprint(ans)", "# coding: utf-8\n# Your code here!\n\ndivided_2 = lambda x : int(x / 2)\nenable_divided_2 = lambda x : True if int(x % 2) == 0 else False\n\nn = int(input())\nA = list(map(int, input().split()))\ncnt = 0\n\nwhile(1) : \n if False in list(map(enable_divided_2, A)) : \n break\n A = list(map(divided_2, A))\n cnt += 1\n \nprint(cnt)", "n = int(input())\na = list(map(int,input().split()))\nx = 0\nt = True\nwhile t:\n for i in range(n):\n if a[i] % 2 == 1:\n t = False\n else:\n a[i] /= 2\n if t == True:\n x += 1\nprint(x)", "n = int(input())\na = list(map(int,input().split()))\ncnt = 0\nwhile all([i%2==0 for i in a]):\n a = [i/2 for i in a]\n cnt += 1\nprint(cnt)", "N = int(input())\nA = list(map(int, input().split()))\ncount = 0\nwhile all(a % 2 == 0 for a in A):\n A = [a /2 for a in A]\n count += 1\nprint(count)\n \n", "N = int(input())\nA = list(map(int, input().split()))\nans = 0\nis_end = False\nwhile True:\n for a in A:\n if a%2 != 0:\n is_end = True\n break\n if is_end:\n break\n ans += 1\n A = [a/2 for a in A]\n\nprint(ans)", "n = int(input())\narr = list(map(int, input().split()))\n\ncnt_arr = []\n\nfor ele in arr:\n cnt = 0\n while ele % 2 == 0:\n ele /= 2\n cnt += 1\n cnt_arr.append(cnt)\nprint((min(cnt_arr)))\n", "import numpy as np\nn = int(input())\np = list(map(int, input().split()))\np = np.array(p)\ncnt = 0\nwhile cnt < 10000000:\n for i in p:\n if i % 2 != 0:\n print(cnt)\n return\n cnt += 1\n p = p // 2", "N = int(input())\na = list(map(int,input().split()))\ndev = lambda x : x/2\namari = lambda x : x % 2\nfor i in range(1000):\n amari_a = list(map(amari, a))\n if amari_a.count(1) > 0: break\n a = list(map(dev,a))\nprint(i)", "n = int(input())\na = list(map(int,input().split()))\ny = list()\nfor i in range(n):\n x = 0\n while a[i] % 2 == 0:\n a[i] /= 2\n x += 1\n y.append(x)\nprint(min(y))", "import sys\n\nn = int(input())\na = list(map(int, input().split()))\n\ncnt = [0] * n\n\nwhile 1:\n for i in range(n):\n if a[i] % 2 == 0:\n a[i] /= 2\n cnt[i] += 1\n else:\n print(min(cnt))\n return", "n = int(input())\nl = list(input().split(' '))\n\nflag = True\nt = 0\nwhile True:\n for i, x in enumerate(l):\n if int(x) % 2 == 0:\n l[i] = int(x) / 2\n else:\n flag = False\n break\n if flag:\n t += 1\n else:\n break\n\nprint(t)\n\n", "n=int(input())\na=list(map(int,input().split()))\nb=[]\ncnt=0\nfor i in range(n):\n if a[i]%2==1:\n print('0')\n return\n else:\n while a[i]%2==0:\n cnt += 1\n a[i] /= 2\n b.append(cnt)\n cnt = 0\nprint(min(b))", "# -*- coding:utf-8 -*-\nN = int(input())\nA_list = list(map(int,input().split()))\n\nans_list = []\ntemp_ans = 0\n\nfor value in A_list:\n temp_value = value\n temp_ans = 0\n while temp_value%2 == 0:\n temp_value /= 2\n temp_ans += 1\n\n ans_list.append(temp_ans)\n\nprint(min(ans_list))", "\ndef div_by_2(n):\n res = 0\n while n % 2 == 0:\n n //= 2\n res += 1\n return res\n\nN = int(input())\nA = list(map(int, input().split()))\nprint(min(map(div_by_2, A)))", "#!/usr/bin/env python3\n# atcoder \n# T\u00fcrkler var m\u0131?\n# Herkese memn\u00fcn oldum\nimport sys\n#from heapq import heapify, heappush, heappop\n#from heapq import nlargest, nsmallest\n\niimr = lambda: map(int, sys.stdin.readline().rstrip().split())\nreadline = sys.stdin.readline\n# puorquoi le sys.stdin.buffer.readline() ne fonctionne plus sur atcoder?\n#sys.setrecursionlimit(10 ** 7)\n#INF = 1 << 30 # \u5927\u4f53 1e9\n\n\ndef debug(*x):\n print(*x, file=sys.stderr)\n\n\n# s == self\nclass atcoder():\n def __init__(s):\n f = open(0)\n s.N = int(f.readline())\n s.A = list(map(int, f.readline().split()))\n\n def \u00e7\u00f6zmek(s):\n res = []\n res.append(s.\u95a2\u6570(s.N, s.A))\n print(*res)\t\n \n def \u95a2\u6570(self, n, a):\n guusuu = True\n cnt = 0\n while(guusuu):\n for i in range(n):\n if(a[i] % 2 != 0):\n guusuu = False\n break;\n else:\n a[i] /= 2\n if(guusuu): cnt += 1\n return cnt \n\ndef __starting_point():\n ima = atcoder()\n ima.\u00e7\u00f6zmek()\n\n__starting_point()", "n = int(input())\nline = list(map(int, input().split()))\nans = 30\nfor i in range(n):\n count = 0\n x = line[i]\n while True:\n if x % 2 == 0:\n x = x//2\n count += 1\n else:\n break\n if count < ans:\n ans = count\nprint(ans)\n \n", "n = int(input())\nli = list(map(int,input().split()))\nli.sort()\ncnt = 0\nguu = 0\nfor j in range(100000):\n guu = 0\n for i in range(len(li)):\n if li[i] % 2 == 0:\n guu += 1\n if guu == n:\n for i in range(len(li)):\n li[i] = li[i]//2\n cnt += 1\n else:\n print(cnt)\n return\n", "n = int(input())\nl = list(map(int, input().split()))\nresult = 0\nloop = 0\nwhile True:\n if all(x % 2 == 0 for x in l):\n result += 1\n for data in range(len(l)):\n l[data] = l[data]//2\n else:\n print(result)\n return\n", "n=int(input())\na=list(map(int, input().split()))\nma=len(bin(10**9))\nfor i in range(n):\n cnt=0\n while a[i]%2==0:\n a[i]/=2\n cnt+=1\n ma=min(ma,cnt)\nprint(ma)\n", "n = int(input())\na = list(map(int, input().split()))\n\nfor i in range(100):\n for j in range(len(a)):\n if a[j]%2 == 0:\n a[j] //= 2\n else:\n print(i)\n return\n", "n = int(input())\na_lst = list(map(int, input().split()))\n\nres = []\nfor a in a_lst:\n tmp = a\n cnt = 0\n while tmp % 2 == 0:\n tmp = tmp // 2\n cnt += 1\n res.append(cnt)\nprint(min(res))", "N=int(input())\nli = list(map(int,input().split()))\n\nflag=True\nans=-1\n\nwhile(flag):\n ans+=1\n newlist=[]\n for i in li:\n newlist.append(i//2)\n if i%2!=0:\n flag=False\n li=newlist\nprint(ans)\n", "N = int(input())\nA = list(map(int, input().split()))\n\nans = float('inf')\nfor i in range(N):\n temp = 0\n while A[i] % 2 == 0:\n A[i] /= 2\n temp += 1\n ans = min(ans, temp)\n\nprint(ans)\n", "N = int(input())\nA = list(map(int,input().split()))\n\ncount=0\nfor _ in range(30):\n for i in range(N):\n B=A[i]%2\n if B==1:\n break\n A[i]=A[i]//2\n else:\n count+=1\n continue\n break\nprint(count)", "def is_divide(an):\n for i, a in enumerate(an):\n if a % 2 == 0:\n an[i] = a / 2\n else:\n return False\n \n return True\n\nn = int(input())\nan = list(map(int, input().split()))\n\ncount = 0\nwhile True:\n if not is_divide(an):\n break\n count += 1\n\nprint(count)\n", "n = int(input())\na = list(map(int, input().split()))\nINF = 10 ** 9\n\ndef how_many_times_divisible(x):\n ans = 0\n while x % 2 == 0:\n x /= 2\n ans += 1\n return ans\n\nans = INF\nfor i in range(n):\n if how_many_times_divisible(a[i]) < ans:\n ans = how_many_times_divisible(a[i])\nprint(ans)\n", "def divide(l):\n\tfor i in range(len(l)):\n\t\tif l[i] % 2 == 0:\n\t\t\tl[i] = int(l[i] / 2)\n\t\telse:\n\t\t\treturn False\n\t\t\t\n\treturn True\n\n\nn = int(input())\nl = list(map(int, input().split()))\n\ncount = 0\nwhile divide(l):\n\tcount += 1\n\t\t\nprint(count)", "n = int(input())\na = [int(i) for i in input().split()]\nans = -1\ntrue = 1\n\nwhile true == 1:\n for i in range(n):\n if a[i]%2 != 0:\n true = 0\n break\n else:\n a[i] /= 2\n ans += 1\n\nprint(ans)", "n=int(input())\nn_list=list(map(int,input().split()))\ncount=0\n\ndef check(list):\n for i in range(n):\n if(n_list[i]%2!=0):\n return False\n return True\n\n \n\nwhile(check(n_list)):\n n_list=[k/2 for k in n_list]\n count+=1\nprint(count) ", "N = int(input())\na = list(map(int, input().split()))\nans = 0\nexist = True\n\nwhile exist:\n for i in range(N):\n if (a[i]%2 != 0):\n exist = False\n else:\n a[i] = a[i]//2\n if exist:\n ans += 1\n\nprint(ans)", "n = int(input())\na = [int(s) for s in input().split()]\n\nans = 0\nparity = True\nwhile parity:\n for i in range(n):\n if a[i] % 2 == 0:\n a[i] = a[i] / 2\n else:\n parity = False\n if parity:\n ans += 1 \nprint(ans)"]
{"inputs": ["3\n8 12 40\n", "4\n5 6 8 10\n", "6\n382253568 723152896 37802240 379425024 404894720 471526144\n"], "outputs": ["2\n", "0\n", "8\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
27,408
6c9ea55542591bc27fd47d8f49ebbcc6
UNKNOWN
Snuke loves working out. He is now exercising N times. Before he starts exercising, his power is 1. After he exercises for the i-th time, his power gets multiplied by i. Find Snuke's power after he exercises N times. Since the answer can be extremely large, print the answer modulo 10^{9}+7. -----Constraints----- - 1 ≀ N ≀ 10^{5} -----Input----- The input is given from Standard Input in the following format: N -----Output----- Print the answer modulo 10^{9}+7. -----Sample Input----- 3 -----Sample Output----- 6 - After Snuke exercises for the first time, his power gets multiplied by 1 and becomes 1. - After Snuke exercises for the second time, his power gets multiplied by 2 and becomes 2. - After Snuke exercises for the third time, his power gets multiplied by 3 and becomes 6.
["N = int(input())\n\n# N!\u3092(10^9+7)\u3067\u5272\u3063\u305f\u4f59\u308a\u3092\u6c42\u3081\u308b\n# N!\u305d\u306e\u3082\u306e\u3092\u6c42\u3081\u308b\u5fc5\u8981\u306f\u306a\u304f\u3001\n# x = i*x (mod 10^9+7) \u3068\u66f4\u65b0\u3057\u3066\u3044\u3051\u3070\u3088\u3044\nM = 10**9 + 7\ns = 1\nfor i in range(1, N+1):\n s *= i\n s %= M\n \nprint(s)", "MOD=1000000007\n\nN=int(input())\nans=1\nfor i in range(1,N+1):\n ans*=i\n ans%=MOD\nprint(ans)\n", "import math\nn = int(input())\nprint(math.factorial(n)%(10**9+7))", "N = int(input())\n\nans = 1\nfor i in range(1, N+1):\n ans = i * ans % (10 ** 9 + 7)\nprint(ans)\n", "N = int(input())\nans = 1\nfor i in range(1, N+1):\n ans = ans * i % (10**9+7)\nprint(ans % (10**9+7))", "N = int(input())\n\np = 1\n\nfor n in range(1, N+1):\n p = (p * n) % (pow(10,9) + 7)\n\nprint(p)", "n = int(input())\npow = 1\nfor i in range(n):\n pow *= i+1\n pow = pow%(10**9+7)\nprint(pow)", "N = int(input())\nMOD = 1_000_000_007\nans = 1\nfor i in range(1, N + 1):\n ans *= i\n ans %= MOD\nprint(ans)\n", "a=int(input())\nb=1\nfor i in range(1,a+1):\n b=b*i\n if b>1000000007:\n b=b%1000000007\nif b<1000000000:\n print(b)\nelse:\n print((b%1000000007))\n", "N = int(input())\n\nmod = 10 ** 9 + 7\nans = 1\n\nfor i in range(N):\n ans = ans * (i + 1) % mod\nprint(ans)", "n = int(input())\nmod = 7 + 10**9\nans = 1\n\nfor i in range(1,n+1):\n ans = (ans * i) % mod\nprint(ans)", "import math\nn = int(input())\nmod = 10**9+7\nprint(math.factorial(n)%mod)", "import math\nn = int(input())\nprint(math.factorial(n) % (10**9 + 7))", "import math\nN = int(input())\nprint(math.factorial(N)%(10**9+7))", "N=int(input())\nx=1\nz=10**9+7\nfor n in range(1,N+1):\n x*=n\n x%=z\nprint(x)", "n = int(input())\nmod = 10**9+7\nans = 1\nfor i in range(n):\n ans *= i+1\n ans = ans%mod\nprint(ans)", "import math\n\n\ndef answer(n: int) -> int:\n return math.factorial(n) % (10 ** 9 + 7)\n\n\ndef main():\n n = int(input())\n print((answer(n)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "N=int(input())\npower=1\nfor i in range(1,N+1) :\n power=i*power%(10**9+7)\nprint(power)", "N = int(input())\np = 1\nfor i in range(N):\n p *= i + 1\n p %= 1000000007\nprint(p)", "n = int(input())\nans = 1\nfor i in range(2, n + 1):\n ans = ans * i % (10 ** 9 + 7)\nprint(ans)\n", "N = int(input())\n\npower = 1\n\nfor n in range(1, N+1):\n power = power*n % 1000000007\n\nprint(power)", "import math\nN = int(input())\nprint(math.factorial(N) % (10**9+7))", "a=int(input())\nimport math\n\nb=math.factorial(a)\nprint(b%(10**9+7))", "N = int(input())\nMOD = 10**9+7\nans = 1\nfor i in range(N):\n ans = ans * (i+1) % MOD\nprint(ans)", "n = int(input())\n\nret = 1\n\nfor i in range(n):\n ret *= i + 1\n ret %= 10**9 + 7\nprint(ret)", "N = int(input())\nP = 1\nfor i in range(N):\n P *= i+1\n P %= 10**9 + 7\nprint(P)", "N = int(input())\n\nM = 10**9 + 7\ns = 1\nfor i in range(1, N+1):\n s *= i\n s %= M\n \nprint(s)", "n=int(input())\nx=1\nfor i in range(n):\n x*=(n-i)\n if x>10**9+7:\n y=x//(10**9+7)\n x-=y*(10**9+7)\n\nprint(x)", "# -*- coding: utf-8 -*-\n\nN = int(input())\n\nMOD = 10 ** 9 + 7\nans = 1\nfor i in range(1,N+1):\n ans = (ans * i) % MOD\n\nprint(ans)", "N = int(input())\nans = 1\nfor i in range(2, N + 1):\n ans *= i\n ans %= (10 ** 9) + 7\nprint(ans)", "n = int(input())\nmod = 10**9+7\nans = 1\nfor i in range(1, n+1):\n ans = (ans * i) % mod\nprint(ans)", "n = int(input())\npower = 1\nfor i in range(1,n+1):\n power *= i\n power = power % (10**9 + 7)\nprint(power)", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n n = int(input())\n mod = 10**9+7\n power=1\n\n for i in range(1,n+1):\n power*=i\n power%=mod\n print(power)\n\ndef __starting_point():\n main()\n__starting_point()", "import math\nx = int(input())\nprint(math.factorial(x)%(10**9+7))", "n = int(input())\nd = 1\nfor i in range(1,n+1):\n d = (d*i)%(10**9+7)\nprint(d)", "#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\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\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())\nn = I()\nans = 1\nfor i in range(n):\n ans *= (i+1)\n ans %= mod\nprint((ans%mod))\n", "from functools import reduce\nMOD = 1_000_000_007\nprint((reduce(lambda a,b: a*b%MOD, list(range(1, int(input())+1)))))\n", "import math\nn=int(input())\nprint(math.factorial(n)%(10**9+7))", "#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())\nn = I()\npower = 1\nfor i in range(n):\n power = (power * (i+1)) % mod\n power %= mod\nprint(power)\n", "N = int(input())\nmod = 10**9 + 7\npower = 1\nfor i in range(1, N+1):\n power *= i\n power %= mod\nprint(power)\n", "n = int(input())\nx = 1\nfor i in range(1, n+1):\n x = (x*i)%(10**9+7)\nprint(x)", "import math\nN=int(input())\nprint(math.factorial(N) % (10**9+7))", "n = int(input())\nmod = 10**9+7\npower = 1\nfor i in range(1, n+1):\n power = (power*i)%mod\nprint(power)", "n=int(input())\nk=1\nfor i in range(2,n+1):\n k *= i\n k %= (10**9)+7\nprint(k)", "n = int(input())\np = 10 ** 9 + 7\nans = [1]\nfor i in range(1,n+1):\n ans.append((ans[-1]*i) % p)\nprint((ans[n]))\n", "N = int(input())\nans = 1\nfor i in range(1,N+1):\n ans *= i\n ans %= 10**9+7\nprint(ans)", "N = int(input())\n \npower = 1\nfor i in range(1,N+1):\n power *= i\n if power >= 10**9+7:\n power %= 10**9+7\nprint(power % (10**9+7))", "n = int(input())\nmod = 1000000007\nres = 1\nfor i in range(1, n+1):\n res = res * i % mod\n\nprint(res)", "n = int(input())\nmod = 1000000007\nsu = 1\nfor i in range(1,n+1):\n su = ((su%mod)*(i%mod))%mod\nprint(su%mod)", "import sys, math\nfrom itertools import combinations as c, product as p\nfrom collections import deque\nsys.setrecursionlimit(10**9)\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 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()\nans = 1\n\nfor i in range(N):\n ans *= i + 1\n ans %= MOD\n\nprint(ans)", "import re\nimport copy\n\ndef accept_input():\n N = input()\n return int(N)\n\nN = accept_input()\n\npower = 1\nfor i in range(1,N+1):\n power = (power * i)%(10**9+7)\nprint(power)\n", "n = int(input())\nans = 1\nfor i in range(1,n+1):\n ans = (ans * i)%(10**9+7)\nprint(ans)", "n = int(input())\nmod = 10 ** 9 + 7\n \nres = 1\nfor i in range(1,n+1):\n res *= i\n res %= mod\nprint(res)", "N = int(input())\nmod = 10 ** 9 + 7\n\npower = 1\nfor i in range(1, N+1):\n power *= i\n power %= mod\n \nprint(power % mod)", "import math\nprint((math.factorial(int(input())) % 1000000007))\n", "import math\n\nn = int(input())\nprint((math.factorial(n) % (10 ** 9 + 7)))\n", "MOD = pow(10,9)+7\ndef MODINV(n:int, MOD=MOD):\n return pow(n, MOD-2, MOD)\n\ndef main():\n N = int(input())\n ans = 1\n for i in range(N):\n ans *= i+1\n ans %= MOD\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nmod = 10**9+7\n\nimport math\nprint(math.factorial(N)%mod)", "n = int(input())\nfor i in range(n-1):\n n *= i+1\n n %= 10**9+7\nprint(n)", "from functools import reduce\nMOD = 1_000_000_007\nprint((reduce(lambda a,b: a*b%MOD, list(range(1, int(input())+1)), 1)))\n", "N = int(input())\n\nK = 10**9 + 7\npower = 1\nfor i in range(1, N+1):\n power = power%K\n power *= i\n\nprint(power%K)", "import math\n\nN = int(input())\n\np = 1\nfor i in range(2, N+1):\n p *= i\n p = p % (1000000000 + 7)\n \nprint(p)\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\nMOD = 10 ** 9 + 7\n\n\ndef solve():\n n = ini()\n p = 1\n for i in range(1, n + 1):\n p *= i\n p %= MOD\n return p\n\n\nprint(solve())\n", "import math\nn = int(input())\nprint(math.factorial(n) % (10 ** 9 + 7))", "MOD = 10**9 + 7\nN = int(input())\nans = 1\nfor i in range(2, N + 1):\n ans *= i\n ans %= MOD\nprint(ans)\n", "import math\nN = int(input())\nprint(math.factorial(N) % (10**9+7))", "N = int(input())\nC = 10**9+7\nans = 1\nfor i in range(1, N + 1):\n ans *= i\n ans %= C\nprint(ans)", "n = int(input())\nMOD = 10**9+7\n\np = 1\nfor i in range(1, n+1):\n p *= i\n p %= MOD\n \nprint(p)", "#ABC055B\nn = int(input())\nans = 1\nMOD = 10**9+7\nfor i in range(2,n+1):\n ans*=i\n ans = ans%MOD\nprint(ans) ", "n = int(input())\nres = 1\nmod = 10 ** 9 + 7\nfor i in range(1, n + 1):\n res = res * i % mod\n\nprint(res)\n", "N = int(input())\n\na =1\ndiv = 10**9 +7\n\nfor n in range(1,N+1):\n a *= n\n if a>div :\n a = a%div\n\nprint(a)", "import sys\nfrom math import factorial\nn=int(sys.stdin.readline())\nprint(factorial(n)%(10**9+7))", "n = int(input())\nf = 1\nm = 10**9+7\nfor i in range(1,n+1):\n f = f%m * i\nprint(f%m)", "import math as mt\nn=int(input())\nprint(mt.factorial(n)%(10**9+7))", "n = int(input())\nimport math\nm = math.factorial(n)\nprint(m % (10**9 + 7))", "N=int(input())\nans=1\ninf=10**9+7\nfor i in range(N):\n ans*=i+1\n ans%=inf\nprint(ans)", "n = int(input())\nres = 1\nmod = 10**9+7\nfor i in range(1, n+1):\n res = res*i%mod\nprint(res)", "ans=1\nN=int(input())\nfor i in range(1,N+1):\n ans*=i\n ans%=10**9+7\nprint(ans)", "N = int(input())\ncalc = 1\nfor i in range(1, N+1):\n calc = (i*calc) % (10**9+7)\n\nprint(calc)\n", "N = int(input())\nans = 1\nmod = 1000000007\n\nfor i in range(1, N + 1):\n ans *= i\n ans %= mod\n\nprint(ans)", "import math\n\nN = int(input())\n\nprint((math.factorial(N) % (10 ** 9+7)))\n", "n = int(input())\nmod = 10 ** 9 + 7\npower = 1\nfor i in range(1,n+1):\n power = (power*i)%mod\nprint(power)", "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)]\n\nmod = 10**9 + 7\np = 1\nfor i in range(1, n+1):\n p = (p*i) % mod\nprint(p)\n", "n = int(input())\nans = 1\nmod = 10 ** 9 + 7\nfor i in range(1,n+1):\n ans *= i\n ans %= mod\nprint(ans)", "from math import *\nprint(factorial(int(input())) % (10**9 + 7))", "N = int(input())\n\nmod = 10 ** 9 + 7\n\npower = 1\nfor i in range(1, N + 1):\n power *= i\n power %= mod\n\nprint(power)\n", "n = int(input())\nans = 1\nfor i in range(1, n+1):\n ans *= i\n if ans >= 10**9 + 7:\n ans %= 10**9 + 7\nprint(ans)\n", "import math\nn = int(input())\nprint(math.factorial(n) % (10**9+7))", "import math\nn = int(input())\nprint(math.factorial(n)%(10**9+7))", "import math\nprint(math.factorial(int(input()))%(10**9+7))", "N = int(input())\nans = 1\nmod = pow(10, 9)+7\nfor i in range(1, N+1):\n ans = (ans*i) % mod\nprint(ans)\n", "N = int(input())\n\nans = 1\nmod = 10**9 + 7\nfor i in range(1, N+1):\n ans *= i\n ans %= mod\nprint(ans)", "import math\n\nN = int(input())\n\nprint((math.factorial(N) % (1000000000 + 7)))\n", "n = int(input())\nans = 1\nfor i in range(1, n+1):\n ans = (ans * i ) % 1000000007\n\nprint(ans)", "import math\nn = int(input())\nprint(math.factorial(n)%(10**9+7))", "import math\n\nn = int(input())\nprint(math.factorial(n) % (10 ** 9 + 7))"]
{"inputs": ["3\n", "10\n", "100000\n"], "outputs": ["6\n", "3628800\n", "457992974\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
13,930
3dd5313487e04dbaddcde81834926c94
UNKNOWN
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total? -----Constraints----- - 1≦N≦100 -----Input----- The input is given from Standard Input in the following format: N -----Output----- Print the necessary number of candies in total. -----Sample Input----- 3 -----Sample Output----- 6 The answer is 1+2+3=6.
["N = int(input())\n \nans = int(N*(N+1)/2)\nprint(ans)", "n = int(input())\nprint((n*(n+1)//2))\n", "ans=0\nn=int(input())\nfor i in range(1,n+1):\n\tans+=i\n\t\nprint(ans)\n", "import math\nfrom datetime import date\n\ndef main():\n\t\t\n\tn = int(input())\n\tprint((n * (n + 1) // 2))\n\t\nmain()\n", "n=int(input())\na=0\nfor i in range(n+1):\n a+=i\nprint(a)", "a = 0\n\nx = int(input())\ny = x+1\nfor i in range(y):\n a = a+i\n \n\nprint(a)", "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()\nprint(int((N*(N+1))/2))\n'''\nsum = 0\nfor i in range(N):\n sum += (i+1)\nprint(sum)\n'''", "n = int(input())\nprint(n*(n+1)//2)", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int):\n return sum(range(1, N+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 print((solve(N)))\n\ndef test():\n import doctest\n doctest.testmod()\n\ndef __starting_point():\n #test()\n main()\n\n__starting_point()", "num = int(input())\ntotal = 0\n\nfor n in range(num+1):\n total = total + n\n\nprint(total)", "#1\u2266N\u2266100\na = input()\n#print(type(a))\nb = int(a)\n#print(type(b))\nc=0\n\nfor i in range(1,b+1):\n\tc = c + i\nprint(c)\n", "n = int(input())\n\n\ndef factorial(i: int):\n if i == 1:\n return 1\n else:\n return i + factorial(i - 1)\n\n\nprint((factorial(n)))\n", "n = int(input())\nans = 0\nfor i in range(1, n + 1):\n ans += i\n\nprint(ans)\n", "N = int(input())\nans = 0\n\nfor i in range(N):\n ans += i + 1\n\nprint(ans)", "N = int(input())\na = 0\nfor i in range(1,N + 1):\n a =i + a\nprint(a)", "n = int(input())\nprint(int((n + 1) * n / 2))", "n = int(input())\nanswer = n*(n+1)//2\nprint(answer)\n", "N = input()\n\nval = int(N) + 1\ns = 0\n\nfor i in range(val):\n s += i\n\nprint(s)", "n = int(input())\nsum = 0\nfor i in range(1, n+1):\n sum += i\nprint(sum)\n", "n = int(input())\n\nc = (1 + n) * n / 2\n\nprint(int(c))", "a = int(input())\nans = 0\nfor i in range(a):\n ans += i+1\nprint(ans)", "x = int(input())\nprint((x*(x+1)//2))\n", "import math\nprint(sum(list(range(1,int(input())+1))))", "a = int(input())\nprint((a*(a+1)//2))\n", "N = int(input())\n\nans = 0\nfor i in range(1, N + 1):\n ans += i\nprint(ans)", "n=int(input())\nprint(n*(n+1)//2)", "N = int(input())\nprint((1+N)*N//2)", "def iroha():\n count = int(input())\n result = 0\n for i in range(count+1):\n result += i\n\n print(result)\n\n\ndef __starting_point():\n iroha()\n__starting_point()", "n = int(input())\nsums = 0\nfor i in range(n+1):\n sums += i\n\nprint(sums)", "print(sum([x for x in range(1, int(input())+1)]))", "# N\u306e\u5165\u529b\u53d7\u4ed8\nN = int(input())\n# 1\uff5eN\u306e\u5408\u8a08\u3092\u8a08\u7b97\nSUM = 0\nfor i in range(N):\n SUM = SUM + i + 1\nprint(SUM)\n", "n = int(input())\ncount = 0\nwhile n > 0:\n count += n\n n -= 1\n \nprint(count)", "n = int(input())\nprint(n*(n+1)//2)", "N = int(input())\nprint(N*(N+1)//2)", "N = int(input())\n\nL = list(range(N+1))\nprint(sum(L))", "sum = 0\nfor i in range(1,int(input())+1):\n sum += i\n \nprint(sum)", "sum = 0\nnum = int(input())\nfor i in range(1, num+1):\n sum += i\n\nprint(sum)", "number = int(input())\n\nanswer = 0\nfor i in range(1, number + 1):\n answer += i\n\nprint(answer)", "n = int(input())\nres = n * (n + 1) // 2\nprint(res)\n", "n = int(input())\nprint(n * (n + 1) // 2)", "n = int(input())\nsum = 0\nfor i in range(n +1):\n sum += i\n\nprint(sum)\n", "N=int(input())\nprint(N*(N+1)//2)", "n = int(input())\ntotal = 0\nfor i in range(1,n+1):\n total += i\nprint(total)\n", "n = int(input())\nprint((n*(n+1)//2))\n", "N = int(input())\ndoces = 0\ncount = N\n\nwhile count > 0:\n doces += count\n count -= 1\nprint (doces)", "n=int(input())\ns=0\nfor i in range(1,n+1):\n s+=i\nprint(s)", "# \u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u3068N\u4eba\u306e\u5b50\u4f9b\u30a4\u30fc\u30b8\u30fc\n\nN = int(input())\n\nanswer = N + N * (N - 1) // 2\n\nif 1 <= N <= 100:\n print(answer)\nelif N <= 0 or 100 < N:\n print('Out of range')", "N = int(input())\nans = 0\n\nfor i in range(0, N + 1):\n ans += i\nprint(ans)", "n=int(input());print(n*(n+1)//2)", "a = int(input())\nresult = 0\nfor i in range(a+1):\n result+=i\nprint(result) ", "\"\"\"\nABC043 A \u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u3068N\u4eba\u306e\u5b50\u4f9b\u30a4\u30fc\u30b8\u30fc\nhttps://atcoder.jp/contests/abc043/tasks/abc043_a\n\"\"\"\n\nx = int(input())\nprint((x*(x+1)//2))\n", "import math\nN = int(input())\n\nsum = math.floor((N * (1 + N))/2)\n\nprint(sum)", "n=int(input())\nprint(n*(n+1)//2)", "N=int(input())\nprint((int((N*(N+1))/2)))\n", "N=int(input())\nprint((N*(N+1))//2)", "Candy = int(input())\nans = 0\n \nfor i in range(Candy):\n ans += i + 1\n \nprint(ans)", "n = int(input())\n\ns = 0\nfor i in range(n):\n s += i\nprint(s+n)", "a = int(input())\nprint((a*(a+1))//2)", "N = int(input())\nprint(int(N * (N + 1) / 2))", "N=int(input())\ns=0\nfor i in range(0,N+1):\n s=s+i\nprint(s)", "from sys import stdin, stdout\nfrom time import perf_counter\n\nimport sys\nsys.setrecursionlimit(10**9)\nmod = 10**9+7\n\n\n\n\n\nn = int(input())\nresutl = (n * (n + 1))//2\nprint(resutl)", "n = int(input())\ntemp = (n*(n+1))//2\nprint(temp)", "n = int(input())\nprint((n*(n+1))//2)", "import math\nn = int(input())\n\nprint(math.floor(n/2*(n+1)))", "n = int(input())\nx = 0\nfor i in range(1, n+1):\n x += i\nprint(x)", "N = int(input())\nprint(N * (N + 1) // 2)", "n = int(input())\n\nprint((n*(n+1)//2))\n", "n = int(input())\nprint(((n+1)*n//2))\n", "from sys import stdin\ninput = stdin.readline\n\nN = int(input())\n\nif N % 2 == 1:\n print(N * (N+1)//2)\nelse:\n print((N+1) * N//2)", "n = int(input())\nprint((int(n*(n+1)/2)))\n\n", "n = int(input())\n\nc = 0\nwhile n!=0:\n c += n\n n -= 1\nprint(c)", "N=int(input())\n\nx=int((N+1)*N/2)\n\nprint(x)", "n=int(input())\nmemo=[0]*110\nmemo[1]=1\nfor i in range(2,105):\n memo[i]=memo[i-1]+i\nprint(memo[n])", "\nn = int(input())\nm = 0\nfor i in range(1,n+1):\n m += i\n\nprint(m)", "N = int(input())\ncnt = 0\nfor i in range(N+1):\n cnt += i\nprint(cnt)", "N = int(input())\n \ncandy=(1+N)*N/2\nprint(int(candy))", "n = int(input())\n\nprint(sum(range(n+1)))", "n = int(input())\n\nans = 0\n\nfor i in range(1,n+1):\n ans += i\nprint(ans)", "n = int(input())\nprint(n*(n+1)//2)", "N=int(input())\nk=0\n\nfor i in range(N+1):\n k +=i\n \nprint(k)", "N = int(input())\nprint(N*(N+1)//2)", "n = int(input())\nans = n*(n+1)//2\nprint(ans)", "N=int(input())\nprint(N*(N+1)//2)", "n=int(input());print(n*(n+1)//2)", "n = int(input())\na = 0\nfor i in range(n+1):\n a = a+i\n\nprint(a)", "N=int(input())\n\nprint((1+N)*N//2)", "N = int(input())\n\nans = 0\n\nfor i in range(N):\n ans += i + 1\nprint(ans)", "n=int(input())\n\nprint(n*(n+1)//2)", "def main():\n n = int(input())\n\n ans = int(n * (n+1) / 2)\n print(ans)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\n\nsum = 0\nfor i in range(1,N+1):\n sum += i\n\nprint(sum)", "N = int(input())\nSum = 0\nfor i in range(1, N + 1):\n Sum += i\nprint(Sum)", "n = int(input())\nprint (n * (n + 1) // 2)", "n = input()\ncu = 0\ncd = 0\nfor i in range(int(n)):\n cu+=1\n cd+=cu\n\nprint(cd)", "N = int(input())\nans = 0\nfor i in range(N + 1):\n ans += i\nprint(ans)\n", "print(sum(range(int(input())+1)))", "print(sum(list(range(int(input())+1))))", "# \u30ad\u30e3\u30f3\u30c7\u30a3\u30fc\u3068N\u4eba\u306e\u5b50\u4f9b\u30a4\u30fc\u30b8\u30fc\n\nN = int(input())\n\nanswer = N + N * (N - 1) // 2\n\nprint(answer)", "n = int(input())\nans = 0\nfor i in range(1, n + 1):\n ans += i\nprint(ans)", "ans = 0\na=int(input())\nfor i in range(a+1):\n\tans+=i\nprint(ans)", "N=int(input());num=0\nfor i in range(N):num+=i+1\nprint(num)"]
{"inputs": ["3\n", "10\n", "1\n"], "outputs": ["6\n", "55\n", "1\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
8,399
8806bde88218d118c8a0f78f019ff2d0
UNKNOWN
We have N cards. A number a_i is written on the i-th card. Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first. The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score. -----Constraints----- - N is an integer between 1 and 100 (inclusive). - a_i \ (1 \leq i \leq N) is an integer between 1 and 100 (inclusive). -----Input----- Input is given from Standard Input in the following format: N a_1 a_2 a_3 ... a_N -----Output----- Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores. -----Sample Input----- 2 3 1 -----Sample Output----- 2 First, Alice will take the card with 3. Then, Bob will take the card with 1. The difference of their scores will be 3 - 1 = 2.
["def main():\n N = int(input())\n A = list(map(int, input().split()))\n alice = 0\n bob = 0\n A.sort(reverse=True)\n for i, a in enumerate(A):\n if i%2 == 0:\n alice += a\n else:\n bob += a\n print((alice - bob))\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = list(map(int, input().split()))\na.sort(reverse=True)\nalice = 0\nbob = 0\nfor i in range(0,n,2):\n alice += a[i]\n if i == n-1:\n break\n bob += a[i+1]\nprint(alice-bob)", "i = input()\nl = list(map(int, input().split()))\n\ndl = list(sorted(l))\ndl = list(reversed(dl))\n\nans = 0\n\nfor i in range(len(dl)):\n if i % 2 == 0:\n ans += dl[i]\n else:\n ans -= dl[i]\n\nprint(ans)\n", "N = int(input())\na = list(map(int,input().split()))\n\nA = sorted(a,reverse=True)\nalice = sum(A[0::2])\nbob = sum(A[1::2])\n\nprint(alice - bob)", "n = int(input())\nc = list(map(int,input().split()))\nc.sort(reverse = True)\na = 0\nb = 0\nif n % 2 == 0:\n for i in range(n // 2 ):\n a += c[i * 2]\n b += c[i * 2 + 1]\nelse:\n for i in range(n // 2 ):\n a += c[i * 2]\n b += c[i * 2 + 1]\n a += c[n - 1]\n\nprint(a - b)", "n = int(input())\nlist_a = sorted([int(i) for i in input().split()], reverse=True)\nans = 0\nfor i in range(0, len(list_a)):\n if i % 2 == 0: ans += list_a[i]\n else: ans -= list_a[i]\nprint(ans)", "n = int(input())\ni = list(map(int, input().split()))\ni.sort(reverse=True)\nprint(sum(i[0::2])-sum(i[1::2]))", "n = int(input())\na = sorted(list(map(int, input().split())), reverse=True)\nprint(sum(a[::2]) - sum(a[1::2]))", "n = int(input())\na = list(map(int, input().split()))\n\nAlice = []\nBob = []\na.sort()\na.reverse()\n\nfor x in range(n):\n if x % 2 == 0:\n Alice.append(a[x])\n else:\n Bob.append(a[x])\n\nprint(sum(Alice) - sum(Bob))", "n=int(input())\nans=0\nA=sorted(list(map(int,input().split())))[::-1]\nfor i in range(n):\n if i % 2 == 0:\n ans += A[i]\n else:\n ans -= A[i]\nprint(ans)", "def max_index(a: list) -> int:\n return a.index(max(a))\n\n\ndef main():\n n = int(input())\n a = list(map(int, input().split()))\n alice_number = 0\n bob_number = 0\n while len(a) > 0:\n alice_number += a.pop(max_index(a))\n if len(a) == 0:\n break\n else:\n bob_number += a.pop(max_index(a))\n print((alice_number - bob_number))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\ncards = list(map(int, input().split()))\nalice = []\nbob = []\n\ncards.sort(reverse=True)\n\nfor i in range(N):\n if i%2 == 0:\n alice.append(cards[i])\n else:\n bob.append(cards[i])\n\nprint((sum(alice) - sum(bob)))\n", "N = int(input())\na = list(map(int, input().split()))\n\ndef sort_reverse(n):\n n.sort(reverse=True)\n return n\n\nN_Even = list(range(0, N, 2))\nN_Odd = list(range(1, N, 2))\na1 = sort_reverse(a)\nsum1 = 0\nsum2 = 0\n\nfor i in N_Even:\n sum1 += a1[i]\nfor j in N_Odd:\n sum2 += a1[j]\n\nprint(sum1 - sum2)", "for a in sorted(map(int,[*open(c:=0)][1].split())):c=a-c\nprint(c)", "N = int(input())\nA = list(map(int, input().split()))\nA.sort()\nAlice = 0\nBob = 0\nwhile 1:\n try:\n Alice += A.pop(-1)\n except IndexError:\n break\n try:\n Bob += A.pop(-1)\n except IndexError:\n break\nprint(Alice-Bob)", "def main():\n\n n = int(input())\n cards = list(map(int, input().split()))\n cards.sort(reverse=True)\n alice, bob = 0, 0\n if n % 2 == 0:\n for i in range(int(n / 2)):\n alice += cards[2 * i]\n bob += cards[2 * i + 1]\n else:\n for j in range(int(n / 2)):\n alice += cards[2 * j]\n bob += cards[2 * j + 1]\n alice += cards[n - 1]\n ans = alice - bob\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\nli = list(map(int,input().split()))\nli.sort(reverse = True)\nif n % 2 == 0:\n a = 0\n b = 0\n for i in range(int(n/2)):\n a += li[2*i]\n b += li[2*i+1]\n ans = a - b\n print(ans)\nelse:\n a = 0\n b = 0\n for i in range(int((n-1)/2)):\n a += li[2*i]\n b += li[2*i+1]\n ans = a + li[n-1] - b\n print(ans)", "def ans088(N:int, a: str):\n a = list(map(int, a.split()))\n list.sort(a,reverse=True)\n Alice_count=0\n Bob_count=0\n for i in range(len(a)):\n if (i+1)%2==1:\n Alice_count+=a[i]\n else:\n Bob_count+=a[i]\n return Alice_count-Bob_count\n\nN=int(input())\na=input()\nprint((ans088(N,a)))\n\n", "import sys\nlines = [s.rstrip(\"\\n\") for s in sys.stdin.readlines()]\nn, = [int(num) for num in lines.pop(0).split(\" \")]\na_list = [int(num) for num in lines.pop(0).split(\" \")]\na_list.sort(reverse=True)\nalice_sum = sum(a_list[i] for i in range(0, n, 2))\nbob_sum = sum(a_list) - alice_sum\nprint((alice_sum - bob_sum))\n", "n = int(input())\nai = list(map(int, input().split()))\nai_sort = sorted(ai, reverse=True)\nalice = ai_sort[::2]\nprint(sum(alice) - (sum(ai) - sum(alice)))", "_,s=open(c:=0)\nfor a in sorted(map(int,s.split())):c=a-c\nprint(c)", "n = int(input())\na = list(map(int, input().split()))\n\na = sorted(a, reverse=True)\nalice = 0\nbob = 0\nfor i in range(len(a)):\n if i%2==0:\n alice += a[i]\n if i%2==1:\n bob += a[i]\nprint(alice-bob)", "N = int(input())\nA = list(map(int, input().split()))\nA.sort()\n\nS = 0\nT = 0\nans = 0\n\nfor i in range(N):\n if N%2 == 0:\n if i%2 != 0:\n S += A[i]\n else:\n T += A[i]\n ans = S - T\n else:\n if i%2 != 0:\n T += A[i]\n else:\n S += A[i]\n ans = S - T\n\nprint(ans)\n", "n=int(input())\na=list(map(int,input().split()))\ns=0\na.sort()\ns=sum(a[:n:2])-sum(a[1:n:2])\nif s>0:\n print(s)\nelse:\n print(-s)", "n = int(input())\nai = list(map(int, input().split()))\nai_sort = sorted(ai)\nalice = []\nfor i in range(-1, -n - 1, -2):\n alice.append(ai_sort[i])\nprint(sum(alice) - (sum(ai) - sum(alice)))", "N = int(input())\na = sorted(map(int,input().split()),reverse=True)\nprint(sum(a[0::2])-sum(a[1::2]))", "N = int(input())\nnums = list(map(int, input().split()))\nnums.sort(reverse=True)\nAlice = []\nBob = []\ni = 0\nif N % 2 == 0:\n while i<=N-1:\n Alice.append(nums[i])\n Bob.append(nums[i+1])\n i += 2\nelse:\n while i<=N-2:\n Alice.append(nums[i])\n Bob.append(nums[i+1])\n i += 2\n Alice.append(nums[N-1])\nsum_allice = sum(Alice)\nsum_bob = sum(Bob)\nanswer = sum_allice - sum_bob\nprint(answer)", "n = int(input())\na = list(map(int,input().split()))\na.sort(reverse=True)\nnum = len(a)\nalice = []\nbob = []\ncoun = 1\nfor i in a:\n if coun % 2 == 1:\n alice.append(i)\n else:\n bob.append(i)\n coun += 1\nans = abs(sum(alice) - sum(bob))\nprint(ans)", "n = int(input())\ndata = list(map(int,input().split()))\ndata.sort(reverse = True)\nprint(sum(data[::2]) - sum(data[1::2]))", "#!/usr/bin/env python3\n\nn = int(input())\na = list(map(int, input().split()))\n\na.sort(reverse=True)\n\nx = 0\ny = 0\nfor i in range(len(a)):\n if i % 2 == 0:\n x += a[i]\n else:\n y += a[i]\n\nprint((x-y))\n", "N=int(input())\na = list(map(int,input().split()))\n\na.sort(reverse=True)\nalice=0\nbob=0\ntf=True\nfor i in a:\n if tf:\n alice+=i\n else:\n bob+=i\n tf=not tf\nprint((alice-bob))\n", "n = input()\na = sorted(list(map(int,input().split())),reverse=True)\n\nprint((sum(a[::2])-sum(a[1::2])))\n", "n = int(input())\nli = list(map(int,input().split()))\nli.sort(reverse=True)\nalice = []\nbob = []\nfor i in range(n):\n if i % 2 == 0:\n alice.append(li[i])\n else:\n bob.append(li[i])\nprint(sum(alice)-sum(bob))", "N = int(input())\na = list(map(int, input().split()))\na.sort(reverse=True)\nAlice, Bob = 0, 0\n\nfor i in range(N):\n if i % 2 == 0:\n Alice += a[i]\n else:\n Bob += a[i]\nprint(Alice - Bob)", "N = int(input())\na = list(map(int, input().split()))\n\na.sort()\na.reverse()\n\nalice = 0\nbob = 0\nfor i in range(N):\n if i % 2 == 0:\n alice += a[i]\n else:\n bob += a[i]\nprint((alice - bob))\n", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, a: \"List[int]\"):\n a = list(reversed(sorted(a)))\n alice = [a_[1] for a_ in enumerate(a) if a_[0] % 2 == 0]\n bob = [a_[1] for a_ in enumerate(a) if a_[0] % 2 == 1]\n # print(alice, bob)\n print((sum(alice) - sum(bob)))\n return\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\ndef main():\n def iterate_tokens():\n for line in sys.stdin:\n for word in line.split():\n yield word\n tokens = iterate_tokens()\n N = int(next(tokens)) # type: int\n a = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n solve(N, a)\n\ndef __starting_point():\n main()\n\n__starting_point()", "from typing import List\n\n\ndef answer(n: int, a: List[int]) -> int:\n alice = 0\n bob = 0\n\n a.sort(reverse=True)\n for i in range(0, len(a), 2):\n alice += a[i]\n for j in range(1, len(a), 2):\n bob += a[j]\n\n return abs(alice - bob)\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()", "def resolve():\n N = int(input())\n an = sorted([int(n) for n in input().split()], reverse=True)\n\n print(sum(an[::2]) - sum(an[1::2]))\n\n\ndef __starting_point():\n resolve()\n__starting_point()", "n=int(input())\na=list(map(int,input().split()))\ns=0\na.sort()\ns=sum(a[:n:2])-sum(a[1:n:2])\n\nprint(abs(s))", "n = int(input())\na = list(map(int, input().split()))\nalice = 0\nbob = 0\na.sort(reverse = True)\nfor i in range(0, n, 2):\n alice += a[i]\nfor i in range(1, n, 2):\n bob += a[i]\nprint(alice - bob)", "N = int(input())\na = list(map(int, input().split()))\na.sort(reverse=True)\nAlice = 0\nBob = 0\nflag=True\nfor i in a:\n if flag==True:\n Alice += i\n flag = False\n else:\n Bob += i\n flag = True\nprint((Alice-Bob))\n", "n=int(input())\na=list(map(int,input().split()))\na.sort(reverse=True)\nalice=0\nbob=0\nfor i in range(n):\n if i%2==0:alice+=a[i]\n else:bob+=a[i]\nprint(alice-bob)", "n = int(input())\na = list(map(int, input().split()))\nsa = sorted(a, reverse = True)\nal = 0\nbo = 0\nfor i in range(n):\n if i % 2 == 0:\n al += sa[i]\n else:\n bo += sa[i]\nprint((al - bo))\n", "n=int(input())\nlst=list(map(int,input().split()))\n\nalice=0\nbob=0\n\nlst.sort()\nfor i in range(n):\n if i%2==0 :\n alice+=lst.pop()\n else :\n bob+=lst.pop()\nprint((alice-bob))\n", "n = int(input())\na = sorted(list(map(int, input().split())),reverse = True)\nAlice = 0\nBob = 0\ncount = 0\n\nwhile True:\n Alice += a[count]\n count += 1\n if count == n:\n print(Alice - Bob)\n return\n Bob += a[count]\n count += 1\n if count == n:\n print(Alice - Bob)\n return", "N = int(input())\na = list(map(int,input().split()))\na.sort(reverse=True)\n\nAlice_point = 0\nBob_point = 0\n\nfor i in range(N):\n if i % 2 == 0:\n Alice_point += a[0]\n a.pop(0)\n\n else:\n Bob_point += a[0]\n a.pop(0)\n\nprint(Alice_point - Bob_point)", "n = int(input())\na = sorted(list(map(int, input().split())), reverse=True)\nprint(sum(a[::2]) - sum(a[1::2]))", "n = int(input())\na = [int(x) for x in input().split()]\na.sort(reverse = True)\nres = 0\nfor i in range(n):\n if i % 2 == 0:\n res += a[i]\n else:\n res -= a[i]\nprint(res)", "N=int(input())\na=list(map(int,input().split()))\na.sort(reverse=True)\nprint((sum(a[::2])-sum(a[1::2])))\n", "N = int(input())\na = list(map(int,input().split()))\n\na.sort(reverse=True)\n\nans = 0\n\nfor i in range(0,N):\n ans = ans + a[i]*(-1)**i\n\n \nprint(ans)\n", "getint = lambda: int(input())\ngetints = lambda: map(int, input().split())\ngetlist = lambda: list(getints())\nn = getint()\na = getlist()\na.sort(reverse=True)\nalice = bob = 0\nfor i in range(n):\n if i % 2:\n bob += a[i]\n else:\n alice += a[i]\nprint(alice - bob)", "N = int(input())\n\ncards = [int(s) for s in input().split()]\nlist.sort(cards, reverse=True)\na_cards = cards[0::2]\nb_cards = cards[1::2]\nprint(sum(a_cards)-sum(b_cards))", "n = int(input())\na = list(map(int, input().split()))\na.sort()\na.reverse()\nx = sum(a[::2])-sum(a[1::2])\nprint(x)\n", "n = int(input())\na=list(map(int, input().split()))\na.sort()\nA = []\nB = []\nfor i in range(1,n+1):\n if i % 2 != 0:\n A.append(a[-i])\n else:\n B.append(a[-i])\nprint(sum(A) - sum(B))", "n = int(input())\na = list(map(int,input().split()))\na = sorted(a,reverse=True)\nA = sum(a[0::2])\nB = sum(a[1::2])\nprint((A - B))\n\n", "N = int(input())\nlist1 = list(map(int,input().split()))\n\nlist1.sort(reverse=True)\n\nalice = 0\nbob = 0\nfor i in range(len(list1)):\n if i % 2 == 0:\n alice += list1[i]\n else:\n bob += list1[i]\n\nprint((alice - bob))\n", "N = int(input())\na = list(map(int,input().split()))\na.sort()\na.reverse()\nalice = 0\nbob = 0\nfor i in range(N) :\n if i%2 == 0 : \n alice += a[i]\n elif i%2 == 1 :\n bob += a[i]\nprint((alice-bob))\n", "N = int(input())\na = list(map(int,input().split()))\n\ncard = list(a)\ncard.sort(reverse=True)\nAlice = []\nBob = []\n\nif len(card) % 2 != 0:\n Alice.append(card[-1])\n card.pop(-1)\n\nwhile card:\n Alice.append(card[0])\n Bob.append(card[1])\n card.pop(0)\n card.pop(0)\n\nprint((sum(Alice)-sum(Bob)))\n", "n = int(input())\na = list(map(int, input().split()))\nalice = 0\nbob = 0\n\na_sort = sorted(a, reverse=True)\n\nfor i in range(n):\n if i%2 == 0:\n alice += a_sort[i]\n else:\n bob += a_sort[i]\n\nprint(alice-bob)", "n = int(input())\na = list(map(int,input().split()))\na.sort(reverse=True)\nal = 0\nbo = 0\nfor i in range(n):\n if i%2==0:\n al += a[i]\n else:\n bo += a[i]\nprint(al-bo)", "N = int(input())\nnums = [int(s) for s in input().split()]\nnums = sorted(nums, reverse=True)\n\nAlice = 0\nBob = 0\ni = 0\nwhile nums:\n if i % 2 == 0:\n Alice += nums.pop(0)\n else:\n Bob += nums.pop(0)\n i += 1\n\nprint(Alice-Bob)", "# coding: utf-8\n# Your code here!\nN=int(input())\nA=list(int(x) for x in input().split())\n\nA.sort(reverse=True)\n\nans=0\nfor i in range(N):\n a=A[i]\n if i%2==0:\n ans += a\n else:\n ans -= a\n \nprint(ans)\n", "N = int(input())\nlst = input().split()\n\nfor i in range(N):\n lst[i] = int(lst[i])\nlst.sort(reverse=True)\n\nAlice = 0\nBob = 0\n\nfor i in range(N // 2):\n Alice += lst[2 * i]\n Bob += lst[(2 * i) + 1]\n\nif N % 2 == 1:\n Alice += lst[-1]\n\nprint(Alice - Bob)", "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 a = sorted(Input(), reverse=True)\n alice = bob = 0\n for i in range(n):\n if i % 2 == 0:\n alice += a[i]\n else:\n bob += a[i]\n \n print(alice - bob)\n\n\nmain()", "N=int(input())\ncard_list=list(map(int,input().split()))\n#\u5404\u81ea\u304c\u81ea\u5206\u306e\u6570\u5b57\u3092\u6700\u5927\u5316\u3059\u308b\u3088\u3046\u306b\u9078\u629e\u3059\u308b\u306e\u304c\u524d\u63d0\u306a\u306e\u3067Alice\u304c\u78ba\u5b9f\u306b\u52dd\u3064\u3002\n#Alice\u306f\uff11\u756a\u76ee\u3001\uff13\u756a\u76ee\u3001\uff15\u756a\u76ee\u3001\uff17\u756a\u76ee\u30fb\u30fb\u30fb\u306b\u53d6\u3063\u3066\u3044\u304f\n#Bob\u306f\uff12\u756a\u76ee\u3001\uff14\u756a\u76ee\u3001\uff16\u756a\u76ee\u3001\uff18\u756a\u76ee\u30fb\u30fb\u30fb\u306b\u53d6\u3063\u3066\u3044\u304f\n#sort\u95a2\u6570\u306b\u306f\u3001\u300creverse\u300d\u3068\u3044\u3046\u5f15\u6570\u304c\u5b58\u5728\u3057\u307e\u3059\u3002reverse\u3092True\u306b\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u300c\u964d\u9806\u300d\u3092\u793a\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\n\ncard_list.sort(reverse=True)\n#print(card_list)\n\ncard_list_Alice=card_list[::2]\n#print(card_list_Alice)\nAlice_score=sum(card_list_Alice)\n#print(Alice_score)\nBob_score=sum(card_list)-Alice_score\n#print(Bob_score)\n#Alice_score=card_list[1]+card_list[3]+\n#Bob_score=card_list[2]+card_list[4]+\n\nprint((Alice_score-Bob_score))\n", "N = int(input())\na_lst = list(map(int, input().split()))\n\na_lst.sort(reverse = True)\n\nA_a_lst = []\nB_a_lst = []\n\nfor i in range(N):\n if i % 2 == 0:\n A_a_lst.append(a_lst[i])\n else:\n B_a_lst.append(a_lst[i])\n\nA_sum = sum(A_a_lst)\nB_sum = sum(B_a_lst)\n\nans = A_sum - B_sum\nprint(ans)", "with open(0) as f:\n N, *A = map(int, f.read().split())\nA.sort(reverse=True)\nAlice = sum(A[::2])\nBob = sum(A[1::2])\nprint(Alice - Bob)", "n = int(input())\na = list(map(int,input().split()))\ncnt = 0\n\na.sort(reverse=True)\n\nfor i in range(n):\n if i%2 == 0:\n cnt += a[i]\n else:\n cnt -= a[i]\n\nprint(cnt)\n", "n = int(input())\nan = list(map(int, input().split()))\n\n\nclass Solution:\n def __init__(self, n, an):\n self.n = n\n self.an = an\n\n @staticmethod\n def __reverse_an():\n r_an = sorted(an, reverse=True)\n return r_an\n\n def answer(self):\n r_an = self.__reverse_an()\n ans = 0\n for index, r_ai in enumerate(r_an):\n if index % 2 == 0:\n ans += r_ai\n else:\n ans -= r_ai\n print(ans)\n\n\nconditions = Solution(n, an)\nconditions.answer()", "N=int(input())\na=list(map(int,input().split()))\na.sort(reverse=True)\n\nalice=0\nfor i in range(0,N,2):\n alice+=a[i]\n\nbob=sum(a)-alice\nprint(alice-bob)", "N = int(input())\n\nA = list(map(int, input().split()))\n\nAlice = 0\nBob = 0\n\nwhile len(A) != 0:\n Alice += max(A)\n A.remove(max(A))\n if len(A) == 0:\n break\n Bob += max(A)\n A.remove(max(A))\n if len(A) == 0:\n break\n\nprint(Alice-Bob)", "#!/usr/local/bin/python3\n# https://atcoder.jp/contests/abc088/tasks/abc088_b\n\n_ = int(input())\nA = sorted(list(map(int, input().split())))[::-1]\n\nans = 0\nfor i, a in enumerate(A):\n if i % 2 == 0:\n ans += a\n else:\n ans -= a\n\nprint(ans)\n", "n = int(input())\nx = list(map(int, input().split()))\n\na = 0\nb = 0\nx = sorted(x)\n\nfor i in range(n):\n if i % 2 == 0:\n a += x.pop()\n else:\n b += x.pop()\n\nprint(a-b)", "n = int(input())\nall_cards = list(map(int, input().split()))\nall_cards.sort(reverse=True)\n\nalice_cards = []\nbob_cards = []\n\nfor i in range(n):\n if i % 2 == 0:\n alice_cards.append(all_cards[i])\n if i % 2 == 1:\n bob_cards.append(all_cards[i])\n\nprint(sum(alice_cards)-sum(bob_cards))", "n = int(input())\na = [int(i) for i in input().split()]\na.sort(reverse=True)\n\nans = 0\nfor i in range(n):\n if i % 2 == 0:\n ans += a[i]\n else:\n ans -= a[i]\n \nprint(ans)", "n = int(input())\ncards = list(map(int,input().split()))\ncards = sorted(cards,reverse=True)\nalice = bob = 0\nfor i in cards[::2]:\n alice += i\nfor j in cards[1::2]:\n bob += j\nprint(alice - bob)", "N = input()\nli = list(map(int,input().split()))\nli.sort(reverse=True)\nAlice = 0\nBob = 0\nfor i in range(len(li)):\n if (i + 1)% 2 == 1:\n Alice += li[i]\n if (i +1)% 2 == 0:\n Bob += li[i]\nprint((Alice - Bob))\n\n", "n = int(input())\na = sorted(list(map(int, input().split())),reverse=True)\nAlice = sum(a[::2])\nBob = sum(a[1::2])\nprint(Alice-Bob)", "n = int(input())\na = list(map(int, input().split()))\nal = []\nbb = []\n\na.sort(reverse=True)\n\nfor i in range(n):\n if i%2 == 1:\n bb.append(a[i])\n else:\n al.append(a[i])\n \nprint((sum(al) - sum(bb)))\n\n", "N = int(input())\nA = list(map(int, input().split()))\nA.sort(reverse=True)\nsum1=0\nsum2=0\nfor num in range(N):\n if num % 2 == 0:\n sum1 += A[num]\n else:\n sum2 += A[num]\nprint(sum1 - sum2)", "N = int(input())\nC = list(map(int,input().split()))\nAlice = []\nBob = []\n\nC = sorted(C,reverse=True)\nfor i in range(0,N):\n if i %2 == 0:\n Alice.append(C[i])\n else:\n Bob.append(C[i])\n\nprint(sum(Alice) - sum(Bob))", "N = int(input())\na = [int(b) for b in input().split()]\nAlice = 0\nBob = 0\n\nfor i in range(1, N+1):\n if i % 2 == 1:\n Alice += a.pop(a.index(max(a)))\n else:\n Bob += a.pop(a.index(max(a)))\n\nprint(str(Alice - Bob))", "n = int(input())\nl = list(map(int, input().split()))\nl.sort(reverse=True)\na = 0\nb = 0\nzyu = 0\nfor i in l:\n if zyu == 0:\n a += i\n zyu = 1\n else:\n zyu = 0\n b += i\nif a < b:\n print((b - a))\nelif a > b:\n print((a - b))\nelse:\n print(\"0\")\n", "N = int(input())\n\na = sorted(list(map(int,input().split())),reverse=True)\n\nAlice = sum([a[i] for i in range(N) if i%2 == 0])\nBob= sum([a[i] for i in range(N) if i%2 == 1])\nprint(Alice-Bob)", "N = int(input())\nA = list(map(int, input().split()))\n\nAlice = 0\nBob = 0\nfor i in range(N):\n maxA = max(A)\n A.remove(maxA)\n if i % 2 == 0:\n Alice += maxA\n else:\n Bob += maxA\n\nprint(\"{}\".format(Alice - Bob))", "n=int(input())\nn_list=list(map(int,input().split()))\nalice=[]\nbob=[]\nwhile(n_list!=[]):\n a=max(n_list)\n alice.append(a)\n n_list.remove(a)\n if(n_list==[]):\n break\n b=max(n_list)\n bob.append(b)\n n_list.remove(b)\nprint(sum(alice)-sum(bob))", "N = input()\ncard = list(map(int, input().split()))\n\nA = []\nB = []\nt = 'A'\nwhile card:\n if t == 'A':\n A.append(max(card))\n card.remove(max(card))\n t = 'B'\n else:\n B.append(max(card))\n card.remove(max(card))\n t = 'A'\n\nprint(sum(A) - sum(B))", "# coding: utf-8\n# Your code here!\n\nn = int(input())\nA = list(map(int, input().split()))\n\nsum_a = 0\nsum_b = 0\n\nsorted_A = sorted(A, reverse = True)\n\nflag = 1\nfor i in sorted_A : \n if flag == 1 : \n sum_a += i\n flag = 0\n else : \n sum_b += i\n flag = 1\n \nprint(sum_a - sum_b)", "n = int(input())\na = list(map(int,input().split()))\na.sort(reverse = True)\nA = 0\nB = 0\nfor i in range(n):\n if i%2 == 0:\n A += a[i]\n else:\n B += a[i]\nprint(A-B)", "N = int(input())\nA = list(map(int,input().split()))\nA.sort(reverse=True)\n\nprint((sum(A[0::2])-sum(A[1::2])))\n", "n = int(input())\na = list(map(int, input().split()))\na.sort(reverse=True)\nans = 0\nfor i in range(n):\n if i%2:\n ans -= a[i]\n else:\n ans += a[i]\nprint(ans)", "n = int(input())\na = [int(s) for s in input().split()]\na.sort(reverse=True)\nalice = sum(a[0:n:2])\nbob = sum(a[1:n:2])\n\nprint(alice - bob)", "n = int(input())\narr = list(map(int, input().split(\" \")))\n\n# Sort arr, firstly\narr.sort(reverse=True)\n\na_arr = []\nb_arr = []\n\nfor (i, ele) in enumerate(arr):\n # Alice\n if i % 2 == 0:\n a_arr.append(ele)\n # Bob\n else:\n b_arr.append(ele)\n\nprint(sum(a_arr) - sum(b_arr))", "n=int(input())\nx = [int(i) for i in input().split()]\nxx = sorted(x)\nans=0\naaa=0\nif n%2==0:\n for i in range(n//2):\n ans+=xx[i*2+1]-xx[i*2]\n print(ans)\nelse:\n for i in range(n//2):\n ans+=xx[i*2+1]-xx[i*2]\n aaa=xx[n-1]-ans\n print(aaa)", "N = int(input())\na = list(map(int,input().split()))\na.sort(reverse=True)\nflag = 0\nalice = 0\nbob = 0\nfor i in range(N):\n if flag == 0:\n alice += a[i]\n #print(\"alice:\"+str(alice))\n flag = 1\n else:\n bob += a[i]\n #print(\"bob:\"+str(bob))\n flag = 0\nprint(alice - bob)", "N = int(input())\na = list(map(int, input().split()))\na.sort(reverse = True)\nans = 0\nfor num in range(N):\n if num % 2 == 0:\n ans += a[num]\n else:\n ans -= a[num]\nprint(ans)", "N = int(input())\na = list(map(int, input().split()))\na.sort(reverse=True)\n\nA = 0\nB = 0\nfor i in range(N):\n if i % 2 ==0:\n A += a[i]\n else:\n B += a[i]\n\ndiff = A - B\nprint(diff)", "def solve1(n, lst):\n alice, bob = 0, 0\n\n #print(\" i |a[i]|Alice|Bob\")\n # print(\"------------------\")\n\n for i in range(n):\n if i % 2 == 0:\n alice += lst[i]\n else:\n bob += lst[i]\n # print(f\"{i:3d}|{a[i]:3d}|{alice:5d}|{bob:5d}\")\n\n return alice - bob\n\n\nn = int(input())\na = list(map(int, input().split(\" \")))\na.sort(reverse=True)\nprint((solve1(n, a)))\n", "import numpy as np\n\nn = int(input())\na = list(map(int, input().split()))\n\na = sorted(a, reverse=True)\na = np.array(a)\nnum_i_even = [i for i in range(n) if i%2==0]\nnum_i_odd = [i for i in range(n) if i%2!=0]\n\nsum1 = np.sum(a[num_i_even])\nsum2 = np.sum(a[num_i_odd])\n\nprint(sum1-sum2)"]
{"inputs": ["2\n3 1\n", "3\n2 7 4\n", "4\n20 18 2 18\n"], "outputs": ["2\n", "5\n", "18\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
25,278
a2d76404678593f2c5baabf6b4d18987
UNKNOWN
Takahashi participated in a contest on AtCoder. The contest had N problems. Takahashi made M submissions during the contest. The i-th submission was made for the p_i-th problem and received the verdict S_i (AC or WA). The number of Takahashi's correct answers is the number of problems on which he received an AC once or more. The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem. Find the numbers of Takahashi's correct answers and penalties. -----Constraints----- - N, M, and p_i are integers. - 1 \leq N \leq 10^5 - 0 \leq M \leq 10^5 - 1 \leq p_i \leq N - S_i is AC or WA. -----Input----- Input is given from Standard Input in the following format: N M p_1 S_1 : p_M S_M -----Output----- Print the number of Takahashi's correct answers and the number of Takahashi's penalties. -----Sample Input----- 2 5 1 WA 1 AC 2 WA 2 AC 2 WA -----Sample Output----- 2 2 In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem. In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem. Thus, he has two correct answers and two penalties.
["N, M = [int(n) for n in input().split()]\n\nsubmit = []\nAC = [0] * N\nWA = [0] * N\n\nfor i in range(M):\n p, s = [n for n in input().split()]\n p = int(p)\n\n if AC[p-1] == 1:\n continue\n\n if s == 'AC':\n AC[p-1] = 1\n \n elif s == 'WA':\n WA[p-1] += 1\n\npen = [x*y for x, y in zip(AC, WA)]\n\nprint(sum(AC), sum(pen))", "N, M = map(int, input().split(' '))\nac_set = set()\nwa_cnt_list = [0] * N\nac_cnt, wa_cnt = 0, 0\nfor i in range(M):\n num, res = input().split(' ')\n num = int(num) - 1\n if num not in ac_set:\n if res == 'AC':\n ac_cnt += 1\n wa_cnt += wa_cnt_list[num]\n ac_set.add(num)\n else:\n wa_cnt_list[num] += 1\nprint(ac_cnt, wa_cnt)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 8 16:23:28 2020\n\n@author: liang\n\"\"\"\n\nN, M = map(int, input().split())\nAC_list = [0]*N\nWA_list = [0]*N\n\nfor i in range(M):\n p, j = input().split()\n p = int(p)\n if j == 'AC':\n AC_list[p-1] += 1\n else:\n if AC_list[p-1] == 0:\n WA_list[p-1] += 1\n\nAC = 0\nWA = 0\nfor i in range(N):\n if AC_list[i] >= 1:\n AC += 1\n WA += WA_list[i]\n \nprint(AC, WA)", "N, M = map(int, input().split(' '))\nac_set = set()\nwa_cnt_ls = [0] * N\nwa_cnt = 0\nfor i in range(M):\n p, s = input().split(' ')\n idx = int(p) - 1\n if not idx in ac_set:\n if s == 'AC':\n wa_cnt += wa_cnt_ls[idx]\n ac_set.add(idx)\n else:\n wa_cnt_ls[idx] += 1\nprint(len(ac_set), wa_cnt)", "import sys\ndef readint():\n return int(sys.stdin.readline())\n\ndef readints():\n return tuple(map(int,sys.stdin.readline().split()))\n\ndef readintslist(n):\n return [tuple(map(int,sys.stdin.readline().split())) for _ in range(n)]\n\ndef main():\n n,m = readints()\n frag = [False]*(n+1)\n penalties = [0]*(n+1)\n for _ in range(m):\n p,s = input().split()\n p = int(p)\n if frag[p]:\n continue\n if s==\"AC\":\n frag[p] = True\n else:\n penalties[p] += 1\n print(sum(frag),sum([penalties[i] for i in range(n+1) if frag[i]]))\ndef __starting_point():\n main()\n__starting_point()", "n, m = map(int,input().split())\nac = set()\nw, x = 0, [0 for i in range(n)]\nfor i in range(m):\n p, s = input().split()\n l = int(p) -1\n if not l in ac:\n if s == \"AC\":\n ac.add(l)\n w += x[l]\n else:\n x[l] += 1\nprint(len(ac),w)", "n, m = map(int, input().split())\nanswers = []\nfor _ in range(m):\n num,res = input().split()\n num = int(num)\n answers.append([num, res])\n\nAC_cnt = 0\nWA_cnt = 0\n\nAC_problems = [0]*n\nWA_problems = [0]*n\nfor answer in answers:\n if answer[1] == 'WA' and AC_problems[answer[0]-1] != 1:\n WA_problems[answer[0]-1] += 1\n else:\n if AC_problems[answer[0]-1] == 0:\n AC_problems[answer[0]-1] += 1\n else:\n continue\nfor i in range(len(AC_problems)):\n AC_cnt += AC_problems[i]\n if AC_problems[i] == 1:\n WA_cnt += WA_problems[i]\n\nprint(AC_cnt, WA_cnt)", "n, m = list(map(int,input().split()))\np = [input().split() for _ in range(m)]\nac = [0] * n\nwa = [0] * n\nfor i in p:\n if i[1] == \"AC\" and ac[int(i[0])-1] == 0:\n ac[int(i[0])-1] = 1\n elif i[1] == \"WA\" and ac[int(i[0])-1] == 0:\n wa[int(i[0])-1] += 1\nwasum = 0\nfor i in range(n):\n if ac[i] == 1:\n wasum += wa[i]\nprint(f\"{sum(ac)} {wasum}\")\n", "n, m= map(int, input().split())\nps = [list(map(str,input().split())) for _ in range(m)]\n\nstr_l = [\"WA\"]*n\nint_l = [0]*n\nnum = 0\nac = 0\n\nfor pp, s in ps:\n p = int(pp)-1\n if s == \"AC\":\n str_l[p] = \"AC\"\n else:\n if str_l[p] != \"AC\":\n int_l[p] += 1\n\nfor i in range(n):\n if str_l[i] == \"AC\":\n num += int_l[i]\n ac += 1\n\nprint(ac,num)", "N, M = map(int, input().split())\np_S = [input().split() for _ in range(M)]\n\n# N, M=O(10^5)\u306a\u306e\u3067\u3001O(N+M)\u3067\u89e3\u304f\uff01\nAC = [False]*N\nWA = [0]*N\n \n# i\u756a\u76ee\u306e\u63d0\u51fa\u306b\u304a\u3044\u3066\u3001\n# (1) \u307e\u3060'AC'\u3055\u308c\u3066\u304a\u3089\u305a\u3001\u63d0\u51fa\u304cWA\u3060\u3063\u305f\u5834\u5408\uff1aWA += 1\n# (2) \u307e\u3060'AC'\u3055\u308c\u3066\u304a\u3089\u305a\u3001\u63d0\u51fa\u304cAC\u3060\u3063\u305f\u5834\u5408\uff1aAC += 1 \n# (3) \u3059\u3067\u306b'AC'\u3055\u308c\u3066\u3044\u308b\u5834\u5408\uff1a\u4f55\u3082\u3057\u306a\u3044\nfor i in range(M): \n num = int(p_S[i][0])-1\n if AC[num] == 0 and p_S[i][1] == 'WA': WA[num] += 1\n elif AC[num] == 0 and p_S[i][1] == 'AC': AC[num] = True\n else: continue\n\n# 'AC'\u3092\u51fa\u3057\u305f\u5404\u554f\u984c\u306b\u304a\u3044\u3066\u3001\u521d\u3081\u3066'AC'\u3092\u51fa\u3059\u307e\u3067\u306b\u51fa\u3057\u305f'WA'\u306e\u6570\u306e\u548c\u3092\u6c42\u3081\u308b\ns = 0\nfor i in range(N):\n if AC[i]:\n s += WA[i]\n \nprint(sum(AC), s)", "N,M = map(int,input().split())\nP = []\nS = []\nAC = [0]*(N+1)\nWA = [0]*(N+1)\nac = 0\nwa = 0\nfor i in range(M):\n p,s = input().split()\n P.append(int(p))\n S.append(s)\nfor i in range(M):\n if(S[i] == \"WA\" and AC[P[i]] == 0):\n WA[P[i]] += 1\n if(S[i] == \"AC\"):\n AC[P[i]] += 1\nfor i in range(1,N+1):\n if(AC[i] >= 1):\n ac += 1\n wa += WA[i]\nprint(ac,wa)", "N,M = map(int,input().split())\n\n#AC,WA\nP = [0]*N\nPenalty = 0\nAccepted = 0\n\nfor i in range(M) :\n p,S = input().split()\n p = int(p)\n \n if S == \"AC\" and P[p-1] != -1:\n Penalty += P[p-1]\n Accepted += 1\n P[p-1] = -1\n elif S == \"WA\" and P[p-1] != -1:\n P[p-1] += 1\n\nprint(Accepted,Penalty)", "n, m = list(map(int, input().split()))\nac = 0\nwa = 0\ncur_n = 0\ncur_wa = 0\ncur_ac = False\npset = []\nfor i in range(m):\n p, s = input().split()\n pset.append((int(p), s))\npset.sort(key= lambda x:x[0])\n\nfor j in range(m):\n if cur_n != pset[j][0]:\n cur_n = pset[j][0]\n cur_ac = False\n cur_wa = 0\n if cur_ac == False:\n if pset[j][1] == 'AC':\n ac += 1\n wa += cur_wa\n cur_ac = True\n else:\n cur_wa += 1\n\nprint(f'{ac} {wa}')\n", "n,m = map(int, input().split())\nl = [[] for _ in range(n)]\nac,wa = (0,0)\nfor i in range(m):\n p,s = input().split()\n p = int(p)\n if s == \"AC\":\n if s not in l[p-1]:\n l[p-1].append(s)\n ac += 1\n wa += l[p-1].count(\"WA\")\n else:\n l[p-1].append(s)\nprint(ac,wa)", "N,M = map(int, input().split())\nans = [0]*N\nac = 0\np = 0\n\nfor m in range(M):\n a,b = map(str, input().split())\n a = int(a) - 1\n\n if ans[a] != -1 and b == 'WA':\n ans[a] += 1\n if ans[a] != -1 and b == 'AC':\n ac += 1\n p += ans[a]\n ans[a] = -1\n\nprint(ac,p)", "N, M = map(int, input().split())\nac = set()\npena = 0\nwalen = [0]*N\n\nfor i in range(M):\n p, S = map(str, input().split())\n p = int(p) - 1\n if p in ac:\n continue\n elif S == 'AC':\n ac.add(p)\n pena += walen[p]\n else:\n walen[p] += 1\n\nprint(len(ac), pena)", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\nimport numpy as np\n\ndef main():\n n,m = map(int,input().split())\n wa_answers=np.zeros(n+1,dtype=int)\n ac_flag=np.zeros(n+1,dtype=int)\n\n for i in range(m):\n no,result=input().split()\n no=int(no)\n if result==\"AC\" and ac_flag[no]==0:\n ac_flag[no]=1\n if result==\"WA\" and ac_flag[no]==0:\n wa_answers[no]+=1\n print(sum(ac_flag),sum(ac_flag*wa_answers))\ndef __starting_point():\n main()\n__starting_point()", "n, m = map(int, input().split())\nps = [list(input().split()) for _ in range(m)]\nans = [0]*n\nwa = [0]*n\nac = [0]*n\nfor i in range(m):\n p, s = int(ps[i][0]), ps[i][1]\n if ac[p-1] == 0:\n if s == 'WA':\n wa[p-1] += 1\n else:\n ans[p-1] = wa[p-1]\n ac[p-1] += 1\nprint(sum(ac), sum(ans))", "from collections import defaultdict\ndef main():\n n, m = map(int, input().split(\" \"))\n d = defaultdict(lambda:\"\")\n dp = defaultdict(lambda:0)\n cnt_p=0\n cnt_ca=0\n for i in range(m):\n p,s = input().split(\" \")\n if d[p] == \"\":\n if s == \"AC\":\n d[p] = 1\n cnt_ca += 1\n cnt_p += dp[p]\n else:\n dp[p] += 1\n print(f\"{cnt_ca} {cnt_p}\")\n\n\ndef __starting_point():\n main()\n__starting_point()", "N, M = map(int, input().split())\nAC = [0]*(N+1)\nWA = [0]*(N+1)\n\nfor i in range (0, M):\n A, B = map(str, input().split())\n A = int(A)\n if B == 'WA':\n if AC[A] == 0:\n WA[A]+=1\n else:\n if AC[A] == 0:\n AC[A] = 1\n\nWronganswer = 0\nfor i in range (0, N+1):\n Wronganswer+=(AC[i]*WA[i])\nprint(sum(AC), Wronganswer)", "import numpy as np\nn,m=map(int,input().split())\na=np.array([list(input().split()) for i in range(m)])\nb=[0]*(n+1)\ne=[0]*(n+1)\nc=0\nd=0\nfor i in a:\n if b[int(i[0])]==0:\n if i[1]==\"AC\":\n c+=1\n b[int(i[0])]=1\n d+=e[int(i[0])]\n else:\n e[int(i[0])]+=1\nprint(c,d)", "n, m = map(int, input().split())\nps = [list(input().split()) for _ in range(m)]\n\nc = [0] * n\nfor p, s in ps:\n if s == 'AC':\n c[int(p)-1] = 1\nd = [0] * n\nwa = 0\nac = 0\nfor p, s in ps:\n if d[int(p)-1] == 0:\n if s == 'WA':\n if c[int(p)-1] == 1:\n wa += 1\n else:\n ac += 1\n d[int(p)-1] = 1\nprint(ac, wa)", "n, m = map(int, input().split())\np = []\ns = []\nfor i in range(m):\n p_i, s_i = input().split()\n p.append(int(p_i))\n s.append(s_i)\n\ncorrect = [0]*n\npenalty = [0]*n\n\nfor i in range(m):\n no = p[i]\n if correct[no-1] == 1:\n continue\n elif s[i] == 'WA':\n penalty[no-1] += 1\n elif s[i] == 'AC':\n correct[no-1] = 1\n\npen = 0\nfor i in range(n):\n if correct[i] == 1:\n pen += penalty[i]\nprint(sum(correct), pen)", "n,m=map(int,input().split())\nl1 = [0]*n\nl2 = [0]*n\nfor i in range(m):\n p,s=map(str,input().split())\n p= int(p)\n if s == 'AC':\n l2[p-1] +=1\n else:\n if l2[p-1] == 0:\n l1[p-1] +=1\ncntac = 0\ncntwa = 0\nfor i in range(n):\n if l2[i] != 0:\n cntac +=1\n cntwa += l1[i]\n\n \n \nprint(cntac,cntwa)", "n,m = map(int,input().split())\np,s =[],[]\nfor _ in range(m):\n p_ ,s_ = input().split()\n p.append(int(p_))\n s.append(s_)\n\nAC = [0]*n\nWA = [0]*n\n\nfor i in range(m):\n if s[i]==\"WA\" and AC[p[i]-1]==0:\n WA[p[i]-1] += 1\n elif s[i]==\"AC\" and AC[p[i]-1]==0:\n AC[p[i]-1] += 1\n \nfor i in range(m):\n if AC[p[i]-1]==0:\n WA[p[i]-1]=0\nprint(sum(AC),sum(WA))", "n, m = map(int, input().split())\nd = [0] * (n+1)\nac = 0\nwa = 0\nfor i in range(m):\n p, s = input().split()\n p = int(p)\n if d[p] == -1:\n continue\n elif s == \"AC\":\n ac += 1\n wa += d[p] \n d[p] = -1\n else:\n d[p] += 1\nprint(ac, wa)", "n, m = map(int, input().split())\nq = [0 for i in range(n)]\na = [False for i in range(n)]\nans1 = 0\nans2 = 0\nfor i in range (m):\n p, S = input().split()\n p = int(p) - 1\n if S == 'AC':\n a[p] = True\n else:\n if a[p] == False:\n q[p] += 1\nfor i in range(n):\n if a[i] == True:\n ans1 += 1\n ans2 += q[i]\nprint(ans1, ans2)", "N, M = map(int, input().split())\npS = [list(input().split()) for _ in range(M)]\n\nb = 0\nlst = [0 for _ in range(N)]\nfor p, S in pS:\n p = int(p)\n if S == \"WA\" and lst[p-1] <= 0:\n lst[p-1] -= 1\n if S == \"AC\" and lst[p-1] <= 0:\n b += - lst[p-1]\n lst[p-1] = 1\n\nprint(lst.count(1), b)", "N, M = map(int, input().split(' '))\nac_set = set()\nwa_cnt, wa_cnt_ls = 0, [ 0 for i in range(N) ]\nfor i in range(M):\n p, s = input().split(' ')\n idx = int(p) - 1\n if not idx in ac_set:\n if s == 'AC':\n ac_set.add(idx)\n wa_cnt += wa_cnt_ls[idx]\n else:\n wa_cnt_ls[idx] += 1\nprint(len(ac_set), wa_cnt)", "N, M = map(int, input().split())\nAC = [0] * N\nWA1 = [0] * N\nWA2 = [0] * N\nfor i in range(M):\n p, s = input().split()\n if s == 'AC':\n if AC[int(p) - 1] == 0:\n AC[int(p) - 1] = 1\n WA2[int(p) - 1] = WA1[int(p) - 1]\n elif AC[int(p) - 1] == 0:\n WA1[int(p) - 1] += 1\nprint(str(AC.count(1))+' '+ str(sum(WA2)))", "N, M = map(int, input().split(' '))\nac_set = set()\nwa_cnt_list = [0] * N\nac_cnt, wa_cnt = 0, 0\nfor i in range(M):\n num, res = input().split(' ')\n num = int(num) - 1\n if num not in ac_set:\n if res == 'AC':\n ac_cnt += 1\n wa_cnt += wa_cnt_list[num]\n ac_set.add(num)\n else:\n wa_cnt_list[num] += 1\nprint(ac_cnt, wa_cnt)", "n,m = map(int,input().split())\np = []\ns = []\nfor i in range(m):\n P,S = input().split()\n p.append(int(P))\n s.append(S)\nquestion = [0] * n #\u305d\u308c\u305e\u308c\u306e\u554f\u984c\u306eWA\u306e\u6570\nac = 0\nwa = 0\nfor i in range(m):\n if question[p[i] - 1] != -1:\n if s[i] == \"AC\":\n ac += 1\n wa += question[p[i] - 1]\n question[p[i] - 1] = -1\n else:\n question[p[i] - 1] += 1\nprint(str(ac) + \" \" + str(wa))", "N,M = map(int,input().split())\nP_S = [input().split() for _ in range(M)]\nwa_cnt = [0] * N\nac = 0\nwa = 0\nfor p,s in P_S:\n index = int(p)-1\n # AC\u306e\u5834\u5408\n if s == \"AC\":\n # \u521d\u3081\u3066\u3067\u306f\u306a\u3044\u5834\u5408\n if wa_cnt[index] != -1:\n wa += wa_cnt[index]\n wa_cnt[index] = -1\n ac += 1\n else:\n if wa_cnt[index] != -1:\n wa_cnt[index] += 1\n\nprint(ac,wa)", "n,m=map(int,input().split())\na=[input().split()for _ in range(m)]\nc=[0]*n\nw=[0]*n\nfor i in range(m):\n if c[int(a[i][0])-1]==0:\n if a[i][1]==\"AC\":\n c[int(a[i][0])-1]+=1\n else:\n w[int(a[i][0])-1]+=1\n else:\n pass\nfor i in range(n):\n if c[i]==0:\n w[i]=0\n else:\n pass\nprint(sum(c),sum(w))", "n, m = list(map(int, input().split()))\nanswer = 0\npenalty = 0\nans = [0] * n\npen = [0] * n\n\nfor x in range(m):\n p, s = input().split()\n pi = int(p) - 1\n if ans[pi] == 1:\n continue\n\n if s == 'AC':\n answer += 1\n ans[pi] = 1\n penalty += pen[pi]\n elif s == 'WA':\n pen[pi] += 1\n\nprint(f'{answer} {penalty}')\n\n", "n,m = map(int,input().split())\np,s = [],[]\nfor _ in range(m):\n a,b = map(str,input().split())\n p.append(a)\n s.append(b)\np = list(map(int,p))\nchecker = [0] * n\npenalty = [0] * n\nans = 0\nfor i,j in enumerate(s):\n if j == \"AC\" and checker[p[i]-1] == 0:\n checker[p[i]-1] = 1\n elif j == \"WA\" and checker[p[i]-1] == 0:\n penalty[p[i]-1] += 1\nfor k,l in enumerate(checker):\n if l:\n ans += penalty[k]\nprint(sum(checker),ans)", "N,M=map(int,input().split())\nWA=[0]*N\nAC=[0]*N\nfor i in range(M):\n p,S=map(str,input().split())\n if S=='WA' and AC[int(p)-1]!=1:\n WA[int(p)-1]+=1\n elif S=='AC':\n AC[int(p)-1]=1\n\nQ=0\nfor i in range(N):\n if AC[i]>0:\n Q+=WA[i]\nprint(sum(AC),Q)", "N,M = map(int,input().split())\nnum_AC,num_WA = 0,0\nres = [list(input().split()) for i in range(M)]\ncheck = ['v']*N\nWA_check = [0]*N\nfor i,j in res:\n i = int(i)\n if check[i-1] == 'v':\n if j == 'WA':\n WA_check[i-1] += 1\n if j == 'AC':\n num_AC += 1\n num_WA += WA_check[i-1]\n check[i-1] = '.'\nprint(num_AC,num_WA)", "N,M = map(int, input().split())\nd = {'AC':0,'WA':0,}\nb = 0\nfor i in range(N + 1):\n d[i] = 0\nfor j in range(M):\n p,s = input().split()\n p = int(p)\n if s == 'AC':\n if d[p] != -1:\n b = d[p]\n d[p] = -1\n d['AC'] += 1\n d['WA'] += b\n b = 0 \n if s == 'WA':\n if d[p] != -1:\n d[p] += 1\nprint(d['AC'],end = ' ')\nprint(d['WA'])\n \n\n", "N, M = map(int, input().split())\ncount1 = 0\ncount2 = 0\nlis = [0] * N\nlis2 = [0] * N\nfor i in range(M):\n p, S = input().split()\n p = int(p)\n if lis[p-1] == 0 and S == \"WA\":\n lis2[p-1] += 1\n elif lis[p-1] == 0 and S == \"AC\":\n count1 += 1\n lis[p-1] = 1\n elif lis[p-1] == 1 and S == \"WA\":\n continue\n elif lis[p-1] == 1 and S == \"AC\":\n continue\nfor i in range(N):\n if lis[i] == 0:\n lis2[i] = 0\ncount2 = sum(lis2)\nprint(str(count1) + \" \" + str(count2))", "N,M=map(int,input().split())\npenalty=[0]*N\nresult=[\"WA\"]*N\n\nfor i in range(M):\n P,S=input().split()\n if S==\"AC\":\n result[int(P)-1]=\"AC\"\n elif S==\"WA\" and result[int(P)-1]==\"WA\":\n penalty[int(P)-1]+=1\n else:\n continue\n\nfor j in range(N):\n if result[j]==\"WA\":\n penalty[j]=0\n\nprint(result.count(\"AC\"),sum(penalty))", "n, m = map(int, input().split())\np_s = [ list(map(str, input().split())) for _ in range(m) ]\nac = [False] * n\nwa = [0] * n\nfor p, s in p_s:\n if ac[int(p)-1] is False:\n if s == 'AC':\n ac[int(p)-1] = True\n else:\n wa[int(p)-1] += 1\nprint(sum([1 for i in ac if i == True ]), sum([i for i,j in zip(wa,ac) if j == True ]))", "import numpy as np\nN,M=map(int,input().split())\nflag=[False]*(N+1)\nac=0\nwa=[0]*(N+1)\nfor _ in range(M):\n p,s=input().split()\n p=int(p)\n if flag[p]==False:\n if s=='AC':\n flag[p]=True\n else:\n wa[p]+=1\nprint(sum(np.array(flag)),sum(np.array(wa)*np.array(flag)))", "n, m = map(int, input().split())\n\nlst = [ [i for i in input().split() ] for j in range(m) ]\n\nac = {}\nwa = {}\nvisited = []\nfor d in lst:\n if d[0] in ac.keys():\n continue\n if d[1] == \"AC\":\n if d[0] not in ac.keys():\n ac[d[0]] = 1\n else:\n if d[0] in wa.keys():\n wa[d[0]] += 1\n else:\n wa[d[0]] = 1\n\nac_count = 0\nwa_count = 0\n\nfor d in ac.keys():\n ac_count += 1\n if d in wa.keys():\n wa_count += int(wa[d])\nprint(ac_count,wa_count)", "N, M = map(int, input().split(' '))\nac_set = set()\nwa_cnt_ls, wa_cnt = [0] * N, 0\n\nfor i in range(M):\n p, s = input().split(' ')\n idx = int(p) - 1\n if not idx in ac_set:\n if s == 'AC':\n ac_set.add(idx)\n wa_cnt += wa_cnt_ls[idx]\n else:\n wa_cnt_ls[idx] += 1\nprint(len(ac_set), wa_cnt)", "N, M = map(int, input().split())\nA = [0]*(N+1)\nW = A.copy()\nfor _ in range(M):\n P, S = input().split()\n p = int(P)\n if S == \"AC\":\n A[p] = 1\n elif A[p] == 0:\n W[p] += 1\n\nprint(sum(A), sum(a*w for a, w in zip(A, W)))", "from collections import defaultdict as dc\nn, m = [int(i) for i in input().split()]\ncq_dic = {}\nwa_dic = dc(int)\nfor _ in range(m):\n p, w = input().split()\n if w == 'AC':\n cq_dic[p] = 1\n elif (not p in cq_dic) and w == 'WA':\n wa_dic[p] += 1\nans = sum([wa_dic[k] for k in cq_dic])\nprint(len(cq_dic), ans)", "n,m = map(int,input().split())\nAC = [0]*n\nWA = [0]*n\nans = 0\nfor i in range(m):\n p,s = input().split()\n p = int(p)-1\n if s == \"AC\" and AC[p] == 0:\n AC[p] = 1\n ans += WA[p]\n WA[p] += 1\nprint(sum(AC),ans)", "N, M = map(int, input().split(' '))\nac_set = set()\nwa_cnt_ls, wa_cnt = [ 0 for i in range(N) ], 0\nfor i in range(M):\n p, s = input().split(' ')\n idx = int(p) - 1\n if not idx in ac_set:\n if s == 'AC':\n ac_set.add(idx)\n wa_cnt += wa_cnt_ls[idx]\n else:\n wa_cnt_ls[idx] += 1\nprint(len(ac_set), wa_cnt)", "N, M = map(int, input().split(' '))\nac_set = set()\nwa_cnt, wa_cnt_ls = 0, [0] * N\nfor i in range(M):\n p, s = input().split(' ')\n idx = int(p) - 1\n if not idx in ac_set:\n if s == 'AC':\n ac_set.add(idx)\n wa_cnt += wa_cnt_ls[idx]\n else:\n wa_cnt_ls[idx] += 1\nprint(len(ac_set), wa_cnt)", "N,M=map(int,input().split())\nx=[0]*N\ny=[0]*N\nP=[]\ns=[]\n\nfor i in range(M):\n p,S=map(str,input().split())\n P.append(int(p))\n s.append(S)\nfor j in range(M-1,-1,-1):\n if s[j]=='AC':\n if x[P[j]-1]==0:\n x[P[j]-1]=1\n else:\n y[P[j]-1]=0\n elif s[j]=='WA':\n if x[P[j]-1]==1:\n y[P[j]-1]+=1\nprint(x.count(1),sum(y))", "n,m = map(int,input().split())\nl = [0]*n\nwcount = 0\nacount = 0\nfor i in range(m):\n A,B = input().split()\n a = int(A)\n b = str(B)\n if l[a-1] != -1 and b ==\"WA\":\n l[a-1] += 1\n elif l[a-1] != -1 and b ==\"AC\":\n acount += 1\n wcount += l[a-1]\n l[a-1] = -1\nprint(acount,wcount)", "N, M = map(int, input().split(' '))\nac_set = set()\nwa_cnt_ls, wa_cnt = [0] * N, 0\nfor i in range(M):\n p, s = input().split(' ')\n idx = int(p) - 1\n if not idx in ac_set:\n if s == 'AC':\n wa_cnt += wa_cnt_ls[idx]\n ac_set.add(idx)\n else:\n wa_cnt_ls[idx] += 1\nprint(len(ac_set), wa_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 AC = defaultdict(int)\n WA = defaultdict(int)\n N, M = MI()\n wa = 0\n for i in range(M):\n p, S = input().split()\n\n if AC[p] == 0:\n if S == \"WA\":\n WA[p] +=1\n else:\n AC[p] = 1\n wa += WA[p]\n\n ac = sum(AC.values())\n print(ac, wa)\n \ndef __starting_point():\n main()\n__starting_point()", "def resolve():\n n,m = map(int,input().split())\n ac_list = [0]*n\n wa_count = [0]*n\n ac = 0\n wa = 0\n for _ in range(m):\n p,s = input().split()\n if s == 'WA' and (ac_list[int(p)-1]==0):\n wa_count[int(p)-1] += 1\n elif s == 'AC' and (ac_list[int(p)-1]==0):\n ac += 1\n ac_list[int(p)-1] = 1\n for (i,j) in zip(wa_count,ac_list):\n if j: wa+=i\n print(f'{ac} {wa}')\nresolve()", "from collections import defaultdict\nN, M = map(int, input().split())\nwa = defaultdict(int)\nac = {}\nfor i in range(M):\n p, S = input().split()\n if S == 'AC': \n ac[p] = True\n else:\n if p not in ac:\n wa[p] += 1\nprint(len(ac), sum([wa[x] for x in ac.keys()]))", "n, m = map(int, input().split())\na = [input().split() for i in range(m)]\nwa =[0]*n #AC\u307e\u3067\u306eWA\u6570\nac = [0]*n\n\nfor i in range(m):\n if a[i][1] == 'AC':\n ac[int(a[i][0])-1] = 1\n else:\n if ac[int(a[i][0])-1]==0:\n wa[int(a[i][0])-1] +=1\ncnt1, cnt2= 0,0\nfor i in range(n):\n if ac[i] ==1:\n cnt1 += ac[i]\n cnt2 += wa[i]\n \nprint(cnt1, cnt2)", "n,m=map(int,input().split())\nac_cnt = set()\nwa_cnt = 0\npenalty = [0]*n\nfor i in range(m):\n p,s = input().split()\n num = int(p) - 1\n if num not in ac_cnt:\n if s == \"AC\":\n ac_cnt.add(num)\n wa_cnt += penalty[num]\n else:\n penalty[num] += 1\nprint(len(set(ac_cnt)),wa_cnt)", "n,m = map(int, input().split())\nres = [0 for i in range(n)]\nP = [0 for i in range(n)]\nans = 0\np = 0\n \nfor i in range(m) :\n pi, si = input().split()\n pi = int(pi) - 1\n if(res[pi]) :\n continue\n if(si == \"AC\") :\n res[pi] = 1\n ans += 1\n p += P[pi]\n else :\n P[pi] += 1\nprint(ans, p)", "N,M = map(int, input().split())\n\nAC = [0] * N\nWA = [0] * N\n\nfor _ in range(M):\n p,S = input().split()\n p = int(p) - 1\n if AC[p] == 1:\n continue\n else:\n if S == 'AC':\n AC[p] = 1\n else:\n WA[p] += 1\n\nPen = [x*y for (x, y) in zip(AC, WA)]\n\nprint(sum(AC), sum(Pen))", "n, m = map(int, input().split())\nP = [0]*n\nAC = 0\nWA = 0\nfor i in range(m):\n p, S = input().split()\n p = int(p)\n if S == \"AC\" and P[p-1] != -1:\n WA += P[p-1]\n AC += 1\n P[p-1] = -1\n elif S == \"WA\" and P[p-1] != -1:\n P[p-1] += 1\nprint(AC, WA)", "N,M = map(int,input().split())\n \n#AC,WA\nP = [0]*N\nPenalty = 0\nAccepted = 0\n \nfor i in range(M) :\n p,S = input().split()\n p = int(p)\n \n if S == \"AC\" and P[p-1] != -1:\n Penalty += P[p-1]\n Accepted += 1\n P[p-1] = -1\n elif S == \"WA\" and P[p-1] != -1:\n P[p-1] += 1\n\nprint(Accepted,Penalty)", "N,M=map(int,input().split())\nS=[0]*(N)\nQ=[0]*(N)\nfor i in range(M):\n p,s=map(str,input().split())\n p=int(p)\n if s=='AC':\n S[p-1]=1\n elif s=='WA' and S[p-1] ==0:\n Q[p-1]+=1\n else:\n pass\nQ_com= [x * y for (x, y) in zip(S, Q)]\nprint (S.count(1),sum(Q_com))", "import numpy as np\n\nn,m = map(int,input().split())\n\nac = [0]*(n+1)\nwa = [0]*(n+1)\n\nfor _ in range(m):\n p,s = map(str,input().split())\n if s == \"AC\" and ac[int(p)] == 0:\n ac[int(p)] = 1\n if s == \"WA\" and ac[int(p)] == 0:\n wa[int(p)] += 1\nprint(sum(ac),sum(np.array(ac)*np.array(wa)))", "N,M=map(int,input().split())\nprob=[[0,0] for i in range(N)]\n\nfor i in range(M):\n p,S=input().split()\n x=int(p)-1\n if prob[x][0]==0 and S=='WA':\n prob[x][1]+=1\n elif prob[x][0]==0 and S=='AC':\n prob[x][0]=1\n\nACs,WAs=0,0\nfor i in range(N):\n if prob[i][0]==1:\n ACs+=1\n WAs+=prob[i][1]\n\nprint(ACs,' ',WAs)", "N, M = map(int, input().split())\nACs = [0] * (N+1)\nPs = [0] * (N+1)\nfor _ in range(M):\n p, s = input().split()\n p = int(p)\n if s == 'AC':\n ACs[p] = 1\n elif s == 'WA': # WA\n if ACs[p] == 0: \n Ps[p] += 1\n\nans1 = sum(ACs)\nans2 = 0\nfor i in range(1, N+1):\n if ACs[i] == 1:\n ans2 += Ps[i]\nprint(ans1, ans2)", "n,m = list(map(int, input().split()))\nwa = [0] * (n + 1)\nac = [0] * (n + 1)\nfor _ in range(m):\n p,s = input().split()\n p = int(p)\n if s == 'WA' and ac[p] == 0:\n wa[p] += 1\n elif s == 'AC':\n ac[p] = 1\n\nfor i,ok in enumerate(ac):\n if not ok:\n wa[i] = 0\n\nprint(('{} {}'.format(sum(ac), sum(wa))))\n", "\ndef i_input(): return int(input())\ndef i_map(): return map(int, input().split())\ndef i_list(): return list(map(int, input().split()))\ndef i_row(N): return [int(input()) for _ in range(N)]\ndef i_row_list(N): return [list(input().split()) for _ in range(N)]\n\nn,m=i_map()\nps=i_row_list(m)\nac=[0]*n\nwa=[0]*n\nfor p,s in ps:\n if s=='AC':\n ac[int(p)-1]=1\n if s=='WA':\n if ac[int(p)-1]==0:\n wa[int(p)-1]+=1\nfor i in range(n):\n if ac[i]==0:\n wa[i]=0\nprint(sum(ac),sum(wa))", "n, m = map(int, input().split())\nans = [0, 0]\nac = [0 for _ in range(n)]\nfor _ in range(m):\n p, s = input().split()\n p = int(p) - 1\n if ac[p] == -1:\n continue\n elif s == \"AC\":\n ans[0] += 1\n ans[1] += ac[p]\n ac[p] = -1\n else:\n ac[p] += 1\nprint(*ans)", "import numpy as np\nn,m=map(int,input().split())\na=np.array([list(input().split()) for i in range(m)])\nb=[0]*n\ne=[0]*n\nc=0\nd=0\nfor i in a:\n if b[int(i[0])-1]==0:\n if i[1]==\"AC\":\n c+=1\n b[int(i[0])-1]=1\n d+=e[int(i[0])-1]\n else:\n e[int(i[0])-1]+=1\nprint(c,d)", "N,M=map(int, input().split())\nACList=[0]*(N+1)\nansAC=0\nansP=0\nfor i in range(M):\n\tp,S=map(str, input().split())\n\tp=int(p)\n\tif S==\"AC\" and ACList[p]!=-1:\n\t\tansAC+=1\n\t\tansP+=ACList[p]\n\t\tACList[p]=-1\n\telif S==\"WA\" and ACList[p]!=-1:\n\t\tACList[p]+=1\n\telse:\n\t\tcontinue\n\nprint(ansAC,ansP)", "N, M = map(int, input().split(' '))\nac_set = set()\nwa_cnt, wa_cnt_ls = 0, [ 0 for i in range(N) ]\n\nfor i in range(M):\n p, s = input().split(' ')\n idx = int(p) - 1\n if not idx in ac_set:\n if s == 'AC':\n ac_set.add(idx)\n wa_cnt += wa_cnt_ls[idx]\n else:\n wa_cnt_ls[idx] += 1\nprint(len(ac_set), wa_cnt)", "n, m = map(int, input().split())\nanswer = 0\npenalty = 0\nans = [0] * n\npen = [0] * n\n \nfor x in range(m):\n p, s = input().split()\n pi = int(p) - 1\n if ans[pi] == 1:\n continue\n \n if s == 'AC':\n answer += 1\n ans[pi] = 1\n penalty += pen[pi]\n elif s == 'WA':\n pen[pi] += 1\n \nprint(f'{answer} {penalty}')"]
{"inputs": ["2 5\n1 WA\n1 AC\n2 WA\n2 AC\n2 WA\n", "100000 3\n7777 AC\n7777 AC\n7777 AC\n", "6 0\n"], "outputs": ["2 2\n", "1 0\n", "0 0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
29,222
1a51b5012feb2fcf8ea27a200ec82573
UNKNOWN
Fennec is fighting with N monsters. The health of the i-th monster is H_i. Fennec can do the following two actions: - Attack: Fennec chooses one monster. That monster's health will decrease by 1. - Special Move: Fennec chooses one monster. That monster's health will become 0. There is no way other than Attack and Special Move to decrease the monsters' health. Fennec wins when all the monsters' healths become 0 or below. Find the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning when she can use Special Move at most K times. -----Constraints----- - 1 \leq N \leq 2 \times 10^5 - 0 \leq K \leq 2 \times 10^5 - 1 \leq H_i \leq 10^9 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N K H_1 ... H_N -----Output----- Print the minimum number of times Fennec needs to do Attack (not counting Special Move) before winning. -----Sample Input----- 3 1 4 1 5 -----Sample Output----- 5 By using Special Move on the third monster, and doing Attack four times on the first monster and once on the second monster, Fennec can win with five Attacks.
["n, k = map(int, input().split())\nH = list(map(int, input().split()))\nH.sort(reverse=True)\nprint(sum(H[k:]))", "N, K = list(map(int, input().split()))\nH = list(map(int, input().split()))\nif len(H) <= K:\n print((0))\nelse:\n print((sum(sorted(H)[:len(H)-K])))\n", "n, k = map(int, input().split())\nh = [int(s) for s in input().split()]\n\nans = 0\nh.sort(reverse= True)\nif k >= n:\n ans = 0\nelse:\n ans = sum(h[k:n])\nprint(ans)", "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 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\nn, k=I()\nh = l()\nh.sort(reverse=True)\n\nprint(sum(h[k:]))", "n,k=list(map(int,input().split()))\nl=list(map(int,input().split()))\nl.sort(reverse=True)\nif k>=n:\n print((0))\nelse:\n for i in range(k):\n l[i]=0\n print((sum(l)))\n", "N, K=map(int, input().split())\nH=list(map(int, input().split()))\n\nH.sort(reverse=True)\n\nif K<=len(H):\n print(sum(H[K:len(H)+1]))\nelse:\n print(0)", "N, K = list(map(int, input().split()))\nH = list(map(int, input().split()))\n\na = 0\n\nif K > N:\n a = K - N\n\nfor _ in range(a):\n H.append(0)\n\nH.sort(reverse = True)\nsum = 0\n\nfor i in range(K):\n H[i] = 0\n \nfor i in range(N):\n sum += H[i]\n \nprint(sum)\n", "N,K=map(int,input().split())\nH=list(map(int,input().split()))\nH.sort(reverse=True)\nprint(sum(H[K:]))", "n, k = list(map(int, input().split()))\nh = list(map(int, input().split()))\n\n# \u30e2\u30f3\u30b9\u30bf\u30fc\u306e\u6570\u3088\u308a\u4f7f\u3048\u308b\u5fc5\u6bba\u6280\u306e\u6570\u304c\u591a\u3051\u308c\u3070\u304a\u308f\u308a\nif n <= k:\n print((0))\n return\n\nnum = 0\n# \u964d\u9806\u306b\u30bd\u30fc\u30c8\nh.sort(reverse=True)\n# \u5927\u304d\u3044\u6570\u9806\u306b\u5fc5\u6bba\u6280\u3092\u4f7f\u3046\n# \u6b8b\u3063\u305f\u3084\u3064\u3092\u6570\u3048\u308b\nfor i in h[k:]:\n num += i\n\nprint(num)\n", "N,K = list(map(int,input().split()))\nH = sorted(list(map(int,input().split())),reverse=True)[K:]\n\nprint((sum(H)))\n", "N, K = map(int, input().split(' '))\nH_ls = list(map(int, input().split(' ')))\nH_ls.sort(reverse=True)\nprint(sum(H_ls[K:]))", "health, attacks = map(int, input().split())\nnum_list = [num for num in map(int, input().split())]\nnum_list.sort(reverse=True)\n\nprint(sum(num_list[attacks:]))", "n, k = map(int, input().split())\n\nlst = [ int(i) for i in input().split() ]\nif len(lst) <= k:\n print(0)\n return\nlst = sorted(lst)\nfor i in range(k):\n lst.pop()\nprint(sum(lst))", "N,K=map(int,input().split())\nH=list(map(int,input().split()))\nH.sort()\nm=0\nif K<N:\n for i in range(N-K):\n m+=H[i]\nprint(m)", "n,k = map(int,input().split())\nh = list(map(int,input().split()))\nh.sort(reverse = True)\nprint(sum(h[k:]))", "N,K = map(int,input().split())\nH = sorted([int(i) for i in input().split()])\nans = 0\nfor i in range(N-K):\n ans += H[i]\nprint(ans)", "n,k=map(int,input().split())\nh = sorted(map(int,input().split()))\nprint(sum(h[:-k]) if k!=0 else sum(h))", "n,k =map(int,input().split())\na = sorted(list(map(int,input().split())))[::-1]\nprint(sum(a[k:]))", "N, K = list(map(int, input().split()))\nH = list(map(int, input().split()))\n\nH.sort(reverse=True)\nprint((sum(H[K:])))\n", "N, K = map(int, input().split(' '))\nH_ls = list(map(int, input().split(' ')))\nH_ls.sort(reverse=True)\nprint(sum(H_ls[K:]))", "num, deathblow = map(int, input().split())\nenemy_table = list(map(int, input().split()))\nlist.sort(enemy_table, reverse=True)\nsum = 0\nif num <= deathblow:\n print(0)\nelse:\n for i in range(deathblow):\n enemy_table[i] = 0\n for j in range(num):\n sum += enemy_table[j]\n print(sum)", "n, k = list(map(int, input().split()))\nh = list(map(int, input().split()))\nh.sort(reverse=True)\nh = h[k:]\nprint((sum(h)))\n", "N, K = map(int, input().split(' '))\nH_ls = list(map(int, input().split(' ')))\nH_ls.sort(reverse=True)\nprint(sum(H_ls[K:]))", "n, k = list(map(int, input().split()))\nenemy = list(map(int, input().split()))\nenemy = sorted(enemy, reverse=True)\nenemy = enemy[k:]\nprint(sum(enemy))", "n,k=map(int,input().split());print(sum(sorted(map(int,input().split()))[::-1][k:]))", "n, k = map(int, input().split())\nh = list(sorted(map(int, input().split())))\nx = 0\nif n > k:\n for i in range(n - k):\n x += h[i]\n\nprint(x)", "n,k = map(int,input().split())\nh = list(map(int,input().split()))\nans = 0\n\nif(n <= k):\n print(0)\nelse:\n h.sort()\n a = []\n a = h[:n-k]\n print(sum(a))", "N,K=map(int,input().split())\nH=sorted(map(int,input().split()))\nif K==0:\n print(sum(H))\nelif N<K:\n K=N\n del H[-K:]\n print(sum(H))\nelse:\n del H[-K:]\n print(sum(H))", "n,k = map(int,input().split())\n\nh = list(map(int,input().split()))\n\nh.sort(reverse = True)\n\nans = 0\nfor i in range(k,n):\n ans += h[i]\n\nprint(ans)", "N,K = map(int, input().split())\nH = list(map(int, input().split()))\nH.sort(reverse=True)\nans = 0\nfor i in range(K, N):\n ans += H[i]\nprint(ans)", "n,k=map(int,input().split())\nh=list(map(int,input().split()))\nh.sort()\nans=0\nfor i in range(n-k):\n ans+=h[i]\n\nprint(ans)", "N, K = map(int, input().split(' '))\nH_ls = list(map(int, input().split(' ')))\nH_ls.sort(reverse=True)\nprint(sum(H_ls[K:]))", "N,K = map(int,input().split())\nH = list(map(int,input().split()))\nH.sort(reverse=True)\nH = H[K:]\nprint(sum(H))", "n,k = map(int,input().split())\nh = list(map(int,input().split()))\nh.sort(reverse = True)\nif n < k:\n k = n\nans = 0\nfor i in range(k):\n h[i] = 0\nfor i in range(n):\n ans += h[i]\nprint(ans)", "n,k = list(map(int,input().split()))\nenemy = list(map(int,input().split()))\n\nenemy.sort(reverse=True)\n\nif k >= n :\n print((0))\n\nelse:\n \n\n for x in range(k):\n enemy[x] = 0\n \n print((sum(enemy)))\n", "def main():\n\tn, k = list(map(int, input().split()))\n\th = [int(v) for v in input().split()]\n\tif k >= len(h):\n\t\treturn 0\n\tmonsters = sorted(h)\n\tmonsters.reverse()\n\treturn sum(monsters[k:])\n\ndef __starting_point():\n print((main()))\n\n__starting_point()", "a,b=map(int,input().split())\nn = list(map(int,input().split()))\nm = sorted(n)[::-1]\nif a <= b:\n print(\"0\")\nelse:\n print(sum(m[b::]))", "N, K = list(map(int, input().split()))\nhp_list = list(map(int, input().split()))\n\nif N <= K:\n print(0)\nelse:\n hp_list.sort()\n del hp_list[N - K:N]\n print(sum(hp_list))", "n, k = map(int,input().split())\nh = list(map(int,input().split()))\nh.sort()\nif n <= k:\n print(\"0\")\nelse:\n if k == 0:\n ans = sum(h)\n else:\n x = n - k\n ans = sum(h[:x])\n\n print(ans)", "N, K = map(int, input().split())\nH = list(map(int, input().split()))\nH.sort(reverse=True)\nprint(max(0, sum(H[K:])))", "\ndef main():\n n, k = map(int, input().split(\" \"))\n h = list(map(int, input().split(\" \")))\n h.sort(reverse = True)\n print(sum(h[k:]))\n \n\ndef __starting_point():\n main()\n__starting_point()", "n,k = map(int,input().split())\nh = list(map(int,input().split()))\nh.sort(reverse=True)\nans = 0\nfor i in range(k,n):\n ans += h[i]\nprint(ans)", "import sys\nimport heapq\n\nn, k = list(map(int, input().split()))\nh = []\nheapq.heapify(h)\nfor x in map(int, input().split()):\n heapq.heappush(h, x)\n\nif n <= k:\n print((0))\n return\n\nans = 0\nfor x in range(n - k):\n ans += heapq.heappop(h)\n\nprint(ans)\n", "H, K = [int(n) for n in input().split()]\nH = [int(n) for n in input().split()]\n\nprint(sum(sorted(H, reverse=True)[K:]))", "n, k = map(int, input().split())\nh = list(map(int,input().split()))\nans = 0\n\nh = sorted(h,reverse=True)\n\nfor i in range(k,n):\n ans += h[i]\n\nprint(ans)", "N, K = map(int, input().split(' '))\nH_ls = list(map(int, input().split(' ')))\nH_ls.sort(reverse=True)\nprint(sum(H_ls[K:]))", "n, k = map(int, input().split())\nh = sorted(list(map(int, input().split())), reverse=True)\n\nprint(sum(h[k:]))", "import sys\nn,k=list(map(int,input().split()))\nh=list(map(int,input().split()))\n\nlist.sort(h,reverse=True)\n\nif k>=n:\n print('0')\n return\n\nc=0\nfor i in range(k,n):\n c+=h[i]\n\nprint(c)\n", "# C - Fennec vs Monster\n\nn,k = list(map(int,input().split()))\nh = list(map(int,input().split()))\nh.sort(reverse=True)\nif k >= n:\n k = n\nh2 = h[k:]\n\nprint((sum(h2)))\n", "n, k = map(int, input().split())\nh = sorted(list(map(int, input().split())), reverse=True)\n\nprint(sum(h[k:]))", "[N, K] = [int(i) for i in input().split()]\nH = [int(i) for i in input().split()]\n\nif N <= K:\n print(0)\nelse:\n h = list(sorted(H))\n t = sum(h[0:N-K])\n print(t)", "n,k = map(int,input().split())\nh = sorted(list(map(int,input().split())),reverse=True)\nprint(sum(h[k:]))", "#!/usr/bin/env python3\nimport sys\nfrom itertools import chain\n\n\ndef solve(N: int, K: int, H: \"List[int]\"):\n H = sorted(H, reverse=True)\n return sum(H[K:])\n\n\ndef main():\n tokens = chain(*(line.split() for line in sys.stdin))\n N = int(next(tokens)) # type: int\n K = int(next(tokens)) # type: int\n H = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n answer = solve(N, K, H)\n print(answer)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N,K=list(map(int, input().split()))\nH=sorted(list(map(int, input().split())), reverse=True)\nif N<=K:\n\tprint((0))\nelse:\n\tprint((sum(H[K:])))\n", "h,k = list(map(int,input().split()))\nlst = list(map(int,input().split()))\nlst.sort()\nif len(lst) >= k + 1:\n print((sum(lst[:len(lst)-k])))\nelse:\n print((0))\n\n", "n, k = map(int, input().split())\nh = list(map(int, input().split()))\nh = sorted(h, reverse=True)\n\nif k >= n:\n print(0)\nelse:\n print(sum(h[k:]))", "n,k = map(int,input().split())\nh = list(map(int,input().split()))\nprint(sum(sorted(h)[:n-k]) if n-k>0 else 0)", "n,k = map(int,input().split())\nh = list(map(int,input().split()))\nh.sort(reverse=True)\nif k>=n:\n print(0)\nelse:\n ans = 0\n for i in range(k,n):\n ans += h[i]\n print(ans)", "N,K = map(int, input().split())\nH = sorted(list(map(int, input().split())), reverse = True)\n\nprint(sum(H[K:]))", "N, K = map(int,input().split(' '))\nH_ls = list(map(int, input().split(' ')))\nH_ls.sort(reverse=True)\nprint(sum(H_ls[K:]))", "N,K=map(int,input().split())\nH=input()\n\ndef ans153(N:int, K:int, H:str):\n if K==0:\n H_list=sorted(list(map(int,H.split())))\n return sum(H_list)\n elif len(list(map(int,H.split())))>K:\n H_list=sorted(list(map(int,H.split())))\n H_list=H_list[:-K]\n return sum(H_list)\n else:\n return 0\n\nprint(ans153(N,K,H))", "n,k = list(map(int,input().split()))\nH = sorted(list(map(int,input().split())))\nif n <= k:\n print((0))\n return\nif k == 0:\n print((sum(H)))\n return\nprint((sum(H[:-k])))\n", "N, K = map(int, input().split())\nlst = list(map(int, input().split()))\n\nif N <= K:\n print(0)\n\nelse:\n lst.sort(reverse = True)\n lst = lst[K:]\n print(sum(lst))", "n,k = map(int,input().split())\nh = list(map(int,input().split()))\n\nh.sort(reverse=True)\n\nans = sum(h[k:])\nprint(ans)", "n, k = map(int, input().split())\nh = sorted(list(map(int,input().split())))\nif k >= len(h):\n print(0)\n return\nprint(sum(h[0:n-k]))", "N, K = list(map(int, input().split()))\nH = list(map(int, input().split()))\n\n\nif(len(H) > K):\n print((sum(sorted(H)[0:len(H)-K])))\nelse:\n print((0))\n", "N,K = map(int,input().split())\nH = [int(x) for x in input().split()]\nH_sort = sorted(H,reverse=True)\nprint(sum(H_sort[K:]))", "N, K = map(int, input().split(' '))\nH_ls = list(map(int, input().split(' ')))\nH_ls.sort(reverse=True)\nprint(sum(H_ls[K:]))", "N, K = map(int, input().split(' '))\nH_ls = list(map(int, input().split(' ')))\nH_ls.sort(reverse=True)\nprint(sum(H_ls[K:]))", "a = list(map(int,input().split()))\nb = list(map(int,input().split()))\n\nif len(b) <= a[1]:\n print(\"0\")\nelif a[1]==0:\n print(sum(b))\nelse:\n b.sort(reverse=True)\n print(sum(b[a[1]:]))", "N,K=map(int,input().split())\nHP=list(map(int,input().split()))\n\nHP.sort()\n\nif K>0:\n HP=HP[:-K]\n\nprint(sum(HP))", "n,k = [int(x) for x in input().split()]\nh = [int(x) for x in input().split()]\nh.sort()\nans = 0\nfor i in range(n-k):\n ans += h[i]\nprint(ans)", "n, k = map(int, input().split())\nh = list(map(int, input().split()))\nh.sort()\n\nif k >= n:\n\tprint(0)\nelse:\n\t# for i in range(k):\n\t# \th.remove(max(h))\n\th = h[:n - k]\n\tprint(sum(h))", "n, k = map(int,input().split())\nh = list(map(int,input().split()))\nh.sort()\nh.reverse()\nif (k > n):\n k = n\nfor i in range(k):\n h[i] = 0\nprint(sum(h))", "N, K = map(int, input().split())\nH = list(map(int, input().split()))\n\nH.sort()\nm = min(N, K)\nH = H[:N-m]\nans = 0\nfor i in range(len(H)):\n ans += H[i]\nprint(ans)", "n, k = map(int, input().split())\n\nh = list(map(int, input().split()))\n\nh.sort(reverse = True)\n\nprint(sum(h[k:]))", "#!/usr/bin/env python3\ndef main():\n N, K = list(map(int, input().split()))\n H = sorted([int(x) for x in input().split()])\n\n if K == 0:\n print((sum(H)))\n elif N > K:\n print((sum(H[:-K])))\n else:\n print((0))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N, K = map(int, input().split())\nH = list(map(int, input().split()))\n \n# N<=K\u306e\u5834\u5408\u3001\u5168\u3066\u306e\u30e2\u30f3\u30b9\u30bf\u30fc\u3092\u5fc5\u6bba\u6280\u3067\u5012\u3057\u3066\u7d42\u4e86\n# N>K\u306e\u5834\u5408\u3001N\u4f53\u306e\u30e2\u30f3\u30b9\u30bf\u30fc\u306e\u3046\u3061\u3001\u4f53\u529b\u304c\u9ad8\u3044\u9806\u306b\u3001K\u4f53\u3092\u5fc5\u6bba\u6280\u3067\u5012\u3059\n# \u6b8b\u3063\u305f\u30e2\u30f3\u30b9\u30bf\u30fc\u306f\u3001\u653b\u6483\u306b\u3088\u3063\u3066\u5012\u3059\n# \u653b\u6483\u306e\u56de\u6570\u3092\u6c42\u3081\u308b\uff08\u5fc5\u6bba\u6280\u306f\u6570\u3048\u306a\u3044\uff09\u3053\u3068\u306b\u6ce8\u610f\u3059\u308b\n\n# \u8a08\u7b97\u91cf\u306fO(NlogN)\u3067\u9593\u306b\u5408\u3046\nH = sorted(H, reverse=True)\nans = 0\nif N > K: ans = sum(H[K:])\n \nprint(ans)", "N, K = map(int, input().split())\nH = list(map(int, input().split()))\n\nH = sorted(H)\nhp = 0\nfor i in range(N-K):\n hp += H[i]\nprint(hp)", "def N():\n return int(input())\ndef L():\n return list(map(int,input().split()))\ndef NL(n):\n return [list(map(int,input().split())) for i in range(n)]\nmod = pow(10,9)+7\n\n#import numpy as np\nimport sys\nimport math\nimport collections\n\nn,k = L()\nh = L()\nh.sort()\nprint(sum(h[:max(n-k,0)]))", "N, K = map(int, input().split())\nH = list(map(int, input().split()))\n\nif N <= K:\n print(0)\nelif K == 0:\n print(sum(H))\nelse:\n total = 0\n for i in H:\n total += i\n max_hp = sum(sorted(H, reverse=True)[:K])\n print(total - max_hp)", "N,K = list(map(int,input().split()))\nHlist = list(map(int,input().split()))\n\nHlist = sorted(Hlist,reverse = True)\n#print (Hlist)\n\nif len(Hlist)>=K and K!=0:\n del Hlist[0:K]\nelif len(Hlist)<K:\n del Hlist[0:len(Hlist)]\n\nif len(Hlist)>0:\n print((sum(Hlist)))\nelse:\n print((len(Hlist)))\n", "N,K = map(int,input().split())\nH = sorted(list(map(int,input().split())))\n\nif not N <= K:\n print(sum(H[0:N-K]))\nelse:\n print(0)", "n, k = map(int, input().split())\nh = list(map(int, input().split()))\nh.sort(reverse=True)\nans = 0\nfor i in range(k, n): ans += h[i]\nprint(ans)", "N,K = list(map(int, input().split(\" \")))\nH = sorted(list(map(int, input().split(\" \"))), reverse=True)\nZ = 0\nR = 0\nfor n,e in enumerate(H):\n if (n == K):\n Z = n\n break\n elif (K >= len(H)):\n Z = len(H)\n break\nfor i in H[Z:]:\n R += i\nprint(R)\n", "N,K=map(int,input().split())\nH=list(map(int,input().split()))\nif N<=K:\n print(0)\nelse:\n H.sort(reverse=True)\n for i in range(K):\n H[i]=0\n print(sum(H))", "n,k=list(map(int,input().split()))\nh=list(map(int,input().split()))\nh.sort(reverse=True)\n\nprint((sum(h[k:])))\n", "n,k = map(int, input().split())\nh = list(map(int, input().split()))\nif k >= len(h):\n print(0)\nelse:\n h.sort()\n print(sum(h[:n-k]))", "n, k = map(int, input().split())\nh = list(map(int, input().split()))\n\nh.sort(reverse=True)\nprint(sum(h[min(n,k):]))", "N, K = map(int, input().split(' '))\nH_ls = list(map(int, input().split(' ')))\nH_ls.sort(reverse=True)\nprint(sum(H_ls[K:]))", "n, k = list(map(int, input().split()))\nh = sorted(list(map(int, input().split())))\n\nif k==0: print((sum(h)))\nelse: print((sum(h[:-k])))\n", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Tue Sep 8 01:07:55 2020\n\n@author: liang\n\"\"\"\n\nN, K = map(int, input().split())\nH = [int(x) for x in input().split()]\nH.sort()\n\nif N > K :\n ans = sum(H[:N-K])\nelse:\n ans = 0\nprint(ans)", "a,b = map(int,input().split())\nlis = list(map(int,input().split()))\nlis.sort(reverse=True)\nprint(sum(lis[b:]))", "N,K = map(int,input().split())\nH = list(map(int,input().split()))\nif K==0:\n print(sum(H))\nelse:\n print(sum(sorted(H)[:-K]))", "N,K=map(int,input().split())\nHlist=list(map(int,input().split()))\nif N-K>0:\n print(sum(sorted(Hlist)[:N-K]))\nelse:\n print(0)", "N,K=list(map(int,input().split()))\nH=sorted(list(map(int,input().split())))\nif len(H) < K:\n print((0))\nelse:\n print((sum(H[:N-K])))\n", "n,k=map(int,input().split())\nh=list(map(int,input().split()))\nh.sort()\ns=0\nfor i in range(n-k):\n s += h[i]\nprint(s)", "n,k = map(int,input().split())\nhealth = list(map(int,input().split()))\ns_health = sorted(health)\nif n <= k:\n print(0)\n return\n\nprint(sum(s_health[:n-k]))", "n, k = [int(i) for i in input().split()]\na = sorted([int(i) for i in input().split()])\nif k <= 0:\n print(sum(a))\nelse:\n print(sum(a[:-k]))"]
{"inputs": ["3 1\n4 1 5\n", "8 9\n7 9 3 2 3 8 4 6\n", "3 0\n1000000000 1000000000 1000000000\n"], "outputs": ["5\n", "0\n", "3000000000\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,339
667fa66309fe4b5ef5d1342400a76bc6
UNKNOWN
There are N balls in the xy-plane. The coordinates of the i-th of them is (x_i, i). Thus, we have one ball on each of the N lines y = 1, y = 2, ..., y = N. In order to collect these balls, Snuke prepared 2N robots, N of type A and N of type B. Then, he placed the i-th type-A robot at coordinates (0, i), and the i-th type-B robot at coordinates (K, i). Thus, now we have one type-A robot and one type-B robot on each of the N lines y = 1, y = 2, ..., y = N. When activated, each type of robot will operate as follows. - When a type-A robot is activated at coordinates (0, a), it will move to the position of the ball on the line y = a, collect the ball, move back to its original position (0, a) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. - When a type-B robot is activated at coordinates (K, b), it will move to the position of the ball on the line y = b, collect the ball, move back to its original position (K, b) and deactivate itself. If there is no such ball, it will just deactivate itself without doing anything. Snuke will activate some of the 2N robots to collect all of the balls. Find the minimum possible total distance covered by robots. -----Constraints----- - 1 \leq N \leq 100 - 1 \leq K \leq 100 - 0 < x_i < K - All input values are integers. -----Inputs----- Input is given from Standard Input in the following format: N K x_1 x_2 ... x_N -----Outputs----- Print the minimum possible total distance covered by robots. -----Sample Input----- 1 10 2 -----Sample Output----- 4 There are just one ball, one type-A robot and one type-B robot. If the type-A robot is used to collect the ball, the distance from the robot to the ball is 2, and the distance from the ball to the original position of the robot is also 2, for a total distance of 4. Similarly, if the type-B robot is used, the total distance covered will be 16. Thus, the total distance covered will be minimized when the type-A robot is used. The output should be 4.
["n = int(input())\nk = int(input())\nx = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n ans += 2*min(k-x[i],x[i])\nprint(ans)", "n = int(input())\nk = int(input())\nli = list(map(int,input().split()))\n\ndis = 0\nfor i in range(n):\n dis += min(2*li[i],2*abs(li[i]-k))\n\nprint(dis)", "n = int(input())\nk = int(input())\nx = list(map(int, input().split()))\nans = 0\n\nfor i in x:\n ans += 2*min(i,abs(k-i))\n\nprint(ans)", "N=int(input())\nK=int(input())\nX=list(map(int,input().split()))\n\nans=0\nfor x in X:\n ans+=min(abs(x),abs(x-K))*2\nprint(ans)", "N = int(input())\nK = int(input())\nX = list(map(int,input().split()))\n\nans = 0\nfor x in X:\n ans += min(abs(x),abs(x-K))\n\nprint(ans*2)", "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()\nk = ri()\nans = 0\nfor i in rl():\n ans += min(i, abs(k-i))\nprint((ans*2))\n\n\n\n\n\n\n\n\n\n\n", "N, K, *X = map(int, open(0).read().split())\n\nans = 0\nfor y,x in enumerate(X, start=1):\n a = x * 2\n b = (K - x) * 2\n ans += min(a, b)\n\nprint(ans)", "N = int(input())\nK = int(input())\nprint((sum([min(int(a), K - int(a)) for a in input().split()]) * 2))\n", "n = int(input())\nk = int(input())\nxn = list(map(int,input().split()))\n\nclass Solution:\n def __init__(self,n,k,xn):\n self.n = n\n self.k = k\n self.xn = xn\n \n def printout(self):\n print(n,k,xn)\n \n def answer(self):\n total = 0\n total = 0\n for xi in xn:\n a = abs(xi - 0)\n b = abs(xi - k)\n if a <= b:\n total += a * 2\n else:\n total += b * 2\n print(total)\n\nconditions = Solution(n,k,xn)\nconditions.answer()", "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, k = (int(input()) for _ in range(2))\n x = Input()\n ans = 0\n for i in range(n):\n ans += min(abs(0-x[i]), abs(k-x[i])) * 2\n print(ans)\n\n\nmain()", "N = int(input())\nK = int(input())\nx = list(map(int,input().split()))\ndistance = 0\n\nfor i in range(N):\n distance += min(2*x[i],2*abs(x[i]-K))\n \nprint(distance)", "N = input()\nK = int(input())\nl = input().split()\n \n\n \nans =0 \nfor i in l:\n\ts = int(i)\n\tans += min(s,K-s)\nprint((ans*2))\n", "n=int(input())\nk=int(input())\nx=list(map(int,input().split()))\nans=0\nfor i in range(n):\n ans+=min(x[i],k-x[i])\nprint(2*ans)", "n = int(input())\nk = int(input())\nxn = list(map(int, input().split()))\n\n\nclass Solution:\n def __init__(self, n, k, xn):\n self.n = n\n self.k = k\n self.xn = xn\n\n @staticmethod\n def printout():\n print(n, k, xn)\n\n @staticmethod\n def answer():\n total = 0\n for xi in xn:\n a = abs(xi - 0)\n b = abs(xi - k)\n if a <= b:\n total += a * 2\n else:\n total += b * 2\n print(total)\n\n\nconditions = Solution(n, k, xn)\nconditions.answer()", "n = int(input())\nk = int(input())\nx = list(map(int, input().split()))\n\ntot_dis = 0\nfor i in range(n):\n min_dis = min(x[i], k-x[i])\n tot_dis += 2*min_dis\nprint(tot_dis)", "n = int(input())\nk = int(input())\npoints = list(map(int, input().split()))\n\nans = 0\nfor i in points:\n minimum = min(abs(k-i), abs(i))\n ans += minimum*2\n\nprint(ans)", "n = int(input())\nk = int(input())\nli = list(map(int,input().split()))\ntotal = 0\nfor i in range(n):\n total += 2*min(li[i],k-li[i])\nprint(total)", "def int_list(sepalate=\" \"): return list(map(int, input().split(sepalate)))\n\n\ndef solve1(n, k, x):\n ans = 0\n\n for i in range(n):\n ans += min(abs(k-x[i]), x[i]) * 2\n\n return ans\n\n\nn = int(input())\nk = int(input())\nx = int_list()\nprint((solve1(n, k, x)))\n", "#!/usr/local/bin/python3\n# https://atcoder.jp/contests/abc074/tasks/abc074_b\n\nN = int(input())\nK = int(input())\nX = list(map(int, input().split()))\n\nans = 0\nfor x in X:\n if x > abs(K-x):\n ans += abs(K-x)*2\n else:\n ans += x*2\nprint(ans)\n", "n,k=int(input()),int(input());print(sum([min(i*2,(k-i)*2) for i in list(map(int,input().split()))]))", "N = int(input())\nK = int(input())\nX = list(map(int, input().split()))\nans = 0\n\nfor i in range(N):\n if X[i] <= (K - X[i]):\n ans += (X[i] * 2)\n else:\n ans += ((K - X[i]) * 2)\nprint (ans)", "n = int(input())\nk = int(input())\nx = list(map(int, input().split()))\nans = 0\nfor i in x:\n ans += min(i,k-i)\nprint(2*ans)", "n = int(input())\nk = int(input())\nx = [int(x) for x in input().split()]\n\n\nans = 0\nfor i in range(n):\n ans += 2*min(x[i], abs(x[i]-k))\n\nprint(ans)", "N = int(input())\nK = int(input())\nX = list(map(int, input().split()))\n\nans = 0\n\nfor x in X:\n ans += min(x, K-x)*2\n \nprint(ans)", "N = int(input())\nK = int(input())\nx = list(map(int, input().split()))\nans = 0\nfor i in x:\n ans += min(i, K - i) * 2\nprint(ans)", "n = int(input())\nk = int(input())\nx = [int(x.strip()) for x in input().split()]\nans = 0\nfor i in x:\n if abs(i-k) > i:\n ans = ans + i\n else:\n ans = ans + abs(i-k)\nans += ans\nprint(ans)", "n = int(input())\nk = int(input())\nx = [int(s) for s in input().split()]\n\nmove = 0\nfor i in x:\n move += min(i, abs(i - k)) * 2\nprint(move)", "n = int(input())\nk = int(input())\nx_l = list(map(int, input().split()))\nth = k/2\n\nans = 0\nfor x in x_l:\n if x >= th:\n ans += abs(x-k)\n else:\n ans += x\nprint(ans*2)", "n,k = [int(input()) for i in range(2)]\nx = list(map(int,input().split()))\n\ndistance = 0\n\nfor i in range(len(x)):\n distance += 2*(min(x[i], abs(x[i]-k)))\n \nprint(distance)", "a=int(input())\nb=int(input())\nc=list(map(int,input().split()))\ntotal=0\nfor i in range(a):\n d=2*c[i]\n e=2*abs(b-c[i])\n total+=min(d,e)\nprint(total)", "n = int(input())\nk = int(input())\nline = list(map(int, input().split()))\nans = 0\nfor i in range(n):\n ans += min(line[i], k-line[i]) * 2\nprint(ans)", "N=int(input())\nK=int(input())\nx=list(map(int,input().split()))\n\nans=0\nfor i in range(N):\n a=abs(x[i])*2\n b=abs(K-x[i])*2\n ans+=min(a,b)\n \nprint(ans)", "_,k=input(),int(input());print(sum([min(i*2,(k-i)*2) for i in list(map(int,input().split()))]))", "n = int(input())\nk = int(input())\ndata = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n ans += min(data[i]*2, (k - data[i])*2)\nprint(ans)", "n = int(input())\nk = int(input())\nL = list(map(int,input().split()))\nans = 0\nfor l in L:\n a = l\n b = abs(k-l)\n ans += min(a,b)*2\nprint(ans)", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, K: int, x: \"List[int]\"):\n return sum(min(xx, abs(xx-K)) for xx in x) * 2\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 N = int(next(tokens)) # type: int\n K = int(next(tokens)) # type: int\n x = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n print((solve(N, K, x)))\n\ndef test():\n import doctest\n doctest.testmod()\n\ndef __starting_point():\n #test()\n main()\n\n__starting_point()", "import math\n\nn = int(input())\nk = int(input())\nx = list(map(int,input().split()))\ncnt = 0\n\ndis = math.ceil(k/2)\nfor i in x:\n if i == k:\n continue\n elif i <= dis:\n cnt += i*2\n else:\n cnt += (k-i)*2\nprint(cnt)\n", "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 K = I()\n x = LI()\n\n ans = sum([2 * min(x[i], K - x[i]) for i in range(N)])\n print(ans)\n\ndef __starting_point():\n resolve()\n__starting_point()", "N = int(input())\nK = int(input())\nx = list(map(int, input().split()))\n\nsum = 0\nfor i in range(N):\n dist = min(x[i], abs(x[i]-K))\n sum += dist\n \nprint(sum*2)", "n,k=int(input()),int(input());print(sum([min(abs(i*2),abs((i-k)*2)) for i in list(map(int,input().split()))]))", "a=int(input())\nb=int(input())\nc=list(map(int,input().split()))\nd=0\nfor i in range(a):\n if c[i]<b-c[i]:\n d=d+c[i]\n else:\n d=d+b-c[i]\nprint(2*d)", "#\n# abc074 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\n10\n2\"\"\"\n output = \"\"\"4\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"2\n9\n3 6\"\"\"\n output = \"\"\"12\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"5\n20\n11 12 9 17 12\"\"\"\n output = \"\"\"74\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N = int(input())\n K = int(input())\n X = list(map(int, input().split()))\n\n ans = 0\n for x in X:\n ans += min(x*2, abs(K-x)*2)\n\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "N = int(input())\nK = int(input())\nX = [int(n) for n in input().split()]\n\nans = 0\n\nfor x in X:\n diff = abs(K - x)\n if diff < x:\n ans += diff\n else:\n ans += x\nprint((2*ans))\n", "N = int(input())\nK = int(input())\nx = list(map(int, input().split()))\n\nsum = 0\n\nfor i in range(N):\n if x[i] >= K - x[i]:\n sum += 2 * (K - x[i])\n \n else:\n sum += 2 * x[i]\n\nprint(sum)", "# -*- coding:utf-8 -*-\nN = int(input())\nK = int(input())\nx_list = list(map(int,input().split()))\n\nsum_distance = 0\n\nfor x in x_list:\n if x < K - x:\n sum_distance += 2*x\n else:\n sum_distance += 2*(K-x)\n\nprint(sum_distance)", "N = int (input())\nK = int (input())\nx = list(map(int, input().split()))\nsum_min = 0\n\nfor p in x:\n a = 2*p\n b = 2*abs(K-p)\n if a >= b:\n sum_min += b\n elif a < b:\n sum_min += a\n\nprint(sum_min)", "N = int(input())\nK = int(input())\nx = list(map(int, input().split()))\n\nans = 0\nfor i in range(N):\n ans += min(x[i]-0, K-x[i])\nprint((ans*2))\n", "n = int(input())\nk = int(input())\na = [int(x) for x in input().split()]\n\nres = 0\n\nfor i in range(n):\n res += min(2*(abs(a[i])),2*(abs(a[i] - k)))\n\nprint(res)", "N = int(input())\nK = int(input())\n\nx = list(map(int, input().split()))\ncalc = 0\n\nfor i in range(N):\n calc += min(x[i], abs(K-x[i])) * 2\n\nprint(calc)", "N = int(input(\"\"))\nK = int(input(\"\"))\na = input(\"\").split(\" \")\na = [int(aa) for aa in a]\nans = 0\nfor x in a:\n if (K-x) < x:\n ans += (K-x)*2\n elif (K-x) >= x:\n ans += x*2\nprint(ans)\n", "\"\"\"Boot-camp-for-Beginners_Easy009_B_Collecting-Balls-(Easy-Version)_28-August-2020.py\"\"\"\n\nN = int(input())\nK = int(input())\nx = list(map(int, input().split()))\n\ns = 0\nfor i in range(N):\n if x[i] < K/2:\n s += 2*x[i]\n else:\n s += 2*(K-x[i])\nprint(s)\n", "N = int(input())\nK = int(input())\nX = list(map(int,input().split()))\n\nans = 0\nfor x in X:\n ans += 2 * (x if x <= K - x else K - x)\n \nprint(ans)", "\n# ABC074\n\nN = int(input())\nK = int(input())\nX = list(map(int, input().split()))\n\nans = 0\nfor x in X:\n ans += min(x, K-x)*2\nprint(ans)\n", "def main():\n _ = int(input())\n k = int(input())\n x = list(map(int, input().split()))\n print((sum([min([abs(xi - point) for point in [0, k]]) * 2 for xi in x])))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nk = int(input())\nx = list(map(int, input().split()))\n\nprint(sum([min(position, abs(k - position)) * 2 for position in x]))", "n = int(input())\nk = int(input())\nx = list(map(int, input().split()))\nans = 0\nfor i in x:\n ans += min(i, k-i)*2\nprint(ans)", "n = int(input())\nk = int(input())\n\nx = list(map(int, input().split()))\nans = 0\nfor i in x:\n ans += 2 * min(i, k - i)\nprint(ans)", "N = int(input())\nK = int(input())\nx = list(map(int,input().split()))\nans = 0\nfor i in x:\n if i <= K - i:\n ans += i\n if i > K - i:\n ans += K - i\nprint((2 * ans))\n \n", "N=int(input())\nK=int(input())\nx=list(map(int,input().split()))\nprint((sum(2*min(y,K-y) for y in x)))\n", "N = int(input())\nK = int(input())\nX = list(map(int, input().split()))\ncnt = 0\n\nfor x in X:\n cnt += min(x, abs(K-x))*2\nprint(cnt)\n", "n = int(input())\nk = int(input())\nx = list(map(int, input().split()))\n\nd = 0\nfor i in x:\n d += min(i, k-i)\nprint(2*d)", "N=int(input())\nK=int(input())\nx=list(map(int,input().split()))\ntot=0\nfor i in range(N):\n if abs(x[i]-K)<x[i]:\n tot+=2*(abs(x[i]-K))\n else:\n tot+=2*x[i]\nprint(tot)", "N = int(input())\nK = int(input())\nlst = input().split()\n\nans = 0\n\nfor i in range(N):\n x = int(lst[i])\n if abs(x) < abs(K - x):\n ans += 2 * abs(x)\n else:\n ans += 2 * abs(K - x)\n\nprint(ans)", "n = int(input())\nk = int(input())\nx = list(map(int,input().split()))\nc= 0\nfor i in range(len(x)):\n c+=min(x[i],k-x[i])*2\nprint(c)", "N = int(input())\nK = int(input())\nx = [int(x) for x in input().split()]\nans = 0\nfor i in range(N):\n ans += 2 * min(abs(x[i]-0), abs(x[i]-K))\nprint(ans)", "N = int(input())\nK = int(input())\nx = list(map(int,input().split()))\nans = 0\n\nfor i in range(N):\n ans += min(abs(x[i] - 0), abs(K - x[i]))\nprint(ans * 2)", "n = int(input())\nk = int(input())\n\ns = 0\nxs = list(map(int, input().split()))\nfor x in xs: \n if x < abs(k-x):\n s += 2 * x\n else:\n s += 2 * abs(k-x)\n \nprint(s)\n", "n = int(input())\nk = int(input())\nv = list(map(int, input().split()))\n\nans = 0\nfor i in v:\n tmp = min(i, k-i)\n ans += tmp\nprint((ans*2))\n", "n = int(input())\nk = int(input())\nl = list(map(int, input().split()))\nc = 0\nfor x in l:\n c += min(x,k-x)\nprint(2*c)", "n=int(input())\nk=int(input())\nx=list(map(int,input().split()))\n\nans=0\nfor i in range(n):\n ans+=min(abs(x[i]-0), abs(x[i]-k))\nprint(ans*2)", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, K: int, x: \"List[int]\"):\n res = 0\n for x_ in x:\n res += 2*min(x_, abs(K-x_))\n print(res)\n return\n\n\n# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template)\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 K = int(next(tokens)) # type: int\n x = [int(next(tokens)) for _ in range(N)] # type: \"List[int]\"\n solve(N, K, x)\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nK = int(input())\nX = list(map(int, input().split()))\nans = 0\nfor x in X:\n ans += min(x, abs(K-x))*2\nprint(ans)\n", "n = int(input())\nk = int(input())\nx = list(map(int,input().split()))\ncount = 0\nfor i in range(n):\n count += min(x[i], k-x[i])\nprint(count * 2)", "_,k=input(),int(input());print(sum(min(i,(k-i))*2 for i in list(map(int,input().split()))))", "N = int(input())\nK = int(input())\nx = [int(c) for c in input().split() ]\n\ncnt = 0\nfor i in range(N):\n a = 0\n b = 0\n a = abs(x[i]-0)*2\n b = abs(x[i]-K)*2\n if a <= b:\n cnt += a\n else:\n cnt += b\n\nprint(cnt)", "N = int(input())\nK = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nfor a in A:\n ans += 2*min(a, K-a)\nprint(ans)", "N = int(input())\nK = int(input())\nx = [int(i) for i in input().split()]\nans = 0\nfor i in range(N) :\n xi = x[i]\n if xi <= (K//2) :\n ans += 2*xi\n else :\n ans += 2*(K-xi)\nprint(ans)", "_,k=input(),int(input());print(sum([min(i,(k-i))*2 for i in list(map(int,input().split()))]))", "N = int(input())\nK = int(input())\nx = list(map(int, input().split()))\n\nans = 0\n\nfor x in x:\n a = 2 * x\n b = abs(K - x) * 2\n ans += min(a, b)\n\nprint(ans)\n", "n = int(input())\nk = int(input())\nnums = list(map(int, input().split()))\nprint(2 * sum([min(k - i, i) for i in nums]))", "n = int(input())\nk = int(input())\nx = list(map(int, input().split()))\nans = 0\nfor i in range(n):\n if x[i] >= k - x[i]:\n ans += 2*(k - x[i])\n else:\n ans += 2*x[i]\nprint(ans)", "n = int(input())\nk = int(input())\nx_list = list(map(int, input().split()))\nans = 0\nfor i in x_list:\n if 2*i < k:\n ans += 2*i\n else :\n ans += (k-i)*2\nprint(ans)\n", "N = int(input())\nK = int(input())\nx = list(map(int,input().split()))\ntotal = 0\nfor i in range (N):\n if x[i]<K/2:\n total += 2*x[i]\n elif x[i]>= K/2:\n total += 2*(K-x[i])\nprint(total)", "n = int(input())\nk = int(input())\nx = list(map(int, input().split()))\na = 0\nfor i in x:\n if 2 * i < 2 * (k - i):\n a += 2 * i\n else:\n a += 2 * (k - i)\nprint(a)", "n = int(input())\nk = int(input())\nx = list(map(int, input().split()))\nd = 0\nfor i in x:\n y = min(i, abs(k-i))\n d += 2*y\nprint(d)", "N = int(input())\nK = int(input())\nxs = list(map(int, input().split()))\n\ndist_sum = 0\nfor i in range(N):\n\ty = i + 1\n\tx = xs[i]\n\t\n\tif x > K - x:\n\t\tdist_sum += (K - x) * 2\n\telse:\n\t\tdist_sum += x * 2\n\t\t\nprint(dist_sum)\n\t\n", "N = int(input())\nK = int(input())\nX = list(map(int, input().split()))\nY = [i for i in range(1, N+1)]\nans = 0\n\nfor x in X:\n distance_a = x\n distance_b = abs(K-x)\n if distance_a < distance_b:\n ans += distance_a\n else:\n ans += distance_b\n \nprint(ans*2)", "with open(0) as f:\n N, K, *X = map(int, f.read().split())\nprint(2*sum(min(x, K-x) for x in X))", "N = int(input())\nK = int(input())\nX = list([int(x) for x in input().split()])\n\nresult = 0\n\nfor pos in X:\n if pos <= abs(pos - K):\n result += 2 * pos\n else:\n result += 2 * abs(pos - K)\n\nprint(result)\n", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\ndef main():\n data=[]\n n = int(input())\n k = int(input())\n data=list(map(int,input().split()))\n length=0\n\n for ball in data:\n if ball < k-ball:\n length+=2*ball\n else:\n length+=2*(k-ball)\n print(length)\n\ndef __starting_point():\n main()\n__starting_point()", "n=int(input())\nk=int(input())\nx=list(map(int,input().split()))\nans=0\nfor i in range(n):\n m=min(abs(x[i]),abs(k-x[i]))\n ans+=m\n\nprint(ans*2)", "n = int(input())\nk = int(input())\nx = list(map(int,input().split()))\nans = 0\nfor i in range(n):\n ans += 2*min(abs(x[i]-k),abs(x[i]))\nprint(ans)", "N = int(input())\nK = int(input())\ndist = 0\nfor val in list(map(int,input().split())):\n dist += 2*min(val,abs(val-K))\n \nprint(dist)", "N=int(input())\nK=int(input())\nX=list(map(int,input().split()))\n\nans=0\n\nfor i in X:\n Y=[]\n Y.append(2*abs(i))\n Y.append(2*abs(i-K))\n ans+=min(Y)\n \nprint(ans)", "n,k=int(input()),int(input());x=list(map(int,input().split()))\nprint(sum([min(i,j) for i,j in zip([abs(i*2) for i in x],[abs((i-k)*2) for i in x])]))", "n=int(input())\nk=int(input())\nl=list(map(int,input().split()))\n\nans=0\nfor i in l:\n if i>=k/2:\n ans+=abs(k-i)*2\n else:\n ans+=i*2\n\nprint(ans)\n", "N = int(input())\nK = int(input())\nX = [int(x) for x in input().split()]\n\nans = 0\nfor x in X:\n ans += min(x, abs(x-K))\nans *= 2\nprint(ans)", "n=int(input())\nk=int(input())\nx=list(map(int,input().split()))\nans=0\nfor xi in x:\n ans+=2*min(xi,k-xi)\nprint(ans)\n", "from typing import List\n\n\ndef answer(n: int, k: int, xs: List[int]) -> int:\n moving_distance = 0\n reference_value = k / 2\n for x in xs:\n if x <= reference_value:\n moving_distance += x * 2\n else:\n moving_distance += (k - x) * 2\n\n return moving_distance\n\n\ndef main():\n n = int(input())\n k = int(input())\n xs = list(map(int, input().split()))\n print(answer(n, k, xs))\n\n\ndef __starting_point():\n main()\n__starting_point()"]
{"inputs": ["1\n10\n2\n", "2\n9\n3 6\n", "5\n20\n11 12 9 17 12\n"], "outputs": ["4\n", "12\n", "74\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
21,342
c16c9d414aaffb4910475afd4a74ae30
UNKNOWN
You planned a trip using trains and buses. The train fare will be A yen (the currency of Japan) if you buy ordinary tickets along the way, and B yen if you buy an unlimited ticket. Similarly, the bus fare will be C yen if you buy ordinary tickets along the way, and D yen if you buy an unlimited ticket. Find the minimum total fare when the optimal choices are made for trains and buses. -----Constraints----- - 1 \leq A \leq 1 000 - 1 \leq B \leq 1 000 - 1 \leq C \leq 1 000 - 1 \leq D \leq 1 000 - All input values are integers. -----Input----- Input is given from Standard Input in the following format: A B C D -----Output----- Print the minimum total fare. -----Sample Input----- 600 300 220 420 -----Sample Output----- 520 The train fare will be 600 yen if you buy ordinary tickets, and 300 yen if you buy an unlimited ticket. Thus, the optimal choice for trains is to buy an unlimited ticket for 300 yen. On the other hand, the optimal choice for buses is to buy ordinary tickets for 220 yen. Therefore, the minimum total fare is 300 + 220 = 520 yen.
["a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nsum = (min(a, b) + min(c, d))\nprint(sum)", "A, B, C, D = [int(input()) for i in range(4)]\n\nif A <= B:\n train = A\nelse:\n train = B\nif C <= D:\n bus = C\nelse:\n bus = D\n\nanswer = (train + bus)\nprint(answer)", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nprint((min(A,B)+min(C,D)))\n", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nprint(min(a,b)+min(c,d))", "a = list(int(input()) for i in range(4))\n\nprint(min(a[0],a[1]) + min(a[2],a[3]))", "# A - Traveling Budget\n\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nif A <= B:\n if C <= D:\n answer = A + C\n else:\n answer = A + D\nelif C <= D:\n answer = B + C\nelse:\n answer = B + D\n\nprint(answer)\n", "train1 = int(input())\ntrain2 = int(input())\nbus1 = int(input())\nbus2 = int(input())\n\na = min(train1, train2)\nb = min(bus1, bus2)\n\nprint(a + b)", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a,b)+min(c,d), flush=True)\n", "a=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\n\nprint(min(a,b)+min(c,d))", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nbus = [A, B]\ntrain = [C, D]\n\nprint(min(bus) + min(train))", "# 092\n\n# 1.\u5024\u3092\u6b63\u3057\u304f\u53d6\u5f97\na =int(input())\nb =int(input())\nc =int(input())\nd =int(input())\n\n# 2.\u6b63\u3057\u304f\u51e6\u7406\nif a > b :\n resalt1=int(b)\nelse :\n resalt1=int(a)\n\nif c > d :\n resalt2=int(d)\nelse :\n resalt2=int(c)\n\nprint(resalt1 + resalt2)", "f = lambda: min(int(input()), int(input()))\nprint((f() + f()))\n", "A=int(input())\nB=int(input())\nC=int(input())\nD=int(input())\nprint((min(A,B)+min(C,D)))\n", "# \u96fb\u8eca\u3000\u901a\u5e38\u5207\u7b26A\u5186\u3001\u4e57\u308a\u653e\u984cB\u5186\n# \u30d0\u30b9\u3000\u901a\u5e38\u5207\u7b26C\u5186\u3001\u4e57\u308a\u653e\u984cD\u5186\na = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\ntotal_fare = (min(a, b) + min(c, d))\n\nprint(total_fare)", "A=int(input())\nB=int(input())\nC=int(input())\nD=int(input())\n\nprint(min(A,B)+min(C,D))", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nsums = [A + C, A + D, B + C, B + D]\n\nprint(min(sums))", "\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\n\na = A + C\nb = A + D\nc = B + C\nd = B + D\nprint(min(a, b, c, d))", "a= int(input())\nb=int(input())\nc=int(input())\nd=int(input())\nprint(min(a,b)+min(c,d))", "print(sum([min(map(int,[input(),input()]))for _ in[0,1]]))", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nans = min(A, B) + min(C, D)\nprint(ans)", "# \u6570\u5024\u306e\u53d6\u5f97\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\n# \u6599\u91d1\u306e\u6700\u5b89\u5024\u3092\u51fa\u529b\ntrain = min(A,B)\nbus = min(C,D)\ntbsum = train + bus\nprint(tbsum)", "A,B,C,D = [int(input()) for i in range(4)]\nprint(min(A, B)+min(C, D))", "A=int(input())\nB=int(input())\nC=int(input())\nD=int(input())\nd_list=[A,B]\nb_list=[C,D]\nb_list.sort()\nd_list.sort()\nprint(d_list[0]+b_list[0])", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nprint((min(a, b) + min(c, d)))\n", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nprint(min(a, b) + min(c, d))", "A=int(input())\nB=int(input())\nC=int(input())\nD=int(input())\nsum=0\nsum+=min(A,B)\nsum+=min(C,D)\nprint(sum)", "l = []\nfor i in range(4):\n l.append(int(input()))\nprint(min(l[0],l[1])+min(l[2],l[3]))", "a = [int(input()) for i in range(4)]\nx = min(a[0], a[1])\ny = min(a[2], a[3])\nprint((x + y))\n", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nprint(min(a,b)+min(c,d))", "print(min(int(input()),int(input()))+min(int(input()),int(input())))", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nans = min(a+c, a+d, b+c, b+d)\n\nprint(ans)", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\nprice = [A + C, B + C, A + D, B + D]\nprint((min(price)))\n", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nresult = min(a, b) + min(c, d)\n# result = int(min(a, b)) + int(min(c, d))\nprint(result)", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\nprint((min(A, B) + min(C, D)))\n", "a,b,c,d=[int(input()) for i in range(4)]\nprint(min(a,b)+min(c,d))", "#ABC092\na = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a+c,b+c,a+d,b+d))", "a = [[],[]]\nfor i in range(2):\n a[0].append(int(input()))\nfor i in range(2):\n a[1].append(int(input()))\na[0].sort()\na[1].sort()\nprint(a[0][0] + a[1][0])", "def main():\n a, b, c, d = (int(input()) for _ in range(4))\n print(min(a, b) + min(c, d))\n\n\nmain()", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a,b)+min(c,d))", "A=int(input())\nB=int(input())\nC=int(input())\nD=int(input())\nprint(min(A,B)+min(C,D))", "import sys\nA, B, C, D = map(int, sys.stdin.readlines())\nimport numpy as np\ntrain, bus = np.array([[A,B]]), np.array([[C,D]]).T\nprint((train+bus).min())", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\ntrain_list = [A, B]\n\nbus_list = [C, D]\n\nanswer = min(train_list) + min(bus_list)\n\nprint(answer)\n", "A = [int(input()) for i in range(4)]\nprint(min(A[0],A[1]) + min(A[2],A[3]))", "A=int(input())\nB=int(input())\nC=int(input())\nD=int(input())\nprint(min(A,B)+min(C,D))", "a = int(input())\nb = int(input())\nc = int(input())\n\nd = int(input())\n\nprint( min(a, b) + min(c, d))", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nif A <= B:\n train = A\nelse:\n train = B\nif C <= D:\n bus = C\nelse:\n bus = D\n\nanswer = (train + bus)\nprint(answer)", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\n# \u96fb\u8eca\u306e\u904b\u8cc3\u30ea\u30b9\u30c8\ntrain = [a,b]\n# \u30d0\u30b9\u306e\u904b\u8cc3\u30ea\u30b9\u30c8\nbus = [c,d]\n# \u96fb\u8eca\u306e\u30d0\u30b9\u306e\u305d\u308c\u305e\u308c\u6700\u5b89\u5024\u3092\u8db3\u3057\u5408\u308f\u305b\u308b\nprint(min(train)+ min(bus))", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nlist01 = [a, b]\nlist02 = [c, d]\nprint(min(list01) + min(list02))", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\nprint((min(A, B) + min(C, D)))\n", "a=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\nprint(min(a,b)+min(c,d))", "a,b,c,d = [int(input()) for _ in range(4)]\nprint(min(a,b) + min(c,d))", "a=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\n\nprint((min(a,b)+min(c,d)))\n", "\na=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\n\nprint((min(a,b)+min(c,d)))\n\n", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a,b)+min(c,d))", "'''\n\u554f\u984c\uff1a\n \u3042\u306a\u305f\u306f\u3001\u96fb\u8eca\u3068\u30d0\u30b9\u3092\u4e57\u308a\u7d99\u3044\u3067\u65c5\u884c\u3092\u3059\u308b\u8a08\u753b\u3092\u7acb\u3066\u307e\u3057\u305f\u3002\n \u96fb\u8eca\u306f\u65c5\u7a0b\u306b\u6cbf\u3063\u3066\u901a\u5e38\u306e\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 A\u5186\u304b\u304b\u308a\u3001\n \u4e57\u308a\u653e\u984c\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 B\u5186\u304b\u304b\u308a\u307e\u3059\u3002\n \u30d0\u30b9\u306f\u65c5\u7a0b\u306b\u6cbf\u3063\u3066\u901a\u5e38\u306e\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 C\u5186\u304b\u304b\u308a\u3001\n \u4e57\u308a\u653e\u984c\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 D\u5186\u304b\u304b\u308a\u307e\u3059\u3002\n\n \u96fb\u8eca\u304a\u3088\u3073\u30d0\u30b9\u306b\u3064\u3044\u3066\n \u901a\u5e38\u306e\u5207\u7b26\u3092\u8cb7\u3046\u304b\u4e57\u308a\u653e\u984c\u304d\u3063\u3077\u3092\u8cb7\u3046\u304b\u3092\u3046\u307e\u304f\u9078\u3093\u3060\u3068\u304d\u306e\u3001\n \u904b\u8cc3\u306e\u5408\u8a08\u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n'''\n\n'''\n\u5236\u7d04\uff1a\n 1 \u2264 A \u2264 1,000\n 1 \u2264 B \u2264 1,000\n 1 \u2264 C \u2264 1,000\n 1 \u2264 D \u2264 1,000\n \u5165\u529b\u5024\u306f\u3059\u3079\u3066\u6574\u6570\u3067\u3042\u308b\u3002\n'''\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 A, B, C, D \u306e\u5024\u3092\u53d6\u5f97\u3059\u308b\na = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\n# \u4e57\u308a\u63db\u3048\u306e\u30d1\u30bf\u30fc\u30f3\u3092\u30ea\u30b9\u30c8\u306b\u5165\u308c\u3066\u3001\u30ea\u30b9\u30c8\u306e\u6700\u5c0f\u5024\u3092\u51fa\u529b\u3059\u308b\ntravel_costs = [a + c, a + d, b + c, b + d]\n\nprint((min(travel_costs)))\n", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\nprint(min(A,B)+min(C,D))", "a=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\nprint(min(a,b)+min(c,d))", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\ntrain_plice = min(A,B)\nbus_plice = min(C,D)\n\nmin_plice = train_plice + bus_plice\nprint(min_plice)", "a=int(input())\nb=int(input())\nc=int(input())\nd=int(input())\n\nprint(min(a,b)+min(c,d))", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a + c, a + d, b + c, b + d))", "train=[]\nbus=[]\ntrain.append(int(input()))\ntrain.append(int(input()))\nbus.append(int(input()))\nbus.append(int(input()))\nprint(min(train)+min(bus))", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nif A < B:\n train = A\nelse:\n train = B\n\nif C < D:\n bus = C\nelse:\n bus = D\n\nprint(train + bus)", "t1=int(input())\nt2=int(input())\nb1=int(input())\nb2=int(input())\n\nprint((min(t1, t2)+min(b1, b2)))\n", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a,b) + min(c,d))", "l=[int(input()) for _ in range(2)]\nl1=[int(input()) for _ in range(2)]\nl.sort()\nl1.sort()\na=l[0]+l1[0]\nprint(a)", "# \u30d0\u30b9\u3068\u96fb\u8eca\u306e\u7d44\u307f\u5408\u308f\u305b\u904b\u8cc3\u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u308b\n\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nfare = [A+C, A+D, B+C, B+D]\nprint((min(fare)))\n", "print(min(int(input()),int(input()))+min(int(input()),int(input())))", "# A - Traveling Budget\n# https://atcoder.jp/contests/abc092/tasks/abc092_a\n\ntrain = []\nbus = []\n\ntrain.append(int(input()))\ntrain.append(int(input()))\nbus.append(int(input()))\nbus.append(int(input()))\n\nprint((min(train) + min(bus)))\n", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nprint(min(A, B) + min(C, D))", "# 092a\n\ndef atc_092a(ABCD: int) -> int:\n return min(ABCD[0], ABCD[1]) + min(ABCD[2], ABCD[3])\n\n\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nABCD = [A, B, C, D]\nprint((atc_092a(ABCD)))\n", "a = int(input())\nb = int(input())\nc = int(input())\n\nd = int(input())\n\ne = min(a, b)\nf = min(c, d)\n\nprint((e+f))\n", "li=[]\nans=0\nfor i in range(4):\n li.append(int(input()))\nif li[0]<li[1]:\n ans+=li[0]\nelse:\n ans+=li[1]\nif li[2]<li[3]:\n ans+=li[2]\nelse:\n ans+=li[3]\nprint(ans)", "a = int(input())\nb = int(input())\nc = int(input())\n\nd = int(input())\n\nif a > b:\n e = b\nelse:\n e = a\n\nif c > d:\n f = d\nelse:\n f = c\n\nprint((e + f))\n", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a, b) + min(c, d))", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nprint(min(a,b)+min(c,d))", "a, b, c, d = (int(input()) for n in range(0, 4))\nprint(min(a, b) + min(c, d))", "A=int(input())\nB=int(input())\nC=int(input())\nD=int(input())\nprint(min(A,B) + min(C,D))", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nprint(min(A,B) + min(C,D))", "# A, B, C, D = map(int,input().split())\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nfee = [A+C,A+D,B+C,B+D]\nfee.sort()\nprint(fee[0])", "# 092_a\n# \"\"\"\n# \u3042\u306a\u305f\u306f\u3001\u96fb\u8eca\u3068\u30d0\u30b9\u3092\u4e57\u308a\u7d99\u3044\u3067\u65c5\u884c\u3092\u3059\u308b\u8a08\u753b\u3092\u7acb\u3066\u307e\u3057\u305f\u3002\n# \u96fb\u8eca\u306f\u65c5\u7a0b\u306b\u6cbf\u3063\u3066\u901a\u5e38\u306e\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 A\u5186\u304b\u304b\u308a\u3001\n# \u4e57\u308a\u653e\u984c\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068B\u5186\u304b\u304b\u308a\u307e\u3059\u3002\n# \u30d0\u30b9\u306f\u65c5\u7a0b\u306b\u6cbf\u3063\u3066\u901a\u5e38\u306e\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 C\u5186\u304b\u304b\u308a\u3001\n# \u4e57\u308a\u653e\u984c\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 D\u5186\u304b\u304b\u308a\u307e\u3059\u3002\n#\n# \u96fb\u8eca\u304a\u3088\u3073\u30d0\u30b9\u306b\u3064\u3044\u3066\u901a\u5e38\u306e\u5207\u7b26\u3092\u8cb7\u3046\u304b\u4e57\u308a\u653e\u984c\u304d\u3063\u3077\u3092\u8cb7\u3046\u304b\u3092\u3046\u307e\u304f\u9078\u3093\u3060\u3068\u304d\u306e\u3001\u904b\u8cc3\u306e\u5408\u8a08\u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n# \"\"\"\n\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\nif (1 <= A & A <= 1000) & (1 <= B & B <= 1000) & (1 <= C & C <= 1000) & (1 <= D & D <= 1000):\n print(((min(A, B)) + (min(C, D))))\n", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\ntrain = [A,B]\nbus = [C,D]\n\nprint(min(train) + min(bus))", "#!/usr/bin/env python3\n\ndef main():\n a, b, c, d = (int(input()) for i in range(4))\n print((min(a, b) + min(c, d)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "print(min(int(input()), int(input())) + min(int(input()), int(input())))", "\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nprint((min(A+C,A+D,B+C,B+D)))\n", "A, B, C, D = [int(input()) for i in range(4)]\n\nprint(min(A,B)+min(C,D))", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\ntrain = min(a,b)\nbus = min(c,d)\n\nprint(train + bus)", "a,b,c,d=map(int,[input(),input(),input(),input()])\nprint(min(a,b)+min(c,d))", "bus_a = int(input())\nbus_b = int(input())\ntrain_a = int(input())\ntrain_b = int(input())\n\nfee_list = [bus_a + train_a, bus_a + train_b, bus_b + train_a, bus_b + train_b]\nfee_list.sort()\nprint((fee_list[0]))\n", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nprint(min([A,B]) + min([C,D]))", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\ntrain = [a, b]\nbus = [c, d]\n\nprint((min(train) + min(bus)))\n", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a+c,a+d,b+c,b+d))", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\n\nprint(min(a,b)+min(c,d))", "print(min([int(input()), int(input())]) + min([int(input()), int(input())]))", "# 092a\n\ndef atc_092a(ABCD: int) -> int:\n return min(ABCD[0], ABCD[1]) + min(ABCD[2], ABCD[3])\n\n\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nABCD = [A, B, C, D]\nprint(atc_092a(ABCD))", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a, b) + min(c, d))", "S_list = [int(input()) for i in range(4)]\na,b,c,d = S_list\nprint(min(a,b)+min(c,d))", "# \u3042\u306a\u305f\u306f\u3001\u96fb\u8eca\u3068\u30d0\u30b9\u3092\u4e57\u308a\u7d99\u3044\u3067\u65c5\u884c\u3092\u3059\u308b\u8a08\u753b\u3092\u7acb\u3066\u307e\u3057\u305f\u3002\n# \u96fb\u8eca\u306f\u65c5\u7a0b\u306b\u6cbf\u3063\u3066\u901a\u5e38\u306e\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 A \u5186\u304b\u304b\u308a\u3001\u4e57\u308a\u653e\u984c\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 B \u5186\u304b\u304b\u308a\u307e\u3059\u3002\n# \u30d0\u30b9\u306f\u65c5\u7a0b\u306b\u6cbf\u3063\u3066\u901a\u5e38\u306e\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 C \u5186\u304b\u304b\u308a\u3001\u4e57\u308a\u653e\u984c\u304d\u3063\u3077\u3092\u8cb7\u3046\u3068 D \u5186\u304b\u304b\u308a\u307e\u3059\u3002 \n# \u96fb\u8eca\u304a\u3088\u3073\u30d0\u30b9\u306b\u3064\u3044\u3066\u901a\u5e38\u306e\u5207\u7b26\u3092\u8cb7\u3046\u304b\u4e57\u308a\u653e\u984c\u304d\u3063\u3077\u3092\u8cb7\u3046\u304b\u3092\u3046\u307e\u304f\u9078\u3093\u3060\u3068\u304d\u306e\u3001\u904b\u8cc3\u306e\u5408\u8a08\u306e\u6700\u5c0f\u5024\u3092\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\nA = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\n\nx = min(A, B)\ny = min(C, D)\n\nprint(x + y)", "a,b,c,d=[int(input()) for i in range(4)]\nprint(min(a,b)+min(c,d))", "A = int(input())\nB = int(input())\nC = int(input())\nD = int(input())\nprint(min(A,B)+min(C,D))", "a = int(input())\nb = int(input())\nc = int(input())\nd = int(input())\nprint(min(a,b) + min(c,d))"]
{"inputs": ["600\n300\n220\n420\n", "555\n555\n400\n200\n", "549\n817\n715\n603\n"], "outputs": ["520\n", "755\n", "1152\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,946
90b6a6306ec37bac9749d4c18935978a
UNKNOWN
There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is A_i. Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 10^9+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0. -----Constraints----- - 1≦N≦10^5 - 0≦A_i≦N-1 -----Input----- The input is given from Standard Input in the following format: N A_1 A_2 ... A_N -----Output----- Print the number of the possible orders in which they were standing, modulo 10^9+7. -----Sample Input----- 5 2 4 4 0 2 -----Sample Output----- 4 There are four possible orders, as follows: - 2,1,4,5,3 - 2,5,4,1,3 - 3,1,4,5,2 - 3,5,4,1,2
["n = int(input())\na = [int(x) for x in input().split()]\na.sort()\nmod = 10 ** 9 + 7\n\ndef p(p):\n ans = 1\n for i in range(p):\n ans *= 2\n ans %= mod\n return ans\n\nif n % 2 == 1:\n res = True\n for i in range(n):\n if a[i] != ((i + 1) // 2) * 2:\n res = False\n if res:\n print(p(n // 2))\n else:\n print(0)\n \nelse:\n res = True\n for i in range(n):\n if a[i] != (i // 2) * 2 + 1:\n res = False\n if res:\n print(p(n // 2))\n else:\n print(0)", "N=int(input())\n*A,=sorted(map(int,input().split()))\n\ndef f(x):\n for i in range(x,N,2):\n if A[i-1]!=i or A[i]!=i:\n return 0\n return 1 \n \na=1\nif N%2==0:a=f(1)\nelse:\n if A[0]!=0:a=0\n else:a=f(2)\nprint(2**(N//2)%(10**9+7)*a)", "import math\n\nN = 5\nARR = [2, 4, 4, 0, 2]\n\nN = 7\nARR = [6, 4, 0, 2, 4, 0, 2]\n#\n# N = 8\n# ARR = [7, 5, 1, 1, 7, 3, 5, 3]\n#\nN = int(input())\nARR = list(map(int, input().split()))\n\n\ndef calculate(n, arr):\n if n % 2 == 0:\n n = n // 2\n start = 1\n finalResult = pow(2, n, 1000000000 + 7)\n else:\n n = n // 2 + 1\n start = 0\n finalResult = pow(2, (n - 1), 1000000000 + 7)\n\n result = {}\n for i in range(n):\n index = start + 2 * i\n if index == 0:\n result.__setitem__(0, 1)\n else:\n result.__setitem__(index, 2)\n\n isOk = True\n for i in range(len(arr)):\n if result.get(arr[i]) == None:\n isOk = False\n break\n\n if result.get(arr[i]) == 0:\n isOk = False\n break\n\n result.__setitem__(arr[i], result.get(arr[i])-1)\n\n if isOk == False:\n print((0))\n return\n\n if sum(result.values()) == 0:\n print(finalResult)\n else:\n print((0))\n\n\ncalculate(N, ARR)\n", "n = int(input())\na = list(map(int, input().split()))\na.sort()\nres = True\nif n % 2 != 0:\n if a[0] != 0:\n res = False\n print(0)\n a = a[1:]\nfor i in range(0, len(a), 2):\n if a[i] != a[i+1]:\n print(0)\n res = False\n break\n\np = 10**9 + 7\nif res:\n print(pow(2, n//2, p))", "n = int(input())\na = sorted(list(map(int, input().split())))\nans = 1\n\nif n%2 == 0:\n for i in range(0, n, 2):\n if a[i] != i + 1 or a[i + 1] != i + 1:\n print(0)\n return\nelse:\n if a[0] != 0:\n print(0)\n return\n for i in range(1, n, 2):\n if a[i] != i + 1 or a[i + 1] != i + 1:\n print(0)\n return\n\nfor i in range(n//2):\n ans = ans*2%(10**9 + 7)\n\nprint(ans)", "n = int(input())\na = sorted(list(map(int, input().split())))\n\nif n%2 == 0: # \u4eba\u6570\u304c\u5076\u6570\u306e\u5834\u5408\u306b\u4e0d\u6574\u5408\u304c\u3042\u308b\u304b\u78ba\u8a8d\n for i in range(0,n,2):\n if a[i] != i+1 or a[i+1] != i+1:\n print(0)\n return\nelse: # \u4eba\u6570\u304c\u5947\u6570\u306e\u5834\u5408\u306b\u4e0d\u6574\u5408\u304c\u3042\u308b\u304b\u78ba\u8a8d\n if a[0] != 0: # \u5dee\u5206\u304c0\u5b58\u5728\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\n print(0)\n return\n else:\n for i in range(1,n,2):\n if a[i] != i + 1 or a[i+1] != i + 1:\n print(0)\n return\n \nans = 1 \nfor i in range(n//2):\n ans = ans*2%(10**9+7)\nprint(ans)", "n = int(input())\na = sorted(list(map(int, input().split())))\nif n % 2 == 0:\n b,s = [1,1],3\nelse:\n b,s = [0],2\nfor i in range(s,n,2):\n b += [i,i]\nif a == b:\n print(pow(2,n//2,1000000007))\nelse:\n print(0)", "N = int(input())\nN_List = sorted(list(map(int,input().split())))\nflg = 0\nans = 1\nif N % 2 == 1:\n if N_List[0] != 0:\n flg = 1\n else:\n for i in range(2,N,2):\n if i*2 != sum(N_List[i-1:i+1]):\n flg = 1\n break\n else:\n ans = (ans * 2) % ((10**9) +7)\n \n\nelse:\n for i in range(1,N,2):\n if i*2 != sum(N_List[i-1:i+1]):\n flg = 1\n break\n else:\n ans = (ans * 2) % ((10**9) +7)\n\nif flg == 0:\n print(ans)\nelse:\n print((0))\n\n \n", "N = int(input())\nA = [int(x) for x in input().split()]\n\ncnt = {}\nif N & 1:\n bit = 1\nelse:\n bit = 0\n\nfor a in A:\n if a & bit:\n ans = 0\n break\n if a in cnt:\n cnt[a] += 1\n else:\n cnt[a] = 1\n\nfor key in list(cnt.keys()):\n if key == 0 and cnt[key] != 1:\n ans = 0\n break\n if key != 0 and cnt[key] != 2:\n ans = 0\n break\nelse:\n ans = 2**(N//2) %1000000007\nprint(ans)\n", "n=int(input())\nfrom collections import Counter as co\nc=co(map(int,input().split()))\nans=pow(2,n//2,10**9+7)\nif n%2 :\n if 0 not in c or c[0]>1:ans=0\n for i in range(1,n):\n if i%2==0 :\n if i not in c or c[i]!=2:ans=0;break\n else:\n if i in c:ans=0;break\nelse:\n if 0 in c:ans=0\n for i in range(1,n):\n if i%2:\n if i not in c or c[i]!=2:ans=0;break\n else:\n if i in c:ans=0;break\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\nl = [0] * n\nfor x in a:\n l[x] += 1\nfor i in range(n):\n if l[i] > 2:\n print(0)\n return\n if l[i] > 0 and (i + n) % 2 == 0: \n print(0)\n return\nif n % 2 == 1 and l[0] > 1:\n print(0)\n return\nprint(pow(2, n // 2, 10 ** 9 + 7))", "n = int(input())\na_list = sorted([int(x) for x in input().split()], reverse=True)\nm = n\nif m % 2 == 1:\n a_list.append(0)\n m += 1\nfor i in range(0, m, 2):\n if not (a_list[i] == a_list[i + 1] == n - (i + 1)):\n print(0)\n return\nprint(2 ** (n // 2) % (10 ** 9 + 7))", "n = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nnum_map = [0] * ((n + 2 - 1) // 2)\nfor i in range(n):\n num_map[a[i] // 2] += 1\n\nres = 2 - n % 2\nif num_map[0] != 2 - n % 2:\n print((0))\nelse:\n for i in range(1, (n + 2 - 1) // 2):\n if num_map[i] != 2:\n print((0))\n break\n else:\n res = res * 2 % mod\n else:\n print(res)\n", "mod = 10**9+7\nn = int(input())\na = list(map(int,input().split()))\nc_dic = dict()\nif n%2 == 0:\n for num in a:\n if num%2 == 0 or n < num:\n print(0)\n return\n if num in c_dic:\n c_dic[num] += 1\n if c_dic[num] > 2:\n print(0)\n return\n else:\n c_dic[num] = 1\n print(pow(2,n//2,mod))\nelse:\n for num in a:\n if num%2 == 1 or n < num:\n print(0)\n return\n if num in c_dic:\n c_dic[num] += 1\n if c_dic[num] > 2:\n print(0)\n return\n else:\n c_dic[num] = 1\n if c_dic[0] != 1:\n print(0)\n return\n print(pow(2,n//2,mod))", "import sys\nfrom collections import Counter\n\nn = int(input())\na = list(map(int, input().split()))\na.sort()\n\nl = []\n\nfor i in range(n):\n li = abs(i - (n-1-i))\n l.append(li)\n \nl.sort()\n\n\nfor ai, li in zip(l,a):\n if ai != li:\n print((0))\n return\n\nd = Counter(l)\nmod = 10 ** 9 + 7\nans = 1\n\nfor li in d:\n for j in range(1,d[li]+1):\n ans *= j\n ans %= mod\n\nprint(ans)\n", "n=int(input())\na=[int(i) for i in input().split()]\n\ndef somosomo(a):\n ans=[]\n if n%2==1:\n ans.append(0)\n for i in range(1,n//2+1):\n ans.append(i*2)\n ans.append(i*2)\n b=sorted(a)\n if b==ans:\n return True\n return False\n else:\n for i in range(1,n//2+1):\n ans.append(i*2-1)\n ans.append(i*2-1)\n b=sorted(a)\n if b==ans:\n return True\n return False\n\ndef two_ride(n):\n ans=1\n for i in range(n):\n ans*=2\n ans%=10**9+7\n return ans\n\nif somosomo(a):\n print(two_ride(n//2))\nelse:\n print(0)", "n=int(input())\na=list(map(int,input().split()))\nl=[0]*n\nfor i in range(n):\n l[a[i]]+=1\n#print(l)\nif n%2==1:\n if l[0]!=1:\n print(0)\n return\nans=1\nfor i in range(n):\n if n%2==0:\n if i%2==0:\n if l[i]!=0:\n print(0)\n return\n else:\n if i%2==1:\n if l[i]!=0:\n print(0)\n return\n \n if l[i]==2:\n ans*=2\n elif l[i]>2:\n print(0)\n return\n ans%=(10**9 +7)\nprint(ans)", "N = int(input())\ncount = [0]*(N+1)\nmodz = 10**9 + 7\n\ndef junretsu(a):\n if a <= 0: return 1\n if (a & 0x01) == 1:\n return 2*junretsu(a-1) % modz\n else:\n rr = junretsu(a>>1)\n return rr*rr % modz\n\npos = list(map(int, input().split()))\nfor i in range(N):\n count[pos[i]] += 1\n\ndiff = [0]*(N+1)\nfor i in range(1, N+1):\n d = abs((N - i) - (i-1))\n diff[d] += 1\n\ninvalid = False\ntotal = 1\nfor i in range(N):\n if count[i] != diff[i]:\n invalid = True\n break\n\nif invalid:\n print((0))\nelse:\n print((junretsu(int(N/2))))\n", "num = int(input())\nt = [int(n) for n in input().split()]\nt = sorted(t)\n\nvalid = True\n\nif num % 2 == 1: # odd\n check = list(range(0,num+1,2))[1:]\n \n valid1 = t[0] == 0\n valid2 = check == t[2::2] # even, skip first\n valid3 = check == t[1::2] # odd\n valid = valid1 and valid2 and valid3\n \n if not valid:\n print((0))\n else:\n ans = 2**((num-1)//2) % (10**9 + 7)\n print(ans)\n \nelse: # even \n check = list(range(1,num,2))\n \n valid1 = True\n valid2 = check == t[::2] # even\n valid3 = check == t[1::2] # odd\n valid = valid1 and valid2 and valid3\n \n if not valid:\n print((0))\n else:\n ans = 2**((num)//2) % (10**9 + 7)\n print(ans)\n\n\n \n", "N = int(input())\nA = list(map(int,input().split()))\n \nA.sort()\n\ncheck=[0]*N\n\nfor idx in range(N%2,N,2):\n check[idx]=idx+1\n check[idx+1]=idx+1\n\nans=0\n\nif check == A:\n if N % 2 == 0:\n ans=(2**(N//2))%(10**9+7)\n elif N % 2 != 0:\n ans=(2**((N-1)//2))%(10**9+7)\n \nprint(ans)\n", "n=int(input())\nmod=10**9+7\nA=list(map(int,input().split()))\n\nfrom collections import Counter\nC=Counter(A)\nif n%2==0:\n for i in range(1,n,2):\n if C.get(i) != 2:\n print(0);return\nelse:\n if C.get(0) !=1:\n print(0);return\n for i in range(2,n,2):\n if C.get(i)!=2:\n print(0);return\n\nn//=2\nprint(pow(2,n,mod))", "n = int(input())\na = sorted(list(map(int, input().split())))\n\nif len(a)%2==1:\n tmp = [0]\n for i in range((len(a)-1)//2):\n tmp.append((i+1)*2)\n tmp.append((i+1)*2)\n if a == tmp:\n ans = (2**((len(a)-1)//2))%(10**9+7)\n else:\n ans = 0\nelse:\n tmp = []\n for i in range(len(a)//2):\n tmp.append(2*i+1)\n tmp.append(2*i+1)\n if a == tmp:\n ans = (2**(len(a)//2))%(10**9+7)\n else:\n ans = 0\nprint(ans)", "N = int(input())\nAs = list(map(int, input().split()))\n# \u7d76\u5bfe\u5024\u306e\u5dee\u306f\u3001\n# \u5947\u6570\u306e\u5834\u5408\u306fN+1\u304b\u30892\u305a\u3064\u6e1b\u3089\u3057\u3066\u884c\u3063\u305f\u5206\u3057\u304b\u306a\u3044\u3002(N+1)/2\n# \u5076\u6570\u306e\u5834\u5408\u306fN\u304b\u30892\u305a\u3064\u6e1b\u3089\u3057\u3066\u884c\u3063\u305f\u5206\u3057\u304b\u306a\u3044\u3002N/2\nnums = {}\nexists = True\nif N % 2 == 0:\n for A in As:\n if A in nums:\n nums[A] += 1\n else:\n nums[A] = 1\n for key, value in list(nums.items()):\n if key == 0:\n exists = False\n if value != 2:\n exists = False\n\nelse:\n for A in As:\n if A in nums:\n nums[A] += 1\n else:\n nums[A] = 1\n for key, value in list(nums.items()):\n if key == 0:\n if value != 1:\n exists = False\n else:\n if value != 2:\n exists = False\nif not exists:\n print((0))\nelse:\n ans = 1\n if N % 2 == 0:\n for i in range(int(N / 2)):\n ans = ans * 2\n ans %= 10**9 + 7\n else:\n for i in range(int((N - 1) / 2)):\n ans = ans * 2\n ans %= 10**9 + 7\n # \u7d76\u5bfe\u5024\u306e\u5dee\u306f0\u306e\u6642\u306f1\u4eba\u3060\u3051\u3002\u305d\u306e\u307b\u304b\u306f2\u4eba\u3060\u3051\u3002\u3053\u308c\u304c\u6e80\u305f\u305b\u308b\u306a\u3089\n # (\u5076\u6570)2**(N+1/2)\n # (\u5947\u6570)2**(N/2)\n print(ans)\n", "from collections import Counter\n\n\ndef mod_pow(a, n, mod):\n \"\"\"\n \u4e8c\u5206\u7d2f\u4e57\u6cd5\u306b\u3088\u308b a^n (mod m)\u306e\u5b9f\u88c5\n :param a: \u7d2f\u4e57\u306e\u5e95\n :param n: \u7d2f\u4e57\u306e\u6307\u6570\n :param mod: \u6cd5\n :return: a^n (mod m)\n \"\"\"\n\n result = 1\n a_n = a\n while n > 0:\n if n & 1:\n result = result * a_n % mod\n a_n = a_n * a_n % mod\n n >>= 1\n return result\n\n\nN = int(input())\nA = Counter(tuple(map(int, input().split(' '))))\nMOD = 10 ** 9 + 7\n\nif A[0] > 1:\n print((0))\nelif sum([key for key, value in list(A.items()) if value == 1]) != 0:\n print((0))\nelse:\n print((mod_pow(2, N // 2, MOD)))\n", "N = int(input())\nA = list(map(int, input().split()))\nmod = 10 ** 9 + 7\n\nA = sorted(A)\nans = 1\nif N % 2 == 0:#[1,1,3,3,5,5,...]\n for i in range(N):\n xx = int(i / 2)\n if A[i] != 2 * xx + 1:\n ans = 0\n else:\n if i % 2 == 1:\n ans *= 2\n ans %= mod\nelse:#[0, 2, 2, 4, 4 ...]\n for i in range(N):\n xx = int((i + 1)/2)\n if A[i] != 2 * xx:\n ans = 0\n else:\n if (i % 2 == 0) and (i != 0):\n ans *= 2\n ans %= mod\n \n \n \n \nprint(ans)\n\n", "n = int(input())\na = list(map(int, input().split()))\na.sort()\nres = True\nanse = list(i for i in range(1, n, 2))\nanso = list(i for i in range(2, n, 2))\nif n % 2 != 0:\n if a[0] != 0:\n res = False\n print(0)\n a = a[1:]\n for i in range(0, len(a), 2):\n if a[i] != anso[i//2] or a[i+1] != anso[i//2]:\n print(0)\n res = False\n break\n\n\nif n % 2 == 0:\n for i in range(0, len(a), 2):\n if a[i] != anse[i//2] or a[i+1] != anse[i//2]:\n print(0)\n res = False\n break\n\np = 10**9 + 7\nif res:\n print(pow(2, n//2, p))", "n=int(input())\nl=list(map(int,input().split()))\nmod=10**9+7\nif n%2==0:\n d={i:2 for i in range(1,n,2)}\nelse:\n d={i:2 for i in range(0,n,2)}\n d[0]=1\nfor a in l:\n if a in d:\n d[a]-=1\n else:\n print((0))\n return\nfor i in list(d.values()):\n if i!=0:\n print((0))\n return\nprint(((2**(n//2))%mod))\n", "from collections import Counter\n\nn = int(input())\nA = list(map(int, input().split()))\ncnt_A = Counter(A)\n\nif not all([v == 2 for k, v in cnt_A.items() if k != 0]):\n print(0)\nelse:\n print(pow(2, n // 2, 10**9 + 7))", "N = int(input())\nA = list(map(int, input().split()))\n\nans = 0\nA_test = sorted(list(set(A)))\n\nif N % 2 == 1:\n judge = [i for i in range(0,N,2)]\n if (A_test == judge) and (A.count(0) == 1):\n ans = 2**(N//2)\nelse:\n judge = [i for i in range(1,N,2)]\n if A_test == judge:\n ans = 2**(N//2)\n\nans = ans % (10**9 + 7)\nprint(ans)\n", "import sys\nfrom collections import Counter\nN = int(input())\nA = list(map(int, input().split()))\nMOD = 10 ** 9 + 7\n\nC = Counter(A)\nC = sorted(C.items(), key=lambda x: x[0])\nif N % 2 == 0:\n s = 1\n for k, v in C:\n if k != s or v != 2:\n print(0)\n return\n s += 2\n print(pow(2, (N // 2), MOD))\nelse:\n s = 0\n for k, v in C:\n if k == 0:\n if k != 0 or v != 1:\n print(0)\n return\n s += 2\n continue\n if k != s or v != 2:\n print(0)\n return\n s += 2\n print(pow(2, (N - 1) // 2, MOD))", "from collections import Counter\nn=int(input())\na=sorted(list(map(int,input().split())))\na_count=Counter(a)\nif n%2==1:\n ans=1\n for i in a_count:\n if i%2!=0:\n print(0)\n break\n else:\n if i==0:\n if a_count[i]!=1:\n print(0)\n break\n \n else:\n if a_count[i]==2:\n ans=(ans*2)%(10**9+7)\n else:\n print(0)\n break\n else:\n print(ans)\nelse:\n ans=1\n for j in a_count:\n if j%2!=1:\n print(0)\n break\n else:\n if a_count[j]==2:\n ans=(ans*2)%(10**9+7)\n \n else:\n print(0)\n break\n else:\n print(ans)", "n = int(input())\na = list(map(int, input().split()))\nflg = 0\n\na.sort()\nif n % 2 == 0:\n if a[0] == 1 and a[1] == 1:\n for i in range(2, n, 2):\n if a[i] == a[i + 1] and a[i - 1] + 2 == a[i]:\n continue\n else:\n flg = 1\n break\n else:\n flg = 1\nelse:\n if a[0] == 0:\n for i in range(1, n, 2):\n if a[i] == a[i + 1] and a[i - 1] + 2 == a[i]:\n continue\n else:\n flg = 1\n break\n else:\n flg = 1\n\nif flg == 1:\n print(0)\nelse:\n print((2 ** (n // 2)) % (10 ** 9 + 7))", "n=int(input())\nl=list(map(int,input().split()))\nmod=10**9+7\nif n%2==0:\n d={i:2 for i in range(1,n,2)}\nelse:\n d={i:2 for i in range(0,n,2)}\n d[0]=1\nfor a in l:\n if a in d:\n d[a]-=1\n else:\n print(0)\n return\nfor i in d.values():\n if i!=0:\n print(0)\n return\nprint((2**(n//2))%mod)", "def main():\n N = int(input())\n A = [int(a) for a in input().split(\" \")]\n A.sort()\n \n if N % 2 == 1 and A.count(0) != 1:\n print(0)\n return 0\n elif N % 2 == 0 and A.count(0) > 0:\n print(0)\n return 0\n \n if N % 2 == 1:\n A.pop(0)\n \n cnt = 0\n while len(A) > 0:\n if A[0] != A[1] or (len(A) > 2 and A[0] == A[1] and A[1] == A[2]):\n print(0)\n return 0\n elif A[0] == A[1] == 2 * cnt + (N % 2) + 1:\n cnt += 1\n A.pop(0)\n A.pop(0)\n else:\n print(0)\n return 0\n \n ans = 1\n for p in range(cnt):\n ans = (ans * 2) % 1000000007\n print(ans)\n\nmain()", "n = int(input())\na = sorted(list(map(int, input().split())))\n\nif n == 1:\n print(1)\n return\nelif n%2 == 0:\n for i in range(0,n-2,2):\n if a[i] != a[i+1] or a[i] == a[i+2]:\n print(0)\n return\n if a[-2] != a[-1]:\n print(0)\n return\nelse:\n if a[0] != 0 or a[1] == 0:\n print(0)\n return\n for i in range(1,n-2,2):\n if a[i] != a[i+1] or a[i] == a[i+2]:\n print(0)\n return\n if a[-2] != a[-1]:\n print(0)\n return\n\nmod = 10**9+7\nif n%2 == 0: print(2**(n//2)%mod)\nelse: print(2**((n-1)//2)%mod)", "N = int(input())\nA = list(map(int, input().split()))\nmod = pow(10,9)+7\nA.sort()\n\nif N%2 == 0:\n for i in range(N//2):\n if A[2*i] != A[2*i+1] or A[2*i] != 2*i+1:\n print((0))\n return\n ans = pow(2,N//2)\n print((ans%mod))\nelse:\n if A[0] != 0:\n print((0))\n return\n for i in range(N//2):\n if A[2*i+1] != A[2*(i+1)] or A[2*i+1] != 2*(i+1):\n print((0))\n return\n ans = pow(2,N//2)\n print((ans%mod))\n", "N=int(input())\n*A,=sorted(map(int,input().split()))\n \na=True\nif N%2==0:\n for i in range(1,N,2):\n if A[i-1]!=i or A[i]!=i:\n a=False\n break\nelse:\n if A[0]!=0:a=False\n else:\n for i in range(2,N,2):\n if A[i-1]!=i or A[i]!=i:\n a=False\n break\nprint(2**(N//2)%(10**9+7) if a else 0)", "from collections import Counter\n\nN = int(input())\nA = list(map(int, input().split()))\nMOD = int(1e9) + 7\n\n# \u5076\u6570\u306e\u5834\u5408\nif N % 2 == 0:\n c = Counter(A)\n if all(i == 2 for i in c.values()):\n print(pow(2, N//2, MOD))\n else:\n print(0)\n# \u5947\u6570\u306e\u5834\u5408\nelse:\n A.sort()\n A = A[1:]\n c = Counter(A)\n if all(i == 2 for i in c.values()):\n print(pow(2, N//2, MOD))\n else:\n print(0)", "N = int(input())\na = list(map(int, input().split()))\nSum = 1\nmod = 1000000007\n\na.sort()\ndata = []\nif N % 2 == 0:\n for i in range(int(N / 2)):\n data.append(1 + i * 2)\n data.append(1 + i * 2)\nelse:\n data.append(0)\n for i in range(1, N // 2 + 1):\n data.append(i * 2)\n data.append(i * 2)\n\nif a == data:\n for i in range(N // 2):\n Sum *= 2\n Sum %= mod\n print(Sum)\nelse:\n print((0))\n", "N=int(input())\nA=list(map(int,input().split()))\n\nA.sort()\ncheck=[0]*N\n\nfor idx in range(N%2,N,2):\n check[idx]=idx+1\n check[idx+1]=idx+1\n\nans=0\nmod=10**9+7\nif check==A:\n if N%2==0:\n ans=(2**(N//2))%mod\n else:\n ans=(2**((N-1)//2))%mod\nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\n\nfrom collections import Counter\nc = Counter(a)\n\ncheck_ary = []\nif n&1:\n check_ary.append(0)\n\nfor i in range(n//2):\n for _ in range(2):\n check_ary.append((i+1)*2 if n&1 else i*2+1)\n\nc2 = Counter(check_ary)\n\nif c != c2:\n print(0)\n return\n\nprint(pow(2, n//2, 10**9+7))", "import sys\nimport heapq, math\nfrom itertools import zip_longest, permutations, combinations, combinations_with_replacement\nfrom itertools import accumulate, dropwhile, takewhile, groupby\nfrom functools import lru_cache\nfrom copy import deepcopy\n\nN = int(input())\nA = list(map(int, input().split()))\n\nB = [0] * N\n\nfor a in A:\n B[a] += 1\n\nok = True\n\nif N % 2 == 1:\n ok = ok and B[0] == 1\n for i in range(1, N):\n ok = ok and B[i] == (2 if i % 2 == 0 else 0)\nelse:\n for i in range(N):\n ok = ok and B[i] == (0 if i % 2 == 0 else 2)\n\nans = 1\nMOD = int(1e9) + 7\nfor _ in range(N // 2):\n ans *= 2\n ans %= MOD\n\nprint((ans if ok else 0))\n", "n=int(input())\nA=list(map(int,input().split()))\nA.sort()\njudge=0\nif n%2==1:\n for i in range(n):\n if A[i]!=2*((i+1)//2):\n judge+=1\n break\nelse:\n for i in range(n):\n if A[i]!=2*(i//2)+1:\n judge+=1\n break\nif judge==1:\n print(0)\nelse:\n print((2**(n//2))%(10**9+7))", "from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nd = list(c.values())\nif (n % 2 == 1 and c[0] == 1 and d.count(2) == (n-1)//2) or (n % 2 == 0 and d.count(2) == n//2):\n print(pow(2, n//2, 10**9+7))\nelse:\n print(0)", "from collections import Counter\nn = int(input())\na = list(map(int, input().split()))\nc = Counter(a)\nd = list(c.values())\nif (n % 2 == 1 and c[0] == 1 and d.count(2) == (n-1)//2) or (n % 2 == 0 and d.count(2) == n//2):\n print((2**(n//2)) % (10**9+7))\nelse:\n print(0)", "N = int(input())\nK = [0 for i in range(N+1)]\nA = list(map(int,input().rstrip().split(\" \")))\nans = 1\nfor i in A:\n K[i] += 1\nfor i in range(N):\n if i != 0 and K[i] != 0 and K[i] != 2:\n ans = 0\n break\n if K[i] == 2:\n ans *= 2\n ans %= 10 ** 9 + 7\nprint(ans)", "import collections\n\nn = int(input())\na = list(map(int, input().split()))\ncnt = collections.Counter(a)\nmod = 7 + 10**9\nif n % 2 == 0:\n for i in range(1, 1 + n // 2):\n if (i * 2 - 1) not in cnt.keys() or cnt[i * 2 - 1] != 2:\n print(0)\n return\n\nelse:\n if 0 not in cnt.keys() or cnt[0] != 1:\n print(0)\n return\n for i in range(1, 1 + n // 2):\n if i * 2 not in cnt.keys() or cnt[i * 2] != 2:\n print(0)\n return\nprint(2 ** (n // 2) % mod)", "n = int(input())\na = list(map(int, input().split()))\n\n\na = sorted(a)\n\nnum = 0\njudge = 0\n\nif len(a)%2 == 1:\n if a[0] == 0:\n for i in range(1, n, 2):\n if a[i] == i+1 and a[i+1] == i+1:\n num += 1\n else:\n print(0)\n judge = 1\n break\n else:\n print(0)\n judge=1\nelse:\n for i in range(0, n, 2):\n if a[i] == i+1 and a[i+1] == i+1:\n num += 1\n else:\n print(0)\n judge = 1\n break\n \nif judge == 0:\n result = (2**num)%(10**9+7)\n print(result)", "from collections import defaultdict\nN = int(input())\nA = list(map(int, input().split()))\n\nL = A[:]\nL = list(set(L))\n\nmod = 10 ** 9 + 7\n\nd = defaultdict(int)\nfor i in range(N):\n d[A[i]] += 1\n\nif N % 2 == 1:\n bfr = 0\n for i in L:\n if i - bfr != 2 and i != 0:\n print((0))\n return\n\n if i == 0:\n if d[i] != 1:\n print((0))\n return\n else:\n continue\n if d[i] != 2:\n print((0))\n return\n bfr = i\n\n print(((2 ** (N // 2)) % mod))\nelse:\n bfr = 1\n for i in L:\n if i - bfr != 2 and i != 1:\n print((0))\n return\n\n if d[i] != 2:\n print((0))\n return\n bfr = i\n\n print(((2 ** (N // 2)) % mod))\n", "n = int(input())\na = list(map(int,input().split()))\nmod = 10**9+7\n\na.sort()\n\nif n%2 == 1: \n if a[0] != 0:\n print((0))\n return\n else:\n a.remove(0)\n tmp = 2\nelse:\n tmp = 1\n\nfor i in range(n//2):\n if tmp == a[0] and tmp == a[1]:\n a.remove(tmp)\n a.remove(tmp)\n else:\n print((0))\n return\n tmp += 2\n\nif len(a) == 0:\n print(((2**(n//2))%mod))\nelse:\n print((0))\n\n\n", "n = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nnum_map = [0] * ((n + 2 - 1) // 2)\nfor i in range(n):\n num_map[a[i] // 2] += 1\n\nres = 1\nif n % 2 == 1:\n if num_map[0] != 1:\n print((0))\n else:\n for i in range(1, (n + 2 - 1) // 2):\n if num_map[i] != 2:\n print((0))\n break\n else:\n res = res * 2 % mod\n else:\n print(res)\nelse:\n for i in range((n + 2 - 1) // 2):\n if num_map[i] != 2:\n print((0))\n break\n else:\n res = res * 2 % mod\n else:\n print(res)\n", "N=int(input())\nA=list(map(int,input().split()))\nmod = 10**9+7\n\nA=tuple(sorted(A))\n\nif N % 2 == 1:\n nums=[0]\n for i in range(2,N+1,2):\n nums.append(i)\n nums.append(i)\nelse:\n nums=[]\n for i in range(1,N+1,2):\n nums.append(i)\n nums.append(i)\n \nnums = tuple(nums)\nif A != nums:\n print(0)\n return\n \nprint(2**(N//2) % mod)", "N = int(input())\nA = list(map(int,input().split()))\nA.sort()\nmod = 10**9 + 7\nif N%2 == 0:\n for i in range(N):\n if A[i] != 1+(i//2)*2:\n print(0)\n break\n else:\n print(pow(2,N//2,mod))\nelse:\n if A[0] == 0:\n for i in range(1,N):\n if A[i] != ((i+1)//2)*2:\n print(0)\n break\n else:\n print(pow(2,N//2,mod))", "n = int(input())\na = list(map(int,input().split()))\nmod = 10**9 + 7\n\nd = [0]*(n+1)\nfor x in a:\n d[x] += 1\nans = 1\nif n%2 == 0:\n sw = 1\n for i,x in enumerate(d):\n if i%2 != 0:\n if x == 2:\n ans *= 2\n ans %= mod\n else:\n sw = 0\n break\n else:\n if x != 0:\n sw = 0\n break\nelse:\n sw = 1\n for i,x in enumerate(d):\n if i%2 == 0:\n if i == 0:\n if x != 1:\n sw = 0\n break\n else:\n if x == 2:\n ans *= 2\n ans %= mod\n else:\n sw = 0\n break\n else:\n if x != 0:\n sw = 0\n break\nif sw == 0:\n ans = 0\nprint(ans)\n", "N = int(input())\nA = sorted(list(map(int,input().split())))\n\nif N%2==0:\n B = [1+2*(n//2) for n in range(N)]\nelse:\n B = [2*(n//2) for n in range(1,1+N)]\n\nif A==B:\n print(pow(2,N//2,10**9+7))\nelse:\n print(0)", "import bisect, collections, copy, heapq, itertools, math, string, sys\ninput = lambda: sys.stdin.readline().rstrip() \nsys.setrecursionlimit(10**7)\nINF = float('inf')\nMOD = 10 ** 9 + 7\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 A = LI()\n\n if N % 2 == 0:\n if sorted(A) == [i // 2 * 2 + 1 for i in range(N)]:\n print((pow(2, N // 2, MOD)))\n else:\n print((0))\n else:\n if sorted(A) == [(i // 2 + 1) * 2 for i in range(-1, N - 1)]:\n print((pow(2, (N - 1) // 2, MOD)))\n else:\n print((0))\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "def PowerMod(N,P,Mod):\n if N%Mod==0:\n return 0\n else:\n PowM = 1\n for TP in range(1,P+1):\n PowM = (PowM*N)%Mod\n return PowM\n\nfrom collections import Counter\nN = int(input())\nA = sorted(Counter([int(T) for T in input().split()]).most_common(),key=lambda X:X[0])\nPassFlag = True\nif N%2==1:\n for TA in range(0,(N+1)//2):\n if A[TA][0]!=(2*TA) or A[TA][1]!=(1+(A[TA][0]!=0)):\n PassFlag = False\n break\n print([0,PowerMod(2,(N-1)//2,10**9+7)][PassFlag])\nelse:\n for TA in range(0,N//2):\n if A[TA][0]!=(2*TA+1) or A[TA][1]!=2:\n PassFlag = False\n break\n print([0,PowerMod(2,N//2,10**9+7)][PassFlag])", "from collections import Counter\n\nn = int(input())\nc = Counter(list(map(int, input().split())))\n\nans = 0\nfor k, v in list(c.items()):\n if k == 0:\n if n%2==0 and v > 2:\n print((0))\n return\n elif n%2==1 and v > 1:\n print((0))\n return\n else:\n ans += 1\n if v > 2:\n print((0))\n return\n\nprint((pow(2, ans, 10**9+7)))\n", "from typing import Counter\n\n\nn = int(input())\nlis = list(map(int, input().split()))\nmod =10**9+7\n\nans = 0\nif n % 2 == 0:\n b = Counter(lis)\n flag = 1\n for i in list(b.values()):\n if i == 2:\n pass\n else:\n flag = 0\n break\n if flag:\n ans = 2**(n//2)\n print((ans % mod))\n else:\n print((0))\nelse:\n lis = sorted(lis)\n lis = lis[1:]\n b = Counter(lis)\n flag = 1\n for i in list(b.values()):\n if i == 2:\n pass\n else:\n flag = 0\n break\n if flag:\n ans = 2**(n//2)\n print((ans % mod))\n else:\n print((0))\n", "n=int(input())\na=list(map(int,input().split()))\nflag=0\nA=a.sort()\nnum=[]\n\nif n%2==0:\n for i in range(1,n,2):\n num.append(i)\n num.append(i)\n\nif n%2==1:\n num=[0]\n for i in range(2,n,2):\n num.append(i)\n num.append(i)\n\nif num==a:\n print(2**(n//2)%(10**9+7))\n\nelse:\n print(\"0\")", "N=int(input())\n*A,=sorted(map(int,input().split()))\n\nf=lambda:2**(N//2)%(10**9+7)\na=True\nif N%2==0:\n for i in range(1,N,2):\n if A[i-1]!=i or A[i]!=i:\n # print(i,A[i-1],A[i])\n a=False\n break\nelse:\n if A[0]!=0:\n a=False\n else:\n for i in range(2,N,2):\n if A[i-1]!=i or A[i]!=i:\n # print(i,A[i-1],A[i])\n a=False\n break\nprint(f() if a else 0)", "n = int(input())\nA = list(map(int, input().split()))\n\nd = {}\nfor a in A:\n d[a] = d.get(a, 0)+1\n\nzero_cnt = 0\ntwo = 0\nno = 0\nfor i in d:\n if i==0:\n zero_cnt+=1\n elif d[i]==2:\n two+=1\n else:\n no+=1\n\nif no!=0 or (n%2==0 and zero_cnt!=0) or (n%2==1 and zero_cnt!=1):\n print((0))\nelse:\n ans = 1\n mod = 10**9+7\n for i in range(two):\n ans *= 2\n ans %= mod\n print((ans%mod))\n", "MOD = 10 ** 9 + 7\nnum = [0] * (10 ** 5 + 1)\nN = int(input())\nA = list(map(int,input().split()))\nfor i in range(len(A)):\n\tnum[A[i]] += 1\nif N % 2 == 1:\n\tfor i in range(0,N,2):\n\t\tcnt = num[i]\n\t\tif i == 0:\n\t\t\tif cnt != 1:\n\t\t\t\tprint(0)\n\t\t\t\treturn\n\t\telse:\n\t\t\tif cnt != 2:\n\t\t\t\tprint(0)\n\t\t\t\treturn\n\tprint(2 ** (N // 2) % MOD)\nelse:\n\tfor i in range(1,N,2):\n\t\tcnt = num[i]\n\t\tif cnt != 2:\n\t\t\tprint(0)\n\t\t\treturn\n\tprint(2 ** (N // 2) % MOD)", "N=int(input())\n*A,=sorted(map(int,input().split()))\n\ndef f(x):\n for i in range(x,N,2):\n if A[i-1]!=i or A[i]!=i:\n return False\n return True \n \na=True\nif N%2==0:a=f(1)\nelse:\n if A[0]!=0:a=False\n else:a=f(2)\nprint(2**(N//2)%(10**9+7) if a else 0)", "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, *A = list(map(int, read().split()))\n\n A.sort()\n\n ok = True\n if len(A) % 2 == 0:\n for i in range(N // 2):\n if not A[2 * i] == A[2 * i + 1] == 2 * i + 1:\n ok = False\n break\n else:\n if A[0] != 0:\n ok = False\n else:\n for i in range(N // 2):\n if not A[2 * i + 1] == A[2 * i + 2] == 2 * i + 2:\n ok = False\n break\n\n if ok:\n ans = pow(2, N // 2, MOD)\n else:\n ans = 0\n\n print(ans)\n\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nA = list(map(int, input().split()))\n\nm = 1000000007\n\nA.sort()\nif N % 2 == 0:\n B = list(range(1, N, 2)) * 2\nelse:\n B = [0] + list(range(2, N, 2)) * 2\nB.sort()\n\nif A != B:\n print((0))\nelse:\n result = 1\n for i in range(N // 2):\n result *= 2\n result %= m\n print(result)\n", "N = int(input())\nA = [int(x) for x in input().split()]\n\nfrom collections import defaultdict as dd\nDict = dd(lambda:0)\nfor a in A:\n Dict[a] += 1\n\nif N & 1: Dict[0] += 1\nf = (lambda:(lambda x:0 if x&1 else 2) if N&1 else (lambda x:2 if x&1 else 0))()\nPossible = {i:f(i) for i in range(N)}\nfor key,value in list(Dict.items()):\n if value != Possible[key]:\n print((0))\n return\nelse:\n print((2**(N//2)%1000000007))\n \n\n", "import sys\n\n# n = 10 ** 5\n# \u30c7\u30fc\u30bf\u8aad\u307f\u8fbc\u307f\u95a2\u4fc2\nn = int(input())\n\na = list(map(int, input().split(' ')))\n\nrecord = {}\n\npossible = True\n\n# \u72b6\u6cc1\u304c\u5b9f\u73fe\u53ef\u80fd\u304b\u78ba\u8a8d\nfor e in a:\n if(e in record.keys()):\n record[e] += 1\n if(record[e] == 2):\n if(e == 0):\n possible = False\n break\n if(record[e] == 3):\n possible = False\n break\n else:\n record[e] = 1\n\nif(possible == False):\n print(0)\n return\n\nmultiCount = int(n / 2)\n\nprint(2 ** multiCount % (10 ** 9 + 7))", "import collections\nN = int(input())\nA = list(map(int,input().split()))\nans = 1\nif 0 in A:\n A.remove(0)\nAcounter = collections.Counter(A)\nfor i in Acounter.values():\n if i == 2:\n continue\n else:\n ans = 0\n break\nif ans == 0:\n pass\nif ans != 0:\n for i in range(N//2):\n ans = (ans * 2) % (10**9 + 7)\nprint(ans)", "import sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\ndef NIJIGEN(H): return [list(input()) for i in range(H)]\nmod=1000000007\nN=INT()\nL=LIST()\nif N%2==0:\n A=range(1,N,2)\n B=range(1,N,2)\nelse:\n A=range(0,N,2)\n B=range(2,N,2)\nA,B=list(A),list(B)\nA=A+B\nif sorted(A)==sorted(L):\n print(pow(2,N//2,mod))\nelse:\n print(0)", "n=int(input())\na=list(map(int,input().split()))\n\nb=[0 for i in range(10**5+1)]\nfor i in a:\n b[i]+=1\n\nif (n%2==0 and b[0]!=0) or (n%2==1 and b[0]!=1):\n print(0)\n return\n\nans=1\nmod=10**9+7\nfor i in b:\n if i==2:\n ans*=2\n ans%=mod\n if i>=3:\n print(0)\n return\n\nprint(ans)", "from collections import Counter\n\nn=int(input())\na=list(map(int,input().split()))\n\nc=Counter(a)\n\nif (n%2==0 and c[0]!=0) or (n%2==1 and c[0]!=1):\n print(0)\n return\n\nans=1\nmod=10**9+7\nfor i in c:\n if c[i]==2:\n ans*=2\n ans%=mod\n if c[i]>=3:\n print(0)\n return\n\nprint(ans)", "from collections import Counter\n\nN = int(input())\nabs_diffs = list(map(int, input().split()))\n\nif N % 2 == 0:\n expected = [i // 2 * 2 + 1 for i in range(N)]\n dims = N // 2\nelse:\n expected = [(i + 1) // 2 * 2 for i in range(N)]\n dims = (N - 1) // 2\n\nif sorted(abs_diffs) == expected:\n print((2 ** dims % (10 ** 9 + 7)))\n\nelse:\n print((0))\n", "n = int(input())\nA = sorted(map(int,input().split()))\n\nif n % 2 == 1:\n ex = [0]\n \n for i in range(n//2):\n a = 2 * (i+1)\n ex += [a,a]\n \nelse:\n ex = []\n a = 1\n \n for i in range(n//2):\n ex += [a,a]\n a += 2\n \nans = 0\n\nif A == ex:\n ans = 2 ** (n//2) % (10**9 + 7)\n \nprint(ans)", "n = int(input())\na = list(map(int, input().split()))\nmod = 10 ** 9 + 7\nif n % 2 == 0:\n b = [2 if i % 2 == 1 else 0 for i in range(n)]\nelse:\n b = [2 if i % 2 == 0 else 0 for i in range(n)]\n b[0] = 1\nc = [0 for i in range(n)]\nfor i in range(n):\n c[a[i]] += 1\nif b != c:\n print(0)\nelse:\n ans = 1\n for i in range(n // 2):\n ans *= 2\n ans %= mod\n print(ans)", "N = int(input())\nA = sorted(list(map(int,input().split())))\n\nif N%2==0:\n B = [2*(n//2)+1 for n in range(N)]\nelse:\n B = [2*(n//2) for n in range(1,N+1)]\n\nif A==B:\n print(pow(2,N//2,10**9+7))\nelse:\n print(0)", "MOD = 10**9+7\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 = int(input())\na = list(map(int, input().split()))\n\nd = {}\nfor i in a:\n if n % 2:\n if i > 0 and i % 2:\n print((0))\n return\n else:\n if i > 0 and i % 2 == 0:\n print((0))\n return\n\n if not i in d:\n d[i] = 1\n elif d[i] == 1:\n d[i] += 1\n else:\n print((0))\n return\n\nif n % 2:\n if d[0] != 1:\n print((0))\n return\n print((fast_pow(2, len(d)-1, MOD)))\nelse:\n if 0 in d:\n print((0))\n return\n print((fast_pow(2, len(d), MOD)))\n", "import math\nN = int(input())\nA = list(map(int, input().split()))\n\nflag = True\nif N%2 == 0:\n if 0 in A or len(set(A)) != N//2:\n flag = False\nelse:\n if len([0 for a in A if a == 0]) != 1 or len(set(A)) != N//2 + 1:\n flag = False\n\nif flag:\n print((2**((N//2))%(10**9+7)))\nelse:\n print((0))\n", "N=int(input())\n*A,=sorted(map(int,input().split()))\n\ndef f(x):\n for i in range(x,N,2):\n if A[i-1]!=i or A[i]!=i:\n return 0\n return 1 \n \na=1\nif N%2==0:a=f(1)\nelse: a=A[0]==0 and f(2)\nprint(2**(N//2)%(10**9+7)*a)", "n = int(input())\nA = tuple(map(int, input().split()))\nmod = 10**9+7\n\nniseven = (n%2 == 0)\n\ncd = dict()\nfor a in (A):\n cd.setdefault(a, 0)\n cd[a] += 1\n if a == 0 and cd[a] > 1:\n print((0))\n break\n if a > 0 and cd[a] > 2:\n print((0))\n break\n if (a%2==0) == niseven:\n print((0))\n break\nelse:\n print((pow(2, n//2, mod)))\n", "def main():\n N=int(input())\n A=list(map(int,input().split()))\n mod=10**9+7\n ans=1\n A.sort()\n if N%2==0:\n for i in range(0,N,2):\n if A[i]!=A[i+1] or A[i]!=i+1:\n print(0)\n return\n ans=ans*2%mod\n print(ans)\n else:\n if A[0]!=0:\n print(0)\n return\n ans=1\n for i in range(1,N,2):\n if A[i]!=A[i+1] or A[i]!=i+1:\n print(0)\n return\n ans=ans*2%mod\n print(ans)\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\na = list(map(int, input().split()))\n\n# \u77db\u76fe\u30c1\u30a7\u30c3\u30af\nfrom collections import Counter\nc = Counter(a)\n\ndef check():\n if n&1:\n if c[0]!=1:\n return False\n for i in range((n-1)//2):\n if c[2*(i+1)] != 2:\n return False\n else:\n for i in range(n//2):\n if c[2*i+1] != 2:\n return False\n return True\n\nif not check():\n print(0)\n return\n\nprint(pow(2, n//2, 10**9+7))", "n = int(input())\na = list(map(int,input().split()))\ndic = {}\nfor i in range(n):\n dic.setdefault(a[i],0)\n dic[a[i]] += 1\nans = 1\nfor key,value in dic.items():\n #\u5076\u6570\n if n%2==0:\n if n > key and key%2==1 and value==2:\n ans *= 2\n else:\n ans = 0\n break\n #\u5947\u6570\n else:\n if n > key and key%2==0:\n if key==0 and value==1:\n ans *= 1\n elif value==2:\n ans *= 2\n else:\n ans = 0\n break\n else:\n ans = 0\n break\nprint(ans%(10**9+7))", "N=int(input())\nMOD=10**9+7\nA=[int(x) for x in input().split()]\nflag=1#\u305d\u306e\u4e26\u3073\u9806\u304c\u3042\u308a\u3048\u308b\u306a\u30891\u3001\u305d\u3046\u3067\u306a\u3044\u306a\u30890\nset1=set()\nset2=set()\nif N%2==1:\n set1.add(0)\n for j in range(2,N+1,2):\n set1.add(j)\n set2.add(j)\n for i in range(N):\n now=A[i]\n if now in set1:\n set1.remove(now)\n elif now in set2:\n set2.remove(now)\n else:\n flag=0\n break\n if len(set1)!=0 or len(set2)!=0:\n flag=0\nelse:\n for k in range(1,N+1,2):\n set1.add(k)\n set2.add(k)\n for p in range(N):\n now=A[p]\n if now in set1:\n set1.remove(now)\n elif now in set2:\n set2.remove(now)\n else:\n flag=0\n break\n if len(set1)!=0 or len(set2)!=0:\n flag=0\nif flag==0:\n print((0))\nelse:\n ans=1\n div2=N//2\n for q in range(div2):\n ans*=2\n ans%=MOD\n print(ans)\n", "N = int(input())\nA = list(map(int, input().split()))\n\nm = 1000000007\n\nA.sort()\nif N % 2 == 0:\n B = list(range(1, N, 2)) * 2\nelse:\n B = [0] + list(range(2, N, 2)) * 2\nB.sort()\n\nif A != B:\n print((0))\nelse:\n result = 1\n for i in range(N // 2):\n result *= 2\n result %= m\n print(result)\n", "from collections import Counter\n\nN,*A = map(int, open(0).read().split())\nac = Counter(A)\nif N % 2 == 0:\n for i in range(1,N,2):\n if ac[i] != 2:\n print(0)\n break\n else:\n print(pow(2,N//2,1000000007))\nelse:\n if ac[0] != 1:\n print(0)\n else:\n for i in range(2,N,2):\n if ac[i] != 2:\n print(0)\n break\n else:\n print(pow(2,N//2,1000000007))", "n=int(input())\na=list(map(int,input().split()))\nif n%2==1:\n x=[i for i in range(n)]\n for i in range(n):\n if i%2==1:\n x[i]+=1\nelse:\n x=[i for i in range(n)]\n for i in range(n):\n if i%2==0:\n x[i]+=1\na.sort()\nif x==a:\n print(pow(2,(n//2),10**9+7))\nelse:\n print(0)", "import sys\nfrom collections import deque\np=10**9+7\n\ndef main(n,a):\n h=n//2\n g=n%2\n a.sort()\n c=[2*(x//2)+g+1 for x in range(n-g)]\n if g==1:\n c.insert(0,0)\n if a!=c:\n return 0\n return 2**(h%(p-1)) % p\n\ndef __starting_point():\n n=int(input())\n a=list(map(int,sys.stdin.readline().strip().split()))\n print((main(n,a)))\n\n__starting_point()", "N=int(input())\nS=list(map(int,input().split()))\nlenS=len(S)\nT=[]\nfor i in range(1,N+1):\n T.append(abs(i-(N+1-i)))\n\nT.sort()\nS.sort()\n\n\n\nfor i in range(N):\n if T[i]!=S[i]:\n print((0))\n return\n\n\nans=1\nnagasa=lenS//2\nfor i in range(nagasa):\n \n ans=(ans*2)%(10**9+7)\n\nprint(ans)\n\n\n", "n = int(input())\na = sorted(list(map(int, input().split())))\n\nif n%2 == 0: # \u4eba\u6570\u304c\u5076\u6570\u306e\u5834\u5408\u306b\u4e0d\u6574\u5408\u304c\u3042\u308b\u304b\u78ba\u8a8d\n for i in range(0,n,2):\n if a[i] != i+1 or a[i] != a[i+1]:\n print(0)\n return\nelse: # \u4eba\u6570\u304c\u5947\u6570\u306e\u5834\u5408\u306b\u4e0d\u6574\u5408\u304c\u3042\u308b\u304b\u78ba\u8a8d\n if a[0] != 0: # \u5dee\u5206\u304c0\u5b58\u5728\u3057\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\n print(0)\n return\n else:\n for i in range(1,n,2):\n if a[i] != i+1 or a[i] != a[i+1]:\n print(0)\n return\n\nans = 1\nfor i in range(n//2):\n ans = ans * 2 % (10**9+7) # \u7d44\u307f\u5408\u308f\u305b\u3068\u3057\u3066\u306f\u540c\u3058\u5dee\u5206\u306e\u5024\u3092\u5165\u308c\u66ff\u3048\u308b2\u629e\u306b\u306a\u308b\u306e\u3067\u3001\u7d50\u679c\u30922\u500d\u306b\u3059\u308b\nprint(ans)", "N=int(input())\n*A,=sorted(map(int,input().split()))\n\na=True\nif N%2==0:\n for i in range(1,N,2):\n if A[i-1]!=i or A[i]!=i:\n a=False\n break\nelse:\n if A[0]!=0:a=False\n else:\n for i in range(2,N,2):\n if A[i-1]!=i or A[i]!=i:\n a=False\n break\nprint(2**(N//2)%(10**9+7) if a else 0)", "import math\nN = int(input())\nA = list(map(int, input().split()))\n\nflag = True\nif N%2 == 0:\n if 0 in A or len(set(A)) != N//2:\n flag = False\nelse:\n if len([0 for a in A if a == 0]) != 1 or len(set(A)) != N//2 + 1:\n flag = False\n\nif flag:\n print((2**(math.floor(N/2))%(10**9+7)))\nelse:\n print((0))\n", "from collections import Counter\n\nn = int(input())\nA = list(map(int, input().split()))\ncnt_A = Counter(A)\n\nif all([v == 2 for k, v in cnt_A.items() if k != 0]):\n print(pow(2, n // 2, 10**9 + 7))\nelse:\n print(0)", "N=int(input())\nMOD=1000000007\nA=list(map(int,input().split()))\ncnt=[0 for i in range(N)]\nfor i in range(N):\n cnt[A[i]]+=1\nif N%2==0:\n for i in range(1,N,2):\n if cnt[i]!=2:\n print((0))\n break\n else:\n print((2**(N//2)%MOD))\nelse:\n if cnt[0]!=1:\n print((0))\n else:\n for i in range(2,(N+1)//2,2):\n if cnt[i]!=2:\n print((0))\n break\n else:\n print((2**((N-1)//2)%MOD))\n", "import collections\nimport sys\ninput = sys.stdin.readline\n\nN = int(input())\nA = list(map(int,input().split()))\nm = 1000000007\n\nflag0 = 1\ncount = 0\n#\u5076\u6570\u3060\u3063\u305f\u3089\nif N %2 ==0:\n colA = collections.Counter(A)\n for key,val in list(colA.items()):\n if key%2 != 1 or val != 2:\n flag0 = 0\n break\n for i in range(1,N,2):\n if i not in list(colA.keys()):\n flag = 0\n break\n else:\n count +=1\n#\u5947\u6570\u3060\u3063\u305f\u3089\nelse:\n A.append(0)\n colA = collections.Counter(A)\n for key,val in list(colA.items()):\n if key%2 != 0 or val != 2:\n flag0 = 0\n break\n for i in range(0,N,2):\n if i not in list(colA.keys()):\n flag = 0\n break\n else:\n count +=1\n count -=1\n\n\nprint((((2**count)%m)*flag0))\n \n"]
{"inputs": ["5\n2 4 4 0 2\n", "7\n6 4 0 2 4 0 2\n", "8\n7 5 1 1 7 3 5 3\n"], "outputs": ["4\n", "0\n", "16\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
48,210
4ba97bf8651baf5b187d1c4a72581837
UNKNOWN
Find the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). -----Constraints----- - 1 \leq N \leq 10^4 - 1 \leq A \leq B \leq 36 - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N A B -----Output----- Print the sum of the integers between 1 and N (inclusive), whose sum of digits written in base 10 is between A and B (inclusive). -----Sample Input----- 20 2 5 -----Sample Output----- 84 Among the integers not greater than 20, the ones whose sums of digits are between 2 and 5, are: 2,3,4,5,11,12,13,14 and 20. We should print the sum of these, 84.
["n, a, b = map(int, input().split())\n\nans = 0\nfor i in range(1, n + 1):\n val = 0\n for c in str(i):\n val += int(c)\n if a <= val <= b:\n ans += i\nprint(ans)", "N,A,B = list(map(int,input().split()))\nK = 0\nfor i in range(1,N+1):\n if A <= sum(map(int,str(i))) <= B:\n K += i\nprint(K)\n \n\n", "n, a, b = (int(i) for i in input().split())\nans = 0\nfor i in range(1, n + 1):\n str_i = str(i)\n sum_i = 0\n for j in str_i:\n sum_i += int(j)\n if a <= sum_i <= b:\n ans += i\nprint(ans)", "n, a, b = list(map(int, input().split()))\n\nans = 0\nfor num in range(1, n+1):\n p = num\n digit_sum = 0\n while p > 0:\n digit_sum += p % 10\n p //= 10\n if a<= digit_sum <= b:\n ans += num\nprint(ans)\n", "n,a,b = list(map(int, input().split()))\ndef sum_digit(x):\n s = 0\n while x:\n s += x % 10\n x //= 10\n return s\nprint(sum([i for i in range(1,n+1) if a <= sum_digit(i) <= b]))", "n, a, b = map(int, input().split())\nr = 0\nfor i in range(n + 1):\n c = 0\n j = i\n for k in range(5):\n c += j % 10\n j = j//10\n if a <= c and c <= b:\n r += i\n\n \nprint(r)", "N, A, B = map(int, input().split())\n\ndef caluculate(n):\n sum = 0\n while n > 0:\n sum += n % 10\n n = n // 10\n return sum\n\nans = 0\nfor i in range(N+1):\n if A <= caluculate(i) <= B:\n ans += i\n\nprint(ans)", "n,a,b = map(int,input().split())\nans = 0\nfor i in range(1,n+1):\n s = str(i)\n sum = 0\n for j in s:\n t = int(j)\n sum+=t\n if a <= sum <= b:\n ans +=i\nprint(ans)", "# coding: utf-8\n# Your code here!\n\nn, a, b = map(int, input().split())\nsum = 0\n\nfor i in range(1, n+1) : \n tmp_sum = 0\n for j in str(i) : \n tmp_sum += int(j)\n if a <= tmp_sum and tmp_sum <= b : \n sum += i\n \nprint(sum)", "def myfunc(A, B):\n def resfunc(x):\n if A <= sum(map(int,list(str(x)))) <=B:\n return x\n else:\n return 0\n return resfunc\n\nN, A, B = map(int, input().split())\nprint(sum(map(myfunc(A,B), range(1, N+1))))", "n, a, b = map(int, input().split())\n\nans = 0\nfor i in range(1,n+1):\n w = sum(list(map(int, list(str(i)))))\n if a <= w and w <= b:\n ans += i\nprint(ans)", "s=list(map(int,input().split()))\n\noklist=[]\n\ndef keta(x):\n ketalist=[]\n for j in range(len(x)):\n ketalist.append(int(x[j]))\n return(sum(ketalist))\n \n \n\nfor i in range(s[0]+1):\n check=keta(str(i))\n if(s[1]<=check and check<=s[2]):\n oklist.append(i) \nsum_=sum(oklist)\nprint(sum_)", "N,A,B = list(map(int,input().split()))\n\nans=0\n\nfor i in range(1,N+1):\n sum_all=0\n tmp=i\n while(tmp>9):\n sum_all += tmp%10\n tmp//=10\n sum_all += tmp\n\n if sum_all>=A and sum_all<=B:\n ans+=i\n # print(i)\n\nprint(ans)\n", "n, a, b = map(int, input().split())\nans = 0\nfor i in range(n+1):\n if a <= sum(list(map(int, list(str(i))))) <= b:\n ans += i\nprint(ans)", "N,A,B=map(int,input().split())\nX=[]\nfor i in range(1,N+1):\n if A<= sum(list(map(int,str(i)))) <=B:\n X.append(i)\nprint(sum(X))", "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, a, b = Input()\n n += 1\n data = (i\n for i in range(1, n)\n if a <= sum(map(int, list(str(i)))) <= b\n )\n print(sum(data))\n\n\nmain()", "N, A, B = map(int, input().split())\n\nL = []\nfor i in range(1, N+1):\n j = map(int, list(str(i)))\n if A <= sum(j) <= B:\n L.append(i)\nprint(sum(L))", "from sys import stdin\nn, a, b = [int(x) for x in stdin.readline().rstrip().split()]\nsum = 0\n\nfor x in range(1,n+1):\n l = x // 10000\n m = (x % 10000) // 1000\n n = (x % 1000) // 100\n o = (x % 100) // 10\n p = x % 10\n if l+m+n+o+p >= a and l+m+n+o+p <= b:\n sum += x\n\nprint(sum)", "N, A, B = map(int, input().split())\nsum_1 = 0\nfor i in range(1,N+1):\n sum_order = 0\n i_str = str(i)\n n = len(i_str)\n for j in range(0,n):\n sum_order += int(i_str[j])\n if A <= sum_order <= B:\n sum_1 += i\nprint(sum_1)", "N, A, B = map(int, input().split())\nlst = []\nfor i in range(N+1):\n if i >= 1 and i < 10:\n if i >= A and i <= B:\n lst.append(i)\n elif i < 100:\n s = i // 10 + i % 10\n if s >= A and s <= B:\n lst.append(i)\n elif i < 1000:\n t = i // 100 + (i % 100) // 10 + i % 10\n if t >= A and t <= B:\n lst.append(i)\n elif i < 10000:\n u = i // 1000 + (i % 1000) // 100 + (i % 100) // 10 + i % 10\n if u >= A and u <= B:\n lst.append(i)\n elif i == 10000:\n lst.append(i)\n\nlst_sum = sum(lst)\nprint(lst_sum)", "n,a,b=map(int,input().split())\ntotal=0\nfor i in range(1,n+1):\n x=(str(i))\n j=0\n total2=0\n for j in range(len(x)):\n total2+=int(x[j])\n if a<=total2<=b:\n total+=i\nprint(total)", "n,a,b = map(int,input().split())\nans = 0\nfor i in range(1,n+1):\n l = len(str(i))\n total = 0\n for j in range(1,l+1):\n total += int(str(i)[-j])\n if a <= total and total <= b:\n ans += i\nprint(ans)", "n,a,b = map(int,input().split())\nans = 0\nfor i in range(1,n+1):\n l = list(map(int,str(i)))\n sum_l = sum(l)\n if sum_l >= a and sum_l <= b:\n ans += i\n\nprint(ans)", "def reverse(num):\n sum1 = 0\n while (num > 0):\n remainder = num % 10\n sum1 = remainder+sum1\n num = num // 10\n return sum1\n\nn,a,b = list(map(int,input().split()))\nc = 0\nfor i in range(1,n+1):\n if reverse(i)>=a and reverse(i)<=b:\n c+=i\nprint(c)", "\n\n# Press the green button in the gutter to run the script.\ndef __starting_point():\n n, a, b = list(map(int, input().split()))\n\n ans = 0\n for n in range(n + 1):\n keta = len(str(n))\n wa = 0\n for m in range(keta):\n tmp = str(n)\n wa = wa + int(tmp[-m-1])\n if a <= wa <= b:\n ans = ans + n\n\n print(ans)\n\n__starting_point()", "N,A,B=list(map(int, input().split()))\ns=0\nfor i in range(1,N+1):\n k=0\n j=i\n while(j>0):\n k+=j%10\n j=j//10\n if (A<=k and k<=B):\n s=s+i\nprint(s)\n", "N,A,B = map(int,input().split())\n\nans = 0\n\nfor i in range(1,N+1):\n \n x = str(i)\n n = len(x)\n sum = 0\n \n for j in range(0,n):\n sum = sum + int(x[j])\n \n if sum >= A and sum <= B:\n ans += i\n \nprint(ans)", "n, a, b = map(int, input().split())\n\nres = 0\nfor i in range(1, n+1):\n tmp = sum([int(elem) for elem in list(str(i))])\n if a <= tmp and tmp <= b:\n res += i\nprint(res)", "n, a, b = map(int, input().split())\nans = 0\nfor i in range(n+1):\n if a <= sum(list(map(int, list(str(i))))) <= b:\n ans += i\nprint(ans)", "n, a, b = list(map(int, input().split()))\nans = 0\n\nfor i in range(1,n+1):\n mod = 0\n div = i\n while div > 0:\n mod += (div % 10)\n div //= 10\n if mod >= a and mod <= b:\n ans += i\n\nprint(ans)\n", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn, a, b = list(map(int, input().split()))\n\nans = 0\nfor i in range(1, n+1):\n tmp = 0\n for j in str(i):\n tmp += int(j)\n\n if tmp >= a and tmp <= b:\n ans += i\nprint(ans)\n", "n,a,b = map(int,input().split())\nc = 0\nfor i in range(1,n+1):\n s = 0\n d = i\n while d!=0:\n s+= d%10\n d//=10\n if a<=s<=b:\n c+=i\nprint(c)", "x = list(map(int,input().split()))\nn = int(x[0])\na = int(x[1])\nb = int(x[2])\n\nres = 0\n\nfor i in range(n+1):\n m = sum([int(r) for r in list(str(i))])\n if a <= m <= b:\n res += i\n\nprint(res)", "N, A, B = list(map(int, input().split()))\n\ntotal = 0\nfor i in range(1, N+1):\n subTotal = sum(list(map(int, str(i))))\n if subTotal >= A and subTotal <= B:\n total += i\n\nprint(total)\n", "N,A,B = map(int,input().split())\nans_list = []\n\nfor i in range(0,N+1):\n if i < 10:\n if i >= A and i <=B:\n ans_list.append(i)\n else:\n temp = list(map(int,str(i)))\n temp=sum(temp)\n if temp >=A and temp<=B:\n ans_list.append(i)\n \nprint(sum(ans_list))", "N, A, B = map(int,input().split())\n\nanswer = 0\n\nfor i in range(N + 1):\n numStrList = list(str(i))\n numIntList = [int(s) for s in numStrList] \n\n if A <= sum(numIntList) <= B :\n answer += i\n\nprint(answer)", "N,A,B=map(int,input().split())\ncount=0\nfor i in range(1,N+1):\n acc=0\n for j in range(len(str(i))):\n acc+=int(str(i)[j])\n if acc >= A and acc <= B: count+=i\nprint(count)", "N,A,B = map(int, input().split())\n \nls = []\nfor n in range(1,N+1):\n sm = sum(int(s) for s in str(n))\n if A <= sm <= B:\n ls.append(int(n))\nprint(sum(ls))", "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, A, B = LI()\n\n ans = 0\n for i in range(1, N + 1):\n if A <= sum([int(i) for i in str(i)]) <= B:\n ans += i\n\n print(ans)\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "N, A, B = map(int, input().split())\n\nans = 0\nfor i in range(1, N+1):\n k = list(str(i))\n sum_i = 0\n for j in k:\n sum_i += int(j)\n if A <= sum_i <= B:\n ans += i\n \nprint(ans)", "N, A, B = list(map(int, input().split()))\n\nres = 0\nfor i in range(1, N+1):\n if(A <= sum(map(int, str(i))) <= B):\n res += i\n\nprint(res)\n", "n, a, b = map(int, input().split())\n\nans = 0\nfor i in range(1, n+1):\n t = 0\n v = i\n while v > 0:\n t += v%10\n v//=10\n if a <= t <= b:\n ans += i\nprint(ans)", "N, A, B = map(int, input().split())\n\n\ndef calc(N):\n sum = 0\n while N > 0:\n sum += N % 10\n N //= 10\n return sum\n\n\nsum_num = 0\nfor i in range(1, N + 1):\n ans = calc(i)\n if A <= ans <= B:\n sum_num += i\n\nprint(sum_num)", "N,A,B = map(int,input().split())\n\nans = 0\nfor i in range(N):\n n = i + 1\n arr = list(map(int,str(n)))\n summ = sum(arr)\n if summ >= A and summ <= B:\n ans += n\nprint(ans)", "n, a, b = list(map(int, input().split()))\nans = 0\n\nfor i in range(1,n+1):\n sum = 0\n x = i\n while x > 0:\n sum += x%10\n x //= 10 \n if a<=sum and sum<=b:\n ans += i\n \nprint(ans)\n", "N, A, B = list(map(int, input().split()))\nans = []\nfor i in range(1, N + 1):\n target = 0\n for j in range(len(str(i))):\n target += int(str(i)[j])\n if A <= target <= B:\n ans.append(i)\n\nprint((sum(ans)))\n", "N,A,B=list(map(int,input().split()))\nans=0\nfor x in range(1,N+1):\n y=sum(int(c) for c in str(x))\n if A<=y and y<=B:\n ans+=x\nprint(ans)\n", "N,A,B = list(map(int,input().split()))\ns = 0\nfor i in range(1,N+1):\n tmp = sum(list(map(int,str(i))))\n if A<=tmp and tmp <= B:\n s += i\n\nprint(s)", "N, A, B = list(map(int, input().split()))\nres = 0\n\nfor i in range(1, N+1):\n num = sum(map(int, list(str(i))))\n if A <= num <= B:\n res += i\n \nprint(res)\n", "lst = input().split()\nN = int(lst[0])\nA = int(lst[1])\nB = int(lst[2])\n\ndef sum(n):\n result = 0\n s = str(n)\n for i in range(len(s)):\n result += int(s[i])\n return result\n\ncount = 0\n\nfor i in range(1, N+1):\n if A <= sum(i) <= B:\n count += i\n\nprint(count)", "n_num, a_num, b_num = map(int, input().split())\n\ndef digit_sum(num):\n str_num = str(num)\n digit_num = 0\n for s in str_num:\n digit_num += int(s)\n return digit_num\n\ncnt = 0\nfor n in range(1, n_num+1):\n if a_num <= digit_sum(n) <= b_num:\n\n cnt += n\n \nprint(cnt)", "N,A,B = map(int,input().split())\nans_list = []\n\nfor i in range(0,N+1):\n\n temp = list(map(int,str(i)))\n temp=sum(temp)\n if temp >=A and temp<=B:\n ans_list.append(i)\n \nprint(sum(ans_list))", "n, a, b = map(int, input().split())\nans = 0\n\nfor i in range(1, n+1):\n if a <= sum(list(map(int, str(i)))) <= b:\n ans += i\n \nprint(ans)", "n, a, b = map(int, input().split())\nsum = 0\nsum_n = 0\nfor num in range(1, n+1):\n num2 = num\n sum_n = 0\n while num > 0:\n sum_n += num % 10\n num //= 10\n if sum_n >= a and sum_n <= b:\n sum += num2\nprint(sum)", "N,A,B=map(int,input().split())\nans=[]\nfor i in range(1,N+1):\n j=i//10000+(i%10000)//1000+(i%1000)//100+(i%100)//10+(i%10)//1\n if A<=j<=B:\n ans.append(i)\n \nprint(sum(ans))", "n, a, b = list(map(int, input().split()))\n\nl = list(range(0))\n\nfor i in range(n+1):\n res = sum(list(map(int, str(i))))\n if res >= a and res <= b:\n l.append(i)\n\nans = sum(list(l))\nprint(ans)\n", "def sum_of_digits(i: int) -> int:\n result = 0\n for _ in range(len(str(i))):\n i, mod = divmod(i, 10)\n result += mod\n\n return result\n\n\ndef answer(n: int, a: int, b: int) -> int:\n some_sums = 0\n for i in range(1, n + 1):\n if a <= sum_of_digits(i) <= b:\n some_sums += i\n\n return some_sums\n\n\ndef main():\n n, a, b = map(int, input().split())\n print(answer(n, a, b))\n\n\ndef __starting_point():\n main()\n__starting_point()", "N, A, B = map(int, input().split())\n\nSum = 0\nfor i in range(N):\n o = (i+1)//10000\n a = (i+1)%10000//1000\n b = (i+1)%1000//100\n c = (i+1)%100//10\n d = (i+1)%10\n e= o+a+b+c+d\n if e >= A and e <= B:\n Sum = Sum + (i+1)\n\nprint(Sum)", "N, A, B = map(int, input().split())\nans = 0\nfor n in range(1, N+1):\n if A <= sum(list(map(int,list(str(n))))) <= B:\n ans += n\nprint(ans)", "n, a, b = list(map(int, input().split()))\nl = []\nans = 0\nfor i in range(n):\n l.append(str(i + 1))\nfor i in l:\n li = list(map(int, i))\n if a <= sum(li) <= b:\n ans += int(i)\nprint(ans)\n", "N, A, B = map(int, input().split())\n\nsum = 0\nfor i in range(N+1):\n x = 0\n for j in range(len(str(i))):\n x = x + int(str(i)[j])\n if A <= x <= B:\n sum = sum + i\nprint(sum)", "n,a,b=map(int,input().split())\nans=0\nfor i in range(n+1):\n i=str(i)\n c=0\n for l in i:\n c+=int(l)\n if a<=c and c<=b:\n ans+=int(i)\nprint(ans)", "n, a, b = list(map(int, input().split()))\n\nans = 0\nfor x in range(1, n + 1):\n c = sum(map(int, str(x)))\n if a <= c <= b:\n ans += x\nprint(ans)\n", "n,a,b = map(int,input().split())\n\nans= 0\n\nfor i in range(n+1):\n if a <= sum(list(map(int, str(i)))) <= b:\n ans = ans + i\n\nprint(ans)", "def findSumOfDigits(n):\n sum = 0\n while n > 0:\n sum += n % 10\n n //= 10\n return int(sum)\n\nN,a,b = map(int,input().split())\nc = 0\ntotal =0\nfor i in range(N+1):\n c = findSumOfDigits(i)\n if a <= c <= b:\n # print(i)\n # print(c)\n total += i\n # print(total)\nprint(total)", "n, a, b = map(int, input().split())\nprint(sum(i for i in range(1, n+1) if a <= sum(map(int, str(i))) <=b))", "#!/user/bin/env pypy3\nimport sys\nfrom functools import reduce\n\n\ndef fast_input():\n return sys.stdin.readline()[:-1]\n\n\ndef digit_sum(num: int) -> int:\n str_num = str(num)\n return reduce(\n lambda acc, n: acc + int(n),\n list(str_num),\n 0\n )\n\n\ndef solve(n: int, a: int, b: int) -> int:\n num_sum = 0\n for num in range(1, n + 1):\n if a <= digit_sum(num) <= b:\n num_sum += num\n return num_sum\n\n\ndef main():\n [n, a, b] = list(map(int, fast_input().split()))\n result = solve(n, a, b)\n print(result)\n\n\nmain()\n", "N, A, B = map(int, input().split())\n\nresult = 0\nfor i in range(1, N+1):\n num = i//(10**4) + i//(10**3)%10 + i//(10**2)%10 + i//10%10 + i%10\n if A <= num <= B:\n result += i\nprint(result)", "N, A, B =list(map(int,input().split()))\n\nal = []\nfor i in range(1, N + 1):\n checkno = 0\n\n for j in range(len(str(i))):\n str_i = str(i)\n checkno += int(str_i[j])\n if A <= checkno and checkno <= B:\n al.append(i)\n\nprint((sum(al)))\n", "n,a,b=map(int,input().split())\nans=0\nfor i in range(n+1):\n if a<=sum(list(map(int,list(str(i)))))<=b:\n ans += i\nprint(ans)", "# 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))\nN,A,B= list(map(int,input().split()))\n# f = 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\ncount=0\nans=[]\nfor i in range(1,N+1):\n cal=[]\n for k in str(i):\n cal.append(int(k))\n\n if A<=sum(cal)<=B:\n ans.append(i)\n \nprint((sum(ans)))\n \n", "# coding: utf-8\n# Your code here!\n\ndef sumDigit(x):\n sum_ = 0\n while x > 0:\n sum_ += x%10\n x //= 10\n return sum_\n\nN,A,B=(int(x) for x in input().split())\n\nss = 0\nfor i in range(N):\n num = sumDigit(i+1)\n if num >= A and num <= B:\n ss += i+1\n\nprint(ss)", "# -*- coding: utf-8 -*-\n\nn, a, b = list(map(int, input().split()))\ns = 0\nans = 0\n\ndef findSumOfDigits(num):\n s = 0\n while num > 0:\n s += int(num % 10)\n num = int(num / 10)\n return s\n\n\nfor i in range(n + 1):\n s = findSumOfDigits(i)\n if a <= s <= b:\n ans += i\nprint(ans)\n", "N,A,B = list(map(int,input().split()))\n\ncnt = 0\nfor n in range(1,N+1):\n val = n % 10\n tmp = n\n while tmp // 10 > 0:\n \n tmp = tmp // 10\n val += tmp % 10\n if val >= A and val <= B:\n cnt += n\nprint(cnt)", "n,a,b = map(int,input().split())\nans = 0\nfor i in range(1,n+1):\n x = list(str(i))\n x = list(map(int,x))\n x = sum(x)\n if a <= x <= b:\n ans += i\nprint(ans)", "n, a, b = map(int, input().split())\nans = 0\nfor i in range(1, n+1):\n x = str(i)\n cnt = 0\n for j in range(len(x)):\n cnt += int(x[j])\n if a <= cnt and cnt <= b:\n ans += i\nprint(ans)", "n, a, b = list(map(int, input().split()))\nl = []\nc = 0\nk = 0\n\nfor i in range(n+1):\n k = i\n c = 0\n while (i > 0):\n c += i%10\n i //= 10\n if (a <= c <= b):\n l.append(k)\n\nprint((sum(l)))\n", "N, A, B = map(int, input().split())\na = list()\nfor i in range(N + 1):\n if A <= sum(map(int, str(i))) <= B:\n a.append(i)\nprint(sum(a))", "N, A, B = map(int, input().split())\n\nres = []\n\nfor n in range(1, N+1):\n i = list(str(n))\n i = [int(n) for n in i]\n if A <= sum(i) <= B:\n res.append(int(n))\n\nprint(sum(res))", "n, a, b = map(int, input().split())\n\nans = 0\n\nfor i in range(n + 1):\n l = list(map(int, str(i)))\n sum_l = sum(l)\n if sum_l >= a and sum_l <= b:\n ans += i\n\nprint(ans)", "N,A,B = map(int, input().split())\nsum1 = 0\nfor n in range(1, N+1):\n sum2 = 0\n for s in str(n):\n sum2 += int(s)\n if A <= sum2 <= B:\n sum1 += n\nprint(sum1)", "getints = lambda: map(int, input().split())\nn, a, b = getints()\nans = 0\nfor i in range(1, n+1):\n s = str(i)\n sum = 0\n for c in s:\n sum += int(c)\n if a <= sum <= b:\n ans += i\nprint(ans)", "N, A, B = list(map(int,input().split()))\nans = 0\nfor i in range(N + 1):\n i = str(i)\n count = 0\n for j in i:\n count += int(j)\n if A <= count and B >= count:\n ans += int(i)\nprint(ans)\n", "N,A,B = map(int,input().split())\ncon = 0\nfor i in range(1 , N + 1):\n a1 = i // 10000\n a2 = (i - a1 * 10000)// 1000\n a3 = (i - a1 * 10000 - a2 * 1000)// 100\n a4 = (i - a1 * 10000 - a2 * 1000 - a3 * 100) // 10\n a5 = i % 10\n if A <= a1 + a2+ a3 + a4 + a5 <= B:\n con += i\nprint(con)", "N,A,B = map(int,input().split())\ncnt = 0\nsum = 0\ni = 0\nfor i in range(N+1):\n j = 0\n tmpsum = 0\n l = list(str(i))\n for j in l:\n tmpsum += int(j)\n if tmpsum>=A and tmpsum <=B:\n sum += i\nprint(sum)", "def solve(N, A, B):\n nums = []\n for n in range(1, N + 1):\n s = 0\n ns = str(n)\n for j in range(len(ns)):\n s += int(ns[j])\n if A <= s and s <= B:\n nums.append(n)\n print((sum(nums)))\n\n\n\ndef __starting_point():\n N, A, B = list(map(int, input().split()))\n solve(N, A, B)\n\n__starting_point()", "def calc_sum(num):\n ans = 0\n for i in range(len(str(num))):\n target = num % 10\n num //= 10\n ans += target\n return ans\n\ndef main():\n\n n, a, b = map(int, input().split())\n ans = 0\n for i in range(1, n + 1):\n num = calc_sum(i)\n if a <= num <= b:\n ans += i\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "N,A,B = list(map(int,input().split()))\nans = 0\nfor i in range(1,N+1):\n M = i//10000+i%10000//1000+i%1000//100+i%100//10+i%10\n if A <= M and M <= B:\n ans+=i\nprint(ans)\n", "n, a, b = map(int,input().split())\ncount = 0\nfor i in range(1,n+1):\n num = i\n digit = 0\n while num > 0:\n digit += num % 10\n num = num // 10\n if a <= digit <= b:\n count += i\nprint(count)", "N,A,B = map(int,input().split())\n\ndef aaa(n):\n sum = 0\n while n > 0:\n sum += n % 10\n n = n//10 \n return sum\n\nsum = 0\n\nfor i in range(1,N+1):\n a = aaa(i)\n if A<= a <= B:\n sum += i\nprint(sum)", "n,a,b = map(int, input().split())\n\nans = 0\nfor num in range(n+1):\n str_num = str(num)\n num_list = list(str_num)\n total = sum([int(i) for i in num_list])\n if total >= a and total <= b:\n ans+=num\nprint(ans)", "N, A, B = list(map(int,input().split()))\n\ndef ten_sumfunc(n):\n ans = 0\n while(n>0):\n ans += n%10\n n = n//10\n return ans\n\ntotal = 0\nfor i in range(N+1):\n sum1 = ten_sumfunc(i)\n if A <= sum1 and sum1 <= B:\n total += i\n \nprint(total)\n", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\n\n# tmp = list([int(i) for i in (list(str(i)))])\n\ndef main():\n n,a,b = map(int,input().split())\n numbers=[]\n tmp=0\n\n for i in range(1,n+1):\n if i >=a and i <=b and i < 10:\n numbers.append(i)\n else:\n tmp_array=list(map(int,list(str(i))))\n if len(tmp_array) > 1:\n for j in tmp_array:\n tmp+=j\n if tmp >=a and tmp <=b:\n numbers.append(i)\n tmp=0\n else:\n continue\n print(sum(numbers))\n \ndef __starting_point():\n main()\n__starting_point()", "N, A, B = list(map(int,input().split()))\n\nans = 0\n\nfor i in range(1, N+1, 1):\n stri = str(i)\n sum = 0\n for j in range(len(str(i))):\n sum += int(stri[j])\n else:\n if sum >= A and sum <= B:\n ans += i\n \nprint(ans)\n", "\nN,A,B = map(int, input().split())\n\nans = 0\n\nfor i in range(N+1):\n x = i%10\n if i >= 10:\n x += (i%100-i%10)/10\n if i >= 100:\n x += (i%1000-i%100)/100\n if i >= 1000:\n x += (i%10000-i%1000)/1000\n if i == 10000:\n x=1\n if A <= x <= B:\n ans += i\n\nprint(ans)", "def FindSumOfDigits(n):\n Sum = 0\n while n>0:\n Sum += n%10\n n //= 10\n return Sum\n\nN, A, B = list(map(int, input().split()))\ntotal = 0\nfor i in range(N):\n Sum = FindSumOfDigits(i+1)\n if A <= Sum and Sum <= B:\n total += i+1\n\nprint(total)\n", "N,A,B=map(int,input().split())\nx=y=z=a=b=sum=0\nfor i in range(1,N+1):\n x=i%10\n y=(i%100)//10\n z=(i%1000)//100\n a=(i%10000)//1000\n b=(i%100000)//10000\n\n if A<=x+y+z+a+b<=B:\n sum+=i\nprint(sum)", "n,a,b = list(map(int,input().split()))\nans = 0\nfor i in range(1,n+1):\n temp = 0\n c = str(i)\n for j in range(len(c)):\n temp += int(c[j])\n if a <= temp and temp <= b:\n ans += i\nprint(ans)\n", "N,A,B = map(int, input().split())\nresult = 0\n\ndef FindSomeOfDegit(x):\n count = 0\n while x > 0:\n count += x%10 \n x = x // 10\n return count\n\nfor i in range(N+1):\n count = FindSomeOfDegit(i)\n if A <= count <= B:\n result += i\n\nprint(result)"]
{"inputs": ["20 2 5\n", "10 1 2\n", "100 4 16\n"], "outputs": ["84\n", "13\n", "4554\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
24,974
28aa04b3ebd3630a98d701f04216f650
UNKNOWN
This contest, AtCoder Beginner Contest, is abbreviated as ABC. When we refer to a specific round of ABC, a three-digit number is appended after ABC. For example, ABC680 is the 680th round of ABC. What is the abbreviation for the N-th round of ABC? Write a program to output the answer. -----Constraints----- - 100 ≀ N ≀ 999 -----Input----- Input is given from Standard Input in the following format: N -----Output----- Print the abbreviation for the N-th round of ABC. -----Sample Input----- 100 -----Sample Output----- ABC100 The 100th round of ABC is ABC100.
["N = input()\nprint(\"ABC\"+N)", "print(\"ABC\"+input())", "print(\"ABC\"+input())", "print('ABC' + input())", "print(\"ABC\" + input())", "print(\"ABC\"+input())", "print(\"ABC\"+input())", "N = int(input())\nprint(f\"ABC{N}\")", "s = input()\n\nprint('ABC'+s)", "n = input()\nprint(\"ABC\" + n)", "print(\"ABC\"+input())", "N = input()\n\nprint(\"ABC\" + N)", "n = (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('ABC'+n)", "n=str(input())\nprint(\"ABC\"+n)", "N = input()\nprint('ABC'+N)", "N = input()\n\nprint(\"ABC\" + N)", "print(\"ABC\"+input())", "N=input()\nprint(\"ABC\"+N)", "N=int(input())\nprint(\"ABC{}\".format(N))", "print(\"ABC\"+input())", "N = input()\nprint('ABC'+N)", "s = \"ABC\"\nN = int(input())\nif 100<=N<=999 :\n print(s + str(N))", "print('ABC' + input())", "N = int(input())\n\nprint((\"ABC{:03d}\".format(N)))\n", "N = input()\nprint(\"ABC\"+N)", "string = \"ABC\"\nN = int(input())\nif 100<=N<=999 :\n print(string + str(N))", "print(f'ABC{input()}')", "n = str(input())\nprint('ABC' + n)", "print(\"ABC\"+input())", "n=input()\nprint('ABC'+n)", "N=input()\nres=\"ABC\"+N\nprint(res)", "print(\"ABC\"+ input())", "n=input()\nprint((\"ABC\"+n))\n\n", "print(\"ABC\"+str(input()))", "print(\"ABC\" + input())", "a = input()\nprint(\"ABC\" + a)", "N = input()\nprint(\"ABC\" + N)", "N = input()\nprint(('ABC' + N))\n", "n = int(input())\nprint(f'ABC{n:0>3}')", "import sys\n\nN = sys.stdin.readline().strip()\nprint(\"ABC\" + N)", "print(\"ABC\"+input())", "a = input()\nb = ('ABC')\nc = b + a\nprint( c )", "n=input()\nprint(\"ABC\"+n)", "print(\"ABC\"+input())", "print(\"ABC\" + input())", "n = input()\nprint('ABC' + n)", "def iroha():\n num = int(input())\n print((\"ABC\"+str(num)))\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "print('ABC'+input())", "print(\"ABC{}\".format(input()))", "n=input()\nprint(\"ABC\"+n)", "print(\"ABC\"+input())", "print(\"ABC\"+str(input()))", "n = int(input())\nprint('ABC', n, sep='')", "N=input()\nprint((\"ABC\"+N))\n", "print('ABC'+input())", "n = input()\nprint('ABC'+n)", "print(\"ABC\" + str(input()))", "print(\"ABC\"+input())", "print('ABC' + input())", "n=int(input())\nprint('ABC'+str(n))", "a=input()\nprint(\"ABC\"+a)", "n = input()\nprint(\"ABC\"+n)", "n = int(input())\n\nprint(('ABC' + str(n)))\n", "x =input()\nprint(\"ABC\"+x)", "n = input()\nprint(\"ABC\"+n)", "print('ABC'+input())", "print(\"ABC\"+input())", "print(f\"ABC{input()}\")", "print(\"ABC\"+input())", "N = int(input())\n\n\nprint(\"ABC\", N, sep=\"\")\n", "'''\nABC068 A - ABCxxx\nhttps://atcoder.jp/contests/abc068/tasks/abc068_a\n'''\nprint((\"ABC\"+input()))\n", "print(input(\"ABC\"))", "N=input()\nprint('ABC'+N)", "n = str(input())\nprint((\"ABC\" + n))\n", "n = int(input())\n\nprint(\"ABC\" + str(n))", "s = input()\nprint('ABC' + s)", "n = input()\nprint((\"ABC\" + n))\n", "print('ABC'+input())", "count_of_contest = int(input())\n\nprint('{}{}'.format('ABC', count_of_contest))", "n=input()\nprint(\"ABC\"+n)", "#\n# abc068 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 = \"\"\"100\"\"\"\n output = \"\"\"ABC100\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"425\"\"\"\n output = \"\"\"ABC425\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"999\"\"\"\n output = \"\"\"ABC999\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n print((\"ABC\" + input()))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "print(f'ABC{input()}')", "print('ABC' + input())", "n = str(input())\nprint(\"ABC\"+n)", "N = input()\nprint((\"ABC\"+N))\n", "print(\"ABC\"+input())", "N = input()\nprint((\"ABC\"+N))\n", "N = input ()\nprint ('ABC'+N)", "print('ABC{}'.format(input()))", "print(\"ABC\"+input())", "a = int(input())\nprint('ABC' + str(a))", "N = input()\nans = \"ABC\" + N\nprint(ans)", "print(\"ABC\"+input())", "N = str(input())\nprint('ABC' + N)", "print('ABC' + input())", "print((\"ABC\"+input()))\n", "n = str(input())\n\nprint('ABC'+n)", "n = input()\nprint(\"ABC\" + n )"]
{"inputs": ["100\n", "425\n", "999\n"], "outputs": ["ABC100\n", "ABC425\n", "ABC999\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
4,702
952970cb681548e4c7d81703fd53a1ee
UNKNOWN
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called Takahashi when the month and the day are equal as numbers. For example, 5-5 is Takahashi. How many days from 2018-1-1 through 2018-a-b are Takahashi? -----Constraints----- - a is an integer between 1 and 12 (inclusive). - b is an integer between 1 and 31 (inclusive). - 2018-a-b is a valid date in Gregorian calendar. -----Input----- Input is given from Standard Input in the following format: a b -----Output----- Print the number of days from 2018-1-1 through 2018-a-b that are Takahashi. -----Sample Input----- 5 5 -----Sample Output----- 5 There are five days that are Takahashi: 1-1, 2-2, 3-3, 4-4 and 5-5.
["a,b=map(int,input().split())\n\nif a>b:\n print(a-1)\nelse:\n print(a)", "n,m=map(int,input().split())\nif n > m:\n print(n-1)\nelse:print(n)", "a,b=map(int,input().split())\nif a>b:\n a-=1\nprint(a)", "a,b = map(int, input().split())\nif b>=a:\n print(a)\nelse:\n print(a-1)", "a,b = map(int,input().rstrip().split())\nif a>b:\n print(a-1)\nelse:\n print(a)", "a, b = list(map(int, input().split()))\nres = a - 1\nif a <= b:\n res += 1\n\nprint(res)\n", "def main():\n a, b = list(map(int, input().split()))\n if a <= b:\n print(a)\n else:\n print((a-1))\n\ndef __starting_point():\n main()\n\n__starting_point()", "a,b=map(int,input().split())\nif a > b:\n print(a-1)\nelse:\n print(a)", "a,b = map(int,input().split())\nif a <= b:\n print(a)\nelse:\n print(a - 1)", "def resolve():\n a, b = map(int, input().split())\n if a <= b: c = a\n else: c = a - 1\n print(c)\nresolve()", "a, b = map(int, input().split())\nprint(a - 1 if a > b else a)", "a,b=map(int,input().split())\nif a<=b:\n print(a)\nelse:\n print(a-1)", "a,b=map(int,input().split())\nif a<=b:\n ans=a\nelse:\n ans=a-1\nprint(ans)", "a, b = map(int, input().split())\nif a <= b:\n print(a)\nelse:\n print(a - 1)", "a, b = map(int, input().split())\nif a <= b:\n print(a)\nelse:\n print(a - 1)", "a,b = map(int,input().split())\nif a<=b:\n print(a)\nelse:\n print(a-1)", "a,b=map(int,input().split())\nif a<=b:\n print(a)\nelse:\n print(a-1)", "a,b=map(int,input().split())\n \nprint(a) if a<=b else print(a-1)", "a,b=map(int,input().split())\nprint(a+(b>=a)-1)", "a,b=map(int,input().split())\n\nans=a-1\n\nif b>=a:\n\tprint(ans+1)\nelse:\n \tprint(ans)", "a, b = map(int, input().split())\nans = a if a <= b else a-1\nprint(ans)", "a, b = map(int, input().split())\nc = a\nif a > b:\n print(c-1)\nelse:\n print(c)", "a,b = list(map(int,input().split()))\nprint(((a-1)+(b>=a)))\n", "a,b=map(int,input().split())\nprint(a-(a>b))", "a, b = map(int, input().split())\nif a > b:\n print(a-1)\nelse:\n print(a)", "a, b = list(map(int,input().split()))\n\nans = a - (a>b)\nprint(ans)", "a, b=map(int,input().split())\nif a<=b:\n print(a)\nelse:\n print(a-1)", "a, b = map(int, input().split())\nprint(a if b >= a else a - 1)", "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 a, b = LI()\n\n if a <= b:\n print(a)\n else:\n print((a - 1))\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "a,b=map(int,input().split())\n\nif a<=b:\n print(a)\nelse:\n print(a-1)", "a,b=input().split()\na=int(a)\nb=int(b)\nif a<=b:\n print(a)\nelse:\n print(a-1)", "a,b = map(int,input().split())\n\nif b >= a:\n print(a)\nelse:\n print(a-1)", "#!/usr/bin/env python3\n\na, b = list(map(int, input().split()))\n\nans = 0\nfor i in range(1, 13):\n if i < a:\n ans += 1\n elif i == a:\n if i <= b:\n ans += 1\nprint(ans)\n", "a,b = map(int,input().split())\nif a > b :\n print(a-1)\nelse:\n print(a)", "a,b=map(int,input().split())\nans= a if a<=b else a-1\nprint(ans)", "a, b = map(int, input().split())\nif (a > b): print(a-1)\nelse: print(a)", "a, b = map(int, input().split())\nprint(a-(a > b))", "a, b = map(int, input().split())\ntakahashi = a - 1\nif b >= a:\n takahashi += 1\nprint(takahashi)", "a, b = list(map(int,input().split()))\nif a <= b:\n print(a)\nelse:\n print((a-1))\n", "a,b=map(int,input().split())\n\nif a<=b:\n ans=a\nelse:\n ans=a-1\nprint(ans)", "A, B = [int(i) for i in input().split()]\n\nif A <= B:\n print(A)\nelse:\n print((A-1))\n", "a, b = map(int, input().split())\nif a <= b:\n print(a)\nelse:\n print(a-1)", "a,b=map(int,input().split())\nif a<=b:print(a)\nelse:print(a-1)", "a,b = list(map(int,input().split()))\nprint(( a if b >= a else a-1))\n", "a, b = map(int, input().split())\n\nif a <= b:\n print(a)\nelse:\n print(a - 1)", "a,b=map(int, input().split())\nprint(a if a<=b or a==1 else a-1)", "month, day = map(int, input().split())\ntakahashi_days = month\nif day >= month:\n print(takahashi_days)\nelif month > day:\n print(takahashi_days -1)", "a, b = map(int, input().split())\n\nif a <= b:\n print(a)\nelse:\n print(a-1)", "a,b=map(int,input().split())\nprint(a if b>=a else a-1)", "lst = input().split()\na = int(lst[0])\nb = int(lst[1])\n\nif a <= b:\n print(a)\nelse:\n print(a - 1)", "a,b = map(int,input().split())\nans = a\nif b < a:\n ans -= 1\nprint(ans)", "a, b = list(map(int, input().split()))\n\nif b < a:\n print(a-1)\nelse:\n print(a)", "a, b = map(int, input().split())\n \nif a>b:\n print(a-1)\nelse:\n print(a)", "a,b=list(map(int,input().split()))\nif a<=b:\n print(a)\nelse:\n print((a-1))\n", "a,b=list(map(int,input().split()))\nif b>=a:\n print(a)\nelse:\n print(a-1)", "a, b = map(int, input().split())\n\nif b < a:\n print(a-1)\nelse:\n print(a)", "a,b = map(int,input().split())\nif a <= b:\n print(a)\nelse:\n print(a-1)", "a,b=map(int,input().split())\nans=a\nif b<a:ans-=1\nprint(ans)", "a,b = map(int,input().split())\n\ncnt = a - (1 if a > b else 0)\n\nprint(cnt)", "a,b=list(map(int, input().split()))\n\nif a<=b:\n ans=a\n \nelse:\n ans=a-1\n \nprint(ans)\n", "a,b = map(int, input().split())\nif a <= b:\n print(a)\nelse:\n print(a-1)", "a,b = map(int,input().split())\nif a <= b:\n print(a)\nelse:\n print(a - 1)", "a,b = map(int, input().split())\nif 1 <= b < a:\n print(a-1)\nelif a <= b:\n print(a)", "\na,b=map(int,input().split())\ncnt = 0\ncnt += a\nif b < a:\n cnt -= 1\nprint(cnt)", "M,D = map(int,input().split())\nprint(M-1+(0,1)[D>=M])", "a, b = list(map(int, input().split()))\n\nprint((a - int(a > b)))\n", "a,b = map(int,input().split())\nif b >= a:\n print(a)\nelse:\n print(a-1)", "a,b=map(int,input().split())\nprint(a if b>=a else a-1)", "a, b = map(int, input().split())\nif a > b:\n print(a-1)\nelse:\n print(a)", "a, b = map(int, input().split())\nif a > b:\n print(a-1)\nelse:\n print(a)", "a,b = map(int, input().split())\nif a <= b:\n print(a)\nelse:\n print(a-1)", "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\n if a - b <= 0:\n print(a)\n else:\n print(a - 1)\n\n\nmain()", "a,b=map(int,input().split())\nif b<a:\n print(a-1)\nelse:\n print(a)", "a,b=map(int,input().split())\nif a <=b:\n print(a)\nelse:\n print(a-1)", "a, b = map(int, input().split())\nif b >= a:\n print(a)\nelse:\n print(a - 1)", "a,b = map(int, input().split())\nprint(a) if b >= a else print(a-1)", "a,b=map(int, input().split())\nprint(a-1+(a<=b))", "#\n# abc096 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 5\"\"\"\n output = \"\"\"5\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"2 1\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"11 30\"\"\"\n output = \"\"\"11\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n a, b = list(map(int, input().split()))\n\n if a > b:\n print((a-1))\n else:\n print(a)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "a, b = map(int, input().split())\nprint(a - (b < a))", "a,b = map(int, input().split())\nif a <= b:\n print(a)\nelse:\n print(a-1)", "# -*- coding: utf-8 -*-\na, b = list(map(int, input().split()))\nif a > b:\n print((a-1))\nelse:\n print(a)\n", "a, b = map(int, input().split())\n\nif a <= b:\n print(a)\nelse:\n print(a - 1)", "a, b= map(int, input().split())\nif a> b:\n print(a-1)\nelse:\n print(a)", "a,b = map(int,input().split())\nprint([a-1,a][b>=a])", "a,b=list(map(int,input().split()))\nans=0\nans+=a\n\nif b>=a:\n pass\nelse:\n ans-=1\nprint(ans)\n", "a, b = list(map(int, input().split()))\n\nif a > b:\n print((a - 1))\nelse:\n print(a)\n", "a,b=map(int,input().split())\nans=0\nfor i in range(1,a):\n for j in range(1,13):\n if i==j:\n ans+=1\nfor i in range(a,a+1):\n for j in range(1,b+1):\n if i==j:\n ans+=1\nprint(ans)", "a, b = map(int, input().split())\n\nprint(a - 1 + (1 if b >= a else 0))", "a,b=map(int,input().split())\nif a>b:print(a-1)\nelse:print(a)", "a, b = map(int, input().split())\nif a <= b:\n print(a)\nelse:\n print(a-1)", "a, b = map(int, input().split())\nif a <= b:\n print(a)\nelse:\n print(a - 1)", "a,b = map(int,input().split())\nif a<=b:\n print(a)\nelse:\n print(a-1)", "a,b=list(map(int,input().split(\" \")))\nprint((a+(b>=a)-1))\n", "A,B=map(int,input().split())\nprint(A-(A>B))", "a, b = list(map(int, input().split()))\nprint((a if a <= b else a - 1))\n", "a, b = map(int, input().split())\nprint(a if b >= a else a-1)", "n,m = [int(x) for x in input().split()]\nif n <= m:\n print(n)\nelse:\n print(n-1)", "a,b=map(int,input().split())\nif a>b:\n a-=1\nprint(a)", "a,b = list(map(int,input().split()))\n\nif a <= b: print(a)\nelse: print((a-1))\n"]
{"inputs": ["5 5\n", "2 1\n", "11 30\n"], "outputs": ["5\n", "1\n", "11\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
10,016
7ceaaa9a63a171e630558059d5b07876
UNKNOWN
Takahashi wants to gain muscle, and decides to work out at AtCoder Gym. The exercise machine at the gym has N buttons, and exactly one of the buttons is lighten up. These buttons are numbered 1 through N. When Button i is lighten up and you press it, the light is turned off, and then Button a_i will be lighten up. It is possible that i=a_i. When Button i is not lighten up, nothing will happen by pressing it. Initially, Button 1 is lighten up. Takahashi wants to quit pressing buttons when Button 2 is lighten up. Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons. -----Constraints----- - 2 ≀ N ≀ 10^5 - 1 ≀ a_i ≀ N -----Input----- Input is given from Standard Input in the following format: N a_1 a_2 : a_N -----Output----- Print -1 if it is impossible to lighten up Button 2. Otherwise, print the minimum number of times we need to press buttons in order to lighten up Button 2. -----Sample Input----- 3 3 1 2 -----Sample Output----- 2 Press Button 1, then Button 3.
["#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tsample\n# CreatedDate: 2020-10-10 20:29:20 +0900\n# LastModified: 2020-10-10 20:37:38 +0900\n#\n\n\nimport os\nimport sys\n# import numpy as np\n# import pandas as pd\n\n\ndef main():\n N = int(input())\n A = [0]\n visited = [0]*(N+1)\n for _ in range(N):\n A.append(int(input()))\n i = 1\n cnt = 0\n while visited[i] == 0:\n if i == 2:\n print(cnt)\n return\n cnt += 1\n visited[i] = 1\n i = A[i]\n print((-1))\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = [int(input())-1 for _ in range(n)]\ncurr_node = 0\nfor i in range(n):\n curr_node = a[curr_node]\n if curr_node == 1:\n print(i+1)\n return\nprint(-1)", "N = int(input())\nl = [int(input())-1 for _ in range(0,N)]\n\ni = 0;\nflg = False\n\nfor n in range(0,N):\n if l[i] == 1 :\n print(n+1)\n flg = True\n break\n else:\n i = l[i]\n\n\nif not flg:\n print(\"-1\")", "N = int(input())\nA = []\nfor i in range(N):\n A.append(int(input())-1)\n \nans = -1\npush = 0\ncount = [False]*N\n \nfor i in range(N+1):\n \n if A[push] == 1:\n ans = i+1\n break\n \n elif count[push]:\n break\n \n else:\n count[push] = True\n push = A[push]\n \n \nprint(ans)\n", "N = int(input())\nButtons = []\nfor i in range(N):\n Buttons.append(int(input()))\npos = 0\ncount = 0\nvisit = [0]*N\nflag = 1\nwhile pos != 1:\n if visit[pos]!=0:\n flag = 0\n break;\n else:\n visit[pos]=1\n pos = Buttons[pos]-1\n count = count+1\nif flag == 1:\n print(count)\nelse :\n print(-1)", "n = int(input())\na = []\nfor i in range(n):\n a.append(int(input()))\n\nres = -1\ncc = 0\ncount = 0\nfor i in range(2*n):\n cc = a[cc] - 1\n count += 1\n if cc == 1:\n res = count\n break\n\nprint(res)", "n = int(input())\na = [int(input())-1 for _ in range(n)]\n\nvisit_node = [0]*(n)\nans = 0\ncurr_node = 0\n\nwhile(visit_node[curr_node] == 0):\n visit_node[curr_node] = 1\n curr_node = a[curr_node]\n ans += 1\n if curr_node == 1:\n print(ans)\n return\nprint(-1)", "import sys\nN = int(input())\nA = [int(input()) for _ in range(N)]\nx = 0\ncnt = 0\nfor _ in range(N):\n x = A[x] - 1\n cnt += 1\n if x == 1:\n print(cnt)\n return\nprint(-1)", "n = int(input())\nlight = [0] * (n+1)\n\nfor i in range(1,n+1):\n light[i] = int(input())\ns = 1\nans = 0\nwhile light[s] != 2 and ans <= n:\n s = light[s]\n ans += 1\n\nif light[s] == 2:\n print(ans + 1)\nelse:\n print(-1)", "#!/usr/local/bin/python3\n# https://atcoder.jp/contests/abc065/tasks/abc065_b\n\nN = int(input())\na = [int(input())-1 for _ in range(N)]\nans = 0\ncur = 0\n\nvisit = [-1] * N\nwhile True:\n # print(cur, visit)\n cur = a[cur]\n ans += 1\n if visit[cur] == -1:\n visit[cur] = ans\n else:\n print(-1)\n return\n if cur == 1:\n print(ans)\n return", "N=int(input())\na=[int(input())-1 for _ in range(N)]\nx=0\nans=0\nwhile True:\n ans+=1\n x=a[x]\n if x==1:\n print(ans)\n break\n if ans>N:\n print((-1))\n break;\n", "import sys\n\nn = int(input())\nA = list(map(int, sys.stdin.readlines()))\n\nindex = 0\npast_index = list()\nfound = False\n\nfor i in range(len(A)):\n if index == 1:\n print(i)\n found = True\n break\n index = A[index]-1\n\nif not found:\n print(-1)", "N = int(input())\nA = [int(input()) for i in range(N)]\ni = 0\ncnt = 1\ncmpr = [0]\nwhile A[i] != 2:\n if A[i] == i + 1:\n print(-1)\n return\n i = A[i] - 1\n cmpr.append(i)\n cnt += 1\n if cnt > N:\n print(-1)\n return\nprint(cnt)", "n=int(input())\na=[int(input()) for i in range(n)]\ncnt=0\ni=1\nwhile i!=2:\n i=a[i-1]\n cnt+=1\n if cnt>10**5:\n cnt=-1\n break\nprint(cnt)\n", "n=int(input())\na=[]\nfor i in range(n):\n a.append(int(input()))\ntotal=1\ni=a[0]-1\nif a[0]==2:\n print(total)\nelse:\n while True:\n if a[i]==2:\n print(total+1)\n break\n elif total>n:\n print(\"-1\")\n break\n else:\n i=a[i]-1\n total+=1", "N = int(input())\n\nlst = []\nfor i in range(N):\n lst.append(int(input()))\n\nnow = 1\ncount = 0\n\nfor i in range(N):\n now = lst[now - 1]\n count += 1\n if now == 2:\n print(count)\n return\n\nprint(-1)", "from collections import defaultdict\n\nn = int(input())\nA = [int(input()) for _ in range(n)]\n\ndic = defaultdict()\n\nfor i in range(n):\n dic[i+1] = A[i]\n\ncnt, idx = 1, 0\nval = dic[1]\n\nwhile idx <= n:\n if val == 2:\n print(cnt)\n return\n val = dic[val]\n cnt += 1\n idx += 1\nprint((-1))\n", "n=int(input())\na=[]\nfor _ in range(n):\n a.append(int(input()))\nnow=0\ncnt=0\nvisit=[0 for _ in range(n)]\nFlag=False\nwhile now != 1:\n if visit[now] != 0:\n Flag=True\n break\n else:\n visit[now]=1\n now=a[now]-1\n cnt+=1\nif Flag:\n print('-1')\nelse:\n print(cnt)\n", "n = int(input())\nq = [int(input()) for i in range(n)]\ncnt = 0\nind = 0\nfor i in range(n):\n ind = q[ind]-1\n cnt += 1\n if ind == 1:\n print(cnt)\n return\n \nprint((-1))\n\n", "n = int(input())\na = []\nb = []\nfor i in range(n):\n a.append(int(input()))\n\nnext = a[0] - 1\nb.append(next + 1)\nfor i in range(n):\n next = a[next] - 1\n b.append(next + 1)\nprint(b.index(2) + 1) if 2 in b else print(-1)", "# -*- coding:utf-8 -*-\n\nimport sys\nnyuryoku = [int(i) - 1 for i in sys.stdin]\n\nN = nyuryoku[0] + 1\na_list = nyuryoku[1:]\n\n\ncnt_push = 0\nbutton_list = [False] * N\ni = 0\n#cur_but_posi = a_list[0]\n\nwhile True:\n if button_list[i] == False:\n button_list[i] = True\n cnt_push += 1\n if a_list[i] == 1:\n break\n i = a_list[i]\n else:\n cnt_push = -1\n break\n\nprint(cnt_push)\n\n\"\"\"\nimport sys\n\nl = [int(i) - 1 for i in sys.stdin]\n\nN = l[0] + 1\n\na = l[1:]\n\ndone = [False] * N\n\ni = 0\n\nans = 0\n\nwhile True:\n if done[i] == False:\n done[i] = True\n ans += 1\n if a[i] == 1:\n break\n i = a[i]\n else:\n ans = -1\n break\n\nprint(ans)\n\"\"\"\n", "n=int(input())\na=[int(input()) for _ in range(n)]\nlight=0\nans=0\nfor i in range(n):\n if a[light]==2:\n ans+=1\n break\n else:\n light=a[light]-1\n ans+=1\nelse:\n ans=-1\nprint(ans)", "N = int(input())\nA = []\nfor i in range(N):\n A.append(int(input())-1)\n \nans = -1\npush = 0\ncount = set()\n \nfor i in range(N+1):\n \n if A[push] == 1:\n ans = i+1\n break\n \n elif A[push] in count:\n break\n \n else:\n count.add(push)\n push = A[push]\n \nprint(ans)\n", "n = int(input())\ndone = [False for _ in range(n)]\nA = [int(input()) - 1 for _ in range(n)]\ntmp = 0\nfor i in range(n + 1):\n if A[tmp] == 1:\n print((i + 1))\n\n break\n if done[tmp]:\n print((-1))\n break\n else:\n done[tmp] = True\n tmp = A[tmp]\nelse:\n print((-1))\n", "N = int(input())\nA = [int(input()) for _ in range(N)]\nA = [a-1 for a in A]\n\nfin = set()\ncnt = 0\ni = 0\nwhile True:\n if i in fin:\n cnt = -1\n break\n if i == 1:\n break\n cnt += 1\n fin.add(i)\n i = A[i]\nprint(cnt)", "# B - Trained?\ndef main():\n n = int(input())\n a = [int(input()) for _ in range(n)]\n cnt = 0\n x = 1\n\n if 2 in a:\n for _ in range(n-1):\n x = a[x-1]\n cnt += 1\n\n if x == 2:\n print(cnt)\n return\n else:\n print(-1)\n else:\n print(-1)\n \n\nif __name__ == \"__main__\":\n main()", "N = int(input())\nA = [0]*(N+1)\nfor i in range(1,N+1):\n A[i] = int(input())\n\nis_visited_list = [0]*(N+1)\n\nloop = False\nnow_visit = 1\ncnt = 0\nwhile True:\n if is_visited_list[now_visit] == 1:\n loop = True\n break\n else:\n is_visited_list[now_visit] = 1\n \n now_visit = A[now_visit]\n if now_visit == 2:\n cnt +=1\n break\n else:\n cnt +=1\n\nif loop:\n print(-1)\nelse:\n print(cnt)", "N = int(input())\nA = [0] * N\nfor i in range(N):\n A[i] = int(input()) - 1 # \u914d\u5217\u306b\u5bfe\u5fdc\nindex = 0\ntrials = -1\nfor i in range(N):\n index = A[index]\n if index == 1:\n trials = i + 1\n break\nprint(trials)\n", "N = int(input())\na = [int(input()) for _ in range(N)]\ncnt = 0\non = 0\nfor _ in range(N):\n cnt += 1\n if a[on] == 2:\n print(cnt)\n return\n on = a[on]-1\nprint(-1)", "N = int(input())\na = [int(input()) for i in range(N)]\n\ncount = [0]*(N)\n\ni = 1\nmin_num = 0\ncount[i-1]+=1\nwhile True:\n i = a[i-1]\n min_num += 1\n if i == 2:\n print(min_num)\n return\n if count[i - 1] == 0:\n count[i-1]+=1\n else:\n break\n\nprint(-1)", "n = int(input())\nq = [int(input()) for i in range(n)]\ncnt = 0\nind = 0\nfor i in range(n):\n ind = q[ind]-1\n cnt += 1\n if ind == 1:\n print(cnt)\n return\n \nprint(-1)", "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 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\nN = k()\nA = []\nfor i in range(N):\n a = k()\n A.append(a)\n \naaa = 0 \nans = A[0]\ncount = 1\n \nfor i in range(N):\n if ans == 2:\n aaa = 1\n break\n else:\n ans = A[ans-1]\n count += 1\nif aaa == 1:\n print(count)\nelse:\n print(-1)", "# N<=10^5\u306a\u306e\u3067\u611a\u76f4\u306b\u3084\u3063\u3066\u3082\u9593\u306b\u5408\u3046\nn = int(input())\na = [int(input()) - 1 for _ in range(n)]\nvisited = [False] * n\nnow = 0\ncount = 0\nwhile visited[now] != True:\n count += 1\n visited[now] = True\n now = a[now]\n if now == 1:\n print(count)\n return\nprint((-1))\n", "N = int(input())\na = []\n \nfor _ in range(N):\n a.append(int(input()) - 1)\n\ni, count = 0, 0\nsuccess = False\nfor _ in range(N):\n i = a[i]\n count += 1\n\n if i == 1:\n success = True\n break\n \nif not success:\n count = -1\n \nprint(count)", "N = int(input())\nA = [int(input()) for _ in range(N)]\n\nA = [0] + A\ni = 1\nk = 1\nwhile k <= N:\n if A[i] == 2:\n print(k)\n return\n i = A[i]\n k += 1\nprint((-1))\n", "N = int(input())\nnum_list = [int(input()) for _ in range(N)]\nnum = 0\nfor i in range(N):\n if num_list[num] == 2:\n print(i+1)\n return\n num = num_list[num]-1\nprint(-1)", "N=int(input())\na=[None]+[int(input()) for i in range(N)]\nc=1\n\nfor i in range(1, N+1):\n if a[c]==2:\n print(i)\n return\n else:\n c=a[c]+0\n \nprint(-1)", "n = int(input())\na = [0]*n\nfor i in range(n):\n a[i] = int(input())\n\n\nans = -1\nmemo = 0\nlight = 1\n\nfor i in range(n):\n if light == 2:\n ans = memo\n break\n light = a[light-1]\n memo += 1\n\n\nprint(ans)", "n = int(input())\na = [int(input()) for i in range(n)]\ncnt = 0\n\nif not a.count(2):\n print('-1')\nelse:\n i = 0\n while True:\n cnt += 1\n if a[i] == 2:\n print(cnt)\n break\n elif a[i] == i+1 or cnt > n:\n print('-1')\n break\n i = a[i]-1", "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 a = [I() - 1 for _ in range(N)]\n\n c = 0\n ans = 0\n is_ok = True\n while True:\n c = a[c]\n ans += 1\n if c == 0 or ans > N:\n is_ok = False\n break\n if c == 1:\n break\n\n if is_ok:\n print(ans)\n else:\n print(-1)\n\ndef __starting_point():\n resolve()\n__starting_point()", "#!/usr/local/bin/python3\n# https://atcoder.jp/contests/abc065/tasks/abc065_b\n\nN = int(input())\na = [int(input())-1 for _ in range(N)]\nans = 0\ncur = 0\n\nvisit = [-1] * N\nwhile True:\n # print(cur, visit)\n cur = a[cur]\n ans += 1\n if visit[cur] == -1:\n visit[cur] = ans\n else:\n print((-1))\n return\n if cur == 1:\n print(ans)\n return\n", "n = int(input())\na = [0]\nfor i in range(n):\n a.append(int(input()))\ncnt = 0\na_before = 1\nwhile cnt <= n:\n cnt += 1\n if a[a_before] == 2:\n print(cnt)\n break\n a_before = a[a_before]\nelse:\n print(-1)", "n = int(input())\nli = [0]\nfor i in range(n):\n li.append(int(input()))\n\ncount = 0\nnow = 1\nwhile now != 2:\n if li[now] == 0:\n count = -1\n break\n else:\n a = li[now]\n li[now] = 0\n now = a\n count += 1\n\nprint(count)", "n=int(input())\na=[int(input())-1 for _ in range(n)]\nid=[-1]*n\nx=0\nfor c in range(1,n+1):\n if id[x]!=-1:\n print(-1)\n return\n id[x]=c\n x=a[x]\n if x==1:\n print(c)\n return", "n = int(input())\n\na = [int(input()) for _ in range(n)]\na.insert(0,0)\n\npos = 1\nfor i in range(1,n+1):\n pos = a[pos]\n if pos==2:\n print(i)\n break\nif pos!=2:\n print((-1))\n", "n = int(input())\na = list(map(int, [input() for i in range(n)]))\nans = 1\nhikari = 1\nfor i in range(n):\n hikari = a[hikari -1]\n if hikari == 2:\n print(ans)\n return\n else:\n ans += 1\nprint(-1)", "n = int(input())\na = []\nfor i in range(n):\n a.append(int(input()))\n \na.insert(0, 0)\nans = -1\npush = 1\n\nfor i in range(1, n+2):\n \n if a[push] == 2:\n ans = i\n break\n \n else:\n push = a[push]\n \nprint(ans)", "n = int(input())\nal = [int(input()) for i in range(n)]\n\ni = 0\nfor j in range(n):\n i = al[i]-1\n if i == 1:\n print(j+1)\n return\nprint(-1)", "n = int(input())\n#x, 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)]\nal = []\nfor i in range(n):\n a = int(input())\n al.append(a)\n\nal.insert(0, 0)\nans = -1\npush = 1\nfor i in range(1, n+2):\n light = al[push]\n push = light\n if light == 2:\n ans = i\n break\nprint(ans)\n", "n=int(input())\na=[int(input()) for i in range(n)]\nans=1\nres=1\nfor i in range(n):\n if a[res-1]==2:\n print(ans)\n return\n else:\n ans+=1\n res=a[res-1]\nprint(-1)", "\ndef resolve():\n N = int(input())\n A = [ int(input()) for _ in range(N)]\n\n #print(N, A)\n\n next = 0\n cnt = 0\n for i in range(N):\n next = A[next] - 1\n #print(next)\n cnt += 1\n if next == 1:\n break\n\n if cnt == N:\n print(-1)\n else:\n print(cnt)\n\n\ndef __starting_point():\n resolve()\n__starting_point()", "N = int(input())\nA = [0] + [int(input()) for _ in range(N)]\n\nj = 1\ncnt = 0\ncheck = False\n\nfor i in range(N):\n if j == 2:\n check= True\n break\n cnt += 1\n j = A[j]\n \nprint(cnt if check else -1)", "# -*- coding: utf-8 -*-\n\nN = int(input())\na = []\nfor i in range(N):\n a.append(int(input()))\n\nans = pos = 0\nflag = [0] * N\nwhile True:\n ans += 1\n if a[pos] == 2:\n break\n #print(pos,a[pos]-1)\n pos = a[pos] - 1\n\n if flag[pos] > 0:\n ans = -1\n break\n else:\n flag[pos] = 1\n\nprint(ans)", "n = int(input())\nl = []\nfor i in range(n):\n a = int(input())\n l.append(a)\nx = l[0]\ncnt = 1\nfor i in range(n):\n if x == 2:\n print(cnt)\n return\n else:\n cnt +=1\n x = l[x-1]\nprint('-1')", "n = int(input())\nA = []\nbool = [True] * n\nfor i in range(n):\n a = int(input())\n a -= 1\n A.append(a)\nj = A[0]\ncnt = 1\nfor i in range(n):\n if j == 1:\n print(cnt)\n return\n if bool[A[j]] == True:\n bool[A[j]] = False \n j = A[j]\n cnt += 1\n else :\n print((-1))\n return\n\n\n", "n = int(input())\na = [int(input()) for _ in range(n)]\n# a = list(map(lambda x: int(x) - 1, a))\t#\u3059\u3079\u3066\u306e\u8981\u7d20\u304b\u3089-1\n\np = a[0]\n\nif p == 2:\n print(1)\n return\n \ncnt = 1\n\nfor _ in range(n):\n p = a[p-1]\n cnt += 1\n if p == 2:\n print(cnt)\n return\n\nprint(-1)", "import re\nimport copy\n\ndef accept_input():\n N = int(input())\n A = {}\n for i in range(1,N+1):\n A[i] = int(input())\n return N,A\n\ndef process(s):\n if s == \"#\":\n return 1\n else:\n return 0\nN,A = accept_input()\ncur = 1\nkaisu = 0\nfor _ in range(N):\n cur = A[cur]\n kaisu += 1\n if cur == 2:\n break\nif cur == 2:\n print(kaisu)\nelse:\n print((-1))\n", "N = int(input())\nd = []\nvisited = [False for _ in range(N+1)]\nfor _ in range(N):\n d.append(int(input())-1)\n\ni = 0\ncnt = 0\nwhile True:\n if i == 1:\n break\n elif cnt >= N:\n cnt = -1\n break\n elif visited[i]:\n cnt = -1\n break\n else:\n visited[i] = True\n cnt += 1\n i = d[i]\n \nprint(cnt)", "n = int(input())\na = [0] * n\nfor i in range(n):\n a[i] = int(input())\n\nvisit = set()\nnow = 1\nfor i in range(1, n + 10):\n if now not in visit:\n visit.add(now)\n now = a[now - 1]\n else:\n print((-1))\n break\n if now == 2:\n print(i)\n break\n", "n = int(input())\nline = [0]\nfor i in range(n):\n line.append(int(input()))\ncheck = [0 for i in range(n+1)]\ncount = 0\ncheck[1] = 1\na = 1\nwhile True:\n count += 1\n if line[a] == 2:\n break\n else:\n a = line[a]\n check[a] += 1\n \n if check[a] > 1:\n count = -1\n break\nprint(count)\n \n", "with open(0) as f:\n N, *a = map(int, f.read().split())\n\nfrom itertools import count\np = 0\nseen = {0}\nfor i in count(1,1):\n p = a[p]-1\n if p == 1:\n ans = i\n break\n if p in seen:\n ans = -1\n break\n seen.add(p)\nprint(ans)", "N = int(input())\na = [0,]\nfor i in range(N):\n a.append(int(input()))\nidx = 1\nfor i in range(1,N+1):\n idx = a[idx]\n if idx == 2:\n print(i)\n return\nprint(-1)", "N = int(input())\na = [int(input()) for _ in range(N)]\nlog = set()\ni = 0\ncount = 1\nwhile a[i] != 2:\n i = a[i] - 1\n if i in log:\n print(-1)\n break\n else:\n log.add(i)\n count += 1\nelse:\n print(count)", "#import sys\n#import numpy as np\nimport math\n#from fractions import Fraction\nimport itertools\nfrom collections import deque\nfrom collections import Counter\nimport heapq\nfrom fractions import gcd\n#input=sys.stdin.readline\n#import bisect\nfrom fractions import gcd\n\nn=int(input())\np=set()\np.add(0)\nai=[int(input()) for _ in range(n)]\ns=0\ncnt=0\nwhile True:\n a=ai[s]\n if a==2:\n print(cnt+1)\n return\n if a-1 not in p:\n p.add(a-1)\n cnt+=1\n s=a-1\n else:\n print(-1)\n return", "N = int(input())\n\nl = []\nfor i in range(N):\n v = int(input())\n l.append(v)\n \nv = l[0]\nans = 1\nwhile v != 2 and v != -1:\n tmp = l[v-1]\n l[v-1] = -1\n v = tmp\n ans += 1\n \nif v == 2:\n print(ans)\nelse: \n print(-1)", "import sys\nN = int(input())\nA ={}\nfor i in range(1,N+1):\n A[i] = int(input())\n#print(A)\nans = 1\nx = 1\nfor j in range(N):\n if A[x] == 2:\n print(ans)\n return\n x = A[x]\n ans += 1\nprint(-1)", "N = int(input())\nA = []\nfor i in range(N):\n a = int(input())\n A.append(a)\nb = 1\nx = A[0]\nwhile x != 2:\n x = A[x - 1]\n if b > N:\n print(-1)\n return\n b += 1\n\nprint(b)", "n = int(input())\nal = []\nfor i in range(n):\n a = int(input())\n al.append(a)\n \nal.insert(0, 0)\nans = -1\npush = 1\nfor i in range(1, n+2):\n light = al[push]\n push = light\n if light == 2:\n ans = i\n break\nprint(ans)", "def main():\n N = int(input())\n a = [int(input()) for _ in range(N)]\n cnt = 0\n tmp = 1\n while cnt<=100001:\n tmp = a[tmp-1]\n cnt += 1\n if tmp == 2:\n return cnt\n elif tmp == 1:\n return -1\n\n return -1\n\nprint((main()))\n", "n=int(input())\na=[int(input()) for i in range(n)]\nans=1\nres=1\nfor i in range(n):\n if a[res-1]==2:\n print(ans)\n return\n else:\n ans+=1\n res=a[res-1]\n\nprint(-1)", "N = int(input())\nA = []\nfor i in range(N):\n A.append(int(input())-1)\n \n#A.insert(0, 0)\nans = -1\npush = 0\n\nfor i in range(N+1):\n\n if A[push] == 1:\n ans = i+1\n break\n \n else:\n push = A[push]\n \nprint(ans)\n", "from typing import List\n\n\ndef answer(n: int, a: List[int]) -> int:\n next_value = 1\n count = 0\n for _ in range(n):\n next_value = a[next_value - 1]\n count += 1\n if next_value == 2:\n return count\n\n return -1\n\n\ndef main():\n n = int(input())\n a = [int(input()) for _ in range(n)]\n print((answer(n, a)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nbuttons = [int(input()) for _ in range(n)]\ndone = [0] * (n + 1)\nnext_button = buttons[0]\nfor _ in range(n):\n buttons_status = done[next_button]\n if buttons_status != 0:\n print((-1))\n return\n done[next_button] = 1\n if next_button == 2:\n break\n next_button = buttons[next_button - 1]\nprint((done.count(1)))\n", "LI = lambda: list(map(int, input().split()))\n\nN = int(input())\nA = [int(input()) for _ in range(N)]\n\n\ndef main():\n a = 1\n for i in range(N + 1):\n if a == 2:\n print(i)\n return 0\n a = A[a - 1]\n print((-1))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\na = []\ns = [0]*n\nx = 1\nfor i in range(n):\n a.append(int(input()))\nif 2 not in a:\n print(-1)\nelse:\n while True:\n if a[x-1] == 2:\n print(sum(s)+1)\n return\n else:\n s[x-1] += 1\n if s[x-1] == 2:\n print(-1)\n return\n x = a[x-1]", "n = int(input())\nbtn = [0]\nfor i in range(n):\n btn.append(int(input()))\nsee = [0 for i in range(n+1)]\n \nnow = 1\ncnt = 0\n\nsee[now] = 1\nwhile True:\n now = btn[now]\n cnt += 1\n \n if now == 2:\n print(cnt)\n break\n \n if see[now] == 1:\n print((-1))\n break\n \n see[now] = 1\n", "n = int(input())\na = [0] + [int(input()) for i in range(n)]\ncnt = 1\nnext_a = a[1]\n\nif a[1] == 2:\n print(cnt)\n\nelse:\n while cnt <= 10**5:\n next_a = a[next_a]\n cnt += 1\n if next_a == 2:\n break\n\n if cnt <= 10**5:\n print(cnt)\n else:\n print(-1)", "n = int(input())\nA = [int(input()) for _ in range(n)]\n\nnow = 0\ncnt = 0\nwhile A[now] != 2 and cnt <= n:\n now = A[now] - 1\n cnt += 1\n\nif A[now] == 2:\n print((cnt + 1))\nelse:\n print((-1))\n", "def f():\n n = int(input())\n a = [int(input()) for _ in range(n)]\n x = 1\n c = 0\n for i in range(n):\n if x != 2:\n x = a[x-1]\n c += 1\n if c == n:\n return -1\n else:\n return c\nprint(f())", "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()\na = [ri() for _ in range(n)]\nidx = 1\ncnt = 1\nif a[0] == 2:\n print((1))\n return\nwhile idx != -1:\n a[idx-1], idx = -1, a[idx-1]\n cnt += 1\n if a[idx-1] == 2:\n print(cnt)\n return\nprint((-1))\n\n\n\n\n\n\n\n\n\n\n", "import sys\nN = int(input())\na = [int(input()) for _ in range(N)]\nflag = [0]*N\nk = 0\ni = 0\nflag[0] = 1\nwhile k <N:\n k += 1\n i = a[i] - 1\n if flag[i] == 0:\n flag[i] = 1\n elif flag[i] == 1:\n print(-1)\n return\n if i == 1:\n print(k)\n return", "import sys\nN = int(input())\nd = [int(input()) for i in range(N)]\n\ncnt = 0\nbutton = d[0]\nwhile button != 2:\n button = d[button-1]\n cnt += 1\n\n if cnt > 100000:\n print(-1)\n return\n\nprint(cnt+1)", "N = int(input())\nL = []\nlight = [0]*(N)\nlight[0] = 1\ncnt, now = 0, 0\n\nfor i in range(N):\n L.append(int(input()))\n\nfor i in range(N):\n now = L[now] - 1\n cnt += 1\n if now == 1:\n print(cnt)\n return\n\nprint((-1))\n", "N = int(input())\nV = [int(input()) for i in range(1,N+1)]\ncnt = 1\nval = V[0]\nwhile True:\n if val == 2:\n print(cnt)\n break\n if (cnt >= N):\n print((-1))\n break\n cnt += 1\n val = V[val-1]\n", "n = int(input())\nal = list(int(input()) for _ in range(n))\nnum = [0]*n\ni = 0\ncnt = 0\nwhile True:\n if al[i] == 2:\n print((cnt+1))\n break\n else:\n if num[al[i]-1] == 1:\n print((-1))\n break\n else:\n num[al[i]-1] += 1\n i = al[i]-1\n cnt += 1\n", "n = int(input())\nA = [int(input()) for _ in range(n)]\n\nnow = 0\ncnt = 0\nwhile A[now] != 2 and cnt <= n:\n now = A[now] - 1\n cnt += 1\n\nif A[now] == 2:\n print((cnt + 1))\nelse:\n print((-1))\n", "N=int(input())\na=[]\nfor i in range(N):\n a.append(int(input())-1)\nflag=True\nstep=[]\npivot=0\nfor i in range(N+1):\n step.append(pivot)\n if a[pivot]==1:\n break\n pivot=a[pivot]\n\nif len(step)>N:\n print(-1)\nelse:\n print(len(step))", "N = int(input())\nA = [int(input())-1 for _ in range(N)]\ncnt = 1\nnext_button = 0\nwhile cnt <= len(A):\n next_button = A[next_button]\n if next_button == 1:\n print(cnt)\n return\n cnt += 1\nprint((-1))\n", "n = int(input())\nl = [0 for _ in range(n)]\nalready = set()\nnext = 1\nc = 0\nfor i in range(n):\n a = int(input())\n l[i] = a\nwhile c <= n:\n next = l[next-1]\n c += 1\n if next == 2:\n print(c)\n break\n elif next in already:\n print(-1)\n break\n already.add(next)", "n = int(input())\nbtn = {b+1: int(input()) for b in range(n)}\ncur = 1\ncnt = 0\nwhile cnt <= n and cur != 2:\n cur = btn[cur]\n cnt += 1\n if cur == 2:\n print(cnt)\n return\nprint(-1)", "N = int(input())\na = tuple(int(input()) for _ in range(N))\nlog = set()\ni = 0\ncount = 1\nwhile a[i] != 2:\n i = a[i] - 1\n if i in log:\n print(-1)\n break\n else:\n log.add(i)\n count += 1\nelse:\n print(count)", "import sys\nimport cProfile\ninput = sys.stdin.readline\ndef main():\n n=int(input())\n a=[int(input()) for _ in range(n)]\n l=[1]\n i=0\n aa=1\n while True:\n aa=a[aa-1]\n if aa == 2:\n print(i+1)\n return\n if i>n:\n print(-1)\n return\n i+=1\nmain()", "n = int(input())\na = [0] * n\nfor i in range(n):\n a[i] = int(input())\n\nnow = 1\nfor i in range(1, n + 10):\n now = a[now - 1]\n if now == 2:\n print(i)\n break\nelse:\n print((-1))\n", "n = int(input())\na = [int(input()) for i in range(n)]\ncnt = 0\n\nif 2 not in a:\n print(-1)\n return\n\nx = 1\nfor i in range(n-1):\n \n x = a[x-1]\n cnt += 1\n\n \n if x == 2:\n print(cnt)\n return\n\nprint(-1)", "N = int(input())\n\nbuttons = []\nfor _ in range(N):\n buttons.append(int(input()))\n\ns = 1\ncnt = 0\nwhile True:\n s = buttons[s-1]\n cnt += 1\n if s == 2:\n break\n elif cnt > N:\n cnt = -1\n break\n\nprint(cnt)", "n = int(input())\ndata = [int(input()) for i in range(n)]\ncount = 0\ntemp = 1\nfor i in range(n):\n temp = data[temp-1]\n count += 1\n if temp == 2:\n print(count)\n break\nelse:\n print(-1)", "n=int(input())\nl=[int(input()) for i in range(n)]\n\nnum=l[0]\ncnt=0\nfor i in range(10**5):\n if num==2:\n cnt+=1\n break\n else:\n num=l[num-1]\n cnt+=1\n \nif cnt==10**5:\n cnt=-1\n \nprint(cnt)", "N = int(input())\na = []\nfor i in range(N):\n a.append(int(input()))\n\nx = 1\nSum = 0\nwhile x != 2 and Sum < N:\n x = a[x - 1]\n Sum += 1\n\nif Sum >= N:\n print(-1)\nelse:\n print(Sum)", "n = int(input())\na = [0] * n\nfor i in range(n):\n a[i] = int(input())\n\ncounter = 0\nnow = 1\nvisit = [False] * n\nvisit[0] = True\nwhile True:\n counter += 1\n if a[now - 1] == 2:\n print(counter)\n break\n elif visit[a[now - 1]-1] == True:\n print((-1))\n break\n else:\n visit[a[now - 1]-1] = True\n now = a[now - 1]\n"]
{"inputs": ["3\n3\n1\n2\n", "4\n3\n4\n1\n2\n", "5\n3\n3\n4\n2\n4\n"], "outputs": ["2\n", "-1\n", "3\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
29,904
87c32618281eea09249e1c7d6fadfba5
UNKNOWN
You are playing the following game with Joisino. - Initially, you have a blank sheet of paper. - Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times. - Then, you are asked a question: How many numbers are written on the sheet now? The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game? -----Constraints----- - 1≀N≀100000 - 1≀A_i≀1000000000(=10^9) - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N A_1 : A_N -----Output----- Print how many numbers will be written on the sheet at the end of the game. -----Sample Input----- 3 6 2 6 -----Sample Output----- 1 The game proceeds as follows: - 6 is not written on the sheet, so write 6. - 2 is not written on the sheet, so write 2. - 6 is written on the sheet, so erase 6. Thus, the sheet contains only 2 in the end. The answer is 1.
["n=int(input())\nd=dict()\nfor _ in range(n):\n hoge=int(input())\n if d.get(hoge,0)==0:\n d[hoge]=1\n else:\n d[hoge]+=1\nans=0\nfor i in d.values():\n if i%2==1:\n ans+=1\nprint(ans)", "import collections\n\nn = int(input())\narr = [int(input()) for _ in range(n)]\n\nc = collections.Counter(arr)\nans = 0\nfor v in c.values():\n if v % 2:\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())\nn = I()\ndic = defaultdict(int)\nfor i in range(n):\n a = I()\n dic[a] += 1\nans = 0\nfor k,v in list(dic.items()):\n ans += v%2\nprint(ans)\n", "N = int(input())\nA = [int(input()) for _ in range(N)]\n\nd = {}\n#key\u8a2d\u5b9a\nfor i in A:\n d[i]=0\n#\u6570\u5b57key\u304c\u5076\u6570\u56de\u51fa\u305f\u30890,\u5947\u6570\u56de\u51fa\u305f\u30891\u306b\u306a\u308b\u3088\u3046\u306bvalue\u3092\u8a2d\u5b9a\nfor i in A:\n if d[i]==1:\n d[i]=0\n else:\n d[i]=1\n \nprint(sum(d.values()))", "from collections import Counter\nN=int(input())\nA=[int(input()) for i in range(N)]\n\ncnt=Counter(A)\nans=0\nfor k,v in cnt.items():\n if v%2==1:\n ans+=1\n\nprint(ans)", "N = int(input())\nA = [int(input()) for _ in range(N)]\n\nc = {}\nans = 0\n\nfor i in A:\n if i not in c.keys():\n c[i] = 0\n c[i] += 1\n \nfor j in c.values():\n if j % 2 ==1:\n ans += 1\n\n#print(A)\n#print(c)\nprint(ans)", "import collections\nn = int(input())\nl = list(int(input()) for i in range(n))\nd = collections.Counter(l)\nans = 0\nfor v in d.values():\n ans += v % 2\nprint(ans)", "N = int(input())\nA = [0]*N\n\nfor i in range(N):\n A[i] = int(input())\n\nA.sort()\n\ncount = 1\nans = 0\nfor i in range(N-1):\n if A[i] == A[i+1]:\n count+=1\n else:\n ans+=count%2\n count=1\n\nans+=count%2\n\nprint(ans)", "# -*- coding: utf-8 -*-\n\nN =int(input())\nA = {}\nfor i in range(N):\n val = int(input())\n if val in A:\n A[val] += 1\n else:\n A[val] = 1\n\nans = 0\nfor k, v in A.items():\n if v % 2 != 0:\n ans += 1\n\nprint(ans)", "from collections import Counter\nn = int(input())\nans = 0\nC = Counter(int(input()) for _ in range(n))\nfor c in list(C.values()):\n if c % 2 == 1:\n ans += 1\nprint(ans)\n", "from sys import stdin, stdout # only need for big input\n\n\ndef solve():\n n = int(input())\n st = set()\n for _ in range(n):\n a = int(input())\n if a in st:\n st.remove(a)\n else:\n st.add(a)\n print(len(st))\n\ndef main():\n solve()\n\n\ndef __starting_point():\n main()\n__starting_point()", "from collections import Counter\n\nn = int(input())\nA = [int(input()) for _ in range(n)]\ncnt_A = Counter(A)\n\nans = 0\nfor v in cnt_A.values():\n if v % 2 == 1:\n ans += 1\nprint(ans)", "from collections import defaultdict\n\nd = defaultdict(int)\n\nn = int(input())\nfor i in range(n):\n a = int(input())\n d[a] = int(not(d[a]))\nans=0\nfor k,v in d.items():\n if v == 1:\n ans += 1\n\nprint(ans)", "n = int(input())\nkami = set()\n\nfor i in range(n) :\n a = int(input())\n if a in kami :\n kami.remove(a)\n else :\n kami.add(a)\n\nprint((len(kami)))\n", "import collections\nn=int(input())\na=[int(input()) for i in range(n)]\nprint(sum([i%2==1 for i in collections.Counter(a).values()]))", "# coding: utf-8\n\n\ndef main():\n N = int(input())\n ans = 0\n dic = {}\n for _ in range(N):\n a = int(input())\n if a not in list(dic.keys()):\n dic[a] = 1\n ans += 1\n elif dic[a] == 0:\n dic[a] += 1\n ans += 1\n else:\n dic[a] -= 1\n ans -= 1\n\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "N = int(input())\nans = {}\nfor i in range(N):\n A = input()\n if A in ans:\n ans[A] += 1\n else:\n ans[A] = 1\nc = 0\nfor i in ans:\n if ans[i] % 2 == 1:\n c += 1\nprint(c)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 23 16:50:38 2020\n\n@author: liang\n\"\"\"\nN = int(input())\nd = dict()\nans = 0 \nA = [int(input()) for _ in range(N)]\nfor a in A:\n if a in d:\n d[a] += 1\n else:\n d[a] = 1\n#print(d)\nfor key in d.keys():\n if d[key] %2 ==1:\n ans += 1\n d[key] = 0\n#print(d)\nprint(ans)", "from collections import Counter\nN = int(input())\nA = [int(input()) for _ in range(N)]\ncnt = dict(Counter(A))\nans = []\nfor k, v in list(cnt.items()):\n if v % 2 != 0:\n ans.append(k)\nprint((len(ans)))\n", "from collections import Counter\n\nN = int(input())\nA = [int(input()) for _ in range(N)]\n\nprint(sum(c%2 for c in Counter(A).values()))", "import collections\n\nn = int(input())\na = [int(input()) for _ in range(n)]\nc = collections.Counter(a)\n\ncnt = 0\nfor x in c.values():\n if x % 2 == 1:\n cnt += 1\nprint(cnt)", "N = int(input())\nA = [int(input()) for _ in range(N)]\n\ndic = {}\n\nfor i in range(N):\n if A[i] in dic.keys():\n dic[A[i]] += 1\n else:\n dic[A[i]] = 1\n \ncnt = 0\n\nfor j in dic.keys():\n if dic[j] % 2 == 1:\n cnt += 1\n \nprint(cnt)", "# 20\nn = int(input())\na = {}\ncnt = 0\n\nfor i in range(n):\n num = int(input())\n a[num] = a.get(num,0)+1\n a[num] %= 2\n \nfor i in a.values():\n cnt += i\n\n\n\nprint(cnt)", "import collections \nN = int(input())\nlsA = []\nfor i in range(N):\n lsA.append(int(input()))\ncounterA = collections.Counter(lsA)\nans = 0\nfor i in counterA.values():\n ans += i%2\nprint(ans)", "N = int(input())\nnumbers = {}\nfor i in range(N):\n x = int(input())\n if x in numbers:\n del numbers[x]\n else:\n numbers[x] = 1\nprint(len(numbers))", "n = int(input())\nli = set()\n\nfor i in range(n):\n x = int(input())\n if x in li:\n li.remove(x)\n else:\n li.add(x)\nprint((len(li)))\n", "n = int(input())\na = list()\nfor i in range(n):\n a.append(int(input()))\nimport collections\nb = collections.Counter(a)\nc = list(map(lambda x: x%2, list(b.values())))\nprint(c.count(1))", "N = int(input())\nS = set()\nfor _ in range(N):\n a = int(input())\n if a in S:\n S.remove(a)\n else:\n S.add(a)\n \nprint((len(S)))\n", "n = int(input())\na = []\nfor i in range(n):\n a.append(int(input()))\na.sort()\njud = 1\nq = a[0]\nans = 0\nfor i in range(1,n):\n if(q==a[i]):\n jud += 1\n else: \n if(jud%2==1):\n ans += 1\n jud = 1\n q = a[i]\nif (jud%2==1):\n ans += 1\nif(n==1):\n ans = 1\nprint(ans)\n", "from collections import Counter\nn = int(input())\na = []\nfor i in range(n):\n a.append(int(input()))\na = dict(Counter(a))\ncount = 0\nfor i in a.values():\n if i % 2 == 1:\n count += 1\nprint(count)", "#!/usr/bin/env python\n\nn = int(input())\na = [int(input()) for _ in range(n)]\n\nd = {}\nfor i in range(n):\n if a[i] not in d:\n d[a[i]] = 1 \n else:\n d[a[i]] += 1\n\nans = 0 \nfor s in list(d.values()):\n if s%2 == 1:\n ans += 1\n\nprint(ans)\n", "n=int(input())\ns=set()\nfor i in range(n):\n a=int(input())\n if a in s:\n s.remove(a)\n else:\n s.add(a)\nprint(len(s))", "N = int(input())\nA = [int(input()) for _ in range(N)]\ndic = {num: 0 for num in set(A)}\nfor i in range(N):\n dic[A[i]] = 1 if dic[A[i]]==0 else 0\nans = 0\nfor num in set(A):\n ans += dic[num]\nprint(ans)", "N = int(input())\nnum = {}\nfor i in range(N):\n A = int(input())\n if A in list(num.keys()):\n num[A] += 1\n else:\n num[A] = 1\nans = 0\nfor i, j in list(num.items()):\n if j%2 == 1:\n ans += 1\nprint(ans)\n", "n = int(input())\npaper = dict()\nfor i in range(n):\n a = int(input())\n if a not in paper:\n paper[a] = 1\n else:\n paper.pop(a)\n\nres = 0\nfor value in list(paper.values()):\n if value == 1:\n res += 1\nprint(res)\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()\nl = [int(input()) for _ in range(N)]\n\nc = Counter(l)\n\nans = 0\nfor i, j in zip(list(c.keys()), list(c.values())):\n if j % 2 != 0:\n ans += 1\n\nprint(ans)\n", "import collections\nn = int(input())\nalist = [int(input()) for i in range(n)]\ncole = collections.Counter(alist)\ncount = 0\nfor i in cole.values():\n if i%2==1:\n count+=1\nprint(count)", "n = int(input())\nA = [int(input()) for _ in range(n)]\na = sorted(A)\ni = 0\nans = 0\nwhile i < n:\n if i == 0:\n if a[0] == a[1]:\n cnt = 2\n i = 2\n while i < n and a[i-1] == a[i]:\n cnt += 1\n i += 1\n ans += cnt%2\n else:\n ans += 1\n cnt = 1\n i = 2\n while i < n and a[i-1] == a[i]:\n cnt += 1\n i += 1\n ans += cnt%2\n else:\n cnt = 1\n i += 1\n while i < n and a[i-1] == a[i]:\n cnt += 1\n i += 1\n ans += cnt%2\nprint(ans)", "n = int(input())\na = [int(input()) for _ in range(n)]\ns = set()\nfor x in a:\n if x in s:\n s.remove(x)\n else:\n s.add(x)\nprint(len(s))", "from collections import defaultdict\nd = defaultdict(int)\nn = int(input())\nfor i in range(n):\n a = int(input())\n if d[a] > 0:\n d[a] -= 1\n else:\n d[a] += 1\n\nans = 0\nfor v in list(d.values()):\n if v > 0:\n ans += 1\nprint(ans)\n", "P = set()\nN = int(input())\nfor i in range(N):\n A = int(input())\n if A in P:\n P.remove(A)\n else:\n P.add(A)\nprint(len(P))", "n=int(int(input()))\ns=set()\nfor i in range(n):\n s^= set([input()])\nprint(len(s))", "import sys\nmod=10**9+7 ; inf=float(\"inf\")\nfrom math import sqrt, ceil\nfrom collections import deque, Counter, defaultdict #\u3059\u3079\u3066\u306ekey\u304c\u7528\u610f\u3055\u308c\u3066\u308b defaultdict(int)\u3067\u521d\u671f\u5316\ninput=lambda: sys.stdin.readline().strip()\nsys.setrecursionlimit(11451419)\nfrom decimal import ROUND_HALF_UP,Decimal #\u5909\u63db\u5f8c\u306e\u672b\u5c3e\u6841\u30920\u30840.01\u3067\u6307\u5b9a\n #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))\nfrom functools import lru_cache\nfrom bisect import bisect_left as bileft, bisect_right as biright\n#\u30e1\u30e2\u5316\u518d\u5e30def\u306e\u5192\u982d\u306b\u6bce\u56de @lru_cache(maxsize=10**10)\n#\u5f15\u6570\u306blist\u306f\u3060\u3081\n#######\u3053\u3053\u307e\u3067\u30c6\u30f3\u30d7\u30ec#######\n#\u30bd\u30fc\u30c8\u3001\"a\"+\"b\"\u3001\u518d\u5e30\u306a\u3089Python3\u306e\u65b9\u304c\u3044\u3044\n#######\u3053\u3053\u304b\u3089\u5929\u3077\u3089########\n\nn=int(input())\nA=[int(input()) for i in range(n)]\nC=Counter(A)\nprint(len([i for i in C.values() if i%2==1]))", "import collections\nn = int(input())\naa = [int(input()) for a in range(n)]\n\ncaa = collections.Counter(aa) # couter aa\ncnt = 0\nlaa = [x[1] for x in caa.items()]\nfor la in laa:\n if la % 2 == 1:\n cnt += 1\nprint(cnt)", "n = int(input())\nA = {}\nfor i in range(n):\n a = int(input())\n A[a] = A.get(a, 0)+1\n A[a] %= 2\ns = 0\nfor v in list(A.values()):\n s += v\nprint(s)\n", "N=int(input())\nA=dict()\nfor _ in range(N):\n a=int(input())\n if a not in A:\n A[a]=0\n A[a]=1-A[a]\nprint((sum(A.values())))\n", "import collections\na = int(input())\ns = [input() for i in range(a)]\nc = collections.Counter(s)\nb = []\nfor myvalue in list(c.values()):\n b.append(myvalue)\n\nd = len(b)\nans = int(0)\nfor i in range(int(d)):\n if b[i] % 2 == 0:\n pass\n else:\n ans += 1\n \nprint(ans)\n \n", "n=int(input())\na=[]\nfor i in range(n):\n a.append(int(input()))\na=sorted(a)\nans=0\ncnt=1\nfor i in range(n-1):\n\n if a[i]==a[i+1]:\n cnt+=1\n else:\n if cnt%2==1:ans+=1\n cnt=1\nif cnt%2==1:ans+=1\nprint(ans)\n", "N=int(input())\nA=[]\nfor n in range(N):\n A.append(int(input()))\n\nA.sort()\n\ncnt=1\nans=0\nfor n in range(1,N):\n if A[n]==A[n-1]:\n cnt+=1\n else:\n if cnt%2==1:\n ans+=1\n cnt=1\n if n==N-1 and cnt%2==1:\n ans+=1\nprint(ans)", "#!/usr/bin/env python3\nimport sys\n\n\ndef solve(N: int, A: \"List[int]\"):\n from collections import Counter \n return sum([x%2==1 for x in list(Counter(A).values())])\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()", "import collections\nn = int(input())\nx = [int(input()) for i in range(n)]\nc = collections.Counter(x)\ncc = list(c.values())\ncnt = 0\nfor i in range(len(cc)):\n if cc[i] % 2 == 1:\n cnt += 1\nprint(cnt)", "from collections import Counter\nn = int(input())\na = [int(input()) for i in range(n)]\nc = Counter(a).values()\nans = 0\nfor i in c:\n if i % 2 == 1:\n ans += 1\nprint(ans)", "n=int(input())\na={}\nfor i in range(n):\n a_=int(input())\n if a_ not in a:\n a[a_]=1\n else:\n a[a_]+=1\nans=0\nfor i in a:\n if a[i]%2==1:\n ans+=1\nprint(ans)", "#20 C - Write and Erase\nN = int(input())\nA = [int(input()) for _ in range(N)]\n\npaper = set()\nfor a in A:\n if not(a in paper):\n paper.add(a)\n else:\n paper.remove(a)\nprint(len(paper))", "n = int(input())\nsum = 0\nnums = {}\n\nfor _ in range(n):\n a = input()\n if a not in nums:\n nums[a] = 1\n else:\n nums[a] += 1\n\nfor i in list(nums.values()):\n sum += i % 2\n\nprint(sum)\n", "N, *A = map(int, open(0).read().split())\n\nimport collections\n\nc = collections.Counter(A)\n\nprint(sum([1 for x in c.values() if x%2==1]))", "n=int(input())\na=set()\nfor i in range(n):\n x=int(input())\n if x in a:\n a.discard(x)\n else:\n a.add(x)\n\nprint(len(a))", "N=int(input())\nd={}\nfor _ in range(N):\n a=int(input())\n if a in d:\n d[a]+=1\n else:\n d[a]=1\nans=0\nfor k,v in d.items():\n ans+=v%2\nprint(ans)", "N = int(input())\nA = [0] * N\nfor i in range(N):\n A[i] = int(input())\n\nfrom collections import Counter\nc = Counter(A)\ncc = list(c.values())\nans = 0\nfor i in range(len(cc)):\n if cc[i] % 2 == 1:\n ans += 1\n\nprint(ans)", "n=int(input())\nd={}\nfor i in range(n):\n A=int(input())\n if A not in d:\n d[A]=1\n elif d[A]==1:\n d[A]=0\n else:\n d[A]=1\nprint(sum(d.values()))", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 23 16:58:10 2020\n\n@author: liang\n\"\"\"\n\n\n\"\"\"\n\u3010\u30d1\u30c7\u30a3\u30f3\u30b0\u306f\u30bd\u30fc\u30c8\u5f8c\u3011\n\"\"\"\nN = int(input())\nA = [int(input()) for _ in range(N)]\nA.sort()\nA += [-1]\nans = 0\ncount = 1\nfor i in range(N):\n #print(count)\n if A[i] == A[i+1]:\n #print(\"A\")\n count += 1\n else:\n #print(\"B\")\n if count%2 == 1:\n ans += 1\n count = 1\nprint(ans)", "import collections\nn=int(input())\na=[]\nfor i in range(n):\n A=int(input()) \n a.append(A)\nc=collections.Counter(a)\nans=0\nfor i in c:\n if c[i]%2==1:\n ans+=1\nprint(ans)", "n=int(input())\n\ncount_dict={}\n\nfor i in range(n):\n new=int(input())\n if new in count_dict:\n count_dict[new]+=1\n else:\n count_dict[new]=1\nans=0\nfor i in count_dict.values():\n if i%2==1:\n ans+=1\nprint(ans)", "N = int(input())\ndic = {}\n\nfor i in range(N):\n a = int(input())\n \n if a not in dic:\n dic[a] = 1\n else:\n del dic[a]\n\nprint(len(dic))", "import collections\nN = int(input())\nA = []\nfor _ in range(N):\n A.append(int(input()))\n \ncnt = collections.Counter(A)\nans = 0\nfor v in cnt.values():\n if v % 2 != 0:\n ans += 1\n \nprint(ans)", "N = int(input())\nA = [int(input()) for i in range(N)]\nA.sort()\n\nans = 0\ncnt = 1\nfor i in range(1, N):\n if A[i] == A[i-1]:\n cnt += 1\n else:\n if cnt % 2 != 0:\n ans += 1\n cnt = 1\nif cnt % 2 != 0:\n ans += 1\nprint(ans)", "def main():\n n = int(input())\n ans = set()\n for _ in range(n):\n a = int(input())\n if a in ans:\n ans.discard(a)\n else:\n ans.add(a)\n\n print((len(ans)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import collections\nN=int(input())\nA=[]\n\nfor i in range(N):\n A.append(int(input()))\n\ncc=collections.Counter(A)\nans=0\nfor nums in list(cc.values()):\n if nums%2==1:\n ans+=1\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()\ncnt = 0\nfor v in list(collections.Counter([ri() for _ in range(n)]).values()):\n if v&1:\n cnt += 1\nprint(cnt)\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "n = int(input())\na = []\n\nfor i in range(n):\n a.append(int(input()))\n\na = sorted(a)\n\nhoge = 0\nfoo = 0\nans = 0\n\nfor i in range(n):\n if i == 0:\n foo = a[i]\n hoge = 1\n elif i == n-1:\n if foo != a[i]:\n if hoge == 1:\n ans += 1\n ans += 1\n else:\n if hoge == 0:\n ans += 1\n elif foo == a[i]:\n hoge = 1-hoge\n else:\n if hoge == 1:\n ans += 1\n foo = a[i]\n hoge = 1\n\nprint(ans)\n", "import collections\nn=int(input())\na=[0]*n\nans=0\nfor i in range(n):\n a[i]=input()\nc=collections.Counter(a)\nl=list(set(a))\nfor i in range(len(l)):\n if c[l[i]]%2==1:\n ans+=1\nprint(ans)", "N = int(input())\nA = [int(input()) for _ in range(N)]\n\nA.sort()\n\nans = 0\nprev = -1\ncnt = 0\nfor a in A:\n if a == prev:\n cnt += 1\n else:\n ans += cnt % 2\n prev = a\n cnt = 1\nelse:\n ans += cnt % 2\n\nprint(ans)", "import collections\nimport numpy as np\nn = int(input())\na = []\nfor _ in range(n):\n a.append(int(input()))\nans = collections.Counter(a)\nc=list(ans.values())\nc=np.array(c)\nprint(sum(c%2))", "from collections import defaultdict\n\n\nN, *A = list(map(int, open(0).read().split()))\nans = defaultdict(int)\nfor a in A:\n ans[a] += 1\nprint((sum(v % 2 for v in list(ans.values()))))\n", "import sys\ndef IS(): return sys.stdin.readline().rstrip()\ndef II(): return int(IS())\nfrom functools import partial, reduce\nfrom collections import Counter\n\n\ndef f_chain(*args):\n return reduce(lambda x, f: f(x), args)\n\ndef main():\n n = II()\n aa = [II() for _ in range(n)]\n c_cnt = Counter(aa).values()\n f_chain(c_cnt,\n partial(map, lambda x: 1 if x%2==1 else 0),\n sum,\n print)\n\ndef __starting_point():\n main()\n__starting_point()", "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\ndef main():\n n = i_input()\n dic = {}\n for i in range(n):\n a = i_input()\n dic[a] = dic.get(a,0) + 1\n\n ans = 0\n\n for i,k in list(dic.items()):\n if k % 2 == 1:\n ans += 1\n print(ans)\n\n\n\n\n\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import collections\na=int(input())\nb=[int(input()) for i in range(a)]\n\nn=collections.Counter(b)\nm,ans=zip(*n.most_common())\nans=[i for i in ans if i%2==1]\nprint(len(ans))", "N = int(input())\nA = [int(input()) for c in range(N)]\nA = sorted(A)\n\ntmp = 1\ncnt = 0\nfor i in range(N): \n if i+1<N:\n if A[i] == A[i+1]:\n tmp += 1\n else:\n cnt += tmp%2\n tmp = 1\n else:\n cnt += tmp%2\n\nprint(cnt)\n", "n = int(input())\ncnt_l = {}\nfor _ in range(n):\n a = int(input())\n if a in cnt_l:\n cnt_l[a] ^= 1\n else:\n cnt_l[a] = 1\nprint((sum(cnt_l.values())))\n", "n = int(input())\nlis = [0]*n\nfor i in range(n):\n lis[i] = int(input())\n\nimport collections\n\nans = 0\nlis = collections.Counter(lis)\n\nfor i in lis.values():\n if i%2 == 1:\n ans += 1\n\nprint(ans)", "N = int(input())\nA = [int(input()) for _ in range(N)]\nA.sort()\n\ni = 0\nans = 0\nwhile i < N:\n tmp = A[i]\n count = 0\n while i < N and A[i] == tmp:\n count += 1\n i += 1\n ans += count % 2\n\nprint(ans)\n", "N = int(input())\nA = []\ncount = 1\nans = 0\n\nfor _ in range(N):\n A.append(int(input()))\n\nA.sort()\n\nfor i in range(N-1):\n if A[i] == A[i+1]:\n count += 1\n else:\n if count%2 == 1:\n ans += 1\n count = 1\nelse:\n if count%2 == 1:\n ans += 1\n else:\n count = 1\n\nprint(ans)", "from collections import Counter\nprint(sum(x % 2 for x in Counter([int(input())\n for _ in range(int(input()))]).values()))", "import sys\ninput = sys.stdin.readline\nn = int(input())\na = [int(input()) for _ in range(n)]\n\nimport collections\nc = collections.Counter(a)\ncnt = 0\n\nfor i,v in list(c.items()):\n if v%2 != 0:\n cnt += 1\nprint(cnt)\n", "from collections import Counter\n\nn = int(input())\nal = list(int(input()) for _ in range(n))\nc = Counter(al)\nans = 0\nfor k, v in c.items():\n if v%2 != 0:\n ans += 1\n\nprint(ans)", "from collections import Counter\nwith open(0) as f:\n N, *A = map(int, f.read().split())\nans = sum(1 for v in Counter(A).values() if v&1)\nprint(ans)", "n = int(input())\nal = []\nfor i in range(n):\n al.append(int(input()))\n\nal.sort()\nal.append(10**9+1)\ncnt = 1\nans = 0\nfor j in range(n):\n if al[j] == al[j+1]:\n cnt += 1\n elif cnt%2 == 0:\n cnt = 1\n elif cnt%2 == 1:\n cnt = 1\n ans += 1\nprint(ans)", "import collections\nn=int(input())\nl = [input() for i in range(n)]\nc = collections.Counter(l)\nans = 0\n\nfor x,y in c.items():\n if y%2 != 0:\n ans += 1\nprint(ans)", "n = int(input())\na = [int(input()) for _ in range(n)]\nimport collections\ncnt = 0\nb = collections.Counter(a)\nfor k in b:\n if b[k]%2==1:\n cnt +=1\nprint(cnt)", "from collections import Counter\n\n\ndef main():\n n = int(input())\n data =Counter(int(input()) for _ in range(n))\n ans = sum(num % 2 != 0 \n for num in data.values()\n )\n print(ans)\n\n\nmain()", "from collections import Counter\nn = int(input())\na = Counter([input() for _ in range(n)])\nans = 0\nfor x in a.values():\n if x%2!=0: ans += 1\nprint(ans)", "from collections import Counter\n\nn=int(input())\nl=[int(input()) for i in range(n)]\n\nl=Counter(l)\n\ncnt=0\n\nfor i in list(l.values()):\n if i%2==0:\n cnt+=1\n \nprint((len(l)-cnt))\n", "N = int(input())\npaper = set([])\n\nfor _ in range(N):\n a = int(input())\n if a in paper:\n paper.discard(a)\n else:\n paper.add(a)\n \nprint((len(paper)))\n", "from collections import defaultdict\nn = int(input())\nli = []\ns = set()\nfor val in range(n):\n i = int(input())\n if i in s:\n s.remove(i)\n else:\n s.add(i)\n\nprint(len(s))", "import sys\n## io ##\ndef IS(): return sys.stdin.readline().rstrip()\ndef II(): return int(IS())\ndef MII(): return list(map(int, IS().split()))\nfrom functools import partial, reduce\nfrom collections import Counter\n#======================================================#\ndef f_chain(*args):\n return reduce(lambda x, f: f(x), args)\ndef is_odd(n):\n return n%2==1\n\ndef main():\n n = II()\n aa = [II() for _ in range(n)]\n c = Counter(aa)\n f_chain(c.values(),\n partial(filter, is_odd),\n list,\n len,\n print,\n )\n\ndef __starting_point():\n main()\n__starting_point()", "n=int(int(input()))\ns=set()\nfor i in range(n):\n s^= {input()}\nprint(len(s))", "\nfrom collections import Counter\n\nN = int(input())\nA = [int(input()) for _ in range(N)]\n\nL = Counter(A)\n\nprint(sum( 1 for c in L.values() if c%2 ))", "n = int(input())\n\nd = {}\nfor i in range(n):\n a = int(input())\n if a in d:\n d[a] ^= 1\n else:\n d[a] = 1\nprint(sum(d.values()))", "N = int(input())\nA = [int(input()) for _ in range(N)]\n\npaper = set()\nfor a in A:\n if a in paper:\n paper.remove(a)\n else:\n paper.add(a)\nans = len(paper)\nprint(ans)", "import collections\nn=int(input())\na=[int(input()) for _ in range(n)]\nb=collections.Counter(a)\nans=0\nfor i in b.keys():\n if b[i]%2:\n ans+=1\nprint(ans)"]
{"inputs": ["3\n6\n2\n6\n", "4\n2\n5\n5\n2\n", "6\n12\n22\n16\n22\n18\n12\n"], "outputs": ["1\n", "0\n", "2\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
27,440
7e6fd9813d500d808571b1963313dda5
UNKNOWN
Takahashi has N balls. Initially, an integer A_i is written on the i-th ball. He would like to rewrite the integer on some balls so that there are at most K different integers written on the N balls. Find the minimum number of balls that Takahashi needs to rewrite the integers on them. -----Constraints----- - 1 \leq K \leq N \leq 200000 - 1 \leq A_i \leq N - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N K A_1 A_2 ... A_N -----Output----- Print the minimum number of balls that Takahashi needs to rewrite the integers on them. -----Sample Input----- 5 2 1 1 2 2 5 -----Sample Output----- 1 For example, if we rewrite the integer on the fifth ball to 2, there are two different integers written on the balls: 1 and 2. On the other hand, it is not possible to rewrite the integers on zero balls so that there are at most two different integers written on the balls, so we should print 1.
["n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nfrom collections import Counter\ndic=Counter(a)\ndic=sorted(list(dic.items()),key=lambda x:x[1])\n\nans=0\ncnt=0\nl=max(len(dic)-k,0)\nfor i in dic:\n if cnt==l:\n break\n ans=ans+i[1]\n cnt=cnt+1\nprint(ans)\n", "N, K = map(int,input().split())\nA = list(map(int,input().split()))\n\nimport collections\n\ncA = collections.Counter(A)\n\nsorted_ls = sorted(list(cA.values()))\nsum_ls = sum(sorted_ls)\n\n\nif len(sorted_ls)>K:\n print(sum(sorted_ls[:len(sorted_ls)-K]))\nelse:\n print(0)", "import collections as c\nn,k=map(int,input().split());a=c.Counter(map(int,input().split()))\nprint([0,sum(sorted([*a.values()])[:len(a)-k])][len(a)>k])", "from collections import Counter\n\nn, k = list(map(int, input().split()))\nctr = Counter(list(map(int, input().split())))\n\naa = sorted(list(ctr.items()), key=lambda x: x[1])\nif len(aa) <= k:\n print((0))\nelse:\n print((sum([x[1] for x in aa[:len(aa) - k]])))\n", "from collections import Counter\n\nn, k = map(int, input().split())\ns = list(map(int, input().split()))\n\nnum = Counter(s)\n\n\nif len(num) <= k:\n print(0)\n\nelse:\n cnt = len(num) - k\n ans = 0\n i = 0\n for v in sorted(num.values()):\n if cnt == i:\n break\n ans += v\n i += 1\n\n print(ans)", "import collections\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\n\nvalues,counts = zip(*collections.Counter(A).most_common())\nans = 0\n\nB = counts[K:]\n\nfor i in B:\n ans += i\nprint(ans)", "from collections import Counter, deque\n\n_, k = map(int, input().split())\na = [int(i) for i in input().split()]\n\nans = 0\nd = deque(sorted(Counter(a).values()))\nwhile k < len(d):\n ans += d.popleft()\nelse:\n print(ans)", "import collections\n\nn, k = map(int,input().split())\na = list(map(int, input().split()))\n\nc = collections.Counter(a)\ni = 0\ncnt = 0\nfor key, val in sorted(c.items(), key=lambda x: -x[1]):\n # print(key, val)\n cnt += val\n i += 1\n if i >= k:\n break\n \nprint(n - cnt)", "import operator\nn,k=[int(_) for _ in input().split()]\nD=dict()\nA=[int(_) for _ in input().split()]\nfor _ in range(n):\n if A[_] in D:\n D[A[_]]+=1\n else:\n D[A[_]]=1\nD=dict(sorted(list(D.items()), key=operator.itemgetter(1),reverse=True))\nc=0\ni=0\nfor _ in D:\n if i>=k:\n c+=D[_]\n i+=1\nprint(c)\n", "N,K = map(int,input().split())\nA = list(map(int,input().split()))\ndic = {}\n\nfor a in A:\n if a in dic.keys():\n dic[a] += 1\n else:\n dic[a] = 1\n \ndic = sorted(dic.items(), key = lambda x:x[1], reverse=True)\n\nans = 0\nfor (i,j) in dic[K:]:\n ans += j\n \nprint(ans)", "n,k = map(int,input().split())\nl = list(map(int, input().split()))\nfreq = [0]*(n+1)\nfor i in l:\n freq[i]+=1\nfreq.sort()\nvf = len(freq) - k if len(freq)> k else 0\nprint(sum(freq[:vf]))", "from collections import Counter\nN, K = map(int, input().split())\nA = Counter(input().split())\n\nprint(sum(sorted(A.values(), reverse=True)[K:]))", "from collections import Counter\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n# N=O(10^5)\u306a\u306e\u3067\u3001O(N)\u3067\u89e3\u304f\n# ABC-155-C-Poll \u306e\u985e\u984c\n# \u65b9\u91dd\uff1a\u5404\u6570\u5b57\u306e\u51fa\u73fe\u56de\u6570\u3092\u6570\u3048\u308b\n\n# Counter(\u30ea\u30b9\u30c8) \u306f\u8f9e\u66f8\u578b\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3067\u3042\u308a\u3001\u30ad\u30fc\u306b\u8981\u7d20\u30fb\u5024\u306b\u51fa\u73fe\u56de\u6570\u3068\u3044\u3046\u5f62\u5f0f\n# Counter(\u30ea\u30b9\u30c8).most_common() \u306f(\u8981\u7d20, \u51fa\u73fe\u56de\u6570)\u3068\u3044\u3046\u30bf\u30d7\u30eb\u3092\u51fa\u73fe\u56de\u6570\u9806\u306b\u4e26\u3079\u305f\u30ea\u30b9\u30c8\nA = Counter(A).most_common()\n\n# \u51fa\u73fe\u56de\u6570\u306e\u5927\u304d\u3044\u65b9\u304b\u3089K\u500b\u306f\u305d\u306e\u307e\u307e\u306b\u3057\u3066\u304a\u304f(=\u5909\u3048\u306a\u3044\u500b\u6570\uff09\n# \u5909\u3048\u308b\u500b\u6570\u306f\u3001N-(\u5909\u3048\u306a\u3044\u500b\u6570)\ns = 0\nfor i in range(min(K, len(A))):\n s += A[i][1]\n \nprint(N-s)", "N,K=map(int,input().split())\nA={}\nfor i in input().split():\n A[i]=A.get(i,0)+1\nA=sorted(A.values())\nprint(sum(A[0:len(A)-K]))", "n, k = list(map(int, input().split()))\nan = [int(num) for num in input().split()]\n\nkind = {}\nfor a in an:\n if not a in kind:\n kind[a] = 1\n else :\n kind[a] += 1\n\nsortedKind = sorted(list(kind.items()), key=lambda x:x[1]) \n\nif len(sortedKind) > k:\n count = 0\n for check in sortedKind[:len(sortedKind)-k]:\n count += check[1]\n print(count)\nelse :\n print((0))\n", "n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nimport collections\n\na=collections.Counter(a)\nkey=list(a.values())\nkey.sort()\nans=sum(key[:len(key)-k])\nprint(ans)\n", "n,k =map(int, input().split())\nA = list(map(int, input().split()))\n\nd = {}\nfor a in A:\n d[a] = d.get(a, 0) + 1\n\nif len(d) <= k:\n print(0)\nelse:\n d = sorted(d.values())\n cnt = 0\n for i in range(len(d)-k):\n cnt += d[i]\n print(cnt)", "n,k = map(int,input().split())\nl = list(map(int, input().split()))\nfreq = [0]*(n+1)\nfor i in l:\n freq[i]+=1\nfreq.sort()\nprint(sum(freq[:n-k+1]))", "n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nfrom collections import Counter\nac=sorted(list(Counter(a).values()))\nle=len(ac)\nif le<=k:\n print((0))\nelse:\n count=0\n for i in range(le-k):\n count+=ac[i]\n print(count)\n", "N, K = map(int, input().split())\na = list(map(int,input().split()))\n\na_dict = {}\n\nfor i in range(N):\n if a[i] not in a_dict.keys():\n a_dict[a[i]] = 1\n else:\n a_dict[a[i]] += 1\n\nans = 0\nif len(a_dict) <= K:\n print(ans)\nelse:\n sort_a_dict_list = sorted(a_dict.items(), key=lambda x:x[1])\n\n for j in range(len(a_dict) - K):\n ans += sort_a_dict_list[j][1]\n print(ans)", "nk = list(map(int, input().split()))\nn, k = nk[0], nk[1]\nballs = {}\nfor ball in list(map(int, input().split())):\n if ball in balls:\n balls[ball] += 1\n else:\n balls[ball] = 1\n\n\nsize = len(list(balls.keys()))\nswap_balls = list([(x[1], x[0]) for x in list(balls.items())])\nswap_balls.sort()\ncount = 0\n\nfor ball_count, ball_number in swap_balls:\n if size <= k:\n break\n else:\n count += ball_count\n size -= 1\n\nprint(count)\n", "N, K = input().split()\nA = dict()\nfor i in input().split():\n if int(i) in A:\n A[int(i)]+=1\n else:\n A[int(i)]=1\n\nhoge = []\nfor i in A.values():\n hoge.append(i)\nhoge.sort()\n\nsum = 0\nchanged = 0\nwhile len(hoge) - changed > int(K):\n sum += hoge[changed]\n changed += 1\n\nprint(sum)", "from collections import Counter\na,b=map(int, input().split())\nc = Counter(list(map(int, input().split())))\ncnt = 0\nl = []\nm = []\n\nfor x,y in c.items():\n l += [y]\n m += [x]\n\nM = len(m)\nL = sorted(l)\nif M <= b:\n print(0)\nif M > b:\n for i in range(M-b):\n cnt += L[i]\n print(cnt)", "N,K = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\ndic={}\nfor i in A:\n if i not in list(dic.keys()):\n dic[i]=1\n else:\n dic[i]+=1\ndic=sorted(list(dic.items()),key=lambda x:x[1],reverse=True)\nk=0\nans=0\nfor key,value in dic:\n if k>=K:\n ans+=value\n k+=1\nprint(ans)\n", "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\nnum_map = dict()\nfor i in range(n):\n if a[i] not in num_map:\n num_map[a[i]] = 1\n else:\n num_map[a[i]] += 1\n\nrest_key_num = max(0, len(num_map) - k)\nvalues = sorted(list(num_map.values()))\nres = 0\nfor j in range(rest_key_num):\n res += values[j]\nprint(res)\n", "n,k = map(int,input().split())\nA = list(map(int,input().split()))\nD = dict.fromkeys(range(1,n+1),0)\nans = 0\nfor a in A:\n D[a] += 1\nD = sorted(D.items(), key=lambda x:x[1])\nfor i in range(n-k):\n ans += D[i][1]\nprint(ans)", "import collections\nN ,K = map(int,input().split())\nlsA = list(map(int,input().split()))\ncounterA = collections.Counter(lsA)\nvalu = list(counterA.values())\nvalu.sort()\nkind = len(set(lsA))\nif kind <= K:\n ans = 0\nelse:\n ans = sum(valu[:kind - K])\nprint(ans)", "N,K=map(int,input().split())\nA=list(map(int,input().split()))\n\ndic={}\nfor i in range(N+1):\n dic[i]=0\nfor i in A:\n dic[i]+=1\n\ndic_sort=sorted(dic.values(),reverse=True)\n\nprint(sum(dic_sort[K:]))", "import collections as c\nn,k=map(int,input().split());a=c.Counter(map(int,input().split()))\nprint([0,sum(sorted([i for i in a.values()])[:len(a)-k])][len(a)>k])", "n,k=list(map(int, input().split()))\na_list=[int(i) for i in input().split()]\n\ndic={}\n\nfor i in a_list:\n if i in dic:\n dic[i]+=1\n else:\n dic[i]=1\n\ndic2=sorted(list(dic.items()), key=lambda x:x[1])\n\nans=0\n\nif len(dic)>k:\n num=len(dic)-k\n for i in range(num):\n ans+=dic2[i][1]\n\n \nprint(ans)\n", "from collections import Counter\nn,k=map(int,input().split())\na=list(map(int,input().split()))\nt=list(set(a))\nc=sorted(Counter(a).most_common(),key=lambda x:x[1])\nnum=len(t)-k\nif num<0:\n print(0)\n return\nelse:\n ans=0\n for i in range(num):\n ans+=c[i][1]\n print(ans)", "from collections import Counter, deque, defaultdict\nn, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nt = defaultdict(int)\nfor x in A:\n t[x]+=1\nB = []\nfor x in list(t.values()):\n B.append(x)\nB.sort()\nif(len(B)<=k):\n print((0))\n return\n \nans = 0\nfor i in range(0, len(B)):\n ans+=B[i]\n if len(B)-(i+1) <= k:\n break\nprint(ans)\n", "n,k = map(int,input().split())\nA = list(map(int,input().split()))\nL = [0] * n\nans = 0\n\nfor a in A:\n L[a-1] += 1\nL = sorted(L)\nfor i in range(n-k):\n ans += L[i]\n\nprint(ans)", "import sys\nfrom collections import Counter\ninput = lambda: sys.stdin.readline().rstrip()\n\ndef main():\n n, k = map(int, input().split())\n a = list(map(int, input().split()))\n a_cnt = sorted(list(Counter(a).values()))\n s = set(a)\n t = max(0, len(s) - k)\n print(sum(a_cnt[0:t]))\n\ndef __starting_point():\n main()\n__starting_point()", "n,k=list(map(int,input().split()))\na=list(map(int,input().split()))\n\nd={}\n\nfor x in range(n):\n if a[x] not in d:\n d[a[x]]=0\n d[a[x]]+=1\n \nans=0\nans1=[]\nfor g in d:\n ans1.append(d[g])\n \nif len(ans1)<=k:\n print((0))\n \nelse:\n ans1.sort()\n r=len(ans1)-k\n for t in range(r):\n ans+=ans1[t]\n \n print(ans)\n \n", "from collections import Counter as C\n\n_, k = map(int, input().split())\na = [int(i) for i in input().split()]\n\nc = C(a).values()\nd = len(c) - k\nif 0 < d:\n print(sum(sorted(c)[:d]))\nelse:\n print(0)", "#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 = [input() for _ in range(n)]\n\nn,k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nd = [0]*(n+1)\n\nfor i in range(n):\n d[a[i]] += 1\n\nd.sort()\n\nprint((sum(d[:n-k+1])))\n", "import collections as c\nn,k = map(int,input().split())\nx = list(map(int,input().split()))\ny = c.Counter(x)\ns = []\nfor i in y.items():\n s.append([i[1],i[0]])\ns.sort()\nans = 0\nfor i in range(len(s)-k):\n ans += s[i][0]\nprint(ans)", "from collections import Counter\n_, K = map(int, input().split())\nA = list(map(int, input().split()))\n_, cnt = zip(*Counter(A).most_common()[::-1])\nprint(sum(cnt[:len(cnt) - K]))", "#!/usr/bin/env python3\nfrom collections import Counter\nimport sys\nsys.setrecursionlimit(10**6)\n\n\nn, k = list(map(int, input().split()))\na = list(map(int, input().split()))\n\nc = Counter(a)\n\nc = list(c.most_common())\n# c = c.most_common()\nlen_c = len(c)\n# print(len_c)\n# print(c)\nans = 0\nwhile(len_c-k > 0):\n # print(len_c-k)\n # print()\n # print(k)\n i, j = c.pop()\n len_c -= 1\n ans += j\nprint(ans)\n", "from collections import Counter\nn,k = map(int, input().split())\na = list(map(int, input().split()))\n\ncnt = Counter(a)\n\nl = len(cnt)\nt = l-k\nans = 0\nfor i in sorted(cnt.values()):\n if t <= 0: break\n t -= 1\n ans += i\nprint(ans)", "N, K = list(map(int, input().split()))\nA = list(map(int,input().split()))\n\nB = [0]*N\nfor i in range(N):\n B[A[i]-1]+=1\n\nB.sort()\n\nprint((sum(B[0:N-K])))\n", "from collections import Counter\nn, k = map(int, input().split())\na = list(map(int, input().split()))\nl = Counter(a)\nif len(set(a)) <= k:\n print(0)\nelse:\n ci = list(l.values())\n ci.sort()\n i = 0\n cnt = len(ci)\n ans = 0\n while cnt > k:\n cnt -= 1\n ans += ci[i]\n i += 1\n print(ans)", "from collections import Counter\n\nn, k = map(int, input().split())\na = [int(an) for an in input().split()]\nans = 0\nset_a = set(a)\nnum_of_types = len(set_a)\nif num_of_types > k:\n cnt = Counter(a)\n ans = sum(sorted(cnt.values())[: num_of_types - k])\n\nprint(ans)", "n,k = map(int,input().split())\nfrom collections import Counter\ns = list(map(int,input().split()))\nnum = Counter(s)\nif len(num) <= k:\n print(0)\nelse:\n n = len(num) - k\n a = 0\n ans = 0\n for i in sorted(num.values()):\n if a == n:\n break\n \n ans += i\n a += 1\n \n print(ans)", "from collections import Counter\n_, K = map(int, input().split())\nA = sorted(list(Counter(input().split()).values()))\nprint(sum(A[:len(A)-K]))", "from collections import Counter, deque, defaultdict\nn, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nt = defaultdict(int)\nfor x in A:\n t[x]+=1\nB = list(t.values())\nB.sort()\nif(len(B)<=k):\n print((0))\n return\n\nans = sum(B[:len(B)-k])\nprint(ans)\n", "import operator\nfrom collections import Counter\nn,k=[int(_) for _ in input().split()]\nD=Counter([int(_) for _ in input().split()])\nD=dict(sorted(list(D.items()), key=operator.itemgetter(1),reverse=True))\nc=0\ni=0\nfor _ in D:\n if i>=k:\n c+=D[_]\n i+=1\nprint(c)\n", "n, k = list(map(int, input().split()))\na = list(map(int, input().split()))\na.sort()\nb = [0]\nc = n\nd = 1\nfor i in range(n-1):\n if a[i] == a[i + 1]:\n d += 1\n c -= 1\n else:\n b.append(d)\n d = 1\nb.append(d)\nb.sort()\nfor i in range(len(b) - 1):\n b[i+1] += b[i]\nprint((b[max(0, c-k)]))\n", "n,k = map(int, input().split())\na = list(map(int, input().split()))\nfrom collections import Counter\na1 = Counter(a).most_common()\nnum = 0\nif k < len(a1):\n for i in range(1,len(a1)-k+1):\n num += a1[-i][1]\n print(num)\nelse:\n print(0)", "N, K = [int(x) for x in input().split()]\nA = [int(x) for x in input().split()]\n\nX = [0] * N\n\nfor i in range(N):\n X[A[i] - 1] += 1\n\nX = sorted(X, reverse=True)\n\nS = sum(X[:K])\n\nans = N - S\n\nprint(ans)", "_, k = map(int, input().split())\nd = {}\nfor i in map(int, input().split()):\n if i in d:\n d[i] += 1\n else:\n d[i] = 1\nd = sorted(d.values(), reverse=True)\nprint(sum(v for v in d[k:]))", "import collections\nn,k=list(map(int,input().split()))\na=list(map(int,input().split()))\nans=0\nc=collections.Counter(a)\nif len(c)<k:\n print(ans)\n return\nl=c.most_common()\nfor i in range(1,-k+len(c)+1):\n ans+=l[-i][1]\nprint(ans)\n", "N,K=list(map(int,input().strip().split()))\nA=list(map(int,input().strip().split()))\n\nd={}\n\nfor n in range(N):\n if d.get(A[n])==None:\n d[A[n]]=1\n else:\n d[A[n]]+=1\n\ndn=sorted(list(d.items()),key=lambda x:x[1])\n\nif K>=len(d):\n print((0))\nelse:\n cnt=0\n ans=0\n for n in range(len(dn)):\n ans+=dn[n][1]\n cnt+=1\n if cnt==len(d)-K:\n break\n print(ans)\n", "from collections import Counter\n\nn, k = list(map(int, input().split()))\nA = list(map(int, input().split()))\nCA = Counter(A)\n\nkouho = CA.most_common()[::-1]\nans = 0\nidx = 0\nwhile idx < len(CA) - k:\n key, val = kouho[idx]\n ans += val\n idx += 1\nprint(ans)\n\n", "N,K = list(map(int,input().split()))\nA = list(map(int,input().split()))\n\nB = [0]*(N+1)\nfor i in range(N):\n B[A[i]] += 1\nB.sort(reverse = True)\ncnt = 0\nfor i in range(K):\n cnt += B[i]\nprint((N - cnt))\n", "N, K = list(map(int, input().split()))\nA = list(map(int, input().split()))\nA_dict = dict()\nfor i in range(N):\n if A_dict.get(A[i]) is None:\n A_dict[A[i]] = 1\n else:\n A_dict[A[i]] += 1\nA_dict_len = len(list(A_dict.keys()))\nans = 0\nA_dict_sorted = sorted(list(A_dict.items()), key=lambda a: a[1])\n#print(A_dict_sorted)\nfor i in range(max(0, A_dict_len - K)):\n ans += A_dict_sorted[i][1]\nprint(ans)\n", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Sep 23 15:50:08 2020\n\n@author: liang\n\"\"\"\n\nN, K = map(int,input().split())\nd = [0]*N\nA = [int(x) for x in input().split()]\n\nfor a in A:\n d[a-1] += 1\n \nd.sort(reverse=True)\n\nans = N - sum(d[:K])\n\nprint(ans)", "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\n# N=O(10^5)\u306a\u306e\u3067\u3001O(N)\u3067\u89e3\u304f\n# ABC-155-C-Poll \u306e\u985e\u984c\n\n# \u5404\u6570\u5b57\u306e\u51fa\u73fe\u56de\u6570\u3092\u6570\u3048\u308b\ndic = {}\nfor i in range(N):\n a = A[i]\n if a not in dic: dic[a] = 1\n else: dic[a] += 1\n\n# dic\u3092\u6607\u9806\u306b\u30bd\u30fc\u30c8\ndic = sorted(dic.items(), key=lambda x:x[1])\n\n# dic\u306f [(5, 1), (3, 2), (2, 2), (4, 2), (1, 3)] \u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\n# dic\u306evalue\u306b\u304a\u3044\u3066\u3001\u524d\u304b\u3089len(dic)-K\u500b\u306e\u548c\u3092\u53d6\u308b\nans = 0\nfor i in range(max(len(dic)-K, 0)):\n ans += dic[i][1]\n \nprint(ans)", "from collections import Counter\n\nn, k = map(int, input().split())\nA = list(map(int, input().split()))\n\ncnt_A = sorted(Counter(A).values())\n\nans = 0\nif len(cnt_A) <= k:\n print(ans)\nelse:\n for i in range(len(cnt_A) - k):\n ans += cnt_A[i]\n print(ans)", "from collections import Counter\nN,K=map(int,input().split())\nA=list(map(int,input().split()))\n\ncnt=Counter(A)\ncnt_sorted=sorted(cnt.items(), reverse=True,key=lambda x:x[1])\n\nsum=0\nfor i in range(min(K,len(cnt))):\n sum+=cnt_sorted[i][1]\n\nprint(N-sum)", "# -*- coding: utf-8 -*-\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\ncount = {}\nfor val in A:\n if val in count:\n count[val] += 1\n else:\n count[val] = 1\n\nans = 0\ndiff = len(set(A)) - K\nif diff > 0:\n count_sorted = sorted(count.items(), key=lambda x:x[1])\n for k,v in count_sorted:\n ans += v\n diff -= 1\n if diff == 0:\n break\n\nprint(ans)", "from collections import Counter\nn,k=map(int,input().split())\nL=Counter(list(map(int,input().split())))\nnum=max(len(L)-k,0)\nans=0\nif num==0:\n print(0)\n return\nL2=sorted(L.values())\nprint(sum(L2[:num]))", "import collections\nN,K=map(int,input().split())\nL=list(map(int,input().split()))\nL=sorted(L)\nc = collections.Counter(L)\nc=c.most_common()\nans=0\nif len(c)>K:\n for i in range(len(c)-K):\n ans+=c[len(c)-i-1][1]\n print(ans)\nelse:\n print(0)", "import collections\nn,k = list(map(int,input().split()))\na = list(map(int,input().split()))\n\na_cnt = collections.Counter(a)\n#print(a_cnt)\na_sort = sorted(list(a_cnt.values()),reverse=True)\n#print(a_sort)\n#print(a_sort[k:])\nprint((sum(a_sort[k:])))\n", "from collections import Counter\n\ndef main():\n N, K = map(int, input().split())\n A = list(map(int, input().split()))\n\n unchange = sum(tuple[1] for tuple in Counter(A).most_common(K))\n print(N-unchange)\n\nmain()", "import collections\nN,K = list(map(int,input().split()))\nN_List = list(map(int,input().split()))\n\nChou_List = collections.Counter(N_List)\nif len(Chou_List) <= K:\n print((0))\nelse:\n Chou_List = sorted(list(Chou_List.values()),reverse=True)\n print((sum(Chou_List[K:])))\n", "from collections import Counter as CC\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = CC(A)\nC = sorted(B.values())\nprint(sum(C[:max(0, len(C) - K)]))", "import bisect as bs\nN, K = (int(x) for x in input().split())\nA = sorted([int(x) for x in input().split()])\nf = lambda X, x: bs.bisect_right(X,x)-bs.bisect_left(X,x)\ncnt = sorted([f(A,a) for a in set(A)],reverse=True)\nvrt = len(cnt)\nprint(sum(cnt[K:]) if vrt > K else 0)", "from collections import Counter\n\nn, K = map(int, input().split())\na = list(map(int, input().split()))\nc = Counter()\nfor x in a:\n c[x] += 1\n\ncv = [(k, x) for x, k in c.items()]\ncv.sort(reverse=True)\n\nans = 0\nwhile len(cv) > K:\n k,_ = cv.pop()\n ans += k\nprint(ans)", "N, K = map(int, input().split())\na_list = list(map(int, input().split()))\n\nnum_dic = {}\nfor a in a_list:\n count = num_dic.get(a, 0)\n num_dic[a] = count + 1\n\nreplace_num = len(num_dic.keys()) - K\nreplace_num = 0 if replace_num < 0 else replace_num\nans = 0\nfor i, taple in enumerate(sorted(num_dic.items(), key = lambda x:x[1])):\n if i == replace_num:\n break\n ans += taple[1]\n\nprint(ans)", "n,k = map(int,input().split())\na = list(map(int,input().split()))\nimport collections\nc = collections.Counter(a)\nli = []\nans = 0\nfor v,num in c.items():\n li.append((v,num))\nll = sorted(li,key=lambda x: x[1],reverse=True)\n\nfor i in range(k,len(ll)):\n #print(ll[i][1])\n ans += ll[i][1]\n\nprint(ans)", "N,K = map(int,input().split())\nA = list(map(int,input().split()))\nimport collections\na = collections.Counter(A)\nb = a.most_common()\nans = 0\nif len(b) > K:\n for i in range(K,len(b)):\n ans += b[i][1]\nprint(ans)", "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nB = [0] * (N + 1)\nfor i in range(N):\n B[A[i]] += 1\nB.sort(reverse=True)\ncnt = 0\n# \u5229\u7528\u53ef\u80fd\u306a\u7a2e\u985e\u6570\u304cK\u500b\u306a\u306e\u3067N-K\u3067\u7b54\u3048\u306b\u306a\u308b\nfor i in range(K):\n cnt += B[i]\nprint(N - cnt)", "from collections import Counter\n\nn, k = list(map(int, input().split()))\na = Counter(list(map(int, input().split())))\na = list(a.items())\na.sort(key=lambda x: x[1])\nopt = len(a) - k\nans = 0\nif opt > 0:\n for i in range(opt):\n ans += a[i][1]\nprint(ans)\n", "from collections import Counter\n\nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nL = Counter(A)\n\nans = N\nfor a, cnt in L.most_common(K):\n ans -= cnt\n\nprint(ans)", "import collections\nn,k=map(int,input().split())\na=list(map(int,input().split()))\na.sort()\ncount=0\nb=len(collections.Counter(a))\nc=collections.Counter(a).most_common()\n#print(b)\nfor i in range(min(k,b)):\n count+=c[i][1]\n# print(count)\nans=len(a)-count\nprint(ans)", "n,k = map(int, input().split())\na = list(map(int, input().split()))\nfrom collections import Counter\na1 = Counter(a).most_common()\nnum = 0\nif k < len(a1):\n for i in range(1,len(a1)-k+1):\n num += a1[-i][1]\n print(num)\nelse:\n print(0)", "# -*- coding: utf-8 -*-\nimport collections\nN, K=list(map(int,input().split()))\nA=list(map(int,input().split()))\nC=collections.Counter(A)\nKEY=list(C.keys())\ncount=0\nif len(KEY)>K:\n D=len(KEY)-K\n L=C.most_common()[::-1]\n for ii in range(D):\n count+=L[ii][1]\n\nprint(count)\n \n", "n, k= list(map(int, input().split()))\na = list(map(int, input().split()))\nimport collections\n\na = collections.Counter(a)\nkey = list(a.values())\n#print(key)\nkey.sort()\n#print(key)\nans = sum(key[:len(key)-k])\nprint(ans)\n", "N,K=list(map(int,input().split()))\nA=list(map(int,input().split()))\nm= [0 for i in range(200001) ]\nfor i in range(N):\n m[A[i]] += 1\nm.sort(reverse=True)\nans = 0\nfor i in range(K,N):\n if ( m[i] == 0 ): break\n ans += m[i]\nprint(ans)\n", "n, k = map(int, input().split())\na = list(map(int, input().split()))\nb = [0]*n\nfor i in range(n):\n b[a[i]-1] += 1\nc = [i for i in b if i != 0]\nc.sort()\nif len(c) - k > 0:\n print(sum((c[0:len(c)-k])))\nelse:\n print(0)", "N, K = map(int, input().split())\nA = list(map(int, input().split()))\n\nA_dic = {}\nA_count = []\n\nfor i in range(N):\n if A[i] not in A_dic.keys():\n A_dic[A[i]] = 1\n else:\n A_dic[A[i]] += 1\n \nfor i in A_dic.keys():\n A_count.append(A_dic[i])\n \nif len(A_count) <= K:\n print(0)\nelse:\n ans = 0\n A_count.sort()\n for i in range(len(A_count) - K):\n ans += A_count[i]\n else:\n print(ans)", "# cook your dish here\nimport operator\nN,K=map(int,input().split())\nlst=list(map(int,input().split()))\nx=[]\nx=set(lst)\nif len(x)<=K:\n print(0)\nelse:\n freq={}\n for i in lst:\n if i in freq:\n freq[i]+=1\n else:\n freq[i]=1\n # l=[]\n # l=list(freq.items())\n s={}\n s = dict(sorted(freq.items(), key=operator.itemgetter(1)))\n # print(s)\n # l.sort()\n cc=abs(len(x)-K)\n # print(cc)\n v=0\n for key,value in s.items():\n \n v+=s[key]\n # print(key)\n cc-=1\n if cc==0:\n print(v)\n break", "N,K = map(int,input().split()) \nA = list(map(int,input().split()))\nA.sort()\ntemp = 1\nV = [] \nfor i in range(N-1):\n if A[i] == A[i+1]:\n temp+=1 \n else:\n V.append(temp)\n temp = 1\n\nV.append(temp)\nV.sort() \nans = N- sum(V[-K:])\nprint(ans)", "from collections import Counter\n \nN, K = map(int, input().split())\nA = list(map(int, input().split()))\n \n# N=O(10^5)\u306a\u306e\u3067\u3001O(N)\u3067\u89e3\u304f\n# ABC-155-C-Poll \u306e\u985e\u984c\n# \u65b9\u91dd\uff1a\u5404\u6570\u5b57\u306e\u51fa\u73fe\u56de\u6570\u3092\u6570\u3048\u308b\n \n# Counter(\u30ea\u30b9\u30c8) \u306f\u8f9e\u66f8\u578b\u306e\u30b5\u30d6\u30af\u30e9\u30b9\u3067\u3042\u308a\u3001\u30ad\u30fc\u306b\u8981\u7d20\u30fb\u5024\u306b\u51fa\u73fe\u56de\u6570\u3068\u3044\u3046\u5f62\u5f0f\n# Counter(\u30ea\u30b9\u30c8).most_common() \u306f(\u8981\u7d20, \u51fa\u73fe\u56de\u6570)\u3068\u3044\u3046\u30bf\u30d7\u30eb\u3092\u51fa\u73fe\u56de\u6570\u9806\u306b\u4e26\u3079\u305f\u30ea\u30b9\u30c8\nA = Counter(A).most_common()\n \n# \u51fa\u73fe\u56de\u6570\u306e\u5927\u304d\u3044\u65b9\u304b\u3089K\u7a2e\u985e\u306f\u305d\u306e\u307e\u307e\u306b\u3057\u3066\u304a\u304f\u3002\u3053\u308c\u306b\u3088\u3063\u3066\u3001\u5909\u3048\u306a\u3044\u500b\u6570\u304c\u6c42\u307e\u308b\u3002\n# \u5909\u3048\u308b\u500b\u6570\u306f\u3001N-(\u5909\u3048\u306a\u3044\u500b\u6570)\ns = 0\nfor i in range(min(K, len(A))):\n s += A[i][1]\n \nprint(N-s)", "N,K=map(int,input().split())\nA=list(map(int,input().split()))\na=[0]*200000\nb=[]\nfor i in A:a[i-1]+=1\nfor i in a:\n if i:b.append(i)\nb.sort()\nans=0\nfor i in range(len(b)-K):ans+=b[i]\nprint(ans)", "from collections import deque\n\nN,K = map(int,input().split())\nA = list(map(int,input().split()))\nnums = [0]*N\n\nfor i in range(N):\n nums[A[i]-1] += 1\n\nnums.sort()\n\nnums = deque(nums)\n\nwhile True:\n if nums[0] == 0:\n nums.popleft()\n else:\n break\nnums = list(nums)\nif len(nums) <= K:\n print(0)\nelse:\n print(sum(nums[:len(nums)-K]))", "n,k=list(map(int,input().split()))\na=[int(i) for i in input().split()]\nc=[0]*(n+1)\nfor i in a:\n c[i]+=1\nprint((sum(sorted(c)[:-k])))\n", "def main():\n n, k = map(int, input().split())\n inlis = list(map(int, input().split()))\n indic = dict()\n cnt = 0\n for i in range(n):\n num = inlis[i]\n if num in indic:\n indic[num] += 1\n else:\n indic[num] = 1\n cnt += 1\n if cnt <= k:\n print(0)\n else:\n indic_sort = sorted(indic.items(), key=lambda x:x[1])\n #print(indic_sort)\n sa = cnt - k\n tmp = 0\n ans = 0\n for j in range(n):\n tmp += 1\n ans += indic_sort[j][1]\n if tmp == sa:\n break\n print(ans)\n\n\n\ndef __starting_point():\n main()\n__starting_point()", "n,k=[int(i) for i in input().split()]\na=[int(i) for i in input().split()]\n\na.sort()\n\ntimes=[0]*(n+1)\nfor i in a:\n times[i]+=1\ntimes.sort()\n\n\nfor i in range(n+1):\n if times[i]!=0:\n j=i\n break\n\nans=0\nif len(times)>k-j:\n for i in range(j,len(times)-k):\n ans+=times[i]\nprint(ans)", "N, K = map(int, input().split())\nA = list(map(int, input().split()))\nB = [0 for i in range(N+1)]\n \nfor a in A:\n B[a] += 1\nnums = [b for b in B if b > 0]\nnums.sort()\nn = len(nums)\nif n <= K:\n print(0)\nelse:\n print(sum(nums[:n-K]))", "from collections import Counter\n\nN, K = list(map(int, input().split()))\nA = Counter(list(map(int, input().split())))\n\nif(len(A) > K):\n values, counts = list(zip(*A.most_common()[-(len(A)-K):]))\n print((sum(counts)))\nelse:\n print((0))\n", "#\n# abc081 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 = \"\"\"5 2\n1 1 2 2 5\"\"\"\n output = \"\"\"1\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"4 4\n1 1 2 2\"\"\"\n output = \"\"\"0\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"10 3\n5 1 3 2 4 1 1 2 3 4\"\"\"\n output = \"\"\"3\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N, K = list(map(int, input().split()))\n a = list(map(int, input().split()))\n an = [0] * N\n for i in a:\n an[i-1] += 1\n an.sort(reverse=True)\n ans = 0\n for i in an:\n if K == 0:\n ans += i\n else:\n K -= 1\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "N,K = map(int, input().split())\na_list = list(map(int, input().split()))\ncounter_list = [0]*N\nfor i in a_list:\n counter_list[i-1] += 1\n\ncounter_list.sort(reverse=True)\n\nans = N - sum(counter_list[:K]) \n\nprint(ans)", "N,K=list(map(int,input().split()))\nA=list(map(int,input().split()))\nX=[0 for _ in range(N+1)]\nfor a in A:\n X[a]+=1\nX.sort(reverse=True)\nprint((N-sum(X[0:K])))\n", "from collections import Counter\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, k = Input()\n a = sorted(Counter(Input()).items(), key=lambda x:x[1], reverse=True)\n temp = 0\n for i in range(min(k, len(a))):\n temp += a[i][1]\n print(sum(i for _, i in a) - temp)\n\n\nmain()", "def main():\n\tN, K = map(int, input().split())\n\tA = list(map(int, input().split()))\n\n\tlst = {}\n\n\tfor num in A:\n\t\tif num in lst:\n\t\t\tlst[num] += 1\n\t\telse:\n\t\t\tlst[num] = 1\n\n\tlst_sorted = sorted(lst.items(), key = lambda x: x[1])\n\n\tlen_lst_sorted = len(lst_sorted)\n\n\tif len_lst_sorted <= K:\n\t\tprint(0)\n\t\treturn\n\telse:\n\t\tans = 0\n\t\tfor i in range(len_lst_sorted - K):\n\t\t\tans += lst_sorted[i][1]\n\t\tprint(ans)\n\t\treturn\n\n \ndef __starting_point():\n \tmain()\n__starting_point()", "import collections\nN,K=map(int,input().split())\na=list(map(int,input().split()))\nc=collections.Counter(a)\nl=len(c)\nc=list(c.items())\nc.sort(key=lambda x: x[1])\nans=0\nfor i in c:\n if l<=K:\n break\n ans+=i[1]\n l-=1\nprint(ans)", "n,k= map(int,input().split())\nXl = list(map(int,input().split()))\nfrom collections import Counter\nXdic = Counter(Xl)\nvaluelist = sorted(list(Xdic.values()), reverse=True)\nprint(sum(valuelist[k:]))"]
{"inputs": ["5 2\n1 1 2 2 5\n", "4 4\n1 1 2 2\n", "10 3\n5 1 3 2 4 1 1 2 3 4\n"], "outputs": ["1\n", "0\n", "3\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
32,243
560e88f4d2ccf40dad41114a73c36e12
UNKNOWN
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i. If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that he cannot stay at his place. Determine whether he can carry out his plan. -----Constraints----- - 1 ≀ N ≀ 10^5 - 0 ≀ x_i ≀ 10^5 - 0 ≀ y_i ≀ 10^5 - 1 ≀ t_i ≀ 10^5 - t_i < t_{i+1} (1 ≀ i ≀ N-1) - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N t_1 x_1 y_1 t_2 x_2 y_2 : t_N x_N y_N -----Output----- If AtCoDeer can carry out his plan, print Yes; if he cannot, print No. -----Sample Input----- 2 3 1 2 6 1 1 -----Sample Output----- Yes For example, he can travel as follows: (0,0), (0,1), (1,1), (1,2), (1,1), (1,0), then (1,1).
["N = int(input())\n\nT = 0\nX = 0\nY = 0\n\nfor i in range(N):\n t, x, y = list(map(int, input().split()))\n dt = t - T\n dx = abs(X - x)\n dy = abs(Y - y)\n dis = dx + dy\n if dt < dis:\n print(\"No\")\n break\n if (dt - dis) % 2 == 1:\n print(\"No\")\n break\n T = t\n X = x\n Y = y\nelse:\n print(\"Yes\")\n", "n=int(input())\nT=0; X=0; Y=0;\nans=\"Yes\"\nfor i in range(n):\n t,x,y=map(int,input().split())\n s=t-T\n if s >= abs(X-x)+abs(Y-y) and (s-abs(X-x)+abs(Y-y))%2==0:\n T,X,Y = t,x,y\n else:\n ans=\"No\"\n break\nprint(ans)", "N = int(input())\n\nlocx = 0\nlocy =0\ntime = 0\nfor i in range(N):\n t,x,y = map(int,input().split())\n time = t-time\n dis = abs(locx-x)+abs(locy-y)\n if (time-dis)<0 :\n print(\"No\")\n return\n if (time-dis)%2 == 1:\n print(\"No\")\n return\n \n \n time = t\n locx = x\n locy = y\n \n \nelse :\n print(\"Yes\")", "from collections import deque\nN = int(input())\ntxy = [map(int, input().split()) for _ in range(N)]\nt, x, y = [list(i) for i in zip(*txy)]\nt = deque(t)\nx = deque(x)\ny = deque(y)\nt.appendleft(0)\nx.appendleft(0)\ny.appendleft(0)\nfor i in range(N):\n direct = t[i+1] - t[i] - abs(x[i+1] - x[i]) - abs(y[i+1] - y[i])\n if direct < 0 or direct % 2 != 0:\n print(\"No\")\n return\nprint(\"Yes\")", "n = int(input())\nxx = 0\nyy = 0\ntt = 0\nfor i in range(n):\n t, x, y = map(int, input().split())\n d = abs(xx - x) + abs(yy - y)\n if t - tt < d or (t - tt - d) % 2 == 1:\n print('No')\n return\n xx = x\n yy = y\n tt = t\nprint('Yes')", "N = int(input())\nT = []\nXY = []\nans = \"Yes\"\n\nfor i in range(N):\n t,x,y = map(int,input().split())\n T.append(t)\n XY.append([x,y])\n\nif T[0]>=abs(XY[0][0])+abs(XY[0][1]) and T[0]%2==(abs(XY[0][0])+abs(XY[0][1]))%2:\n None\nelse:\n ans = \"No\"\n\nfor i in range(1,N):\n dT=T[i]-T[i-1]\n dX=abs(XY[i][0]-XY[i-1][0])\n dY=abs(XY[i][1]-XY[i-1][1])\n if dT >= dX+dY and dT%2 == (dX+dY)%2:\n None\n else:\n ans = \"No\"\n\nprint(ans)", "def main():\n N = int(input())\n txy = [list(map(int,input().split())) for _ in range(N)]\n txy = [[0,0,0]] + txy\n #print(txy)\n for i in range(N):\n temp = txy[i+1][0] - txy[i][0] - abs(txy[i+1][1] - txy[i][1]) - abs(txy[i+1][2] - txy[i][2]) \n if not (temp % 2 == 0 and temp >= 0):\n print(\"No\")\n return\n print(\"Yes\")\n \nmain()", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\n\nt, x, y = 0, 0, 0\nfor i in range(n):\n t_new, x_new, y_new = list(map(int, input().split()))\n\n time = t_new-t\n dis = abs(x_new-x)+abs(y_new-y)\n\n if time < dis:\n print(\"No\")\n return\n if time % 2 != dis % 2:\n print(\"No\")\n return\n t, x, y = t_new, x_new, y_new\nprint(\"Yes\")\n", "N = int(input())\nt = 0\nxy = [0,0]\nans = 'Yes'\nfor i in range(N):\n ti,xi,yi = map(int,input().split())\n dt = ti - t\n dx = abs(xi - xy[0])\n dy = abs(yi - xy[1])\n if dt < dx+dy:\n ans = 'No'\n elif dt%2 != (dx+dy)%2:\n ans = 'No'\n t = ti\n xy = [xi,yi]\nprint(ans)", "n=int(input())\nn_list=[[0,0,0]]\nfor i in range(n):\n n_list.append(list(map(int,input().split())))\n\nfor t in range(n):\n dt=n_list[t+1][0]-n_list[t][0]\n dist=abs(n_list[t+1][1]-n_list[t][1])+abs(n_list[t+1][2]-n_list[t][2])\n\n if(dist>dt):\n can='No'\n break\n xy=n_list\n if(dist%2 != dt%2):\n can='No'\n break\n can='Yes'\nprint(can)", "# https://atcoder.jp/contests/abc086/tasks/arc089_a\nn = int(input())\ntxy = [list(map(int, input().split())) for _ in range(n)]\n\npx, py = (0, 0)\npt = 0\n\nfor t, x, y in txy:\n if not (x + y <= t and (x + y) % 2 == t % 2 and abs(x - px) + abs(y - py) <= t - pt):\n print('No')\n return\n px, py = x, y\n pt = t\n\nprint('Yes')\n", "N = int(input())\ntxy = [[0,0,0]] + [list(map(int,input().split())) for _ in range(N)]\n\ncheck = True\nfor i in range(1,N+1):\n K = txy[i][0] - txy[i-1][0]\n tmp = K - abs(sum(txy[i][1:]) - sum(txy[i-1][1:]))\n if tmp < 0 or tmp % 2 == 1:\n check = False\n break\n \nprint(\"Yes\" if check else \"No\")", "N=int(input())\nt=[]\nx=[]\ny=[]\nfor i in range(N):\n txy=list(map(int,input().split()))\n t.append(txy[0])\n x.append(txy[1])\n y.append(txy[2])\n\nnow_x=0\nnow_y=0\nnow_time=0\nisOK=True\nfor i in range(N):\n dist=(x[i]-now_x)**2+(y[i]-now_y)**2\n time=t[i]-now_time\n\n if dist<=time**2 and dist%2 ==time%2:\n now_x=x[i]\n now_y=y[i]\n now_time=t[i]\n else:\n isOK=False\n break\n \n\nif isOK:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n=int(input())\nt=0\nx=0\ny=0\nfor i in range(n):\n t_,x_,y_=map(int,input().split())\n t=abs(t_-t)\n x=abs(x_-x)\n y=abs(y_-y)\n if x+y>t:\n print('No')\n return\n if t_%2!=(x_+y_)%2:\n print('No')\n return\n \nprint('Yes')", "N = int(input())\nt = [0] * (N+1)\nx = [0] * (N+1)\ny = [0] * (N+1)\nfor i in range(N):\n t[i+1], x[i+1], y[i+1] = map(int, input().split())\n\nf = True\nfor i in range(N):\n dt = t[i+1] - t[i]\n dist = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])\n if dt < dist:\n f = False\n if dist%2 != dt%2:\n f = False\n\nprint('Yes' if f else 'No')", "n = int(input())\n\nprev_t, prev_x, prev_y = 0, 0, 0\nfor _ in range(n):\n t, x, y = map(int, input().split())\n if (abs(x - prev_x) + abs(y - prev_y) <= t - prev_t and\n (abs(x - prev_x) + abs(y - prev_y)) % 2 == (t - prev_t) % 2):\n prev_t, prev_x, prev_y = t, x, y\n continue\n else:\n print('No')\n break\nelse:\n print('Yes')", "N = int(input())\nl = []\nnow = [0,0,0]\nans = 'Yes'\nfor _ in range(N):\n inp = list(map(int,input().split()))\n l.append(inp)\n\nfor i in range(N):\n shortest = abs(l[i][1] - now[1]) + abs(l[i][2] - now[2])\n if shortest > l[i][0]-now[0]:\n ans = 'No'\n break\n a = l[i][0] -now[0]- shortest\n if a % 2 !=0:\n ans = 'No'\n break\n else:\n now = l[i]\nprint(ans)", "n = int(input())\nx,y,t=0,0,0\n\nfor i in range(n):\n mt,mx,my= map(int,input().split())\n ft = mt - t\n fx = abs(x-mx)\n fy = abs(y-my)\n if fx + fy > ft:\n print(\"No\")\n return\n elif (ft - (fx + fy)) % 2 == 0:\n pass\n else:\n print(\"No\")\n return\n x,y,t=mx,my,mt\nprint(\"Yes\")", "N = int(input())\nt, x, y = 0, 0, 0\nans = \"Yes\"\n\nfor i in range(N):\n nt, nx, ny = map(int,input().split())\n if ((nt - t) - abs(nx - x) - abs(ny - y))%2 != 0 or abs(nx - x) + abs(ny - y) > (nt - t):\n ans = \"No\"\n break\n else:\n t = nt\n x = nx\n y = ny\n\nprint(ans)", "\nN = int(input())\n\nres = True\npre_t, pre_x, pre_y = 0, 0, 0\nfor _ in range(N):\n t, x, y = list(map(int, input().split()))\n tmp = (t - pre_t) - abs(x - pre_x) - abs(y - pre_y)\n if tmp < 0 or tmp % 2 == 1:\n res = False\n break\n pre_t = t\n pre_x = x\n pre_y = y\n \nprint(('Yes' if res else 'No'))\n", "n = int(input())\nx, y = 0, 0\nt = 0\nfor i in range(n):\n ti, xi, yi = list(map(int, input().split()))\n l = abs(xi - x + yi - y)\n if l <= ti - t and l % 2 == (ti - t) % 2:\n x, y = xi, yi\n t = ti\n else:\n print(\"No\")\n break\nelse:\n print(\"Yes\")\n", "from collections import namedtuple\nplan = namedtuple('plan', ['time', 'x', 'y'])\n\ndef main():\n with open(0) as f:\n N = int(f.readline())\n plans = []\n for _ in range(N):\n t, x, y = map(int, f.readline().split())\n plans.append(plan(t, x, y))\n current = plan(0, 0, 0)\n for p in plans:\n t = p.time - current.time\n way = abs(p.x-current.x) + abs(p.y-current.y)\n if t < way:\n print('No')\n return None\n if (t - way) & 1:\n print('No')\n return None\n current = p\n else:\n print('Yes')\n\nmain()", "#2\u30d1\u30bf\u30fc\u30f3\u3067\u306efail\n#\u2460\u2192\u5076\u5947\u304cstep\u3068\u4f4d\u7f6e\u3067\u9055\u3046\n#\u5358\u7d14\u306b\u9060\u3059\u304e\u308b\nn = int(input())\n\nt_pre =0\nx_pre =0\ny_pre =0\nfor i in range(n):\n t,x,y = list(map(int,input().split()))\n if (t-t_pre)<abs(x-x_pre)+abs(y-y_pre):\n print('No')\n break\n if t%2 != (x+y)%2:\n print('No')\n break\n t_pre = t\n x_pre =x\n y_pre = y\n \n if i ==n-1:\n print('Yes')", "N = int(input())\ntxy = [[0, 0, 0]]\nfor i in range(N):\n txy.append(list(map(int, input().split())))\n\nfor i in range(N):\n dt = txy[i+1][0] - txy[i][0]\n dx = txy[i+1][1] - txy[i][1]\n dy = txy[i+1][2] - txy[i][2]\n \n if dt < abs(dx + dy):\n print('No')\n break\n else:\n if (dt - (dx + dy)) % 2 != 0:\n print('No')\n break\nelse:\n print('Yes')", "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n ans = 'Yes'\n n = int(input())\n now = [0,0]\n pt = 0\n for i in range(n):\n t, x, y = map(int, input().split())\n d = abs((x - now[0]) + (y - now[1]))\n if d > abs(t - pt) or (t - pt)%2 != d%2:\n ans = \"No\"\n break\n now = [x, y]\n pt = t\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "n=int(input())\ns = 0\na = 0\nb = 0\nfor i in range(n):\n t,x,y=map(int,input().split())\n if t-s - abs(x-a) - abs(y-b)>=0 and (t-s - abs(x-a) - abs(y-b)) %2 == 0:\n s = t\n a = x\n b = y\n else:\n print('No')\n return\nprint('Yes')", "n = int(input())\nx0 = 0\ny0 = 0\nt0 = 0\nfor i in range(n):\n \n t, x, y = map(int, input().split())\n d = abs(x - x0) + abs (y - y0)\n if d > t - t0:\n print('No')\n return\n elif (t - t0 - d) % 2 == 1:\n print('No')\n return\n else:\n x0 = x\n y0 = y\n t0 = t\n\nprint('Yes')", "n = int(input())\nrx = 0\nry = 0\nrt = 0\nok = True\nfor _ in range(n):\n t, x, y = map(int, input().split())\n dist = abs(x-rx) + abs(y-ry)\n #print(dist)\n if dist <= abs(t-rt) and (abs(t-rt)-dist)%2 == 0:\n rx = x\n ry = y\n rt = t\n else:\n print(\"No\")\n return\nprint(\"Yes\")", "N = int(input())\nA = [[0,0,0]]\nfor i in range(N):\n A.append(list(map(int, input().split())))\n\nflag = True\nfor i in range(N):\n if not flag:\n break\n time = int(A[i+1][0]) - int(A[i][0])\n dist = abs(A[i+1][1] - A[i][1]) + abs(A[i+1][2] - A[i][2]) # x2-x1 + y2-y1\n if time < dist:\n flag = False\n elif time % 2 != dist % 2:\n flag = False\n\nif flag:\n print('Yes')\nelse:\n print('No')", "import numpy as np\nN = int(input())\n\ntxy = [[0,0,0]]\nfor i in range(N):\n txy.append(list(map(int,input().split())))\n\nout='Yes'\nfor i in range(1,N+1):\n x = np.array(txy[i])\n y = np.array(txy[i-1])\n mv = abs(x-y)\n # print(mv)\n dam = mv[0] - (mv[1] + mv[2])\n if dam%2==1 or dam<0:\n out='No'\n\nprint(out)\n", "N = int(input())\nP = [[0,0,0]]\nfor i in range(N):\n t,x,y = list(map(int,input().split()))\n P.append([t,x,y])\njudge = True\nfor i in range(1,N+1):\n dt = P[i][0] - P[i-1][0]\n dist = abs(P[i][1] - P[i-1][1]) + abs(P[i][2] - P[i-1][2])\n if (dt % 2 == 0 and dist % 2 == 0 and dist <= dt) or (dt % 2 == 1 and dist % 2 == 1 and dist <= dt):\n judge = True\n else:\n judge = False\nif judge:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "from sys import stdin, stdout # only need for big input\n\n\ndef solve():\n n = int(input()) \n pos = []\n for _ in range(n):\n t, x, y = list(map(int, input().split()))\n pos.append((t,x,y))\n\n prev = (0, 0, 0)\n\n for p in pos:\n dt = p[0] - prev[0]\n move = abs(p[1] - prev[1]) + abs(p[2] - prev[2])\n if move > dt:\n print(\"No\")\n return\n else:\n if (dt - move) % 2 == 1:\n print(\"No\")\n return\n prev = p\n\n print(\"Yes\")\n\n \n \n\ndef main():\n solve()\n\n\ndef __starting_point():\n main()\n__starting_point()", "N=int(input())\nT=[0]*(N+1);S=[0]*(N+1);f=0\nfor i in range(1,N+1):\n t,x,y=map(int,input().split())\n T[i]=t\n S[i]=[x,y]\nT[0]=0;S[0]=[0,0]\n\n#print(T)\n#print(S)\n\nfor i in range(1,N+1):\n if (T[i]-T[i-1])<(abs(S[i][0]-S[i-1][0])+abs(S[i][1]-S[i-1][1])):\n f=1\n if (T[i]-T[i-1])%2!=(abs(S[i][0]-S[i-1][0])+abs(S[i][1]-S[i-1][1]))%2:\n f=1\n\nprint(\"Yes\" if f==0 else \"No\")", "N = int(input())\nt, x, y = 0, 0, 0\nans = 'Yes'\n\nfor n in range(N):\n ti,xi,yi = map(int,input().split())\n dist = abs(xi-x)+abs(yi-y)\n dt = ti-t\n if dist > dt or (dist-dt) % 2 != 0:\n ans='No'\n break\n t,x,y = ti,xi,yi\nprint(ans)", "t, x, y = 0, 0, 0\n\nfor i in range(int(input())):\n t_n, x_n, y_n = map(int, input().split())\n diff = abs(x - x_n) + abs(y - y_n)\n if diff > t_n - t or (t_n - t - diff) % 2 == 1:\n print(\"No\")\n return\n t, x, y = t_n, x_n, y_n\nprint(\"Yes\")", "# coding: utf-8\n\n\ndef main():\n N = int(input())\n ans = 'Yes'\n t, x, y = 0, 0, 0\n for _ in range(N):\n nt, nx, ny = list(map(int, input().split()))\n d = abs(x - nx) + abs(y - ny)\n if d > nt - t or (nt - t - d) % 2 != 0:\n ans = 'No'\n break\n t, x, y = nt, nx, ny\n\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "#!/user/bin/env pypy3\nimport sys\nfrom typing import NamedTuple, List\n\n\ndef fast_input():\n return sys.stdin.readline()[:-1]\n\n\nclass Position(NamedTuple):\n t: int\n x: int\n y: int\n\n def _calc_diff_move(self, position) -> int:\n diff_x = self.x - position.x\n diff_y = self.y - position.y\n return abs(diff_x) + abs(diff_y)\n\n def can_move_from(self, prev) -> bool:\n diff_t = self.t - prev.t\n diff_move = self._calc_diff_move(prev)\n if not diff_t % 2 == diff_move % 2:\n return False\n return diff_t >= diff_move\n\n\ndef result_format(b: bool) -> str:\n return \"Yes\" if b else \"No\"\n\n\ndef solve(positions: List[Position]) -> bool:\n positions = [Position(t=0, x=0, y=0)] + positions\n for p_ind in range(len(positions) - 1):\n p_curr = positions[p_ind]\n p_next = positions[p_ind + 1]\n if not p_next.can_move_from(p_curr):\n return False\n return True\n\n\ndef main():\n n = int(fast_input())\n positions = []\n for _ in range(n):\n t, x, y = list(map(int, fast_input().split()))\n positions.append(Position(t=t, x=x, y=y))\n result = solve(positions)\n print((result_format(result)))\n\n\nmain()\n", "import sys\nN = int(input())\nt_param = 0\nx_param = 0\ny_param = 0\n\nfor i in range(N):\n t, x, y = map(int, input().split())\n if (abs(x - x_param) + abs(y - y_param)) > (abs(t - t_param)) or ((x + y + t)%2) != 0 :\n print('No')\n return\n t_param = t\n x_param = x\n y_param = y\nprint('Yes')", "n = int(input())\nd = [list(map(int, input().split())) for _ in range(n)]\n\npT, pX, pY = 0, 0, 0\n\nfor i in range(n):\n cT, cX, cY = d[i]\n mvT, mvX, mvY = abs(cT-pT), abs(cX-pX), abs(cY-pY)\n \n dam = mvT - (mvX+mvY)\n\n if dam%2 == 1 or dam<0:\n print('No')\n return\n\n pT, pX, pY = d[i]\n\nprint('Yes')", "n = int(input())\n\ntxy = [list(map(int,input().split())) for _ in range(n)]\ntxy =[[0,0,0]] + txy\n\nfor i in range(n):\n move = abs(txy[i+1][1]-txy[i][1])+abs(txy[i+1][2]-txy[i][2])\n time = txy[i+1][0]-txy[i][0]\n if time % 2 ^ move % 2 == 1 or time < move:\n print(\"No\")\n return\n\nprint(\"Yes\")", "n_num = int(input())\nplan_list = [[0, (0, 0)]]\n\ndef movable(p1, p2):\n time = p2[0] - p1[0]\n distance = 0\n \n distance += abs(p1[1][0] - p2[1][0])\n distance += abs(p1[1][1] - p2[1][1])\n \n if distance > time:\n return 0\n else:\n if (time - distance) % 2 != 0:\n return 0\n else:\n return 1\n \n\nfor _ in range(n_num):\n line = [int(i) for i in input().split()]\n plan_list.append([line[0], (line[1], line[2])])\n \nvector = (0, 0)\n\nflag = 0\nfor n in range(1, n_num+1):\n if movable(plan_list[n-1], plan_list[n]) == 0:\n flag = 1\n \nif flag == 1:\n print('No')\nelse:\n print('Yes')", "# \u6700\u77ed\u3067\u305f\u3069\u308a\u7740\u3044\u305f\u3068\u3057\u3066\u76ee\u7684\u306e\u6642\u9593\u307e\u3067\u306e\u6b8b\u308a\u6642\u9593\u304c\u5947\u6570\u306a\u3089\u3070No\n# \u3042\u3068\u305d\u3082\u305d\u3082\u6642\u9593\u3092\u4f7f\u3063\u3066\u3082\u305f\u3069\u308a\u3064\u3051\u306a\u3044\u5834\u5408\u3082No\nn = int(input())\npos = [0, 0]\ntime = 0\nfor _ in range(n):\n t, x, y = list(map(int, input().split()))\n # \u6700\u77ed\u3067\u305f\u3069\u308a\u3064\u304f\u6642\u9593\n dist = abs(pos[0] - x) + abs(pos[1] - y)\n # \u305d\u3082\u305d\u3082\u305f\u3069\u308a\u3064\u3051\u306a\u3044\u5834\u5408\n if t - time < dist:\n print(\"No\")\n return\n # \u5076\u5947\u6027\n rest = t - time\n if rest % 2 != dist % 2:\n print(\"No\")\n return\n time = t\n pos = [x, y]\nprint(\"Yes\")\n", "N = int(input())\n\nInput = []\nfor i in range(N):\n Input.append(list(map(int, input().split())))\n\nposition = {\"x\":0, \"y\":0}\npreT = 0\nfor i in range(N):\n T = Input[i][0]\n x = Input[i][1]\n y = Input[i][2]\n\n move = abs(position[\"x\"] - x) + abs(position[\"y\"] - y)\n if move > (T - preT) or move % 2 != (T - preT) % 2:\n print(\"No\")\n return\n\n preT = T\n position[\"x\"] = x\n position[\"y\"] = y\n\nprint(\"Yes\")", "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\ndef main():\n n = i_input()\n xb = 0\n yb = 0\n tb = 0\n for i in range(n):\n t,x,y = i_map()\n walk = abs(x-xb) + abs(y-yb)\n if walk > t-tb: # \u6642\u9593\u8db3\u308a\u306a\u3044\n print(\"No\")\n return\n if ((t-tb)-walk)%2 != 0: # \u623b\u3063\u3066\u6765\u308c\u3093\n print(\"No\")\n return\n xb = x\n yb = y\n tb = t\n print(\"Yes\")\n\n\n\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\nl = [list(map(int, input().split())) for _ in range(n)]\n\nx = y = t = 0\nfor i in range(n):\n dx, dy, dt = l[i][1], l[i][2], l[i][0]\n dist = abs((dx - x) + (dy - y))\n\n if abs(dt - t) < dist:\n print(\"No\")\n return\n if abs(dt - t) % 2:\n if dist % 2 == 0:\n print(\"No\")\n return\n else:\n if dist % 2 == 1:\n print(\"No\")\n return\n x, y, t = dx, dy, dt\nprint(\"Yes\")", "N = int(input())\nt0, x0, y0 = 0, 0, 0\nfor i in range(N):\n t, x, y = list(map(int, input().split()))\n kyori = abs(x - x0) + abs(y - y0)\n time = t - t0\n if (abs(kyori - time)) % 2 == 0 and time - kyori >= 0:\n t0, x0, y0 = t, x, y\n else:\n print('No')\n return\nprint('Yes')\n", "N = int(input())\nP = [(0,0,0)] + [tuple(int(x) for x in input().split()) for _ in range(N)]\n\ndef travelable(p,q):\n time = q[0] - p[0]\n dist = abs(q[1]-p[1]) + abs(q[2]-p[2])\n if dist <= time and time%2 == dist%2:\n return True\n else:\n return False\nfrom itertools import zip_longest\nprint('Yes' if all(travelable(p,q) for p,q in zip_longest(P[:N],P[1:])) else 'No')", "N = int(input())\nt_x_y = [list(map(int, input().split())) for _ in range(N)]\nt_x_y.insert(0, [0, 0, 0])\n \nans = 'Yes'\nfor i in range(N):\n dt = t_x_y[i+1][0] - t_x_y[i][0]\n dist = abs(t_x_y[i+1][1] - t_x_y[i][1]) + abs(t_x_y[i+1][2] - t_x_y[i][2])\n \n # dt < dist \u304c\u5fc5\u8981\n if dt < dist:\n ans = 'No'\n break\n else:\n # dt >= dist \u306e\u4e0a\u3067\u3001dt\u3068dist\u306e\u5076\u5947\u304c\u4e00\u81f4\u3059\u308c\u3070\u3088\u3044\n if (dt - dist) % 2 != 0:\n ans = 'No'\n break\n \nprint(ans)", "N = int(input())\nt,x,y = 0,0,0\nfor i in range(N):\n a,b,c = t,x,y\n t,x,y = map(int,input().split())\n d = abs(x-b)+abs(y-c)\n e = t-a\n if d%2 != e%2 or d > e:\n print(\"No\")\n return\nprint(\"Yes\")", "import math\nn = int(input())\n#P position t time\nP = [0,0]\nt0 = 0\nfor _ in range(n):\n t,x,y = list(map(int, input().split( )))\n dt = t - t0\n dis = abs(x - P[0]) + abs(y - P[1])\n if dis > dt:\n print('No')\n return\n elif (dt - dis)%2 == 1:\n print('No')\n return\n t0 = t\n P = [x,y]\nprint('Yes')\n \n", "N = int(input())\nT = [0, 0, 0]\nans = \"Yes\"\nfor _ in range(N):\n t = list(map(int, input().split()))\n k = abs((t[1]+t[2])-(T[1]+T[2]))\n n = t[0]-T[0]\n if n % 2 == 0:\n if k > n or k % 2 != 0:\n ans = \"No\"\n else:\n if k > n or k % 2 == 0:\n ans = \"No\"\n T = t\n\nprint(ans)", "N = int(input())\nL = []\nfor i in range(N):\n t = list(map(int, input().split()))\n L.append(t)\n\nL.insert(0, [0,0,0])\n\nfor i in range(1, N+1):\n time = abs(L[i-1][0] - L[i][0])\n distance = abs(L[i-1][1] - L[i][1]) + abs(L[i-1][2] - L[i][2])\n if (time < distance) or (time%2 != distance%2):\n print('No')\n return\n\nprint('Yes')\n", "n = int(input())\nl = [list(map(int, input().split())) for _ in range(n)]\n\nx = y = t = 0\nfor i in range(n):\n dx, dy, dt = l[i][1], l[i][2], l[i][0]\n dist = abs((dx - x) + (dy - y))\n\n if abs(dt - t) < dist or (dt - t - dist) % 2:\n print(\"No\")\n return\n\n x, y, t = dx, dy, dt\nprint(\"Yes\")", "n = int(input())\nbt = 0\nbx = 0\nby = 0\nfor _ in range(n):\n t, x, y = map(int, input().split())\n dt = abs(x - bx) + abs(y - by)\n if dt > t - bt or dt % 2 != (t - bt) % 2:\n print(\"No\")\n break\n bt = t\n bx = x\n by = y\nelse:\n print(\"Yes\")", "import sys\nN = int(input())\nd = [list(map(int,input().split())) for l in range(N)]\nd.insert(0,[0,0,0])\n#print(N)\n#print(d)\n\ndef get_length(l1,l2):\n return abs(l1[1] - l2[1]) + abs(l1[2] - l2[2])\n\nfor cnt in range(N):\n length = get_length(d[cnt],d[cnt+1])\n time = abs(d[cnt][0]-d[cnt+1][0])\n if length <= time and abs(time - length) % 2 == 0:\n pass\n else:\n print(\"No\")\n return\n\nprint(\"Yes\")", "n=int(input())\na=[list(map(int,input().split())) for i in range(n)]\na.insert(0,[0,0,0])\nfor i in range(n):\n b=a[i+1][0]-a[i][0]\n c=abs(a[i+1][1]+a[i+1][2]-a[i][1]-a[i][2])\n if b<c or b%2!=c%2:\n print(\"No\")\n break\nelse:\n print(\"Yes\")", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Sep 21 23:53:42 2020\n\n@author: liang\n\"\"\"\n\nN = int(input())\n\nprev = (0, 0, 0)\n\nflag = True\n\nfor i in range(N):\n t, x, y = map(int, input().split())\n if t%2 != (x+y)%2:\n flag = False\n if abs(x+y - prev[1] - prev[2]) > t-prev[0]:\n flag = False\n prev = (t,x,y)\n\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")", "n = int(input())\npt, px, py = 0,0,0\nf = 0\nfor i in range(n):\n t,x,y = map(int, input().split())\n gt = t-pt\n gx, gy = abs(x-px), abs(y-py)\n gt -= gx+gy\n if gt < 0 or gt%2==1:\n f=1\n pt,px,py = t,x,y\nif f:\n print(\"No\")\nelse:\n print(\"Yes\")", "N = int(input())\n\npx = 0\npy = 0\npt = 0\n\nfor _ in range(N):\n T, X, Y = (int(i) for i in input().split())\n\n d = abs(X - px + Y - py)\n dt = (T - pt)\n if d > dt or (d % 2) != (dt % 2):\n print('No')\n import sys\n return\n else:\n px = X\n py = Y\n pt = T\n\nprint('Yes')\n", "n = int(input())\npt, px, py = 0, 0, 0\n\nfor _ in range(n):\n t, x, y = map(int, input().split())\n d = abs(x-px) + abs(y-py)\n if d > t-pt or (d + t-pt)%2 != 0:\n print(\"No\")\n return\n pt, px, py = t, x, y\nprint(\"Yes\")", "N = int(input())\n\nlocx = 0\nlocy =0\ntime = 0\nfor i in range(N):\n t,x,y = map(int,input().split())\n nowtime = t-time\n dis = abs(locx-x)+abs(locy-y)\n if (nowtime-dis)<0 :\n print(\"No\")\n return\n if (nowtime-dis)%2 == 1:\n print(\"No\")\n return\n \n \n time = t\n locx = x\n locy = y\n \n \nelse :\n print(\"Yes\")", "n=int(input())\n \nnum,a,b=0,0,0\n \nfor i in range(n):\n t,x,y=map(int,input().split())\n num,a,b=abs(t-num),abs(x-a),abs(y-b)\n su=a+b\n if num>=su and num%2 == su%2:\n ans=\"Yes\"\n else:\n ans=\"No\"\n break\n \nprint(ans)", "N = int(input())\nP = [list(map(int,input().split())) for i in range(N)] # list of [t, x, y]\npret = prex = prey = 0\nf = 1\nfor i in range(N):\n t = P[i][0]\n x = P[i][1]\n y = P[i][2]\n td = t - pret\n xd = abs(x - prex)\n yd = abs(y - prey)\n diff = xd + yd # \u6700\u4f4e\u304b\u304b\u308bt\n if td < diff:\n f = 0\n break\n if (td - diff) % 2 == 0:\n pret = t\n prex = x\n prey = y\n continue\n else:\n f = 0\n break\nif f == 1:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\ntxn = []\nfor i in range(N):\n txn.append([int(i) for i in input().split()])\n\nima = [0,0,0]\nfor i in range(N):\n dist = abs(ima[1] - txn[i][1]) + abs(ima[2] - txn[i][2])\n\n if dist > (txn[i][0] - ima[0]) :\n print(\"No\")\n return\n \n if dist%2 != (txn[i][0] - ima[0])%2 :\n print(\"No\")\n return\n \n ima = txn[i]\n\nprint(\"Yes\")", "N = int(input())\nP = [(0,0,0)] + [tuple(int(x) for x in input().split()) for _ in range(N)]\n\ndef travelable(p,q):\n time = q[0] - p[0]\n dist = abs(q[1]-p[1]) + abs(q[2]-p[2])\n if dist <= time and time%2 == dist%2:\n return True\n else:\n return False\n \nprint('Yes' if all(travelable(p,q) for p,q in zip(P[:N],P[1:])) else 'No')", "N = int(input())\nsuccess = True\n\nt0,x0,y0 = 0,0,0\nfor i in range(N):\n t1,x1,y1 = map(int,input().split())\n dist = abs(x1-x0) + abs(y1-y0)\n time = t1 - t0\n \n check1 = (time == dist)\n check2 = (time > dist) and ((time - dist) % 2 == 0)\n if not (check1 or check2):\n success = False\n break\n \n t0,x0,y0 = t1,x1,y1\n \nif success:\n print(\"Yes\")\nelse:\n print(\"No\")", "n=int(input())\n\ndef func(start,goal,t):\n distance=abs(start[0]-goal[0])+abs(start[1]-goal[1])\n if distance<=t and (t-distance)%2==0:\n return True\n return False\nnow=0\ncan=1\nstart=[0,0]\nfor i in range(n):\n t,x,y=[int(i) for i in input().split()]\n goal=[x,y]\n if not func(start,goal,t-now):\n can=0\n break\n else:\n start=goal\n now=t\n\nif can==1:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n = int(input())\nti, xi, yi = (0,0,0)\nfor i in range(n):\n ti1, xi1, yi1 = list(map(int, input().split()))\n if abs(xi1-xi)+abs(yi1-yi) <= (ti1-ti) and (abs(xi1-xi)+abs(yi1-yi))%2 == (ti1-ti)%2:\n xi = xi1\n yi = yi1\n ti = ti1\n continue\n else:\n print(\"No\")\n return\nprint(\"Yes\")\n", "n=int(input())\na = [0]*(n+1)\na[0] = [0, 0, 0]\nfor i in range(n):\n a[i+1]=list(map(int,input().split()))\n\nflag = True\nfor i in range(n):\n if abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2]) > (a[i+1][0]-a[i][0]):\n flag=False\n elif (abs(a[i+1][1]-a[i][1])+abs(a[i+1][2]-a[i][2])-(a[i+1][0]-a[i][0]))%2==1:\n flag=False\n\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")\n", "n=int(input())\n\nnum,a,b=0,0,0\n\nfor i in range(n):\n t,x,y=list(map(int,input().split()))\n num,a,b=abs(t-num),abs(x-a),abs(y-b)\n su=a+b\n if num>=su and num%2 == su%2:\n ans=\"Yes\"\n else:\n ans=\"No\"\n break\n \nprint(ans)\n", "N = int(input())\nT = []\nXY = []\n\n\ndef f(x1, y1, x2, y2):\n return abs(x1 - x2) + abs(y1 - y2)\n\n\ncx, cy = 0, 0\nct = 0\nfor _ in range(N):\n t, x, y = list(map(int, input().split()))\n d = f(cx, cy, x, y)\n # print(f'{ct=}, {t=}, {d=}')\n if d > t - ct:\n print('No')\n return\n if (t - ct - d) % 2 != 0:\n print('No')\n return\n cx, cy = x, y\n ct = t\nprint('Yes')\n", "'''\nCreated on 2020/08/31\n\n@author: harurun\n'''\ndef main():\n import sys\n pin=sys.stdin.readline\n pout=sys.stdout.write\n perr=sys.stderr.write\n\n N=int(pin())\n time=0\n nx=0\n ny=0\n for i in range(N):\n t,x,y=list(map(int,pin().split()))\n d=abs(nx-x)+abs(ny-y)\n s=t-time\n if d<=s and s%2==d%2:\n time=t\n nx=x\n ny=y\n else:\n print(\"No\")\n return\n print(\"Yes\")\n return\nmain()\n#kaisetuAC\n", "n = int(input())\npx = py = pt = 0\nfor i in range(n):\n\tt,x,y = map(int,input().split())\n\td = abs(x - px) + abs(y - py)\n\tnt = t - pt\n\tif nt < d or d%2 != nt%2:\n\t\tprint(\"No\")\n\t\treturn\n\tpx = x\n\tpy = y\n\tpt = t\nprint(\"Yes\")", "n=int(input())\ntxy=[list(map(int,input().split())) for i in range(n)]\nx,y=0,0\nt=0\nfor i in range(n):\n if abs((x+y) - (txy[i][1]+txy[i][2]))%2 == abs(t-txy[i][0])%2 and abs(t-txy[i][0]) >= abs((x+y)-(txy[i][1]+txy[i][2])):\n x,y=txy[i][1],txy[i][2]\n else:\n print(\"No\")\n return\n t=txy[i][0]\nprint(\"Yes\")", "n=int(input())\na=[[0,0,0]]\n\nfor i in range(n):\n a.append(list(map(int, input().split(\" \"))))\nfor i in range(n):\n check = a[i + 1][0] - a[i][0] - (abs(a[i+1][1]-a[i][1]) + abs(a[i+1][2]-a[i][2]))\n if check >= 0 and check % 2 == 0:\n continue\n else:\n print(\"No\")\n break\nelse:\n print(\"Yes\")", "# coding: utf-8\n\n\ndef main():\n N = int(input())\n ans = 'Yes'\n t, x, y = 0, 0, 0\n for _ in range(N):\n nt, nx, ny = list(map(int, input().split()))\n d = abs(x - nx) + abs(y - ny)\n if d > nt - t or (nt - t - d) % 2 != 0:\n ans = 'No'\n break\n t, x, y = nt, nx, ny\n\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\ns = [list(map(int,input().split())) for i in range(n)]\nstand = [0,0]\nprev = 0\n\nfor t,x,y in s:\n diff = abs(x+y-sum(stand))\n walk = t-prev\n if diff<=walk and walk%2==diff%2:\n stand=[x,y]\n prev = t\n else:\n print('No')\n break\nelse:\n print('Yes')\n", "N = int(input())\nt0, x0, y0 = 0, 0, 0\nfor i in range(N):\n t, x, y = list(map(int, input().split()))\n kyori = abs(x - x0) + abs(y - y0)\n time = abs(t0 - t)\n if abs(kyori - time) % 2 == 0 and time - kyori >= 0:\n t0, x0, y0 = t, x, y\n else:\n print('No')\n return\nprint('Yes')\n", "N = int(input())\n\na = [list(map(int, input().split())) for i in range(N)]\n\nfor i in range(N):\n if i == 0:\n if (a[i][0] - a[i][1] - a[i][2]) % 2 != 0 or (a[i][0] - a[i][1] - a[i][2]) < 0:\n print(\"No\")\n return\n else:\n if (a[i][0] - a[i][1] - a[i][2]) % 2 != 0 or (a[i][0]- a[i-1][0]) -( (a[i-1][1] + a[i-1][2] )-(a[i][1] + a[i][2])) < 0:\n print(\"No\")\n return\nprint(\"Yes\")", "N = int(input())\nt_x_y = [list(map(int, input().split())) for _ in range(N)]\nt_x_y.insert(0, [0, 0, 0])\n\nans = 'Yes'\nfor i in range(N):\n dt = t_x_y[i+1][0] - t_x_y[i][0]\n dist = abs(t_x_y[i+1][1] - t_x_y[i][1]) + abs(t_x_y[i+1][2] - t_x_y[i][2])\n \n if dt < dist:\n ans = 'No'\n break\n else:\n # dt >= dist\n if (dt - dist) % 2 != 0:\n ans = 'No'\n break\n \nprint(ans)", "N = int(input())\n\nt = [0]\nx = [0]\ny = [0]\nfor i in range(N):\n l = [int(c) for c in input().split()]\n t.append(l[0])\n x.append(l[1])\n y.append(l[2])\n\nfor i in range(N):\n move = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])\n time = t[i+1]-t[i]\n if time%2 ^ move%2 == 1 or time < move:\n print(\"No\")\n return\n\nprint(\"Yes\")", "n=int(input())\nbx=by=bt=0\nans='Yes'\n\nfor i in range(n):\n t,x,y=map(int, input().split())\n if t%2!=(x+y)%2:\n ans='No'\n if abs(bx-x)+abs(by-y)>abs(bt-t):\n ans='No'\n bx=x\n by=y\n bt=t\n\nprint(ans)", "n = int(input())\nl = [(0,0,0)]\nflag = 1\nfor i in range(n):\n l.append(list(map(int,input().split())))\nfor i in range(n):\n d = abs(l[i+1][1] - l[i][1]) + abs(l[i+1][2] - l[i][2])\n if l[i+1][0] - l[i][0] >= d and (l[i+1][0] - l[i][0] - d) % 2 == 0:\n continue\n else:\n flag = 0\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")\n\n \n\n", "#!/user/bin/env pypy3\nimport sys\nfrom typing import NamedTuple, List\n\n\ndef fast_input():\n return sys.stdin.readline()[:-1]\n\n\nclass Position(NamedTuple):\n t: int\n x: int\n y: int\n\n def _calc_diff_move(self, position) -> int:\n diff_x = self.x - position.x\n diff_y = self.y - position.y\n return abs(diff_x) + abs(diff_y)\n\n def can_move_from(self, prev) -> bool:\n diff_t = self.t - prev.t\n diff_move = self._calc_diff_move(prev)\n # \u5947\u6570\u306e\u3068\u304d\u306f\u305d\u306e\u5834\u7981\u6b62\n if not diff_t % 2 == diff_move % 2:\n return False\n return diff_t >= diff_move\n\n\ndef result_format(b: bool) -> str:\n return \"Yes\" if b else \"No\"\n\n\ndef solve(positions: List[Position]) -> bool:\n positions = [Position(t=0, x=0, y=0)] + positions\n for p_ind in range(len(positions) - 1):\n p_curr = positions[p_ind]\n p_next = positions[p_ind + 1]\n if not p_next.can_move_from(p_curr):\n return False\n return True\n\n\ndef main():\n n = int(fast_input())\n positions = []\n for _ in range(n):\n t, x, y = list(map(int, fast_input().split()))\n positions.append(Position(t=t, x=x, y=y))\n result = solve(positions)\n print((result_format(result)))\n\n\nmain()\n", "cnt = int(input())\n\nt_s, x_s, y_s = 0, 0, 0\nfor _ in range(cnt):\n t, x, y = map(int, input().split())\n d_t, d_x, d_y = t-t_s, x-x_s, y-y_s\n z = abs(d_x + d_y)\n if z > d_t or (d_t - z)%2 == 1:\n print(\"No\")\n break\n t_s, x_s, y_s = t, x, y\nelse:\n print(\"Yes\")", "n=int(input())\nlocation=list(map(str,[input() for i in range(n)]))\nfail=0\nfor j in range(n):\n if j==0:\n a=[0,0,0]\n else:\n a=list(map(int, location[j-1].split()))\n b=list(map(int,location[j].split()))\n x=abs(a[1]-b[1])\n y=abs(a[2]-b[2])\n t=b[0]-a[0]\n if x+y<=t:\n if (x+y)%2==t%2:\n pass\n else:\n fail+=1\n else:\n fail+=1\nif fail==0:\n print(\"Yes\")\nelse:\n print(\"No\")", "N=int(input())\nP=[(0,0,0)]\nfor i in range(N):\n\tt,x,y=map(int,input().split())\n\tP.append((t,x,y))\n\nT=[0]*N\ndist=[0]*N\n\nfor i in range(N):\n\tT[i]=P[i+1][0]-P[i][0]\n\tdist[i]=abs(P[i+1][1]-P[i][1])+abs(P[i+1][2]-P[i][2])\n\nans=1\nfor i in range(N):\n\tif dist[i]>T[i]:\n\t\tans=0\n\telse:\n\t\tm=T[i]-dist[i]\n\t\tif m%2==0:\n\t\t\tpass\n\t\telse:\n\t\t\tans=0\n\tif ans==0:\n\t\tbreak\nprint(\"Yes\" if ans==1 else \"No\")", "n = int(input())\n\nT = [0]\nX = [0]\nY = [0]\n\njudge = 'Yes'\n\nfor i in range(n):\n t, x, y = map(int,input().split())\n T.append(t)\n X.append(x)\n Y.append(y)\n\nfor i in range(1, n+1):\n delt_t = T[i] - T[i-1]\n t_parity = delt_t % 2\n d = abs(X[i] - X[i -1]) + abs(Y[i] - Y[i - 1])\n d_parity = d % 2\n if delt_t >= d and t_parity == d_parity:\n continue\n else:\n judge = 'No'\n break\n\nprint(judge)", "n = int(input())\nrx = 0\nry = 0\nrt = 0\nok = True\nfor _ in range(n):\n t, x, y = map(int, input().split())\n dist = abs(x-rx) + abs(y-ry)\n #print(dist)\n if dist <= abs(t-rt) and (abs(t-rt)-dist)%2 == 0:\n rx = x\n ry = y\n rt = t\n else: ok = False\n\nif ok: print(\"Yes\")\nelse: print(\"No\")", "n=int(input())\narr=[[0,0,0]]+[list(map(int,input().split())) for _ in range(n)]\nfor i in range(n):\n t1,x1,y1=arr[i]\n t2,x2,y2=arr[i+1]\n if abs(x1-x2)+abs(y1-y2)>t2-t1:\n print('No')\n return\n if (abs(x1-x2)+abs(y1-y2))%2!=(t2-t1)%2:\n print('No')\n return\nprint('Yes')", "Row = int(input())\nList = []\nfor i in range (Row):\n List.append(list(map(int, input().split())))\nx = 0\ny = 0\nT = 0\nflag = True\nfor i in range(Row):\n reqT = abs(List[i][1]-x)+abs(List[i][2]-y)\n chck= List[i][0] - T - reqT\n if chck < 0 or chck % 2 == 1:\n flag = False\n break\n x = List[i][1]\n y = List[i][2]\n T = List[i][0]\nif flag:\n print(\"Yes\")\nelse:\n print(\"No\")", "N = int(input())\nl = [list(map(int, input().split())) for _ in range(N)]\n\npT, pX, pY = 0, 0, 0\n\nfor i in range(N):\n cT, cX, cY = l[i]\n mvT, mvX, mvY = abs(cT-pT), abs(cX-pX), abs(cY-pY)\n \n dam = mvT - (mvX+mvY)\n\n if dam %2 == 1 or dam < 0:\n print('No')\n return\n\n pT, pX, pY = l[i]\n\nprint('Yes')\n\n", "N = int(input())\npt, px, py = 0, 0, 0\ncan = True\nfor i in range(N):\n t, x, y = map(int, input().split())\n T, X, Y = t - pt, abs(x - px), abs(y - py)\n if T < X + Y or T % 2 != (X + Y) % 2:\n can = False\n pt, px, py = t, x, y\nprint('Yes' if can else 'No')", "N=int(input())\nt=[0]\nx=[0]\ny=[0]\nfor _ in range(N):\n a,b,c=list(map(int,input().split()))\n t.append(a)\n x.append(b)\n y.append(c)\n\nfor i in range(N):\n X=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])\n T=abs(t[i+1]-t[i])\n if X>T or X%2!=T%2:\n print(\"No\")\n break\nelse:\n print(\"Yes\")\n", "N = int(input())\n\nplan = []\n\nFeasible = True\n\nfor i in range(N):\n t,x,y = map(int,input().split())\n plan.append([t,x,y])\n\nt0,x0,y0 = 0,0,0\n\nfor t1,x1,y1 in plan:\n dx = x1-x0\n dy = y1-y0\n dt = t1-t0\n dist = abs(dx)+abs(dy)\n d = dt - dist\n \n if dt < dist:\n Feasible = False\n elif (dist+dt)%2 != 0:\n Feasible = False\n t0,x0,y0 = t1,x1,y1\nprint(\"Yes\" if Feasible else \"No\")", "n = int(input())\npt,px,py = 0, 0, 0\n\nfor _ in range(n):\n ct,cx,cy = map(int,input().split())\n t = ct - pt\n d = abs(cx-px) + abs(cy-py)\n if t < d or (t%2) != (d%2):\n print('No')\n break\n pt,px,py = ct,cx,cy\nelse:\n print('Yes')", "def check(dest,start):\n ll = dest[1] - start[1] + dest[2]-start[2]\n if ll < 0:\n ll = -ll\n time = dest[0] - start[0]\n tmp = ll - time\n if tmp <= 0 and tmp%2 == 0 :\n return True\n else:\n return False\n\nn = int(input())\nstart = [0,0,0]\nfor i in range(n):\n dest = list(map(int, input().split()))\n if check(dest,start):\n start = dest\n else:\n print(\"No\")\n return\n\nprint(\"Yes\")", "# -*- coding: utf-8 -*-\nimport numpy as np\nimport sys\nfrom collections import deque\nfrom collections import defaultdict\nimport heapq\nimport collections\nimport itertools\nimport bisect\nfrom scipy.special import comb\nimport copy\nsys.setrecursionlimit(10**6)\n\n\ndef zz():\n return list(map(int, sys.stdin.readline().split()))\n\n\ndef z():\n return int(sys.stdin.readline())\n\n\ndef S():\n return sys.stdin.readline()[:-1]\n\n\ndef C(line):\n return [sys.stdin.readline() for _ in range(line)]\n\n\nN = z()\nT, X, Y = [], [], []\npos_x, pos_y, now_t = 0, 0, 0\nfor i in range(N):\n t, x, y = zz()\n T.append(t)\n X.append(x)\n Y.append(y)\nok = 1\nfor t, x, y in zip(T, X, Y):\n if (abs(x - pos_x) + abs(y - pos_y) > (t - now_t)):\n ok = 0\n break\n if (((abs(x - pos_x) + abs(y - pos_y)) % 2) != ((t - now_t) % 2)):\n ok = 0\n break\n pos_x, pos_y, now_t = x, y, t\nif(ok == 1):\n print('Yes')\nelse:\n print('No')\n", "n=int(input())\ntxylist=[[0,0,0]]\nfor i in range(n):\n txy=list(map(int,input().split(\" \")))\n txylist+=[txy]\nfor i in range(n):\n p=False\n t0,x0,y0=txylist[i]\n t1,x1,y1=txylist[i+1]\n t,x,y=t1-t0,x1-x0,y1-y0\n tt=abs(x)+abs(y)\n legs=t-tt\n if legs>=0 and legs%2==0:\n p=True\n else:\n print(\"No\")\n break\nif p==True:\n print(\"Yes\")"]
{"inputs": ["2\n3 1 2\n6 1 1\n", "1\n2 100 100\n", "2\n5 1 1\n100 1 1\n"], "outputs": ["Yes\n", "No\n", "No\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
40,892
fca88f268b06b2a78a97370b7f163358
UNKNOWN
You are given two positive integers a and b. Let x be the average of a and b. Print x rounded up to the nearest integer. -----Constraints----- - a and b are integers. - 1 \leq a, b \leq 100 -----Input----- Input is given from Standard Input in the following format: a b -----Output----- Print x rounded up to the nearest integer. -----Sample Input----- 1 3 -----Sample Output----- 2 The average of 1 and 3 is 2.0, and it will be rounded up to the nearest integer, 2.
["a, b = map(int, input().split())\nprint(((a + b) + (2 - 1)) // 2)", "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\na, b = LI()\nx = a + b\n\nif x%2 == 0:\n print(x//2)\nelse:\n print((x+1)//2)", "import math\na,b = map(int,input().split())\nprint(math.ceil((a+b)/2))", "import decimal\n\na, b = list(map(int, input().split()))\n\nnum = decimal.Decimal((a + b) / 2)\n\nans = int(num)\nif num % 1 != 0:\n ans += 1\n\nprint(ans)\n", "import math\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 a, b = Input()\n print(math.ceil((a+b)/2))\n\n\nmain()", "import math\n\na,b = map(int,input().split())\n\nans = math.ceil((a+b)/2)\n\nprint(ans)", "a,b = map(int,input().split())\nimport math\nprint(math.ceil((a+b)/2))", "import math\na, b = map(int, input().split())\nprint(math.ceil((a+b)/2))", "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()\nx=A+B\n\nif x%2==0:\n print((x//2))\nelse:\n print(((x+1)//2))\n", "import math\na, b = map(int, input().split())\nprint(math.ceil((a + b) / 2))", "#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)]\nv = (a+b)//2\nmod = (a+b) % 2\nif mod == 0:\n print(v)\nelse:\n print((v+1))\n", "a, b = map(int, input().split())\nx = a + b\nif x % 2 == 0:\n print(int(x/2))\nelse:\n print(int((x + 1)/2))", "a,b=map(int,input().split())\nif (a%2 == 0 and b%2 == 0) or (a%2 == 1 and b%2 == 1):\n print((a+b)//2)\nelse:\n print(((a+b)//2) + 1)", "a,b=map(int,input().split())\nprint(-(-(a+b)//2))", "a, b = map(int, input().split())\nans = (-(a+b))//2\n\nprint(-ans)", "import math\n\na, b = map(int, input().split())\nx = (a + b) / 2\nprint(math.ceil(x))", "import math\nx,y = map(int,input().split())\nprint(math.ceil((x+y)/2))", "lst = input().split()\na = int(lst[0])\nb = int(lst[1])\n\nv1 = (a + b) / 2\nv2 = (a + b) // 2\n\nif v1 == v2:\n print(v2)\nelse:\n print(v2 + 1)", "import math\na, b = map(int , input().split())\nprint(math.ceil((a + b)/2) )", "a,b=map(int,input().split())\nprint(abs(-(a+b)//2))", "import math\na, b = map(int, input().split())\nprint(math.ceil((a+b)/2))", "#82\na,b=map(int,input().split())\nimport math\nprint(math.ceil((a+b)/2))", "a,b=input().split()\na=int(a)\nb=int(b)\nif (a+b)%2==0:\n print(int((a+b)/2))\nelse:\n print(int((a+b)/2)+1)", "#!/usr/bin/env python3\nimport math\nimport sys\nsys.setrecursionlimit(10**6)\n\na, b = list(map(int, input().split()))\n\n\nprint((math.ceil((a+b)/2)))\n", "a,b = map(int,input().split())\nprint((a+b+1)//2)", "a,b=map(int,input().split())\nprint((a+b+1)//2)", "a,b=map(int,input().split())\nans=(a+b)//2\nprint(ans if (a+b)&1!=1 else ans+1)", "a, b = map(int, input().split())\nimport math\nprint(math.ceil((a + b) / 2))", "print(((sum(map(int,input().split()))-1)//2+1))\n", "a, b = map(int, input().split())\n\n\nx = (a + b) / 2\nif x % 1 == 0:\n print(int(x))\nelse:\n print(int(x + 1))", "a,b = map(int,input().split())\n\nimport math\nprint(math.ceil((a + b) / 2))", "a,b=list(map(int,input().split()))\nc=(a+b)/2\nif c%1>0:\n print((int(c+1)))\nelse:\n print((int(c)))\n", "import math\n\na, b = list(map(int, input().split()))\n\nsum_ceil = math.ceil((a+b)/2)\n\nprint(sum_ceil)\n", "import math\na,b=list(map(int,input().split()))\nprint((math.ceil((a+b)/2)))\n", "a,b = map(int,input().split())\nprint(-(-(a+b)//2))", "import math\na, b = map(int, input().split())\nave = (a+b) / 2\nprint(math.ceil(ave))", "import math\na,b=map(int,input().split())\nprint(math.ceil((a+b)/2))", "import numpy as np\nX = np.array([int(x) for x in input().split()])\nans = np.ceil(np.mean(X))\nprint(int(ans))", "a,b=map(int,input().split())\nprint((a+b+1)>>1)", "a,b = map(int, input().split())\nimport math\nprint(math.ceil((a+b)/2))", "A, B = map(int, input().split())\nif (A+B)%2 == 1:\n print((A+B)//2+1)\nelse:\n print((A+B)//2)", "a, b = map(int, input().split())\nprint(int((a+b+1)/2))", "a,b = map(int,input().split())\nif (a+b) % 2 == 0:\n print((a+b)//2)\nelse:\n print((a+b)//2 + 1)", "import math as mt\na,b=map(int, input().split())\nprint(mt.ceil((a+b)/2))", "import math\na,b=map(int,input().split())\nprint(math.ceil((a+b)/2))", "a, b = map(int, input().split())\nprint((a + b + 1) // 2)", "a, b = map(int, input().split())\n\nif (a+b)%2 == 0:\n ans=(a+b)//2\nelse:\n ans=(a+b)//2 +1\nprint(ans)", "from math import ceil\na,b = map(int,input().split())\nprint(ceil((a+b)/2))", "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 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\na,b = I()\nprint(math.ceil((a+b)/2))", "a, b = map(int, input().split())\nif (a+b)%2 == 0:\n print((a+b)//2)\nelse:\n print((a+b)//2 + 1)", "import math\n\na, b = map(int, input().split())\nresult = math.ceil((a + b) / 2)\nprint(result)", "a, b = map(int, input().split())\n\nprint((a + b + 1) // 2)", "import math\na,b=map(int,input().split());print(math.ceil((a+b)/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)\ne1,e2 = list(map(int,input().split()))\n#f = list(map(int,input().split()))\n#g = [input() for _ in range(a)]\nprint((math.ceil((e1+e2)/2)))\n\n\n", "import math\n\na, b = map(int, input().split())\navg = (a + b) / 2\nprint(math.ceil(avg))", "import math\na, b = (int(t) for t in input().split())\nx = (a + b) / 2\nprint(math.ceil(x))", "a, b = map(int,input().split())\nif (a+b) % 2 == 0:\n ans = (a+b) // 2\nelse:\n ans = (a+b) // 2 + 1\nprint(ans)", "import math\na,b = map(int,input().split())\nprint(math.ceil((a+b)/2))", "import math\na, b = map(int, input().split())\nprint(math.ceil((a+b)/2))", "from numpy import average\na, b = map(int,input().split())\nprint((a + b - 1) // 2 + 1)", "a , b = list(map(int,input().split()))\nprint((-(-(a+b)//2)))\n", "import math\n\na, b = list(map(int, input().split()))\nprint((math.ceil((a + b) / 2)))\n", "import math\na,b=map(int,input().split())\nprint(math.ceil((a+b)/2))", "a, b =map(int, input().split())\nprint(int((a+b+1)/2))", "a,b = map(int,input().split())\n\nif (a+b)%2==0:\n print(\"{:.0f}\".format((a+b)/2))\nelse:\n print(\"{:.0f}\".format((a+b)/2-0.5+1))", "a,b=map(int,input().split())\nif (a+b)%2==0:\n print((a+b)//2)\nelse:\n print((a+b)//2+1)", "a,b=map(int,input().split())\nprint(-(-(a+b)//2))", "a,b=map(int,input().split())\nc=a+b\nif c%2==0:\n print(c//2)\nelse:\n print(c//2+1)", "a,b=map(int,input().split())\nif (a+b)%2==0 :\n print((a+b)//2)\nelse :\n print((a+b)//2+1)", "#\n# abc082 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 = \"\"\"1 3\"\"\"\n output = \"\"\"2\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"7 4\"\"\"\n output = \"\"\"6\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"5 5\"\"\"\n output = \"\"\"5\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n a, b = list(map(int, input().split()))\n print(((a+b+1)//2))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "import math\na, b = map(int, input().split())\nprint(math.ceil((a+b)/2))", "#ABC082A\na,b = list(map(int,input().split()))\na+=b\nprint(((a+2-1)//2))\n", "import math\n\n\ndef main():\n a, b = map(int, input().split())\n print(math.ceil((a+b)/2))\n \n\ndef __starting_point():\n main()\n__starting_point()", "a,b=map(int,input().split(\" \"))\nprint((a+b)//2+(a+b)%2)", "a,b=map(int,input().split())\nimport math\nprint(math.ceil((a+b)/2))", "from math import ceil\n\na, b = map(int, input().split())\nprint(ceil((a + b) / 2))", "a,b=map(int,input().split())\nprint(-(-(a+b)//2))", "a, b = map(int, input().split())\nfrom math import ceil\nprint(ceil((a+b)/2))", "import math\nx, y = map(int, input().split())\nprint(math.ceil((x + y) / 2))", "from math import ceil\na,b = map(int, input().split())\nprint(ceil((a+b)/2))", "a, b = list(map(int,input().split()))\nprint(((a + b - 1) // 2 + 1))\n", "a,b = list(map(int,input().split()))\n\nprint((-(-(a+b)//2)))\n", "a, b = list(map(int, input().split()))\nres = (a + b + 2 - 1) // 2\nprint(res)\n", "a, b = list(map(int, input().split()))\nprint((-(-(a + b) // 2)))\n", "print(sum(map(int, input().split())) + 1 >> 1)", "import math\n\na, b = map(int, input().split())\nx = (a + b) / 2\n\nprint(math.ceil(x))", "import sys\nimport math\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\na, b = inl()\n\nx = (a + b + 1) // 2\nprint(x)\n", "a,b = map(int,input().split())\nprint((a+b+1)//2)", "\nimport math\na, b = map(int, input().split())\nmulti = math.ceil((a + b) / 2)\n\nprint(str(multi))", "import math\na, b = map(int, input().split())\nprint(math.ceil((a+b)/2))", "a,b = map(int, input().split())\nprint((a+b+1)//2)", "a,b = list(map(int,input().split()))\nprint((-(-(a+b)//2)))\n\n", "import math\n\n\na, b = map(int, input().split())\nx = (a + b) / 2\nprint(math.ceil(x))", "import math\n\na, b = map(int, input().split())\nprint(math.ceil((a+b)/2))", "import math\na,b=map(int,input().split())\nx=(a+b)/2\nprint(math.ceil(x))", "import math\na, b = [int(x) for x in input().split()]\nprint(math.ceil((a+b)/2))", "import math\n\na, b = map(int, input().split())\n\nprint(math.ceil((a + b) / 2))", "a, b = map(int, input().split())\nprint(((a+b+1)//2))", "a,b = map(int,input().split())\nprint((a+b)//2 if (a+b)%2==0 else (a+b)//2+1)"]
{"inputs": ["1 3\n", "7 4\n", "5 5\n"], "outputs": ["2\n", "6\n", "5\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
11,457
4f896dcca992bfc1aac5cc93d5e57ad6
UNKNOWN
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges. The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i. An edge whose removal disconnects the graph is called a bridge. Find the number of the edges that are bridges among the M edges. -----Notes----- - A self-loop is an edge i such that a_i=b_i (1 \leq i \leq M). - Double edges are a pair of edges i,j such that a_i=a_j and b_i=b_j (1 \leq i<j \leq M). - An undirected graph is said to be connected when there exists a path between every pair of vertices. -----Constraints----- - 2 \leq N \leq 50 - N-1 \leq M \leq min(N(Nβˆ’1)⁄2,50) - 1 \leq a_i<b_i \leq N - The given graph does not contain self-loops and double edges. - The given graph is connected. -----Input----- Input is given from Standard Input in the following format: N M a_1 b_1 a_2 b_2 : a_M b_M -----Output----- Print the number of the edges that are bridges among the M edges. -----Sample Input----- 7 7 1 3 2 7 3 4 4 5 4 6 5 6 6 7 -----Sample Output----- 4 The figure below shows the given graph: The edges shown in red are bridges. There are four of them.
["import sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\ndef NIJIGEN(H): return [list(input()) for i in range(H)]\ndef dfs(j):\n if j not in finish:\n finish.add(j)\n for k in L[j]:\n dfs(k)\nN,M=MAP()\ns=list()\nL=[[] for _ in range(N)]\nfor i in range(M):\n a,b=MAP()\n a-=1\n b-=1\n L[a].append(b)\n L[b].append(a)\n s.append([a,b])\nans=0\nfor i in range(M):\n a,b=s[i]\n L[a].remove(b)\n L[b].remove(a)\n finish=set()\n dfs(a)\n if len(finish)!=N:\n ans+=1\n L[a].append(b)\n L[b].append(a)\nprint(ans)", "class UnionFind():\n \"\"\"\n parents\n \u5404\u8981\u7d20\u306e\u89aa\u8981\u7d20\u306e\u756a\u53f7\u3092\u683c\u7d0d\u3059\u308b\u30ea\u30b9\u30c8\n \u8981\u7d20\u304c\u6839\uff08\u30eb\u30fc\u30c8\uff09\u306e\u5834\u5408\u306f-(\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u306e\u8981\u7d20\u6570)\u3092\u683c\u7d0d\u3059\u308b\n find(x)\n \u8981\u7d20x\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u306e\u6839\u3092\u8fd4\u3059\n union(x, y)\n \u8981\u7d20x\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u3068\u8981\u7d20y\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u3068\u3092\u4f75\u5408\u3059\u308b\n size(x)\n \u8981\u7d20x\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u306e\u30b5\u30a4\u30ba\uff08\u8981\u7d20\u6570\uff09\u3092\u8fd4\u3059\n same(x, y)\n \u8981\u7d20x, y\u304c\u540c\u3058\u30b0\u30eb\u30fc\u30d7\u306b\u5c5e\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u8fd4\u3059\n members(x)\n \u8981\u7d20x\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u306b\u5c5e\u3059\u308b\u8981\u7d20\u3092\u30ea\u30b9\u30c8\u3067\u8fd4\u3059\n \u95a2\u9023\u8a18\u4e8b: Python\u30ea\u30b9\u30c8\u5185\u5305\u8868\u8a18\u306e\u4f7f\u3044\u65b9\n roots()\n \u3059\u3079\u3066\u306e\u6839\u306e\u8981\u7d20\u3092\u30ea\u30b9\u30c8\u3067\u8fd4\u3059\n group_count()\n \u30b0\u30eb\u30fc\u30d7\u306e\u6570\u3092\u8fd4\u3059\n all_group_members\n {\u30eb\u30fc\u30c8\u8981\u7d20: [\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u542b\u307e\u308c\u308b\u8981\u7d20\u306e\u30ea\u30b9\u30c8], ...}\u306e\u8f9e\u66f8\u3092\u8fd4\u3059\n \u95a2\u9023\u8a18\u4e8b: Python\u3067\u8f9e\u66f8\u3092\u4f5c\u6210\u3059\u308bdict()\u3068\u6ce2\u62ec\u5f27\u3001\u8f9e\u66f8\u5185\u5305\u8868\u8a18\n __str__()\n print()\u3067\u306e\u8868\u793a\u7528\n \u30eb\u30fc\u30c8\u8981\u7d20: [\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u542b\u307e\u308c\u308b\u8981\u7d20\u306e\u30ea\u30b9\u30c8]\u3092\u6587\u5b57\u5217\u3067\u8fd4\u3059\n \"\"\"\n \n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\n\nN,M=list(map(int,input().split()))\nab=[tuple(map(int,input().split())) for _ in range(M)]\nans=0\n\nfor i in range(M):\n uf = UnionFind(N)\n \n for j in range(M):\n if i!=j:\n a,b=ab[j][0],ab[j][1]\n uf.union(a-1,b-1)\n #print(i)\n if uf.group_count()!=1:\n ans+=1\n \nprint(ans)\n\n", "from collections import deque\ndef BFS(N,M,List):\n Edge = [[] for TN in range(N+1)]\n for TM in range(0,M):\n Edge[List[TM][0]].append(List[TM][1])\n Edge[List[TM][1]].append(List[TM][0])\n\n Distance = [-1]*(N+1)\n Distance[0] = 0\n Distance[1] = 0\n \n From = [0]*(N+1)\n From[1] = 1\n\n Deque = deque()\n Deque.append(1)\n while Deque:\n Now = Deque.popleft()\n for Con in Edge[Now]:\n if Distance[Con]==-1:\n Distance[Con] = Distance[Now]+1\n Deque.append(Con)\n From[Con] = Now\n\n return Distance[1:],From[1:]\n\nimport copy\nN,M = (int(T) for T in input().split())\nList = [[] for TM in range(0,M)]\nfor TM in range(0,M):\n List[TM] = [int(T) for T in input().split()]\nCount = 0\nfor TM in range(0,M):\n ListCopy = copy.deepcopy(List)\n del ListCopy[TM]\n Distance,From = BFS(N,M-1,ListCopy)\n if -1 in Distance:\n Count += 1\nprint(Count)", "n, m = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(m)]\n\ndef find(x):\n if root[x] < 0:\n return x\n else:\n root[x] = find(root[x])\n return root[x]\n\ndef unit(x, y):\n gx = find(x)\n gy = find(y)\n\n if gx == gy:\n return\n\n if root[gx] > root[gy]:\n gx, gy = gy, gx\n\n root[gx] += root[gy]\n root[gy] = gx\n\ncnt = 0\nfor i in range(m):\n root = [-1] * n\n for j in range(m):\n if i == j:continue\n unit(AB[j][0]-1, AB[j][1]-1)\n roots = [i for i in root if i < 0]\n cnt += (len(roots) != 1)\nprint(cnt)", "from collections import deque\nfrom sys import stdin\ninput = stdin.readline\n\nN,M = map(int, input().split())\nneighbor = [[] for _ in range(N)]\nA = [-1]*M; B = [-1]*M\nfor i in range(M):\n a,b = map(lambda x: int(x) - 1, input().split())\n A[i] = a; B[i] = b\n neighbor[a].append(b)\n neighbor[b].append(a)\n\ncnt = 0\nfor i in range(M):\n a,b = A[i],B[i]\n neighbor[a].remove(b)\n neighbor[b].remove(a)\n visited = [False]*N\n queue = deque()\n queue.append(0)\n visited[0] = True\n \n while queue:\n x = queue.popleft()\n \n for z in neighbor[x]:\n if not visited[z]:\n visited[z] = True\n queue.append(z)\n \n \n if False in visited:\n cnt += 1\n \n neighbor[a].append(b)\n neighbor[b].append(a)\n\nprint(cnt)", "class DisjointSet:\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n\nN, M, *ab = list(map(int, open(0).read().split()))\nedges = [(a - 1, b - 1) for a, b in zip(*[iter(ab)] * 2)]\n\nans = 0\nfor i in range(M):\n ds = DisjointSet(N)\n for j in range(M):\n if i == j:\n continue\n ds.union(*edges[j])\n if len([-p for p in ds.parents if p < 0]) > 1:\n ans += 1\nprint(ans)\n", "N,M = map(int,input().split())\nG = [[] for _ in range(N)]\nH = []\nfor i in range(M):\n a,b = map(int,input().split())\n a-=1;b-=1 #0index\n G[a].append([b,i]);G[b].append([a,i]) #i\u3092\u8fba\u306eID\u3068\u3057\u3066\u4fdd\u5b58\n H.append([a,b])\nans = 0\n \ndef dfs(v,ID): #ID\u306e\u8fba\u3092\u4f7f\u3048\u306a\u3044\n visited.add(v)\n for u,idx in G[v]:\n if idx == ID or u in visited:\n continue\n dfs(u,ID)\n \nfor i in range(M):\n visited = set([])\n start = H[i][0]\n goal = H[i][1]\n dfs(start,i)\n if goal not in visited:\n ans +=1\nprint(ans)", "class UnionFindWithSize:\n def __init__(self, size):\n self.parent = [i for i in range(size)]\n self.size = [1]*size\n def find(self, x):\n if self.parent[x] == x:\n return x\n self.parent[x] = self.find(self.parent[x])\n return self.parent[x]\n def unite(self, x, y):\n x, y = self.find(x), self.find(y)\n if x == y:\n return\n if self.size[x] < self.size[y]:\n self.size[y] += self.size[x]\n self.parent[x] = y\n else:\n self.size[x] += self.size[y]\n self.parent[y] = x\n def same(self, x, y):\n return self.find(x) == self.find(y)\n def sizeofset(self, x):\n return self.size[self.find(x)]\ndef __starting_point():\n N,M = map(int,input().split())\n edges = [tuple(map(lambda x:int(x)-1,input().split())) for _ in range(M)]\n ans = 0\n for i in range(M):\n uf = UnionFindWithSize(N)\n for j in range(M):\n if j != i:\n a,b = edges[j]\n uf.unite(a,b)\n if uf.sizeofset(0) != N:\n ans += 1\n print(ans)\n__starting_point()", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.para = [-1] * (n + 1)\n \n def find(self, x):\n if self.para[x] < 0:\n return x\n else:\n self.para[x] = self.find(self.para[x])\n return self.para[x]\n \n def unite(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x > y:\n x, y = y, x\n if x == y:\n return\n else:\n self.para[x] += self.para[y]\n self.para[y] = x\n def isSame(self, x, y):\n return self.find(x) == self.find(y)\n \n def count(self,x):\n return -self.para[self.find(x)]\nN, M = map(int, input().split())\nun_orginal = UnionFind(N)\nA = [tuple(map(int, input().split())) for _ in range(M)]\nfor a,b in A:\n un_orginal.unite(a,b)\nans = 0\nfor i in range(M):\n un = UnionFind(N)\n for k in range(M):\n if i == k:\n continue\n else:\n un.unite(A[k][0], A[k][1])\n cnt = 0\n for k in range(N+1):\n if un_orginal.count(k) == un.count(k):\n cnt += 1\n if cnt == N+1:\n ans += 1\nprint(M-ans)", "from networkx import *\nn, m = map(int, input().split())\na = [list(map(int, input().split())) for _ in range(m)]\ng = Graph(a)\nans = 0\nfor x in a:\n g.remove_edges_from([x])\n if not is_connected(g):\n ans += 1\n g.add_edges_from([x])\nprint(ans)", "N,M = map(int,input().split())\nAB = [tuple(map(int,input().split())) for i in range(M)]\n\nclass UnionFind:\n def __init__(self,N):\n self.parent = [i for i in range(N)]\n self._size = [1] * N\n self.count = 0\n def root(self,a):\n if self.parent[a] == a:\n return a\n else:\n self.parent[a] = self.root(self.parent[a])\n return self.parent[a]\n def is_same(self,a,b):\n return self.root(a) == self.root(b)\n def unite(self,a,b):\n ra = self.root(a)\n rb = self.root(b)\n if ra == rb: return\n if self._size[ra] < self._size[rb]: ra,rb = rb,ra\n self._size[ra] += self._size[rb]\n self.parent[rb] = ra\n self.count += 1\n def size(self,a):\n return self._size[self.root(a)]\n\nans = 0\nfor i in range(M):\n uf = UnionFind(N)\n for j,(a,b) in enumerate(AB):\n if i==j: continue\n a,b = a-1,b-1\n if uf.is_same(a,b): continue\n uf.unite(a,b)\n if uf.size(0) != N:\n ans += 1\nprint(ans)", "3\n# coding: utf-8\nfrom collections import defaultdict\n\nclass UnionFind(object):\n def __init__(self, N):\n self.parent = [x for x in range(N)] \n\n def root(self, x):\n if self.parent[x] == x: return x\n return self.root(self.parent[x]) \n\n def unite(self, x, y):\n root_x = self.root(x)\n root_y = self.root(y)\n if root_x != root_y:\n self.parent[root_x] = root_y\n \n def same(self, x, y):\n root_x = self.root(x)\n root_y = self.root(y)\n return root_x == root_y\n \n def num_group(self):\n return sum(1 for i in range(len(self.parent)) if self.parent[i] == i)\n\nN, M = (int(x) for x in input().split())\nB = [[int(x) -1 for x in input().split()] for _ in range(M)]\n\ndef isBridge(nth):\n union_find = UnionFind(N)\n for i in range(M): \n if i == nth: continue\n union_find.unite(B[i][0], B[i][1])\n if union_find.num_group() != 1:\n return 1\n\nret = 0\nfor i in range(M):\n if isBridge(i):\n ret += 1\nprint(ret)\n\n", "N,M=map(int,input().split())\nAB=[list(map(int,input().split())) for i in range(M)]\nr=0\nfor m in range(M):\n c=[[] for i in range(N)]\n for i,(a,b) in enumerate(AB):\n if i!=m:\n c[a-1].append(b-1)\n c[b-1].append(a-1)\n q=[0]\n v=[1]+[0]*(N-1)\n while q:\n p=q.pop()\n for n in c[p]:\n if v[n]==0:\n v[n]=1\n q.append(n)\n if 0 in v:\n r+=1\nprint(r)", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n \n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n \n def unite(self, x, y):# UF.unite(a-1,b-1)\n x = self.find(x)\n y = self.find(y)\n \n if x == y:\n return\n \n if self.parents[x] > self.parents[y]:\n x, y = y, x\n \n self.parents[x] += self.parents[y]\n self.parents[y] = x\n \n def size(self, x):#\u4eca\u56de\u306f\u4f7f\u3063\u3066\u3044\u306a\u3044\n return -self.parents[self.find(x)]\n \n def same(self, x, y):#UF.same(a-1,b-1) True/False\n return self.find(x) == self.find(y)\n\nN,M=map(int,input().split())\n\nA=[0]*M;t=0;B=[0]*M\n\nfor i in range(M):\n a,b=map(int,input().split())\n A[i]=[a-1,b-1]\nfor t in range(M):\n UF=UnionFind(N)\n for i in range(M):\n if i!=t:\n UF.unite(A[i][0],A[i][1])\n if UF.same(A[t][0],A[t][1])==False:\n B[t]=1\nprint(sum(B))", "class UnionFind():\n def __init__(self, n):\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\nn,m = map(int,input().split())\na = [list(map(int,input().split())) for i in range(m)]\nans = 0\nfor i in range(m):\n uf = UnionFind(n+1)\n cnt = 0\n for j in range(m):\n if i == j:\n continue\n else:\n uf.union(a[j][0],a[j][1])\n for k in uf.parents:\n if k < 0:\n cnt += 1\n if cnt != 2:\n ans += 1\n\nprint(ans)", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\n\nN, M = [int(i) for i in input().split()]\nABS = [[int(i) for i in input().split()] for _ in range(M)]\n\ncnt = 0\nfor i in range(M):\n uf = UnionFind(N+1)\n for a, b in [*ABS[:i], *ABS[i+1:]]:\n uf.union(a, b)\n if uf.group_count() > 2:\n cnt += 1\n\nprint(cnt)\n", "class UnionFind:\n def __init__(self,n):\n self.nodes=n\n self.parents=[i for i in range(n)]\n self.sizes=[1]*n\n self.rank=[0]*n\n\n def find(self,x):\n if self.parents[x]==x:\n return x\n else:\n self.parents[x]=self.find(self.parents[x])\n return self.parents[x]\n\n def unite(self,x,y):\n x=self.find(x)\n y=self.find(y)\n if x!=y:\n if self.rank[x]<self.rank[y]:\n self.sizes[y]+=self.sizes[x]\n self.parents[x]=y\n else:\n self.sizes[x]+=self.sizes[y]\n self.parents[y]=x\n if self.rank[x]==self.rank[y]:\n self.rank[x]+=1\n def same(self,x,y):\n return self.find(x)==self.find(y)\n\n def get_parents(self):\n for n in range(self.nodes):\n self.find(n)\n return self.parents\n\nadj = []\nN, M = map(int,input().split())\nfor m in range(M):\n a,b = map(int,input().split())\n adj.append([a-1,b-1])\n\nans=0\nfor i in range(M):\n uf = UnionFind(N)\n for j in range(M):\n if i==j:\n continue\n uf.unite(*adj[j]) \n if len(set(uf.get_parents()))!=1:\n ans += 1\nprint(ans)", "import copy\nN, M = map(int, input().split())\nl = []\nfor i in range(M):\n l.append(list(map(int, input().split())))\n \ndef bfs(l, tmp, came):\n t = []\n for n in tmp:\n for s in l:\n if (s[0]==n) and (s[1] not in came):\n t.append(s[1])\n came.append(s[1])\n elif (s[1]==n) and (s[0] not in came):\n t.append(s[0])\n came.append(s[0])\n if t == []:\n came = set(came)\n return came\n else:\n return bfs(l, t, came)\n \nans = 0\nfor i in range(M):\n x = copy.copy(l)\n x.pop(i)\n a = bfs(x, [1], [1])\n if len(a) < N:\n ans += 1\nprint(ans)", "class union_find():\n def __init__(self, n):\n # self.n = n\n self.root = [-1]*(n+1)\n self.rank = [0]*(n+1)\n self.siz = n\n\n def find_root(self, x):\n if self.root[x] < 0:\n return x\n else:\n self.root[x] = self.find_root(self.root[x])\n return self.root[x]\n\n def unite(self, x, y):\n x = self.find_root(x)\n y = self.find_root(y)\n if x == y:\n return\n elif self.rank[x] > self.rank[y]:\n self.root[x] += self.root[y]\n self.root[y] = x\n else:\n self.root[y] += self.root[x]\n self.root[x] = y\n if self.rank[x] == self.rank[y]:\n self.rank[y] += 1\n self.siz -= 1\n\n def same(self, x, y):\n return self.find_root(x) == self.find_root(y)\n\n def size(self):\n return self.siz\n\n\nn, m = list(map(int, input().split()))\n\nab = []\nfor _ in range(m):\n ab.append(list(map(int, input().split())))\n\ng = union_find(n)\nans = 0\nfor i in range(len(ab)):\n for j in range(len(ab)):\n if i == j:\n continue\n a, b = ab[j]\n g.unite(a, b)\n\n if g.size() != 1:\n ans += 1\n g = union_find(n)\n\n\nprint(ans)\n", "N, M = list(map(int, input().split()))\n\nedge = []\ngraph = [[] for _ in range(N)]\nfor _ in range(M):\n a, b = [int(x) - 1 for x in input().split()]\n edge.append((a, b))\n graph[a].append(b); graph[b].append(a)\n\ndef dfs(now):\n searched[now] = True\n for next in graph[now]:\n if searched[next]:\n continue\n if min(now, next) == a and max(now, next) == b:\n continue\n dfs(next)\n\nans = M\nfor i in range(M):\n a, b = edge[i]\n searched = [False] * N\n dfs(0)\n if sum(searched) == N:\n ans -= 1\n\nprint(ans)\n", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[1]:\n\n\nn,m = list(map(int,input().split()))\ndata = [list(map(int, input().split())) for i in range(m)]\n\ndef dfs(pos):\n if visit[pos] == 1:\n return\n visit[pos] = 1\n \n for i in range(n):\n if graph[pos][i] == 1:\n dfs(i)\n\ncount = 0\nfor hen in range(m):\n graph = [[0]*n for i in range(n)]\n visit = [0]*n\n\n for i in range(m):\n pos1 = data[i][0] - 1\n pos2 = data[i][1] - 1\n if i != hen:\n graph[pos1][pos2] = 1\n graph[pos2][pos1] = 1\n dfs(0)\n connected = True\n for i in range(n):\n if visit[i] == 0:\n connected = False\n if not connected:\n count += 1\nprint(count)\n\n\n# In[ ]:\n\n\n\n\n", "#Union Find\n\n#x\u306e\u6839\u3092\u6c42\u3081\u308b\ndef find(x):\n if par[x] < 0:\n return x\n else:\n tank = []\n while par[x] >= 0:\n tank.append(x)\n x = par[x]\n for elt in tank:\n par[elt] = x\n return x\n#x\u3068y\u306e\u5c5e\u3059\u308b\u96c6\u5408\u306e\u4f75\u5408\ndef unite(x,y):\n x = find(x)\n y = find(y)\n \n if x == y:\n return False\n else:\n #size\u306e\u5927\u304d\u3044\u307b\u3046\u304cx\n if par[x] > par[y]:\n x,y = y,x\n par[x] += par[y]\n par[y] = x\n return True\n\n#x\u3068y\u304c\u540c\u3058\u96c6\u5408\u306b\u5c5e\u3059\u308b\u304b\u306e\u5224\u5b9a\ndef same(x,y):\n return find(x) == find(y)\n\n#x\u304c\u5c5e\u3059\u308b\u96c6\u5408\u306e\u500b\u6570\ndef size(x):\n return -par[find(x)]\n\nn,m=list(map(int,input().split()))\nedge=[]\nfor _ in range(m):\n a,b=list(map(int,input().split()))\n a,b=a-1,b-1\n\n edge.append([a,b])\n\n\nans=0\nfor j in range(m):\n #\u521d\u671f\u5316 \n #\u6839\u306a\u3089-size,\u5b50\u306a\u3089\u89aa\u306e\u9802\u70b9\n par = [-1]*n\n cnt=0\n for p in range(m):\n if p==j:\n continue\n \n e=edge[p]\n unite(e[0],e[1]) \n \n for k in range(n):\n if par[k]<0:\n cnt+=1\n\n if cnt>=2:\n ans+=1\n \n \n\n \n\n\nprint(ans)\n\n", "N, M = map(int, input().split())\nto1 = [[0] for i in range(N)]\nab = [[0, 0] for i in range(M)]\n\nfor i in range(M):\n ab[i][0], ab[i][1] = map(int, input().split())\n to1[ab[i][0]-1].append(ab[i][1]-1)\n to1[ab[i][1]-1].append(ab[i][0]-1)\n\nans = 0\n\ndef DFS(n):\n nonlocal v\n if v[n] == 1:\n return\n v[n] = 1\n for i in to1[n]:\n DFS(i)\n\nfor i in range(M):\n v = [0] * N\n p = ab[i]\n p[0] -= 1\n p[1] -= 1\n to1[p[0]].remove(p[1])\n to1[p[1]].remove(p[0])\n DFS(0)\n if sum(v) != N:\n ans += 1\n to1[p[0]].append(p[1])\n to1[p[1]].append(p[0])\n\nprint(ans)", "import copy\n\ndef main():\n\tN, M = [int(n) for n in input().split(\" \")]\n\tedges = [[] for i in range(N)]\n\t# edges[i] : edges from vertex i \n\tr = []\n\tfor i in range(M):\n\t\ta, b = [int(x) for x in input().split(\" \")]\n\t\tedges[a - 1].append(b - 1)\n\t\tedges[b - 1].append(a - 1)\n\t\tr.append([a - 1, b - 1])\n\tcnt = 0\n\tfor i in range(len(r)):\n\t\tif not isConnected(edges, r[i]):\n\t\t\tcnt += 1\n\tprint(cnt)\n\ndef isConnected(edges, remove_edge):\n\tn_v = len(edges)\n\tchecked = [0] * n_v\n\tto_check = [0]\n\te = copy.deepcopy(edges)\n\te[remove_edge[0]].remove(remove_edge[1])\n\te[remove_edge[1]].remove(remove_edge[0])\n\twhile len(to_check) > 0:\n\t\tchecking = to_check.pop(0)\n\t\tchecked[checking] = 1\n\t\tfor i in e[checking]:\n\t\t\tif checked[i] == 1:\n\t\t\t\tcontinue\n\t\t\telse:\n\t\t\t\tto_check.append(i)\n\tif n_v == sum(checked):\n\t\treturn True\n\telse:\n\t\treturn False\n\n\nmain()", "n, m = map(int, input().split())\nlist_AB = [ list(map(int,input().split(\" \"))) for _ in range(m)]\nans = 0\n\nfor i in range(m):\n route = [[] for _ in range(n)]\n for j in range(m):\n if j != i:\n a, b = list_AB[j][0], list_AB[j][1]\n route[a-1].append(b-1)\n route[b-1].append(a-1)\n\n q = [0]\n l = {0}\n\n while q:\n x = q.pop(0)\n for p in route[x]:\n if p not in l:\n l.add(p)\n q.append(p)\n\n if len(list(l)) != n:\n ans += 1\n\nprint(ans)", "N,M = list(map(int,input().split()))\nG = [[] for _ in range(N)]\nH = []\nfor i in range(M):\n a,b = list(map(int,input().split()))\n a-=1;b-=1 #0index\n G[a].append([b,i]);G[b].append([a,i]) #i\u3092\u8fba\u306eID\u3068\u3057\u3066\u4fdd\u5b58\n H.append([a,b])\nans = 0\n\ndef dfs(v,ID): #ID\u306e\u8fba\u3092\u4f7f\u3048\u306a\u3044\n visited.add(v)\n for u,idx in G[v]:\n if idx == ID or u in visited:\n continue\n dfs(u,ID)\n\nfor i in range(M):\n visited = set([])\n start = H[i][0]\n goal = H[i][1]\n dfs(start,i)\n if goal not in visited:\n ans +=1\nprint(ans)\n", "from collections import Counter\nN, M = map(int, input().split())\n\nclass UnionFind:\n def __init__(self, N):\n self.root = list(range(N + 1))\n self.size = [1] * (N + 1)\n\n def __getitem__(self, x):\n root = self.root\n while root[x] != x:\n root[x] = root[root[x]]\n x = root[x]\n return x\n\n def merge(self, x, y):\n x = self[x]\n y = self[y]\n if x == y:\n return\n sx, sy = self.size[x], self.size[y]\n if sx < sy:\n x, y = y, x\n sx, sy = sy, sx\n self.root[y] = x\n self.size[x] += sy\n\n\nA, B = [], []\nfor i in range(M):\n a, b = map(int, input().split())\n A.append(a)\n B.append(b)\n\ncount = 0\nfor i in range(M):\n uni = UnionFind(N)\n for j in range(M):\n if j == i:\n continue\n uni.merge(A[j], B[j])\n # UnionFind\u306e\u9023\u7d50\u6210\u5206\u306e\u500b\u6570\u3092\u6570\u3048\u308b\n roots = [uni[x] for x in uni.root[1:]]\n counter = Counter(roots)\n if len(counter) > 1:\n count += 1\n\nprint(count)", "class UnionFind():\n def __init__(self,n):\n self.parents = [-1]*n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n \n\nN,M = map(int, input().split())\nAB = []\nfor _ in range(M):\n AB.append(list(map(int, input().split())))\nans = 0\nfor i in range(M):\n if i == M-1:\n ab = AB[:M-1]\n else:\n ab = AB[:i]+AB[i+1:]\n uf = UnionFind(N)\n for j in ab:\n uf.union(j[0]-1,j[1]-1)\n if uf.parents[uf.find(0)] != - N:\n ans += 1\nprint(ans)", "N,M=map(int,input().split())\ngraph = [[] for i in range(N)]\n\nfor i in range(M):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n graph[a].append(b)\n graph[b].append(a) \n \ndef dfs(x,g):\n if vis[x]:return\n vis[x]=1\n for i in g[x]:\n dfs(i,g)\n return\n\nans=0\nfor i in range(len(graph)):\n for j in range(len(graph[i])):\n t=graph[i]\n gn=graph[0:i]+[t[0:j]+t[j+1:]]+graph[i+1:]\n vis=[0]*N\n dfs(0,gn)\n if not(all(vis)):\n # print(i+1, graph[i][j]+1,gn,vis)\n ans+=1\nprint(ans)", "n,m = map(int, input().split())\nreach = [0]*(n+1)\nl = [[] for i in range(n+1)]\nfor i in range(m):\n a,b = map(int, input().split())\n l[a].append(b)\n l[b].append(a)\n \ndef dfs(s, parent):\n reach[s] = 1\n for i in l[s]:\n if i == parent: continue\n if reach[i] == 0:\n dfs(i, s)\n else:\n reach[i] += 1\n\nloop = [0]*(n+1)\nfor i in range(1, n+1):\n reach = [0]*(n+1)\n dfs(i, 0)\n if reach[i] != 1:\n loop[i] = 1\nans = 0\nfor i in range(1, n+1):\n for j in l[i]:\n if loop[i] == 1 and loop[j] == 1:\n ans += 1\nprint(m - ans//2)", "\nclass node:\n def __init__(self, id):\n self.id = id\n self.root = self\n\n def findRoot(self):\n if self == self.root:\n return self\n else:\n self.root = self.root.findRoot()\n return self.root\n\n def resetRoot(self):\n self.root = self\n\nclass Tree:\n def __init__(self, num):\n self.nodes = {i:node(i) for i in range(num)}\n\n def union(self, one, other):\n root1 = one.findRoot()\n root2 = other.findRoot()\n root1.root = root2.root = self.nodes[min(root1.id, root2.id)]\n\n def resetTree(self):\n for n in self.nodes.values():\n n.resetRoot()\n\n def makeTree(self, Edge):\n self.edge = Edge\n for x,y in Edge:\n self.union(self.nodes[x-1], self.nodes[y-1])\n\n\ndef main():\n with open(0) as f:\n N, M = map(int, f.readline().split())\n Edge = [tuple(map(int, line.split())) for line in f.readlines()]\n \n tree = Tree(N)\n ans = 0\n for i in range(M):\n edge = [v for v in Edge if v != Edge[i]]\n tree.makeTree(edge)\n if any(x.findRoot().id != 0 for x in tree.nodes.values()):\n ans += 1\n tree.resetTree()\n print(ans)\n\ndef __starting_point():\n main()\n__starting_point()", "import copy\nN,M=map(int,input().split())\npath_matrix=[[0 for i in range(N)] for j in range(N)]\nL=[[] for i in range(M)]\n\nfor i in range(M):\n a,b=map(int,input().split())\n path_matrix[a-1][b-1]=1\n path_matrix[b-1][a-1]=1\n L[i].append(a)\n L[i].append(b)\n\ncolor_white=[\"W\" for i in range(N)]\ncolor_black=[\"B\" for i in range(N)]\nvisited=copy.deepcopy(color_white)\n\ndef path(x,y):\n path_matrix[x-1][y-1]=0\n path_matrix[y-1][x-1]=0\n return DFS(x,path_matrix)\n\ndef DFS(x,tim):\n visited[x-1]=\"B\"\n if visited==color_black:\n return True\n total_ans=0\n for i in range(N):\n if tim[x-1][i]==1 and visited[i]==\"W\":\n total_ans=int(DFS(i+1,tim))\n\n return total_ans\n \nans=0\nfor i in range(M):\n visited=copy.deepcopy(color_white)\n if path(L[i][0],L[i][1])==0:\n ans+=1\n path_matrix[L[i][0]-1][L[i][1]-1]=1\n path_matrix[L[i][1]-1][L[i][0]-1]=1\n\nprint(ans)", "import itertools\n#\u5165\u529b\nN,M = list(map(int, input().split()))\nABs = [list(map(int, input().split())) for _ in range(M)]\n\n#\u6a4b\u306fMAX50\u672c\u306a\u306e\u3067\u30011\u672c\u305a\u3064\u53d6\u308a\u9664\u3044\u3066\u5168\u3066\u304c\u7e4b\u304c\u308b\u304b\u3069\u3046\u304b\u3092\u8a66\u884c\u3059\u308b\u3002\n\n#UnionFind\u6728\n\n\ndef find(x):\n if par[x] == x:\n return x\n else:\n par[x] = find(par[x]) #\u7d4c\u8def\u5727\u7e2e\n return par[x]\ndef same(x,y):\n return find(x) == find(y)\ndef unite(x,y):\n x = find(x)\n y = find(y)\n if x == y:\n return 0\n par[x] = y\n size[y] = size[x] + size[y]\n size[x] = 0\n\n#\u6a4b\u306e\u7d44\u307f\u5408\u308f\u305b\nloop_list = list(itertools.combinations(ABs, M-1))\n#print(loop_list)\n\nans = 0\nfor loop in loop_list:\n #\u30eb\u30fc\u30d7\u6bce\u306b\u30ea\u30bb\u30c3\u30c8\u3059\u308b\u306e\u3067\u3002\u826f\u304f\u306a\u3044\u6c17\u304c\u3059\u308b\u3002\n par = [i for i in range(N+1)]\n size = [1 for _ in range(N+1)]\n\n for bridge in loop:\n unite(bridge[0], bridge[1])\n \n# print(par)\n# print(size)\n if(max(size) != N):\n ans += 1\n\nprint(ans)", "N,M=map(int,input().split())\nab=[list(map(int,input().split()))for _ in range(M)]\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nans=0\nfor i in range(M):\n uf=UnionFind(N)\n for j in range(M):\n if i==j:\n continue\n a,b=ab[j]\n uf.union(a-1,b-1)\n ans+=(uf.group_count()>1)\nprint(ans)", "from collections import deque\nnumber,m = list(map(int,input().split()))\n\nh = deque([])\n\nfor _ in range(m):\n l = list(map(int,input().split()))\n h.append(l)\ncount = 0\n\nfor i in range(m):\n if i != 0:\n h.append([a1,b1])\n a1,b1 = h.popleft()\n g = [[] for _ in range(number)]\n for a,b in h:\n\n g[a-1].append(b)\n g[b-1].append(a)\n\n q = deque([a1])\n pre = [0]*number\n pre[a1-1] = 1\n while q:\n now = q.popleft()\n\n for n in g[now-1]:\n\n if pre[n-1] == 0:\n q.append(n)\n pre[n-1] = 1\n else:\n continue\n \n if sum(pre) != number:\n count+=1\n\nprint(count)\n\n", "class UnionFind():\n def __init__(self,n):\n self.n = n\n self.parents = [-1]*n\n def find(self,x):\n if self.parents[x]<0:\n return x\n else:\n self.parents[x]=self.find(self.parents[x])\n return self.parents[x]\n def unite(self,x,y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.parents[x]>self.parents[y]:\n x,y=y,x\n self.parents[x]+=self.parents[y]\n self.parents[y]=x\n def same(self,x,y):\n return self.find(x)==self.find(y)\nN,M = map(int,input().split())\nA = [0]*M\nt=0\nB=[0]*M\nfor i in range(M):\n a,b=map(int,input().split())\n A[i]=[a-1,b-1]\nfor t in range(M):\n UF = UnionFind(N)\n for i in range(M):\n if i!=t:\n UF.unite(A[i][0],A[i][1])\n if UF.same(A[t][0],A[t][1])==False:\n B[t]=1\nprint(sum(B))", "class UnionFind():\n def __init__(self, n):\n self.parents = list(range(n))\n self.size = [1] * n\n def find(self, x):\n if self.parents[x] == x:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.size[x] < self.size[y]:\n self.size[y] += self.size[x]\n self.parents[x] = y\n else:\n self.size[x] += self.size[y]\n self.parents[y] = x\n def size(self, x):\n return -self.parents[self.find(x)]\n def same(self, x, y):\n return self.find(x) == self.find(y)\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n def group_count(self):\n return len(self.roots())\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\nn,m=list(map(int,input().split()))\nnum=[list(map(int,input().split())) for _ in range(m)]\nans=0\nfor i in range(m):\n uf=UnionFind(n)\n for j in range(m):\n if i!=j:\n uf.union(num[j][0]-1,num[j][1]-1)\n if uf.size[uf.find(0)]!=n:\n ans+=1\nprint(ans)\n", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\nn, m = map(int, input().split())\na = [list(map(int, input().split())) for i in range(m)]\nans = 0\nfor i in range(m):\n uf = UnionFind(n)\n for j in range(m):\n if i != j:\n uf.union(a[j][0]-1, a[j][1]-1)\n if uf.size(0) != n:\n ans += 1\nprint(ans)", "N, M = list(map(int, input().split()))\nAB = [tuple(map(int, input().split())) for _ in range(M)]\n\ndef find(x):\n if par[x] == x:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\ndef unite(x,y):\n x = find(x)\n y = find(y)\n if x == y:\n return 0\n par[x] = y\n\ncnt = 0\nfor i in range(M):\n par = [i for i in range(N+1)]\n k = 0\n for a, b in AB:\n if k != i:\n unite(a,b)\n k += 1\n \n res = []\n for j in range(1,N+1):\n res.append(find(j))\n \n if len(set(res)) >= 2:\n cnt += 1\nprint(cnt)\n", "class UnionFind:\n def __init__(self, N):\n self.N = N\n\n # the parent of all node is itself\n # self.parent = list(range(N))\n self.parent = [-1] * N\n\n def root(self, i):\n if self.parent[i] < 0:\n return i\n\n r = self.root(self.parent[i])\n self.parent[i] = r\n return r\n\n def unite(self, i, j):\n i = self.root(i)\n j = self.root(j)\n\n if i == j:\n return\n\n if i > j:\n i, j = j, i\n\n self.parent[i] += self.parent[j]\n self.parent[j] = i\n # print(self.parent)\n\n def same(self, i, j):\n return self.root(i) == self.root(j)\n\n def size(self, i):\n return -self.parent[self.root(i)]\n\n def roots(self):\n return [self.root(i) for i in range(self.N)]\n\n def groupcount(self):\n return len(set(self.roots()))\n\nN, M = map(int, input().split())\nedges = [[int(x) - 1 for x in input().split()] for _ in range(M)]\n\nans = 0\n\n# \u5168\u3066\u306eedge\u306b\u5bfe\u3057\u3066\nfor i in range(M):\n # UnionFind\u6728\u3092\u521d\u671f\u5316\n forest = UnionFind(N)\n\n # i\u756a\u76ee\u306e\u30a8\u30c3\u30b8\u3092\u9664\u3044\u305f\u3082\u306e\u3092\u3064\u306a\u3050\n for i, j in edges[:i] + edges[i+1:]:\n forest.unite(i, j)\n\n # \u5168\u3066\u306e\u30ce\u30fc\u30c9\u304c\u3064\u306a\u304c\u3063\u3066\u3044\u308b <=> \u30b0\u30eb\u30fc\u30d7\u6570\u306f1\n # \u30b0\u30eb\u30fc\u30d7\u6570\uff08\u5cf6\u306e\u6570\uff09\u304c\uff11\u3067\u306f\u306a\u3044 <=> \u30b0\u30e9\u30d5\u306f\uff12\u3064\u4ee5\u4e0a\u306e\u5cf6\u304b\u3089\u6210\u308b\n if forest.groupcount() != 1:\n ans += 1\n\nprint(ans)", "from collections import deque\nfrom sys import stdin\ninput = stdin.readline\n\nclass Unionfind():\n def __init__(self, n):\n self.n = n\n self.parent = [-1]*n\n \n def find(self, x):\n if self.parent[x] < 0:\n return x\n else:\n self.parent[x] = self.find(self.parent[x])\n return self.parent[x]\n \n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n \n if x == y:\n return\n if self.parent[x] < self.parent[y]:\n x,y = y,x\n \n self.parent[x] += self.parent[y]\n self.parent[y] = x\n \n\nN,M = map(int, input().split())\nA = [-1]*M; B = [-1]*M\nfor i in range(M):\n a,b = map(lambda x: int(x) - 1, input().split())\n A[i] = a; B[i] = b\n\nans = 0\nfor exclude_idx in range(M):\n uf = Unionfind(N)\n for i in range(M):\n if i == exclude_idx:\n continue\n uf.union(A[i],B[i])\n \n cnt = 0\n for parent in uf.parent:\n if parent < 0:\n cnt += 1\n if cnt >= 2:\n ans += 1\n\nprint(ans)", "class UnionFind:\n def __init__(self, n):\n self.parent = [i for i in range(n)]\n self.size = [1 for i in range(n)]\n\n def root(self, x):\n if self.parent[x] == x:\n return x\n else:\n self.parent[x] = self.root(self.parent[x])\n return self.parent[x]\n\n def unite(self, x, y):\n x = self.root(x)\n y = self.root(y)\n if x != y:\n self.parent[x] = y\n self.size[y] += self.size[x]\n\n def same(self, x, y):\n return self.root(x) == self.root(y)\n\n def count(self, x):\n return self.size[self.root(x)]\n\nN, M = list(map(int, input().split()))\nAB = [list([int(x)-1 for x in input().split()]) for _ in range(M)]\nans = 0\nfor i in range(M):\n un = UnionFind(N)\n for j in range(M):\n if i != j:\n un.unite(AB[j][0], AB[j][1])\n if un.count(0) != N:\n ans += 1\nprint(ans)\n", "n,m = map(int, input().split())\ns =[set() for i in range(n)]\ne = []\nfor i in range(m):\n a,b = map(int, input().split())\n a-=1\n b-=1\n s[a].add(b)\n s[b].add(a)\n e.append([a,b])\ndef dfs(u,v,c):\n visited[u] = 1\n c += 1\n if u == v:\n d.append(c)\n return True\n for i in s[u]:\n if visited[i]:\n continue\n if c == 1:\n if i == v:\n continue\n dfs(i,v,c)\n\ncnt = 0\nfor i in range(m):\n x,y = e[i][0],e[i][1]\n visited = [0 for i in range(n)]\n d = []\n dfs(x,y,0)\n if len(d) > 0:\n cnt += 1\nprint (m-cnt)", "class UnionFind():\n def __init__(self,n):\n self.n=n\n self.parents =[-1]*n\n\n def find(self, x):\n if self.parents[x]<0:\n return x\n else:\n self.parents[x]=self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x=self.find(x)\n y=self.find(y)\n if x==y:\n return\n if self.parents[x]>self.parents[y]:\n x,y=y,x\n self.parents[x]+=self.parents[y]\n self.parents[y]=x\n \n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x)==self.find(y)\n\n def members(self, x):\n root=self.find(x)\n return list(i for i in range(self.n) if self.find(i) == root)\n\n def roots(self):\n return list(i for i, x in enumerate(self.parents) if x < 0)\n\n def group_count(self):\n return len(self.roots)\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nadj=[]\nN, M = map(int, input().split())\nfor m in range(M):\n a,b=map(int, input().split())\n adj.append([a-1,b-1])\n\nans = 0\nfor i in range(M):\n uf = UnionFind(N)\n for j in range(M):\n if i == j:\n continue\n uf.union(*adj[j])\n if len(set(uf.roots()))!=1:\n ans += 1\nprint(ans)", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x): #\u89aa\u3092\u8fd4\u3059\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y): #\u548c\u96c6\u5408\u306e\u751f\u6210\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x): #\u6240\u5c5e\u3059\u308b\u96c6\u5408\u306e\u5927\u304d\u3055\n return -self.parents[self.find(x)]\n\n def same(self, x, y): #\u540c\u3058\u96c6\u5408\u306b\u5c5e\u3057\u3066\u3044\u308b\u304b\u5224\u5b9a\n return self.find(x) == self.find(y)\n\n def members(self, x): #\u540c\u3058\u96c6\u5408\u306b\u5c5e\u3059\u308b\u8981\u7d20\u5168\u5217\u6319\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self): #\u96c6\u5408\u306e\u30ea\u30fc\u30c0\u30fc\u5168\u5217\u6319\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self): #\u96c6\u5408\u306e\u6570\n return len(self.roots())\n\n def all_group_members(self): #\u8f9e\u66f8\u578b,{(\u30ea\u30fc\u30c0\u30fc\u306e\u756a\u53f7):(\u305d\u306e\u96c6\u5408\u306e\u8981\u7d20\u5168\u5217\u6319)}\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nn,m=map(int,input().split())\nl=[]\nfor i in range(m):\n l.append(list(map(int,input().split())))\nans=0\nfor i in range(m):\n a=UnionFind(n)\n for j in range(m):\n if i==j:\n continue\n a.union(l[j][0]-1,l[j][1]-1)\n if a.group_count()==2:\n ans+=1\nprint(ans)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Oct 12 00:49:45 2020\n\n@author: liang\n\"\"\"\nfrom collections import deque\n\ndef isBridge(start, goal):\n visited = [False]*N\n q = deque()\n q.append(start)\n visited[start] = True\n while q:\n cur = q.popleft()\n if cur == goal:\n return False\n for nex in adj[cur]:\n if not visited[nex]:\n visited[nex] = True\n q.append(nex)\n return True \n\nN, M = map(int, input().split())\nadj = list()\n\n\nfor i in range(N):\n adj.append(list())\n\nE = list()\nfor i in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n E.append((a,b))\n adj[a].append(b)\n adj[b].append(a)\nans = 0\nfor e in E:\n a, b = e\n adj[a].remove(b)\n adj[b].remove(a)\n if isBridge(a,b):\n ans += 1\n adj[a].append(b)\n adj[b].append(a)\nprint(ans)", "from itertools import combinations\n\nclass unionfind:\n def __init__(self,n):\n self.par=[i for i in range(n)]\n self.rank=[1]*n\n\n def root(self,a):\n if self.par[a]==a : return a\n parent=self.root(self.par[a])\n self.par[a]=parent\n return parent\n\n def unite(self,a,b):\n ra,rb=self.root(a),self.root(b)\n if ra==rb : return\n if self.rank[ra]>self.rank[rb]:\n ra,rb=rb,ra\n self.par[rb]=ra\n self.rank[ra]+=1\n\n def same(self,a,b):\n return self.root(a)==self.root(b)\n\n\ndef main():\n n,m=map(int,input().split())\n edges=[tuple(map(int,input().split())) for _ in range(m)]\n\n sm=0\n for e_remove in edges:\n uf=unionfind(n)\n for e in edges:\n if e==e_remove : continue\n uf.unite(e[0]-1,e[1]-1)\n\n for a in combinations(range(n),2):\n if not uf.same(a[0],a[1]):\n break\n else : continue\n sm+=1\n\n print(sm)\n\nmain()", "N,M = map(int,input().split())\ns = [[] for i in range(N)]\nm = []\nfor i in range(M):\n a,b = map(int,input().split())\n s[a-1].append(b)\n s[b-1].append(a)\n m.append([a,b])\nans = 0\nfrom collections import deque\nimport copy\nd = deque()\nfor i in range(M):\n n = [0] * N\n a = m[i][0]\n b = m[i][1]\n c = s[a-1].copy()\n c.remove(b)\n d.append(c)\n n[a-1] = 1\n while len(d) > 0:\n e = d.popleft()\n for j in e:\n if n[j-1] == 0:\n n[j-1] = 1\n d.append(s[j-1])\n if 0 in n:\n ans += 1\nprint(ans)", "def root(i):\n if par[i] < 0:\n return i\n else:\n return root(par[i])\n\ndef size(a):\n return -par[root(a)]\n\ndef union(a,b):\n a = root(a)\n b = root(b)\n if a == b:#\u89aa\u304c\u7b49\u3057\u3044\n return False\n if size(a) < size(b):#\u30b5\u30a4\u30ba\u304c\u5927\u304d\u3044\u65b9\u306b\u7e4b\u3052\u308b\n a,b = b,a\n par[a] += par[b]\n par[b] = a\n return True\n\nn,m = map(int,input().split())\nbridge = []\nfor i in range(m):\n bridge.append([int(j)-1 for j in input().split()])\nans = 0\nfor i in range(m):\n par = [-1 for _ in range(n)]\n for j in range(m):\n if j != i:\n union(bridge[j][0],bridge[j][1])\n cnt = [ i for i in par if i < 0]\n if len(cnt) > 1:\n ans += 1\nprint(ans)", "class UnionFind():\n def __init__(self,N):\n self.par=[-1]*N\n \n def unite(self,x,y):\n x = self.root(x)\n y = self.root(y)\n if x == y:\n return False\n if self.par[x] > self.par[y]:\n x,y = y,x\n self.par[x] += self.par[y]\n self.par[y] = x\n return True\n \n def root(self,x):\n if self.par[x]<0:\n return x\n self.par[x] = self.root(self.par[x])\n return self.par[x]\n \n def size(self,x):\n return -self.par[self.root(x)]\n\nN,M = map(int,input().split())\nEdge = []\nfor _ in range(M):\n u,v = map(int,input().split())\n Edge.append((u-1,v-1))\n\nans = 0\n\nfor e in Edge:\n uf = UnionFind(N)\n for _e in Edge:\n if e == _e:\n continue\n uf.unite(_e[0],_e[1])\n if uf.size(0) != N:\n ans += 1\n\nprint(ans)", "import copy\nimport sys\nsys.setrecursionlimit(10**7)\n\nN, M = map(int, input().split())\nG = [[] for _ in range(N)]\nside = []\nfor _ in range(M):\n a, b = map(int, input().split())\n a -= 1; b -= 1\n G[a].append(b)\n G[b].append(a)\n side.append((a,b))\n\ndef dfs(v,G):\n seen[v] = True\n for next_v in G[v]:\n if seen[next_v] == True:\n continue\n dfs(next_v,G)\n\nbridge = 0\n# \u5404\u8fba\u3092\u53d6\u308a\u9664\u304f\nfor a,b in side:\n Gc = copy.deepcopy(G)\n Gc[a].remove(b)\n Gc[b].remove(a)\n seen = [False]*N\n cnt = 0\n # \u9023\u7d50\u6210\u5206\u306e\u30ab\u30a6\u30f3\u30c8\n for s in range(N):\n if seen[s] == True:\n continue\n cnt += 1\n dfs(s,Gc)\n # \u9023\u7d50\u6210\u5206\u304c 2 \u500b\u4ee5\u4e0a\u306a\u3089\u305d\u306e\u8fba\u306f\u6a4b \n if cnt>=2:\n bridge += 1\nprint(bridge)", "import copy\nfrom collections import deque\nN,M = map(int,input().split())\nlsside = [[] for i in range(N+1)]\nlsline = []\nfor i in range(M):\n a,b = map(int,input().split())\n lsside[a].append(b)\n lsside[b].append(a)\n lsline.append([a,b])\n\nans = 0\nlsloop = []\nfor i in range(M):\n graph = copy.deepcopy(lsside)\n a = lsline[i][0]\n b = lsline[i][1]\n graph[a].remove(b)\n graph[b].remove(a)\n used = [False for i in range(N+1)]\n ii = 1\n d = deque()\n d.append(a)\n used[a] = True\n while d:\n v = d.popleft()\n for i in graph[v]:\n if used[i]:\n continue\n ii += 1\n d.append(i)\n used[i] = True\n lsloop.append(ii)\nans = M - lsloop.count(N)\nprint(ans)", "from collections import deque\nN, M = map(int, input().split())\n\nh = [[]*N for _ in range(N)]\nAB = []\n\nfor _ in range(M):\n a, b = list(map(int, input().split()))\n a -= 1\n b -= 1\n h[a].append(b)\n h[b].append(a)\n AB.append([a, b])\n\nans = 0\n\nfor i in range(M):\n a, b = AB[i]\n h[a].remove(b)\n h[b].remove(a)\n \n fl = [False]*N\n\n q = deque([0])\n while q:\n t = q.popleft()\n if fl[t]:\n continue\n fl[t] = True\n for tt in h[t]:\n q.append(tt)\n \n if not all(fl):\n ans += 1\n\n h[a].append(b)\n h[b].append(a)\n\nprint(ans)", "import queue\nn, m = list(map(int, input().split()))\nroute = [[] for _ in range(n)]\nvals = []\nfor _ in range(m):\n a, b = list(map(int, input().split()))\n route[a-1].append(b-1)\n route[b-1].append(a-1)\n vals.append([a-1, b-1])\nans = m\nfor i in range(m):\n route2 = set()\n q = queue.Queue()\n q.put(0)\n route[vals[i][0]].remove(vals[i][1])\n route[vals[i][1]].remove(vals[i][0])\n while not q.empty():\n a = q.get()\n if not a in route2:\n route2.add(a)\n for j in route[a]:\n q.put(j)\n if len(route2) == n:\n ans -= 1\n break\n route[vals[i][0]].append(vals[i][1])\n route[vals[i][1]].append(vals[i][0])\nprint(ans)\n \n", "class union_find():\n def __init__(self,n):\n self.n=n\n ##\u89aa\u8981\u7d20\u306e\u30ce\u30fc\u30c9\u756a\u53f7\u3092\u683c\u7d0d\u3002par[x]==x\u306e\u3068\u304d\u305d\u306e\u30ce\u30fc\u30c9\u306f\u6839\n ##\u89aa\u3068\u306f\u305d\u306e\u4e0a\u306b\u30ce\u30fc\u30c9\u306a\u3057\uff01\uff01\u3000\n self.par=[i for i in range(n+1)]\n self.rank=[0]*(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\n ##\u6728\u306e\u9ad8\u3055\u3092\u6bd4\u8f03\u3057\u3001\u4f4e\u3044\u65b9\u304b\u3089\u9ad8\u3044\u65b9\u3078\u8fba\u3092\u306f\u308b\n\n if self.rank[x]<self.rank[y]:\n self.par[x]=y\n else:\n self.par[y]=x\n ##\u540c\u3058\u306a\u3089\u7247\u65b9\u3092\u4f38\u3070\u3059\n if self.rank[x]==self.rank[y]:\n self.rank[y]+=1\n\n def same(self,x,y):\n return self.find(x) == self.find(y)\n \nn,m=map(int,input().split())\nuf=union_find(n)\nans=0\ns=[]\nfor _ in range(m):\n a=list(map(int,input().split()))\n s.append(a)\n uf.union(a[0],a[1])\n \n \n\nfor e in range(m):\n uf1=union_find(n)\n ch=0\n for d in range(m):\n if d!=e:\n uf1.union(s[d][0],s[d][1])\n \n for i in range(1,n):\n for j in range(i+1,n+1):\n if not uf1.same(i,j):\n ch+=1\n if ch>0:\n ans+=1\n\n \nprint(ans)", "# Union Find\n# x\u306e\u6839\u3092\u6c42\u3081\u308b\ndef find(x):\n if par[x] < 0:\n return x\n else:\n par[x] = find(par[x])\n return par[x]\n\n\n# x\u3068y\u306e\u5c5e\u3059\u308b\u96c6\u5408\u306e\u4f75\u5408\ndef unite(x, y):\n x = find(x)\n y = find(y)\n\n if x == y:\n return False\n else:\n # x < y \u306b\u3059\u308b\n if par[x] > par[y]:\n x, y = y, x\n par[x] += par[y]\n par[y] = x\n return True\n\n\n# \u6839\u306e\u500b\u6570\u3092\u8fd4\u3059\ndef group_count():\n return sum(x < 0 for x in par)\n\n\nn, m = map(int, input().split())\nl = []\nfor _ in range(m):\n l.append(tuple(map(int, input().split())))\n\nans = 0\nfor j in range(m):\n par = [-1] * n\n for i, ab in enumerate(l):\n if i != j:\n unite(ab[0] - 1, ab[1] - 1)\n if group_count() == 2:\n ans += 1\n\nprint(ans)", "n , m = list(map(int, input().split()))\nc = [[0]*n for i in range(n)]\nfor i in range(m):\n a , b = list(map(int, input().split()))\n c[a-1][b-1]=1\n c[b-1][a-1]=1\nans = 0\nfor k in range(n):\n for i in range(n):\n if sum(c[i])==1:\n ans+=1\n for j in range(n):\n if c[i][j]==1:\n c[i][j]=0\n c[j][i]=0\nprint(ans)\n", "from networkx import *\nn, m = map(int, input().split())\na = [list(map(int, input().split())) for _ in range(m)]\ng = Graph(a)\nprint(len(tuple(bridges(g))))", "from collections import deque\n\nn, m = list(map(int, input().split()))\ngraph = [[] for i in range(n)]\nfor i in range(m):\n u, v = list(map(int, input().split()))\n u -= 1\n v -= 1\n graph[u].append([i,v])\n graph[v].append([i,u])\n \ncnt = 0\nfor i in range(m):\n d = deque()\n d.append(0)\n visited = [False]*n\n visited[0] = True\n while d:\n cf = d.pop()\n for ci, ct in graph[cf]:\n if ci == i:\n continue\n if not visited[ct]:\n d.append(ct)\n visited[ct] = True\n if False in visited:\n cnt += 1\nprint(cnt)\n", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nN, M = list(map(int, input().split()))\nuf = UnionFind(N)\nab_list = []\nans =0\nfor i in range(M):\n a,b = list(map(int, input().split()))\n a, b = a-1, b-1\n ab_list.append([a, b])\n\nfor i in range(M):\n uf = UnionFind(N)\n for j in range(M):\n if i == j:\n continue\n uf.union(ab_list[j][0], ab_list[j][1])\n if not uf.same(ab_list[i][0], ab_list[i][1]):\n ans += 1\nprint(ans)\n", "n, m = map(int, input().split())\ng = [[] for _ in range(n)]\nfor i in range(m):\n a, b = map(int, input().split())\n a, b = a-1, b-1\n g[a].append(b)\n g[b].append(a)\n\ndef lowlink(g, root=0):\n n = len(g)\n order = [n]*n\n low = [n]*n\n\n s = [root]\n cnt = 1\n par = [-1]*n\n seq = []\n while s:\n v = s.pop()\n if order[v] != n:\n continue\n order[v] = cnt\n seq.append(v)\n low[v] = cnt\n cnt += 1\n for u in g[v]:\n if order[u] < cnt:\n if par[v] != u:\n low[v] = min(low[v], order[u])\n continue\n else:\n par[u] = v\n s.append(u)\n child = [[] for _ in range(n)]\n for v in range(n):\n if par[v] != -1:\n child[par[v]].append(v)\n seq.reverse()\n for v in seq:\n for u in child[v]:\n low[v] = min(low[v], low[u])\n # bridge\n bridge = []\n for p in range(n):\n for c in child[p]:\n if order[p] < low[c]:\n bridge.append((p, c))\n\n # articulation points\n AP = []\n for v in range(n):\n if v == root:\n if len(child[v]) >= 2:\n AP.append(v)\n else:\n for c in child[v]:\n if order[v] <= low[c]:\n AP.append(v)\n break\n return AP, bridge\n\n_, bridge = lowlink(g, 0)\nprint(len(bridge))", "class UnionFind:\n def __init__(self, n):\n self._n = n\n self._table = [-1]*n\n\n def _root(self, x):\n stack = []\n while self._table[x] >= 0:\n stack.append(x)\n x = self._table[x]\n for y in stack:\n self._table[y] = x\n return x\n \n def unite(self, x, y):\n x, y = self._root(x), self._root(y)\n if x == y:\n return\n if x > y:\n x, y = y, x\n self._table[x] += self._table[y]\n self._table[y] = x\n \n def same(self, x, y):\n return self._root(x) == self._root(y)\n\n def count_members(self, x):\n return -self._table[self._root(x)]\n \n def count_groups(self):\n return len({self._root(i) for i in range(self._n)})\n \n def __str__(self):\n return str([self._root(i) for i in range(self._n)])\n \n def __repr__(self): \n return repr([self._root(i) for i in range(self._n)])\n\nn, m, *AB = map(int, open(0).read().split())\nans = 0\nfor i in range(m):\n uf = UnionFind(n)\n for j, (a, b) in enumerate(zip(AB[::2], AB[1::2])):\n if i == j:\n continue\n uf.unite(a-1, b-1)\n ans += uf.count_groups() != 1\nprint(ans)", "class UnionFind():\n def __init__(self,n):\n self.parents=[-1]*n\n \n def find(self,x):\n if self.parents[x]<0:\n return x\n self.parents[x]=self.find(self.parents[x])\n return self.parents[x]\n \n def union(self,x,y):\n x = self.find(x)\n y = self.find(y)\n if x==y:\n return\n \n if self.parents[x]>self.parents[y]:\n x,y=y,x\n \n self.parents[x]+=self.parents[y]\n self.parents[y]=x\n\nN,M=map(int,input().split())\nans=0\nA=[]\nB=[]\n\nfor _ in range(M):\n a,b=map(int,input().split())\n A.append(a)\n B.append(b)\n \nfor i in range(M):\n uf=UnionFind(N+1)\n for j in range(M):\n if i==j:\n continue\n uf.union(A[j],B[j])\n else:\n if abs(min(uf.parents[1:]))!=N:\n ans+=1\nprint(ans)", "import networkx as nx\n\nn, m, *AB = map(int, open(0).read().split())\nG = nx.Graph()\nG.add_edges_from(zip(AB[::2], AB[1::2]))\nprint(len(list(nx.bridges(G))))", "import sys\nsys.setrecursionlimit(10 ** 9)\n# input = sys.stdin.readline ####\ndef int1(x): return int(x) - 1\ndef II(): return int(input())\ndef MI(): return list(map(int, input().split()))\ndef MI1(): return list(map(int1, input().split()))\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef MS(): return input().split()\ndef LS(): return list(input())\ndef LLS(rows_number): return [LS() for _ in range(rows_number)]\ndef printlist(lst, k=' '): print((k.join(list(map(str, lst)))))\nINF = float('inf')\n# from math import ceil, floor, log2\nfrom collections import deque, defaultdict\n# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations\n# from heapq import heapify, heappop, heappush\n# import numpy as np # cumsum\n# from bisect import bisect_left, bisect_right\n\ndef solve():\n N, M = MI()\n V = [[] for _ in range(N)]\n E = []\n for i in range(M):\n a, b = MI1()\n V[a].append(b)\n V[b].append(a)\n E.append((a, b))\n\n ans = 0\n for a, b in E:\n used = [0] * N\n flag = True\n q = deque([a])\n used[a] = 1\n while q:\n cur = q.popleft()\n\n for nv in V[cur]:\n if (a, b) == (cur, nv) or (a, b) == (nv, cur):\n continue\n\n if used[nv]:\n continue\n\n if nv == b:\n flag = False\n q = []\n break\n\n q.append(nv)\n used[nv] = 1\n # print(a, b, q)\n\n if flag:\n ans += 1\n print(ans)\n\ndef __starting_point():\n solve()\n\n\n__starting_point()", "import sys\n\ninput = sys.stdin.readline\n\n\nclass UnionFind:\n \"\"\"Union Find class.\n\n \"Path compression\" and \"Union by rank\" are used.\n\n References:\n <https://en.wikipedia.org/wiki/Disjoint-set_data_structure>\n \"\"\"\n\n def __init__(self, N):\n self.N = N\n self.__make_set()\n\n def __make_set(self):\n self._parent = list(range(self.N + 1))\n self._rank = [0] * (self.N + 1)\n self._size = [1] * (self.N + 1)\n\n def find(self, x):\n if self._parent[x] != x:\n self._parent[x] = self.find(self._parent[x])\n return self._parent[x]\n\n def union(self, x, y):\n x_root = self.find(x)\n y_root = self.find(y)\n\n if x_root == y_root:\n return\n\n x_rank = self._rank[x_root]\n y_rank = self._rank[y_root]\n if x_rank > y_rank:\n self._parent[y_root] = x_root\n self._size[x_root] += self._size[y_root]\n elif x_rank < y_rank:\n self._parent[x_root] = y_root\n self._size[y_root] += self._size[x_root]\n else:\n self._parent[y_root] = x_root\n self._rank[x_root] += 1\n self._size[x_root] += self._size[y_root]\n\n def same_set(self, x, y):\n return self.find(x) == self.find(y)\n\n def size(self, x):\n return self._size[self.find(x)]\n\n\ndef main():\n N, M = list(map(int, input().split()))\n a = [None] * M\n b = [None] * M\n for i in range(M):\n a[i], b[i] = list(map(int, input().split()))\n\n ans = 0\n for i in range(M):\n uf = UnionFind(N)\n for j in range(M):\n if j == i:\n continue\n uf.union(a[j], b[j])\n if not uf.same_set(a[i], b[i]):\n ans += 1\n\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "class UnionFind(): \n def __init__(self, n):\n self.n = n\n self.root = [-1] * n\n self.rnk = [0] * n\n \n def findRoot(self, x):\n if self.root[x] < 0:\n return x\n else:\n self.root[x] = self.findRoot(self.root[x]) #; print('root[x]', self.root[x])\n return self.root[x]\n\n def unite(self, x, y):\n x = self.findRoot(x)\n y = self.findRoot(y)\n if x == y:\n return \n elif self.rnk[x] > self.rnk[y]:\n self.root[y] = x\n else:\n self.root[x] = y\n if self.rnk[x] == self.rnk[y]:\n self.rnk[y] += 1\n\n def isSame(self, x, y):\n return self.findRoot(x) == self.findRoot(y)\n\n\nN, M = map(int, input().split())\nedge = [tuple(map(int, input().split())) for _ in range(M)] #;print(edge)\n\ncnt = 0\nfor i in range(M):\n uf = UnionFind(N+1)\n for j in range(M):\n if j != i:\n uf.unite(edge[j][0], edge[j][1])\n #print(i, edge[i][0], edge[i][1], uf.isSame(edge[i][0], edge[i][1]))\n if not uf.isSame(edge[i][0], edge[i][1]):\n cnt += 1\nprint(cnt)", "from collections import deque, defaultdict\nimport sys\nsys.setrecursionlimit(2**20)\nclass LowLink:\n \"\"\"\n \u4e0e\u3048\u3089\u308c\u305f\u30b0\u30e9\u30d5\u306e\u95a2\u7bc0\u70b9\u3068\u6a4b\u3092\u6c42\u3081\u308b\n Attributes:\n size:\u30b0\u30e9\u30d5\u306e\u9802\u70b9\n pre:oreorder\u3067\u306e\u8a2a\u554f\u9806\n low: ###1. prenum[u]\n ###2.G\u306eBackEdge(u,v)\u304c\u5b58\u5728\u3059\u308b\u5834\u5408prenum[v]\n ###3.u\u3092\u3059\u3079\u3066\u306e\u5b50child\u306b\u5bfe\u3057\u3066lowest[child]\n \"\"\"\n def __init__(self, v):\n self.size = len(v) + 1\n self.v = v\n self.pre = [None]*self.size\n self.low = [None]*self.size\n self.articulations = []\n self.bridges = []\n for x in range(self.size):\n if self.pre[x] is None:\n self.cnt = 0\n self.dfs(x, None)\n \n def dfs(self, x, prev):\n self.pre[x] = self.low[x] = self.cnt\n self.cnt += 1\n is_articulation = False\n n = 0\n for y in self.v[x]:\n if self.pre[y] is None:\n n += 1\n low_y = self.dfs(y, x)\n if low_y < self.low[x]:\n self.low[x] = low_y\n if self.pre[x] <= low_y:\n if self.pre[x]:\n is_articulation = True\n if self.pre[x] < low_y:\n self.bridges.append(\n (min(x,y), max(x, y))\n )\n else:\n if y != prev and self.pre[y] < self.low[x]:\n self.low[x] = self.pre[y]\n if prev is None and n > 1:\n is_articulation = True\n \n if is_articulation:\n self.articulations.append(x)\n \n return self.low[x]\n\ndef solve():\n V, E = map(int, input().split())\n G = defaultdict(lambda: [])\n for _ in range(E):\n s, t= map(int, input().split())\n G[s].append(t)\n G[t].append(s)\n \n #initialize\n lowlink = LowLink(G)\n #bridges\n bridges = lowlink.bridges\n print(len(bridges))\n \ndef __starting_point():\n solve()\n__starting_point()", "# \u5e45\u512a\u5148\u63a2\u7d22\u3067\u9023\u7d50\u6210\u5206\u3092\u6c42\u3081\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\nfrom collections import deque\n\n# n = int(input())# \u30ce\u30fc\u30c9\u306e\u6570\nn, m = map(int, input().split())\n\nl = [list(map(int, input().split())) for _ in range(m)]\n\nans = 0\n\n\ndef bfs(start_node, color_id): # start_node\u306f\u63a2\u7d22\u306e\u958b\u59cb\u70b9\n nonlocal color, d\n q = deque([start_node])\n d[start_node] = 0\n color[start_node] = color_id\n while len(q) != 0:\n u = q.popleft()\n for v in adjl[u]:\n if color[v] == NIL:\n d[v] = d[u]+1\n color[v] = color_id\n q.append(v)\n\n\n#print(l)\nfor k in range(1, m+1):\n\n # \u96a3\u63a5\u30ea\u30b9\u30c8\u3067\u683c\u7d0d\u3059\u308b\n adjl = [[] for _ in range(n+1)]\n for i in range(1, m+1): # \u96a3\u63a5\u95a2\u4fc2\u3092\u53d7\u3051\u53d6\u308b\n if i == k:\n continue\n s, t = l[i-1]\n adjl[s].append(t)\n adjl[t].append(s)\n\n NIL = -1 # \u672a\u767a\u898b\u3092\u793a\u3059\u5024\n d = [-1 for i in range(n+1)] # \u9802\u70b91\u304b\u3089\u306e\u8ddd\u96e2\u3092\u683c\u7d0d\u3059\u308b\u30ea\u30b9\u30c8\n color = [NIL for i in range(n+1)] # \u672a\u5230\u9054\u304b\u3092\u793a\u3059\u30ea\u30b9\u30c8\n\n #print(adjl)\n\n color_id = 0\n for u in range(1, n+1): # node\u5168\u3066\u304b\u3089\u30b9\u30bf\u30fc\u30c8\u3059\u308b\n if color[u] == NIL:\n color_id += 1\n bfs(u, color_id)\n\n #print(color)\n if len(set(color)) >= 3:\n ans += 1\nprint(ans)", "def 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\nimport copy\nN,M = (int(T) for T in input().split())\nList = [[] for TM in range(0,M)]\nfor TM in range(0,M):\n List[TM] = [int(T) for T in input().split()]\n \nCount = 0\nfor TM in range(0,M):\n ListCopy = copy.deepcopy(List)\n del ListCopy[TM]\n \n Parent = [I for I in range(N+1)]\n Rank = [0]*(N+1)\n for TTM in range(0,M-1):\n UniteParent(ListCopy[TTM][0],ListCopy[TTM][1])\n\n if not CheckParent(List[TM][0],List[TM][1]):\n Count += 1\nprint(Count)", "class UnionFind: #\u5f15\u6570\u306f\u9802\u70b9\u306e\u6570\u30011\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\n def __init__(self, n):\n self.parents = [i for i in range(n+1)]\n self.rank = [0] * (n+1)\n\n # \u691c\u7d22\n def find(self, x):\n if self.parents[x] == x:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n # \u4f75\u5408\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.parents[x] = y\n else:\n self.parents[y] = x\n if self.rank[x] == self.rank[y]:\n self.rank[x] += 1\n\n # \u540c\u3058\u96c6\u5408\u306b\u5c5e\u3059\u308b\u304b\u5224\u5b9a\n def same_check(self, x, y):\n return self.find(x) == self.find(y)\n\n\ndef __starting_point():\n N, M = list(map(int, input().split()))\n bridges = [tuple(map(int, input().split())) for _ in range(M)]\n\n count = 0\n for i in range(M):\n union_find = UnionFind(N)\n for j in range(M):\n if i == j:\n continue\n a, b = bridges[j]\n union_find.union(a, b)\n\n for j in range(1, N):\n if union_find.find(j) != union_find.find(j+1):\n count += 1\n break\n\n print(count)\n \n \n\n\n\n\n\n\n\n__starting_point()", "#\n# abc075 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\nfrom collections import deque\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 = \"\"\"7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7\"\"\"\n output = \"\"\"4\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"3 3\n1 2\n1 3\n2 3\"\"\"\n output = \"\"\"0\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"6 5\n1 2\n2 3\n3 4\n4 5\n5 6\"\"\"\n output = \"\"\"5\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n N, M = list(map(int, input().split()))\n AB = [list(map(int, input().split())) for _ in range(M)]\n\n ans = 0\n for i in range(M):\n Target = AB[:]\n Target.pop(i)\n\n G = [[i+1, 0] for i in range(N)]\n for ab in Target:\n a, b = ab\n G[a-1][1] += 1\n G[b-1][1] += 1\n G[a-1].append(b)\n G[b-1].append(a)\n\n F = [False] * N\n Q = deque()\n Q.append(1)\n F[0] = True\n\n while Q:\n p = Q.pop()\n if G[p-1][1] == 0:\n continue\n\n for np in G[p-1][2:]:\n if F[np-1]:\n continue\n Q.append(np)\n F[np-1] = True\n\n for f in F:\n if f == False:\n ans += 1\n break\n\n print(ans)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "from typing import List, Tuple\n\n\ndef main():\n n, m = list(map(int, input().split()))\n g = []\n for _ in range(m):\n a, b = list(map(int, input().split()))\n g.append((a, b))\n print((br(n, m, g)))\n\n\ndef br(n: int, m: int, g: List[Tuple[int, int]]):\n ret = 0\n for i in range(m):\n v = set()\n w = [1]\n while w:\n now = w.pop()\n v.add(now)\n for j, node in enumerate(g):\n if j == i:\n continue\n if node[0] == now and node[1] not in v:\n w.append(node[1])\n elif node[1] == now and node[0] not in v:\n w.append(node[0])\n if len(v) != n:\n ret += 1\n return ret\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "from typing import List, Tuple\n\n\ndef main():\n n, m = list(map(int, input().split()))\n g = []\n for _ in range(m):\n a, b = list(map(int, input().split()))\n g.append((a, b))\n print((bb(n, m, g)))\n\n\ndef bb(n: int, m: int, g: List[Tuple[int, int]]):\n ret = 0\n for i in range(m):\n v = set()\n w = [1]\n while w:\n now = w.pop()\n v.add(now)\n for j, node in enumerate(g):\n if j == i:\n continue\n if node[0] == now and node[1] not in v:\n w.append(node[1])\n elif node[1] == now and node[0] not in v:\n w.append(node[0])\n if len(v) != n:\n ret += 1\n return ret\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "def FindParent(X):\n if Parent[X]==X:\n return X\n else:\n Parent[X] = FindParent(Parent[X])\n return Parent[X]\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\nimport copy\nN,M = (int(T) for T in input().split())\nList = [[] for TM in range(0,M)]\nfor TM in range(0,M):\n List[TM] = [int(T) for T in input().split()]\n \nCount = 0\nfor TM in range(0,M):\n ListCopy = copy.deepcopy(List)\n del ListCopy[TM]\n \n Parent = [I for I in range(N+1)]\n Rank = [0]*(N+1)\n for TTM in range(0,M-1):\n UniteParent(ListCopy[TTM][0],ListCopy[TTM][1])\n for TN in range(1,N+1):\n FindParent(TN)\n if len(set(Parent[1:]))>1:\n Count += 1\nprint(Count)", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parent = [i for i in range(self.n)]\n self.rank = [0] * self.n\n \n def find_root(self, x):\n if self.parent[x] == x:\n return x\n else:\n self.parent[x] = self.find_root(self.parent[x])\n return self.parent[x]\n \n def unite(self, x, y):\n rx = self.find_root(x)\n ry = self.find_root(y)\n if rx == ry:\n return\n if self.rank[rx] < self.rank[ry]:\n self.parent[rx] = ry\n else:\n self.parent[ry] = rx\n if self.rank[rx] == self.rank[ry]:\n self.rank[rx] += 1\n \n def is_same(self, x, y):\n return self.find_root(x) == self.find_root(y)\n\nN, M = map(int, input().split())\nedge = []\nbridge = 0\nfor _ in range(M):\n e = list(map(lambda x: int(x)-1, input().split()))\n edge.append(e)\n\nfor i in range(M):\n uf = UnionFind(N)\n for j in range(M):\n if j == i:\n continue\n uf.unite(edge[j][0], edge[j][1])\n if uf.find_root(edge[i][0]) != uf.find_root(edge[i][1]):\n bridge += 1\n\nprint(bridge)", "N, M = (int(x) for x in input().split())\nedge = [tuple(int(x) for x in input().split()) for _ in range(M)]\n\nimport numpy as np\nfrom scipy.sparse.csgraph import floyd_warshall\nINF = 100\ntmpl_graph = [[INF if i != j else 0 for j in range(N)] for i in range(N)]\n\nans = 0\nfor E in edge:\n edgeWithoutE = edge.copy()\n edgeWithoutE.remove(E)\n graph = np.array(tmpl_graph)\n for x in edgeWithoutE:\n graph[x[0]-1,x[1]-1] = 1\n graph[x[1]-1,x[0]-1] = 1\n graph = floyd_warshall(graph,directed=False)\n if len(graph[graph == 100]) > 0:\n ans += 1\nprint(ans)", "#https://atcoder.jp/contests/abc075/submissions/15509548\n\nn, m = list(map(int, input().split()))\ng = [[] for _ in range(n)]\nfor i in range(m):\n a, b = list(map(int, input().split()))\n a, b = a-1, b-1\n g[a].append(b)\n g[b].append(a)\n\ndef lowlink(g, root=0):\n n = len(g)\n order = [n]*n\n low = [n]*n\n\n s = [root]\n cnt = 0\n par = [-1]*n\n seq = []\n while s:\n v = s.pop()\n if order[v] != n:\n continue\n order[v] = cnt\n seq.append(v)\n low[v] = cnt\n cnt += 1\n for u in g[v]:\n if order[u] < cnt:\n if par[v] != u:\n low[v] = min(low[v], order[u])\n continue\n else:\n par[u] = v\n s.append(u)\n child = [[] for _ in range(n)]\n for v in range(n):\n if par[v] != -1:\n child[par[v]].append(v)\n seq.reverse()\n for v in seq:\n for u in child[v]:\n low[v] = min(low[v], low[u])\n # bridge\n bridge = []\n for p in range(n):\n for c in child[p]:\n if order[p] < low[c]:\n bridge.append((p, c))\n\n # articulation points\n AP = []\n for v in range(n):\n if v == root:\n if len(child[v]) >= 2:\n AP.append(v)\n else:\n for c in child[v]:\n if order[v] <= low[c]:\n AP.append(v)\n break\n return AP, bridge\n\n_, bridge = lowlink(g, 0)\nprint((len(bridge)))\n", "import sys\nsys.setrecursionlimit(10 ** 9)\n# input = sys.stdin.readline ####\ndef int1(x): return int(x) - 1\ndef II(): return int(input())\ndef MI(): return list(map(int, input().split()))\ndef MI1(): return list(map(int1, input().split()))\ndef LI(): return list(map(int, input().split()))\ndef LI1(): return list(map(int1, input().split()))\ndef LLI(rows_number): return [LI() for _ in range(rows_number)]\ndef MS(): return input().split()\ndef LS(): return list(input())\ndef LLS(rows_number): return [LS() for _ in range(rows_number)]\ndef printlist(lst, k=' '): print((k.join(list(map(str, lst)))))\nINF = float('inf')\n# from math import ceil, floor, log2\n# from collections import deque, defaultdict\n# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations\n# from heapq import heapify, heappop, heappush\n# import numpy as np # cumsum\n# from bisect import bisect_left, bisect_right\n\n\"\"\"\nhttps://note.nkmk.me/python-union-find/\n\u7d20\u96c6\u5408\u30c7\u30fc\u30bf\u69cb\u9020\n\n:parameter\nunion(x, y): 2\u3064\u306e\u96c6\u5408\u3092\u4e00\u3064\u306b\u4f75\u5408\u3059\u308b\nfind(x): x\u304c\u3069\u306e\u96c6\u5408\u306b\u5c5e\u3057\u3066\u3044\u308b\u304b\u3092\u5224\u5b9a\u3059\u308b\nsize(x): \u8981\u7d20x\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u306e\u30b5\u30a4\u30ba\uff08\u8981\u7d20\u6570\uff09\u3092\u8fd4\u3059\nsame(x, y): \u8981\u7d20x, y\u304c\u540c\u3058\u30b0\u30eb\u30fc\u30d7\u306b\u5c5e\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u8fd4\u3059\nmembers(x): \u8981\u7d20x\u304c\u5c5e\u3059\u308b\u30b0\u30eb\u30fc\u30d7\u306b\u5c5e\u3059\u308b\u8981\u7d20\u3092\u30ea\u30b9\u30c8\u3067\u8fd4\u3059\nroots(): \u5168\u3066\u306e\u6839\u306e\u8981\u7d20\u3092\u30ea\u30b9\u30c8\u3067\u8fd4\u3059\ngroup_count(): \u30b0\u30eb\u30fc\u30d7\u306e\u6570\u3092\u8fd4\u3059\nall_group_members(): \u8f9e\u66f8\u3092\u8fd4\u3059\u3002\u3000key = \u30eb\u30fc\u30c8\u8981\u7d20, value = \u305d\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u542b\u307e\u308c\u308b\u8981\u7d20\u306e\u30ea\u30b9\u30c8\n__str__(): print()\u3067\u306e\u8868\u793a\u7528\u3002\u30eb\u30fc\u30c8\u8981\u7d20: [\u305d\u306e\u30b0\u30eb\u30fc\u30d7\u306b\u542b\u307e\u308c\u308b\u8981\u7d20\u306e\u30ea\u30b9\u30c8]\u3092\u6587\u5b57\u5217\u3067\u8fd4\u3059\n\"\"\"\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def all_group_count(self):\n return [self.size(r) for r in self.roots()]\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\n\ndef solve():\n N, M = MI()\n E = []\n for i in range(M):\n a, b = MI1()\n E.append((a, b))\n\n ans = 0\n for a, b in E:\n uf = UnionFind(N)\n for v1, v2 in E:\n if (v1, v2) == (a, b):\n continue\n uf.union(v1, v2)\n # print(uf.group_count())\n if uf.group_count() > 1:\n ans += 1\n print(ans)\n\ndef __starting_point():\n solve()\n\n\n__starting_point()", "n, m = list(map(int, input().split()))\nadj = [[0]*(n+1) for _ in range(n+1)] #idx; 1~n\nedges = [tuple(map(int, input().split())) for _ in range(m)]\ncnt = 0\n\nfor e in edges:\n x, y = e\n adj[x][y] = 1\n adj[y][x] = 1\n\ndef dfs(s):\n seen[s] = 1\n for nx in range(1, n+1):\n if adj[s][nx]:\n if seen[nx]:\n continue\n dfs(nx)\n \nfor bridge in edges:\n bx, by = bridge\n adj[bx][by] = 0 #\u9053\u3092\u9664\u304f\n adj[by][bx] = 0\n seen = [0]*(n+1)\n dfs(1) #1\u304b\u3089\u6df1\u3055\u512a\u5148\u63a2\u7d22seen\u3092\u57cb\u3081\u308b\n is_ok = 1\n if any(seen[i] == 0 for i in range(1, n+1)):\n is_ok = 0\n if not is_ok:\n cnt += 1\n adj[bx][by] = 1 #\u9053\u3092\u623b\u3059\n adj[by][bx] = 1\n\nprint(cnt)\n", "import queue\n\nn, m = list(map(int, input().split()))\nam_bm = []\nside_map = dict()\nfor i in range(m):\n ai, bi = list(map(int, input().split()))\n if ai not in side_map:\n side_map[ai] = set()\n side_map[ai].add(bi)\n else:\n side_map[ai].add(bi)\n if bi not in side_map:\n side_map[bi] = set()\n side_map[bi].add(ai)\n else:\n side_map[bi].add(ai)\n am_bm.append((ai, bi))\n\ncounter = 0\nfor i in range(m):\n a, b = am_bm[i]\n q = queue.Queue()\n q.put(1)\n node_passed = set()\n node_passed.add(1)\n while not q.empty():\n a_tmp = q.get()\n for b_tmp in side_map[a_tmp]:\n if a_tmp == a and b_tmp == b or a_tmp == b and b_tmp == a:\n pass\n elif b_tmp not in node_passed:\n q.put(b_tmp)\n node_passed.add(b_tmp)\n if len(node_passed) == n:\n counter += 1\nprint((m - counter))\n", "# \u3069\u306e2\u70b9\u9593\u3082\u8fba\u3092\u8fbf\u308c\u3070\u5230\u9054\u3067\u304d\u308b\u3000\uff1d\u3000\u9023\u7d50\u30b0\u30e9\u30d5\n# \u3069\u3046\u9811\u5f35\u3063\u3066\u3082\u305f\u3069\u308a\u7740\u3051\u306a\u3044\u3000\uff1d\u3000\u975e\u9023\u7d50\u30b0\u30e9\u30d5\nN, M = list(map(int, input().split()))\nAB = [list(map(int, input().split())) for i in range(M)]\n\n\nclass UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\n\n# 1\u8fba\u3092\u7701\u3044\u3066UnionFind\u3057\u305f\u3068\u304d\u3001\u30b0\u30eb\u30fc\u30d7\u6570\u304c\uff12\u4ee5\u4e0a\u306b\u306a\u3063\u305f\u3089\u305d\u306e\u8fba\u306f\u300c\u6a4b\u300d\nans = 0\nfor i in range(M):\n u = UnionFind(N)\n for j, ab in enumerate(AB):\n if i == j:\n continue\n else:\n a, b = ab\n u.union(a - 1, b - 1)\n if u.group_count() != 1:\n ans += 1\n\nprint(ans)\n", "n, m = list(map(int, input().split()))\nedges = [[] for _ in range(n)]\n\nfor i in range(m):\n a, b = list(map(int, input().split()))\n\n edges[a-1].append(b-1)\n edges[b-1].append(a-1)\n\nind = 1\nqueue = [0]\nvisitedOrder = {}\nvisited = {}\ncnt = 0\n\nwhile queue:\n cur = queue[-1]\n\n if cur not in visited:\n visited[cur] = ind\n visitedOrder[cur] = ind\n ind += 1\n\n neighbours = False\n for nei in edges[cur]:\n if nei not in visited:\n neighbours = True\n queue.append(nei)\n break\n\n if not neighbours:\n queue.pop()\n\n if cur != 0:\n connected = visited[cur]\n\n for nei in edges[cur]:\n if nei != queue[-1]:\n connected = min(connected, visited[nei])\n\n visited[cur] = connected\n if connected > visitedOrder[queue[-1]]:\n cnt += 1\n\nprint(cnt)", "def dfs(current):\n for maps in Graph[current]:\n if maps in already:\n continue\n else:\n already.append(maps)\n dfs(maps)\n\nn,m = map(int,input().split())\nans = 0\nEdges = []\nfor _ in range(m):\n Edges.append([int(j)-1 for j in input().split()])\n\nfor i in range(m):\n egdes = Edges[0:i]+Edges[i+1:]\n Graph = [[] for _ in range(n)]\n for edge in egdes:\n Graph[edge[0]].append(edge[1])\n Graph[edge[1]].append(edge[0])\n already = []\n dfs(0)\n if len(already) != n:\n ans += 1\nprint(ans)", "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 n,m = i_map()\n ab = [i_list() for i in range(m)]\n\n def dfs(table):\n visited = [1]\n que = [1]\n\n while que != []:\n now = que[0]\n del que[0]\n\n for index, e in enumerate(table[now]):\n if (e==1) & (index not in visited):\n visited.append(index)\n que.append(index)\n if len(visited) == n:\n return 0\n else:\n return 1\n\n ans = 0\n for i in range(m):\n graph = ab.copy()\n del graph[i]\n table = [[0]*(n+1) for i in range(n+1)]\n for a,b in graph:\n table[a][b] = 1\n table[b][a] = 1\n\n ans += dfs(table)\n print(ans)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import networkx as nx\n\nN, M = map(int, input().split())\nG = nx.Graph()\nG.add_nodes_from(range(1, N + 1))\nG.add_edges_from([tuple(map(int, input().split())) for _ in range(M)])\n\nprint(len(tuple(nx.bridges(G))))# nx.bridges\u2026\u2026\u6a4b\u3068\u306a\u308b\u8fba\u3092\u30a4\u30c6\u30ec\u30fc\u30bf\u3068\u3057\u3066\u8fd4\u3059", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n if x == y:\n return\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n \n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return list(i for i in range(self.n) if self.find(i) == root)\n\n def roots(self):\n return list(i for i, x in enumerate(self.parents) if x < 0)\n\n def group_count(self):\n return len(self.roots)\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nadj = []\nN, M = list(map(int, input().split()))\nfor m in range(M):\n a,b = list(map(int, input().split()))\n adj.append([a-1, b-1])\n\nans = 0\nfor i in range(M): # \u53d6\u308a\u9664\u304f\u8fba\u306e\u756a\u53f7\n uf = UnionFind(N)\n for j in range(M): # \u8fba\u3092\u8ffd\u52a0\u3057\u306a\u3044\uff08\u53d6\u308a\u9664\u304f\uff09\n if i == j:\n continue\n uf.union(*adj[j])\n if len(set(uf.roots())) != 1:\n ans += 1\nprint(ans)\n\n", "from collections import defaultdict\n\nN, M = list(map(int, input().split()))\n\nG = defaultdict(list)\n\nAB = []\nfor _ in range(M):\n a, b = list(map(int, input().split()))\n a, b = a, b\n G[a].append(b)\n G[b].append(a)\n AB.append((a, b))\n\n# print(f'{G=}')\n\n\ndef f(a, b):\n S = set([])\n Q = [1]\n while True:\n QQ = []\n for q in Q:\n S.add(q)\n for j in G[q]:\n if q == a and j == b:\n continue\n if q == b and j == a:\n continue\n if j not in S:\n QQ.append(j)\n if len(QQ) == 0:\n break\n Q = QQ\n # print(f'{QQ=}')\n # print(f'{a=}, {b=}, {S=}')\n return 1 if len(S) != N else 0\n\n\ncnt = 0\nfor a, b in AB:\n cnt += f(a, b)\n\n# print(f'{cnt=}')\nprint(cnt)\n", "import sys\nsys.setrecursionlimit(10**9)\nclass UnionFind:\n def __init__(self, n):\n self.n = [-1]*n\n self.r = [0]*n\n self.siz = n\n\n def find_root(self, x):\n if self.n[x] < 0:\n return x\n else:\n self.n[x] = self.find_root(self.n[x])\n return self.n[x]\n\n def unite(self, x, y):\n x = self.find_root(x)\n y = self.find_root(y)\n if x == y:\n return\n elif self.r[x] > self.r[y]:\n self.n[x] += self.n[y]\n self.n[y] = x\n else:\n self.n[y] += self.n[x]\n self.n[x] = y\n if self.r[x] == self.r[y]:\n self.r[y] += 1\n self.siz -= 1\n\n def root_same(self, x, y):\n return self.find_root(x) == self.find_root(y)\n\n def count(self, x):\n return -self.n[self.find_root(x)]\n\n def size(self):\n return self.siz\n\nn,m=list(map(int,input().split()))\nedges=[list(map(int,input().split()))for _ in range(m)]\nans=0\nfor i in range(m):\n u=UnionFind(n)\n for j in range(m):\n if j==i:continue\n a,b=edges[j]\n a-=1\n b-=1\n u.unite(a,b)\n if u.size()!=1:ans+=1\nprint(ans)\n", "N, M = map(int, input().split())\nAB = [list(map(int, input().split())) for _ in range(M)]\n\n\nclass Union_Find:\n def __init__(self, n):\n self.par = [-1] * n\n self.siz = [1] * n\n\n def root(self, x):\n if self.par[x] == -1:\n return x\n else:\n return self.root(self.par[x])\n\n def issame(self, x, y):\n return self.root(x) == self.root(y)\n\n def unite(self, x, y):\n x = self.root(x)\n y = self.root(y)\n\n if x == y:\n return False\n\n if self.siz[x] < self.siz[y]:\n tmp = x\n x = y\n y = tmp\n\n self.par[y] = x\n self.siz[x] += self.siz[y]\n return True\n\n def size(self, x):\n return self.siz[x]\n\n\nans = 0\nfor m in range(M):\n uf = Union_Find(N)\n for i in range(M):\n if i == m:\n continue\n \n a, b = AB[i]\n a -= 1\n b -= 1\n uf.unite(a, b)\n\n ans += len(set([uf.root(x) for x in range(N)])) != 1\n\nprint(ans)", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parent = [i for i in range(self.n)]\n self.rank = [0] * self.n\n \n def find_root(self, x):\n if self.parent[x] == x:\n return x\n else:\n self.parent[x] = self.find_root(self.parent[x])\n return self.parent[x]\n \n def unite(self, x, y):\n rx = self.find_root(x)\n ry = self.find_root(y)\n if rx == ry:\n return\n if self.rank[rx] < self.rank[ry]:\n self.parent[rx] = ry\n else:\n self.parent[ry] = rx\n if self.rank[rx] == self.rank[ry]:\n self.rank[rx] += 1\n \n def is_same(self, x, y):\n return self.find_root(x) == self.find_root(y)\n\nN, M = map(int, input().split())\nedge = []\nbridge = 0\nfor _ in range(M):\n e = list(map(lambda x: int(x)-1, input().split()))\n edge.append(e)\n\nfor i in range(M):\n uf = UnionFind(N)\n for j in range(M):\n if j == i:\n continue\n uf.unite(edge[j][0], edge[j][1])\n \n root = uf.find_root(0)\n for i in range(1, N):\n if root != uf.find_root(i):\n bridge += 1\n break\n\nprint(bridge)", "from sys import stdin\nnii=lambda:map(int,stdin.readline().split())\nlnii=lambda:list(map(int,stdin.readline().split()))\nfrom collections import deque\nfrom copy import deepcopy\n\nn,m=nii()\nl=[lnii() for i in range(m)]\n\ndef BFS(t_l):\n tree=[[] for i in range(n)]\n for a,b in t_l:\n a-=1\n b-=1\n tree[a].append(b)\n tree[b].append(a)\n\n dist=[-1 for i in range(n)]\n dist[0]=0\n\n que=deque()\n que.append(0)\n\n while que:\n x=que.popleft()\n for i in tree[x]:\n if dist[i]==-1:\n que.append(i)\n dist[i]=dist[x]+1\n\n return dist\n\nans=0\nfor i in range(m):\n t_l=deepcopy(l)\n del t_l[i]\n dist=BFS(t_l)\n if -1 in dist:\n ans+=1\n\nprint(ans)", "N,M=list(map(int,input().split()))\na=[]\nb=[]\nfor e in range(M):\n x,y=list(map(int,input().split()))\n x-=1\n y-=1\n a.append(x)\n b.append(y)\n\ndef solve(e):\n parent=[i for i in range(N)]\n def find(x,parent):\n y=parent[x]\n while y!=parent[y]:\n y=find(y,parent)\n parent[x]=y\n return y\n def unite(a,b,parent):\n x=find(a,parent)\n y=find(b,parent)\n if x!=y:\n parent[x]=y\n\n for i in range(M):\n if i==e:\n continue\n unite(a[i],b[i],parent)\n cnt=[0 for _ in range(N)]\n for i in range(N):\n cnt[find(i,parent)]=1\n if cnt.count(1)>1:\n return 1\n else:\n return 0\nans=0\nfor i in range(M):\n ans+=solve(i)\nprint(ans)\n", "import sys\nfrom collections import deque\n\ninput = sys.stdin.readline\nN, M = map(int, input().split())\n\nedges = [[] for _ in range(N)]\nedge_set = set()\nfor _ in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n edges[a].append(b)\n edges[b].append(a)\n\n edge_set.add((a, b))\n\nans = 0\nfor a, b in edge_set:\n q = deque()\n q.append(0)\n visited = set()\n while q:\n p = q.popleft()\n if p in visited:\n continue\n visited.add(p)\n for np in edges[p]:\n if (p, np) == (a, b) or (np, p) == (a, b):\n continue\n q.append(np)\n if len(visited) != N:\n ans += 1\n\nprint(ans)", "import sys\nreadline = sys.stdin.readline\n\nN,M = map(int,readline().split())\nbridges = [None] * M\nG = [[] for i in range(N)]\n\nfor i in range(M):\n a,b = map(int,readline().split())\n G[a - 1].append(b - 1)\n G[b - 1].append(a - 1)\n bridges[i] = (a - 1, b - 1)\n \nfrom collections import deque\n\nans = 0\nfor i in range(M):\n q = deque([])\n q.append(0)\n seen = set()\n while q:\n v = q.popleft()\n if v in seen:\n continue\n seen.add(v)\n for child in G[v]:\n if (v, child) == bridges[i] or (child, v) == bridges[i]:\n continue\n q.append(child)\n if len(seen) != N:\n ans += 1\n \nprint(ans)", "class UnionFind():\n def __init__(self, n):\n self.n = n\n self.parents = [-1] * n\n\n def find(self, x):\n if self.parents[x] < 0:\n return x\n else:\n self.parents[x] = self.find(self.parents[x])\n return self.parents[x]\n\n def union(self, x, y):\n x = self.find(x)\n y = self.find(y)\n\n if x == y:\n return\n\n if self.parents[x] > self.parents[y]:\n x, y = y, x\n\n self.parents[x] += self.parents[y]\n self.parents[y] = x\n\n def size(self, x):\n return -self.parents[self.find(x)]\n\n def same(self, x, y):\n return self.find(x) == self.find(y)\n\n def members(self, x):\n root = self.find(x)\n return [i for i in range(self.n) if self.find(i) == root]\n\n def roots(self):\n return [i for i, x in enumerate(self.parents) if x < 0]\n\n def group_count(self):\n return len(self.roots())\n\n def all_group_members(self):\n return {r: self.members(r) for r in self.roots()}\n\n def __str__(self):\n return '\\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())\n\nN,M = list(map(int,input().split()))\nedges = []\nfor i in range(M):\n x = list(map(int,input().split()))\n edges.append(x)\nans = 0\nfor i in range(M):\n uf = UnionFind(N)\n for j in range(M):\n if j != i:\n uf.union(edges[j][0]-1,edges[j][1]-1)\n if j == M-1 and uf.group_count() != 1:\n ans += 1\nprint(ans)\n", "n,m = map(int,input().split())\npar = [i for i in range(n+1)]\ndef find(x):\n if par[x] == x:\n return x\n else:\n par[x] = find(par[x]) #\u7d4c\u8def\u5727\u7e2e\n return par[x]\ndef same(x,y):\n return find(x) == find(y)\ndef unite(x,y):\n x = find(x)\n y = find(y)\n if x == y:\n return 0\n par[x] = y\nls = [list(map(int,input().split())) for _ in range(m)]\nans = 0\nfor i in ls:\n for k in ls:\n if i != k:\n [a,b] = k\n unite(a,b)\n flag = True\n for p in range(1,n+1):\n for q in range(1,n+1):\n if not same(p,q):\n flag = False\n break\n if flag == False:\n break\n if flag == False:\n ans += 1\n par = [i for i in range(n+1)]\nprint(ans)"]
{"inputs": ["7 7\n1 3\n2 7\n3 4\n4 5\n4 6\n5 6\n6 7\n", "3 3\n1 2\n1 3\n2 3\n", "6 5\n1 2\n2 3\n3 4\n4 5\n5 6\n"], "outputs": ["4\n", "0\n", "5\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
104,377
f37252dc0c1d950feb7a91fd0aaa8a71
UNKNOWN
You are given three integers, A, B and C. Among them, two are the same, but the remaining one is different from the rest. For example, when A=5,B=7,C=5, A and C are the same, but B is different. Find the one that is different from the rest among the given three integers. -----Constraints----- - -100 \leq A,B,C \leq 100 - A, B and C are integers. - The input satisfies the condition in the statement. -----Input----- Input is given from Standard Input in the following format: A B C -----Output----- Among A, B and C, print the integer that is different from the rest. -----Sample Input----- 5 7 5 -----Sample Output----- 7 This is the same case as the one in the statement.
["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\n\nxs=LI()\n\nif xs[0] == xs[1]:\n print(xs[2])\nelif xs[0] == xs[2]:\n print(xs[1])\nelse:\n print(xs[0])", "A, B, C = map(int,input().split())\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)", "a = input().split(' ')\n\nfor i in a:\n if (a.count(i)==1):\n print(i)", "a, b, c = map(int, input().split())\n\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)", "#\n# abc075 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 7 5\"\"\"\n output = \"\"\"7\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"1 1 7\"\"\"\n output = \"\"\"7\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"-100 100 100\"\"\"\n output = \"\"\"-100\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n A, B, C = list(map(int, input().split()))\n\n if A == B:\n print(C)\n elif A == C:\n print(B)\n else:\n print(A)\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "#75\na,b,c=map(int,input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)", "a, b, c = input().split()\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)", "a,b,c=map(int, input().split())\nprint(a if b==c else b if c==a else c)", "a=list(map(int,input().split()))\nb=set(a)\n\nfor i in b:\n if (a.count(i))==1:\n print(i)", "# 3\u3064\u306e\u6574\u6570\u306e\u3046\u30611\u3064\u3060\u3051\u7570\u306a\u308b\u5024\u3092\u51fa\u529b\nA, B, C = map(int,input().split())\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)", "import collections\nl=list(map(int,input().split()))\ncounted = collections.Counter(l)\nprint(counted.most_common()[1][0])", "l=list(map(int,input().split()))\nfrom collections import Counter\nl=list(Counter(l).most_common())\nprint(l[1][0])", "a,b,c = input().split()\nif a == b:\n print(c)\nelif a == c:\n print(b)\nelif b == c:\n print(a)", "A,B,C=map(int,input().split())\nif A==B :\n print(C)\nelif B==C :\n print(A)\nelse :\n print(B)", "a,b,c=map(int,input().split())\nif a==b:\n print(c)\nelif b==c:\n print(a)\nelse:\n print(b)", "a,b,c = map(int,input().split())\n\nif a == b:\n print(c)\n \nelif a == c:\n print(b)\n \nelse:\n print(a)", "A, B, C = [int(i) for i in input().split()]\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelif B == C:\n print(A)\n", "a,b,c = map(int,input().split())\nprint(a if b==c else b if a==c else c)", "a, b, c = map(int, input().split())\nprint(a ^ b ^ c)", "A,B,C = map(int,input().split())\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)", "a, b, c = list(map(int, input().split()))\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)\n", "a,b,c = map(int, input().split())\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)", "A,B,C = map(int,input().split())\n\nprint(A if B == C else B if A == C else C)", "A, B, C = sorted(map(int, input().split()))\n\nprint((A if B == C else C))\n", "a,b,c=map(int,input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)", "A, B, C = list(map(int, input().split()))\n\nif A - B == 0:\n print(C)\nelif A - C == 0:\n print(B)\nelse:\n print(A)\n", "a, b, c = map(int, input().split())\nif a == b: print(c)\nif b == c: print(a)\nif c == a: print(b)", "A, B, C = map(int, input().split())\n\nif A == C:\n print(B)\nelif B == C:\n print(A)\nelse:\n print(C)", "a,b,c = map(int,input().split())\nif a != b and a == c:\n print(b)\nelif a != b and a != c:\n print(a)\nelse:\n print(c)", "def main():\n a = list(map(int,input().split()))\n if a[0] == a[1]:\n print((a[2]))\n elif a[1] == a[2]:\n print((a[0]))\n else:\n print((a[1]))\n \ndef __starting_point():\n main()\n\n__starting_point()", "integer1, integer2, integer3 = map(int, input().split())\nif integer2 == integer3:\n print(integer1)\nelif integer1 == integer3:\n print(integer2)\nelse:\n print(integer3)", "a,b,c=map(int,input().split())\n\nprint(c) if a == b else print(b) if a == c else print(a)", "# A - One out of Three\n# https://atcoder.jp/contests/abc075/tasks/abc075_a\n\nA, B, C = list(map(int, input().split()))\n\nif A == B and A != C:\n print(C)\nelif A == C and A != B:\n print(B)\nelif B == C and A != C:\n print(A)\n", "A,B,C = map(int, input().split())\nif A == C:\n print(B)\nelif A == B:\n print(C)\nelse:\n print(A)", "# \u5165\u529b\nA, B, C = map(int, input().split())\n\n# \u6bd4\u8f03\u3057\u3066\u51fa\u529b\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelif B == C:\n print(A)", "# \u5165\u529b\nA, B, C = map(int,input().split())\n\n# \u51e6\u7406\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)", "a,b,c= map(int,input().split())\nprint(a^b^c)", "x,y,z=map(int,input().split())\nprint(z if x == y else y if x == z else x)", "a,b,c = map(int,input().split())\n\nif a == c:\n\tprint(b)\nelif a == b:\n\tprint(c)\nelif b == c:\n\tprint(a)", "a,b,c = map(int,input().split())\nif a == b:\n print(c)\nif a == c:\n print(b)\nif b == c:\n print(a)", "ls = list(map(int,input().split()))\nif ls[1] != ls[2] and ls[2] == ls[0]:\n print((ls[1]))\nif ls[0] != ls[1] and ls[1] == ls[2]:\n print((ls[0]))\nif ls[2] != ls[1] and ls[1] == ls[0]:\n print((ls[2]))\n", "a, b, c = list(map(int, input().split()))\n\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)\n", "a = [int(x) for x in input().split()]\nif a[0] == a[1]:\n print(a[2])\nelif a[1] == a[2]:\n print(a[0])\nelse:\n print(a[1])", "a,b,c = map(int,input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)", "A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif B == C:\n print(A)\nelse:\n print(B)", "a,b,c=list(map(int,input().split()))\nif a==b & b != c:\n print(c)\nelif a==c & c !=b:\n print(b)\nelse:\n print(a)\n", "A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif B == C:\n print(A)\nelif C == A:\n print(B)", "A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelse:\n print(A)", "a, b, c = map(int, input().split())\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)", "a,b,c=map(int,input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)", "a,b,c = map(int, input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)", "import sys, collections\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 ABC = LI()\n\n cnt = collections.Counter(ABC)\n ans = [k for k, v in list(cnt.items()) if v == 1]\n print((ans[0]))\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "# 3 \u3064\u306e\u6574\u6570 A, B, C\u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n# A, B, C \u306e\u3046\u3061 2\u3064\u306f \u540c\u3058\u6574\u6570\u3067\u3042\u308a\u3001\n# \u6b8b\u308a\u306e 1\u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3067\u3059\u3002\n# \u4f8b\u3048\u3070\u3001A = 5, B = 7, C = 5\u306e\u5834\u5408\u3001\n# A, C \u306e 2\u3064\u306f\u540c\u3058\u6574\u6570\u3067\u3042\u308a\u3001\n# B \u306f 1\u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3067\u3059\u3002\n# 3\u3064\u306e\u6574\u6570\u306e\u3046\u3061\u30011\u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3092\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\n# \u5236\u7d04\n# -100 \u2266 A, B, C \u2266 100\n# A, B, C \u306f\u6574\u6570\n# \u5165\u529b\u306f\u554f\u984c\u6587\u306e\u6761\u4ef6\u3092\u6e80\u305f\u3059\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\n# \u7570\u306a\u308b\u6574\u6570\u3092\u63a2\u3057\u3066\u51fa\u529b\u3059\u308b\nresult = 0\n\nif a == b:\n result = c\nelif b == c:\n result = a\nelif a == c:\n result = b\nelse:\n result = \"Error\"\n\nprint(result)\n", "a, b, c = map(int, input().split())\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)", "a,b,c = input().split()\n\nif(a==b):\n print(c)\nelif(a == c):\n print(b)\nelse:\n print(a)", "from collections import Counter\n\nABC = list(map(int, input().split()))\n\ncnt = Counter(ABC)\nvalues, counts = zip(*cnt.most_common(2))\n\nprint(values[1])", "num = list(map(int, input().split()))\nnum = sorted(num)\nprint((num[0] if num[0] != num[1] else num[2]))\n", "a,b,c = map(int,input().split())\nif a==b:\n print(c)\nelif b==c:\n print(a)\nelse:\n print(b)", "a,b,c = map(int,input().split())\nif a == c:\n print(b)\nelif a == b:\n print(c)\nelse:\n print(a)", "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 abc = sorted(Input())\n if abc[0] == abc[1]:\n print(abc[2])\n else:\n print(abc[0])\n\n\nmain()", "a,b,c=input().split()\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)", "# A - One out of Three\n\n# \u5165\u529b\u3055\u308c\u305f\u6574\u6570A,B,C\u306e\u3046\u3061\u30012\u3064\u306f\u7b49\u3057\u304f1\u3064\u306f\u7570\u306a\u308b\n# 1\u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u306e\u5024\u3092\u51fa\u529b\u3059\u308b\n\n\nA,B,C = list(map(int,input().split()))\n\nif A == B:\n print(C)\nelif A == C:\n print(B)\nelif B == C:\n print(A)\n", "a, b, c = list(map(int, input().split()))\n\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)\n", "a, b, c =map(int, input().split())\n\n\nif a==b:\n print(c)\nelif b ==c:\n print(a)\nelse:\n print(b)", "# 3 \u3064\u306e\u6574\u6570 A , B , C \u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002 A , B , C \u306e\u3046\u3061 2 \u3064\u306f \u540c\u3058\u6574\u6570\u3067\u3042\u308a\u3001\u6b8b\u308a\u306e 1 \u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3067\u3059\u3002\n# \u4f8b\u3048\u3070\u3001 A = 5 , B = 7 , C = 5 \u306e\u5834\u5408\u3001 A , C \u306e 2 \u3064\u306f\u540c\u3058\u6574\u6570\u3067\u3042\u308a\u3001 B \u306f 1 \u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3067\u3059\u3002\n# 3 \u3064\u306e\u6574\u6570\u306e\u3046\u3061\u3001 1 \u3064\u3060\u3051\u7570\u306a\u308b\u6574\u6570\u3092\u6c42\u3081\u3066\u304f\u3060\u3055\u3044\u3002\n\nA,B,C =map(int,input().split())\n\nif A == B:\n print(C)\n\nelif A == C:\n print(B)\n\nelif B == C:\n print(A)", "A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif B == C:\n print(A)\nelif C == A:\n print(B)", "a,b,c = map(int,input().split())\n\nif a == b:\n print(c)\nelif a == c:\n print(b)\nelse:\n print(a)", "a,b,c=map(int,input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)", "A,B,C=list(map(int,input().split()))\nif A==B:\n print(C)\nelif B==C:\n print(A)\nelse:\n print(B)\n", "#!/usr/bin/env python3\n\nA, B, C = list(map(int, input().split()))\nif A == B: print(C)\nelif A == C: print(B)\nelse: print(A)\n", "a, b, c = list(map(int, input().split()))\n\nprint((a ^ b ^ c))\n", "A, B, C = map(int, input().split())\nprint(A if B == C else B if A == C else C)", "a, b, c = map(int,input().split())\n\nif int(a) == int(b):\n print(c)\nif int(a) == int(c):\n print(b)\nif int(b) == int(c):\n print(a)", "a, b, c = map(int, input().split())\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)", "def main():\n import sys\n input = sys.stdin.readline\n sys.setrecursionlimit(10**7)\n from collections import Counter, deque\n from collections import defaultdict\n from itertools import combinations, permutations, accumulate, groupby, product\n from bisect import bisect_left,bisect_right\n from heapq import heapify, heappop, heappush\n from math import floor, ceil,pi,factorial\n from operator import itemgetter\n def I(): return int(input())\n def MI(): return list(map(int, input().split()))\n def LI(): return list(map(int, input().split()))\n def LI2(): return [int(input()) for i in range(n)]\n def MXI(): return [[LI()]for i in range(n)]\n def SI(): return input().rstrip()\n def printns(x): print(('\\n'.join(x)))\n def printni(x): print(('\\n'.join(list(map(str,x)))))\n inf = 10**17\n mod = 10**9 + 7\n#main code here!\n a,b,c=MI()\n if a==b:\n print(c)\n elif b==c:\n print(a)\n else:\n print(b)\n \ndef __starting_point():\n main()\n\n__starting_point()", "lst = input().split()\n\nfor i in range(3):\n if lst.count(lst[i]) == 1:\n print(lst[i])\n break", "a, b, c = map(int, input().split())\nif a == b:\n print(c)\nelif b == c:\n print(a)\nelse:\n print(b)", "A,B,C=list(map(int,input().split()))\nif A==B:\n print(C)\nelif A==C:\n print(B)\nelif B==C:\n print(A)\n", "a,b,c = list(map(int,input().split()))\n\nif a == b:\n print(c)\nelif a == c:\n print(b) \nelse:\n print(a)\n", "A, B, C = map(int, input().split())\nprint(A ^ B ^ C)", "l=sorted(map(int,input().split()))\nprint(sum(l)-l[1]*2)", "# AtCoder abc075 a\n# \u30b9\u30c8\u30ec\u30c3\u30c1\u8ab2\u984c\n\n# \u5165\u529b\na, b, c =list(map(int, input().split()))\n\n# \u5224\u5b9a\nif a == b:\n print(c)\nelif a == c:\n print(b)\nelse:\n print(a)\n", "A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif B == C:\n print(A)\nelif A == C:\n print(B)", "A,B,C = list(map(int,input().split()))\nif A==B:\n print(C)\nelif A == C:\n print(B)\nelif B == C:\n print(A)\n", "A, B, C = map(int, input().split())\n\nif A == B:\n print(C)\nelif B == C:\n print(A)\nelse:\n print(B)", "a,b,c = sorted(map(int,input().split()))\nprint( c if a == b else a)", "a,b,c=map(int,input().split())\nif a==c:\n print(b)\nelif a==b:\n print(c)\nelse:\n print(a)", "l = list(map(int, input().split()))\nfor ll in l:\n if l.count(ll)==1:\n print(ll)\n break", "def iroha():\n a,b,c = list(map(int, input().split()))\n if a == b:\n print(c)\n elif a == c:\n print(b)\n else:\n print(a)\n\n\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "a,b,c=list(map(int,input().split()))\n\nif a==b:\n ans=c\nelif b==c:\n ans=a\nelse:\n ans=b\nprint(ans)\n", "a, b, c = map(int, input().split())\nif a == b:\n print(c)\nelif c == b:\n print(a)\nelse:\n print(b)", "# 075_a\nA,B,C=list(map(int,input().split()))\nif (-100<=A and A<=100) and (-100<=B and B<=100) and (-100<=C and C<=100):\n if A==B:\n print(C)\n elif B==C:\n print(A)\n elif C==A:\n print(B)\n", "s=list(map(int,input().split()))\ni=set(s)\nprint(sum(i)-(sum(s)-sum(i)))", "a,b,c=map(int,input().split())\nif a==b:\n print(c)\nelif a==c:\n print(b)\nelse:\n print(a)", "a, b, c = map(int, input().split())\n\nif a == b:\n print(c)\nelif a == c:\n print(b)\nelse:\n print(a)", "a,b,c=map(int,input().split())\nprint(a if b==c else b if a==c else c)", "a=list(map(int,input().split()))\na.sort()\n\nif a[0]==a[1]:\n print(a[2])\nelse:\n print(a[0])", "a, b, c=map(int,input().split())\nif a==b:\n print(c)\nelif c==b:\n print(a)\nelse:\n print(b)"]
{"inputs": ["5 7 5\n", "1 1 7\n", "-100 100 100\n"], "outputs": ["7\n", "7\n", "-100\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,561
4dcd14340d1207b1e6f3859b5f543558
UNKNOWN
Snuke is making sugar water in a beaker. Initially, the beaker is empty. Snuke can perform the following four types of operations any number of times. He may choose not to perform some types of operations. - Operation 1: Pour 100A grams of water into the beaker. - Operation 2: Pour 100B grams of water into the beaker. - Operation 3: Put C grams of sugar into the beaker. - Operation 4: Put D grams of sugar into the beaker. In our experimental environment, E grams of sugar can dissolve into 100 grams of water. Snuke will make sugar water with the highest possible density. The beaker can contain at most F grams of substances (water and sugar combined), and there must not be any undissolved sugar in the beaker. Find the mass of the sugar water Snuke will make, and the mass of sugar dissolved in it. If there is more than one candidate, any of them will be accepted. We remind you that the sugar water that contains a grams of water and b grams of sugar is \frac{100b}{a + b} percent. Also, in this problem, pure water that does not contain any sugar is regarded as 0 percent density sugar water. -----Constraints----- - 1 \leq A < B \leq 30 - 1 \leq C < D \leq 30 - 1 \leq E \leq 100 - 100A \leq F \leq 3 000 - A, B, C, D, E and F are all integers. -----Inputs----- Input is given from Standard Input in the following format: A B C D E F -----Outputs----- Print two integers separated by a space. The first integer should be the mass of the desired sugar water, and the second should be the mass of the sugar dissolved in it. -----Sample Input----- 1 2 10 20 15 200 -----Sample Output----- 110 10 In this environment, 15 grams of sugar can dissolve into 100 grams of water, and the beaker can contain at most 200 grams of substances. We can make 110 grams of sugar water by performing Operation 1 once and Operation 3 once. It is not possible to make sugar water with higher density. For example, the following sequences of operations are infeasible: - If we perform Operation 1 once and Operation 4 once, there will be undissolved sugar in the beaker. - If we perform Operation 2 once and Operation 3 three times, the mass of substances in the beaker will exceed 200 grams.
["a, b, c, d, e, f = map(int, input().split())\ns = set()\nfor i in range(30 // a + 1):\n for j in range(30 // b + 1):\n if 0 < (a * i + b * j) * 100 <= f:\n s = s | {a * i + b * j}\ns2 = set()\nfor i in range(3000 // c + 1):\n for j in range(3000 // d + 1):\n if c * i + d * j <= f:\n s2 = s2 | {c * i + d * j}\nans = []\nfor i in s:\n for j in s2:\n if i * 100 + j <= f and j <= i * e:\n ans.append([j / i * -1, i * 100 + j, j])\nans.sort()\nprint(ans[0][1], ans[0][2])", "A,B,C,D,E,F = map(int,input().split())\n\nconcentration = 0\nans = [A*100,0]\n\nwater = []\nfor a in range(F//(A*100) + 1):\n for b in range(((F-a*A*100)//(B*100))+1):\n water.append((a*A+b*B)*100)\n \nwater = sorted(list(set(water)))\n\nsugar = []\nfor c in range(F//C + 1):\n for d in range(((F - c*C)//D)+1):\n sugar.append(c*C+d*D)\nsugar = sorted(list(set(sugar)))\n\n\nfor wa in water:\n for su in sugar:\n if wa + su <= F:\n if su <= (wa/100)*E:\n if wa != 0:\n if concentration < su/(su+wa):\n concentration = su/(su+wa)\n ans = [su+wa,su]\n\nprint(\" \".join(map(str,ans)))", "A,B,C,D,E,F = map(int,input().split())\nmx =- 1\nS = set()\nW = set()\n\nfor a in range(0,F+1,100*A):\n for b in range(0,F+1-a,100*B):\n W.add(a+b)\n\nfor c in range(0,F+1,C):\n for d in range(0,F+1-c,D):\n S.add(c+d)\n\nfor w in W:\n for s in S:\n if 0<w+s<=F and s<=w*E//100:\n if mx<s/(w+s):\n ans=w+s,s\n mx=s/(w+s)\n\nprint(ans[0],ans[1])", "a,b,c,d,e,f=map(int,input().split())\nw=set()\nfor i in range(0,f,100*a):\n for j in range(0,f,100*b):\n if i+j<=f:\n w.add(i+j)\n else:\n break\ns=set()\nfor i in range(0,f,c):\n for j in range(0,f,d):\n if i+j<=f:\n s.add(i+j)\n else:\n break\nn=100*a\nm=0\nl=0\nfor x in w:\n for t in s:\n if x+t!=0 and x+t<=f and 100*t<=e*x and t/(x+t)>l:\n n=x+t\n m=t\n l=t/(x+t)\nprint(n,m)", "A,B,C,D,E,F = map(int,input().split())\nmx =- 1\nS = set()\nW = set()\n\nfor a in range(0,F+1,100*A):\n for b in range(0,F+1-a,100*B):\n W.add(a+b)\n\nfor c in range(0,F+1,C):\n for d in range(0,F+1-c,D):\n S.add(c+d)\n\nfor w in W:\n for s in S:\n if 0<w+s<=F and s<=w*E//100:\n if mx<s/(w+s):\n ans=w+s,s\n mx=s/(w+s)\n\nprint(ans[0],ans[1])", "a, b, c, d, e, f = map(int, input().split())\n\nwater = [False] * (f//100 + 1)\nfor i in range(0, len(water), a):\n water[i] = True\nfor i in range(len(water) - b):\n if water[i]:\n water[i + b] = True\n\nsugar = [False] * ((f//100) * e + 1)\nfor i in range(0, len(sugar), c):\n sugar[i] = True\nfor i in range(len(sugar) - d):\n if sugar[i]:\n sugar[i + d] = True\n\n# denominator: \u5206\u6bcd, numerator: \u5206\u5b50\ndeno = a * 100\nnume = 0\n\nfor i in range(1, len(water)):\n if water[i]:\n j = min([i*e, f - 100*i])\n while not sugar[j]:\n j -= 1\n i = 100 * i + j\n\n if nume * i < deno * j:\n deno = i\n nume = j\n\nprint(deno, nume)", "a, b, c, d, e, f = map(int, input().split())\nW = set(); S = set()\nsa = 0; wsa = a * 100\nfor i in range(0, f + a * 100, a * 100):\n for j in range(0, f + b * 100, b * 100):\n w = i + j\n if w <= f:\n W.add(w)\n else:\n break\nfor i in range(0, f // 2 + c, c):\n for j in range(0, f // 2 + d, d):\n s = i + j\n if s <= f // 2:\n S.add(s)\n else:\n break\nS.remove(0)\nfor i in W:\n for j in S:\n if e / (100 + e) >= j / (i + j) > sa / wsa and i + j <= f:\n sa, wsa = j, i + j\nprint(wsa, sa)", "import bisect, heapq\n\na, b, c, d, e, f = map(int, input().split())\n\nw = set()\ntemp = [a * i for i in range((30 - 1) // a + 2)]\nfor i in temp:\n while i not in w and i <= 30:\n w.add(i)\n i += b\nw = list(w)\nw.remove(0)\nw.sort()\n\ns = set()\ntemp = [c * i for i in range((3000 - 1) // c + 2)]\nfor i in temp:\n while i not in s and i <= 3000:\n s.add(i)\n i += d\ns = list(s)\ns.sort()\n\nqueue = []\nheapq.heapify(queue)\nfor i in w:\n if i * 100 > f:\n continue\n num = bisect.bisect(s, i * e)\n for j in range(num - 1, -1, -1):\n if i * 100 + s[j] > f:\n continue\n heapq.heappush(queue, [-s[j] / i, 100 * i + s[j], s[j]])\n break\nprint(queue[0][1], queue[0][2])", "a, b, c, d, e, f = map(int, input().split())\n\nans = -1\nans_water = -1\nans_sugar = -1\nfor ia in range(f//(a*100)+2):\n water = 100*a*ia\n if water > f or water == 0: continue\n for ib in range(f//(b*100)+2):\n if ib != 0: water += 100*b\n if water > f or water == 0: continue\n for ic in range(f//c+1):\n sugar = c*ic\n if sugar/(water//100) > e: continue\n for id in range(f//d+1):\n if id != 0: sugar+=d\n if sugar/(water//100) > e: continue\n if sugar + water > f: continue\n if (100*sugar)/(sugar+water) > ans:\n ans = (100*sugar)/(sugar+water)\n ans_water = water\n ans_sugar = sugar\nprint(ans_sugar+ans_water, ans_sugar)", "a,b,c,d,e,f=map(int,input().split())\nans=[-1]*9999\nans[a*100]=0\nans[b*100]=0\nfin=[a*100,0]\np=0\nfor i in range(1,f+1):\n if ans[i]==-1:\n continue\n if (ans[i]+c)/(i-ans[i])<=e*0.01:\n ans[i+c]=max(ans[i]+c,ans[i+c])\n if (ans[i]+d)/(i-ans[i])<=e*0.01:\n ans[i+d]=max(ans[i]+d,ans[i+d])\n ans[i+a*100]=max(ans[i+a*100],ans[i])\n ans[i+b*100]=max(ans[i+b*100],ans[i])\n if ans[i]/i>p:\n p=ans[i]/i\n fin=[i,ans[i]]\nprint(*fin)", "a,b,c,d,e,f = map(int,input().split())\nans = [-1]*10000\n# ans[0] = 0\nans[a*100] = 0\nans[b*100] = 0\nq1 = a*100\nq2 = b*100\np = 0\nfin = [a*100,0]\nfor i in range(1,f+1):\n if ans[i] == -1:\n continue\n if (ans[i]+c)/(i-ans[i]) <= e*0.01:\n ans[i+c] = max(ans[i]+c,ans[i+c])\n if (ans[i]+d)/(i-ans[i]) <= e*0.01:\n ans[i+d] = max(ans[i]+d,ans[i+d])\n ans[i+a*100] = max(ans[i+a*100],ans[i])\n ans[i+b*100] = max(ans[i+b*100],ans[i])\n if i != 0:\n if ans[i]/i > p:\n # print(p,i)\n p = ans[i]/i\n fin = [i,ans[i]]\n# print(ans[190:210])\nprint(*fin)", "A,B,C,D,E,F = (int(T) for T in input().split())\nSugM = 0\nWatM = 100*A\nfor TC in range(0,F+1):\n for TD in range(0,F+1):\n Suger = C*TC+D*TD\n RestS = F-Suger\n if RestS>=0:\n for TA in range(0,(RestS//100)+1):\n for TB in range(0,(RestS//100)+1):\n if TA==TB==0:\n continue\n else:\n Water = TA*A*100+TB*B*100\n RestW = RestS-Water\n if RestW>=0 and Water>=(100*Suger)/E:\n if SugM/(WatM+SugM)<Suger/(Water+Suger):\n SugM = Suger\n WatM = Water\n else:\n break\n else:\n break\nprint('{} {}'.format(WatM+SugM,SugM))", "a,b,c,d,e,f=map(int,input().split())\n\nmax_s=0\nmax_w=a\nmax_conc=0\n\nwater_s=set()\nsugar_s=set()\nfor i in range(f//a//100+1):\n aa=a*i\n for j in range(f//b//100+1):\n bb=b*j\n if aa+bb <= f//100:\n water_s.add(aa+bb)\n \nfor i in range(f//c+1):\n cc=c*i\n for j in range(f//d+1):\n dd=d*j\n if cc+dd <= f:\n sugar_s.add(cc+dd)\n\nfor w in water_s:\n for sg in sugar_s:\n if w*100+sg <= f and w*e >= sg and w+sg > 0:\n conc=(100*sg)/(100*w+sg)\n if max_conc < conc:\n max_conc=conc\n max_w=w\n max_s=sg\nprint(max_w*100+max_s,max_s)", "a,b,c,d,e,f=map(int,input().split())\ng=[-1]*9999\ng[a*100]=0\ng[b*100]=0\nh=[a*100,0]\np=0\nfor i in range(1,f+1):\n if g[i]==-1:\n continue\n if (g[i]+c)/(i-g[i])<=e*0.01:\n g[i+c]=max(g[i]+c,g[i+c])\n if (g[i]+d)/(i-g[i])<=e*0.01:\n g[i+d]=max(g[i]+d,g[i+d])\n g[i+a*100]=max(g[i+a*100],g[i])\n g[i+b*100]=max(g[i+b*100],g[i])\n if g[i]/i>p:\n p=g[i]/i\n h=[i,g[i]]\nprint(*h)", "import sys\n\nsys.setrecursionlimit(10 ** 7)\ninput = sys.stdin.readline\nf_inf = float('inf')\nmod = 10 ** 9 + 7\n\n\ndef resolve():\n A, B, C, D, E, F = list(map(int, input().split()))\n\n water = set()\n for a in range(F // (A * 100) + 1):\n for b in range(F // (B * 100) + 1):\n if 0 < a * 100 * A + b * 100 * B <= F:\n water.add(a * 100 * A + b * 100 * B)\n\n kouho = []\n for w in water:\n ma = (E * w) // 100\n for c in range(ma // C + 1):\n for d in range(ma // D + 1):\n sugar = c * C + d * D\n if 0 < sugar <= ma and w + sugar <= F:\n kouho.append([w, sugar])\n\n if len(kouho) == 0:\n print((list(water)[0], 0))\n return\n\n max_noudo = 0\n res = []\n for w, sugar in kouho:\n noudo = sugar / (w + sugar)\n if max_noudo < noudo:\n max_noudo = noudo\n res = [w + sugar, sugar]\n print((*res))\n\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "a , b , c , d , e , f = map(int,input().split())\nmidp = [-1 for i in range(f+1)]\nmizu = []\nmidp[0] = 0\nfor i in range(f+1):\n if midp[i] != -1:\n if i + a*100 <= f and midp[i+a*100] != 0:\n midp[i+a*100] = 0\n mizu.append(i+a*100)\n if i + b*100 <= f and midp[i+b*100] != 0:\n midp[i+b*100] = 0\n mizu.append(i+b*100)\nans = 0\ncou = [a*100,0]\nfor i in mizu:\n sai = i*e//100\n sadp = [-1 for f in range(sai+1)]\n sadp[0] = 0\n maxsa = 0\n for j in range(sai+1):\n if sadp[j] != -1:\n if j + c <= sai and i + j + c <= f and sadp[j+c] != 0:\n sadp[j+c] = 0\n maxsa = max(maxsa,j+c)\n if j + d <= sai and i + j + d <= f and sadp[j+d] != 0:\n sadp[j+d] = 0\n maxsa = max(maxsa,j+d)\n if ans < maxsa/(i+maxsa):\n ans = maxsa/(i+maxsa)\n cou = [i+maxsa,maxsa]\n\nprint(*cou)", "A,B,C,D,E,F = map(int,input().split())\n\nws = set()\nfor a in range(0,F+1,100*A):\n for b in range(0,F+1,100*B):\n if a+b > F: break\n ws.add(a+b)\nws.remove(0)\n\nss = set()\nfor c in range(0,F+1,C):\n for d in range(0,F+1,D):\n if c+d > F: break\n ss.add(c+d)\n\nbest_s = -1\nbest_w = 1\nfor w in ws:\n for s in ss:\n if w+s > F: continue\n if E*w < s*100: continue\n if best_s * (s+w) < s * (best_s + best_w):\n best_s = s\n best_w = w\nprint(best_s+best_w, best_s)", "a, b, c, d, e, f = map(int, input().split())\nW = set(); S = set()\nsa = 0; wsa = a * 100\n\nfor i in range(0, f + a * 100, a * 100):\n for j in range(0, f + b * 100, b * 100):\n w = i + j\n if w <= f:\n W.add(w)\n else:\n break\nfor i in range(0, f // 2 + c, c):\n for j in range(0, f // 2 + d, d):\n s = i + j\n if s <= f // 2:\n S.add(s)\n else:\n break\nS.remove(0)\nfor i in W:\n for j in S:\n if e / (100 + e) >= j / (i + j) > sa / wsa and i + j <= f:\n sa, wsa = j, i + j\nprint(wsa, sa)", "a,b,c,d,e,f=map(int,input().split())\na=100*a\nb=100*b\ndp1=[0]*(f+1)\ndp2=[0]*(f+1)\nfor i in range(f+1):\n if i%a==0:\n if i+a<=f:\n dp1[i+a]=1\nfor i in range(f+1):\n if i==0 or dp1[i]==1:\n if i+b<=f:\n dp1[i+b]=1\nfor i in range(f+1):\n if i%c==0:\n if i+c<=f:\n dp2[i+c]=1\nfor i in range(f+1):\n if i==0 or dp2[i]==1:\n if i+d<=f:\n dp2[i+d]=1\n\nans=[-1,-1,-1]\nfor i in range(f+1):\n if dp1[i]==1:\n x=min(f-i,(i//100)*e)\n k=-1\n for j in range(x,-1,-1):\n if dp2[j]==1 or j==0:\n k=j\n if ans[0]<100*k/(i+k):\n ans=[100*k/(i+k),i+k,k]\n break\nprint(str(ans[1])+\" \"+str(ans[2]))", "import sys\n\ninput = sys.stdin.readline\n\n\ndef main():\n A, B, C, D, E, F = list(map(int, input().split()))\n\n max_concentration = 0\n ans = (100 * A, 0)\n for a in range(0, F + 1, 100 * A):\n for b in range(0, F - a + 1, 100 * B):\n water = a + b\n if water == 0:\n break\n for c in range(0, F - water + 1, C):\n for d in range(0, F - water - c + 1, D):\n sugar = c + d\n if sugar > (water // 100) * E:\n break\n concentration = (100 * sugar) / (water + sugar)\n if concentration > max_concentration:\n max_concentration = concentration\n ans = (water + sugar, sugar)\n\n print((\" \".join(map(str, ans))))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "A,B,C,D,E,F=map(int,input().split(' '))\nwater = set()\nfor a in range(0,F,100*A):\n for b in range(0,F,100*B):\n if a+b <= F:\n water.add(a+b)\n else:\n break\nsugars = set()\nfor c in range(0,F,C):\n for d in range(0,F,D):\n if c+d <= F:\n sugars.add(c+d)\n else:\n break\ndensity = 0\nsugar = 0\ncontent = 100*A\nfor x in water:\n for y in sugars:\n if x+y != 0 and x+y <= F and E*x >= 100*y and density < y/(x+y):\n density = y/(x+y)\n sugar = y\n content = x+y\nprint(content,sugar)", "def main():\n\tA, B, C, D, E, F = map(int, input().split())\n\twater = set()\n\tsugar = set()\n\n\tfor i in range(F // (100 * A) + 1):\n\t\tfor j in range(F // (100 * B) + 1):\n\t\t\twater_amount = 100 * A * i + 100 * B * j\n\t\t\tif 0 < water_amount and water_amount <= F:\n\t\t\t\twater.add(water_amount)\n\n\tfor i in range(F // C + 1):\n\t\tfor j in range(F // D + 1):\n\t\t\tsugar_amount = C * i + D * j\n\t\t\tif sugar_amount <= F:\n\t\t\t\tsugar.add(sugar_amount)\n\n\t# print(water)\n\t# print(sugar)\n\n\tmax_c = -1\n\tmax_w = 0\n\tmax_s = 0\n\n\tfor w in water:\n\t\tfor s in sugar:\n\t\t\tif w + s <= F:\n\t\t\t\tif s / w <= E / 100:\n\t\t\t\t\tif s * 100 / (w + s) > max_c:\n\t\t\t\t\t\tmax_c = s * 100 / (w + s)\n\t\t\t\t\t\tmax_w = w\n\t\t\t\t\t\tmax_s = s\n\n\tprint(max_w + max_s, max_s)\n\n \ndef __starting_point():\n \tmain()\n__starting_point()"]
{"inputs": ["1 2 10 20 15 200\n", "1 2 1 2 100 1000\n", "17 19 22 26 55 2802\n"], "outputs": ["110 10\n", "200 100\n", "2634 934\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
14,671
e2426f7fffbce24f02838e2aa6b387c9
UNKNOWN
The word internationalization is sometimes abbreviated to i18n. This comes from the fact that there are 18 letters between the first i and the last n. You are given a string s of length at least 3 consisting of lowercase English letters. Abbreviate s in the same way. -----Constraints----- - 3 ≀ |s| ≀ 100 (|s| denotes the length of s.) - s consists of lowercase English letters. -----Input----- Input is given from Standard Input in the following format: s -----Output----- Print the abbreviation of s. -----Sample Input----- internationalization -----Sample Output----- i18n
["a = input()\nprint(f\"{a[0]}{len(a[1:-1])}{a[-1]}\")", "s = input()\nans = s[0] + str(len(s)-2) + s[-1]\nprint(ans)", "s = input()\nprint(s[0] + str(len(s)-2) + s[-1])", "s = input()\nprint((s[0]+str(len(s)-2)+s[len(s)-1]))\n", "import sys\n\n\ndef main():\n s = input()\n N = len(s)\n ans = s[0] + str(N - 2) + s[-1]\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = list(input())\na = ''\nb = s.pop(0)\nc = s.pop()\na += b\na += str(len(s))\na += c\nprint(a)", "s = input()\ns1, s2, s3 = s[0], s[1:-1], s[-1]\n\nans = s1 + str(len(s2)) + s3\nprint(ans)", "s = [i for i in input()]\nprint(s[0] + str(len(s) - 2) + s[-1])", "s=input()\nt=len(s)\nans=s[0]+str(t-2)+s[-1]\nprint(ans)", "n = input()\nn = list(n)\na = n.pop(0)\nb = n.pop()\nc = len(n)\nprint(a+str(c)+b)", "s = input()\n\nprint(s[0]+str(len(s)-2)+s[len(s)-1])", "S = input()\nMid = len(S)-2\nprint(S[0]+str(Mid)+S[-1])", "string = input()\nprint((string[0] + str(len(string) - 2) + string[-1]))\n", "s = input()\nprint(s[0]+str(len(s[1:-1]))+s[-1])", "s = str(input())\nans = s[0] + str(len(s)-2) + s[-1]\nprint(ans)", "#!/usr/bin/env python3\n\n\ndef main():\n s = input()\n print((s[0] + str(len(s) - 2) + s[-1]))\n\n\nmain()\n", "s = input()\nprint(s[0] + str(len(s)-2) + s[-1])", "S = input()\nprint((S[0]+str(len(S)-2)+S[-1]))\n", "S = input()\n\nprint(S[0]+str(len(S)-2)+S[-1])", "s = input()\n\nprint(s[0], len(s) - 2, s[-1], sep='')", "s = str(input())\nprint(s[0] + str(len(s) - 2) + s[-1])", "S = input()\nprint(S[0]+str(len(S)-2)+S[-1])", "s=input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s = input()\nn = len(s)-2\nprint((s[0]+str(n)+s[-1]))\n", "def answer(s: str) -> str:\n return f'{s[0]}{len(s) - 2}{s[-1]}'\n\ndef main():\n s = input()\n print(answer(s))\n\ndef __starting_point():\n main()\n__starting_point()", "s=input()\nprint((s[0]+str(len(s)-2)+s[len(s)-1]))\n", "s = input()\nres = s[0] + str(len(s) - 2) + s[-1]\nprint(res)\n", "s = input()\nprint(f\"{s[0]}{len(s)-2}{s[-1]}\")", "s=str(input())\nn=str(len(s)-2)\np=s[0]+n+s[len(s)-1]\nprint(p)", "s = input()\nl = len(s)\nprint((s[0] + str(l-2) + s[-1]))\n", "s=input()\n\nprint(s[0]+str(len(s)-2)+s[-1])", "#!/usr/bin/env python3\n\ndef main():\n s = input()\n print((s[0]+str(len(s)-2)+s[-1]))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "#ABC069\ns = input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s = input()\nprint(s[0] + str(len(s[1:-1])) + s[-1])", "a = list(input())\n\nprint(a[0] + str(len(a) - 2) + a[len(a) - 1])", "s = input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s=input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s = input()\nn = str(len(s)-2)\nprint((s[0]+n+s[-1]))\n", "# -*- coding: utf-8 -*-\n\nS = input()\n\na = len(S)\n\nprint((S[0]+str(a-2)+S[-1]))\n", "s = str(input())\nprint(s[0] + str(len(s) - 2) + s[-1])", "S=input()\nprint((S[0]+str(len(S)-2)+S[-1]))\n", "s = input()\ns_len = len(s)\nhead, tail = s[0], s[s_len - 1]\nprint((head + str(s_len - 2) + tail))\n", "s=input()\na=len(s)-2\nprint(s[0]+str(a)+s[len(s)-1])", "s = list(input())\nprint(s[0], len(s)-2, s[len(s)-1], sep='')\n", "s = input()\n\n\nprint(s[0] + str(len(s)-2) + s[len(s) -1])", "s=input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s = input()\nsize = len(s)\nprint((s[0] + str(size - 2) + s[size - 1]))\n", "s = input()\n\nl = len(s) - 2\n\nprint(s[0] + str(l) + s[-1])", "a,*b,c = input()\nprint(a,len(b),c,sep=\"\")\n", "s=input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s=input()\nprint(f\"{s[0]}{len(s)-2}{s[-1]}\")", "s = input()\nprint(s[0]+str(len(s)-2)+s[len(s)-1])", "s = input()\ns_c = len(s)-2\nprint(\uff53[0] + str(s_c) +s[-1])", "s=list(input())\ny=str(len(s)-2)\nprint(s[0]+y+s[-1])", "S = input()\nprefix = S[0]\nsufix = S[-1]\ncontent = str(len(S[1:-1]))\nprint(prefix + content + sufix)", "s=input()\n\nprint(s[0]+str(len(s)-2)+s[-1])", "s = input()\nprint(s[0] + str(len(s) - 2) + s[-1])", "S = input()\nprint((S[0] + str(len(S) - 2) + S[-1]))\n", "s = input()\nprint(f'{s[0]}{len(s[1:-1])}{s[-1]}')", "# ABC069\ns = input()\n\nprint((s[0] + str(len(s[0:-2])) + s[-1]))\n", "s = input()\nprint(s[0] + str(len(s)-2) + s[-1])", "s = input()\nprint(s[0] + str(len(s) - 2) + s[-1])", "s = input()\nprint(s[0] + str(len(s) - 2) + s[-1])", "S = str(input())\n\ns_between_len = len(S) - 2\n\na = S[:1] + str(s_between_len) + S[-1]\nprint(a)", "a=input()\nprint(f\"{a[0]}{len(a)-2}{a[len(a)-1]}\")", "s = input()\nt = str(len(s) - 2)\nprint(s[0] + t + s[-1])", "s = input()\nprint(s[0] + str(len(s) - 2) + s[-1])", "s = input()\n\nprint(s[0]+ str(len(s) - 2) + s[-1])", "s = input()\n\nl = s[0] + str(len(s)-2) + s[-1]\n\nprint(l)", "s=input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s = input()\ns = s[0] + str(len(s) - 2) + s[-1]\nprint(s)\n", "s=input()\n\nnew_s=s[0]+str(len(s[1:-1]))+s[-1]\nprint(new_s)", "s = str(input())\n\nprint((s[0] + str(len(s) - 2) + s[-1]))\n", "s=input()\nlen_a=str(len(s)-2)\nprint((s[0]+len_a+s[-1]))\n", "s = input()\nl = len(s)\nprint(f'{s[0]}{l-2}{s[l-1]}')", "a = input()\nprint(a[0] + str(len(a) - 2) + a[-1])", "s = input()\nprint(s[0] +str(len(s[1:-1]))+ s[-1])", "S = input()\nans = S[0] + str(len(S) - 2) + S[-1]\nprint(ans)", "s=input()\nN=len(s)\nprint(s[0]+str(N-2)+s[N-1])", "s = input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s = input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s = input()\nn = len(s[1:-1])\nprint(s[0]+str(n)+s[-1])", "s = input()\nprint(s[0] + str(len(s)-2) + s[-1])", "s = str(input())\nans = s[0] + str(len(s)-2) + s[-1]\nprint(ans)", "s = input()\n\nprint(s[0] + str(len(s)-2) + s[-1])", "s=input()\nprint(s[0]+str(len(s)-2)+s[len(s)-1])", "s=input()\nS=s[0]+str(len(s)-2)+s[-1]\nprint(S)", "s=input()\nprint(s[0]+str(len(s)-2)+s[-1])", "s = input()\nprint(s[0]+str(len(s)-2)+s[-1])", "def main():\n s = input()\n print(f'{s[0]}{len(s) - 2}{s[-1]}')\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\nprint((s[0] + str(len(s)-2) + s[-1]))\n", "s = input()\nprint('{}{}{}'.format(s[0],len(s)-2,s[-1]))", "s = input()\nprint((s[0]+str(len(s)-2)+s[-1]))\n", "s = input()\nprint(s[0] + str(len(s) - 2) + s[-1])", "s = input()\nn = str(len(s)-2)\nprint(s[0]+n+s[-1])", "# -*- coding: utf-8 -*-\n\ns = list(input())\n\nnum = len(s)\noutput = s[0] + str(num-2) + s[num-1]\n\nprint(output)", "# \u6587\u5b57\u5217\u306e\u5165\u529b\ns = input()\nprint(s[0]+str(len(s[1:-1]))+s[-1])", "s = input()\nprint(\"{}{}{}\".format(s[0], len(s)-2, s[-1]))", "a=input()\nprint(a[0]+str(int(len(a)-2))+a[-1])", "s = input()\nprint(s[0] + str(len(s) - 2) + s[-1])"]
{"inputs": ["internationalization\n", "smiles\n", "xyz\n"], "outputs": ["i18n\n", "s4s\n", "x1z\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
6,556
ea2b894a7251a3972d1d7bcef3087a82
UNKNOWN
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}. Write a program that prints YES if this grid remains the same when rotated 180 degrees, and prints NO otherwise. -----Constraints----- - C_{i,j}(1 \leq i \leq 2, 1 \leq j \leq 3) is a lowercase English letter. -----Input----- Input is given from Standard Input in the following format: C_{11}C_{12}C_{13} C_{21}C_{22}C_{23} -----Output----- Print YES if this grid remains the same when rotated 180 degrees; print NO otherwise. -----Sample Input----- pot top -----Sample Output----- YES This grid remains the same when rotated 180 degrees.
["a = input()\nb = input()\n\nif a[:: -1] == b:\n print(\"YES\")\nelse:\n print(\"NO\")", "P = input()\nQ = input()\n\nif P[::-1] == Q:\n print(\"YES\")\nelse:\n print(\"NO\")", "a = input()\nb = input()\n\nif a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:\n print('YES')\nelse:\n print('NO')\n", "c1 = input()\nc2 = input()\nif c1[0] == c2[2] and c1[1] == c2[1] and c1[2] == c2[0]:\n print('YES')\nelse:\n print('NO')", "a,b=[input() for i in range(2)]\nc=a[::-1];d=b[::-1]\n\nif a==d and b==c:\n print('YES')\n \nelse:\n print('NO')", "# 077_a\nC1=input()\nC2=input()\n# (1<=i and i<=2) and (1<=j and j<=3):\n\nif C1==(C2[2]+C2[1]+C2[0])and C2==(C1[2]+C1[1]+C1[0]):\n print('YES')\nelse:\n print('NO')", "a = input()\nb = input()\nif a == b[::-1]:\n print('YES')\nelse:\n print('NO')\n", "a = input()\nb = input()\nif a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:\n print('YES')\nelse:\n print('NO')", "i = input()\nj = input()\n\nif i[0] == j[2] and i[1] == j[1] and i[2] == j[0]:\n print('YES')\nelse:\n print('NO')", "a=input()\nprint(\"YES\") if input()==a[::-1] else print(\"NO\")", "if input() == input()[::-1]:\n print('YES')\nelse:\n print('NO')", "a = list(map(str, input()))\nb = list(map(str, input()))\n\nif a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:\n print('YES')\nelse:\n print('NO')", "# coding = SJIS\n\na = str(input())\nb = str(input())\n\nif a[0] == b[2]:\n if a[1] == b[1]:\n if a[2] == b[0]:\n print(\"YES\")\n return\n else:\n print(\"NO\")\n return\n else:\n print(\"NO\")\n return\nelse:\n print(\"NO\")\n return", "A = list(input())\nB = list(input())\nif A[0] == B[2] and A[1] == B[1] and A[2] == B[0]:\n print('YES')\nelse:\n print('NO')", "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nc1 = list(str(input()))\nc2 = list(reversed(str(input())))\n\nif c1 == c2:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "s=input()\nt=input()\nt=t[::-1]\nif s==t:\n print(\"YES\")\nelse:\n print(\"NO\")", "first = input()\nsecond = input()\n\nif first[0] == second[2] and first[1] == second[1] and first[2] == second[0]:\n print('YES')\nelse:\n print('NO')", "a = input()\nb = input()\nif a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:\n print('YES')\nelse:\n print('NO')", "a=input()\nb=input()\nif a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "def main():\n c1 = input()\n c2 = input()\n\n if all((c1[0] == c2[2], c1[2] == c2[0], c1[1] == c2[1])):\n print(\"YES\")\n else:\n print(\"NO\")\n\n\nmain()", "a = input()\nb = input()\n\nif a == b[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "x = str(input())\ny = str(input())\n\nconditions = x[0] == y[2] and x[1] == y[1] and x[2] == y[0]\nif conditions:\n print(\"YES\")\nelse:\n print(\"NO\")", "s=input()\nt=input()\nprint(\"YES\" if s==t[::-1] else \"NO\")", "s = str(input())\nt = str(input())\n\nif s[0] == t[2] and s[1] == t[1] and s[2] == t[0]:\n result = \"YES\"\nelse:\n result = \"NO\"\n\nprint(result)\n", "data1 = input()\ndata2 = input()\n\ncount = 3 -1\nsw = 0\ni = 0\nj = len(data2)-1\nwhile i <= count:\n if data1[i] == data2[j]:\n sw += 1\n i += 1\n j -= 1\nif sw == 3:\n print(\"YES\")\nelse:\n print(\"NO\")", "n = str(input())\ns = str(input())\nif n[0]== s[2]and n[1]==s[1] and n[2]== s[0]:\n print('YES')\nelse:\n print('NO')\n", "C=input()+input()\nprint(\"YNEOS\"[1 in[1 for i in range(3)if C[i]!=C[-i-1]]::2])", "a = list(input())\nb = list(input())\n\nif a[0] == b[2] and b[0] == a[2] and a[1]==b[1]:\n print('YES')\nelse:\n print('NO')\n", "C1 = str(input())\nC2 = str(input())\n\nif C1[0] == C2[-1] and C1[1] == C2[-2] and C1[2] == C2[-3]:\n print('YES')\nelse:\n print('NO')", "x = input()\ny = input()\nif x[::-1] == y:\n\tprint('YES')\nelse:\n\tprint('NO')", "c=[list(input()) for i in range(2)]\nif c[0][0]==c[1][2] and c[0][1]==c[1][1] and c[0][2]==c[1][0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "s=input()\nt=input()\na=0\nfor i in range(3):\n if s[i]!=t[-i-1]:\n a=1\nprint('YES' if a==0 else 'NO')", "a = list(input())\nb = list(input())\na = a[::-1]\nif a == b:\n print('YES')\nelse:\n print('NO')", "x = list(input())\ny = list(input())\n\nif x[0] == y[2] and x[1] == y[1] and x[2] == y[0]:\n print('YES')\nelse:\n print('NO')", "C123=list(input())\nC456=list(reversed(input()))\n\nif C123 == (C456):\n print('YES')\nelse:\n print('NO')", "# A - Rotation\nline1 = input()\nline2 = input()\nmy_list1 = []\nmy_list2 = []\n \nfor i in line1:\n my_list1.append(i)\n \nfor i in line2:\n my_list2.append(i)\n \nmy_list2.reverse()\n \nif my_list1 == my_list2:\n print('YES')\nelse:\n print('NO')\n \n# print(my_list1, my_list2)\n", "a=input()\nb=input()\nif [a[2],a[1],a[0]]==[b[0],b[1],b[2]]:\n print(\"YES\")\nelse:\n print(\"NO\")", "a = input()\nb = input()\n\nif a==b[::-1] and b ==a[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "C1 = str(input())\nC2 = str(input())\n\nif C1[0] == C2[-1] and C1[1] == C2[-2] and C1[2] == C2[-3]:\n print(\"YES\")\nelse:\n print(\"NO\")", "c1 = str(input())\nc2 = str(input())\n\nif c2 == c1[::-1] and c1 == c2[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "\nc1=input()\nc2=input()\n\nif c1[0]+c1[1]+c1[2] == c2[2]+c2[1]+c2[0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "c = [\"\"] * 2\nc[0] = input()\nc[1] = input()\ns = True\nfor i in range(2):\n for j in range(3):\n if c[i][j] != c[-i-1][-j-1]: s = False\nif s: print('YES')\nelse: print('NO')", "s = list(input())\nt = list(input())\n\nif s == t[::-1]:\n print('YES')\nelse:\n print('NO')", "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\nC1 = S()\nC2 = S()\n\nif C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "# 077a\n\ndef atc_077a(input_value: str) -> str:\n C1 = input_value[0]\n C2 = input_value[1]\n\n if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:\n return \"YES\"\n else:\n return \"NO\"\n\n\nC1 = input()\nC2 = input()\nprint((atc_077a([C1, C2])))\n", "c = [list(input()) for i in range(2)]\n\nif c[0][0] == c[1][2] and c[0][1] == c[1][1] and c[0][2] == c[1][0]:\n print('YES')\nelse:\n print('NO')", "C1 = input()\nC2 = input()\nif C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:\n print('YES')\nelse:\n print('NO')\n", "a = input()\nb = input()\n\nif a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "a=input()\nb=input()\nif a[1]==b[1] and a[0]==b[2] and a[2]==b[0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "S1,S2=[input() for _ in range(2)]\nprint(\"YES\") if S1[2]==S2[0] and S1[1]==S2[1] and S1[0]==S2[2] else print(\"NO\")", "a = input()\nb = input()\nif a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:\n print('YES')\nelse:\n print('NO')", "line1=input()\nline2=input()\n\nif line1[0]==line2[2] and line1[1]==line2[1] and line1[2]==line2[0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "c1 = input()\nc2 = input()\n\nprint(\"YES\" if c1 == c2[::-1] else \"NO\")", "S = input()[::-1]\nT = input()\nprint('YES' if S == T else 'NO')", "a = input()\nb = input()\nif a[::-1] == b:\n print('YES')\nelse:\n print('NO')", "c1 = input()\nc2 = input()\n\nif c1 == c2[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "# \u6587\u5b57\u5217\u3092\u53d6\u5f97\nC1 = str(input())\nC2 = str(input())\n\n# \u6587\u5b57\u5217\u306e\u7d50\u5408\nori_str = C1 + C2\n\n# \u672b\u5c3e\u304b\u3089\uff11\u6587\u5b57\u305a\u3064\u53d6\u5f97\u3057\u3066\u9006\u3055\u307e\u6587\u5b57\u3092\u751f\u6210\nrev_str = ori_str[-1::-1]\n\n# \u6bd4\u8f03\u7d50\u679c\u3092\u51fa\u529b\nif ori_str == rev_str:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "print(('NO', 'YES')[input() == input()[::-1]])", "# A - Rotation\n# https://atcoder.jp/contests/abc077/tasks/abc077_a\n\na = input()\nb = input()\n\nresult = 'YES'\ni = 0\nj = -1\nwhile i < len(a):\n if a[i] != b[j]:\n result = 'NO'\n break\n i += 1\n j -= 1\n\nprint(result)\n", "C1 = input()\nC2 = input()\n\nprint(\"YES\" if C1 == C2[::-1] else \"NO\")", "i = input()\nj = input()\nif i == j [::-1]:\n print('YES')\nelse:\n print('NO')", "a,b=input(),input()\nif a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:print('YES')\nelse:print('NO')", "# 2\u6bb5\u76ee\u306e\u6587\u5b57\u5217\u3092\u9006\u306b\u3057\u30661\u6bb5\u76ee\u306e\u6587\u5b57\u5217\u3068\u4e00\u81f4\u3059\u308c\u3070\u3044\u3044\nc = input('')\nd = input('')\n\nif c == d[::-1]:\n print('YES')\nelse:\n print('NO')", "A = input()\nB = input()\n\nprint(\"YES\" if A[0] == B[-1] and A[-1] == B[0] and A[1] == B[1] else \"NO\")", "a = input()\nb = input()\n\nc = a[2]+a[1]+a[0]\n\nif b == c:\n print('YES')\n \nelse:\n print('NO')", "a = input()\nb = input()\nif a==b[::-1]:\n print(\"YES\")\nelse:\n print(\"NO\")", "# \u30bd\u30fc\u30c8\u304b\u3051\u3066\u3069\u3061\u3089\u3082\u540c\u3058\u3060\u3068YES\n\nc1 = list(input())\nc2 = list(input())\n\n# print(c1)\n# print(c2)\n\nc1_str = ''.join(c1)\n# c2_str = ''.join(c2)\n\nc2_str_reverse = c2[2] + c2[1] + c2[0]\n\nif c1_str == c2_str_reverse:\n print('YES')\nelse:\n print('NO')\n", "C1 = input()\nC2 = input()\n\nprint(\"YES\" if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0] else \"NO\")", "#\n# abc077 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 = \"\"\"pot\ntop\"\"\"\n output = \"\"\"YES\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"tab\nbet\"\"\"\n output = \"\"\"NO\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"eye\neel\"\"\"\n output = \"\"\"NO\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n C1 = input()\n C2 = input()\n\n if C1[0] == C2[2] and C1[2] == C2[0] and C1[1] == C2[1]:\n print(\"YES\")\n else:\n print(\"NO\")\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "a = input()\nb = input()\n# \u6700\u521d\u306e\u6587\u5b57\u3068\u6700\u5f8c\u306e\u6587\u5b57\u3092\u5165\u308c\u66ff\u3048\u3066\u3082\u540c\u3058\u306b\u306a\u308c\u3070YES\nif a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "c=[list(input())for i in range(2)]\nif c[0][0]==c[1][2] and c[0][1]==c[1][1] and c[0][2]==c[1][0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "'''\n\u554f\u984c\uff1a\n \u7e26 2 \u30de\u30b9\u3001\u6a2a 3 \u30de\u30b9\u306e\u30de\u30b9\u76ee\u304c\u4e0e\u3048\u3089\u308c\u307e\u3059\u3002\n \u4e0a\u304b\u3089 i \u884c\u76ee\u3001\u5de6\u304b\u3089 j \u884c\u76ee\u306e\u30de\u30b9\u306e\u8272\u306f\u3001Cij \u3067\u8868\u3055\u308c\u307e\u3059\u3002\n\n \u3053\u306e\u30de\u30b9\u76ee\u3092 180 \u5ea6\u56de\u8ee2\u3055\u305b\u305f\u3068\u304d\u3001\n \u5143\u306e\u30de\u30b9\u76ee\u3068\u4e00\u81f4\u3059\u308b\u306a\u3089 YES \u3092\u3001\u305d\u3046\u3067\u306a\u3044\u306a\u3089 NO \u3092\u51fa\u529b\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u3066\u304f\u3060\u3055\u3044\u3002\n'''\n\n'''\n\u5236\u7d04\uff1a\n Cij\uff081 \u2266 i \u2266 2\u3001 1 \u2266 j \u2266 3\uff09\u306f\u82f1\u5c0f\u6587\u5b57\u3067\u3042\u308b\u3002\n'''\n\n# \u6a19\u6e96\u5165\u529b\u304b\u3089 Cij\u3001Cji \u3092\u53d6\u5f97\u3059\u308b\ncij = str(input())\ncji = str(input())\n\nreverse_cij = cij[2] + cij[1] + cij[0] # cij \u3092180\u5ea6\u56de\u8ee2\u3055\u305b\u305f\u6587\u5b57\u5217\n\nresult = \"\"\nif cji == reverse_cij:\n result = \"YES\"\nelse:\n result = \"NO\"\n\nprint(result)\n", "#\u5165\u529b\u4f8b\u306f\u5408\u3046\u304cWA\u306b\u306a\u308b\n\nA = input()\nB = input()\n\n\nif A[0]==B[2] and A[1]==B[1] and A[2]==B[0]:\n print(\"YES\")\nelse:\n print(\"NO\")\n\n#YES\u3068NO\u306b\u3057\u306a\u3044\u3068\u3044\u3051\u306a\u3044\u3068\u3053\u308d\u3092Yes\u3001No\u306b\u306a\u3063\u3066\u3044\u305f\n", "c1 = input()\nc2 = input()\n\n# \u30de\u30b9\u76ee\u3092 180\u5ea6\u56de\u8ee2 \u3055\u305b\u305f\u3068\u304d\u3001\u5143\u306e\u30de\u30b9\u76ee\u3068\u4e00\u81f4\u3059\u308b\u306a\u3089 YES \u3092\u3001\u305d\u3046\u3067\u306a\u3044\u306a\u3089 NO \u3092\u51fa\u529b\u305b\u3088\u3002\n\nif [c1[0], c1[1], c1[2]] == [c2[2], c2[1], c2[0]]:\n print(\"YES\")\nelse:\n print(\"NO\")", "li = list(input())\nli1 = list(input())\n\nif li[0] == li1[2] and li[1] == li1[1] and li[2] == li1[0]:\n print('YES')\nelse:\n print('NO')", "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\nC1=S()\nC2=S()\n\nif C1[0]==C2[2] and C1[1]==C2[1] and C1[2]==C2[0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "C1 = input()\nC2 = input()\n\nif C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:\n print('YES')\nelse:\n print('NO')", "Ci = input()\nCj = input()\n\nif Ci[0] == Cj[-1] and Ci[1] == Cj[-2] and Ci[2] == Cj[-3]:\n print('YES')\nelse:\n print('NO')", "s = str(input())\nt = str(input())\n\nif s[0] == t[2] and s[1] == t[1] and s[2] == t[0]:\n result = 'YES'\nelse:\n result = 'NO'\nprint(result)", "C=[list(input()) for _ in range(2)]\nflag=True\nfor i in range(2):\n for j in range(3):\n if C[i][j]!=C[1-i][2-j]:\n flag=False\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "C1 = input()\nC2 = input()\nif C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:\n print('YES')\nelse:\n print('NO')\n", "a = input()\nb = input()\nfor i in range(3):\n if a[i] != b[-(i+1)]:\n print(\"NO\")\n break\nelse:\n print(\"YES\")", "x = input()\ny = input()\n\nif x[0] == y[2] and x[1] == y[1] and x[2] == y[0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "#77\ndata1=list(input())\ndata2=list(input())\nif (data1[0]==data2[2] and data1[1]==data2[1] and data1[2]==data2[0]):\n print('YES')\nelse:\n print('NO')", "s1 = input()\ns2 = input()\n\nif s1 == s2[::-1]:\n print('YES')\nelse:\n print('NO')\n", "c1 = input()\nc2 = input()\nprint(\"YES\" if c1 == c2[::-1] else \"NO\")", "C1 = input()\nC2 = input()\n\nif C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:\n print(\"YES\")\nelse:\n print(\"NO\")", "c1 = input()\nc2 = input()\n\nif c1[0] == c2[-1] and c1[1] == c2[-2] and c1[2] == c2[-3]:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "import math\nb=input()\nc=[]\nfor i in range(len(b)):\n\tc.append(b[i])\n#a = list(map(int,input().split()))\n#b = list(map(int,input().split()))\n#s=int(input())\n\nf=input()\nt=[]\nfor i in range(len(f)):\n\tt.append(f[i])\nd=[]\nfor i in range(len(c)):\n\td.append(c[-(i+1)])\n\t\nif d==t:\n\tprint(\"YES\")\nelse:\n\tprint(\"NO\")", "a=input()\nb=input()\nif [a[2],a[1],a[0]]==[b[0],b[1],b[2]]:\n print(\"YES\")\nelse:\n print(\"NO\")", "\nC1 =str(input())\nC2 =str(input())\n\nif C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:\n print('YES')\n\nelse:\n print('NO')\n\n", "def iroha():\n lists = [input() for _ in range(2)]\n reversed_text = ''.join(list(reversed(lists[0])))\n print((\"YES\" if reversed_text == lists[1] else \"NO\"))\n\ndef __starting_point():\n iroha()\n\n\n__starting_point()", "c1, c2 = [input() for _ in range(2)]\n\n\ndef answer(c1: str, c2: str) -> str:\n if c1[0] == c2[2] and c1[2] == c2[0] and c1[1] == c2[1]:\n return 'YES'\n else:\n return 'NO'\n\nprint(answer(c1, c2))", "C1 = input()\nC2 = input()\nif C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:\n print('YES')\nelse:\n print('NO')\n", "with open(0) as f:\n C = ''.join(f.read().split())\nprint('YES' if C == C[::-1] else 'NO')", "word1, word2 = [input() for i in range(2)]\nif word1[0] == word2[2] and word1[1] == word2[1] and word1[2] == word2[0]:\n print('YES')\nelse:\n print('NO')", "C1, C2 = [input() for i in range(2)]\nprint('YES' if C1 == C2[::-1] else 'NO')", "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\nC1 = S()\nC2 = S()\n\nif C1[::-1] == C2:\n print(\"YES\")\nelse:\n print(\"NO\")\n", "def atc_077a(input_value: str) -> str:\n C1 = input_value[0]\n C2 = input_value[1]\n\n if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:\n return \"YES\"\n else:\n return \"NO\"\n\n\nC1 = input()\nC2 = input()\nprint(atc_077a([C1, C2]))", "s = input()\nt = input()\nprint(\"YES\" if s==t[::-1] and t==s[::-1] else \"NO\")"]
{"inputs": ["pot\ntop\n", "tab\nbet\n", "eye\neel\n"], "outputs": ["YES\n", "NO\n", "NO\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
18,103
796003695c573a1ca0f0e90fedf9e5d2
UNKNOWN
You are given a string s. Among the different substrings of s, print the K-th lexicographically smallest one. A substring of s is a string obtained by taking out a non-empty contiguous part in s. For example, if s = ababc, a, bab and ababc are substrings of s, while ac, z and an empty string are not. Also, we say that substrings are different when they are different as strings. Let X = x_{1}x_{2}...x_{n} and Y = y_{1}y_{2}...y_{m} be two distinct strings. X is lexicographically larger than Y if and only if Y is a prefix of X or x_{j} > y_{j} where j is the smallest integer such that x_{j} \neq y_{j}. -----Constraints----- - 1 ≀ |s| ≀ 5000 - s consists of lowercase English letters. - 1 ≀ K ≀ 5 - s has at least K different substrings. -----Partial Score----- - 200 points will be awarded as a partial score for passing the test set satisfying |s| ≀ 50. -----Input----- Input is given from Standard Input in the following format: s K -----Output----- Print the K-th lexicographically smallest substring of K. -----Sample Input----- aba 4 -----Sample Output----- b s has five substrings: a, b, ab, ba and aba. Among them, we should print the fourth smallest one, b. Note that we do not count a twice.
["import sys\nstdin=sys.stdin\n\nip=lambda: int(sp())\nfp=lambda: float(sp())\nlp=lambda:list(map(int,stdin.readline().split()))\nsp=lambda:stdin.readline().rstrip()\nyp=lambda:print('Yes')\nnp=lambda:print('No')\n\ns=list(sp())\nk=ip()\n\nans=set()\n\nalpa=list(set(s))\nalpa.sort()\nch=0\nsiyou=[]\nfor i in range(len(alpa)):\n if i<=2:\n siyou.append(alpa[i])\n else:\n break\n \nfor x in siyou:\n for i in range(len(s)):\n if s[i]==x:\n st=''\n for y in range(i,i+5):\n if y<len(s):\n st+=s[y]\n ans.add(st)\n if len(ans)>k:\n break\n \nans=list(ans)\nans.sort()\nprint(ans[k-1])\n \n\n\n", "s=input()\nK=int(input())\n\nif K==1:\n print(sorted(s)[0])\n return\n \ntopK = sorted(s)[:min(K,len(s))]\n\nindices=[]\nfor i in range(len(s)):\n if s[i] in topK:indices.append(i)\n \nselected=[]\nfor j in range(len(indices)):\n i = indices[j]\n tmp=[]\n for k in range(min(K,len(s)-i)):\n tmp.append(s[i:i+k+1])\n selected.extend(tmp)\n \nselected = sorted(set(selected))\n\nprint(selected[K-1])", "import sys\nfrom collections import defaultdict\n\nsys.setrecursionlimit(10 ** 6)\nINF = float(\"inf\")\nMOD = 10 ** 9 + 7\n\n\ndef input():\n return sys.stdin.readline().strip()\n\n\ndef main():\n S = input()\n N = len(S)\n K = int(input())\n\n places = defaultdict(list)\n for i in range(N):\n places[S[i]].append(i)\n\n places = sorted(list(places.items()), key=lambda x: x[0])\n words = set()\n for k, v in places:\n for start in v:\n cnt = 0\n for end in range(start + 1, N + 1):\n words.add(S[start:end])\n cnt += 1\n\n if cnt == 5:\n break\n\n if len(words) >= 5:\n break\n\n words = sorted(words)\n print((words[K - 1]))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "s =input()\nk = int(input())\n\nls = len(s)\n\nres =[]\n\nfor i in range(1,k+1):\n for j in range(ls-i+1):\n res.append(s[j:j+i])\n \nress = sorted(list(set(res)))\nprint(ress[k-1])", "s,K = open(0).read().split()\nK = int(K)\nss = set()\ntemp = set([''])\nfor x in s:\n temp = set([''.join((y,x)) for y in temp if len(y) <= 4])\n ss = ss | temp\n temp.add('')\nl = list(ss)\nl.sort()\nprint(l[K-1])", "# C - K-th Substring\n\ns = str(input())\nK = int(input())\n\nstr_list = set()\nfor i in range(len(s)+1):\n for j in range(i+1, i+K+1):\n if j > len(s):\n break\n str_list.add(s[i:j])\n\nstr_list = list(str_list)\nstr_list.sort()\nprint((str_list[K-1]))\n\n", "s = input()\nk = int(input())\na = []\n\nfor i in range(len(s)):\n for j in range(i+1, len(s)+1):\n if j - i >= 6:\n break\n a.append(s[i:j])\n\nres = sorted(set(a))\nprint(res[k-1])", "s = input()\nn = len(s)\nk = int(input())\nl = set()\n\nfor i in range(n):\n for j in range(1, 6):\n if i + j <= n:\n l.add(s[i: i + j])\n\nl = sorted(l)\nprint(l[k - 1])", "s = input()\nl = len(s)\nk = int(input())\nA = set()\nfor i in range(l):\n for j in range(1, 6):\n if i+j <= l:\n A.add(s[i:i+j])\nANS = sorted(A)\nprint((ANS[k-1]))\n", "s = input()\nk = int(input())\n\ndata = set()\nfor i in range(len(s)):\n for j in range(i, i + k):\n data.add(s[i: j + 1])\ndata = sorted(data)\nprint(data[k - 1])", "s = input()\nK = int(input())\n\nS = set([])\nfor i in range(len(s)):\n for j in range(i + 1, i + 1 + K):\n # print(f'{s[i:j]=}')\n S.add(s[i:j])\n# print(f'{S=}')\n# print(f'{sorted(S)=}')\nans = sorted(S)[K - 1]\nprint(ans)\n", "S = input()\nk = int(input())\nabc = []\nfor i in range(len(S)):\n for j in range(1, k+1):\n if i+j <= len(S):\n s = S[i:i+j]\n if not s in abc:\n abc.append(S[i:i+j])\n \nabc = sorted(abc)\nprint((abc[k-1]))\n", "S = input()\nN = len(S)\nK = int(input())\ntop_k = []\nfor i in range(N):\n for j in range(i + 1, min([i + K, N]) + 1):\n st = S[i:j]\n top_k.append(st)\n if len(top_k) > K:\n top_k = list(set(top_k))\n top_k.sort()\n top_k = top_k[:K]\ntop_k.sort()\nprint(top_k[-1])", "s = input()\nk = int(input())\nseen = set()\ni = 1\n \nwhile i<=k:\n for j in range(len(s)):\n seen.add(s[j:j+i])\n i += 1\n \nprint(sorted(seen)[k-1])", "s = input()\nk = int(input())\n\nsubs = set()\nfor i in range(len(s)):\n for j in range(i+1, min(i+6, len(s) + 1)):\n sub = s[i:j]\n subs.add(sub)\n\nprint((sorted(list(subs))[k-1]))\n", "s = input()\nk = int(input())\nn = len(s)\nsubst = set()\nfor i in range(n):\n for j in range(5):\n subst.add(s[i:i+j+1])\nls = list(subst)\nls.sort()\nprint((ls[k-1]))\n", "def main():\n s = input()\n K = int(input())\n r = set()\n for i in range(97, 97 + 26):\n for j, v in enumerate(s):\n if v == chr(i):\n for k in range(5):\n r.add(s[j:j+k+1])\n if len(r) > 5:\n break\n l = list(r)\n l.sort()\n return l[K-1]\nprint((main()))\n", "# input\ns = input()\nK = int(input())\n\n# check\ncase = []\nappend = case.append\nfor i in range(1, K + 1):\n for idx in range(0, len(s) - (i - 1)):\n if s[idx:idx + i] not in case:\n append(s[idx:idx + i])\ncase.sort(reverse=True)\n\nprint(case[-K])", "# Python3 (3.4.3)\nimport sys\ninput = sys.stdin.readline\n\n# -------------------------------------------------------------\n# function\n# -------------------------------------------------------------\n\n\n# -------------------------------------------------------------\n# main\n# -------------------------------------------------------------\nS = input().rstrip()\nK = int(input())\n\nAns = []\nfor k in range(5):\n for i in range(len(S)-k):\n s = S[i:i+k+1]\n if s not in Ans:\n Ans.append(s)\n\nAns.sort()\nprint(Ans[K-1])", "s=input()\nk=int(input())\nr=set()\n\nfor i in range(1,6):\n for j in range(len(s)-i+1):\n r.add(s[j:j+i])\nl=list(r)\nl=sorted(l)\nprint(l[k-1])", "import sys\ns = input()\nK = int(input())\n\na_list = sorted(set(s))\nfor i in a_list:\n if K == 1:\n print(i)\n return\n p = []\n for j, x in enumerate(s):\n if x == i:\n p.append(s[j:min(j+K,len(s))])\n p.sort()\n t = K\n for j in range(len(p)):\n if j != len(p) - 1:\n if p[j] == p[j+1][0:len(p[j])]:\n continue\n if len(p[j]) < t:\n t -= len(p[j]) - 1\n else:\n print(p[j][0:t])\n return\n K = t - 1", "import sys\n\nsys.setrecursionlimit(10 ** 9)\n\nS = input()\nK = int(input())\n\nchars = sorted(set(S))\nchecked = set()\n\n\ndef dfs(s):\n for c in chars:\n if len(checked) >= K:\n return\n next_s = s + c\n if next_s not in checked and next_s in S:\n checked.add(next_s)\n if len(checked) == K:\n print(next_s)\n return\n elif len(next_s) <= len(S):\n dfs(next_s)\n\n\ndfs('')\n", "s = input()\nk = int(input())\nc = set()\nfor i in range(len(s)):\n for j in range(i+1, i+6):\n c.add(s[i:j])\nprint((sorted(list(c))[k-1]))\n", "s = input()\nk = int(input())\nn = len(s)\n\n# print('s',s,'k',k)\nc = set()\nfor i in range(n):\n # print(s[i:i+5])\n t = s[i:i+5]\n for j in range(1,5+1):\n # print(t[:j])\n c.add(t[:j])\n\nc = list(c)\nc.sort()\n# print(*c,sep='\\n')\nprint((c[k-1]))\n", "import collections\n\ns = input()\nk = int(input())\nb = collections.Counter(s)\nc = sorted(b.items())\ncon = []\nn = 0\nwhile True:\n con.append(c[n][0])\n if len(con) == k:\n break\n for i in range(len(c)):\n check = c[n][0] + c[i][0]\n if check in s:\n con.append(check)\n if len(con) >= k:\n break\n for i_2 in range(len(c)):\n check_2 = check + c[i_2][0]\n if check_2 in s:\n con.append(check_2)\n if len(con) >= k:\n break\n for i_3 in range(len(c)):\n check_3 = check_2 + c[i_3][0]\n if check_3 in s:\n con.append(check_3)\n if len(con) >= k:\n break\n for i_4 in range(len(c)):\n check_4 = check_3 + c[i_4][0]\n if check_4 in s:\n con.append(check_4)\n if len(con) >= k:\n break\n if len(con) >= k:\n break \n n +=1\nprint(con[k-1])", "s = input()\nk = int(input())\n#l = \"abcdefghijklmnopqrstuvwxyz\"\n#print(ord(\"b\")) 97\nans = []\nfor i in range(len(s)):\n x = 0\n for j in range(5):\n if (i+j<len(s)):\n x += (ord(s[i+j])-96)*10**(8-2*j)\n ans.append((x,s[i:i+j+1]))\nans = list(set(ans))\nans.sort()\n#print(ans)\nprint(ans[k-1][1])", "s = list(input())\nk = int(input())\ns.append((''))\nDict = {}\ndict_keys = []\nfor left in range(len(s)):\n for right in range(left+1,len(s)):\n string = ''.join(s[left:right])\n if len(string)>k:\n break\n if string not in Dict.keys():\n Dict[string] = True\nDict = sorted(Dict.keys())\nprint(Dict[k-1])", "S = input()\nk = int(input())\nss = []\nfor i in range(len(S)):\n for j in range(i+1, min(i+k+1, len(S)+1)):\n ss.append(S[i:j])\n\nss = sorted(list(set(ss)))\nprint(ss[k-1])", "s = input()\nk = int(input())\nc = set()\nfor i in range(len(s)):\n for j in range(k):\n c.add(s[i:i+j+1])\nprint((sorted(list(c))[k-1]))\n", "s = input()\nn = len(s)\nK = int(input())\nans = []\nan = set()\nfor i in range(1,min(5,n)+1):\n for j in range(n-i+1):\n S = s[j:j+i]\n if S not in an:\n ans.append(S)\n an.add(S)\nans.sort()\nprint(ans[K-1])", "S = input()\nN = len(S)\nK = int(input())\nStringList = []\nfor TSt in range(0,N):\n for TEd in range(TSt+1,TSt+K+1):\n StringList.append(S[TSt:TEd])\nSetString = sorted(set(StringList))\nprint(SetString[K-1])", "s = input()\nK = int(input())\n\ndef substring(S):\n N = len(S)\n ls = []\n for i in range(1,min(6,N+1)):\n for j in range(0,N-i+1):\n ls.append(S[j:j+i])\n setls = set(ls)\n ls = list(setls)\n ls.sort()\n return ls\nprint(substring(s)[K-1])", "s = input()\nn = len(s)\nk = int(input())\nl = set()\n\nfor i in range(n):\n for j in range(1, 6):\n if i + j <= n:\n l.add(s[i: i + j])\n\nl = sorted(l)\nprint((l[k - 1]))\n", "S = input()\nK = int(input())\nS_len = len(S)\nans = set()\nfor i in range(0, K+1):\n for j in range(0, S_len):\n if j + i <= S_len:\n t = S[j:j + i]\n if t != '':\n ans.add(t)\nans = list(ans)\nans.sort()\nprint((ans[K-1]))\n", "s = list(input())\nK = int(input())\nsub_list = []\nfor i in range(1, min(K+1, len(s)+1)):\n for j in range(len(s) - i + 1):\n sub = \"\".join(s[j:j+i])\n if sub not in sub_list:\n sub_list.append(sub)\nsub_list.sort()\nprint(sub_list[K-1])", "s=input()\nk=int(input())\nn=len(s)\nr=[]\nfor right in range(0,n):\n for left in range(right+1, right+k+1):\n r.append(s[right:left])\nprint(sorted(set(r))[k-1])", "def main2():\n S=list(input())\n K=int(input())\n N=len(S)\n\n P=sorted(S)\n l=[]\n a=[]\n k=0\n while len(l)<=5 and k<N:\n if P[k] not in a:\n a.append(P[k])\n for n in range(N):\n if S[n]==P[k]:\n for i in range(1,6):\n if n+i<=N:\n tmp=\"\".join(S[n:n+i])\n if tmp not in l:\n l.append(tmp)\n k+=1\n l.sort()\n print(l[K-1])\n\ndef __starting_point():\n main2()\n__starting_point()", "s = input()\nK = int(input())\n\nseq = set()\nl = len(s)\nfor i in range(l):\n for j in range(1, K + 1):\n seq.add(s[i:i + j])\n\nseq = list(seq)\nseq.sort()\nprint((seq[K - 1]))\n", "s = input()\nk = int(input())\nn = len(s)\n\ndic = {}\nansl = []\n\nfor i in range(n):\n for j in range(i, n):\n length = j-i+1\n if length > k:\n continue\n partial = s[i:j+1]\n if not dic.get(partial, False):\n dic[partial] = True\n ansl.append(partial)\n\nansl.sort()\nprint((ansl[k-1]))\n", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ndef main():\n s = list(input())\n k = int(input())\n subs = set()\n lens = len(s)\n for i1 in range(k + 1):\n for i2 in range(lens - i1):\n subs.add(\"\".join(s[i2:i2+i1+1]))\n subs_l = list(subs)\n subs_l.sort()\n print(subs_l[k-1])\n\ndef __starting_point():\n main()\n__starting_point()", "s = input()\nk = int(input())\nl = []\nfor i in range(len(s)):\n for j in range(i+1,min(i+k+1, len(s)+1)):\n l.append(s[i:j])\nprint(sorted(list(set(l)))[k-1])", "#!/usr/bin/env python3\nfrom collections import deque\n\n\ndef search(moji):\n num = len(moji)\n setsn = set([])\n for i in range(len(s)-num+1):\n if s[i:i+num] == moji:\n str_ = s[i:i+num+1]\n if len(str_) == num+1:\n setsn.add(str_)\n sorted_setsn = sorted(setsn, reverse=True)\n\n return sorted_setsn\n\n\ns = str(input())\nk = int(input())\nn = len(s)\n\nsets1 = set([])\nfor i in range(0, len(s)):\n sets1.add(s[i])\n\nsorted_sets1 = sorted(sets1)\n\n# if k == 1:\n# print(sorted_sets1[0])\n# return\n# else:\n# k -= 1\n\ndq = deque(sorted_sets1)\n\nwhile(len(dq)):\n # print(dq, k)\n moji = dq.popleft()\n k -= 1\n if k == 0:\n print(moji)\n return\n sorted_setsn = search(moji)\n\n # print(sorted_setsn)\n dq.extendleft(sorted_setsn)\n", "s = input()\n\nd = [\"z\"*5010]*5\n\nk = int(input())\nfor i in range(len(s)):\n for j in range(i, i+k):\n x = s[i:j+1]\n if x in d or x == '':\n continue\n l = 0\n while l < 5 and x > d[l]:\n l += 1\n # print(k, d[0:k], x, d[k:])\n if l < 5:\n d = d[0:l] + [x] + d[l:]\n d = d[0:5]\n # print(f\"->{d}\")\n# l = list(d)\n# l.sort()\n# print(l)\n# if l[0] == '':\n # l = l[1:]\n\nprint((d[k-1]))\n", "S = input()\nN = len(S)\nK = int(input())\nS_list = sorted(set(list(S)))\n\nmemo = {}\n\nfor small_char in S_list:\n for i in range(N):\n if S[i] == small_char:\n for j in range(i+1, i+K+1):\n word = S[i:j]\n memo[word] = None\n if len(memo) >= K:\n break\n\nans_list = sorted(list(memo.keys()))\nprint((ans_list[K-1]))\n", "s = input()\nK = int(input())\n\nsubst = []\nfor i in range(5):\n for j in range(len(s) - i):\n subst.append(s[j:j+i+1])\n\nsubst = list(set(subst))\nsubst.sort()\n\nprint(subst[K - 1])", "S = input()\nN = len(S)\nK = int(input())\nttl = []\nfor i in range(N):\n for j in range(N - i):\n ttl.append(S[j:j+i+1])\n if i > K:\n break\nttl = sorted(list(set(ttl)))\nprint(ttl[K-1])", "from itertools import combinations\ns = input()\nn = int(input())\n\nle = len(s)\ntmp = s[:5]\n\nfor i in range(le - 4):\n tmp = min(tmp, s[i:i+5])\n\nseed = tuple(combinations(list(range(min(6, le+1))), 2))\nres = set()\nfor i, j in seed:\n res.add(tmp[i:j])\nans = sorted(res)\nprint((ans[n - 1]))\n", "S = input()\nK = int(input())\n\nN = len(S)\n\nmemo = []\nfor i in range(N):\n for d in range(1, min(K, N - i) + 1):\n memo.append(S[i:i + d])\n\nprint(sorted(set(memo))[K - 1])", "s = input()\nk = int(input())\nse = set()\nfor i in s:\n se.add(i)\nif len(s) > 1:\n for i in range(len(s)-1):\n se.add(s[i]+s[i+1])\nif len(s) > 2:\n for i in range(len(s)-2):\n se.add(s[i]+s[i+1]+s[i+2])\nif len(s) > 3:\n for i in range(len(s)-3):\n se.add(s[i]+s[i+1]+s[i+2]+s[i+3])\nif len(s) > 4:\n for i in range(len(s)-4):\n se.add(s[i]+s[i+1]+s[i+2]+s[i+3]+s[i+4])\nse = sorted(se)\nprint(se[k-1])", "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 S = readline().strip()\n K = int(readline())\n\n subs = set()\n\n for i in range(len(S)):\n for j in range(i + 1, min(len(S) + 1, i + K + 1)):\n subs.add(S[i:j])\n\n subs = sorted(subs)\n print((subs[K - 1]))\n\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "# K\u306f\u6700\u5927\u3067\uff15\u306a\u306e\u3067\u30011~\uff15\u6587\u5b57\u306e\u90e8\u5206\u6587\u5b57\u5217\u3092\u5168\u5217\u6319\u3057\u3066\u91cd\u8907\u7701\u3044\u3066\u30bd\u30fc\u30c8\u3059\u308c\u3070\u7d42\u308f\u308a\ns = input()\nK = int(input())\n\nsub = set()\nfor i in range(K):\n for j in range(len(s) - i):\n sub.add(s[j:j + i + 1])\n\nsub = list(sub)\nsub.sort()\n\nprint(sub[K - 1])", "def main():\n S = input()\n k = int(input())\n setS = set(list(S))\n count = 0\n ans = []\n for j in range(1, k + 1):\n for i in range(len(S) - j + 1):\n ans.append(S[i:i + j])\n ans = sorted(list(set(ans)))\n print((ans[k - 1]))\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\nk = int(input())\n\nsubs_list = []\nfor i in range(len(s)):\n for j in range(i+1, i+k+1):\n subs_list.append(s[i:j])\n\nans = sorted(set(subs_list))\nprint((ans[k-1]))\n", "S = list(input())\nn = len(S)\nk = int(input())\nH = [\"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\"]\np = 0\ncnt = 0\nD = set()\n\nwhile True:\n for i in range(n):\n if S[i] == H[p]:\n for j in range(1, 6):\n if i + j <= n:\n D.add(\"\".join(S[i:i + j]))\n\n p += 1\n if len(list(D)) >= k:\n break\n\nD = list(D)\nD.sort()\n\nprint(D[k-1])", "s = input()\nk = int(input())\n\ncand = []\nfor i in range(len(s)):\n temp = ''\n for j in range(k):\n if i + j >= len(s):continue\n temp += s[i + j]\n cand.append(temp)\n\ncand.sort()\n#print(cand)\nans = cand.pop(0)\nk -= 1\nwhile k != 0:\n temp = cand.pop(0)\n if temp == ans:continue \n ans = temp\n k -= 1\n\nprint(ans)", "S = input()\nK = int(input())\nprint(sorted(set(S[i:i+j+1] for i in range(len(S)) for j in range(K)))[K-1])", "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log, log2\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom 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()))\ndef ZIP(n): return list(zip(*(MAP() for _ in range(n))))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10**9 + 7\n#from decimal import *\n\ns = input()\nK = INT()\n\n\nsubstr = []\n\nfor l in range(len(s)):\n\tr = l+1\n\twhile r < len(s)+1:\n\t\t#print(l, r, substr)\n\t\tif bisect(substr, s[l:r]) == 5:\n\t\t\tbreak\n\t\telif s[l:r] in substr:\n\t\t\tr += 1\n\t\telif s[l:r] not in substr:\n\t\t\tinsort(substr, s[l:r])\n\t\t\tsubstr = substr[:5]\n\t\t\tif s[l:r] in substr:\n\t\t\t\tr += 1\n\n\n#print(substr)\nprint((substr[K-1]))\n", "S = input()\nK = int(input())\n\nsubstrings = set()\nfor length in range(1, K + 1):\n for i in range(len(S) - length + 1):\n substrings.add(S[i:i + length])\n\nsubstrings = sorted(substrings)\n\nprint((substrings[K - 1]))\n", "s = str(input())\nK = int(input())\n# s\u304cabcac \u306e\u5834\u5408\u3001a,bca,ac \u306a\u3069\u306f\u90e8\u5206\u5217(substring\n# abc \u3068ab\u306e\u5834\u5408\u3001ab\u306e\u65b9\u304c\u8f9e\u66f8\u9806\u3067\u5c0f\u3055\u3044\u3068\u5224\u65ad\u3059\u308b\u3002\n# abc \u3068aba\u306e\u5834\u5408\u3001aba\u306e\u65b9\u304c\u5c0f\u3055\u3044\n\nsubstrings = set([])\nfor i in range(5):\n for j in range(len(s) - i):\n # print(i, j)\n substrings.add(s[j:j + i + 1])\n# print(substrings)\nprint((sorted(substrings)[K - 1]))\n", "s = input()\nk = int(input())\nl = \"abcdefghijklmnopqrstuvwxyz\"\nd = {}\n\nfor i in range(26):\n cnt = s.count(l[i])\n pre = 0\n if cnt > 0:\n for j in range(cnt):\n pos = s.find(l[i], pre)\n pre = pos + 1\n for m in range(min(len(s) - pos, k)):\n if s[pos:pos + m + 1] not in d:\n d[s[pos:pos + m + 1]] = 1\n if len(d) >= k:\n dl = []\n for i in d.keys():\n dl.append(i)\n dl.sort()\n print(dl[k - 1])\n return", "s = input()\nl = len(s)\nk = int(input())\nA = set()\nfor i in range(l):\n for j in range(1, 6):\n if i+j <= l:\n A.add(s[i:i+j])\nans = sorted(A)\nprint(ans[k-1])", "def main():\n S = input()\n N = len(S)\n K = int(input())\n top_k = []\n for i in range(N):\n for j in range(i + 1, min([i + K, N]) + 1):\n st = S[i:j]\n top_k.append(st)\n if len(top_k) > K:\n top_k = list(set(top_k))\n top_k.sort()\n top_k = top_k[:K]\n top_k.sort()\n print(top_k[-1])\n\n\ndef __starting_point():\n main()\n__starting_point()", "s = input()\nk = int(input())\n\nalphabets = [chr(i + 97) for i in range(26)]\n\nfor char in alphabets:\n l = []\n for i in range(len(s)):\n if s[i] == char:\n l.append(s[i:])\n\n if l == []:\n continue\n\n if k == 1:\n print((l[0][0]))\n return\n \n k -= 1\n\n strings = set([])\n for i in l:\n for j in range(2, min(k+2, len(i)+1)):\n strings.add(i[:j])\n strings = list(strings)\n strings.sort()\n \n if len(strings) >= k:\n print((strings[k-1]))\n return\n else:\n k -= len(strings)\n", "s=input();k=int(input());print(sorted({s[i:i+j]for i in range(len(s))for j in range(1,k+1)})[k-1])", "s = input().rstrip()\nk = int(input())\n\nn = len(s)\nss = set()\nfor i in range(n):\n for j in range(1, k + 1):\n ss.add(s[i:i+j])\nprint(sorted(ss)[k - 1])", "s = input()\nk = int(input())\nc = []\nfor i in range(len(s)):\n for j in range(k): c.append(s[i:i+j+1])\nc.sort()\npre = ''\nfor x in c:\n if pre == x: continue\n k -= 1\n if k == 0:\n print(x)\n break\n pre = x\n", "# coding: utf-8\nimport sys\n\nsr = lambda: sys.stdin.readline().rstrip()\nir = lambda: int(sr())\nlr = lambda: list(map(int, sr().split()))\n\nS = sr()\nK = ir()\ncand = set()\nlength = len(S)\nfor i in range(length):\n for j in range(1, 6):\n cand.add(S[i:i+j])\n\nanswer = sorted(list(cand))[K-1]\nprint(answer)\n", "# import sys\n# sys.setrecursionlimit(10 ** 6)\nimport bisect\n# from collections import deque\n# from decorator import stop_watch\n#\n#\n# @stop_watch\ndef solve(S, K):\n n = len(S)\n l = [''] + ['\u3042'] * 5\n for i in range(n):\n for j in range(i, i + 5):\n tmp = S[i:j + 1]\n tmp_num = bisect.bisect_left(l, tmp)\n if tmp_num > 5:\n continue\n elif l[tmp_num] != tmp:\n l.insert(tmp_num, tmp)\n l.pop(-1)\n print((l[K]))\n\n\ndef __starting_point():\n S = input()\n K = int(input())\n solve(S, K)\n\n # # test\n # from random import randint\n # from func import random_str\n # n = 5000\n # S = random_str(n, 'abcde')\n # K = randint(1, 5)\n # print(S)\n # print(K)\n # solve(S, K)\n\n__starting_point()", "s = input()\nl = len(s)\nk = int(input())\nA = set()\nfor i in range(l):\n for j in range(1, 6):\n if i+j <= l:\n A.add(s[i:i+j])\nANS = sorted(A)\nprint((ANS[k-1]))\n", "s = input()\nk = int(input())\nsubstring = set([])\nfor i in range(min(len(s), 5)):\n for j in range(0, len(s)-i):\n substring.add(s[j:i+j+1])\nans = list(substring)\nans.sort()\nprint(ans[k-1])", "s=input()\nk=int(input())\nans=[]\n\nfor i in range(len(s)):\n for j in range(i+1,min(k+i+1,len(s)+1)):\n ans.append(s[i:j])\n\nans=list(set(ans))\nans.sort()\nprint((ans[k-1]))\n", "S=input()\nK=int(input())\nN=len(S)\ns=set()\nfor i in range(N):\n for j in range(i+1,min(i+K+1,N+1)):\n s|={S[i:j]}\nA=list(s)\nA.sort()\nprint((A[K-1]))\n", "s = input()\nk = int(input())\nseen = set()\ni = 1\n\nwhile i<=k:\n for j in range(len(s)):\n seen.add(s[j:j+i])\n i += 1\n\nprint(sorted(seen)[k-1])", "# coding: utf-8\n# hello world\u3068\u8868\u793a\u3059\u308b\n#dp\u3067\u3067\u304d\u306a\u3044\u304b\u306a\uff1f\nimport sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(10**7)\nfrom collections import Counter, deque\nfrom collections import defaultdict\nfrom itertools import combinations, permutations, accumulate, groupby, product\nfrom bisect import bisect_left,bisect_right\nfrom heapq import heapify, heappop, heappush\nfrom math import floor, ceil,pi\nfrom operator import itemgetter\ndef I(): return int(input())\ndef MI(): return map(int, input().split())\ndef LI(): return list(map(int, input().split()))\ndef LI2(): return [int(input()) for i in range(n)]\ndef MXI(): return [[LI()]for i in range(n)]\ndef SI(): return input().rstrip()\ndef printns(x): print('\\n'.join(x))\ndef printni(x): print('\\n'.join(list(map(str,x))))\ninf = 10**17\nmod = 10**9 + 7\n\ns=SI()\nk=I()\nn=len(s)\nstrs=[]\nfor i in range(n):\n for j in range(1,k+1):\n strs.append(s[i:i+j])\nprint(sorted(list(set(strs)))[k-1])", "from itertools import*\ns = input()\nk = int(input())\nl = len(s)\nprint(sorted(set(s[i:j] for i, j in combinations(range(l+1), 2) if j - i <= k))[k-1])", "import sys, re\nfrom collections import deque, defaultdict, Counter\nfrom math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log, log2\nfrom itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby\nfrom operator import itemgetter, mul\nfrom copy import deepcopy\nfrom string import ascii_lowercase, ascii_uppercase, digits\nfrom bisect import bisect, bisect_left, insort, insort_left\nfrom 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()))\ndef ZIP(n): return list(zip(*(MAP() for _ in range(n))))\nsys.setrecursionlimit(10 ** 9)\nINF = float('inf')\nmod = 10**9 + 7\n#from decimal import *\n\ndef main():\n\ts = input()\n\tK = INT()\n\n\tstrings = set()\n\tfor i in range(1, K+1): #\u6587\u5b57\u5217\u306e\u9577\u3055 : K\u756a\u76ee\u3067\u9577\u3055\u304cK\u4ee5\u4e0a\u306e\u3092\u8003\u3048\u308b\u5fc5\u8981\u306f\u306a\u3044\u3002\n\t\tfor j in range(len(s)-i+1): #\u30b9\u30bf\u30fc\u30c8\u5730\u70b9\n\t\t\t#print(j, i)\n\t\t\tstrings.add(s[j:j+i])\n\n\tprint((sorted(strings)[K-1]))\n\ndef __starting_point():\n\tmain()\n\n__starting_point()", "s = input()\nk = int(input())\n\nl = k\ncount = 0\nn = len(s)\nlst = 'abcdefghijklmnopqrstuvwxyz'\nfor alpha in lst:\n alpha_index = []\n for index in range(n):\n if alpha == s[index]:\n alpha_index.append(index)\n if len(alpha_index) > 0:\n cand_lst = []\n for index2 in alpha_index:\n end_lst = [index2 + m for m in range(1,6) if index2 + m <= n]\n for end in end_lst:\n cand_lst.append(s[index2:end])\n cand_lst = set(cand_lst)\n cand_lst = sorted(cand_lst)\n #print('alpha: ', alpha)\n #print('alpha_index: ', alpha_index)\n #print('cand_lst: ', cand_lst)\n if len(cand_lst) < l:\n l = l - len(cand_lst)\n else:\n res = cand_lst[l-1]\n break\n\nprint(res)", "S = input()\nK = int(input())\nA = []\nfor i in range(len(S)):\n for j in range(1,6):\n a = S[i:i+j]\n A.append(a) \n #print(A)\n\nA = set(A)\nA = sorted(set(A))\nprint(A[K-1])", "from collections import defaultdict\nimport string\ns = input()\nK = int(input())\nlocation = defaultdict(list)\nfor i, s_i in enumerate(s):\n location[s_i].append(i)\ncount = 0\ns_list = []\nfor c in string.ascii_lowercase[:26]:\n if location[c] == []:\n continue\n for idx in location[c]:\n for i in range(K):\n if idx + i + 1 > len(s):\n break\n if s[idx:idx+i+1] in s_list:\n continue\n s_list.append(s[idx:idx+i+1])\n count += 1\n if count == K:\n break\ns_list.sort()\nprint(s_list[K-1])", "import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\nfrom collections import defaultdict\ndef main():\n s = list(input())\n k = int(input())\n k -= 1\n\n d1 = defaultdict(list)\n for i, c in enumerate(s):\n d1[c].append(i)\n d2 = sorted(d1.items())\n\n lens = len(s)\n for d2e in d2:\n subs = set()\n subs.add(d2e[0])\n for d2ee in d2e[1]:\n end = min(lens + 1, d2ee + k + 2)\n for i1 in range(d2ee+1, end):\n subs.add(\"\".join(s[d2ee:i1]))\n if len(subs) > k:\n subsl = list(subs)\n subsl.sort()\n print(subsl[k])\n return\n else:\n k -= len(subs)\n\ndef __starting_point():\n main()\n__starting_point()", "s = input()\nk = int(input())\nn = len(s)\ntemp_set = set()\nfor i in range(n):\n for j in range(i + 1, min(i + k + 1, n + 1)):\n temp_set.add(s[i:j])\ntemp_list = sorted(list(temp_set))\nprint(temp_list[k - 1])", "def main():\n s=input()\n k=int(input())\n a=set()\n for l in range(5):\n for i in range(len(s)-l):\n a.add(s[i:i+l+1])\n print(sorted(a)[k-1])\n\ndef __starting_point():\n main()\n__starting_point()", "#!/usr/bin/env python3\n\n\ndef main():\n s = input()\n N = len(s)\n K = int(input())\n X = set()\n for i in range(1,K+1):\n for j in range(N-i+1):\n X.add(s[j:j+i])\n print((sorted(X)[K-1]))\n\ndef __starting_point():\n main()\n\n__starting_point()", "s = input()\nk = int(input())\nli = []\nfor i in range(len(s)):\n for j in range(i+1,len(s)+1):\n if j-i<=6:\n li += [s[i:j]]\nli2 = set(li)\nli3 = sorted(li2)\nprint(li3[k-1])", "s=input()\nn=len(s)\nk=int(input())\nl=[]\nfor i in range(n):\n for j in range(i,i+k+1):\n a=s[i:j+1]\n l.append(a)\nl=set(l)\nl=list(l)\nl.sort()\nprint(l[k-1])", "S = input()\nN = len(S)\nK = int(input())\ncnt = {i: [] for i in range(N)}\nfor i in range(N):\n for j in range(N - i):\n s = S[j:j+i+1]\n l = len(s)\n if s not in cnt[l-1]:\n cnt[l-1].append(s)\n if i > K:\n break\nttl = []\nfor k, v in cnt.items():\n ttl.extend(v)\nttl.sort()\nprint(ttl[K-1])", "s=input()\ns=s+'0'\nK=int(input())\np=set()\nfor i in range(len(s)):\n for j in range(1,6):\n if i+j<=len(s)-1:\n p.add(s[i:j+i])\np=sorted(p)\nprint(p[K-1])", "s = input()\nk = int(input())\nlst = sorted(list(set(s)))\ntank = []\nfor tg in lst:\n for i in range(len(s)):\n if s[i]==tg:\n for j in range(k):\n if i+j<=len(s) and (s[i:i+j+1] not in tank):\n tank.append(s[i:i+j+1])\n if len(tank) >= k:\n break\ntank.sort()\nprint(tank[k-1])", "s = input()\nK = int(input())\nN = len(s)\n\nans = []\n\nfor i in range(min(K, N)):\n for j in range(N-i):\n ans.append(s[j:j+i+1])\n \nans.sort()\ncount = 0\nnow = '0'\nfor i in range(len(ans)):\n if ans[i] != now:\n count += 1\n now = ans[i]\n if count == K:\n print(now)\n return\n \n", "from collections import deque\n\ns = input()\nk = int(input())\n\ndef index_Multi(List,liter):\n #List\u306f\u30ea\u30b9\u30c8\u672c\u4f53\u30fbliter\u306f\u691c\u7d22\u3057\u305f\u3044\u6587\u5b57\n index_L = []\n for val in range(0,len(List)):\n if liter == List[val]:\n index_L.append(val)\n return index_L\n\ndef substr(s, k, j):\n n = ord(\"a\")\n\n while True:\n l = index_Multi(s, chr(n+j))\n word = []\n if len(l) == 0:\n n += 1\n else:\n for p in l:\n for i in range(k):\n word.append(s[p:p+i+1])\n sword = set(word)\n if len(sword) >= k:\n tword = list(sword)\n tword.sort()\n #print(tword, sword)\n return tword[k-1]\n else:\n return substr(s, k-len(sword), j+1)\n break\n\nprint(substr(s, k, 0))", "def calc( s , k , n):\n\n\tbruh = {}\n\tfor i in range(1, k + 1): # length\n\t\tfor j in range( n - ( i - 1)): # start \n\t\t\tbruh[s[j: j + i:]] = 0\n\tanother = bruh.keys()\n\tanother = sorted(another)\n\tprint( another[k - 1])\n\ns = input()\n\nk = int(input())\n\nn = len(s)\n \ncalc( s , k , n)", "s = input()\nk = int(input())\n\nSUBSTRINGS = set()\nfor i in range(len(s)):\n for j in range(i + 1, i + 6):\n SUBSTRINGS.add(s[i:j])\n\nSUBSTRINGS = sorted(SUBSTRINGS)\n\nprint((SUBSTRINGS[k - 1]))\n"]
{"inputs": ["aba\n4\n", "atcoderandatcodeer\n5\n", "z\n1\n"], "outputs": ["b\n", "andat\n", "z\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
34,183
45cc4e4d48f2ac78d90cee07b6156e64
UNKNOWN
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white. Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i). Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows: - If a_i = 1, he painted the region satisfying x < x_i within the rectangle. - If a_i = 2, he painted the region satisfying x > x_i within the rectangle. - If a_i = 3, he painted the region satisfying y < y_i within the rectangle. - If a_i = 4, he painted the region satisfying y > y_i within the rectangle. Find the area of the white region within the rectangle after he finished painting. -----Constraints----- - 1 ≦ W, H ≦ 100 - 1 ≦ N ≦ 100 - 0 ≦ x_i ≦ W (1 ≦ i ≦ N) - 0 ≦ y_i ≦ H (1 ≦ i ≦ N) - W, H (21:32, added), x_i and y_i are integers. - a_i (1 ≦ i ≦ N) is 1, 2, 3 or 4. -----Input----- The input is given from Standard Input in the following format: W H N x_1 y_1 a_1 x_2 y_2 a_2 : x_N y_N a_N -----Output----- Print the area of the white region within the rectangle after Snuke finished painting. -----Sample Input----- 5 4 2 2 1 1 3 3 4 -----Sample Output----- 9 The figure below shows the rectangle before Snuke starts painting. First, as (x_1, y_1) = (2, 1) and a_1 = 1, he paints the region satisfying x < 2 within the rectangle: Then, as (x_2, y_2) = (3, 3) and a_2 = 4, he paints the region satisfying y > 3 within the rectangle: Now, the area of the white region within the rectangle is 9.
["def main():\n w, h, n = list(map(int, input().split()))\n\n x_min = 0\n x_max = w\n y_min = 0\n y_max = h\n\n for _ in range(n):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n x_min = max(x_min, x)\n elif a == 2:\n x_max = min(x_max, x)\n elif a == 3:\n y_min = max(y_min, y)\n else:\n y_max = min(y_max, y)\n\n print((\n (x_max - x_min) * (y_max - y_min)\n if x_min < x_max and y_min < y_max else 0\n ))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "W,H,N=map(int,input().split())\nA,B,C,D=[0],[W],[0],[H]\n\nfor i in range(N):\n x,y,a=map(int,input().split())\n if a==1:\n A.append(x)\n elif a==2:\n B.append(x)\n elif a==3:\n C.append(y)\n elif a==4:\n D.append(y)\n\nW=min(B)-max(A)\nH=min(D)-max(C)\n\nif W<0 or H<0:\n ans=0\nelse:\n ans=H*W\nprint(ans)", "w,h,n=list(map(int,input().split()))\nxmin=0\nxmax=w\nymin=0\nymax=h\nfor i in range(n):\n x,y,a=list(map(int,input().split()))\n if a==1:\n xmin=max(x,xmin)\n elif a==2:\n xmax=min(x,xmax)\n elif a==3:\n ymin=max(y,ymin)\n else:\n ymax=min(y,ymax)\nprint((max(0,xmax-xmin)*max(0,ymax-ymin)))\n\n", "w, h, n = map(int, input().split())\nx1 = [0]\nx2 = [w]\ny1 = [0]\ny2 = [h]\n\nfor i in range(n):\n x, y, a = map(int, input().split())\n if a == 1:\n x1.append(x)\n elif a == 2:\n x2.append(x)\n elif a == 3:\n y1.append(y)\n elif a == 4:\n y2.append(y)\n\nleft = max(x1)\nright = min(x2)\nbottom = max(y1)\ntop = min(y2)\n\nans =max(0, right - left)*max(0, top - bottom)\nprint(ans)", "# coding = SJIS\n\nw, h, n = map(int, input().split())\npoints = []\narea = [0, w, 0, h]\n\nfor i in range(n):\n x, y, a = map(int, input().split())\n points.append([x, y, a])\n\nfor i in range(n):\n if points[i][2] == 1:\n area[0] = max(area[0], points[i][0])\n if points[i][2] == 2:\n area[1] = min(area[1], points[i][0])\n if points[i][2] == 3:\n area[2] = max(area[2], points[i][1])\n if points[i][2] == 4:\n area[3] = min(area[3], points[i][1])\n\nans = max(0, (area[1] - area[0])) * max(0, (area[3] - area[2]))\n\nprint(ans)", "W,H,N=map(int,input().split())\nl,r,b,t=0,W,0,H\nfor _ in range(N):\n x,y,a=map(int,input().split())\n if a==1:\n l=max(l,x)\n elif a==2:\n r=min(r,x)\n elif a==3:\n b=max(b,y)\n else:\n t=min(t,y)\nif l<r and b<t:\n print((r-l)*(t-b))\nelse:\n print(0)", "w,h,n=map(int,input().split())\ns=0\nb=w\nt=0\nc=h\n\nfor i in range(n):\n x,y,a=map(int,input().split())\n if a==1:\n s=max(s,x)\n elif a==2:\n b=min(b,x)\n elif a==3:\n t=max(t,y)\n else:\n c=min(c,y)\nif b>s and c>t:\n print((b-s)*(c-t))\nelse:\n print(0)", "import numpy as np\n\n\ndef main():\n w, h, n = list(map(int, input().split()))\n xyas = [list(map(int, input().split())) for _ in range(n)]\n board = np.array([[0 for i in range(w)] for j in range(h)])\n for x, y, a in xyas:\n if a == 1:\n board[:, :x] = 1\n elif a == 2:\n board[:, x:] = 1\n elif a == 3:\n board[-y:, :] = 1\n elif a == 4:\n board[:-y, :] = 1\n ans = (w*h) - np.sum(board)\n print(ans)\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "W,H,N = map(int,input().split())\na = []\nfor i in range(N):\n b = list(map(int,input().split()))\n a.append(b)\nxs = 0\nxe = W\nys = 0\nye = H\nfor i in range(N):\n if a[i][2] == 1 and xs < a[i][0]:\n xs = a[i][0]\n elif a[i][2] == 2 and xe > a [i][0]:\n xe = a[i][0]\n elif a[i][2] == 3 and ys < a[i][1]:\n ys = a[i][1]\n elif a[i][2] == 4 and ye > a[i][1]:\n ye = a[i][1]\nif xs < xe:\n w = xe - xs\nelse:\n w = 0\nif ys < ye:\n h = ye - ys\nelse:\n h = 0\nprint(w*h)", "w,h,n = map(int, input().split())\nx1 = [0] #1 left border of white area\nx2 = [w] #2\ny1 = [0] #3\ny2 = [h] #4\nfor i in range(n):\n x,y,a = map (int, input().split())\n if a == 1:\n x1.append(x)\n elif a == 2:\n x2.append(x)\n elif a == 3:\n y1.append(y)\n elif a ==4:\n y2.append(y)\n\nleft = max(x1)\nright = min(x2)\nbottom = max(y1)\ntop = min(y2)\n\n\nans =max(0, right - left)*max(0, top - bottom)\n\nprint(ans)", "W, H, N = map(int,input().split()) \nl = 0; r = W; u = H; d = 0 \n\nfor i in range(N):\n x, y, a = map(int,input().split()) \n if a == 1:\n l = max(l,x) \n elif a == 2:\n r = min(r,x) \n elif a == 3:\n d = max(d,y) \n else:\n u = min(u,y) \n\nprint(max(0,(r-l))*max(u-d, 0)) ", "w, h, n = map(int,input().split())\nL = [list(map(int,input().split())) for i in range(n)]\nx1 = 0\nx2 = w\ny1 = 0\ny2 = h\nfor i in range(n):\n if L[i][2] == 1:\n x1 = max(L[i][0], x1)\n if L[i][2] == 2:\n x2 = min(L[i][0], x2)\n if L[i][2] == 3:\n y1 = max(L[i][1], y1)\n if L[i][2] == 4:\n y2 = min(L[i][1], y2)\n \nans = 0\nif x2>=x1 and y2>=y1:\n ans = (x2-x1)*(y2-y1)\nprint(ans)", "w, h, n = list(map(int, input().split()))\nx_pos = [0, w]\ny_pos = [0, h]\nfor _ in range(n):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n x_pos[0] = max(x_pos[0], x)\n elif a == 2:\n x_pos[1] = min(x_pos[1], x)\n elif a == 3:\n y_pos[0] = max(y_pos[0], y)\n else:\n y_pos[1] = min(y_pos[1], y)\nans = max(0, (x_pos[1] - x_pos[0])) * max(0, (y_pos[1] - y_pos[0]))\nprint(ans)\n", "W, H, N = list(map(int, input().split()))\nbl_x, tr_x, bl_y, tr_y = 0, W, 0, H\nfor i in range(N):\n\tx, y, a = list(map(int, input().split()))\n\tif a == 1:\n\t\tbl_x = max(bl_x, x)\n\telif a == 2:\n\t\ttr_x = min(tr_x, x)\n\telif a == 3:\n\t\tbl_y = max(bl_y, y)\n\telif a == 4:\n\t\ttr_y = min(tr_y, y)\nprint((max(tr_x - bl_x, 0) * max(tr_y - bl_y, 0)))\n", "W, H, N = list(map(int, input().split()))\nX_Y_A = [list(map(int, input().split())) for _ in range(N)]\noX = 0\noY = 0\nfor x, y, a in X_Y_A:\n if a == 1:\n oX = max(x, oX)\n elif a == 2:\n W = min(x, W)\n elif a == 3:\n oY = max(y, oY)\n else:\n H = min(y, H)\n# print(W, oX, H, oY)\nprint((max(0, W-oX)*max(0, H-oY)))\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 w,h,n = i_map()\n\n up = h\n right = w\n down = 0\n left = 0\n\n for i in range(n):\n x,y,a = i_map()\n if a == 1:\n left = max(left,x)\n elif a == 2:\n right = min(right, x)\n elif a == 3:\n down = max(down, y)\n else:\n up = min(up, y)\n print((max((up-down),0)*max((right-left),0)))\n\ndef __starting_point():\n main()\n\n__starting_point()", "import sys\nimput=sys.stdin.read\nw,h,n=map(int,input().split())\nt=[list(map(int,input().split())) for i in range(n)]\nsu=[]\nst=[]\nsv=[]\nsw=[]\nsux=svy=0\nstx=w\nswy=h\nfor j in range(n):\n if t[j][2]==1:\n su.append(t[j][0])\n sux=max(su)\n elif t[j][2]==2:\n st.append(t[j][0])\n stx=min(st)\n elif t[j][2]==3:\n sv.append(t[j][1])\n svy=max(sv)\n else:\n sw.append(t[j][1])\n swy=min(sw)\nif sux-stx>=0 or svy-swy>=0:\n print(0)\nelse:\n print((stx-sux)*(swy-svy))", "w, h, n = map(int, input().split())\nxya = [list(map(int, input().split())) for _ in range(n)]\nx, y, a = zip(*xya)\nxl, xr, yb, yt = 0, w, 0, h\nfor i in range(n):\n if a[i] == 1: xl = max(xl, x[i])\n elif a[i] == 2: xr = min(xr, x[i])\n elif a[i] == 3: yb = max(yb, y[i])\n else: yt = min(yt, y[i])\nprint((xr-xl)*(yt-yb)*(xr>xl and yt>yb))", "lst = input().split()\n\nW = int(lst[0])\nH = int(lst[1])\nN = int(lst[2])\n\nfield = [([0] * W)] * H\n\nL = []\n\nfor i in range(N):\n L = input().split()\n if L[2] == '1':\n for j in range(H):\n for k in range(int(L[0])):\n field[j][k] = 1\n elif L[2] == '2':\n for j in range(H):\n for k in range(int(L[0]), W):\n field[j][k] = 1\n elif L[2] == '3':\n for j in range(int(L[1])):\n field[j] = [1] * W\n elif L[2] == '4':\n for j in range(int(L[1]), H):\n field[j] = [1] * W\n\nans = 0\n\nfor s in field:\n ans += s.count(0)\n\nprint(ans)", "import bisect,collections,copy,itertools,math,string\nimport sys\ndef I(): return int(sys.stdin.readline().rstrip())\ndef LI(): return list(map(int,sys.stdin.readline().rstrip().split()))\ndef S(): return sys.stdin.readline().rstrip()\ndef LS(): return list(sys.stdin.readline().rstrip().split())\ndef main():\n w,h,n = LI()\n board = [[1]*h for _ in range(w)]\n\n for _ in range(n):\n x,y,a = LI()\n if a == 1:\n for i in range(x):\n board[i] = [0 for _ in range(h)]\n elif a == 2:\n for i in range(x,w):\n board[i] = [0 for _ in range(h)]\n elif a == 3:\n for i in range(w):\n for j in range(y):\n board[i][j] = 0\n elif a == 4:\n for i in range(w):\n for j in range(y,h):\n board[i][j] = 0\n\n ans = 0\n for line in board:\n ans += sum(line)\n\n print(ans)\n\n # print(*board,sep=\"\\n\")\nmain() \n", "w,h,n=[int(i) for i in input().split()]\n#\u4e8c\u6b21\u5143\u914d\u5217\u306e\u4f5c\u6210\nlist_2d=[[0]*w for i in range(h)]\n\n\ndef nurie(x,y,a):\n if a==1:\n for i in range(h):\n for j in range(x):\n list_2d[i][j]=1\n elif a==2:\n for i in range(h):\n for j in range(x,w):\n list_2d[i][j]=1\n \n\n elif a==3:\n for i in range(y):\n for j in range(w):\n list_2d[i][j]=1\n \n else:\n for i in range(y,h):\n for j in range(w):\n list_2d[i][j]=1\n return list_2d\n \nfor i in range(n):\n x,y,a=[int(i) for i in input().split()]\n nurie(x,y,a)\n \nsum=0\nfor i in range(h):\n sum+=list_2d[i].count(0)\n \nprint(sum)", "w,h,n = map(int,input().split())\nx1 = 0\nx2 = w\ny1 = 0\ny2 = h\nfor i in range(n):\n x,y,a = map(int,input().split())\n if a == 1:\n x1 = max(x1,x)\n elif a == 2:\n x2 = min(x2,x)\n elif a == 3:\n y1 = max(y1,y)\n else:\n y2 = min(y2,y)\nif x1 >= x2 or y1 >= y2:\n print(0)\nelse:\n print(w*h-h*(x1+w-x2)-(x2-x1)*(y1+h-y2))", "W,H,N = map(int,input().split())\nX=Y=0\n\n\nfor i in range(N):\n x,y,a = map(int,input().split())\n \n if a==1:\n X = max(X,x)\n \n elif a==2:\n W = min(W,x)\n \n elif a==3:\n Y = max(Y,y)\n else:\n H = min(H,y)\nprint(max(W-X,0)*max(H-Y,0))", "w, h, n = list(map(int, input().split()))\nr_w = w\nl_w = 0\nu_h = h\nd_h = 0\n\nfor i in range(n):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n l_w = max(l_w, x)\n elif a == 2:\n r_w = min(r_w, x)\n elif a == 3:\n d_h = max(d_h, y)\n elif a == 4:\n u_h = min(u_h, y)\n\nres = max(0, r_w - l_w) * max(0, u_h - d_h)\nprint(res)\n", "w,h,n = map(int,input().split())\ndata = list(input().split() for i in range(n))\nx_1 = 0\nx_2 = w\ny_1 = 0\ny_2 = h\nfor i in range(n):\n if int(data[i][2]) == 1:\n if int(data[i][0]) > x_1:\n x_1 = int(data[i][0])\n elif int(data[i][2]) == 2:\n if int(data[i][0]) < x_2:\n x_2 = int(data[i][0])\n elif int(data[i][2]) == 3:\n if int(data[i][1]) > y_1:\n y_1 = int(data[i][1])\n else:\n if int(data[i][1]) < y_2:\n y_2 = int(data[i][1])\nif x_2 - x_1 <= 0 or y_2 - y_1 <= 0:\n print(0)\nelse:\n print((x_2 - x_1) * (y_2 - y_1))", "W,H,N=list(map(int,input().split()))\n\nans=[0,W,0,H]\n\nfor i in range(N):\n x,y,a=list(map(int,input().split()))\n if a==1:\n if ans[0]<x:\n ans[0]=x\n elif a==2:\n if ans[1]>x:\n ans[1]=x\n elif a==3:\n if ans[2]<y:\n ans[2]=y\n else:\n if ans[3]>y:\n ans[3]=y\n\nS=(ans[1]-ans[0])*(ans[3]-ans[2]) \n\nif (ans[1]-ans[0])<0:\n print((0))\nelif (ans[3]-ans[2])<0:\n print((0))\nelse:\n print(S)\n", "W, H, N = map(int,input().split()) \nl = 0; r = W; u = H; d = 0 \n\nfor i in range(N):\n x, y, a = map(int,input().split()) \n if a == 1:\n l = max(l,x) \n elif a == 2:\n r = min(r,x) \n elif a == 3:\n d = max(d,y) \n else:\n u = min(u,y) \n\nprint(max(0,(r-l))*max(u-d, 0)) ", "W, H, N = map(int, input().split())\nx, y, a = [0] * N, [0] * N, [0] * N\nfor i in range(N):\n x[i], y[i], a[i] = map(int, input().split())\n \nxmin = 0\nxmax = W\nymin = 0\nymax = H\n\nfor i in range(N):\n if a[i] == 1:\n xmin = max(x[i], xmin)\n elif a[i] == 2:\n xmax = min(x[i], xmax)\n elif a[i] == 3:\n ymin = max(y[i], ymin)\n else:\n ymax = min(y[i], ymax)\n\nheight = ymax - ymin\nwidth = xmax - xmin\n\nif height <= 0 or width <= 0:\n print(0)\nelse:\n print(height * width)", "W,H,N= list(map(int,input().split()))\nBlack = [[True for _ in range(W)] for i in range(H)]\nfor i in range(N):\n x,y,a = list(map(int,input().split()))\n for j in range(H):\n for k in range(W):\n if a == 1:\n if k < x:\n Black[j][k] = False\n elif a == 2:\n if k >= x:\n Black[j][k] = False\n elif a == 3:\n if j < y:\n Black[j][k] = False\n elif a == 4:\n if j >= y:\n Black[j][k] = False\n #print(Black)\n\nc = 0\n#print(Black)\nfor i in range(H):\n c += Black[i].count(True)\nprint(c)\n\n\n\n", "w, h, n = map(int, input().split())\n\nlist = [0, w, 0, h]\n\nfor i in range(n):\n x, y, a = map(int, input().split())\n if a == 1 and list[0] <= x:\n list[0] = x\n elif a == 2 and list[1] >= x:\n list[1] = x\n elif a == 3 and list[2] <= y:\n list[2] = y\n elif a == 4 and list[3] >= y:\n list[3] = y\n else:\n pass\n\nif list[0] > list[1] or list[2] > list[3]:\n print(0)\nelse:\n print((list[0] - list[1]) * (list[2] - list[3]))", "w, h, n = list(map(int, input().split()))\nsw = 0\nsh = 0\nfor _ in range(n):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n sw = max(sw, x)\n elif a == 2:\n w = min(w, x)\n elif a == 3:\n sh = max(sh, y)\n elif a == 4:\n h = min(h, y)\nif sw < w and sh < h:\n print(((w-sw) * (h-sh)))\nelse:\n print((0))\n", "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n#\n# FileName: \tB\n# CreatedDate: 2020-10-09 21:12:23 +0900\n# LastModified: 2020-10-09 21:32:50 +0900\n#\n\n\nimport os\nimport sys\nimport numpy as np\n# import pandas as pd\n\n\ndef main():\n W, H, N = list(map(int, input().split()))\n square = [[0, W], [0, H]]\n for _ in range(N):\n x, y, a = list(map(int, input().split()))\n if a == 1 and square[0][0] < x:\n square[0][0] = x\n\n elif a == 2 and square[0][1] > x:\n square[0][1] = x\n\n elif a == 3 and square[1][0] < y:\n square[1][0] = y\n\n elif a == 4 and square[1][1] > y:\n square[1][1] = y\n\n if square[0][0] >= square[0][1] or \\\n square[1][0] >= square[1][1]:\n print((0))\n return\n print(((square[0][1]-square[0][0])*(square[1][1]-square[1][0])))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "W, H, N = map(int, input().split())\narray = [list(map(int, input().split())) for i in range(N)]\n\nxmin = 0\nxmax = W\nymin = 0\nymax = H\nfor i in range(N):\n\n if array[i][2] == 1:\n xmin = max(xmin, array[i][0])\n elif array[i][2] == 2:\n xmax = min(xmax, array[i][0])\n elif array[i][2] == 3:\n ymin = max(ymin, array[i][1])\n elif array[i][2] == 4:\n ymax = min(ymax, array[i][1])\narea = (xmax-xmin)*(ymax-ymin)\nif area <= 0 or xmax < xmin or ymax < ymin:\n print(0)\nelse:\n print(area)", "#!/usr/bin/env python3\n\n\ndef main():\n W, H, N = list(map(int, input().split()))\n X = Y = 0\n for i in range(N):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n X = max(X, x)\n elif a == 2:\n W = min(W, x)\n elif a == 3:\n Y = max(Y, y)\n else:\n H = min(H, y)\n print((max(W - X, 0) * max(H - Y, 0)))\n\n\nmain()\n", "w, h, n = map(int, input().split())\nr, l, u, d = w, 0, h, 0\nfor _ in range(n):\n x, y, a = map(int, input().split())\n if a == 1:\n l = max(l, x)\n elif a == 2:\n r = min(r, x)\n elif a == 3:\n d = max(d, y)\n else:\n u = min(u, y)\nprint(max(0, r-l) * max(0, u-d))", "w,h,n=map(int,input().split())\nb=w\nc=h\nd=0\ne=0\nfor i in range(n):\n x,y,a=map(int,input().split())\n if a==1:\n d=max(x,d)\n elif a==2:\n b=min(x,b)\n elif a==3:\n e=max(y,e)\n elif a==4:\n c=min(y,c)\nif b<d or c<e:\n print(0)\nelse:\n print((b-d)*(c-e))", "\nurl = \"https://atcoder.jp//contests/abc047/tasks/abc047_b\"\n\ndef main():\n w, h, n = list(map(int, input().split()))\n xya = [list(map(int, input().split())) for _ in range(n)]\n x, y = [0, w], [0, h]\n for low in xya:\n if low[2] == 1 and x[0] < low[0]:\n x[0] = low[0]\n elif low[2] == 2 and x[1] > low[0]:\n x[1] = low[0]\n elif low[2] == 3 and y[0] < low[1]:\n y[0] = low[1]\n elif low[2] == 4 and y[1] > low[1]:\n y[1] = low[1]\n xs = x[1] - x[0]\n ys = y[1] - y[0]\n if xs < 0 or ys < 0:\n print((0))\n else:\n ans = xs * ys\n print(ans)\n\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "w, h, n = list(map(int, input().split()))\n\nsx = [0, w]\nsy = [0, h]\n\nfor i in range(n):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n sx[0] = max(sx[0], x)\n if a == 2:\n sx[1] = min(sx[1], x)\n if a == 3:\n sy[0] = max(sy[0], y)\n if a == 4:\n sy[1] = min(sy[1], y)\n\nprint((max(0, max(0, (sx[1] - sx[0])) * max(0, (sy[1] - sy[0])))))\n", "W, H, N = [int(x) for x in input().split()]\n\nx_min = 0\nx_max = W\ny_min = 0\ny_max = H\n\nfor i in range(N):\n x, y, a = [int(x) for x in input().split()]\n if a == 1:\n x_min = max(x_min, x)\n elif a == 2:\n x_max = min(x_max, x)\n elif a == 3:\n y_min = max(y_min, y)\n else: # a == 4\n y_max = min(y_max, y)\n\narea = max(0, x_max - x_min) * max(0, y_max - y_min)\n\nprint(area)", "whn = list(map(int, input().split()))\nw, h, n = whn[0], whn[1], whn[2]\nxyas = [list(map(int, input().split())) for _ in range(n)]\nc = [[1 for _ in range(h)] for _ in range(w)]\n# \u5857\u308a\u3064\u3076\u3055\u308c\u305f\u90e8\u5206\u30921\u306b\u3057\u3066\u3044\u304f\nfor xya in xyas:\n x, y, a = xya[0], xya[1], xya[2]\n if a == 1:\n for i in range(x):\n c[i] = [0 for _ in range(h)]\n elif a == 2:\n for i in range(x, w):\n c[i] = [0 for _ in range(h)]\n elif a == 3:\n for i in range(w):\n for j in range(y):\n c[i][j] = 0\n elif a == 4:\n for i in range(w):\n for j in range(y, h):\n c[i][j] = 0\n\nprint((sum([sum(c2) for c2 in c])))\n", "W,H,N=list(map(int,input().split()))\n\n# \u5de6\u4e0b\u306e\u5ea7\u6a19\nX=Y=0\n\nfor i in range(N):\n # \u5165\u529b\n x,y,a=list(map(int,input().split()))\n\n if a==1:\n X=max(X,x)\n elif a==2:\n W=min(W,x)\n elif a==3:\n Y=max(Y,y)\n else:\n H=min(H,y)\n\n# \u51fa\u529b\nprint((max(W-X,0)*max(H-Y,0)))\n \n", "w,h,n = map(int,input().split())\nchk = [0]*101\nwx = [1]*w\nwy = [1]*h\nfor _ in range(n):\n x,y,a = map(int,input().split())\n if a == 1:\n wx[:x] = chk[:x]\n elif a==2:\n wx[x:] = chk[x+1:w-1]\n elif a==3:\n wy[:y] = chk[:y]\n else:\n wy[y:] = chk[y+1:h-1]\nws = wx.count(1)*wy.count(1)\n\nprint(ws)", "w,h,n = map(int,input().split())\nb,c,d,e = 0,w,0,h\nfor i in range(n):\n x,y,a = map(int,input().split())\n if a == 1:\n b = max(b,x)\n elif a == 2:\n c = min(c,x)\n elif a == 3:\n d = max(d,y)\n else:\n e = min(e,y)\nprint(max(c-b,0)*max(e-d,0))", "w,h,n = list(map(int,input().split()))\nxl = []\nyl = []\nal = []\nfor _ in range(n):\n x,y,a = list(map(int,input().split()))\n xl.append(x)\n yl.append(y)\n al.append(a)\n\nsx = 0\ngx = w\nsy = 0\ngy = h\n\nfor i in range(len(al)):\n if al[i] == 1 and sx < xl[i]:\n sx = xl[i]\n if sx > gx:\n print((0))\n return\n elif al[i] == 2 and gx > xl[i]:\n gx = xl[i]\n if sx > gx:\n print((0))\n return\n elif al[i] == 3 and sy < yl[i]:\n sy = yl[i]\n if sy > gy:\n print((0))\n return\n elif al[i] == 4 and gy > yl[i]:\n gy = yl[i]\n if sy > gy:\n print((0))\n return\n if i == len(al)-1:\n print(((gx-sx)*(gy-sy)))\n \n", "w, h, n = map(int, input().split())\np = [0]\nq = [w]\nr = [0]\ns = [h]\nfor i in range(n):\n x, y, a = map(int, input().split())\n if a == 1:\n p.append(x)\n elif a == 2:\n q.append(x)\n elif a == 3:\n r.append(y)\n else:\n s.append(y)\nif max(p) <= min(q) and max(r) <= min(s):\n print((min(q) - max(p))*(min(s) - max(r)))\nelse:\n print(0)", "w,h,n=list(map(int,input().split()))\ni,j=0,0\nfor _ in range(n):\n x,y,a=list(map(int,input().split()))\n if a==1:\n i=max(i,x)\n elif a==2:\n w=min(w,x)\n elif a==3:\n j=max(j,y)\n else:\n h=min(h,y)\nprint(((w-i)*(h-j) if w>i and h>j else 0))\n", "w, h, n = list(map(int, input().split()))\nplots = [list(map(int, input().split())) for _ in range(n)]\n\nw_min, w_max, h_min, h_max = 0, w, 0, h\n\nfor i in range(n):\n if plots[i][2] == 1:\n w_min = max(w_min, plots[i][0])\n elif plots[i][2] == 2:\n w_max = min(w_max, plots[i][0])\n elif plots[i][2] == 3:\n h_min = max(h_min, plots[i][1])\n else:\n h_max = min(h_max, plots[i][1])\n\nprint((max(0, (w_max - w_min)) * max(0, (h_max - h_min))))\n", "w , h , n=map(int, input().split())\nW = [1]*w\nH = [1]*h\n\nfor i in range(n):\n x,y,a=map(int, input().split())\n if a == 1:\n for i in range(x):\n W[i] = 0\n if a == 2 :\n for i in range(x,w):\n W[i] = 0\n if a == 3:\n for i in range(y):\n H[i] = 0\n if a == 4:\n for i in range(y,h):\n H[i] = 0\nprint(sum(W)*sum(H))", "w,h,\uff4e = list(map(int, input().split()))\nans = [[0]*(w) for i in range(h)]\nfor i in range(n):\n x,y,a = list(map(int, input().split()))\n if a == 1:\n for i in range(x):\n for j in range(h):\n ans[j][i] = 1\n elif a == 2:\n for i in range(x,w):\n for j in range(h):\n ans[j][i] = 1\n elif a == 3:\n for i in range(w):\n for j in range(y):\n ans[j][i] = 1\n elif a == 4:\n for i in range(w):\n for j in range(y,h):\n ans[j][i] = 1\n\ncnt = 0\nfor i in ans:\n cnt += sum(i)\nprint((h*w - cnt))\n", "num_line = input().split(\" \")\nx_num = int(num_line[0])\ny_num = int(num_line[1])\nnum = int(num_line[2])\n\ntangle = [[1]*x_num for i in range(y_num)]\n\n#print(tangle)\n\nfor i in range(num):\n line = input().split(\" \")\n x_tem = int(line[0])\n y_tem = int(line[1])\n index = int(line[2])\n \n if(index == 1):\n for j in range(y_num):\n for k in range(x_tem):\n tangle[j][k] = 0\n #print(tangle) \n \n elif(index == 2):\n for j in range(y_num):\n for k in range(x_num - x_tem):\n tangle[j][k + x_tem] = 0\n #print(tangle)\n \n elif(index == 3):\n for j in range(y_tem):\n for k in range(x_num):\n tangle[j][k] = 0\n #print(tangle)\n \n else:\n for j in range(y_num - y_tem):\n for k in range(x_num):\n tangle[j + y_tem][k] = 0\n #print(tangle)\n \nresult = 0\nfor i in range(y_num):\n for j in range(x_num):\n result += tangle[i][j]\n \nprint(result)", "w, h, n = list(map(int, input().split()))\nans = [[0 for _ in range(w)] for _ in range(h)]\nfor i in range(n):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n for j in range(h):\n ans[j][:x] = [1 for _ in range(x)]\n if a == 2:\n for j in range(h):\n ans[j][x:] = [1 for _ in range(w-x)]\n if a == 3:\n for j in range(h-y,h):\n ans[j] = [1 for _ in range(w)]\n if a == 4:\n for j in range(h-y):\n ans[j] = [1 for _ in range(w)]\ncnt = 0\nfor k in ans:\n cnt += k.count(0)\nprint(cnt)\n", "import numpy as np\nW,H,N = list(map(int, input().split()))\nX = [[0 for _ in range(W)] for _ in range(H)]\nfor i in range(N):\n x,y,a = list(map(int,input().split()))\n if a == 1:#\u3088\u308a\u5de6\u9ed2\n for j in range(H):\n X[j][:x] = [1 for _ in range(x)]\n elif a == 2:\n for j in range(H):\n X[j][x:] = [1 for _ in range(W-x)]\n elif a == 3:#\u3088\u308a\u4e0b\u9ed2\n for j in range(H-y,H):\n X[j] = [1 for _ in range(W)]\n else:\n for j in range(H-y):\n X[j] = [1 for _ in range(W)]\nans = 0\nfor k in X:\n ans += k.count(0)\nprint(ans)\n", "import numpy as np\n\nW,H,N=map(int,input().split())\n\nX=Y=0\nfor i in range(N):\n x,y,a=map(int,input().split())\n\n if a==1:\n X=max(X,x)\n elif a==2:\n W=min(W,x)\n elif a==3:\n Y=max(Y,y)\n else:\n H=min(H,y)\n\nS=max((W-X),0)*max((H-Y),0)\n\nprint(S)", "w, h, n = map(int, input().split())\nl = [[0]*w for _ in range(h)]\ncount = 0\nfor _ in range(n):\n x, y, a = map(int, input().split())\n if a == 1:\n for i in range(h):\n for j in range(x):\n if l[i][j] == 0:\n l[i][j] = 1\n count += 1\n if a == 2:\n for i in range(h):\n for j in range(x,w):\n if l[i][j] == 0:\n l[i][j] = 1\n count += 1\n if a == 3:\n for i in range(y):\n for j in range(w):\n if l[i][j] == 0:\n l[i][j] = 1\n count += 1\n if a == 4:\n for i in range(y,h):\n for j in range(w):\n if l[i][j] == 0:\n l[i][j] = 1\n count += 1\n\nprint(w*h - count) ", "w,h,n=list(map(int,input().split()))\nox,oy=0,0\nfor i in range(n):\n x,y,a=list(map(int,input().split()))\n if a==1:\n if ox<x:\n ox=x\n elif a==2:\n if w>x:\n w=x\n elif a==3:\n if oy<y:\n oy=y\n else:\n if h>y:\n h=y\nprint((max(w-ox,0)*max(h-oy,0)))\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\n \ndef iparse():\n return list(map(int, input().split()))\n\n\ndef __starting_point():\n w, h, n = iparse()\n xmax = w\n xmin = 0\n ymin = 0\n ymax = h\n for i in range(n):\n x, y, a = iparse()\n \n if a == 1:\n xmin = max(xmin,x)\n if a == 2:\n xmax = min(xmax,x)\n if a == 3:\n ymin = max(ymin,y)\n if a == 4:\n ymax = min(ymax,y)\n \n print((max(xmax-xmin,0)*(max(0,ymax-ymin))))\n__starting_point()", "import numpy as np\nw, h, n = map(int, input().split())\nloc = [input() for _ in range(n) ]\n\ndef black(x, y, i):\n if i == 1:\n mtx[:x,] = 0\n elif i == 2:\n mtx[x:,] = 0\n elif i == 3:\n mtx[:, :y] = 0\n elif i == 4:\n mtx[:, y:] = 0\n\n \nmtx = np.ones((w, h), dtype=int)\nfor l in loc:\n x, y, i = map(int, l.split())\n black(x, y, i)\nprint(mtx.sum())", "w,h,n=map(int,input().split())\na=[[int(i)for i in input().split()]for j in range(n)]\nS=[[0,w],[0,h]]\nfor i in a:\n if i[2]==1:\n S[0][0]=max(i[0],S[0][0])\n\n if i[2]==2:\n S[0][1]=min(i[0],S[0][1])\n\n if i[2]==3:\n S[1][0]=max(i[1],S[1][0])\n\n if i[2]==4:\n S[1][1]=min(i[1],S[1][1])\n\nans=max(0,(S[0][1]-S[0][0]))*max(0,(S[1][1]-S[1][0]))\nprint(ans)", "W, H, N = [int(x) for x in input().split()]\nx_min, x_max, y_min, y_max = 0, W, 0, H\nnum_lists = [[int(x) for x in input().split()] for _ in range(N)]\n\nfor num_list in num_lists:\n if num_list[2] == 1 and num_list[0] > x_min:\n x_min = num_list[0]\n if num_list[2] == 2 and num_list[0] < x_max:\n x_max = num_list[0]\n if num_list[2] == 3 and num_list[1] > y_min:\n y_min = num_list[1]\n if num_list[2] == 4 and num_list[1] < y_max:\n y_max = num_list[1]\n\nif x_min > x_max or y_min > y_max:\n print(0)\nelse:\n print((x_max-x_min)*(y_max-y_min))", "from typing import List\n\n\ndef answer(w: int, h: int, n: int, xyas: List[List[int]]) -> int:\n bottom_left_corner_of_white = {'x': 0, 'y': 0}\n top_right_corner_of_white = {'x': w, 'y': h}\n\n for xya in xyas:\n x, y, a = xya\n if a == 1:\n if bottom_left_corner_of_white['x'] < x:\n bottom_left_corner_of_white['x'] = x\n if a == 2:\n if x < top_right_corner_of_white['x']:\n top_right_corner_of_white['x'] = x\n if a == 3:\n if bottom_left_corner_of_white['y'] < y:\n bottom_left_corner_of_white['y'] = y\n if a == 4:\n if y < top_right_corner_of_white['y']:\n top_right_corner_of_white['y'] = y\n\n width_of_white = max(0, top_right_corner_of_white['x'] - bottom_left_corner_of_white['x'])\n height_of_white = max(0, top_right_corner_of_white['y'] - bottom_left_corner_of_white['y'])\n\n return width_of_white * height_of_white\n\n\ndef main():\n w, h, n = map(int, input().split())\n xyas = [list(map(int, input().split())) for _ in range(n)]\n print(answer(w, h, n, xyas))\n\n\ndef __starting_point():\n main()\n__starting_point()", "w, h, n = list(map(int, input().split()))\n\ns_w = [0, w]\ns_h = [0, h]\nfor _ in range(n):\n x, y, a = list(map(int, input().split()))\n if a == 1 and x > s_w[0]:\n s_w[0] = x\n elif a == 2 and x < s_w[1]:\n s_w[1] = x\n elif a == 3 and y > s_h[0]:\n s_h[0] = y\n elif a == 4 and y < s_h[1]:\n s_h[1] = y\n\nans_w = s_w[1] - s_w[0]\nans_h = s_h[1] - s_h[0]\nprint((ans_w * (ans_w > 0)) * (ans_h * (ans_h > 0)))", "import sys\nimport math\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\n\nw, h, n = inintm()\n\nll = [0,0]\nrh = [w,h]\n\nfor i in range(n):\n x, y, a = inintm()\n if a == 1:\n ll[0] = max(ll[0], x)\n elif a == 2:\n rh[0] = min(rh[0], x)\n elif a == 3:\n ll[1] = max(ll[1], y)\n else:\n rh[1] = min(rh[1], y)\n\nif rh[0]-ll[0] < 0 or rh[1]-ll[1] < 0:\n print(0)\nelse:\n print((rh[0]-ll[0])*(rh[1]-ll[1]))", "w,h,n = map(int, input().split())\nl,r,d,u = (0,w,0,h)\nfor i in range(n):\n x,y,a = map(int, input().split())\n if a == 1:\n l = max(l,x)\n elif a == 2:\n r = min(r,x)\n elif a == 3:\n d = max(d,y)\n else:\n u = min(u,y)\nprint((r-l)*(u-d) if r>l and u>d else 0)", "import sys\n\ninput = sys.stdin.readline\n\ndef main():\n W, H, N = list(map(int, input().split()))\n X = [0, W]\n Y = [0, H]\n for i in range(N):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n X[0] = max(x, X[0])\n elif a == 2:\n X[1] = min(x, X[1])\n elif a == 3:\n Y[0] = max(y, Y[0])\n else:\n Y[1] = min(y, Y[1])\n if X[1] <= X[0] or Y[1] <= Y[0]:\n ans = 0\n else:\n ans = (X[1] - X[0]) * (Y[1] - Y[0])\n print(ans)\n\ndef __starting_point():\n main()\n\n__starting_point()", "w, h, n = map(int, input().split())\nright, left, lower, upper = 0, w, 0, h\nfor _ in range(n):\n x, y, a = map(int, input().split())\n if a == 1:\n right = max(right, x)\n if a == 2:\n left = min(left, x)\n if a == 3:\n lower = max(lower, y)\n if a == 4:\n upper = min(upper, y)\n\na = left - right\nb = upper - lower\n\nif a <= 0 or b <= 0:\n print(0)\nelse:\n print(a*b)", "W,H,N = (int(T) for T in input().split())\nXYA = [[0],[W],[0],[H]]\nfor TN in range(0,N):\n X,Y,A = (int(T) for T in input().split())\n if A in [1,2]:\n XYA[A-1].append(X)\n else:\n XYA[A-1].append(Y)\nCW = min(XYA[1])-max(XYA[0])\nCH = min(XYA[3])-max(XYA[2])\nif CW>=0 and CH>=0:\n print(CW*CH)\nelse:\n print(0)", "#\n# abc047 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 4 2\n2 1 1\n3 3 4\"\"\"\n output = \"\"\"9\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"5 4 3\n2 1 1\n3 3 4\n1 4 2\"\"\"\n output = \"\"\"0\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\"\"\"\n output = \"\"\"64\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n W, H, N = list(map(int, input().split()))\n a = []\n ox = 0\n oy = 0\n for _ in range(N):\n a.append(list(map(int, input().split())))\n for i in range(N):\n if a[i][2] == 1:\n ox = max(a[i][0], ox)\n elif a[i][2] == 2:\n W = min(a[i][0], W)\n elif a[i][2] == 3:\n oy = max(a[i][1], oy)\n elif a[i][2] == 4:\n H = min(a[i][1], H)\n print((max(W-ox, 0)*max(H-oy, 0)))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "w, h, n = map(int, input().split())\nx_pos = [0, w]\ny_pos = [0, h]\nfor _ in range(n):\n x, y, a = map(int, input().split())\n if a == 1:\n x_pos[0] = max(x_pos[0], x)\n elif a == 2:\n x_pos[1] = min(x_pos[1], x)\n elif a == 3:\n y_pos[0] = max(y_pos[0], y)\n else:\n y_pos[1] = min(y_pos[1], y)\nif x_pos[1] - x_pos[0] < 0 or y_pos[1] - y_pos[0] < 0:\n ans = 0\nelse:\n ans = (x_pos[1] - x_pos[0] ) * (y_pos[1] - y_pos[0])\nprint(ans)", "W,H,N=map(int, input().split())\nX=[0,W]\nY=[0,H]\n\nfor i in range(N):\n x,y,a = map(int, input().split())\n if a==1:\n X[0]=max(x, X[0])\n elif a==2:\n X[1]=min(x, X[1])\n elif a==3:\n Y[0]=max(y, Y[0])\n else:\n Y[1]=min(y, Y[1])\n\nif X[1]-X[0]<=0 or Y[1]-Y[0]<=0:\n area=0\nelse:\n area = max(0,(X[1]-X[0])*(Y[1]-Y[0]))\nprint(area)", "w, h, n = map(int, input().split())\nb = [0, 0]\nc = [w, h]\nfor _ in range(n):\n x, y, a = map(int, input().split())\n if a == 1:\n if b[0] < x:\n b[0] = x\n elif a == 2:\n if c[0] > x:\n c[0] = x\n elif a == 3:\n if b[1] < y:\n b[1] = y\n else:\n if c[1] > y:\n c[1] = y\nd = max(0, (c[0] - b[0])) * max(0, (c[1] - b[1]))\nprint(d)", "W, H, N = map(int, input().split())\nu, U, v, V = 0, W, 0, H\nfor _ in range(N):\n x, y, a = map(int,input().split())\n if a == 1:\n u = max(u,x)\n if a == 2:\n U = min(U,x)\n if a == 3:\n v = max(v,y)\n if a == 4:\n V = min(V,y)\nf = lambda x:x if x > 0 else 0\nprint(f(U-u)*f(V-v))", "W,H,N = map(int,input().split())\n\na1,a2,a3,a4 = -1,101,-1,101\nfor i in range(N):\n x,y,a = map(int,input().split())\n if a == 1:\n a1 = max(a1,x)\n elif a == 2:\n a2 = min(a2,x-1)\n elif a == 3:\n a3 = max(a3,y)\n else:\n a4 = min(a4,y-1)\n \nmass = [[0 for _ in range(W)] for _ in range(H)]\nfor i in range(H):\n for j in range(W):\n if i < a3 or a4 < i:\n mass[i][j] += 1\n if j < a1 or a2 < j:\n mass[i][j] += 1\n \ncnt = 0\nfor k in mass:\n cnt += k.count(0)\n \nprint(cnt)", "W,H,N=map(int,input().split())\nvalues=[[0],[W],[0],[H]]\nfor i in range(N):\n x,y,a=(map(int,input().split()))\n if a<=2:\n values[a-1].append(x)\n elif a>=3:\n values[a-1].append(y)\nprint(max(0,min(values[1])-max(values[0]))*max(0,min(values[3])-max(values[2])))", "w, h, n = map(int,input().split())\n\nxl, xr = 0, w\nyl, yu = 0, h\nfor i in range(n):\n x, y, a = map(int,input().split())\n if a == 1:\n xl = max(xl, x)\n elif a == 2:\n xr = min(xr, x)\n elif a == 3:\n yl = max(yl, y)\n else:\n yu = min(yu, y)\n \nprint((xr-xl)*(yu-yl)) if xl < xr and yl < yu else print(0)", "w, h, n = map(int, input().split())\n\nx = [0] * n\ny = [0] * n\na = [0] * n\n\nfor i in range(n):\n x[i], y[i], a[i] = map(int, input().split())\n\nw_l = 0\nh_l = 0\nfor i in range(n):\n if a[i] == 1:\n if w_l < x[i]:\n w_l = x[i]\n elif a[i] == 2:\n if w > x[i]:\n w = x[i]\n elif a[i] == 3:\n if h_l < y[i]:\n h_l = y[i]\n elif a[i] == 4:\n if h > y[i]:\n h = y[i]\nW = w - w_l\nH = h - h_l\nif W < 0 or H < 0:\n ans = 0\nelse:\n ans = W * H\nprint(ans)", "H,W,N=map(int,input().split())\nsita,hidari=0,0\nue,migi=W,H\nfor i in range(N):\n x,y,a=map(int,input().split())\n if a==1:\n hidari=max(x,hidari)\n elif a==2:\n migi=min(migi,x)\n elif a==3:\n sita=max(sita,y)\n else:\n ue=min(ue,y)\nprint(max(0,(migi-hidari))*max(0,(ue-sita)))", "W, H, N = map(int, input().split())\nxya = [list(map(int, input().split())) for i in range(N)]\nX=Y=0\nfor i in range(N):\n if xya[i][2] == 1:\n X = max(X,xya[i][0])\n if xya[i][2] == 2:\n W = min(W,xya[i][0])\n if xya[i][2] == 3:\n Y = max(Y,xya[i][1])\n if xya[i][2] == 4:\n H = min(H,xya[i][1])\nprint(max(W-X,0)*max(H-Y,0))", "def main():\n W,H,N = list(map(int,input().split()))\n X = 0 #a=1\u521d\u671f\u5024\n Y = 0 #a=3\u521d\u671f\u5024\n for _ in range(N):\n x,y,a = list(map(int,input().split()))\n if a == 1:\n X = max(X,x)\n elif a == 2:\n W = min(W,x)\n elif a == 3:\n Y = max(Y,y)\n elif a == 4:\n H = min(H,y)\n #S\u3092\u6c42\u3081\u308b\n S = max((W-X),0) * max((H-Y),0)\n print(S)\ndef __starting_point():\n main()\n\n\n__starting_point()", "w,h,n = map(int, input().split())\ns = [[1 for i in range(w)] for j in range(h)]\nb = [[1,2,3,4,5],[6,7,8,9,10]]\nalist = []\nfor i in range(n):\n x,y,a = map(int, input().split())\n alist.append(a)\n if a == 1:\n for j in range(h):\n for k in range(0,x):\n s[j][k] = 0\n if a == 2:\n for j in range(h):\n for k in range(x,w):\n s[j][k] = 0\n if a == 3:\n for k in range(w):\n for j in range(0,y):\n s[j][k] = 0\n if a == 4:\n for k in range(w):\n for j in range(y,h):\n s[j][k] = 0\nans = 0\nfor i in range(h):\n ans = ans + s[i].count(1)\nprint(ans)", "W, H, N = map(int, input().split())\nx = []\ny = []\na = []\nX = [1]*W\nY = [1]*H\nans = 0\nfor _ in range(N):\n i, j, k = map(int, input().split())\n x.append(i)\n y.append(j)\n a.append(k)\nfor i in range(N):\n if a[i] == 1:\n for j in range(x[i]):\n X[j] = 0\n elif a[i] == 2:\n for j in range(x[i], W):\n X[j] = 0\n elif a[i] == 3:\n for j in range(y[i]):\n Y[j] = 0\n else:\n for j in range(y[i], H):\n Y[j] = 0\nfor i in range(H):\n for j in range(W):\n if X[j] and Y[i]:\n ans += 1\nprint(ans)", "X, Y, N = list(map(int, input().split()))\nlst = [[0 for i in range(X)] for j in range(Y)]\n\nfor i in (list(range(N))):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n for j in range(Y):\n for k in range(x):\n lst[j][k] = 1\n elif a == 2:\n for j in range(Y):\n for k in range(X-1, x-1, -1):\n lst[j][k] = 1\n elif a == 3:\n for j in range(y):\n for k in range(X):\n lst[j][k] = 1\n elif a == 4:\n for j in range(Y-1, y-1, -1):\n for k in range(X):\n lst[j][k] = 1\n\ncount = 0\nfor i in lst:\n count += i.count(0)\nprint(count)\n\n", "import sys\ninput = sys.stdin.readline\n\n\ndef read():\n W, H, N = list(map(int, input().strip().split()))\n XYA = []\n for i in range(N):\n x, y, a = list(map(int, input().strip().split()))\n XYA.append((x, y, a))\n return W, H, N, XYA\n\n\ndef solve(W, H, N, XYA):\n S = [[0 for j in range(W+1)] for i in range(H+1)]\n for x, y, a in XYA:\n if a == 1:\n lt, rt, lb, rb = (0, 0), (x, 0), (0, H), (x, H)\n elif a == 2:\n lt, rt, lb, rb = (x, 0), (W, 0), (x, H), (W, H)\n elif a == 3:\n lt, rt, lb, rb = (0, 0), (W, 0), (0, y), (W, y)\n elif a == 4:\n lt, rt, lb, rb = (0, y), (W, y), (0, H), (W, H)\n S[lt[1]][lt[0]] += 1\n S[rt[1]][rt[0]] -= 1\n S[lb[1]][lb[0]] -= 1\n S[rb[1]][rb[0]] += 1\n \n for i in range(H):\n for j in range(W+1):\n S[i+1][j] += S[i][j]\n for i in range(H+1):\n for j in range(W):\n S[i][j+1] += S[i][j]\n \n ans = 0\n for i in range(H):\n for j in range(W):\n if S[i][j] == 0:\n ans += 1\n return ans\n\n\ndef __starting_point():\n inputs = read()\n print((solve(*inputs)))\n\n__starting_point()", "w, h, n = map(int, input().split())\nl, r, t, b = 0, w, h, 0\nfor i in range(n):\n x, y, a = map(int, input().split())\n if a == 1:\n l = max(x, l)\n elif a == 2:\n r = min(x, r)\n elif a == 3:\n b = max(y, b)\n else:\n t = min(y, t)\nif (r - l) <= 0 or (t - b) <= 0:\n print(0)\nelse:\n print((r - l) * (t - b))", "w,h,n=map(int,input().split())\nansw=set(range(w+1)) \nansh=set(range(w+1))\nfor i in range(n):\n x,y,a=map(int,input().split())\n if a==1:\n answ=answ & set(range(x,w+1))\n elif a==2:\n answ=answ & set(range(x+1))\n elif a==3:\n ansh=ansh & set(range(y,h+1))\n elif a==4:\n ansh=ansh & set(range(y+1))\nif len(answ) == 0 or len(ansh)==0:\n print(0)\nelse:\n print((max(answ)-min(answ))*(max(ansh)-min(ansh)))", "w,h,n = [int(x) for x in input().split()]\na = []\nfor i in range(n):\n a.append([int(x) for x in input().split()])\n\nmp = [[0] * h for x in range(w)]\n\nfor i in range(n):\n if a[i][2] == 1:\n for j in range(a[i][0]):\n for k in range(h):\n mp[j][k] = 1\n elif a[i][2] == 2:\n for j in range(a[i][0],w):\n for k in range(h):\n mp[j][k] = 1\n elif a[i][2] == 3:\n for j in range(w):\n for k in range(a[i][1]):\n mp[j][k] = 1\n elif a[i][2] == 4:\n for j in range(w):\n for k in range(a[i][1],h):\n mp[j][k] = 1\n\nres = 0\nfor i in range(w):\n for j in range(h):\n if mp[i][j] == 0:\n res += 1\n\nprint(res)", "W, H, N = list(map(int, input().split()))\ninput_list = []\nfor i in range(N):\n input_list.append(list(map(int, input().split())))\n\npoint_list = []\nfor h in range(H):\n list_ = []\n for w in range(W):\n list_.append(1)\n point_list.append(list_)\n\nfor input_ in input_list:\n x, y, a = input_\n if a == 1:\n for h in range(H):\n for i in range(x):\n point_list[h][i] = 0\n if a == 2:\n for h in range(H):\n for i in range(x, W):\n point_list[h][i] = 0\n if a == 3:\n for i in range(y):\n for w in range(W):\n point_list[i][w] = 0\n if a == 4:\n for i in range(y, H):\n for w in range(W):\n point_list[i][w] = 0\n\nans = sum([sum(point) for point in point_list])\nprint(ans)\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 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############################################################\nW, H, N = lint()\nqueue = lint_list(N)\n\nxmin = max([x for x, y, a in queue if a == 1] + [0])\nxmax = min([x for x, y, a in queue if a == 2] + [W])\nymin = max([y for x, y, a in queue if a == 3] + [0])\nymax = min([y for x, y, a in queue if a == 4] + [H])\n\nprint(max(0, xmax - xmin) * max(0, ymax - ymin))", "W,H,N=list(map(int,input().split()))\nwhite=[[1 for _ in range(H)] for _ in range(W)]\n\nfor i in range(N):\n x,y,a=list(map(int,input().split()))\n if a==1:\n for i in range(x):\n for j in range(H):\n white[i][j]=0\n elif a==2:\n for i in range(x,W):\n for j in range(H):\n white[i][j]=0\n elif a==3:\n for i in range(W):\n for j in range(y):\n white[i][j]=0\n else:\n for i in range(W):\n for j in range(y,H):\n white[i][j]=0\nprint((sum(sum(x) for x in white)))\n", "W, H, N = list(map(int, input().split()))\n\nmax_x = 0\nmax_y = 0\nmin_x = W\nmin_y = H\nfor i in range(N):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n max_x = max(max_x, x)\n elif a == 2:\n min_x = min(min_x, x)\n elif a == 3:\n max_y = max(max_y, y)\n else:\n min_y = min(min_y, y)\n\n# print(max_x, max_y)\n# print(min_x, min_y)\nif(min_x > max_x) and (min_y > max_y):\n print(((min_x - max_x) * (min_y - max_y)))\nelse:\n print((0))\n", "W, H, N = list(map(int, input().split()))\nX = []\nY = []\nA = []\nfield = [[0] * W for _ in range(H)]\nfor i in range(N):\n x, y, a = list(map(int, input().split()))\n X.append(x)\n Y.append(y)\n A.append(a)\n\nfor i in range(N):\n if A[i] == 1:\n for j in range(X[i]):\n for k in range(H):\n field[k][j] = 1\n elif A[i] == 2:\n for j in range(X[i], W):\n for k in range(H):\n field[k][j] = 1\n elif A[i] == 3:\n for j in range(W):\n for k in range(Y[i]):\n field[k][j] = 1\n else:\n for j in range(W):\n for k in range(Y[i], H):\n field[k][j] = 1\n\nSum = 0\nfor i in range(W):\n for j in range(H):\n if field[j][i] == 0:\n Sum += 1\n\nprint(Sum)\n", "w,h,n=map(int,input().split())\na=[[int(i) for i in input().split()] for i in range(n)]\n \nx,y=0,0\nfor s,t,u in a:\n if u==1:\n x=max(x,s)\n elif u==2:\n w=min(w,s)\n elif u==3:\n y=max(y,t)\n else:\n h=min(h,t)\nheight=max(0,h-y)\nwidth=max(0,w-x)\nprint(height*width)", "w,h,n=list(map(int, input().split())) #\u521d\u671f\u5024\nlx=0\nly=0\nrx=w\nry=h\n\nfor i in range(n):\n x,y,a=list(map(int, input().split()))\n \n if a==1:\n if lx<x:\n lx=x\n elif a==2:\n if rx>x:\n rx=x\n \n elif a==3:\n if ly<y:\n ly=y\n \n else:\n if ry>y:\n ry=y\n# \u51fa\u529b\nprint((max(rx-lx,0)*max(ry-ly,0)))\n", "# -*- coding: utf-8 -*-\n\nW, H, N = list(map(int, input().split()))\nxs = ys = 0\nxe = W\nye = H\nfor i in range(N):\n x, y, a = list(map(int, input().split()))\n if a == 1 and x > xs:\n xs = x\n elif a == 2 and x < xe:\n xe = x\n elif a == 3 and y > ys:\n ys = y\n elif a == 4 and y < ye:\n ye = y\n\nw = xe - xs\nh = ye - ys\nif w > 0 and h > 0:\n ans = w * h\nelse:\n ans = 0\n\nprint(ans)\n", "w, h, n = map(int, input().split())\nx, y, a = [], [], []\nfor i in range(n):\n X, Y, A = map(int, input().split())\n x.append(X)\n y.append(Y)\n a.append(A)\nzahyou = [[1 for _ in range(h)] for __ in range(w)]\n\ndef m1(d):\n for i in range(d):\n for j in range(h):\n zahyou[i][j] = 0\n\ndef m2(d):\n for i in range(w-d):\n for j in range(h):\n zahyou[i+d][j] = 0\n\ndef m3(d):\n for i in range(w):\n for j in range(d):\n zahyou[i][j] = 0\n\ndef m4(d):\n for i in range(w):\n for j in range(h-d):\n zahyou[i][j+d] = 0\n\nfor i in range(n):\n if a[i] == 1:\n m1(x[i])\n elif a[i] == 2:\n m2(x[i])\n elif a[i] == 3:\n m3(y[i])\n else:\n m4(y[i])\n\nprint(sum(map(sum,zahyou)))", "w, h, n = map(int, input().split())\nW = [1] * w\nH = [1] * h\n\nfor i in range(n):\n x, y, a = map(int, input().split())\n if a == 1:\n for j in range(x):\n W[j] = 0\n elif a == 2:\n for j in range(x, w):\n W[j] = 0\n elif a == 3:\n for j in range(y):\n H[j] = 0\n elif a == 4:\n for j in range(y, h):\n H[j] = 0\nprint(sum(W) * sum(H))", "W,H,N = list(map(int, input().split()))\nm = [[0]*W]*H\nimport numpy as np\narr = np.array(m)\n\nfor i in range(N):\n x, y, a = list(map(int, input().split()))\n if a == 1:\n arr[:,:x] = 1\n if a == 2:\n arr[:, x:] = 1\n if a == 3:\n arr[H - y:,:] = 1\n if a == 4:\n arr[:H-y,:] = 1\nprint((np.count_nonzero(arr == 0)))\n\n", "w, h, n = map(int, input().split())\nquery = [tuple(map(int, input().split())) for _ in range(n)]\n\nsx, sy = 0, 0\nfor x, y, a in query:\n if a == 1:\n sx = max(sx, x)\n elif a == 2:\n w = min(w, x)\n elif a == 3:\n sy = max(sy, y)\n else:\n h = min(h, y)\nprint(max(0, w - sx) * max(0, h - sy))", "import numpy as np\n\nw, h, n = list(map(int, input().split()))\narea = np.zeros((w, h))\n\nfor i in range(n):\n x, y, a = list(map(int, input().split()))\n if a==1:\n area[:x, :] = 1\n elif a==2:\n area[x:, :] = 1\n elif a==3:\n area[:, :y] = 1\n else:\n area[:, y:] = 1\n\nprint(((w*h) - int(area.sum())))\n", "import numpy as np\n\nw,h,n = map(int,input().split())\nb = np.zeros((h,w),dtype=np.int)\n\nfor i in range(n):\n x,y,a = map(int,input().split())\n if a == 1:\n b[:,:x] = 1\n elif a == 2:\n b[:,x:] = 1\n elif a == 3:\n b[:y,:] = 1\n else:\n b[y:,:] = 1\nprint(np.count_nonzero(b < 1))"]
{"inputs": ["5 4 2\n2 1 1\n3 3 4\n", "5 4 3\n2 1 1\n3 3 4\n1 4 2\n", "10 10 5\n1 6 1\n4 1 3\n6 9 4\n9 4 2\n3 1 3\n"], "outputs": ["9\n", "0\n", "64\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
52,702
196df35e80b703daf6eb0502b48f4eb1
UNKNOWN
A railroad running from west to east in Atcoder Kingdom is now complete. There are N stations on the railroad, numbered 1 through N from west to east. Tomorrow, the opening ceremony of the railroad will take place. On this railroad, for each integer i such that 1≀i≀N-1, there will be trains that run from Station i to Station i+1 in C_i seconds. No other trains will be operated. The first train from Station i to Station i+1 will depart Station i S_i seconds after the ceremony begins. Thereafter, there will be a train that departs Station i every F_i seconds. Here, it is guaranteed that F_i divides S_i. That is, for each Time t satisfying S_i≀t and tοΌ…F_i=0, there will be a train that departs Station i t seconds after the ceremony begins and arrives at Station i+1 t+C_i seconds after the ceremony begins, where AοΌ…B denotes A modulo B, and there will be no other trains. For each i, find the earliest possible time we can reach Station N if we are at Station i when the ceremony begins, ignoring the time needed to change trains. -----Constraints----- - 1≀N≀500 - 1≀C_i≀100 - 1≀S_i≀10^5 - 1≀F_i≀10 - S_iοΌ…F_i=0 - All input values are integers. -----Input----- Input is given from Standard Input in the following format: N C_1 S_1 F_1 : C_{N-1} S_{N-1} F_{N-1} -----Output----- Print N lines. Assuming that we are at Station i (1≀i≀N) when the ceremony begins, if the earliest possible time we can reach Station N is x seconds after the ceremony begins, the i-th line should contain x. -----Sample Input----- 3 6 5 1 1 10 1 -----Sample Output----- 12 11 0 We will travel from Station 1 as follows: - 5 seconds after the beginning: take the train to Station 2. - 11 seconds: arrive at Station 2. - 11 seconds: take the train to Station 3. - 12 seconds: arrive at Station 3. We will travel from Station 2 as follows: - 10 seconds: take the train to Station 3. - 11 seconds: arrive at Station 3. Note that we should print 0 for Station 3.
["def LIHW(h):\n return [list(map(int, input().split())) for _ in range(h)]\n\n\nN = int(input())\nX = LIHW(N-1)\n\nfor i in range(N-1):\n time = [0]*N\n time[i] = X[i][1]+X[i][0]\n for j in range(i+1, N-1):\n if time[j-1] <= X[j][1]:\n time[j] = X[j][1]+X[j][0]\n else:\n if (time[j-1]-X[j][1]) % X[j][2] == 0:\n time[j] = time[j-1] + X[j][0]\n else:\n time[j] = time[j-1] + X[j][0]+X[j][2] - \\\n ((time[j-1]-X[j][1]) % X[j][2])\n print(time[j])\nprint(0)", "N = int(input())\n\nCSF = []\nfor _ in range(N-1):\n C, S, F = map(int, input().split())\n CSF.append((C, S, F))\n\ndef cnt(x):\n ret = 0\n for i in range(x, N-1):\n C, S, F = CSF[i]\n if ret < S:\n ret = S\n ret += C\n else:\n ret = -(-ret//F)*F\n ret += C\n return ret\n\nfor x in range(N):\n print(cnt(x))", "N = int(input())\nCSF = [list(map(int, input().split())) for i in range(N - 1)]\nans = []\nfor i in range(N - 1):\n temp = 0\n for j in range(i, N - 1):\n c, s, f = CSF[j][0], CSF[j][1], CSF[j][2]\n if temp <= s:\n temp += s - temp\n temp += temp % f\n else:\n temp += (f - ((temp - s) % f)) % f\n temp += c\n ans.append(temp)\nfor i in range(N - 1):\n print((ans[i]))\nprint((0))\n", "n = int(input())\nl = [list(map(int,input().split())) for i in range(n-1)]\nc,s,f = [list(i) for i in zip(*l)]\nfor _ in range(n-1):\n ans = 0\n for i in range(_,n-1):\n if ans < s[i]:\n ans = s[i]\n elif ans % f[i] == 0:\n pass\n else:\n ans += f[i] - (ans % f[i])\n ans += c[i]\n print(ans)\nprint(0)", "n = int(input())\ncsf = [list(map(int,input().split())) for _ in range(n-1)]\n\nfor i in range(n):\n time = 0\n while True:\n if i == n-1:\n print(time)\n break\n if csf[i][1] <= time and time%csf[i][2] == 0:\n time += csf[i][0]\n elif csf[i][1] > time:\n time = csf[i][1] + csf[i][0]\n else:\n time += csf[i][2] - time%csf[i][2] + csf[i][0]\n i += 1", "N = int(input())\nC = [0] * N\nS = [0] * N\nF = [0] * N\n\nfor i in range(N-1):\n C[i], S[i], F[i] = map(int, input().split())\n\ndef arrive(st):\n time = C[st] + S[st]\n for i in range(st + 1, N-1):\n if time <= S[i]:\n time = C[i] + S[i]\n else:\n if time % F[i] != 0:\n time = time + C[i] + (F[i] - time % F[i])\n else:\n time = time + C[i]\n return time\n\nfor i in range(N-1):\n print(arrive(i))\nprint(\"0\")", "\ndef main():\n with open(0) as f:\n N = int(f.readline())\n train = [tuple(map(int, line.split())) for line in f.readlines()]\n \n ans = []\n for start in range(N-1):\n arrive = 0\n for station in range(start, N-1):\n c, s, f = train[station]\n #\u51fa\u767a\u6642\u9593:\u533a\u9593[arrive,)\u306e\u4e0b\u9650 \n departure = lambda arrive:(arrive+f-1)//f*f if arrive >= s else s\n arrive = departure(arrive) + c\n ans.append(arrive)\n ans.append(0)\n for x in ans: print(x)\n\nmain()\n", "n = int(input())\nT = [0]*n\nc,s,f = [0]*(n-1),[0]*(n-1),[0]*(n-1)\n \nfor i in range(n-1):\n\tc[i],s[i],f[i] = map(int,input().split())\n\nfor\ti in range(n-1):\n\tT[i] = s[i] + c[i]\n\tfor j in range(i+1,n-1):\n\t\tif T[i] > s[j]:\n\t\t\tT[i] = -((-T[i]//f[j]))*f[j] + c[j]\n\t\telse:\n\t\t\tT[i] = s[j] + c[j]\n\tprint(T[i])\nprint(0)", "n=int(input())\nt=[]\nfor i in range(n-1):\n t.append(list(map(int,input().split())))\n\n\nfor i in range(n):\n s=0\n for j in range(i,n-1):\n s=max(t[j][1],((s-1)//t[j][2]+1)*t[j][2])+t[j][0]\n print(s)", "N = int(input())\nC = []\nS = []\nF = []\nfor _ in range(N-1):\n c, s, f = map(int, input().split())\n C.append(c)\n S.append(s)\n F.append(f)\n\nfor i in range(N):\n t = 0\n for j in range(i, N-1):\n if t < S[j]:\n t = S[j]\n elif t % F[j] != 0:\n t += F[j]-t%F[j]\n t += C[j]\n print(t)", "N = int(input())\n\nx = []\nfor i in range(N - 1):\n c, s, f = list(map(int, input().split()))\n x.append([c, s, f])\n\nans = []\nfor i in range(N - 1):\n t = x[i][0] + x[i][1]\n for j in range(i + 1, N - 1):\n if t % x[j][2] == 0:\n t = max(t, x[j][1])\n else:\n t = max(t + (x[j][2] - t % x[j][2]), x[j][1])\n t += x[j][0]\n ans.append(t)\nans.append(0)\n\nfor i in range(N):\n print((ans[i]))\n", "from math import ceil\n\nn = int(input())\ncs = []\nss = []\nfs = []\n\nfor _ in range(n-1):\n c, s, f = map(int, input().split())\n cs.append(c)\n ss.append(s)\n fs.append(f)\n\nfor i in range(n):\n t = 0\n for j in range(i, n-1):\n if t < ss[j]:\n t = ss[j]\n t = ceil(t / fs[j]) * fs[j]\n t += cs[j]\n print(t)", "n = int(input())\ncsf = []\nfor i in range(n - 1):\n csf.append(list(map(int, input().split())))\nfor i in range(n):\n t = 0\n for j in range(n - i - 1):\n c, s, f = (csf[i + j][k] for k in range(3))\n t = (max(t - 1, s - 1) // f + 1) * f + c\n print(t)", "N = int(input())\nC = [list(map(int,input().split())) for _ in range(N-1)]\n\nfor i in range(N-1):\n now = 0\n for j in range(i,N-1):\n now = max(C[j][1], -(-now//C[j][2])*C[j][2])\n now += C[j][0]\n print(now)\nprint(0)", "N = int(input())\nCSF = [[] for T in range(0,N-1)]\nfor TN in range(0,N-1):\n CSF[TN] = [int(T) for T in input().split()]\nfor TN in range(0,N):\n Time = 0\n for TT in range(TN,N-1):\n if Time>=CSF[TT][1]:\n Time += CSF[TT][0] + (CSF[TT][2]-(Time%CSF[TT][2]))%CSF[TT][2]\n else:\n Time += CSF[TT][0] + (CSF[TT][1]-Time)\n print(Time)", "N = int(input())\nCSF = [ list(map(int,input().split(\" \"))) for _ in range(N - 1)]\n\nfor i in range(N):\n Time = 0\n for j in range(i, N - 1):\n c, s, f = CSF[j]\n Time = max(Time, s)\n if Time % f != 0:\n Time += (f - Time % f)\n Time += c\n\n print(Time)", "n = int(input())\nc = []\ns = []\nf = []\nfor i in range(n-1):\n c_, s_ , f_ = map(int, input().split())\n c.append(c_)\n s.append(s_)\n f.append(f_)\n \nfor i in range(n-1):\n res = s[i] + c[i]\n for j in range(i+1, n-1):\n if res >= s[j]:\n if (res-s[j]) % f[j] == 0:\n res = res + c[j] + ((res - s[j]) % f[j])\n else:\n res = res + c[j] + f[j] - ((res-s[j])%f[j])\n else:\n res = s[j] + c[j]\n print(res)\nprint(0)", "n = int(input())\ngraph =[]\ntime = 0\nfor i in range(n-1):\n c,s,f = map(int,input().split())\n graph.append([i,c,s,f])\n\ndef shortest_path(start,end,times):\n if start == end:\n return times\n elif times<=graph[start][2]:\n times = (graph[start][2]+graph[start][1])\n return shortest_path(start+1,end,times)\n elif times%graph[start][3]==0:\n times += (graph[start][1])\n return shortest_path(start+1,end,times)\n else:\n times = times+graph[start][3]-times%graph[start][3]+graph[start][1]\n return shortest_path(start+1,end,times)\n\n\nfor i in range(n):\n print(shortest_path(i,n-1,0))", "n = int(input())\nstations = []\nfor i in range(n-1):\n stations.append(list(map(int, input().split())))\n\nans = [0]\ntime_matrix = [[0] * n for i in range(n)]\nfor i in range(n):\n for j in range(i+1):\n if i < n-1:\n if time_matrix[i][j] % stations[i][2] == 0:\n waiting = 0\n else:\n waiting = stations[i][2] - (time_matrix[i][j] % stations[i][2])\n time_matrix[i+1][j] = max(time_matrix[i][j] + stations[i][0] + waiting, stations[i][0] + stations[i][1])\n\nfor i in range(n):\n print((time_matrix[n-1][i]))\n", "n = int(input())\nc_s_f = []\nfor i in range(n - 1):\n line = list(map(int, input().split()))\n c_s_f.append(line)\n\nfor i in range(n - 1):\n t = c_s_f[i][0] + c_s_f[i][1]\n for j in range(i + 1, n - 1):\n if t <= c_s_f[j][1]:\n t = c_s_f[j][1] + c_s_f[j][0]\n else:\n t = (t + c_s_f[j][2] - 1) // c_s_f[j][2] * \\\n c_s_f[j][2] + c_s_f[j][0]\n print(t)\nprint((0))\n", "n = int(input())\ncsf = [list(map(int,input().split())) for _ in range(n-1)]\n\nfor i in range(n):\n time = 0\n while True:\n if i == n-1:\n print(time)\n break\n if time < csf[i][1]:\n time = csf[i][1] + csf[i][0]\n else:\n if time%csf[i][2] == 0:\n time += csf[i][0]\n else:\n time += csf[i][0] + csf[i][2] - time%csf[i][2]\n i += 1\n", "N=int(input())\nC,S,F=map(list,zip(*[list(map(int,input().split())) for i in range(N-1)]))\nr=[0]*N\nfor i in range(N-2,-1,-1):\n x=S[i]+C[i]\n for j in range(i+1,N-1):\n x=S[j]+C[j] if x<S[j] else -(-x//F[j])*F[j]+C[j]\n r[i]=x\nprint(*r,sep='\\n')", "N=int(input())\nC=[list(map(int,input().split())) for _ in range(N-1)]\n\nfor i in range(N-1):\n c,s,f=C[i]\n ans=s+c\n for j in range(i+1,N-1):\n nc,ns,nf=C[j]\n # print('D',ans,nc,ns,nf,(ans-ns)%nf)\n ans=max(ans,ns)\n m=(ans-ns)%nf\n if m!=0:ans+=nf-m\n # print('D',ans,nc,ns,nf,(ans-ns)%nf)\n ans+=nc\n print(ans)\nprint(0)", "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 main():\n n = ni()\n C = []\n S = []\n F = []\n for i in range(n - 1):\n c, s, f = nm()\n C.append(c)\n S.append(s)\n F.append(f)\n for i in range(n - 1):\n time = 0\n for j in range(i, n - 1):\n if time <= S[j]:\n time = S[j] + C[j]\n else:\n time = time + (F[j] - (time - S[j]) % F[j]) % F[j] + C[j]\n print(time)\n print((0))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "n = int(input())\n\nC, S, F = [], [], []\nfor i in range(n-1):\n c,s,f = map(int, input().split())\n C.append(c)\n S.append(s)\n F.append(f)\n\nfor i in range(n-1):\n # \u5404i\u99c5\u304b\u3089\u767a\u8eca\u3059\u308b\u5217\u8eca\u3092\u3059\u3079\u3066\u8abf\u3079\u308b\n t = 0\n for j in range(i,n-1):\n if S[j]>t:\n t = S[j]\n \n if (t-S[j])%F[j]==0:\n t += C[j]\n else:\n t += F[j] - (t-S[j])%F[j] + C[j]\n\n if j==n-2:\n print(t)\nprint(0)", "N=~-int(input())\nC=[list(map(int,input().split())) for _ in range(N)]\n\nfor i in range(N):\n p,q,r=C[i]\n A=q+p\n for j in range(i+1,N):\n c,s,f=C[j]\n if A<s:A=s\n m=(A-s)%f\n if m!=0:A+=f-m\n A+=c\n print(A)\nprint(0)", "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Oct 2 01:57:07 2020\n\n@author: liang\n\"\"\"\nimport math\n\nN = int(input())\nStations = list()\nfor i in range(N-1):\n C, S, F = map(int,input().split())\n Stations.append((C,S,F))\n\ndef solve(n,time):\n if n == N-1:\n return time\n C, S, F = Stations[n]\n tmp = max(S+C, math.ceil(time/F)*F+C)\n return solve(n+1,tmp)\n\nfor i in range(N):\n print(solve(i,0))", "n=int(input());A=[0]*n\nfor i in range(1,n):\n c,s,f=map(int,input().split())\n for j in range(i):A[j]=max(-A[j]//f*-f,s)+c\nprint(*A,sep=\"\\n\")", "#!/usr/bin/env python\n\nn = int(input())\nc = [0 for _ in range(n-1)]\ns = [0 for _ in range(n-1)]\nf = [0 for _ in range(n-1)]\nfor i in range(n-1):\n c[i], s[i], f[i] = list(map(int, input().split()))\n\nt = [[-1 for _ in range(n)] for _ in range(n-1)]\n\nfor i in range(n-1):\n t[i][i] = s[i]\n\nfor i in range(n-1):\n for j in range(i, n): \n if i != j:\n t[i][j] = t[i][j-1]+c[j-1]\n if j == n-1:\n break\n if t[i][j]-t[j][j] <= 0:\n t[i][j] = t[j][j]\n else:\n if (t[i][j]-t[j][j])%f[j] != 0:\n t[i][j] = t[j][j] + ((t[i][j]-t[j][j])//f[j]+1) * f[j]\n\n\n#print('t =', t)\n\n# output \nfor i in range(n-1):\n print((t[i][n-1]))\nprint((0))\n", "n = int(input())\ncsf = [list(map(int, input().split())) for _ in range(n-1)]\nans = []\nfor i in range(n-1):\n time = 0\n for p in range(i, n - 1):\n c, s, f = csf[p]\n if s >= time:\n time = s+c\n else:\n d = time - s\n time = s + f * (-(-d // f)) + c\n ans.append(time)\n\nans.append(0)\n\nfor i in range(n):\n print((ans[i]))\n", "n = int(input())\n\nnow = 0\nans = [0] * (n)\nCSF = [list(map(int, input().split())) for _ in range(n - 1)]\nfor i in range(n - 1):\n now = 0\n for j in range(n - i - 1):\n c, s, f = CSF[i + j]\n if now <= s:\n now = s\n else:\n now = f * ((now + f - 1) // f)\n now += c\n ans[i] = now\n\nprint((\"\\n\".join(map(str, ans))))\n", "n = int(input())\nc = []\ns = []\nf = []\nfor _ in range(n-1):\n _c, _s, _f = list(map(int, input().split()))\n c.append(_c)\n s.append(_s)\n f.append(_f)\n\nans = 0\n\nfor i in range(n):\n ans = 0\n for j in range(i, n-1):\n if ans < s[j]:\n ans = s[j] + c[j]\n elif ans % f[j] == 0:\n ans += c[j]\n else:\n ans += f[j] - ans%f[j] + c[j]\n\n print(ans)\n", "N = int(input())\nCSF = [[0] * 3 for i in range(N-1)]\n\nfor i in range(N-1):\n c, s, f = list(map(int, input().split()))\n CSF[i][0] = c\n CSF[i][1] = s\n CSF[i][2] = f\n\nfor i in range(N-1):\n now = CSF[i][1]+CSF[i][0]\n for j in range(i+1, N-1):\n # 1\u672c\u76ee\u306e\u524d\u306a\u30891\u672c\u76ee\u307e\u3067\u5f85\u3064\n if now <= CSF[j][1]:\n now += CSF[j][0]+(CSF[j][1]-now)\n\n # 1\u672c\u76ee\u4ee5\u964d\u306a\u3089\u5f85\u3061\u6642\u9593\u3068\u79fb\u52d5\u6642\u9593\u3092\u52a0\u7b97\u3059\u308b\n else:\n while (now - CSF[j][1]) % CSF[j][2] != 0:\n now += 1\n now += CSF[j][0]\n print(now)\nprint((0))\n", "n = int(input())\ninp = []\nfor i in range(n-1):\n inp.append(list(map(int, input().split())))\n\nfor i in range(n-1):\n total = 0\n for j in range(i, n-1):\n if total < inp[j][1]:\n total = inp[j][1]\n while total % inp[j][2] != 0:\n total += 1\n total += inp[j][0]\n print(total)\nprint((0))\n \n\n\n\n", "n=int(input())\nyo=[]\nfor _ in range(n-1):\n a=list(map(int,input().split()))\n yo.append(a)\n \ndef ans(x):\n if x==n-1:\n return 0\n else:\n t=0\n for i in range(x,n-1):\n if t<=yo[i][1]:\n t=yo[i][1]+yo[i][0]\n else:\n s=t-yo[i][1]\n if s%yo[i][2]==0:\n t=t+yo[i][0]\n else:\n mo=s%yo[i][2]\n t=t+yo[i][2]-mo+yo[i][0]\n return t\n \nfor j in range(n):\n print((ans(j)))\n \n", "N = int(input())\ncsf = [list(map(int,input().split())) for i in range(N-1)]\nfor i in range(N-1):\n ans = csf[i][1]+csf[i][0]\n for j in range(i+1,N-1):\n if ans <= csf[j][1]:\n ans = csf[j][1]\n else:\n f = ans%csf[j][2]\n if f != 0:\n ans += csf[j][2]-f\n ans += csf[j][0]\n print(ans)\nprint(0)", "n=int(input())\nl=[]\nfor _ in range(n-1):\n c,s,f=map(int,input().split())\n for i,t in enumerate(l):\n if t>s: t=-(-t//f)*f\n else: t=s\n l[i]=t+c\n l+=[s+c]\nfor i in l+[0]:\n print(i)", "import math\n\nn = int(input())\ncL = []\nsL = []\nfL = []\nfor i in range(n - 1):\n c, s, f = map(int, input().split(\" \"))\n cL.append(c)\n sL.append(s)\n fL.append(f)\n\nans = 0\nfor i in range(n - 1):\n sm = 0\n for j in range(i, n - 1):\n c = cL[j]\n s = sL[j]\n f = fL[j]\n if sm < s:\n sm = s + c\n continue\n df = f - (sm - s) % f\n if df == f:\n df = 0\n sm += c + df\n print(sm)\nprint(0)", "N=int(input())\ncsf=[list(map(int,input().split()))for _ in range(N-1)]\ni=0\nwhile i<N:\n ans=0\n j=i\n while j<N-1:\n c,s,f=list(csf[j])\n ans=max(ans,s)\n if ans%f:\n ans+=f-ans%f\n ans+=c\n j+=1\n print(ans)\n i+=1", "N = int(input())\nlis = [[0, 0, 1]]\nfor i in range(N - 1):\n C, S, F = list(map(int, input().split()))\n lis.append([C, S, F])\n\n# i \u99c5\u30b9\u30bf\u30fc\u30c8 \u306e\u96fb\u8eca\nfor i in range(N):\n C, S_ij, F = 0, 0, 1\n for j in range(i + 1, N): # j \u99c5\u306b\u7740\u304f\n C, S, F = lis[j]\n S = max(S, S_ij) # max\uff08j \u99c5\u306e\u30b9\u30bf\u30fc\u30c8\u6642\u9593\u3001 ij \u9593\u306e\u6642\u9593\uff09\n S_ij = C + ((S - 1) // F + 1) * F\n print(S_ij)\n", "def solve():\n n = int(input())\n csf = [list(map(int,input().split())) for _ in range(n-1)]\n \n for i in range(n):\n time = 0\n while True:\n if i == n-1:\n print(time)\n break\n if time < csf[i][1]:\n time = csf[i][1] + csf[i][0]\n else:\n if time%csf[i][2] == 0:\n time += csf[i][0]\n else:\n time += csf[i][0] + csf[i][2] - time%csf[i][2]\n i += 1\n\ndef __starting_point():\n solve()\n__starting_point()", "N = int(input())\nl = []\nfor i in range(N-1):\n c, s, f = map(int, input().split())\n l.append([c, s, f])\n \nfor i in range(N-1):\n time = l[i][1] + l[i][0]\n for j in range(i+1, N-1):\n if time-l[j][1] >= 0:\n wait = time % l[j][2]\n if wait == 0:\n time += l[j][0]\n else:\n time += l[j][2] - wait + l[j][0]\n else:\n time = l[j][1] + l[j][0]\n print(time)\nprint(0)", "# import itertools\nimport math\n# from functools import reduce\n# import sys\n# sys.setrecursionlimit(500*500)\n# import numpy as np\n# from collections import deque\n# import heapq\n\n# \u5165\u529b\nN = int(input())\n# S = input()\n# n, *a = map(int, open(0))\n# H, N = map(int, input().split())\n# A = list(map(int, input().split()))\n# A = list(map(lambda x: int(x)*(-1), input().split()))\n# B = list(map(int, input().split()))\ncsf = [list(map(int,input().split())) for _ in range(N-1)]\n# S = 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# edges = [list(map(int,input().split())) for _ in range(N - 1)]\n# tree = [[] for _ in range(N + 1)]\n\n# for edge in edges:\n# tree[edge[0]].append(edge[1])\n# tree[edge[1]].append(edge[0])\n\n# depth = [-1] * (N + 1)\n# depth[1] = 0\n# count = [0] * (N + 1)\n\n# for i in range(Q):\n# p, x = map(int, input().split())\n# count[p] += x\n\n# def dfs(tree, s):\n# for l in tree[s]:\n# if depth[l[0]] == -1:\n# depth[l[0]] = depth[s] + 1\n# dfs(tree, l[0])\n# dfs(tree, 1)\n\n# \u7d20\u56e0\u6570\u5206\u89e3\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# \u7d04\u6570\u5217\u6319\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# bfs\n# tree = [[] for _ in range(N + 1)]\n# edges = [list(map(int,input().split())) for _ in range(M)]\n\n# for edge in edges:\n# tree[edge[0]].append(edge[1])\n# tree[edge[1]].append(edge[0])\n\n# depth = [-1] * (N + 1)\n# depth[1] = 0\n\n# d = deque()\n# d.append(1)\n\n# ans = [0] * (N + 1)\n# while d:\n# v = d.popleft()\n# for i in tree[v]:\n# if depth[i] != -1:\n# continue\n# depth[i] = depth[v] + 1\n# ans[i] = v\n# d.append(i)\n\n# # ans = depth[2:]\n# print('Yes')\n# print(*ans[2:], sep=\"\\n\")\n\n# def gcd_list(numbers):\n# return reduce(math.gcd, numbers)\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\n\nfor i in range(N):\n t = 0\n for j in range(i, N - 1):\n if csf[j][1] >= t:\n t = csf[j][1] + csf[j][0]\n # print(i, j, t)\n else:\n t = csf[j][1] + math.ceil((t - csf[j][1]) / csf[j][2]) * csf[j][2] + csf[j][0]\n # print(i, j, t)\n print(t)", "n=int(input())\nc,s,f=[],[],[]\nfor _ in range(n-1):\n x,y,z=map(int,input().split())\n c.append(x)\n s.append(y)\n f.append(z)\n\nfor i in range(n-1):\n temp=s[i]+c[i]\n for j in range(i+1,n-1):\n if temp<=s[j]: temp=s[j]+c[j]\n else:\n if (temp-s[j])%f[j]==0: temp+=c[j]\n else:\n k=(temp-s[j])//f[j]+1\n temp=s[j]+k*f[j]+c[j]\n print(temp)\nprint(0)", "N= int(input())\nli = [list(map(int,input().split())) for _ in range(N-1)]\n\nfor i in range(N-1):\n ci,si,fi = li[i]\n time = si+ci\n for j in range(i+1,N-1):\n cj,sj,fj = li[j]\n if time%fj != 0:\n time = ((time//fj)+1)*fj\n #print(i,time)\n if time < sj:\n time = sj\n time += cj\n print(time)\nprint(0)", "n = int(input())\nC = []\nS = []\nF = []\nfor _ in range(n-1):\n c, s, f = map(int, input().split())\n C.append(c)\n S.append(s)\n F.append(f)\n\ndef f(n, s, f):\n if n <= s:\n return s\n if n % f == 0:\n return n\n else:\n return n // f * f + f\n\nfor i in range(n-1):\n now = S[i] + C[i]\n for j in range(i+1, n-1):\n now = f(now, S[j], F[j]) + C[j]\n print(now)\nprint(0)", "N=int(input())\nl=[0]*N\nfor i in range(N-1):\n c,s,f=map(int,input().split())\n l[i]=c+s\n for j in range(i):\n l[j]=max(l[j],s,-(-l[j]//f)*f)+c\n\nfor i in l:print(i)", "N=int(input())\nCSF=[list(map(int,input().split())) for _ in range(N-1)]\nfor j in range(N):\n t=0\n for i in range(j,N-1):\n if t<CSF[i][1]:\n t=CSF[i][1]\n else:\n x=(t-1)//CSF[i][2]+1\n t=CSF[i][2]*x\n t+=CSF[i][0]\n print(t)\n", "n = int(input())\ncost = [0]*n\nstart = [0]*n\nfreaq = [0]*n\ndp = [[0]*n for _ in range(n)]\n\nfor i in range(n-1):\n cost[i],start[i],freaq[i] = map(int,input().split())\n dp[i][i] = start[i]\n\nfreaq[n-1] = 1\n\nt = 0\n\nfor i in range(n-1):\n for j in range(i+1):\n t = dp[j][i]\n t += cost[i]\n if t%freaq[i+1] != 0:\n t += freaq[i+1] - t%freaq[i+1]\n t = max(t,start[i+1])\n dp[j][i+1] = t\n\nfor i in range(n):\n print(dp[i][n-1])", "n = int(input())\nc = [0] * n\ns = [0] * n\nf = [0] * n\nfor i in range(n - 1):\n c[i], s[i], f[i] = map(int, input().split())\n\nans = [0] * n\nfor i in range(n - 1):\n for j in range(i, n - 1):\n if ans[i] < s[j]:\n ans[i] = s[j]\n elif ans[i] % f[j] > 0:\n ans[i] += f[j] - ans[i] % f[j]\n ans[i] += c[j]\n\nfor i in range(n):\n print(ans[i])", "n = int(input())\ncsf = [list(map(int, input().split())) for _ in range(n-1)]\n\nfor i in range(n-1):\n t = 0\n for c,s,f in csf[i:]:\n if s > t:\n # \u59cb\u767a\u3092\u5f85\u3064\n t = s\n else:\n # \u6b21\u767a\u3092\u5f85\u3064\n t += (s-t) % f\n t += c\n print(t)\nprint(0)", "N = int(input())\nC, S, F = [], [], []\nfor _ in range(N-1):\n c, s, f = map(int, input().split())\n C.append(c)\n S.append(s)\n F.append(f)\nS.append(0)\n\nimport numpy as np\ndef theta(x): #\u30d8\u30f4\u30a3\u30b5\u30a4\u30c9\u306e\u6bb5\u5dee\u95a2\u6570\n return x if x > 0 else 0\n\ndef DptTimeAtNextSt(i, T): #\u6642\u523bT\u306b\u99c5i\u3092\u51fa\u767a\u3057\u305f\u6642\u3001\u99c5i+1\u3092\u51fa\u767a\u3059\u308b\u6642\u9593\n nonlocal C, S, F\n arrT = T + C[i]\n if i == N-2: return arrT \n return S[i+1] + np.ceil(theta(arrT-S[i+1])/F[i+1]) * F[i+1]\n\ndef solve(i, S): #\u99c5i\u306b\u5bfe\u3059\u308b\u89e3\u3092\u518d\u5e30\u7684\u306b\u89e3\u304f\u95a2\u6570\n if i == N-1:\n return int(S)\n else:\n return solve(i+1, DptTimeAtNextSt(i,S))\n\nfor i in range(N):\n print(solve(i,S[i]))", "n=int(input())\ncsf=[]\nfor i in range(n-1):\n c,s,f=list(map(int,input().split()))\n csf.append([c,s,f])\n\nfor i in range(n):\n t=0\n for j in range(i,n-1):\n c,s,f=csf[j]\n if t<=s:\n t = s + c\n else:\n if t%f==0: w=0\n else: w=f-t%f\n t = t + w + c\n print(t)\n", "def jikan(now_t,i):\n if i==n:\n return now_t\n else:\n if now_t<=s[i]:\n now_t = s[i]\n else:\n tmp1 = now_t//f[i]\n if now_t%f[i]!=0:\n now_t = (tmp1+1)*f[i]\n tmp = jikan(now_t+c[i],i+1)\n return tmp\n\nn = int(input())\nc,s,f = [0],[0],[0]\nfor i in range(n-1):\n ci,si,fi = list(map(int,input().split()))\n c.append(ci)\n s.append(si)\n f.append(fi)\n#print(c,s,f)\nfor i in range(1,n+1):\n print((jikan(0,i)))\n", "from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb\nfrom itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement\nfrom collections import deque,defaultdict,Counter\nfrom bisect import bisect_left,bisect_right\nfrom operator import itemgetter\nfrom heapq import heapify,heappop,heappush\nfrom queue import Queue,LifoQueue,PriorityQueue\nfrom copy import deepcopy\nfrom time import time\nimport string\nimport sys\nsys.setrecursionlimit(10 ** 7)\ndef input() : return sys.stdin.readline().strip()\ndef INT() : return int(input())\ndef MAP() : return map(int,input().split())\ndef LIST() : return list(MAP())\n\nn = INT()\nls = []\nfor i in range(n-1):\n c, s, f = MAP()\n ls.append([c, s, f])\nfor i in range(n-1):\n ans = 0\n for j in range(i, n-1):\n ans = max(ans, ls[j][1])\n ans = ls[j][0] + ( ans + ls[j][2] - 1 )// ls[j][2] * ls[j][2]\n print(ans)\nprint(0)", "#!/usr/bin/env python3\n(n, ), *q = [[*map(int, i.split())] for i in open(0)]\nans = [0] * n\nfor i, p in enumerate(q):\n c, s, f = p\n for j in range(i):\n ans[j] = c + max(s, -(-ans[j] // f) * f)\n ans[i] = c + s\nprint(*ans, sep=\"\\n\")\n", "N=int(input())\nC=[list(map(int,input().split())) for _ in range(N-1)]\n\nfor i in range(N-1):\n c,s,f=C[i]\n A=s+c\n for j in range(i+1,N-1):\n nc,ns,nf=C[j]\n if A<ns:A=ns\n elif (A-ns)%nf!=0:A+=nf-(A-ns)%nf\n A+=nc\n print(A)\nprint(0)", "import math\nimport sys\n\n\nMAX_N = 500\n\n\nN = int(input())\nC = []\nS = []\nF = []\nfor _ in range(N - 1):\n c, s, f = [int(x) for x in input().split()]\n C.append(c)\n S.append(s)\n F.append(f)\n\nif N == 1:\n print((0))\n return\n\nfor i in range(N - 1):\n t = S[i] + C[i]\n for j in range(i + 1, N - 1):\n t = max(S[j], int(math.ceil(t / F[j])) * F[j]) + C[j]\n print(t)\nprint((0))\n", "N=int(input())\nC=[]\nS=[]\nF=[]\nfor i in range(N-1):\n CSF=list(map(int,input().split()))\n C.append(CSF[0])\n S.append(CSF[1])\n F.append(CSF[2])\n\nans=[0]*(N)\n\nfor i in range(N-1):\n t=0\n\n for j in range(i,N-1):\n m=-(-t//F[j])*F[j]\n t=max(S[j],m)\n t+=C[j]\n \n ans[i]=t\n\nprint(*ans,sep='\\n')", "import sys\nimport math\nimport itertools\nimport collections\nfrom collections import deque\nfrom collections import defaultdict\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\nMOD2 = 998244353\nINF = float('inf')\ninput = lambda: sys.stdin.readline().strip()\n\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\ndef main():\n N = NI()\n CSF = [NLI() for _ in range(N-1)]\n CSF.append([0,0,1])\n\n \n for n in range(N-1):\n time = CSF[n][1]\n \n for m in range(n,N-1):\n time += CSF[m][0]\n if time < CSF[m+1][1]:\n time = CSF[m+1][1]\n else:\n if time % CSF[m+1][2] != 0:\n time = ((time//CSF[m+1][2])+1)*CSF[m+1][2]\n print(time)\n print(0)\n\n\n\ndef __starting_point():\n main()\n__starting_point()", "n = int(input())\ntimetable = [list(map(int, input().split())) for _ in range(n - 1)]\n\ndef nextstn(t, stn):\n if t >= timetable[stn][1]:\n return (((t + timetable[stn][2] - 1) // timetable[stn][2]) * timetable[stn][2]) + timetable[stn][0]\n else:\n return timetable[stn][1] + timetable[stn][0]\n\nfor i in range(n - 1):\n current_stn = i\n laps = 0\n while current_stn < n - 1:\n laps = nextstn(laps, current_stn)\n current_stn += 1\n print(laps)\nelse:\n print(0)", "import sys\n\ninput_methods=['clipboard','file','key']\nusing_method=0\ninput_method=input_methods[using_method]\n\ntin=lambda : map(int, input().split())\nlin=lambda : list(tin())\nmod=1000000007\n\n#+++++\n\ndef cc(al):\n\tret = 0\n\tfor (c, s, f) in al:\n\t\tif ret <= s:\n\t\t\tret = s+c\n\t\telse:\n\t\t\tst = ((ret + f-1)//f)*f\n\t\t\tret = st + c\n\tprint(ret)\n\t\t\n\ndef main():\n\tn = int(input())\n\t#if n==4:\n\t#\treturn 1/0\n\t#b , c = tin()\n\t#s = input()\n\tal = [lin() for _ in range(n-1)]\n\tfor i in range(n):\n\t\tcc(al[i:])\n\t\n\t\n\t\n#+++++\nisTest=False\n\ndef pa(v):\n\tif isTest:\n\t\tprint(v)\n\t\t\ndef input_clipboard():\n\timport clipboard\n\tinput_text=clipboard.get()\n\tinput_l=input_text.splitlines()\n\tfor l in input_l:\n\t\tyield l\n\ndef __starting_point():\n\tif sys.platform =='ios':\n\t\tif input_method==input_methods[0]:\n\t\t\tic=input_clipboard()\n\t\t\tinput = lambda : ic.__next__()\n\t\telif input_method==input_methods[1]:\n\t\t\tsys.stdin=open('inputFile.txt')\n\t\telse:\n\t\t\tpass\n\t\tisTest=True\n\telse:\n\t\tpass\n\t\t#input = sys.stdin.readline\n\t\t\t\n\tret = main()\n\tif ret is not None:\n\t\tprint(ret)\n__starting_point()", "def main():\n import sys\n input = lambda:sys.stdin.readline().strip()\n \n N = int(input())\n #C:\u6240\u8981\u6642\u9593,S:\u958b\u59cb\u5f8c,F:\u9593\u9694\n CSF = [list(map(int,input().split())) for _ in range(N-1)]\n\n for i in range(N):\n t = 0\n for c,s,f in CSF[i:]:\n if t<=s:\n t=s\n else:\n t=((t-s)//f if (t-s)%f==0 else (t-s)//f+1)*f+s\n t+=c\n print(t)\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\nstation = [list(map(int, input().split())) for _ in range(N - 1)]\n\nlst = []\n\nfor i in range(N - 1):\n c, s, f = station[i]\n\n for j in range(len(lst)):\n a = lst[j]\n\n if a >= s:\n if a % f == 0:\n a += c\n else:\n a += (f - a % f) + c\n else:\n a = s + c\n\n lst[j] = a\n\n lst.append(s + c)\n\n\nlst.append(0)\nfor a in lst:\n print(a)\n", "N=int(input())\nCSF=[list(map(int,input().split())) for _ in range(N-1)]\nfor j in range(N):\n t=0\n for i in range(j,N-1):\n if t<CSF[i][1]:\n t=CSF[i][1]\n else:\n x=(t-1)//CSF[i][2]+1\n t=CSF[i][2]*x\n t+=CSF[i][0]\n print(t)", "def resolve():\n '''\n code here\n '''\n N = int(input())\n starts = [[int(item) for item in input().split()] for _ in range(N-1)]\n\n for i in range(N):\n temp_time = 0\n if i == N-1:\n print((0))\n else:\n for j in range(i,N-1):\n c, s, f = starts[j]\n if temp_time <= s:\n temp_time = s\n\n if temp_time % f == 0:\n pass\n else:\n temp_time = (temp_time // f + 1) * f\n \n temp_time += c\n print(temp_time)\n\n\ndef __starting_point():\n resolve()\n\n__starting_point()", "N = int(input())\nT = 0\nt = 0\nans = []\nfor i in range(N-1):\n C, S, F = list(map(int, input().split()))\n for j in range(len(ans)):\n if ans[j] <= S:\n ans[j] = S+C\n elif ans[j]%F != 0:\n ans[j] = ans[j]+F-(ans[j] % F)+C\n else:\n ans[j] += C\n ans.append(S+C)\nfor a in ans:\n print(a)\nprint((0))\n", "N = int(input())\nC, S, F = [], [], []\n\nfor _ in range(N-1):\n c, s, f = map(int, input().split())\n C.append(c)\n S.append(s)\n F.append(f)\n\nfor station in range(N):\n now = station\n time = 0\n\n while now < N-1:\n if time < S[now]:\n time = S[now] + C[now]\n else:\n if time % F[now] == 0:\n time += C[now]\n else:\n wait_time = F[now] - (time % F[now])\n time += wait_time + C[now]\n\n now += 1\n\n print(time)", "n=int(input())\ncsf = [list(map(int,input().split())) for i in range(n-1)]\nans1=[]\nfor j in range(n-1):\n requ_time=csf[j][1]+csf[j][0]\n for i in range(j,n-1):\n if i!=j:\n if requ_time <= csf[i][1]:\n requ_time+=(csf[i][0]+(csf[i][1]-requ_time))\n #elif requ_time > csf[i][1] and csf[i][0]+csf[1] > requ_time:\n else:\n requ_time+=(csf[i][0]+(csf[i][2]-(requ_time-csf[i][1])%csf[i][2])%csf[i][2])\n ans1.append(requ_time)\nfor i in ans1:\n print(i)\nprint((0))\n", "n=int(input())\nl=[0]*n\nfor i in range(1,n):\n c,s,f=map(int,input().split())\n for j in range(i):\n l[j]=max(-l[j]//f*-f,s)+c\nfor i in l: print(i)", "import sys\n\nN = int(sys.stdin.readline())\n\nstations = []\nfor _ in range(N-1):\n c, s, f = map(int, sys.stdin.readline().split())\n stations.append((c, s, f))\n\nfor i in range(N-1):\n t = 0\n for j in range(i, N-1):\n c, s, f = stations[j]\n if t <= s:\n t = s + c\n else:\n tmp = t - s\n t = s + f * ((tmp - 1) // f + 1) + c\n\n print(t)\nprint(0)", "import math\ndef main():\n n=int(input())\n csf=[list(map(int,input().split())) for _ in range(n-1)]\n for i in range(n):\n if i == n-1:\n print(0)\n else:\n t=0\n for c,s,f in csf[i:]:\n t = max(s,t)\n t = math.ceil(t/f)*f+c\n #print(\"start:\", i, t)\n print(t)\n\ndef __starting_point():\n main()\n__starting_point()", "N = int(input())\ncsf = [list(map(int, input().split())) for _ in range(N-1)]\nans = [None]*N\nans[-1] = 0\nfor i in range(N-1):\n now = 0\n for j in range(i,N-1):\n if now <= csf[j][1]:\n now = csf[j][1]\n else:\n t = (now - csf[j][1] + csf[j][2]-1)//csf[j][2]\n now = csf[j][1] + t*csf[j][2]\n now += csf[j][0]\n ans[i] = now\n[print(a) for a in ans]", "N = int(input())\ncsf = [list(map(int, input().split())) for i in range(N - 1)]\n\nfor i in range(N):\n ans = 0\n for c, s, f in csf[i::]:\n if ans <= s:\n ans = s\n else:\n if ans % f == 0:\n pass\n else:\n ans = (ans // f + 1) * f\n ans += c\n print(ans)\n", "def est_time(sta,N,csf_list):\n SUM = 0\n for i in range(sta,N):\n if i == sta:\n SUM += csf_list[i-1][0] + csf_list[i-1][1]\n else:\n if SUM >= csf_list[i-1][1]:\n SUM = ((SUM+csf_list[i-1][2]-1) // csf_list[i-1][2])*csf_list[i-1][2]\n SUM += csf_list[i-1][0]\n else:\n SUM = csf_list[i-1][1]\n SUM += csf_list[i-1][0]\n return SUM\n\nN=int(input())\ncsf_list=[tuple(map(int,input().split())) for _ in range(N-1)]\n\nfor i in range(N):\n print(est_time(i+1,N,csf_list))", "N = int(input())\nCls = [0]\nSls = [0]\nFls = [0]\nlsans = []\nfor i in range(1,N):\n c,s,f = map(int,input().split())\n Cls.append(c)\n Sls.append(s)\n Fls.append(f)\nfor i in range(1,N):\n t = 0\n for j in range(i,N):\n if t < Sls[j]:\n t = Sls[j] + Cls[j]\n elif t%Fls[j] == 0:\n t += Cls[j]\n else:\n t += Fls[j]-(t%Fls[j])+Cls[j]\n lsans.append(t)\nlsans.append(0)\nfor i in lsans:\n print(i)", "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, *CSF = map(int, read().split())\n train = [0] * (N - 1)\n for i, t in enumerate(zip(*[iter(CSF)] * 3)):\n train[i] = t\n\n ans = [0] * N\n for i in range(N - 1):\n t = 0\n for c, s, f in train[i:]:\n if t < s:\n t = s + c\n else:\n t += f - ((t - 1) % f + 1) + c\n ans[i] = t\n\n ans[N - 1] = 0\n print(*ans, sep='\\n')\n return\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "import sys\n\nN = int(sys.stdin.readline())\n\nstations = []\nfor _ in range(N-1):\n c, s, f = map(int, sys.stdin.readline().split())\n stations.append((c, s, f))\n\nfor i in range(N-1):\n t = 0\n for j in range(i, N-1):\n c, s, f = stations[j]\n if t <= s:\n t = s + c\n else:\n tmp = t - s\n t = s + f * ((tmp - 1) // f + 1) + c\n\n print(t)\nprint(0)", "#!/usr/bin/env python3\nimport sys\nimport math\nsys.setrecursionlimit(10**6)\nn = int(input())\n\ncsf = [list(map(int, input().split())) for i in range(n-1)]\n\nfor i in range(n-1):\n csf_tmp = csf[i:]\n\n c, s, f = csf_tmp[0]\n\n t = c+s\n for j in range(1, len(csf_tmp)):\n c, s, f = csf_tmp[j]\n\n if t <= s:\n t = s\n else:\n mod = (t-s) % f\n if mod != 0:\n t += f-mod\n # print(t)\n t += c\n # print(t)\n print(t)\n # print()\nprint((0))\n", "n = int(input())\nans = [0] * n\n\nfor i in range(1, n):\n c, s, f = list(map(int, input().split()))\n\n for j in range(i):\n ans[j] = max(ans[j], s)\n ans[j] = ((ans[j]+f-1)//f) * f\n ans[j] += c\n\nfor a in ans:\n print(a)", "n = int(input())\nroute, ans = [], []\nfor i in range(n-1):\n a = list(map(int, input().split()))\n route.append(a)\n\nfor i in range(n-1):\n c = route[i][0]+route[i][1]\n for j in range(i+1, n-1):\n if c < route[j][1]:\n c = route[j][0]+route[j][1]\n elif (c-route[j][1])%route[j][2] == 0:\n c += route[j][0]\n else:\n c += route[j][0]+route[j][2]-(c-route[j][1])%route[j][2]\n ans.append(c)\nans.append(0)\nfor i in ans:\n print(i)\n", "N = int(input())\nC = [0]*(N-1)\nS = [0]*(N-1)\nF = [0]*(N-1)\nfor TN in range(0,N-1):\n C[TN],S[TN],F[TN] = (int(T) for T in input().split())\nfor TN in range(0,N):\n Time = 0\n for TS in range(TN,N-1):\n if Time>=S[TS]:\n Time += C[TS]+(F[TS]-(Time%F[TS]))%F[TS]\n else:\n Time += C[TS]+(S[TS]-Time)\n print(Time)", "n = int(input())\nT = [0]*n\nc,s,f = [0]*(n-1),[0]*(n-1),[0]*(n-1)\n \nfor i in range(n-1):\n\tc[i],s[i],f[i] = map(int,input().split())\n\nfor\ti in range(n-1):\n\tT[i] = s[i] + c[i]\n\tfor j in range(i+1,n-1):\n\t\tif T[i] > s[j]:\n\t\t\tT[i] += (-T[i])%f[j] + c[j]\n\t\telse:\n\t\t\tT[i] = s[j] + c[j]\n\tprint(T[i])\nprint(0)", "from math import *\n\nn = int(input()) - 1\nc = [0] * n\ns = [0] * n\nf = [0] * n\nfor i in range(n):\n c[i], s[i], f[i] = map(int, input().split())\n \nfor i in range(n):\n a = s[i] + c[i]\n for j in range(i + 1, n):\n if a <= s[j]:\n a = s[j] + c[j]\n else:\n a = s[j] + f[j] * ceil((a-s[j])/f[j]) + c[j]\n print(a)\nprint(0)", "n=int(input())\ncsf=[tuple(map(int,input().split())) for _ in range(n-1)]\n\narrtime=lambda i,cs: max(csf[i][2]*(cs//csf[i][2]+(cs%csf[i][2]>0)),csf[i][1])+csf[i][0]\nfor i in range(n-1):\n arrivN=csf[i][1]\n for j in range(i,n-1):\n arrivN=arrtime(j,arrivN)\n print(arrivN)\nprint(0)", "n = int(input())\ncl = []\nsl = []\nfl = []\n\nfor _ in range(n-1):\n c,s,f = list(map(int,input().split()))\n cl += [c]\n sl += [s]\n fl += [f]\n\n \n\nfor i in range(n):\n time = 0\n while True:\n if i==n-1:\n print(time)\n break\n if sl[i]<=time and time%fl[i]==0:\n time += cl[i]\n elif sl[i]>time:\n time = sl[i] +cl[i]\n else: #sl[i]<=time and time%fl[i]!=0\n time += fl[i] - time%fl[i] +cl[i]\n i += 1\n \n\n", "n=int(input())\nnum=[]\nfor i in range(n-1):\n num.append(list(map(int,input().split())))\nfor i in range(n-1):\n ans=0\n for j in range(i,n-1):\n if ans<=num[j][1]:\n ans=num[j][1]\n else:\n ans=num[j][1]+((-((ans-num[j][1])//-num[j][2]))*num[j][2])\n ans+=num[j][0]\n print(ans)\nprint((0))\n", "N = int(input())\nC = [0] * (N-1)\nS = [0] * (N-1)\nF = [0] * (N-1)\nfor i in range(N-1):\n C[i], S[i], F[i] = map(int,input().split())\n\nfor i in range(N):\n t = 0\n for j in range(i,N - 1):\n if t < S[j]:\n t = S[j]\n elif t % F[j] == 0:\n pass\n else:\n t = t + F[j] - (t % F[j])\n t += C[j]\n print(t)", "#!/usr/bin/env python\n# coding: utf-8\n\n# In[18]:\n\n\nN = int(input())\ncsf = []\nfor _ in range(N-1):\n csf.append(list(map(int, input().split())))\n\n\n# In[19]:\n\n\nfor i in range(N):\n if i < N-1:\n t = csf[i][1]\n for i in range(i,N-1):\n c,s,f = csf[i]\n if t >= s:\n if t%f == 0:\n t += c\n else:\n t = (-(-t//f))*f+c\n else:\n t = s+c\n print(t)\n else:\n print((0))\n\n\n# In[ ]:\n\n\n\n\n", "import math\nN = int(input())\n\nC = []\nS = []\nF = []\nfor _ in range(N - 1):\n c, s, f = list(map(int, input().split()))\n C.append(c)\n S.append(s)\n F.append(f)\n\n\nfor i in range(N - 1):\n count = 0\n count += S[i]\n count += C[i]\n for j in range(i + 1, N - 1):\n if count < S[j]:\n count = S[j]\n else:\n count = math.ceil((count - S[j]) / F[j]) * F[j] + S[j]\n count += C[j]\n print(count)\nprint((0))\n", "n = int(input())\nls = [list(map(int,input().split())) for _ in range(n-1)]\ndef culc(nt,p):\n if nt == 0:\n if p != n-1:\n nt = ls[p][1] + ls[p][0]\n culc(nt,p+1)\n else:\n print((0))\n else:\n if p != n-1:\n if nt >= ls[p][1]:\n m = (nt - ls[p][1])//ls[p][2]\n if (nt - ls[p][1])%ls[p][2] != 0:\n m += 1\n nt = ls[p][1] + ls[p][2]*m + ls[p][0]\n culc(nt,p+1)\n else:\n nt = ls[p][1] + ls[p][0]\n culc(nt,p+1)\n else:\n print(nt)\nfor i in range(n):\n culc(0,i)\n\n", "import math\n\nN = int(input())\nCSF = [list(map(int, input().split())) for _ in range(N - 1)]\n\nfor i in range(N):\n t = 0\n\n for c, s, f in CSF[i:]:\n # \u5f85\u3061\u6642\u9593\n if t < s:\n t = s\n else:\n t = math.ceil((t - s) / f) * f + s\n\n # i -> i+1\u306b\u79fb\u52d5\n t += c\n\n print(t)\n", "import sys\nmod=10**9+7 ; inf=float(\"inf\")\nfrom math import sqrt, ceil\nfrom collections import deque, Counter, defaultdict #\u3059\u3079\u3066\u306ekey\u304c\u7528\u610f\u3055\u308c\u3066\u308b defaultdict(int)\u3067\u521d\u671f\u5316\ninput=lambda: sys.stdin.readline().strip()\nsys.setrecursionlimit(11451419)\nfrom decimal import ROUND_HALF_UP,Decimal #\u5909\u63db\u5f8c\u306e\u672b\u5c3e\u6841\u30920\u30840.01\u3067\u6307\u5b9a\n #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))\nfrom functools import lru_cache\nfrom bisect import bisect_left as bileft, bisect_right as biright\n#\u30e1\u30e2\u5316\u518d\u5e30def\u306e\u5192\u982d\u306b\u6bce\u56de @lru_cache(maxsize=10**10)\n#\u5f15\u6570\u306blist\u306f\u3060\u3081\n#######\u3053\u3053\u307e\u3067\u30c6\u30f3\u30d7\u30ec#######\n#\u30bd\u30fc\u30c8\u3001\"a\"+\"b\"\u3001\u518d\u5e30\u306a\u3089Python3\u306e\u65b9\u304c\u3044\u3044\n#######\u3053\u3053\u304b\u3089\u5929\u3077\u3089########\n\nn=int(input())\nA=[list(map(int,input().split())) for i in range(n-1)]\nfor i in range(n):\n if i==n-1:print((0));return\n now=0\n for l in A[i:]:\n c,s,f =l \n now=max(now,s)\n for plus in range(0,101):\n if (now+plus)% f==0:\n now+=plus\n break\n now+=c\n print(now)\n\n", "n = int(input())\ncsf = [tuple(map(int, input().split())) for _ in range(n - 1)]\n\nfor i in range(n - 1):\n c, s, f = csf[i]\n a = s + c\n now = i\n for j in range(i + 1, n - 1):\n nc, ns, nf = csf[j]\n # next = ns + nf * x\n if a <= ns:\n a = ns\n else:\n x = (a - ns + nf - 1) // nf\n a = ns + nf * x\n a += nc\n\n print(a)\nprint((0))\n", "n=int(input())\nC=[]\nS=[]\nF=[]\nfor i in range(n-1):\n\tc,s,f=list(map(int, input().split()))\n\tC.append(c)\n\tS.append(s)\n\tF.append(f)\n\ndef d(x,t): #\u99c5x\u6642\u9593\uff54\u3067\u79fb\u52d5\u3059\u308b\u306e\u306b\u304b\u304b\u308b\u6642\u9593\n\tif S[x]>=t:\n\t\treturn C[x]+S[x]-t\n\telse:\n\t\tif (t-S[x])%F[x]==0:\n\t\t\treturn C[x]\n\t\telse:\n\t\t\treturn C[x]+F[x]-(t-S[x])%F[x]\n\nfor i in range(n-1):\n\tx=i\n\tans=0\n\tfor j in range(x,n-1):\n\t\tans+=d(j,ans)\n\t\tx=+1\n\tprint(ans)\nprint((0))\n"]
{"inputs": ["3\n6 5 1\n1 10 1\n", "4\n12 24 6\n52 16 4\n99 2 2\n", "4\n12 13 1\n44 17 17\n66 4096 64\n"], "outputs": ["12\n11\n0\n", "187\n167\n101\n0\n", "4162\n4162\n4162\n0\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
46,830
e403c7de707b128c8d5f0ee7a2c89554
UNKNOWN
There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either . or *. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down). -----Constraints----- - 1≦H, W≦100 - C_{i,j} is either . or *. -----Input----- The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W} -----Output----- Print the extended image. -----Sample Input----- 2 2 *. .* -----Sample Output----- *. *. .* .*
["H, W = map(int, input().split())\nfor _ in range(H):\n C = input()\n print(C)\n print(C)", "H,W = map(int,input().split())\nlis = []\n\nfor _ in range(H):\n C = input()\n lis.append(C)\n lis.append(C)\n\nfor i in lis:\n print(i)", "h,w=map(int,input().split())\nc = [input() for _ in range(h)]\n\nfor i in c:\n print(i)\n print(i)", "#\n# abc049 b\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 = \"\"\"2 2\n*.\n.*\"\"\"\n output = \"\"\"*.\n*.\n.*\n.*\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_2(self):\n input = \"\"\"1 4\n***.\"\"\"\n output = \"\"\"***.\n***.\"\"\"\n self.assertIO(input, output)\n\n def test_\u5165\u529b\u4f8b_3(self):\n input = \"\"\"9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........\"\"\"\n output = \"\"\".....***....***.....\n.....***....***.....\n....*...*..*...*....\n....*...*..*...*....\n...*.....**.....*...\n...*.....**.....*...\n...*.....*......*...\n...*.....*......*...\n....*.....*....*....\n....*.....*....*....\n.....**..*...**.....\n.....**..*...**.....\n.......*..*.*.......\n.......*..*.*.......\n........**.*........\n........**.*........\n.........**.........\n.........**.........\"\"\"\n self.assertIO(input, output)\n\n\ndef resolve():\n H, W = list(map(int, input().split()))\n ans = []\n for i in range(H):\n S = input()\n ans.append(S)\n ans.append(S)\n\n for i in range(2*H):\n print((ans[i]))\n\n\ndef __starting_point():\n # unittest.main()\n resolve()\n\n__starting_point()", "def main():\n H, W = list(map(int, input().split()))\n for _ in range(H):\n C = input()\n print(C)\n print(C)\n\ndef __starting_point():\n main()\n\n__starting_point()", "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############################################################\nH, W = lint()\nimage = lnstr(H)\nfor column in image:\n print(column)\n print(column)\n", "h, w = map(int, input().split())\nc = [list(input()) for i in range(h)]\nfor i in c:\n for j in i:\n print(j, end ='')\n print('')\n for j in i:\n print(j, end ='')\n print('')", "H, W = map(int, input().split())\nC = [input() for _ in range(H)]\n[print(C[i//2]) for i in range(2 * H)]", "h, w = list(map(int, input().split()))\n\nfor i in range(h):\n c = input()\n for i in range(2):\n print(c)\n", "h,w= map(int,input().split())\nc = [input() for _ in range(h)]\nl = []\nfor i in range(h):\n l.append(c[i])\n l.append(c[i])\nfor i in l:\n print(i)", "# coding: utf-8\n\nheight, width = map(int, input().split())\nfor i in range(height):\n str = input()\n print(str)\n print(str)", "H, W = list(map(int, input().split()))\nC = []\nfor i in range(H):\n x = str(input())\n C.append(x)\nfor i in range(H):\n print((C[i]))\n print((C[i]))\n", "\nurl = \"https://atcoder.jp//contests/abc049/tasks/abc049_b\"\n\ndef main():\n h, w = list(map(int, input().split()))\n ss = [input() for _ in range(h)]\n for s in ss:\n print(s)\n print(s)\n\ndef __starting_point():\n main()\n\n__starting_point()", "H, _ = map(int, input().split())\nfor _ in range(H):\n row = input()\n print(row)\n print(row)", "h, w = map(int, input().split())\nc = []\nfor _ in range(h):\n s = input()\n c.append(s)\n c.append(s)\nprint(\"\\n\".join(c))", "h,w = [int(x) for x in input().split()]\nfor i in range(h):\n s = input()\n print(s)\n print(s)", "h,w = map(int,input().split())\nc = []\nfor _ in range(h):\n c.append(input())\nfor i in range(h):\n print(c[i])\n print(c[i])", "h,j=map(int,input().split())\nfor i in range(h):\n a=input()\n print(a)\n print(a)", "H, W = map(int, input().split())\nC = [input() for _ in range(H)]\nWprint = lambda x:(print(x),print(x))\nfor c in C:\n Wprint(c) ", "h,w=map(int,input().split())\nfor i in range(h):\n c=input()\n print(c)\n print(c)", "H,W = list(map(int,input().split()))\n\nfor h in range(H):\n C=input()\n print(C)\n print(C)\n", "h, w = map(int,input().split())\nc = [list(input()) for i in range(h)]\nfor pic in c:\n print(\"\".join(pic))\n print(\"\".join(pic))", "#-*-coding:utf-8-*-\nimport sys\ninput=sys.stdin.readline\nimport numpy as np\n\ndef main():\n dot=[]\n h,w = map(int,input().split())\n dot=np.array([list(input().rstrip()) for _ in range(h)])\n \n for i in range(1,h+1):\n print(\"\".join(dot[i-1]))\n print(\"\".join(dot[int(i+1/2)-1]))\n\ndef __starting_point():\n main()\n__starting_point()", "h,w=map(int,input().split())\nc=[input() for _ in range(h)]\nfor i in range(h):\n print(c[i])\n print(c[i])", "h, w = list(map(int, input().split()))\n\nfor y in range(h):\n s = input()\n print(s)\n print(s)\n", "H, W = list(map(int, input().split()))\nC = [[s for s in input().split()] for _ in range(H)]\n\nfor i in range(H):\n print((*C[i]))\n print((*C[i]))\n", "a,b=list(map(int,input().split()))\n\nfor i in range(a):\n b=input()\n \n for i in range(2):\n print(b)\n \n", "h, w = map(int, input().split())\nP = [input() for _ in range(h)]\n\nfor s in P:\n print(s)\n print(s)", "h, w = map(int, input().split())\n\nlines = [input() for _ in range(h)]\n\nfor line in lines:\n print(line)\n print(line)", "h, w = map(int, input().split())\nc_l = [ str(input()) for _ in range(h) ]\n\nfor c in c_l:\n print(c)\n print(c)", "h, w = map(int, input().split())\nc = []\n\nfor i in range(h):\n c.append(input().split())\n\nfor i in range(h):\n s = ''.join(c[i])\n print(s + '\\n' + s)", "H, W = map(int, input().split())\n\nC = [input() for _ in range(H)]\n\nfor c in C:\n print(c)\n print(c)", "h, w = map(int, input().split()) \nfor i in range(h):\n s = input()\n print(s)\n print(s)", "H, W = map(int, input().split())\nC = [input() for i in range(H)]\n\nans = ['' for i in range(H*2)]\n\nfor i in range(H):\n for j in range(W):\n ans[2 * i] += C[i][j]\n ans[2 * i + 1] += C[i][j]\nfor i in range(2 * H):\n print(ans[i])", "h,w=map(int,input().split())\nc=[input() for i in range(h)]\nfor i in range(h):\n print(c[i]+'\\n'+c[i])", "num = input().split()\nhei = int(num[0])\nwei = int(num[1])\n\nphoto = []\n\nfor i in range(hei):\n temp = input()\n temp = list(temp)\n photo.append(temp)\n photo.append(temp)\n \nfor i in range(hei*2):\n for j in range(wei):\n print(photo[i][j],end=\"\")\n print(\"\\n\",end=\"\")", "h, _ = list(map(int, input().split()))\nfor i in range(h):\n s = input()\n print((s+'\\n'+s))\n", "x,y = map(int,input().split())\nfor _ in range(x):\n N = list(input())\n for _ in range(2):\n print(''.join(N))", "h, w = map(int, input().split())\na = []\nfor _ in range(h):\n a.append(input())\nfor i in range(h):\n print(a[i])\n print(a[i])", "H, W = map(int, input().split())\n\nfor _ in range(H):\n C = input()\n print(C)\n print(C)", "H, W = map(int, input().split())\n\nfor i in range(H):\n s = input()\n print(s)\n print(s)", "H,W=list(map(int,input().split()))\nC=[input() for _ in range(H)]\nfor i in range(H):\n print((C[i]))\n print((C[i]))\n", "H, W = list(map(int, input().split()))\nfor i in range(H):\n S = input()\n print((S+'\\n'+S))\n", "n,m = map(int, input().split())\n\nfor i in range(n):\n s = input()\n print(s)\n print(s)", "H, W = list(map(int, input().split()))\nL = []\nfor _ in range(H):\n c = input()\n L.append(c)\n L.append(c)\n\nfor i in L:\n print(i)\n", "h, w = map(int, input().split())\nfor _ in range(h):\n s = input()\n print(s)\n print(s)", "H, W = map(int, input().split())\nL = []\n\nfor i in range(H):\n C = list(map(str, input().split()))\n L.append(C)\n L.append(C)\n\nfor i in range(2*H):\n print(L[i][0])", "from typing import List\n\n\ndef answer(h: int, w: int, c: List[str]) -> str:\n result = []\n for i in c:\n for _ in range(2):\n result.append(i)\n\n return '\\n'.join(result)\n\n\ndef main():\n h, w = list(map(int, input().split()))\n c = [input() for _ in range(h)]\n print((answer(h, w, c)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "h,w=map(int, input().split())\nl=[0]*2*h\nfor i in range(h):\n c=input()\n l[2*i]=c\n l[2*i+1]=c\n \nfor i in range(h):\n print(l[2*i])\n print(l[2*i+1])", "h, w = map(int,input().split())\n\nfor i in range(h):\n c = input()\n print(c)\n print(c)", "h,w = map(int,input().split())\nc = []\nfor _ in range(h):\n c.append(input())\n \nfor i in range(2*h):\n print(c[i//2])", "for i in range(int(input().split()[0])):\n a = input()\n print(a, a, sep='\\n')", "H, W = list(map(int, input().split()))\nfor i in range(H):\n s = input()\n print(s)\n print(s)\n\n", "H,W = map(int, input().split())\nfor i in range(H):\n x = input()\n print(x)\n print(x)", "H, W = map(int, input().split())\nC = [input() for _ in range(H)]\n\nfor i in range(2*H):\n print(C[i// 2])", "a,b=input().split()\na=int(a)\nb=int(b)\nc=[input() for i in range(a)]\nfor i in range(a):\n print(c[i])\n print(c[i])", "h,w = map(int,input().split())\ndata=[]\nfor i in range(h):\n data.append(input())\nfor i in range(2 * h):\n print(data[i // 2])", "h, w = list(map(int, input().split()))\nc = []\nfor i in range(h):\n s = input()\n c.append(s)\n c.append(s)\nprint((\"\\n\".join(c)))\n", "h,w=map(int,input().split())\nfor i in range(h):\n c=input()\n print(c)\n print(c)", "h,w=map(int,input().split());[print(i+'\\n'+i) for i in [input() for _ in range(h)]]", "h, w = map(int, input().split())\nc = [list(input()) for i in range(h)]\n\nac = [[0] * (w) for i in range(2*h)]\nfor i in range(2*h):\n for j in range(w):\n ac[i][j] = c[i//2][j]\n\nfor s in ac:\n print(*s, sep='')", "x,y = map(int,input().split())\nL = []\n\nfor _ in range(x):\n N = list(input())\n L.append(N)\n L.append(N)\n \nfor l in L:\n print(''.join(l))", "h,w = map(int,input().split())\nc = []\nfor i in range(h):\n a = input()\n c.append(a)\nfor i in range(h):\n print(c[i])\n print(c[i])", "import sys\ninput = sys.stdin.readline\nsys.setrecursionlimit(200000)\n\n\ndef read():\n H, W = list(map(int, input().strip().split()))\n C = []\n for i in range(H):\n c = input().strip()\n C.append(c)\n return H, W, C\n\n\ndef solve(H, W, C):\n for c in C:\n print(c)\n print(c)\n\n\ndef __starting_point():\n inputs = read()\n solve(*inputs)\n\n__starting_point()", "H, W = [int(a) for a in input().split()]\nlst = []\nfor i in range(H):\n lst.append(input())\n \nfor i in range(H):\n print(lst[i])\n print(lst[i])", "h, w = list(map(int, input().split()))\nstr = [input() for i in range(h)]\nfor i in range(h):\n print((str[i]))\n print((str[i]))\n", "h, w = list(map(int, input().split()))\nfor _ in range(h):\n s = input()\n print(s)\n print(s)\n", "h,w = map(int,input().split())\nfor i in range(h):\n x = input()\n print(x)\n print(x)", "h, w = map(int, input().split())\nfor i in range(h):\n row = input()\n print(row)\n print(row)", "H, W = map(int, input().split())\nC = [input() for _ in range(H)]\n \nfor i in range(H):\n print(C[i])\n print(C[i])", "H, W = map(int, input().split())\nfor i in range(H):\n x = input()\n print(x)\n print(x)", "h, w = map(int,input().split())\npixel = [input() for _ in range(h)]\nfor i in pixel:\n for j in range(2):\n print(i)", "H,W = map(int, input().split())\n\nfor i in range(H):\n x = input()\n print(x)\n print(x)", "h,w=map(int,input().split())\nfor i in range(h):\n c=input()\n c=c+\"\\n\"+c\n print(c)", "from typing import List\n\n\ndef answer(h: int, w: int, c: List[str]) -> str:\n result = ''\n for i in c:\n for j in range(2):\n result += f'{i}\\n'\n\n return result[:-1]\n\n\ndef main():\n h, w = list(map(int, input().split()))\n c = [input() for _ in range(h)]\n print((answer(h, w, c)))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "h, w = map(int, input().split()) \nfor i in range(h):\n s = input()\n print(s)\n print(s)", "h,w=map(int,input().split())\nfor i in range(h):\n c=input()\n print(c)\n print(c)", "h, w = map(int, input().split())\nc_lst = [list(map(str, input().split())) for _ in range(h)]\n\nnew_lst = []\nfor i in range(h):\n new_lst.append(c_lst[i])\n new_lst.append(c_lst[i])\n\nfor i in range(len(new_lst)):\n new = new_lst[i][0]\n print(new)", "h, w = map(int, input().split())\nc = []\nfor _ in range(h):\n c.append(list(input()))\nfor i in range(2*h):\n print(\"\".join(c[i//2]))", "h, w = list(map(int, input().split()))\nc = []\nfor i in range(h):\n c.append(input())\n\nfor i in range(h * 2):\n res = \"\"\n for j in range(w):\n res += c[i // 2][j]\n print(res)\n", "h, _ = list(map(int, input().split()))\nfor _ in range(h):\n s = input()\n print((s+'\\n'+s))\n", "h, w = list(map(int, input().split()))\nfor _ in range(h):\n s = input()\n print(s)\n print(s)\n", "#!/usr/bin/env python3\nH, W = list(map(int, input().split()))\nc = [input() for i in range(H)]\n\nfor i in range(H):\n print((c[i]))\n print((c[i]))\n", "h, w = map(int, input().split())\np = [input() for _ in range(h)]\nfor i in range(h):\n print(p[i])\n print(p[i])", "h,w = map(int,input().split())\nc = []\nfor _ in range(h):\n c.append(input())\nfor i in range(h):\n print(c[i])\n print(c[i])", "h,w=map(int,input().split())\nfor _ in range(h):\n c=input()\n print(c)\n print(c)", "H,W = map(int, input().split())\n\nC = [input() for i in range(H)]\n\nfor i in range(H):\n print(C[i])\n print(C[i])", "h,w = map(int,input().split())\n\nfor i in range(h):\n\ta = input()\n\tprint(a)\n\tprint(a)", "h,w = map(int, input().split())\nfor i in range(h):\n s = input()\n print(s)\n print(s)", "H,W=list(map(int,input().split()))\n\nfor i in range(H):\n S=input()\n print(S)\n print(S)\n", "h,w = map(int,input().split())\nfor i in range(h):\n s = input()\n print(s)\n print(s)", "h, w = map(int, input().split())\nfor i in range(h):\n str_ = input()\n print(str_)\n print(str_)", "n,m = list(map(int,input().split()))\nfor i in range(n):\n q = input()\n print(q)\n print(q)\n", "H, W = map(int,input().split())\ngrid = []\nfor i in range(H):\n array = list(input().strip().split())\n grid.append(array)\n\nfor i in range(H):\n print(''.join(grid[i]))\n print(''.join(grid[i]))", "H, W = [int(x) for x in input().split()]\nfor i in range(H):\n str_list = input()\n print(str_list)\n print(str_list)", "import copy\nh,w = map(int,input().split())\nli = []\nfor i in range(h):\n li.append(input())\n#print(li)\nlis = copy.copy(li)\n#print(lis)\n#list1 = li+lis\n#print(list1)\nfor i in range(h):\n print(li[i])\n print(lis[i])", "h, w = map(int, input().split())\nfor i in range(h):\n c = input()\n print(c)\n print(c)", "h,w=list(map(int,input().split()))\nl=[input()for _ in range(h)]\nfor i in l:\n print(i)\n print(i)\n", "h, w = list(map(int, input().split()))\nc = [list(input()) for _ in range(h)]\ncc = [[] for i in range(2 * h)]\nfor i in range(h):\n cc[2*i].append(c[i])\n print((\"\".join(*cc[2*i])))\n cc[2*i + 1].append(c[i])\n print((\"\".join(*cc[2*i + 1])))\n\n"]
{"inputs": ["2 2\n*.\n.*\n", "1 4\n***.\n", "9 20\n.....***....***.....\n....*...*..*...*....\n...*.....**.....*...\n...*.....*......*...\n....*.....*....*....\n.....**..*...**.....\n.......*..*.*.......\n........**.*........\n.........**.........\n"], "outputs": ["*.\n*.\n.*\n.*\n", "***.\n***.\n", ".....***....***.....\n.....***....***.....\n....*...*..*...*....\n....*...*..*...*....\n...*.....**.....*...\n...*.....**.....*...\n...*.....*......*...\n...*.....*......*...\n....*.....*....*....\n....*.....*....*....\n.....**..*...**.....\n.....**..*...**.....\n.......*..*.*.......\n.......*..*.*.......\n........**.*........\n........**.*........\n.........**.........\n.........**.........\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
16,583
1fb781f53e1a6b427f73ef0c24d3f2fe
UNKNOWN
Given is a sequence of integers A_1, A_2, ..., A_N. If its elements are pairwise distinct, print YES; otherwise, print NO. -----Constraints----- - 2 ≀ N ≀ 200000 - 1 ≀ A_i ≀ 10^9 - All values in input are integers. -----Input----- Input is given from Standard Input in the following format: N A_1 ... A_N -----Output----- If the elements of the sequence are pairwise distinct, print YES; otherwise, print NO. -----Sample Input----- 5 2 6 1 4 5 -----Sample Output----- YES The elements are pairwise distinct.
["def N():\n return int(input())\ndef L():\n return list(map(int,input().split()))\ndef NL(n):\n return [list(map(int,input().split())) for i in range(n)]\nmod = pow(10,9)+7\n\n#import numpy as np\nimport sys\nimport math\nimport collections\n\nn =N()\na = L()\ns = set()\nfor i in range(n):\n if a[i] in s:\n print(\"NO\")\n return\n s.add(a[i])\nprint(\"YES\")", "N = int(input())\nA_ls = input().split(' ')\nrst = set()\nfor i in A_ls:\n rst.add(i)\nif len(rst) == N:\n print('YES')\nelse:\n print('NO')", "import copy\n\nN = int(input())\nlist1 = list(map(int, input().split()))\nlist2 = copy.copy(list1)\nlist3 = set(list1)\n\n\n\nx=len(list2)\ny=len(list3)\n\n\nif x==y:\n print('YES')\nelse:\n print('NO')", "def resolve():\n n = int(input())\n a = tuple(map(int,input().split()))\n print('YES' if len(a)==len(set(a)) else 'NO')\nresolve()", "N = int(input())\nA_ls = list(input().split(' '))\nA_set = { i for i in A_ls }\nif len(A_set) == N:\n print('YES')\nelse:\n print('NO')", "N = int(input())\nA = list(map(int, input().split()))\n\nans = \"NO\"\nif N == len(set(A)):\n ans = \"YES\"\n\nprint(ans)\n", "N=int(input())\nA=sorted(list(map(int,input().split())))\nl=[]\n#print(A)\nfor i in range(N-1):\n l.append(A[i+1]-A[i])\n\nif 0 in l:\n print('NO')\nelse:print('YES')\n", "n = int(input())\na = list(map(int,input().split()))\nans = len(a)\na1 = set(a)\nans1 = len(a1)\n\nif ans == ans1:\n print(\"YES\")\nelse:\n print(\"NO\")", "num = int(input())\ntable = list(map(int, input().split()))\ncount = 0\nlist.sort(table)\nif num == 2:\n if table[0] == table[1]:\n count += 1\nelse:\n for i in range(1, num-1):\n if num == 2:\n if table[0] == table[1]:\n count += 1\n elif table[i] == table[i+1] or table[i-1] == table[i]:\n count += 1\n else:\n continue\nif count == 0:\n print('YES')\nelse:\n print('NO')", "n = int(input())\nprint(\"YES\" if len(set(map(int,input().split())))==n else \"NO\")", "N = int(input())\nA = list(map(int, input().split()))\n\nprint('YES' if len(set(A)) == N else 'NO')", "n = int(input())\nan = list(map(int,input().split()))\nan.sort()\n\nfor x in range(n-1):\n if an[x+1]-an[x] == 0:\n print(\"NO\")\n break\n\nelse:\n print(\"YES\")\n", "n=int(input())\nx=list(map(int,input().split()))\nif(len(set(x))==n):print(\"YES\")\nelse:print(\"NO\")\n", "input();a=[*map(int,input().split())];print('YNEOS'[len(set(a))!=len(a)::2])", "import sys\n\nn = int(input())\na = dict()\nfor x in map(int, input().split()):\n if a.get(x) == 1:\n print('NO')\n return\n\n a[x] = 1\n\nprint('YES')\n", "N = int(input())\nlst = list(map(int, input().split()))\nk = list(set(lst))\nif len(k) == N:\n print('YES')\n\nelse:\n print('NO')", "n = int(input())\nl = list(map(int, input().split()))\nl.sort()\nfor i in range(n-1):\n\tif l[i] == l[i+1]:\n\t\tprint('NO')\n\t\treturn\n\nprint('YES')", "n = int(input())\na = list(map(int, input().split()))\na = sorted(a)\nans = \"YES\"\n\nfor i in range(n-1):\n if a[i] == a[i+1]:\n ans = \"NO\"\n break\n\nprint(ans)\n", "N=int(input())\n#b,c=int(input()),int(input())\n# c=[]\n# for i in b:\n# c.append(i)\n#e1,e2 = map(int,input().split())\nA = list(map(int,input().split()))\n#j = [input() for _ in range(a)]\n# h = []\n# for i in range(e1):\n# h.append(list(map(int,input().split())))\nA.sort()\nans=\"YES\"\nfor i in range(1,N):\n if A[i-1]==A[i]:\n ans=\"NO\"\n break\nprint(ans)", "input()\na=list(map(int,input().split()))\n\nprint((\"YES\" if len(a)==len(set(a)) else \"NO\"))\n", "n = int(input())\nA = list(map(int, input().split()))\n\nA = list(set(A))\n\nif len(A) == n:\n print('YES')\nelse :\n print('NO')", "n = int(input())\na = list(map(int, input().split()))\nan = set(a)\n\nif len(a) == len(an):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "n = int(input())\na = list(map(int,input().split()))\naa = set(a)\nprint(\"YES\" if len(a) ==len(aa) else \"NO\")", "N=int(input())\nK=set(input().split())\ni=len(K)\nif i==N:\n print('YES')\nelse:\n print('NO')", "N = int(input())\nA = list(map(int, input().split()))\n\ns=set()\nfor i in range(N):\n s.add(A[i])\n \nif len(s)==N:\n print(\"YES\")\nelse:\n print(\"NO\")", "N = int(input())\nA_ls = input().split(' ')\nA_set = { i for i in A_ls }\nif len(A_set) == N:\n print('YES')\nelse:\n print('NO')", "N = int(input())\nA = input().split()\n\nA_set = set(A)\n\nif len(A) == len(A_set):\n print('YES')\nelse:\n print('NO')", "N=int(input())\nA=sorted(list(map(int,input().split())))\nl=[]\nfor i in range(N-1):\n l.append(A[i+1]-A[i])\n\nif 0 in l:\n print('NO')\nelse:print('YES')\n", "N = int(input())\nA = sorted([int(i) for i in input().split()])\nfor i in range(N-1):\n if(A[i] == A[i+1]):\n print(\"NO\")\n return\nprint(\"YES\")", "n=int(input())\nnums=list(map(int,input().split()))\nsetnum=set(nums)\nif(len(setnum)==n):\n print(\"YES\")\nelse:\n print(\"NO\")", "n = int(input())\na = list(map(int,input().split()))\na.sort()\nans = 'YES'\nfor i in range(n-1):\n if a[i] == a[i+1]:\n ans = 'NO' \nprint(ans)", "import collections\nN = int(input())\nA = list(map(int, input().split()))\n\nC = collections.Counter(A)\n\nV = C.values()\nL = list(V)\n\n\nfor i in range(len(L)):\n if L[i] > 1:\n print('NO')\n return\n \nprint('YES')", "N = int(input())\nA = list(map(int, input().split()))\n\nflag = True\nA = sorted(A)\nfor i in range(N-1):\n if A[i] == A[i+1]:\n flag = False\nif flag:\n print(\"YES\")\nelse:\n print(\"NO\")", "N = int(input())\nA = list(map(int, input().split()))\nA_ = set(A)\nif len(A) == len(A_):\n print('YES')\n return\nelse:\n print('NO')\n return", "n = int(input())\na = map(int, input().split())\nc = set(a)\n\nif len(c) == n:\n print('YES')\nelse:\n print('NO')", "n = int(input())\ns = list(map(int,input().split()))\ntemp = len(s)\nans = len(list(set(s)))\nif temp == ans:\n print('YES')\nelse:\n print('NO')", "n = int(input())\nlst = [ int(i) for i in input().split()]\n \nif len(set(lst)) == n:\n print(\"YES\")\nelse:\n print(\"NO\")", "n=int(input())\na=list(map(int,input().split()))\nb=set(a)\nif len(a)==len(b):\n print('YES')\nelse:\n print('NO')", "N = int(input())\nA = list(map(int, input().split()))\n\nA_set = set(A)\n\nif len(A) == len(A_set):\n print('YES')\nelse:\n print('NO')", "n = int(input())\nm = len(set(map(int, input().split())))\nprint(('YES' if n == m else 'NO'))\n", "n = int(input())\nA = list(map(int,input().split()))\nUA = set(A)\nprint('YES' if len(A) == len(UA) else 'NO')", "N = int(input())\nA = list(map(int, input().split()))\nA.sort()\nprint(\"YNEOS\"[any(a==b for a, b in zip(A, A[1:]))::2])", "n=int(input())\na=list(map(int,input().split()))\nprint(('YES' if len(a)==len(set(a)) else 'NO'))\n", "n = int(input())\na = list(map(int,input().split()))\nprint(\"YES\" if len(set(a))==len(a) else \"NO\")", "N=int(input())\nA=list(map(int,input().split()))\ndic={}\nfor num in A:\n if num not in dic:\n dic[num]=1 \n else:\n dic[num]+=1\nif max(dic.values())>1:\n print('NO')\nelse:\n print('YES')", "n = int(input())\nA = list(map(int, input().split()))\nA.sort()\nsuccess = True\nfor i in range(n-1):\n if A[i] == A[i+1]:\n success = False\n break\nif success:\n print(\"YES\")\nelse:\n print(\"NO\")", "N = int(input())\nA =list(map(int, input().split()))\n\nprint('YES') if len(set(A)) == N else print('NO')", "N = int(input())\nA_ls = map(int, input().split(' '))\nrst = set()\nfor i in A_ls:\n rst.add(i)\nif len(rst) == N:\n print('YES')\nelse:\n print('NO')", "n = int(input())\na = [int(x) for x in input().split()]\nc = []\nres = \"YES\"\nfor i in range(n):\n c.append(a[i])\nc = set(c)\nif len(c) != n:\n res = \"NO\"\nprint(res)", "n = int(input())\na = list(map(int,input().split()))\na.sort()\nbefore = a[0]\nfor i in range(1,n):\n if before == a[i]:\n print(\"NO\")\n break\n before = a[i]\nelse:\n print(\"YES\")", "n=int(input())\na=list(map(int,input().split()))\n\nb=set(a)\n\nif len(a)==len(b):\n print('YES')\nelse:\n print('NO')", "N = int(input())\nA = list(map(int, input().split()))\n\nA.sort()\n\nans = 'YES'\nfor i in range(1, N):\n\tif A[i - 1] == A[i]:\n\t\tans = 'NO'\n\t\tbreak\n\nprint(ans)", "N = int(input())\nAlist = list(map(int,input().split()))\n\ntemp = len(Alist)\nansnum = len(list(set(Alist)))\n\nif ansnum == temp:\n print (\"YES\")\nelse :\n print (\"NO\")", "N=int(input())\nAs=sorted(list(map(int,input().split())))\nc=0\nfor i in range(N-1):\n c+=(As[i]==As[i+1])\nprint('YNEOS'[c>0::2])", "n=int(input())\nA=set(map(int, input().split()))\nif len(A)==n:\n print('YES')\nelse:\n print('NO')", "n = int(input())\nlst = list(map(int,input().split()))\nx = len(lst)\nlst = list(set(lst))\ny = len(lst)\n\nif (x == y):\n print(\"YES\")\nelse:\n print(\"NO\")\n", "N = int(input())\nA = list(map(int, input().split()))\n\ndic = {}\nfor a in A:\n if a in dic:\n dic[a] += 1\n else:\n dic[a] = 1\n\nM = max(dic.values())\nprint(\"YES\" if M == 1 else \"NO\")", "N = int(input())\nA_ls = map(int, input().split(' '))\nrst = { i for i in A_ls }\nif len(rst) == N:\n print('YES')\nelse:\n print('NO')", "n = int(input())\na = sorted([int(i) for i in input().split()])\nans = 'YES'\nfor i in range(1, n):\n if a[i-1] == a[i]:\n ans = 'NO'\n break\nprint(ans)", "N = int(input())\nA = list(map(int,input().split()))\nset_A = list(set(A))\n\nif len(set_A) == N:\n print(\"YES\")\nelse:\n print(\"NO\")", "import sys\nn = int(input())\nlst = list(map(int,input().split()))\n\nlst.sort()\nfor i in range(n-1):\n if lst[i] == lst[i+1]:\n print('NO')\n return\nprint('YES') \n \n", "\n\n\nn = int(input())\nnums = input().split(' ')\nnums = [int(x) for x in nums]\ns = set()\nb = False\nfor x in nums:\n if x in s:\n print(\"NO\")\n b = True\n break\n s.add(x)\nif not b:\n print(\"YES\")\n \n\n\n\n", "N = int(input())\nA = list(map(int,input().split()))\nA = sorted(A)\nfor i in range(N - 1):\n if A[i] == A[i + 1]:\n print('NO')\n return\nprint('YES')", "n=int(input())\na=list(map(int,input().split()))\nm=len(a)\na=set(a)\nn=len(a)\nif m==n:\n print(\"YES\")\nelse:\n print(\"NO\")", "N = int(input())\nA_ls = map(int, input().split(' '))\nrst = { i for i in A_ls }\nif len(rst) == N:\n print('YES')\nelse:\n print('NO')", "N = int(input())\nA = sorted(list(map(int,input().split())))\n\nfor i in range(1,N):\n if A[i] == A[i-1]:\n print(\"NO\")\n Flag = False\n break\n else:\n Flag = True\n\nif Flag:\n print(\"YES\")", "N=int(input())\nA=sorted(list(map(int,input().split())))\nl=[]\nfor i in range(N-1):\n l.append(A[i+1]-A[i])\n\nif 0 in l:\n print('NO')\nelse:print('YES')\n", "N=int(input())\nl=set(list(map(int, input().split())))\n\nprint(\"YES\") if N==len(l) else print(\"NO\")", "n = int(input())\na = map(int,input().split())\n\nif len(set(a)) == n:\n print(\"YES\")\nelse:\n print(\"NO\")", "def main():\n\tn = int(input())\n\tl = [int(v) for v in input().split()]\n\tif len(set(l)) == n:\n\t\treturn \"YES\"\n\treturn \"NO\"\n\t\n\ndef __starting_point():\n print((main()))\n\n__starting_point()", "n=int(input())\nS=list(map(int,input().split()))\n\nS_set=set(S)\n\nif len(S)==len(S_set):\n print('YES')\n\nelse:\n print('NO')", "import collections\nn = int(input())\naa = list(map(int, input().split()))\nc =collections.Counter(aa)\nif len(c) == n:\n print('YES')\nelse:\n print('NO')", "N = int(input())\nls = input().split(' ')\ndic = { i for i in ls }\nif len(dic) == N:\n print('YES')\nelse:\n print('NO')", "m = int(input())\nn = list(map(int,input().split()))\nprint(\"YES\" if len(set(n)) == m else \"NO\")", "n = int(input())\na_list = input().split()\nif len(a_list) == len(set(a_list)) :\n print('YES')\nelse:\n print('NO')", "n = int(input())\na = list(map(int, input().split()))\na.sort()\nans='YES'\nfor i in range(n-1):\n if a[i] == a[i+1]:\n ans='NO'\n break\nprint(ans)", "n = int(input())\na = set(map(int, input().split()))\n\nprint('YES') if n==len(a) else print('NO')", "n = int(input())\nalist = list(map(int,input().split()))\nif len(set(alist))==n:\n print(\"YES\")\nelse:\n print(\"NO\")", "N = int(input())\nA = list(map(int, input().split()))\n\nif N == len(set(A)):\n print('YES')\nelse:\n print('NO')", "n = int(input())\na = list(set(map(int, input().split())))\n\nprint('YES') if n==len(a) else print('NO')", "n = int(input())\n\na = list(map(int, input().split()))\n\n\nx = len(set(a))\n\n\nif x == len(a):\n print(\"YES\")\nelse:\n print(\"NO\")", "n = int(input())\n\na = list(map(int, input().split()))\nb = set(a)\n\nprint('YES' if len(a) == len(b) else 'NO')", "import collections\n\nn = int(input())\na = list(input().split())\nc = collections.Counter(a)\n\nif c.most_common()[0][1] != 1:\n print('NO')\n return\n\nprint('YES')", "N = int(input())\nA = input().split()\nans = 'YES' if len(A) - len(set(A)) == 0 else 'NO'\nprint(ans)", "N = int(input())\nA = [int(n) for n in input().split()]\n\nif len(set(A)) == N:\n print('YES')\nelse:\n print('NO')", "def DuplicateCheck(seq):\n return len(seq) != len(set(seq))\n\nN=input()\nA=input().split()\nprint('NO' if DuplicateCheck(A) else 'YES')", "n = int(input())\na = list(map(int,input().split()))\nb = sorted(a)\nmemo = 0\nfor i in range(n-1):\n if(b[i]==b[i+1]):\n memo +=1\nif(memo==0):\n print(\"YES\")\nelse:\n print(\"NO\")", "n = int(input())\na = list(map(int,input().split()))\nb = len(set(a))\nif n == b:\n print(\"YES\")\nelse:\n print(\"NO\")", "n=int(input());print('YNEOS'[len(set(map(int,input().split())))!=n::2])", "n = int(input())\na = list(map(int,input().split()))\na = len(list(set(a)))\nif n == a:\n print(\"YES\")\nelse:\n print(\"NO\")", "n = int(input())\nA = list(map(int,input().split()))\nres = set()\nans = \"YES\"\nfor i in range(n):\n if(A[i] in res):\n ans = \"NO\"\n break\n res.add(A[i])\nprint(ans)", "n = int(input())\ns = set(map(int, input().split()))\nprint(\"YES\" if n == len(s) else \"NO\")", "N=int(input())\nA=list(map(int,input().split()))\nA.sort()\nfor i in range(N-1):\n if A[i]==A[i+1]:\n print(\"NO\")\n break\n if i==N-2:\n print(\"YES\")", "#!/usr/bin/env python3\ndef main():\n N = int(input())\n print(('YES' if len(set(input().split())) == N else 'NO'))\n\n\ndef __starting_point():\n main()\n\n__starting_point()", "_ = input()\nl = [ int(x) for x in input().split() ]\nl.sort()\n\nfor i in range(len(l)-1):\n if l[i] == l[i+1]:\n print('NO')\n return\n\nprint('YES')\n", "from collections import Counter\n\ncnt = input()\nnum_list = Counter(map(int, input().split()))\n\nfor _ in num_list.values():\n if _ > 1:\n print(\"NO\")\n break\nelse:\n print(\"YES\")", "from collections import Counter\nN=int(input())\nAlist=list(map(int,input().split()))\ncount=Counter(Alist)\nflag=True\nfor value in count.values():\n if value>1:\n flag=False\nprint('YES' if flag else 'NO')", "N = int(input())\nA_ls = list(input().split(' '))\nrst = { i for i in A_ls }\nif len(rst) == N:\n print('YES')\nelse:\n print('NO')", "N = int(input())\nA = [int(x) for x in input().split()]\n\nif len(set(A)) == len(A) :\n print(\"YES\")\nelse :\n print(\"NO\")", "n = int(input())\na = [int(s) for s in input().split()]\n\nprint('YES') if len(a) == len(set(a)) else print('NO')"]
{"inputs": ["5\n2 6 1 4 5\n", "6\n4 1 3 1 6 2\n", "2\n10000000 10000000\n"], "outputs": ["YES\n", "NO\n", "NO\n"]}
INTRODUCTORY
PYTHON3
ATCODER.JP
15,731
2f9eda2ce0e046119c5c6a911cd9eb1b
UNKNOWN
There are $n$ people who want to participate in a boat competition. The weight of the $i$-th participant is $w_i$. Only teams consisting of two people can participate in this competition. As an organizer, you think that it's fair to allow only teams with the same total weight. So, if there are $k$ teams $(a_1, b_1)$, $(a_2, b_2)$, $\dots$, $(a_k, b_k)$, where $a_i$ is the weight of the first participant of the $i$-th team and $b_i$ is the weight of the second participant of the $i$-th team, then the condition $a_1 + b_1 = a_2 + b_2 = \dots = a_k + b_k = s$, where $s$ is the total weight of each team, should be satisfied. Your task is to choose such $s$ that the number of teams people can create is the maximum possible. Note that each participant can be in no more than one team. You have to answer $t$ independent test cases. -----Input----- The first line of the input contains one integer $t$ ($1 \le t \le 1000$) β€” 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 participants. The second line of the test case contains $n$ integers $w_1, w_2, \dots, w_n$ ($1 \le w_i \le n$), where $w_i$ is the weight of the $i$-th participant. -----Output----- For each test case, print one integer $k$: the maximum number of teams people can compose with the total weight $s$, if you choose $s$ optimally. -----Example----- Input 5 5 1 2 3 4 5 8 6 6 6 6 6 6 8 8 8 1 2 2 1 2 1 1 2 3 1 3 3 6 1 1 3 4 2 2 Output 2 3 4 1 2 -----Note----- In the first test case of the example, we can reach the optimal answer for $s=6$. Then the first boat is used by participants $1$ and $5$ and the second boat is used by participants $2$ and $4$ (indices are the same as weights). In the second test case of the example, we can reach the optimal answer for $s=12$. Then first $6$ participants can form $3$ pairs. In the third test case of the example, we can reach the optimal answer for $s=3$. The answer is $4$ because we have $4$ participants with weight $1$ and $4$ participants with weight $2$. In the fourth test case of the example, we can reach the optimal answer for $s=4$ or $s=6$. In the fifth test case of the example, we can reach the optimal answer for $s=3$. Note that participant with weight $3$ can't use the boat because there is no suitable pair for him in the list.
["for _ in range(int(input())):\n n = int(input())\n wt = list(map(int, input().split()))\n count = {}\n for x in wt:\n if x not in count:\n count[x] = 0\n count[x] += 1\n k = 0\n\n for s in range(101):\n temp = 0\n temp2 = 0\n for x in count:\n if (s - x) in count:\n if (s - x) == x:\n temp2 += count[x] // 2\n else:\n temp += min(count[x], count[s -x])\n \n k = max(k, temp//2 + temp2)\n print(k)\n", "t=int(input())\nfor _ in range(t):\n n=int(input())\n a=list(map(int,input().split()))\n a.sort()\n ga=0\n for i in range(1,2*n+1):\n j,k=0,n-1 \n flag=True\n ans=0\n while(j<k):\n if a[j]+a[k]>i:\n k-=1 \n elif a[j]+a[k]<i:\n j+=1 \n else:\n j+=1 \n k-=1 \n ans+=1 \n ga=max(ans,ga)\n print(ga)\n", "import sys\ninput = sys.stdin.readline\nfrom collections import Counter\n\nt=int(input())\nfor tests in range(t):\n n=int(input())\n W=list(map(int,input().split()))\n C=Counter(W)\n\n ANS=0\n\n for i in range(n):\n for j in range(i+1,n):\n B=W[i]+W[j]\n\n A=0\n\n for c in C:\n if c*2==B:\n A+=C[c]//2\n\n elif c*2<B:\n A+=min(C[c],C[B-c])\n\n ANS=max(ANS,A)\n\n print(ANS)\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\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\nfor _ in range(val()):\n n = val()\n l = li()\n ans = 0\n for j in range(1, 101):\n curr = 0\n m = Counter(l)\n for i in l:\n if j - i != i and m[j - i] and m[i]:\n m[j-i] -= 1\n m[i] -= 1\n curr += 1\n if j - i == i and m[i] > 1:\n m[i] -= 2\n curr += 1\n # print(curr, j)\n ans = max(ans, curr)\n print(ans)", "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\nfrom fractions import Fraction\n#sys.setrecursionlimit(100000)\nINF = float('inf')\nmod = int(1e9)+7\n\nfor t in range(int(data())):\n n=int(data())\n w=sorted(mdata())\n ans=0\n for i in range(2,2*max(w)+1):\n cnt=0\n s,e=0,n-1\n while s<e:\n if w[s]+w[e]==i:\n cnt+=1\n s+=1\n e-=1\n elif w[s]+w[e]<i:\n s+=1\n else:\n e-=1\n ans=max(ans,cnt)\n out(ans)\n\n", "for _ in range(int(input())):\n n = int(input())\n u = list(map(int, input().split()))\n d = [0] * n\n for i in range(n):\n d[u[i] - 1] += 1\n ans = 0\n for s in range(1, 2 * n + 1):\n d1 = d[:]\n cnt = 0\n for i in range(n):\n if 0 <= s - u[i] - 1 < n and d1[s - u[i] - 1] > 0:\n cnt += 1\n d1[s - u[i] - 1] -= 1\n ans = max(ans, cnt)\n print(ans // 2)\n \n", "def solve():\n n = int(input())\n a = list(map(int, input().split()))\n a.sort()\n c = [0] * (n + 1)\n for i in a:\n c[i] += 1\n ans = 0\n for tw in range(1, 101):\n cans = 0\n b = [0] * (n + 1)\n for i in a:\n j = tw - i\n if j > n or j <= 0:\n continue\n if i != j and c[i] - b[i] >= 1 and c[j] - b[j] >= 1 \\\n or i == j and c[i] - b[i] >= 2:\n b[i] += 1\n b[j] += 1\n cans += 1\n ans = max(ans, cans)\n print(ans)\n\nt = int(input())\nfor _ in range(t):\n solve()", "t = int(input())\nfor _ in range(t):\n n = int(input())\n ws = sorted(map(int, input().split()))\n ans = 0\n for s in range(2, 101):\n count = 0\n l = 0\n r = n - 1\n while r > l:\n if ws[l] + ws[r] == s:\n l += 1\n r -= 1\n count += 1\n elif ws[l] + ws[r] < s:\n l += 1\n else:\n r -= 1\n ans = max(ans, count)\n print(ans)", "from collections import defaultdict\n\nt = int(input())\n\nfor _ in range(t):\n n = int(input())\n w = list(map(int, input().split()))\n counts = defaultdict(int)\n for x in w:\n counts[x] += 1\n \n m = 0\n for s in range(2, n*2+1):\n count = 0\n for x in list(counts.keys()):\n xcount = counts[x]\n if x < s-x: \n c = counts[s-x]\n count += min(c, xcount)\n elif x == s-x:\n count += xcount//2\n \n m = max(m, count)\n print(m)\n \n", "from bisect import bisect_left\nimport sys\ninput=sys.stdin.readline\nt = int(input())\n\nfor _ in range(t):\n l = int(input())\n a = list(map(int,input().split()))\n a.sort()\n \n ans = 0\n \n for w in range(1,2*l+1):\n c = 0\n used = {}\n for i in range(len(a)):\n for j in range(i+1, len(a)):\n if a[i] + a[j] == w and i not in used and j not in used:\n c += 1\n used[i] = 1\n used[j] = 1\n ans = max(c, ans)\n print(ans)", "#!/usr/bin/env pypy3\n\nfrom collections import Counter\n\ndef score(cN, target):\n\tret1 = 0\n\tret2 = 0\n\tfor k in cN:\n\t\tif 2*k == target:\n\t\t\tret1 += cN[k] // 2\n\t\telse:\n\t\t\tl = target - k\n\t\t\tret2 += min(cN[k], cN[l])\n\treturn ret1 + ret2//2\n\ndef ans(N):\n\tN = sorted(N)\n\tcN = Counter(N)\n\n\treturn max(score(cN, target) for target in range(2, 101))\n\nT = int(input())\nfor t in range(T):\n\tinput()\n\tN = list(map(int, input().split()))\n\t\n\tprint(ans(N))", "t = int(input())\nfor _ in range(t):\n\tn = int(input())\n\tarr = [int(j) for j in input().split()]\n\n\tcount = [0]*101\n\n\tfor x in arr:\n\t\tcount[x] += 1\n\n\tans = 0\n\tfor i in range(1, 101):\n\t\ttemp = 0\n\t\tfor j in range(1, i+1):\n\t\t\ttemp += min(count[j], count[i-j])\n\t\ttemp //= 2\n\t\tans = max(ans, temp)\n\tprint(ans)\n", "t = int(input())\nfor _ in range(t):\n n = int(input())\n w = list(map(int, input().split()))\n m = min(w)\n M = max(w)\n ans = 0\n for i in range(m*2, M*2+1):\n d = dict()\n tmp = 0\n for x in w:\n if i - x in d and d[i-x] > 0:\n d[i-x] -= 1\n tmp += 1\n else:\n if x in d:\n d[x] += 1\n else:\n d[x] = 1\n if ans < tmp:\n ans = tmp\n # print(tmp, i)\n print(ans)\n", "\nfor _ in range(int(input())):\n n = int(input())\n w = list(sorted(map(int, input().split())))\n ma = 0\n for s in range(2,2*n+1):\n l = 0\n r = n-1\n cnt = 0\n while l < r:\n cs = w[l] + w[r]\n if cs == s:\n cnt += 1\n l += 1\n r -= 1\n elif cs < s:\n l += 1\n else:\n r -= 1\n ma = max(cnt, ma)\n\n print(ma)\n\n"]
{ "inputs": [ "5\n5\n1 2 3 4 5\n8\n6 6 6 6 6 6 8 8\n8\n1 2 2 1 2 1 1 2\n3\n1 3 3\n6\n1 1 3 4 2 2\n", "4\n14\n2 6 5 9 5 8 13 14 12 5 6 14 5 2\n36\n15 22 27 7 23 36 10 17 33 21 18 22 3 4 32 24 8 19 36 22 17 11 24 10 33 4 30 6 2 17 11 16 18 1 2 20\n2\n2 2\n12\n4 9 10 6 1 9 5 8 8 9 9 12\n" ], "outputs": [ "2\n3\n4\n1\n2\n", "3\n10\n1\n4\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
8,454
031e26d7c854a74ac8a3debea747e48d
UNKNOWN
Vasya goes to visit his classmate Petya. Vasya knows that Petya's apartment number is $n$. There is only one entrance in Petya's house and the distribution of apartments is the following: the first floor contains $2$ apartments, every other floor contains $x$ apartments each. Apartments are numbered starting from one, from the first floor. I.e. apartments on the first floor have numbers $1$ and $2$, apartments on the second floor have numbers from $3$ to $(x + 2)$, apartments on the third floor have numbers from $(x + 3)$ to $(2 \cdot x + 2)$, and so on. Your task is to find the number of floor on which Petya lives. Assume that the house is always high enough to fit at least $n$ apartments. You have to answer $t$ independent test cases. -----Input----- The first line of the input contains one integer $t$ ($1 \le t \le 1000$) β€” the number of test cases. Then $t$ test cases follow. The only line of the test case contains two integers $n$ and $x$ ($1 \le n, x \le 1000$) β€” the number of Petya's apartment and the number of apartments on each floor of the house except the first one (there are two apartments on the first floor). -----Output----- For each test case, print the answer: the number of floor on which Petya lives. -----Example----- Input 4 7 3 1 5 22 5 987 13 Output 3 1 5 77 -----Note----- Consider the first test case of the example: the first floor contains apartments with numbers $1$ and $2$, the second one contains apartments with numbers $3$, $4$ and $5$, the third one contains apartments with numbers $6$, $7$ and $8$. Therefore, Petya lives on the third floor. In the second test case of the example, Petya lives in the apartment $1$ which is on the first floor.
["import sys\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 #n, t = map(int, sys.stdin.readline().split())\n #q = list(map(int, sys.stdin.readline().split()))\n #q = linput()\n n, x = list(map(int, sys.stdin.readline().split()))\n if n < 3:\n print(1)\n return 0\n print((n - 2 + x - 1) // x + 1)\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\nfor i in range(int(sys.stdin.readline().strip()) ):\n main()\n \n", "import sys, math\n\n\ninput = lambda: sys.stdin.readline().rstrip()\n\n\ndef gcd(n, f):\n if n == 0 or f == 0:\n return max(n, f)\n if n > f:\n return gcd(n % f, f)\n else:\n return gcd(f % n, n)\n\n\ndef division_with_remainder_up(pp, ppp):\n return (pp + ppp - 1) // ppp\n\n\nfor i in range(int(input())):\n n, k = map(int, input().split())\n n -= 2\n if n <= 0:\n print(1)\n else:\n print(division_with_remainder_up(n,k)+1)", "# Created by: WeirdBugsButOkay\n# 28-09-2020, 13:35:28\n\nimport math\n\ndef solve() :\n n, x = list(map(int, input().split()))\n ans = 1\n n -= 2\n while n > 0 :\n ans += 1\n n -= x\n print(ans)\n\nt = 1\nt = int(input())\nfor _ in range (0, t) :\n solve()\n", "'''\nName : Jaymeet Mehta\ncodeforces id :mj_13\nProblem : \n'''\nfrom sys import stdin,stdout\ntest=int(stdin.readline())\nfor _ in range(test):\n n,x = map(int,stdin.readline().split())\n n-=2\n ans=1\n while(n>0):\n n-=x\n ans+=1\n print(ans)", "# cook your dish here\n# code\n# ___________________________________\n# | |\n# | |\n# | _, _ _ ,_ |\n# | .-'` / \\'-'/ \\ `'-. |\n# | / | | | | \\ |\n# | ; \\_ _/ \\_ _/ ; |\n# | | `` `` | |\n# | | | |\n# | ; .-. .-. .-. .-. ; |\n# | \\ ( '.' \\ / '.' ) / |\n# | '-.; V ;.-' |\n# | ` ` |\n# | |\n# |___________________________________|\n# | |\n# | Author : Ramzz |\n# | Created On : 21-07-2020 |\n# |___________________________________|\n#\n# _ __ __ _ _ __ ___ ________\n# | '__/ _` | '_ ` _ \\|_ /_ /\n# | | | (_| | | | | | |/ / / / \n# |_| \\__,_|_| |_| |_/___/___|\n#\n\nimport math\nimport collections\nfrom sys import stdin,stdout,setrecursionlimit\nfrom bisect import bisect_left as bsl\nfrom bisect import bisect_right as bsr\nimport heapq as hq\nsetrecursionlimit(2**20)\n\nt = 1\nt = int(stdin.readline())\n\nfor _ in range(t):\n #n = int(stdin.readline())\n #s = stdin.readline().strip('\\n')\n n,x = list(map(int, stdin.readline().rstrip().split()))\n \n if(n==1 or n==2):\n print(1)\n else:\n n-=2\n cnt=1\n while(n>0):\n n -= x\n cnt+=1\n \n print(cnt)\n \n \n \n \n \n", "import sys\ninput = sys.stdin.readline\n\ndef getInts():\n return [int(s) for s in input().split()]\n\ndef getInt():\n return int(input())\n\ndef getStrs():\n return [s for s in input().split()]\n\ndef getStr():\n return input().strip()\n\ndef listStr():\n return list(input().strip())\n\nimport collections as col\nimport math,itertools\n\n\"\"\"\n\"\"\"\n\ndef solve():\n N, X = getInts()\n if N <= 2:\n return 1\n N -= 3\n return N//X + 2\n \n#print(solve())\nfor _ in range(getInt()):\n print(solve())\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\nfor _ in range(val()):\n n, x = li()\n if n <= 2:\n print(1)\n else:\n n -= 2\n print(1 + (n // x) + (1 if n % x else 0))", "from math import *\nfor _ in range(int(input())):\n n, x = list(map(int, input().split()))\n if n <= 2:\n print(1)\n else:\n print(1 + (n - 2 + x - 1) // x)", "for _ in range(int(input())):\n n, x = tuple(map(int, input().split()))\n if n <= 2:\n print(1)\n else:\n print((n - 3) // x + 2)\n", "'''\n Auther: ghoshashis545 Ashis Ghosh\n College: jalpaiguri Govt Enggineering College\n\n'''\nfrom os import path\nimport sys\nfrom heapq import heappush,heappop\nfrom functools import cmp_to_key as ctk\nfrom collections import deque,defaultdict as dd\nfrom bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\nfrom itertools import permutations\nfrom datetime import datetime\nfrom math import ceil,sqrt,log,gcd\ndef ii():return int(input())\ndef si():return input().rstrip()\ndef mi():return map(int,input().split())\ndef li():return list(mi())\nabc='abcdefghijklmnopqrstuvwxyz'\n# mod=1000000007\nmod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\ndef bo(i):\n return ord(i)-ord('a')\n\n\n\n \ndef solve():\n\n \n \n \n for _ in range(ii()):\n\n n,x = mi()\n if n<=2:\n print(1)\n continue\n\n c = 2\n p = 2+x\n while(n > p):\n p += x\n c += 1\n print(c) \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n \ndef __starting_point():\n\n \n if path.exists('input.txt'):\n sys.stdin=open('input.txt', 'r')\n sys.stdout=open('output.txt','w')\n else:\n input=sys.stdin.readline\n solve()\n__starting_point()", "def ii(): return int(input())\ndef li(): return list(map(int, input().split()))\n\n\nt = int(input())\n\nfor _ in range(t):\n n, x = list(map(int, input().split()))\n\n for i in range(n):\n if i*x+2 >= n:\n print(i+1)\n break\n", "for _ in range(int(input())):\n\tn, x = list(map(int, input().split()))\n\tl = 1\n\tr = 2\n\tcnt = 1\n\twhile True:\n\t\tif l <= n <= r:\n\t\t\tprint(cnt)\n\t\t\tbreak\n\t\telse:\n\t\t\tcnt+=1\n\t\t\tl = r + 1\n\t\t\tr += x\n", "for _ in range(int(input())):\n n, x = list(map(int, input().split()))\n if n <= 2:\n print(1)\n else:\n if (n - 2) % x == 0:\n print((n - 2) // x + 1)\n else:\n print((n - 2) // x + 2)\n", "import math\nimport collections\nt=int(input())\nfor w in range(t):\n n,x=(int(i) for i in input().split())\n if(n<=2):\n print(1)\n else:\n print(1+math.ceil((n-2)/x))", "import math\nfor _ in range(int(input())):\n x,y=map(int,input().split())\n if x<3:\n print(1)\n else:\n x-=2\n x=math.ceil(x/y)\n print(x+1)", "# for _ in range(1):\nfor _ in range(int(input())):\n # n = int(input())\n n, x = list(map(int, input().split()))\n # arr = list(map(int, input().split()))\n # s = input()\n if (n <= 2):\n print(1)\n else:\n n -= 3\n print(n // x + 2)\n", "import sys\nimport re\nimport random\nimport math\nimport copy\nfrom heapq import heappush, heappop, heapify\nfrom functools import cmp_to_key\nfrom bisect import bisect_left, bisect_right\nfrom collections import defaultdict, deque, Counter\n# sys.setrecursionlimit(1000000)\n\n# input aliases\ninput = sys.stdin.readline\ngetS = lambda: input().strip()\ngetN = lambda: int(input())\ngetList = lambda: list(map(int, input().split()))\ngetZList = lambda: [int(x) - 1 for x in input().split()]\n\nINF = float(\"inf\")\nMOD = 10**9 + 7\ndivide = lambda x: pow(x, MOD-2, MOD)\n\ndef solve():\n n, m = getList()\n if n <= 2:\n print(1)\n return\n else:\n f = (n-3) // m\n print(f + 2)\n\n\ndef main():\n n = getN()\n for _ in range(n):\n solve()\n\n return\ndef __starting_point():\n main()\n # solve()\n\n__starting_point()", "import sys\ninput=sys.stdin.readline\n\nT=int(input())\nfor _ in range(T):\n #n=int(input())\n n,x=list(map(int,input().split()))\n #A=list(map(int,input().split()))\n\n flag=1\n for i in range(2,n,x):\n flag=flag+1\n\n print(flag)\n", "t = int(input())\nwhile t:\n t -= 1\n n, x = list(map(int, input().split()))\n ans = 1\n total = 2\n if n <= 2:\n print(1)\n continue\n while True:\n total += x\n ans += 1\n if total >= n:\n print(ans)\n break\n", "from collections import *\nfrom heapq import *\nfrom math import *\n\n\nt = int(input())\nwhile t:\n t -= 1\n # n = int(input())\n n,x =[int(x) for x in input().split()]\n if n <= 2:\n print(1)\n else:\n n -= 2\n print(1+ceil(n/x))", "# if graph problem, dont forget to write sys.setrecursionlimit(10**7)\nfrom math import ceil, floor\n\n\ndef solve():\n\n n, x = list(map(int, input().split()))\n if (1 <= n <= 2):\n print(1)\n else:\n print(ceil((n-2)/x)+1)\n return\n\n\ndef main():\n T = int(input())\n for i in range(T):\n solve()\n return\n\n\ndef __starting_point():\n main()\n\n\n__starting_point()", "for _ in range (int(input())):\n a,b=map(int,input().split())\n if(a<=2):\n print(1)\n else:\n a-=2\n ans=1\n if(a%b!=0):ans=2\n ans+=a//b\n print(ans)", "from sys import stdin, stdout\ninput = stdin.readline\nfrom collections import defaultdict as dd\nimport math\ndef geti(): return list(map(int, input().strip().split()))\ndef getl(): return list(map(int, input().strip().split()))\ndef gets(): return input()\ndef geta(): return int(input())\ndef print_s(s): stdout.write(s+'\\n')\n\ndef solve():\n for _ in range(geta()):\n n,k=geti()\n n-=2\n ans=1\n while n>0:\n ans+=1\n n-=k\n print(ans)\n\ndef __starting_point():\n solve()\n\n__starting_point()", "for i in range(int(input())):\n n,x=list(map(int,input().split()))\n ans=2\n v=1\n if n<=2:\n print(1)\n else:\n for i in range(n-2):\n v+=1\n ans+=x\n if ans>=n:\n print(v)\n break\n", "import math\nfrom collections import deque\nfrom collections import defaultdict\n\nt = int(input())\nwhile t>0:\n t-=1\n n,x = list(map(int,input().strip().split(\" \")))\n \n if n==1 or n==2:\n print(1)\n else:\n n -= 2\n \n print(math.ceil(n/x)+ 1)\n"]
{ "inputs": [ "4\n7 3\n1 5\n22 5\n987 13\n", "7\n7 3\n1 5\n22 5\n987 13\n7 3\n1 5\n22 5\n" ], "outputs": [ "3\n1\n5\n77\n", "3\n1\n5\n77\n3\n1\n5\n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
11,656
09f6758f4ff430b2380d0cc16f472913
UNKNOWN
You want to perform the combo on your opponent in one popular fighting game. The combo is the string $s$ consisting of $n$ lowercase Latin letters. To perform the combo, you have to press all buttons in the order they appear in $s$. I.e. if $s=$"abca" then you have to press 'a', then 'b', 'c' and 'a' again. You know that you will spend $m$ wrong tries to perform the combo and during the $i$-th try you will make a mistake right after $p_i$-th button ($1 \le p_i < n$) (i.e. you will press first $p_i$ buttons right and start performing the combo from the beginning). It is guaranteed that during the $m+1$-th try you press all buttons right and finally perform the combo. I.e. if $s=$"abca", $m=2$ and $p = [1, 3]$ then the sequence of pressed buttons will be 'a' (here you're making a mistake and start performing the combo from the beginning), 'a', 'b', 'c', (here you're making a mistake and start performing the combo from the beginning), 'a' (note that at this point you will not perform the combo because of the mistake), 'b', 'c', 'a'. Your task is to calculate for each button (letter) the number of times you'll press it. You have to answer $t$ independent test cases. -----Input----- The first line of the input contains one integer $t$ ($1 \le t \le 10^4$) β€” the number of test cases. Then $t$ test cases follow. The first line of each test case contains two integers $n$ and $m$ ($2 \le n \le 2 \cdot 10^5$, $1 \le m \le 2 \cdot 10^5$) β€” the length of $s$ and the number of tries correspondingly. The second line of each test case contains the string $s$ consisting of $n$ lowercase Latin letters. The third line of each test case contains $m$ integers $p_1, p_2, \dots, p_m$ ($1 \le p_i < n$) β€” the number of characters pressed right during the $i$-th try. It is guaranteed that the sum of $n$ and the sum of $m$ both does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$, $\sum m \le 2 \cdot 10^5$). It is guaranteed that the answer for each letter does not exceed $2 \cdot 10^9$. -----Output----- For each test case, print the answer β€” $26$ integers: the number of times you press the button 'a', the number of times you press the button 'b', $\dots$, the number of times you press the button 'z'. -----Example----- Input 3 4 2 abca 1 3 10 5 codeforces 2 8 3 2 9 26 10 qwertyuioplkjhgfdsazxcvbnm 20 10 1 2 3 5 10 5 9 4 Output 4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 4 5 3 0 0 0 0 0 0 0 0 9 0 0 3 1 0 0 0 0 0 0 0 2 1 1 2 9 2 2 2 5 2 2 2 1 1 5 4 11 8 2 7 5 1 10 1 5 2 -----Note----- The first test case is described in the problem statement. Wrong tries are "a", "abc" and the final try is "abca". The number of times you press 'a' is $4$, 'b' is $2$ and 'c' is $2$. In the second test case, there are five wrong tries: "co", "codeforc", "cod", "co", "codeforce" and the final try is "codeforces". The number of times you press 'c' is $9$, 'd' is $4$, 'e' is $5$, 'f' is $3$, 'o' is $9$, 'r' is $3$ and 's' is $1$.
["from string import ascii_lowercase\n\nt = int(input())\n\nfor _ in range(t):\n n, m = [int(x) for x in input().split()]\n\n s = input()\n count = {x : 0 for x in ascii_lowercase}\n errors = [int(x) for x in input().split()]\n\n errors = sorted(errors)\n\n e_idx = 0\n for j, c in enumerate(s):\n while e_idx < m and errors[e_idx] <= j:\n e_idx += 1\n count[c] += (m - e_idx) + 1\n\n print(*[count[c] for c in ascii_lowercase])\n", "for eps in range(int(input())):\n n, m = map(int, input().split())\n s = input()\n a = list(map(int, input().split()))\n a.sort()\n ans = [0] * 26\n j = 0\n for i in range(n):\n while j < m and i >= a[j]:\n j += 1\n ans[ord(s[i]) - ord(\"a\")] += m - j + 1\n for elem in ans:\n print(elem, end=\" \")\n print()", "from sys import stdin\n\n\ndef solve():\n n, m = list(map(int, input().split()))\n s = input()\n ml = list(map(int, input().split()))\n ml.append(n)\n ml.sort(reverse=True)\n prev = 0\n ans = [0] * 26\n for i in range(m, -1, -1):\n for j in range(prev, ml[i]):\n ans[ord(s[j]) - ord('a')] += i + 1\n prev = ml[i]\n print(*ans)\n\n\nfor i in range(int(input())):\n solve()\n", "import sys\ninput = sys.stdin.readline\n\n\nalph = \"abcdefghijklmnopqrstuvwxyz\"\nto_int = {v: i for i, v in enumerate(alph)}\n\nt = int(input())\nfor _ in range(t):\n n, m = list(map(int, input().split()))\n s = input()\n p = list(map(int, input().split()))\n num = [[0] * (n + 1) for i in range(26)]\n for i in range(n):\n tmp = to_int[s[i]]\n for j in range(26):\n if tmp == j:\n num[j][i + 1] = num[j][i] + 1\n else:\n num[j][i + 1] = num[j][i]\n ans = [0] * 26\n for i in range(len(ans)):\n for j in p:\n ans[i] += num[i][j]\n ans[i] += num[i][-1]\n print(*ans)", "ans = []\nempt = [0 for i in range(26)]\ns = 'abcdefghijklmnopqrstuvwxyz'\npos = {s[i]: i for i in range(26)}\n\nfor t in range(int(input())):\n\t[n, m] = [int(i) for i in input().split()]\n\tseq = input()\n\terr = [(int(i) - 1) for i in input().split()]\n\tfreq = {}\n\tfor i in err:\n\t\tif i in freq:\n\t\t\tfreq[i] += 1\n\t\telse:\n\t\t\tfreq[i] = 1\n\n\tdp = [0 for i in range(n)]\n\tdp[n - 1] = 1\n\tfor i in range(n - 2, -1, -1):\n\t\tdp[i] = dp[i + 1]\n\t\tif i in freq:\n\t\t\tdp[i] += freq[i]\n\ta = empt + []\n\tfor i in range(n):\n\t\ta[pos[seq[i]]] += dp[i]\n\tans.append(' '.join([str(i) for i in a]))\n\nprint('\\n'.join(ans))\n", "t=int(input())\nwhile(t):\n t-=1\n co=[0]*26\n n,m=list(map(int,input().split()))\n reco=[0]*n\n s=input()\n a=list(map(int,input().split()))\n for i in range(m):\n reco[0]+=1\n reco[a[i]]+=-1\n reco[0]+=1\n for i in range(1,n):\n reco[i]=reco[i]+reco[i-1]\n for i in range(n):\n z=ord(s[i])-97\n co[z]+=reco[i]\n print(*co)\n", "t=int(input())\nwhile t:\n n,m=map(int,input().split())\n s=input()\n p=input().split()\n for i in range(m):\n p[i]=int(p[i])\n p.sort()\n ls=[]\n count=0\n for i in range(m):\n if(i==0):\n count+=1\n if(i==m-1):\n ls.append([p[i],count])\n elif(p[i]==p[i-1]):\n count+=1\n if(i==m-1):\n ls.append([p[i],count])\n else:\n ls.append([p[i-1],count])\n count=1\n if(i==m-1):\n ls.append([p[i],count])\n ls.append([n,0]) \n visited=[1 for i in range(n)]\n count=m\n j=0\n for i in range(n):\n if(i<ls[j][0]):\n visited[i]+=count\n else:\n count-=ls[j][1]\n j+=1\n visited[i]+=count\n ans=[0 for i in range(26)]\n for i in range(n):\n ans[ord(s[i])-97]+=visited[i]\n print(*ans)\n t-=1", "import string\n\nfor _ in range(int(input())):\n n, m = list(map(int, input().split()))\n s = input()\n p = list(map(int, input().split())) + [-1]\n\n d = {c: [0] for c in string.ascii_lowercase}\n\n for i in s:\n for c in string.ascii_lowercase:\n d[c].append(d[c][-1])\n\n d[i][-1] += 1\n\n ans = {c: 0 for c in string.ascii_lowercase}\n\n for i in p:\n for c in string.ascii_lowercase:\n ans[c] += d[c][i]\n\n print(*list(ans.values()))\n", "import sys\ninput = sys.stdin.readline\n\nt=int(input())\n\nfor tests in range(t):\n n,m=list(map(int,input().split()))\n S=input().strip()\n P=list(map(int,input().split()))\n\n SCORE=[[0]*26 for i in range(n)]\n\n for i in range(n):\n for j in range(26):\n SCORE[i][j]=SCORE[i-1][j]\n \n SCORE[i][ord(S[i])-97]+=1\n\n ANS=[0]*26\n\n for p in P:\n for j in range(26):\n ANS[j]+=SCORE[p-1][j]\n\n for j in range(26):\n ANS[j]+=SCORE[-1][j]\n\n print(*ANS)\n \n\n \n", "\nimport math\n\ndef rints():\n return list(map(int,input().split()))\n\n\nt = int(input())\nfor _ in range(t):\n n,m = rints()\n s = input()\n p = rints()\n occs = [0] * 26\n \n p.sort()\n\n ai = 0\n active = [1]*n\n rem = m+1\n for pi in p:\n for i in range(ai,pi):\n active[i] = rem\n rem -= 1\n ai = pi\n\n for i in range(n):\n c = ord(s[i]) - ord('a')\n occs[c] += active[i]\n\n print(*occs)\n\n", "import sys\ninput = sys.stdin.readline\n\nfor _ in range(int(input())):\n n, m = list(map(int, input().split()))\n s = list([ord(x)-97 for x in input().rstrip()])\n p = [n] + sorted(map(int, input().split()), reverse=True)\n ans = [0]*26\n\n i = 0\n for i in range(n):\n while p and p[-1] == i:\n p.pop()\n ans[s[i]] += len(p)\n\n print(*ans)\n"]
{ "inputs": [ "3\n4 2\nabca\n1 3\n10 5\ncodeforces\n2 8 3 2 9\n26 10\nqwertyuioplkjhgfdsazxcvbnm\n20 10 1 2 3 5 10 5 9 4\n", "1\n11 2\nthisisatest\n3 5\n" ], "outputs": [ "4 2 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \n0 0 9 4 5 3 0 0 0 0 0 0 0 0 9 0 0 3 1 0 0 0 0 0 0 0 \n2 1 1 2 9 2 2 2 5 2 2 2 1 1 5 4 11 8 2 7 5 1 10 1 5 2 \n", "1 0 0 0 1 0 0 3 5 0 0 0 0 0 0 0 0 0 4 5 0 0 0 0 0 0 \n" ] }
INTRODUCTORY
PYTHON3
CODEFORCES
6,020