text
stringlengths
198
433k
conversation_id
int64
0
109k
Provide a correct Python 3 solution for this coding contest problem. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 "Correct Solution: ``` ###test n=int(input()) A=list(map(int,input().split( ))) B=list(map(int,input().split( ))) count=0 flag=True while flag: flag=False for i in range(-1,n-1): tonari=B[i-1]+B[i+1] tmp=(B[i]-A[i])//tonari if tmp>0: B[i]-=tonari*tmp count+=tmp flag=True if A==B: print(count) else: print(-1) ```
4,000
Provide a correct Python 3 solution for this coding contest problem. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 "Correct Solution: ``` def p_c(): N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) l = [-1] * N for i in range(N): l[i] = B[i - 1] + B[(i + 1) % N] ans = 0 while 1: f = False for i in range(N): if A[i] <= B[i] - l[i]: f = True n = (B[i] - A[i]) // l[i] ans += n B[i] -= n * l[i] l[i - 1] -= n * l[i] l[(i + 1) % N] -= n * l[i] if not f: break if A != B: print(-1) else: print(ans) if __name__ == '__main__': p_c() ```
4,001
Provide a correct Python 3 solution for this coding contest problem. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 "Correct Solution: ``` N=int(input()) A=[int(i) for i in input().split()] B=[int(i) for i in input().split()] ans=0 while(True): flag=0 #print(B) for i in range(N): tmp=B[(i-1)%N]+B[(i+1)%N] if B[i]>tmp and B[i]>A[i]: beforeans=ans if B[i]%tmp>=A[i]: ans+=B[i]//tmp B[i]%=tmp else: k=((A[i]-1-(B[i]%tmp))//tmp)+1 ans+=B[i]//tmp B[i]%=tmp #print(i,1,B) ans-=k B[i]+=k*tmp #print(i,2,B) if ans!=beforeans: flag=1 if flag==0: break flag2=1 for i in range(N): if A[i]!=B[i]: flag2=0 break if flag2: print(ans) else: print(-1) ```
4,002
Provide a correct Python 3 solution for this coding contest problem. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 "Correct Solution: ``` words = lambda t : list(map(t, input().split())) n = int(input()) a = words(int) b = words(int) def getNext(i): if i == n-1: return 0 else: return i+1 def getPrev(i): if i == 0: return n-1 else: return i-1 from collections import deque q = deque() def verify(i): if b[i] != a[i] and b[i] - (b[getNext(i)] + b[getPrev(i)]) >= a[i]: return True else: return False for i in range(len(b)): if b[i] >= a[i] and verify(i): q.append(i) ans = 0 succeed = True while not len(q) == 0: i = q.popleft() ni = getNext(i) pi = getPrev(i) #print(i, b) d = b[ni] + b[pi] if b[i] % d == a[i] % d: ans += b[i] // d - (a[i] // d) b[i] = a[i] else: ans += b[i] // d b[i] %= d if b[i] < a[i]: succeed = False break if verify(ni): q.append(ni) if verify(pi): q.append(pi) for i in range(len(b)): if a[i] != b[i]: succeed = False break if succeed: print(ans) else: print(-1) ```
4,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 Submitted Solution: ``` import heapq import os import sys if os.getenv("LOCAL"): sys.stdin = open("_in.txt", "r") sys.setrecursionlimit(10 ** 9) INF = float("inf") IINF = 10 ** 18 MOD = 10 ** 9 + 7 # MOD = 998244353 N = int(sys.stdin.buffer.readline()) A = list(map(int, sys.stdin.buffer.readline().split())) B = list(map(int, sys.stdin.buffer.readline().split())) # 逆から貪欲に操作可能 def solve(): heap = [(-b, i) for i, b in enumerate(B)] heapq.heapify(heap) ret = 0 while heap: b, i = heapq.heappop(heap) b *= -1 a = A[i] if b < a: return -1 if b == a: continue step = B[(i - 1) % N] + B[(i + 1) % N] if (b - a) // step == 0: return -1 cnt = (b - a) // step ret += cnt b -= cnt * step B[i] = b heapq.heappush(heap, (-b, i)) return ret ans = solve() print(ans) ``` Yes
4,004
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 Submitted Solution: ``` N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) ans = 0 queue = [] # 山を探す for i in range(N): if B[i] > B[(i+1)%N] + B[(i-1)%N] and B[i] > A[i]: queue.append(i) # 山を崩す while queue != []: p = queue.pop(-1) hoge = (B[p] - A[p])//(B[(p+1)%N]+B[(p-1)%N]) B[p] -= (B[(p+1)%N]+B[(p-1)%N])*hoge ans += hoge if B[(p+1)%N] > B[p] + B[(p+2)%N] and B[(p+1)%N] > A[(p+1)%N]: queue.append((p+1)%N) if B[(p-1)%N] > B[p] + B[(p-2)%N] and B[(p-1)%N] > A[(p-1)%N]: queue.append((p-1)%N) if A == B: print(ans) else: print(-1) ``` Yes
4,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 Submitted Solution: ``` # import sys import math # ひとつ入力 n = int(input()) # initial state a = [int(i) for i in input().split()] # last state b = [int(i) for i in input().split()] answer = 0 answer_p = -1 while answer >= 0: answer_p = answer for i in range(n): tmp = b[(i-1)%n] + b[(i+1)%n] if 0 < tmp < b[i] and a[i] < b[i]: res = (b[i]-a[i]) // (b[(i+1)%n]+b[(i-1)%n]) answer += res b[i] -= res * (b[(i+1)%n]+b[(i-1)%n]) if answer == answer_p: break # print(a,b,answer) for i in range(n): if a[i] != b[i]: print(-1) exit() print(answer) ``` Yes
4,006
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 Submitted Solution: ``` import heapq def naive(): N = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) hantei = [1]*N for i,(x,y) in enumerate(zip(a,b)): if x<y: hantei[i] = 0 if x>y: print(-1) exit() # a == b となるidxの数。これがNでwhileから抜ける rest = sum(hantei) t = [] for i,val in enumerate(b): heapq.heappush(t, (-val,i)) res = 0 while rest < N: now = heapq.heappop(t) abc = -now[0] idx = now[1] newval = abc - b[(idx-1)%N] - b[(idx+1)%N] b[idx] = newval # print(b) if a[idx] > newval: res = -1 break elif a[idx] == newval: hantei[idx] = 0 rest += 1 res += 1 heapq.heappush(t, (-newval,idx)) print(res) def naive2(): N = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) hantei = [1]*N for i,(x,y) in enumerate(zip(a,b)): if x<y: hantei[i] = 0 if x>y: print(-1) exit() # a == b となるidxの数。これがNでwhileから抜ける rest = sum(hantei) t = [] for i,val in enumerate(b): if val==a[i] or val==1: continue heapq.heappush(t, (-val,i)) res = 0 while rest < N: now = heapq.heappop(t) abc = -now[0] idx = now[1] left = b[(idx-1)%N] right = b[(idx+1)%N] step = left+right if abc <= step: res = -1 break sub_cnt = (abc-1)//step if (abc-a[idx])%step==0 and (abc-a[idx])//step < sub_cnt: res += (abc-a[idx])//step hantei[idx] = 0 b[idx] = a[idx] rest += 1 continue if sub_cnt <= 0: res = -1 break diff = sub_cnt*step b[idx] -= diff # print(b) if a[idx] > b[idx]: res = -1 break elif a[idx] == b[idx]: hantei[idx] = 0 rest += 1 res += sub_cnt continue res += sub_cnt heapq.heappush(t, (-b[idx],idx)) print(res) naive2() ``` Yes
4,007
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 Submitted Solution: ``` #import sys #input = sys.stdin.readline n = int(input()) a =[int(xi) for xi in input().split()] b =[int(yi) for yi in input().split()] cnt, prev_cnt = 0, -1 while cnt != prev_cnt: prev_cnt = cnt for i in range(n): adj_sum = b[i - 1] + b[(i + 1) % n] k = (b[i] - a[i]) // adj_sum if k > 0: b[i] -= k * adj_sum cnt += k print(cnt if a == b else -1) ``` No
4,008
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 Submitted Solution: ``` import heapq import sys def main(): input=sys.stdin.readline N=int(input()) A=list(map(int,input().split())) B=list(map(int,input().split())) H=[] for i,x in enumerate(B): heapq.heappush(H,(-x,i)) ans=0 flg=0 while flg==0: x,i=heapq.heappop(H) v=x+B[(i-1)%N]+B[(i+1)%N] if -v<A[i]: for i,j in zip(A,B): if i!=j: print(-1) exit() break B[i]=-v heapq.heappush(H,(v,i)) ans+=1 print(ans) if __name__ == '__main__': main() ``` No
4,009
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 Submitted Solution: ``` n=int(input()) A=[int(i) for i in input().split()] B=[int(i) for i in input().split()] from heapq import heappop, heappush push = lambda x,i: heappush(BB,(-x,i)) BB=[] for i in range(n): push(B[i],i) ans=0 while BB: b,ind=heappop(BB) b,ai=-b,A[ind] if b<ai: ans=-1 break d=B[(ind-1)%n]+B[(ind+1)%n] dd=(b-ai)//d if dd==0: if b==ai: continue ans=-1 break ans+=dd B[ind]-=d*dd push(B[ind],ind) print(ans) ``` No
4,010
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N positive integers arranged in a circle. Now, the i-th number is A_i. Takahashi wants the i-th number to be B_i. For this objective, he will repeatedly perform the following operation: * Choose an integer i such that 1 \leq i \leq N. * Let a, b, c be the (i-1)-th, i-th, and (i+1)-th numbers, respectively. Replace the i-th number with a+b+c. Here the 0-th number is the N-th number, and the (N+1)-th number is the 1-st number. Determine if Takahashi can achieve his objective. If the answer is yes, find the minimum number of operations required. Constraints * 3 \leq N \leq 2 \times 10^5 * 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 A_1 A_2 ... A_N B_1 B_2 ... B_N Output Print the minimum number of operations required, or `-1` if the objective cannot be achieved. Examples Input 3 1 1 1 13 5 7 Output 4 Input 4 1 2 3 4 2 3 4 5 Output -1 Input 5 5 6 5 2 1 9817 1108 6890 4343 8704 Output 25 Submitted Solution: ``` N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) maxA = max(A) cnt = 0 while 1: maxB = 0 maxB_ind = -1 for i, b in enumerate(B): if maxB < b: maxB_ind = i maxB = b if maxB <= maxA: if A==B: print(cnt) else: print(-1) exit() if maxB_ind==0: cnt += B[maxB_ind]//(B[1]+B[-1]) if cnt==0: print(-1) exit() B[maxB_ind] %= (B[1]+B[-1]) elif maxB_ind==N-1: cnt += B[maxB_ind]//(B[0]+B[maxB_ind-1]) if cnt==0: print(-1) exit() B[maxB_ind] %= (B[0]+B[maxB_ind-1]) else: cnt += B[maxB_ind]//(B[maxB_ind-1]+B[maxB_ind+1]) if cnt==0: print(-1) exit() B[maxB_ind] %= (B[maxB_ind-1]+B[maxB_ind+1]) ``` No
4,011
Provide a correct Python 3 solution for this coding contest problem. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 "Correct Solution: ``` x,y,z,K=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) a.sort(reverse=1) b.sort(reverse=1) c.sort(reverse=1) m=[] for i in range(x): for j in range(y): for k in range(z): if (i+1)*(j+1)*(k+1)>K: break m.append(a[i]+b[j]+c[k]) m.sort(reverse=1) for i in m[:K]: print(i) ```
4,012
Provide a correct Python 3 solution for this coding contest problem. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 "Correct Solution: ``` X,Y,Z,K = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) import itertools AB = [a + b for a, b in itertools.product(A,B)] AB.sort(reverse=True) ABC = [ab + c for ab, c in itertools.product(AB[:3000],C)] ABC.sort(reverse=True) for i in range(K): print(ABC[i]) ```
4,013
Provide a correct Python 3 solution for this coding contest problem. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 "Correct Solution: ``` X,Y,Z,K = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) AB = [] ABC = [] for i in A: for j in B: AB.append(i+j) AB.sort(reverse=True) AB_max = AB[:K] for j in AB_max: for h in C: ABC.append(j+h) ABC.sort(reverse=True) for i in range(K): print(ABC[i]) ```
4,014
Provide a correct Python 3 solution for this coding contest problem. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 "Correct Solution: ``` from itertools import product X, Y, Z, K = map(int, input().split()) AB = [] for ab in product(map(int, input().split()), map(int, input().split())): AB.append(ab[0] + ab[1]) AB.sort(reverse=True) AB = AB[:min(K,X*Y)] ABC = [] for abc in product(AB, map(int, input().split())): ABC.append(abc[0]+abc[1]) ABC.sort(reverse=True) for i in range(K): print(ABC[i]) ```
4,015
Provide a correct Python 3 solution for this coding contest problem. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 "Correct Solution: ``` x, y, z, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = sorted(list(map(int, input().split())))[::-1] a1 = sorted(a[i] + b[j] for i in range(x) for j in range(y))[::-1] a2 = sorted(a1[i] + c[j] for i in range(min(len(a1), k)) for j in range(z))[::-1] for i in range(k): print(a2[i]) ```
4,016
Provide a correct Python 3 solution for this coding contest problem. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 "Correct Solution: ``` from heapq import nlargest x,y,z,k=map(int,input().split()) A,B,C=[list(map(int,input().split()))for _ in[0]*3] D=nlargest(k,(a+b for a in A for b in B )) E=nlargest(k,(d+c for c in C for d in D )) for i in E: print(i) ```
4,017
Provide a correct Python 3 solution for this coding contest problem. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 "Correct Solution: ``` X, Y, Z, K = map(int, input().split()) *A, = map(int, input().split()) *B, = map(int, input().split()) *C, = map(int, input().split()) A.sort(reverse=True) D = [i+j for j in C for i in B] D.sort(reverse=True) E = [i+j for j in D[:K] for i in A[:K]] E.sort(reverse=True) print(*E[:K], sep="\n") ```
4,018
Provide a correct Python 3 solution for this coding contest problem. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 "Correct Solution: ``` x,y,z,k=map(int,input().split()) a=sorted(list(map(int,input().split())),reverse=True) b=sorted(list(map(int,input().split())),reverse=True) c=sorted(list(map(int,input().split())),reverse=True) ab=[i+j for j in b for i in a] ab.sort(reverse=True) abc=[i+j for j in c[:k] for i in ab[:k]] abc.sort(reverse=True) print(*abc[:k],sep='\n') ```
4,019
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 Submitted Solution: ``` X, Y, Z, K = map(int, input().split()) *A, = sorted(map(int, input().split())) *B, = sorted(map(int, input().split())) *C, = sorted(map(int, input().split())) ab = [i+j for i in A for j in B] ab = sorted(ab, reverse=True)[:K] abc= [i+j for i in ab for j in C] abc.sort(reverse=True) for i in abc[:K]: print(i) ``` Yes
4,020
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 Submitted Solution: ``` x,y,z,k=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) ab=[s+t for s in a for t in b] ab.sort() ab=ab[-1:-k-1:-1] abc=[s+t for s in ab for t in c] abc.sort() abc=abc[-1:-k-1:-1] for i in range(len(abc)): print(abc[i]) ``` Yes
4,021
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 Submitted Solution: ``` x , y ,z , k = map(int, input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) a.sort(reverse=True) b.sort(reverse=True) c.sort(reverse=True) e = [i + j for i in a[:k] for j in b[:k]] e.sort(reverse=True) e = e[:k] ans = [i + j for i in e for j in c[:k]] ans.sort(reverse=True) for i in range(k): print(ans[i]) ``` Yes
4,022
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 Submitted Solution: ``` from heapq import* x,y,z,K=map(int,input().split()) a=(list(map(int,input().split()))) b=(list(map(int,input().split()))) c=sorted(list(map(int,input().split())))[::-1] d=sorted([q+p for q in a for p in b],reverse=True)[:K] e=sorted([q+p for q in d for p in c],reverse=True)[:K] for i in e: print(i) ``` Yes
4,023
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 Submitted Solution: ``` X, Y, Z, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) # A.sort(reverse=True) # B.sort(reverse=True) # C.sort(reverse=True) # m = A[0]+B[0]+C[0] AB = [] for a in A: for b in B: AB.append(a+b) ABC = [] for c in C: for ab in AB: ABC.append(c+ab) ABC.sort(reverse=True) for i in range(K): print(ABC[i]) ``` No
4,024
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 Submitted Solution: ``` # coding: utf-8 # hello worldと表示する #float型を許すな #numpyはpythonで import sys input = sys.stdin.readline sys.setrecursionlimit(10**7) from collections import Counter, deque from collections import defaultdict from itertools import combinations, permutations, accumulate, groupby, product from bisect import bisect_left,bisect_right from heapq import heapify, heappop, heappush from math import floor, ceil,pi,factorial from operator import itemgetter def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def LI2(): return [int(input()) for i in range(n)] def MXI(): return [[LI()]for i in range(n)] def SI(): return input().rstrip() def printns(x): print('\n'.join(x)) def printni(x): print('\n'.join(list(map(str,x)))) inf = 10**17 mod = 10**9 + 7 x,y,z,k=MI() A=LI() B=LI() C=LI() lis=[] for i in range(x): for j in range(y): lis.append(A[i]+B[j]) lis.sort(reverse=True) lisan=[] for i in range(min(k,x*y)): for j in range(z): lisan.append(lis[i]+C[j]) lisan.sort(reverse=True) for i in range(k): print(lisan[i]) ``` No
4,025
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 Submitted Solution: ``` x, y, z, k = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) c = list(map(int, input().split())) e = [] for va in a: for vb in b: e.append(va+vb) e.sort(reverse=True) e = e[:k] d = [] for vc in c: for ve in e: d.append(vc+ve) d.sort(reverse=True) d = d[:k] for vd in d: print(vd) ``` No
4,026
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The Patisserie AtCoder sells cakes with number-shaped candles. There are X, Y and Z kinds of cakes with 1-shaped, 2-shaped and 3-shaped candles, respectively. Each cake has an integer value called deliciousness, as follows: * The deliciousness of the cakes with 1-shaped candles are A_1, A_2, ..., A_X. * The deliciousness of the cakes with 2-shaped candles are B_1, B_2, ..., B_Y. * The deliciousness of the cakes with 3-shaped candles are C_1, C_2, ..., C_Z. Takahashi decides to buy three cakes, one for each of the three shapes of the candles, to celebrate ABC 123. There are X \times Y \times Z such ways to choose three cakes. We will arrange these X \times Y \times Z ways in descending order of the sum of the deliciousness of the cakes. Print the sums of the deliciousness of the cakes for the first, second, ..., K-th ways in this list. Constraints * 1 \leq X \leq 1 \ 000 * 1 \leq Y \leq 1 \ 000 * 1 \leq Z \leq 1 \ 000 * 1 \leq K \leq \min(3 \ 000, X \times Y \times Z) * 1 \leq A_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq B_i \leq 10 \ 000 \ 000 \ 000 * 1 \leq C_i \leq 10 \ 000 \ 000 \ 000 * All values in input are integers. Input Input is given from Standard Input in the following format: X Y Z K A_1 \ A_2 \ A_3 \ ... \ A_X B_1 \ B_2 \ B_3 \ ... \ B_Y C_1 \ C_2 \ C_3 \ ... \ C_Z Output Print K lines. The i-th line should contain the i-th value stated in the problem statement. Examples Input 2 2 2 8 4 6 1 5 3 8 Output 19 17 15 14 13 12 10 8 Input 3 3 3 5 1 10 100 2 20 200 1 10 100 Output 400 310 310 301 301 Input 10 10 10 20 7467038376 5724769290 292794712 2843504496 3381970101 8402252870 249131806 6310293640 6690322794 6082257488 1873977926 2576529623 1144842195 1379118507 6003234687 4925540914 3902539811 3326692703 484657758 2877436338 4975681328 8974383988 2882263257 7690203955 514305523 6679823484 4263279310 585966808 3752282379 620585736 Output 23379871545 22444657051 22302177772 22095691512 21667941469 21366963278 21287912315 21279176669 21160477018 21085311041 21059876163 21017997739 20703329561 20702387965 20590247696 20383761436 20343962175 20254073196 20210218542 20150096547 Submitted Solution: ``` def d_cake_123_binary_search(X, Y, Z, K, A, B, C): # editionalの解法4 O(K^2log(max(P)) # 参考: https://atcoder.jp/contests/abc123/submissions/4871511 import bisect ab = sorted([e1 + e2 for e2 in B for e1 in A]) # A, Bの要素は全部調べる # rejected 以上の値は、美味しさの合計がそれ以上である個数がK個未満である accepted, rejected = -1, 10**11 while abs(accepted - rejected) > 1: mid = (accepted + rejected) // 2 count = sum([len(ab) - bisect.bisect_left(ab, mid - e) for e in C]) if count >= K: accepted = mid else: rejected = mid ans = [] for e in C: idx = bisect.bisect_left(ab, accepted - e) for i in range(idx, len(ab)): ans.append(e + ab[i]) ans.sort(reverse=True) return ' '.join(map(str, ans)) X, Y, Z, K = [int(i) for i in input().split()] A = [int(i) for i in input().split()] B = [int(i) for i in input().split()] C = [int(i) for i in input().split()] print(d_cake_123_binary_search(X, Y, Z, K, A, B, C)) ``` No
4,027
Provide a correct Python 3 solution for this coding contest problem. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 "Correct Solution: ``` import collections import bisect N, M = map(int, input().split()) P = [list(map(int, input().split())) for i in range(M)] ans = collections.defaultdict(list) for p, y in sorted(P): ans[p] += [y] for p, y in P: print("%06d%06d"%(p, bisect.bisect(ans[p], y))) ```
4,028
Provide a correct Python 3 solution for this coding contest problem. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 "Correct Solution: ``` N, M = map(int,input().split()) ls = [[] for _ in range(N)] for i in range(M): p, y = map(int,input().split()) ls[p-1].append((y, i)) ids = [None]*M for i in range(N): ls[i].sort() for j in range(len(ls[i])): y,k = ls[i][j] ids[k] = "{:0>6}{:0>6}".format(i+1,j+1) print(*ids, sep="\n") ```
4,029
Provide a correct Python 3 solution for this coding contest problem. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 "Correct Solution: ``` N, M = map(int, input().split()) p = [[] for i in range(M)] counter = [0] * N ans = [""] * M for i in range(M): k, y = map(int, input().split()) p[i] = [k, y, i] p.sort(key=lambda x:x[1]) for k, y, i in p: counter[k-1] += 1 ans[i] = "{:06d}{:06d}".format(k, counter[k-1]) for i in ans: print(i) ```
4,030
Provide a correct Python 3 solution for this coding contest problem. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 "Correct Solution: ``` import collections,bisect N,M=map(int,input().split()) PY=[list(map(int,input().split())) for i in range(M)] a=collections.defaultdict(list) for city,year in sorted(PY):a[city]+=[year] for city,year in PY: z=bisect.bisect(a[city],year) print("%06d%06d"%(city,z)) ```
4,031
Provide a correct Python 3 solution for this coding contest problem. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 "Correct Solution: ``` import bisect n,m = map(int,input().split()) Q = [] P = [[] for _ in range(n)] for i in range(m): p,y = map(int,input().split()) Q.append([p,y]) P[p-1].append(y) P_1 = [sorted(l) for l in P] for p,y in Q: a = str(p).zfill(6) b = str(bisect.bisect(P_1[p-1], y)).zfill(6) print(a+b) ```
4,032
Provide a correct Python 3 solution for this coding contest problem. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 "Correct Solution: ``` N, M = map(int, input().split()) PY = [tuple(list(map(int, input().split()))+[i]) for i in range(M)] PY.sort(key=lambda x: x[1]) ans = ['']*M P = [0]*N for p, y, i in PY: ret = '' p -= 1 P[p] += 1 ret += '{:0=6}'.format(p+1) ret += '{:0=6}'.format(P[p]) ans[i] = ret print(*ans, sep='\n') ```
4,033
Provide a correct Python 3 solution for this coding contest problem. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 "Correct Solution: ``` n,m=map(int,input().split()) import bisect l=[[] for _ in range(n)] l2=[] for i in range(m): p,y=map(int,input().split()) bisect.insort_left(l[p-1],y) l2.append([p,y]) for m in l2: print("{:06d}".format(m[0]) +"{:06d}".format(bisect.bisect_left(l[m[0]-1],m[1])+1)) ```
4,034
Provide a correct Python 3 solution for this coding contest problem. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 "Correct Solution: ``` n,m=map(int,input().split()) py=[list(map(int,input().split()))+[i] for i in range(m)] py.sort(key=lambda x:x[0]*10**6+x[1]) ne=[1]*(10**5+1) ans=[] for p,_,i in py: ans.append((str(p).zfill(6)+str(ne[p]).zfill(6),i)) ne[p]+=1 ans.sort(key=lambda x:x[1]) for s,_ in ans: print(s) ```
4,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 Submitted Solution: ``` N,M = map(int,input().split()) PY=[list(map(int,input().split()))+[0] for _ in range(M)] sort_PY=sorted(PY,key=lambda x:x[1]) c={} for i in range(M): p=sort_PY[i][0] if(p in c): c[p]+=1 else: c[p]=1 sort_PY[i][2]=c[p] for p,y,z in PY: print(str(p).zfill(6)+str(z).zfill(6)) ``` Yes
4,036
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 Submitted Solution: ``` import bisect import collections N, M = map(int, input().split()) PM = [[int(j) for j in input().split()] for i in range(M)] A = collections.defaultdict(list) for x, y in sorted(PM): A[x] += [y] for x, y in PM: z = bisect.bisect(A[x], y) print('%06d%06d'%(x,z)) ``` Yes
4,037
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 Submitted Solution: ``` import sys input=sys.stdin.readline N,M=[int(n) for n in input().split()] lis=[[i]+[int(n) for n in input().split()] for i in range(M)] #print(lis) l_2=sorted(lis, key=lambda x: x[2]) dic={} for k,i,j in l_2: dic[i]=dic.get(i,0)+1 lis[k]='{:0=6}{:0=6}'.format(i,dic[i]) for i in lis:print(i) ``` Yes
4,038
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 Submitted Solution: ``` import collections,bisect N,M=map(int,input().split()) PY=[list(map(int,input().split())) for i in range(M)] x=collections.defaultdict(list) for city,year in sorted(PY): x[city]+=[year] for city,year in PY: num=bisect.bisect(x[city],year) print("%06d%06d"%(city,num)) ``` Yes
4,039
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 Submitted Solution: ``` n,m = list(map(int,input().split())) a = [[] for i in range(n+1)] b = [] for i in range(m): p,s = list(map(int,input().split())) a[p].append(s) b.append([p,s]) for i in range(n+1): a[i].sort() for i in range(m): ken = b[i][0] si = a[ken].index(b[i][1]) +1 ken = str(ken).zfill(6) si = str(si).zfill(6) print("".join([ken,si])) ``` No
4,040
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 Submitted Solution: ``` N,M = (int(x) for x in input().split()) p_y_list = [] for i in range(M): p_y_list.append(tuple(int(x) for x in input().split())) p_y_list.sort(key = lambda x:x[1]) p_y_list.sort(key = lambda x:x[0]) p_y_id_list = [] p = p_y_list[0][0] y_c = 1 for i in p_y_list: if i[0] == p: p_y_id_list.append((i[0],y_c)) y_c += 1 else: p = i[0] y_c = 1 p_y_id_list.append((i[0],y_c)) p_y_id_list.sort(key = lambda x:x[1] , reverse =True) p_y_id_list.sort(key = lambda x:x[0] , reverse =True) for i in p_y_id_list: print(str(i[0]).rjust(6,"0") + str(i[1]).rjust(6,"0")) ``` No
4,041
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 Submitted Solution: ``` # -*- coding: utf-8 -*- """ Created on Tue Sep 15 01:01:58 2020 @author: liang """ #ゼロパディング+インデックス #str(1).zfill(6) + str(a.index(2) + 1).zfill(6) N, M = map(int, input().split()) d = [list() for _ in range(N)] P = list() #insert O(M) for i in range(M): p, y = map(int,input().split()) d[p-1].append(y) P.append((p,y)) #year sort O(N log N) for i in range(N): d[i].sort() #search O(M) for i in range(M): p, y = P[i] ans = str(p).zfill(6)+str(d[p-1].index(y)+1).zfill(6) print(ans) ``` No
4,042
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i. You can assume that there are no multiple cities that are established in the same year. It is decided to allocate a 12-digit ID number to each city. If City i is the x-th established city among the cities that belong to Prefecture i, the first six digits of the ID number of City i is P_i, and the last six digits of the ID number is x. Here, if P_i or x (or both) has less than six digits, zeros are added to the left until it has six digits. Find the ID numbers for all the cities. Note that there can be a prefecture with no cities. Constraints * 1 \leq N \leq 10^5 * 1 \leq M \leq 10^5 * 1 \leq P_i \leq N * 1 \leq Y_i \leq 10^9 * Y_i are all different. * All values in input are integers. Input Input is given from Standard Input in the following format: N M P_1 Y_1 : P_M Y_M Output Print the ID numbers for all the cities, in ascending order of indices (City 1, City 2, ...). Examples Input 2 3 1 32 2 63 1 12 Output 000001000002 000002000001 000001000001 Input 2 3 2 55 2 77 2 99 Output 000002000001 000002000002 000002000003 Submitted Solution: ``` N,M = map(int,input().split()) lis = [list(map(int,input().split())) for _ in range(M)] ans_lis = [0] * M lis_sort = sorted(lis) i = 1 flag = 0 for _ in range(len(lis_sort)): if flag != lis_sort[_][0]: flag = lis_sort[_][0] i = 1 ans_lis[lis.index(lis_sort[_])] = str(i) i += 1 for x,y in zip(lis,ans_lis): print('0'*(6-len(str(x[0]))),x[0],'0'*(6-len(y)),y,sep='') ``` No
4,043
Provide a correct Python 3 solution for this coding contest problem. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 "Correct Solution: ``` S=input() T=S.count("o") print(700+T*100) ```
4,044
Provide a correct Python 3 solution for this coding contest problem. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 "Correct Solution: ``` s = input() x = s.count("o") print(700+x*100) ```
4,045
Provide a correct Python 3 solution for this coding contest problem. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 "Correct Solution: ``` s=input() print(int(700+100*s.count('o'))) ```
4,046
Provide a correct Python 3 solution for this coding contest problem. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 "Correct Solution: ``` print(len(input().replace("x",""))*100+700) ```
4,047
Provide a correct Python 3 solution for this coding contest problem. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 "Correct Solution: ``` a=input() print(a.count("o")*100+700) ```
4,048
Provide a correct Python 3 solution for this coding contest problem. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 "Correct Solution: ``` n=list(input()).count("o") print(700+(n*100)) ```
4,049
Provide a correct Python 3 solution for this coding contest problem. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 "Correct Solution: ``` S = input() print(700+(S.count("o")*100)) ```
4,050
Provide a correct Python 3 solution for this coding contest problem. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 "Correct Solution: ``` s=input();print(700+100*(s.count('o'))) ```
4,051
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 Submitted Solution: ``` a=input() print(700+100*int(a.count("o"))) ``` Yes
4,052
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 Submitted Solution: ``` S = input() print(700 + S.count("o") * 100) ``` Yes
4,053
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 Submitted Solution: ``` print(700 + 100 * input().strip().count('o')) ``` Yes
4,054
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 Submitted Solution: ``` print(700 + 100 * list(input()).count("o")) ``` Yes
4,055
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 Submitted Solution: ``` S = list(map(str, input())) count = 0 for i in range(3): if S[i] = "o": count += 1 print(700+count*100) ``` No
4,056
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 Submitted Solution: ``` N,C = map(int,input().split()) lists = [list(map(lambda x:int(x),input().split())) for i in range(N)] cal = 0 cals = [] if lists[0][0] < lists[0][1]: cal = cal - lists[0][0] + lists[0][1] cals.append(cal) for i in range(1,N): cal = cal - (lists[i][0] - lists[i-1][0]) + lists[i][1] cals.append(cal) print(max(cals)) ``` No
4,057
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 Submitted Solution: ``` s=input() print(500 + s.count("o")*100) ``` No
4,058
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. 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. Examples Input oxo Output 900 Input ooo Output 1000 Input xxx Output 700 Submitted Solution: ``` s=input() print(700+100*int(s.coount("o"))) ``` No
4,059
Provide a correct Python 3 solution for this coding contest problem. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 "Correct Solution: ``` N = int(input()) T = list(map(int, input().split())) M = int(input()) S = sum(T) for _ in range(M): P, X = map(int, input().split()) print(S-T[P-1]+X) ```
4,060
Provide a correct Python 3 solution for this coding contest problem. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 "Correct Solution: ``` N = int(input()) T = list(map(int, input().split())) M = int(input()) for i in range(M): P, X = map(int, input().split()) print(sum(T) - T[P-1] + X) ```
4,061
Provide a correct Python 3 solution for this coding contest problem. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 "Correct Solution: ``` n=int(input()) t=list(map(int,input().split())) a=sum(t) for i in range(int(input())): p,x=map(int,input().split()) print(a+x-t[p-1]) ```
4,062
Provide a correct Python 3 solution for this coding contest problem. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 "Correct Solution: ``` n=int(input()) t=list(map(int,input().split())) m=int(input()) for i in range(m): p,x=map(int,input().split()) print(sum(t)-(t[p-1]-x)) ```
4,063
Provide a correct Python 3 solution for this coding contest problem. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 "Correct Solution: ``` n=int(input()) t=list(map(int,input().split())) m=int(input()) for i in range(m): p,x=map(int,input().split()) ans=sum(t)-t[p-1]+x print(ans) ```
4,064
Provide a correct Python 3 solution for this coding contest problem. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 "Correct Solution: ``` n = int(input()) t = [int(i) for i in input().split()] m = int(input()) for mi in range(m): p, x = [int(i) for i in input().split()] print(sum(t)-t[p-1]+x) ```
4,065
Provide a correct Python 3 solution for this coding contest problem. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 "Correct Solution: ``` x=int(input()) y=list(map(int, input().split())) z=int(input()) for i in range(z): a,b=list(map(int, input().split())) print(sum(y)-y[a-1]+b) ```
4,066
Provide a correct Python 3 solution for this coding contest problem. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 "Correct Solution: ``` N=int(input()) T=list(map(int,input().split())) M=int(input()) for i in range(M): P,X=map(int,input().split()) print(sum(T[:P-1])+X+sum(T[P:]),end="\n") ```
4,067
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 Submitted Solution: ``` n=int(input()) T=list(map(int,input().split())) goukei=sum(T) m=int(input()) for i in range(m): p,x=map(int,input().split()) print(goukei-T[p-1]+x) ``` Yes
4,068
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 Submitted Solution: ``` N=int(input()) T=list(map(int,input().split())) S=sum(T) M=int(input()) for i in range(M): P, X = map(int,input().split()) diff = T[P-1]-X print(S-diff) ``` Yes
4,069
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 Submitted Solution: ``` n = int(input()) ts = list(map(int, input().split())) m = int(input()) for _ in range(m): i, p = map(int, input().split()) print(sum(ts)-ts[i-1]+p) ``` Yes
4,070
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 Submitted Solution: ``` n = int(input()) T = list(map(int,input().split())) m = int(input()) ans = sum(T) for i in range(m): p,x=map(int,input().split()) print(ans-(T[p-1]-x)) ``` Yes
4,071
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 Submitted Solution: ``` n = int(input()) list = list(map(int, input().split())) sum = sum(list) num = int(input()) for x in range(num): a = list(map(int, input().split())) ans = sum + a[1] - list[a[0]-1] print(ans) ``` No
4,072
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 Submitted Solution: ``` N=int(input()) T_N=int(input().split()) list_time = [] for i in range(N): list_time.append(T_N[i]) #Ti秒の総和を求める sum=sum(list_time) M=int(input()) for i in range(M): p,x=map(int,input().split()) #ドリンク飲んだ時と飲まないときの差を元の合計に足す。 ans=sum+x-list_time[p-1] print(ans) ``` No
4,073
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 Submitted Solution: ``` #50b #n 問題数 n = int(input()) #t 時間 t = [int(i) for i in input().split()] #m ドリンクの種類 m = int(input()) ans = [] for i in range(m): a,b = map(int,input().split()) temp = sum(t) - t[a-1] + b ans[i] = temp for i in range(m): print(ans[i]) ``` No
4,074
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered 1 through N. Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N). Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds. It does not affect the time to solve the other problems. A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her. Constraints * All input values are integers. * 1≦N≦100 * 1≦T_i≦10^5 * 1≦M≦100 * 1≦P_i≦N * 1≦X_i≦10^5 Input The input is given from Standard Input in the following format: N T_1 T_2 ... T_N M P_1 X_1 P_2 X_2 : P_M X_M Output For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line. Examples Input 3 2 1 4 2 1 1 2 3 Output 6 9 Input 5 7 2 3 8 5 3 4 2 1 7 4 13 Output 19 25 30 Submitted Solution: ``` N = int(input()) times = map(int, input().split()) M = int(input()) sum_t = sum(times) for _ in range(M): dist, time = map(int, input().split()) if times[dist-1] >= time: print(sum_t-(times[dist-1]-time)) else: print(sum_t+(time-times[dist-1])) ``` No
4,075
Provide a correct Python 3 solution for this coding contest problem. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No "Correct Solution: ``` # coding: utf-8 w = input() print("No" if sum(w.count(s)%2 for s in w) else "Yes") ```
4,076
Provide a correct Python 3 solution for this coding contest problem. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No "Correct Solution: ``` w = input() for c in w: if w.count(c) % 2: print("No") quit() print("Yes") ```
4,077
Provide a correct Python 3 solution for this coding contest problem. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No "Correct Solution: ``` s=input() if all(s.count(i)%2==0 for i in set(s)): print('Yes') else: print('No') ```
4,078
Provide a correct Python 3 solution for this coding contest problem. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No "Correct Solution: ``` S = input() if all([S.count(i) % 2 == 0 for i in S]): print('Yes') else: print('No') ```
4,079
Provide a correct Python 3 solution for this coding contest problem. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No "Correct Solution: ``` w=input() print("YNeos"[sum(map(lambda x:w.count(x)%2,w))!=0::2]) ```
4,080
Provide a correct Python 3 solution for this coding contest problem. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No "Correct Solution: ``` s=input() f=True for a in s: if s.count(a)%2 != 0: f=False print('Yes' if f else 'No') ```
4,081
Provide a correct Python 3 solution for this coding contest problem. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No "Correct Solution: ``` s=input();print('NYoe s'[all([s.count(i)%2==0 for i in set(s)])::2]) ```
4,082
Provide a correct Python 3 solution for this coding contest problem. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No "Correct Solution: ``` s=input() print("Yes" if all([s.count(i)%2==0 for i in s]) else "No") ```
4,083
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No Submitted Solution: ``` w = input() for i in set(w): if w.count(i) % 2 == 1: print("No") exit() print("Yes") ``` Yes
4,084
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No Submitted Solution: ``` w=input() ws=list(set(w)) ans='Yes' for i in ws: if w.count(i)%2==1: ans='No' print(ans) ``` Yes
4,085
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No Submitted Solution: ``` w=input() if all([w.count(i)%2==0 for i in w]): print("Yes") else: print("No") ``` Yes
4,086
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No Submitted Solution: ``` w = input() if all(w.count(i)%2==0 for i in w): print("Yes") else: print("No") ``` Yes
4,087
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No Submitted Solution: ``` from collections import Counter w = input() flag = 0 counter = Counter(w) for word, cnt in counter.most_common(): if cnt % 2 != 0: flag = 1 print("NO") if flag == 0: print("YES") ``` No
4,088
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No Submitted Solution: ``` w=list(input()) w.sort() c=[] for i in range(len(w)): k=i+1 for k in range(len(w)): if w[i]==w[k]: c.append(1) if len(c)%2==0: print("Yes") else: print("No") ``` No
4,089
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No Submitted Solution: ``` s = input() from collections import Counter print(all([v%2==0 for v in Counter(s).values()])) ``` No
4,090
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Let w be a string consisting of lowercase letters. We will call w beautiful if the following condition is satisfied: * Each lowercase letter of the English alphabet occurs even number of times in w. You are given the string w. Determine if w is beautiful. Constraints * 1 \leq |w| \leq 100 * w consists of lowercase letters (`a`-`z`). Input The input is given from Standard Input in the following format: w Output Print `Yes` if w is beautiful. Print `No` otherwise. Examples Input abaccaba Output Yes Input hthth Output No Submitted Solution: ``` w = input() for t in w: if any(w.count(t)%2) == 0: print('Yes') else: print('No') ``` No
4,091
Provide a correct Python 3 solution for this coding contest problem. Matrix of given integers a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends. Input The input data is given in the following format. n a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n n is 1 or more and 100 or less, and ai, j is -10000 or more and 10000 or less. Output Print the maximum value on one line. Examples Input 3 1 -2 3 -4 5 6 7 8 -9 Output 16 Input 4 1 3 -9 2 2 7 -1 5 -8 3 2 -1 5 0 -3 1 Output 15 "Correct Solution: ``` n = int(input()) s = [[0 for i in range(n + 1)] for j in range(n + 1)] for r in range(n): inp = list(map(int, input().split())) for c in range(n): s[r + 1][c + 1] = inp[c] + s[r][c + 1] ans = -10001 for r_end in range(1, n + 1): for r_start in range(r_end): dp = [-10001] for c in range(1, n + 1): s_tmp = s[r_end][c] - s[r_start][c] dp.append(max(dp[c - 1] + s_tmp, s_tmp)) ans = max(ans, max(dp)) print(ans) ```
4,092
Provide a correct Python 3 solution for this coding contest problem. Matrix of given integers a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends. Input The input data is given in the following format. n a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n n is 1 or more and 100 or less, and ai, j is -10000 or more and 10000 or less. Output Print the maximum value on one line. Examples Input 3 1 -2 3 -4 5 6 7 8 -9 Output 16 Input 4 1 3 -9 2 2 7 -1 5 -8 3 2 -1 5 0 -3 1 Output 15 "Correct Solution: ``` import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) A = [list(map(int, readline().split())) for i in range(N)] B = [[0]*(N+1) for i in range(N+1)] for i in range(N): c = 0 Ai = A[i] Bi = B[i] Bj = B[i+1] for j in range(N): Bj[j+1] = Bi[j+1] + Ai[j] def gen(): for i0 in range(N): Ba = B[i0] for i1 in range(i0+1, N+1): Bb = B[i1] mi = su = 0 for j in range(N): su += Bb[j+1] - Ba[j+1] yield su - mi mi = min(mi, su) write("%d\n" % max(gen())) solve() ```
4,093
Provide a correct Python 3 solution for this coding contest problem. Matrix of given integers a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends. Input The input data is given in the following format. n a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n n is 1 or more and 100 or less, and ai, j is -10000 or more and 10000 or less. Output Print the maximum value on one line. Examples Input 3 1 -2 3 -4 5 6 7 8 -9 Output 16 Input 4 1 3 -9 2 2 7 -1 5 -8 3 2 -1 5 0 -3 1 Output 15 "Correct Solution: ``` n = int(input()) a = [list(map(int, input().split())) for i in range(n)] # ????????? sum_v = [[0 for i in range(n)] for i in range(n + 1)] for i in range(n): c = 0 for j in range(n): c += a[j][i] sum_v[j+1][i] = c ans = -10**9 for sr in range(n): er = 0 for er in range(sr, n): c = 0 for col in range(n): c += sum_v[er+1][col] - sum_v[sr][col] ans = max(ans, c) if c < 0: c = 0 # c????????¢ (a(?????°) + b < b???????????? print(ans) ```
4,094
Provide a correct Python 3 solution for this coding contest problem. Matrix of given integers a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends. Input The input data is given in the following format. n a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n n is 1 or more and 100 or less, and ai, j is -10000 or more and 10000 or less. Output Print the maximum value on one line. Examples Input 3 1 -2 3 -4 5 6 7 8 -9 Output 16 Input 4 1 3 -9 2 2 7 -1 5 -8 3 2 -1 5 0 -3 1 Output 15 "Correct Solution: ``` from itertools import accumulate n = int(input()) mp = [list(map(int, input().split())) for _ in range(n)] acc_arr = [list(accumulate([0] + line)) for line in mp] ans = max([max(line) for line in mp]) for i in range(n + 1): for j in range(i + 1, n + 1): acc = 0 for k in range(n): add = acc_arr[k][j] - acc_arr[k][i] if acc + add > 0: acc = acc + add ans = max(acc, ans) else: acc = 0 print(ans) ```
4,095
Provide a correct Python 3 solution for this coding contest problem. Matrix of given integers a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends. Input The input data is given in the following format. n a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n n is 1 or more and 100 or less, and ai, j is -10000 or more and 10000 or less. Output Print the maximum value on one line. Examples Input 3 1 -2 3 -4 5 6 7 8 -9 Output 16 Input 4 1 3 -9 2 2 7 -1 5 -8 3 2 -1 5 0 -3 1 Output 15 "Correct Solution: ``` # AOJ 0098 Maximum Sum Sequence II # Python3 2018.6.17 bal4u #include <stdio.h> a = [[0 for c in range(102)] for r in range(102)] s = [[0 for c in range(102)] for r in range(102)] n = int(input()) for r in range(n): a[r] = list(map(int, input().split())) for r in range(n): for c in range(n): s[r][c+1] += s[r][c]+a[r][c] ans = s[0][1]; for c in range(n): for k in range(c+1, n+1): t = 0 for r in range(n): if t < 0: t = s[r][k]-s[r][c] else: t += s[r][k]-s[r][c] if t > ans: ans = t print(ans) ```
4,096
Provide a correct Python 3 solution for this coding contest problem. Matrix of given integers a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends. Input The input data is given in the following format. n a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n n is 1 or more and 100 or less, and ai, j is -10000 or more and 10000 or less. Output Print the maximum value on one line. Examples Input 3 1 -2 3 -4 5 6 7 8 -9 Output 16 Input 4 1 3 -9 2 2 7 -1 5 -8 3 2 -1 5 0 -3 1 Output 15 "Correct Solution: ``` n=int(input()) dp=[[0]*(n) for _ in range(n)] ans=-10**9 a=[list(map(int,input().split())) for i in range(n)] for i in range(n): s=[0]*101 for j in range(n):s[j+1]=s[j]+a[i][j] for j in range(n): for k in range(j,n): dp[j][k]=max(dp[j][k],0)+s[k+1]-s[j] ans=max(ans,dp[j][k]) print(ans) ```
4,097
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Matrix of given integers a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends. Input The input data is given in the following format. n a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n n is 1 or more and 100 or less, and ai, j is -10000 or more and 10000 or less. Output Print the maximum value on one line. Examples Input 3 1 -2 3 -4 5 6 7 8 -9 Output 16 Input 4 1 3 -9 2 2 7 -1 5 -8 3 2 -1 5 0 -3 1 Output 15 Submitted Solution: ``` # -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0098 TLE n=85だと通らない """ import sys from sys import stdin from functools import lru_cache input = stdin.readline def calc_points(n, array): # 右下から(x, y)までの長方形に含まれる値の和 global dp for y in range(n - 1, -1, -1): for x in range(n - 1, -1, -1): dp[y][x] = dp[y+1][x] + dp[y][x+1] - dp[y+1][x+1] + array[y][x] @lru_cache(maxsize=None) def get_dp(y, x): return dp[y][x] def solve(n, array): ans = 0 calc_points(n, array) for sy in range(n + 1): for sx in range(n + 1): for ey in range(sy+1, n + 1): for ex in range(sx+1, n + 1): s1 = get_dp(sy, sx) s2 = get_dp(sy, ex) s3 = get_dp(ey, sx) s4 = get_dp(ey, ex) s = s1 - s2 - s3 + s4 if s > ans: ans = s return ans dp = [[0] * (100 + 1) for _ in range(100 + 1)] def main(args): array = [] # n = 3 # array.append([1, -2, 3]) # array.append([-4, 5, 6]) # array.append([7, 8, -9]) n = int(input()) for _ in range(n): array.append([int(x) for x in input().split()]) ans = solve(n, array) print(ans) if __name__ == '__main__': main(sys.argv[1:]) ``` No
4,098
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Matrix of given integers a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n Then, create a program that outputs the maximum value of the sum of one or more consecutive terms (submatrix) in the vertical and horizontal directions and ends. Input The input data is given in the following format. n a1,1 a1,2 ... a1, n a2,1 a2,2 ... a2, n :: an, 1 an, 2 ... an, n n is 1 or more and 100 or less, and ai, j is -10000 or more and 10000 or less. Output Print the maximum value on one line. Examples Input 3 1 -2 3 -4 5 6 7 8 -9 Output 16 Input 4 1 3 -9 2 2 7 -1 5 -8 3 2 -1 5 0 -3 1 Output 15 Submitted Solution: ``` n = int(input()) l = [[int(i) for i in input().split()] for j in range(n)] m = -1000000000 for x1 in range(n): for x2 in range(x1,n): for y1 in range(n): for y2 in range(y1,n): s = 0 for x in range(x1,x2+1): for y in range(y1,y2+1): s += l[y][x] if s > m: m = s print(m) ``` No
4,099