message
stringlengths
2
48.6k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
318
108k
cluster
float64
8
8
__index_level_0__
int64
636
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights. Horace was the first to finish making his wall. He called his wall an elephant. The wall consists of w towers. The bears also finished making their wall but they didn't give it a name. Their wall consists of n towers. Horace looked at the bears' tower and wondered: in how many parts of the wall can he "see an elephant"? He can "see an elephant" on a segment of w contiguous towers if the heights of the towers on the segment match as a sequence the heights of the towers in Horace's wall. In order to see as many elephants as possible, Horace can raise and lower his wall. He even can lower the wall below the ground level (see the pictures to the samples for clarification). Your task is to count the number of segments where Horace can "see an elephant". Input The first line contains two integers n and w (1 ≤ n, w ≤ 2·105) — the number of towers in the bears' and the elephant's walls correspondingly. The second line contains n integers ai (1 ≤ ai ≤ 109) — the heights of the towers in the bears' wall. The third line contains w integers bi (1 ≤ bi ≤ 109) — the heights of the towers in the elephant's wall. Output Print the number of segments in the bears' wall where Horace can "see an elephant". Examples Input 13 5 2 4 5 5 4 3 2 2 2 3 3 2 1 3 4 4 3 2 Output 2 Note The picture to the left shows Horace's wall from the sample, the picture to the right shows the bears' wall. The segments where Horace can "see an elephant" are in gray. <image>
instruction
0
54,347
8
108,694
Tags: string suffix structures, strings Correct Solution: ``` def diff(s) : return [s[i] - s[i - 1] for i in range(1, len(s))] n, m = map(int, input().split()) if m > n : print(0) ; exit(0) if m == 1 : print(n) ; exit(0) t = diff(list(map(int, input().split()))) p = diff(list(map(int, input().split()))) w = p + [10 ** 9] + t res = 0 pi = [0] * len(w) for i in range (1, len(w)): j = pi[i - 1] while j > 0 and w[i] != w[j] : j = pi[j - 1] if w[i] == w[j] : j += 1 pi[i] = j if j == len(p) : res += 1 print(res) ```
output
1
54,347
8
108,695
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights. Horace was the first to finish making his wall. He called his wall an elephant. The wall consists of w towers. The bears also finished making their wall but they didn't give it a name. Their wall consists of n towers. Horace looked at the bears' tower and wondered: in how many parts of the wall can he "see an elephant"? He can "see an elephant" on a segment of w contiguous towers if the heights of the towers on the segment match as a sequence the heights of the towers in Horace's wall. In order to see as many elephants as possible, Horace can raise and lower his wall. He even can lower the wall below the ground level (see the pictures to the samples for clarification). Your task is to count the number of segments where Horace can "see an elephant". Input The first line contains two integers n and w (1 ≤ n, w ≤ 2·105) — the number of towers in the bears' and the elephant's walls correspondingly. The second line contains n integers ai (1 ≤ ai ≤ 109) — the heights of the towers in the bears' wall. The third line contains w integers bi (1 ≤ bi ≤ 109) — the heights of the towers in the elephant's wall. Output Print the number of segments in the bears' wall where Horace can "see an elephant". Examples Input 13 5 2 4 5 5 4 3 2 2 2 3 3 2 1 3 4 4 3 2 Output 2 Note The picture to the left shows Horace's wall from the sample, the picture to the right shows the bears' wall. The segments where Horace can "see an elephant" are in gray. <image> Submitted Solution: ``` ''' Auther: ghoshashis545 Ashis Ghosh College: jalpaiguri Govt Enggineering College ''' from os import path from io import BytesIO, IOBase import sys from heapq import heappush,heappop from functools import cmp_to_key as ctk from collections import deque,Counter,defaultdict as dd from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right from itertools import permutations from datetime import datetime from math import ceil,sqrt,log,gcd def ii():return int(input()) def si():return input().rstrip() def mi():return map(int,input().split()) def li():return list(mi()) abc='abcdefghijklmnopqrstuvwxyz' # mod=1000000007 mod=998244353 inf = float("inf") vow=['a','e','i','o','u'] dx,dy=[-1,1,0,0],[0,0,1,-1] def bo(i): return ord(i)-ord('0') file = 1 def ceil(a,b): return (a+b-1)//b # write fastio for getting fastio template. def z_algo(s): n = len(s) z = [0]*n l = r = 0 for i in range(n): if i > r: l = r = i diff = s[r]-s[r-l] r += 1 while r < n and (s[r] - s[r-l]) == diff: r+=1 z[i] = r-l r-=1 else: j = i-l if z[j] + i > r: l = i diff = s[r] - s[r-l] r+=1 while r < n and (s[r]-s[r-l])==diff: r+=1 z[i] = r-l r-=1 else: z[i] = z[j] return z def solve(): n,m = mi() a = li() b = li() x = z_algo(b+[inf]+a) x = x[(m+1):] # print(x) print(x.count(m)) if __name__ =="__main__": if(file): if path.exists('input.txt'): sys.stdin=open('input.txt', 'r') sys.stdout=open('output.txt','w') else: input=sys.stdin.readline solve() ```
instruction
0
54,348
8
108,696
Yes
output
1
54,348
8
108,697
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights. Horace was the first to finish making his wall. He called his wall an elephant. The wall consists of w towers. The bears also finished making their wall but they didn't give it a name. Their wall consists of n towers. Horace looked at the bears' tower and wondered: in how many parts of the wall can he "see an elephant"? He can "see an elephant" on a segment of w contiguous towers if the heights of the towers on the segment match as a sequence the heights of the towers in Horace's wall. In order to see as many elephants as possible, Horace can raise and lower his wall. He even can lower the wall below the ground level (see the pictures to the samples for clarification). Your task is to count the number of segments where Horace can "see an elephant". Input The first line contains two integers n and w (1 ≤ n, w ≤ 2·105) — the number of towers in the bears' and the elephant's walls correspondingly. The second line contains n integers ai (1 ≤ ai ≤ 109) — the heights of the towers in the bears' wall. The third line contains w integers bi (1 ≤ bi ≤ 109) — the heights of the towers in the elephant's wall. Output Print the number of segments in the bears' wall where Horace can "see an elephant". Examples Input 13 5 2 4 5 5 4 3 2 2 2 3 3 2 1 3 4 4 3 2 Output 2 Note The picture to the left shows Horace's wall from the sample, the picture to the right shows the bears' wall. The segments where Horace can "see an elephant" are in gray. <image> Submitted Solution: ``` from sys import stdin from collections import deque from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin def ii(): return int(stdin.readline()) def fi(): return float(stdin.readline()) def mi(): return map(int, stdin.readline().split()) def fmi(): return map(float, stdin.readline().split()) def li(): return list(mi()) def lsi(): x=list(stdin.readline()) x.pop() return x def si(): return stdin.readline() res=['YES', 'NO'] ############# CODE STARTS HERE ############# n, m=mi() x=li() b=li() if m>n: print(0) exit() if m==1: print(n) exit() a=[] for i in range(1, m): a.append(b[i]-b[i-1]) a.append('#') for i in range(1, n): a.append(x[i]-x[i-1]) kmp=[-1]*len(a) j=-1 for i in range(1, len(a)): while j>=0 and a[i]!=a[j+1]: j=kmp[j] if a[i]==a[j+1]: j+=1 kmp[i]=j kmp.sort(reverse=True) #print(a) #print(kmp) print(kmp.count(m-2)) """ pos, l, r=0, 0, n+m-2 while l<=r: mid=(l+r)//2 if kmp[mid]>=m-2: l=mid+1 pos=l else: r=mid-1 print(min(pos, n-m+1)) """ ```
instruction
0
54,349
8
108,698
Yes
output
1
54,349
8
108,699
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights. Horace was the first to finish making his wall. He called his wall an elephant. The wall consists of w towers. The bears also finished making their wall but they didn't give it a name. Their wall consists of n towers. Horace looked at the bears' tower and wondered: in how many parts of the wall can he "see an elephant"? He can "see an elephant" on a segment of w contiguous towers if the heights of the towers on the segment match as a sequence the heights of the towers in Horace's wall. In order to see as many elephants as possible, Horace can raise and lower his wall. He even can lower the wall below the ground level (see the pictures to the samples for clarification). Your task is to count the number of segments where Horace can "see an elephant". Input The first line contains two integers n and w (1 ≤ n, w ≤ 2·105) — the number of towers in the bears' and the elephant's walls correspondingly. The second line contains n integers ai (1 ≤ ai ≤ 109) — the heights of the towers in the bears' wall. The third line contains w integers bi (1 ≤ bi ≤ 109) — the heights of the towers in the elephant's wall. Output Print the number of segments in the bears' wall where Horace can "see an elephant". Examples Input 13 5 2 4 5 5 4 3 2 2 2 3 3 2 1 3 4 4 3 2 Output 2 Note The picture to the left shows Horace's wall from the sample, the picture to the right shows the bears' wall. The segments where Horace can "see an elephant" are in gray. <image> Submitted Solution: ``` def ZFunction(S) : L = R = 0 N = len(S) Z = [0] * N Z[0] = N for i in range (1, N) : if i > R : L = R = i while R < N and S[R] == S[R - L] : R += 1 Z[i] = R - L R -= 1 else : k = i - L if Z[k] < R - i + 1 : Z[i] = Z[k] else : L = i while R < N and S[R] == S[R - L] : R += 1 Z[i] = R - L R -= 1 return Z if __name__ == "__main__" : N, W = [int(x) for x in input().split()] A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] S = [0] * (N + W - 2) if W == 1 : print(N) exit(0) for i in range (0, N + W - 2) : if i < W - 1 : S[i] = B[i] - B[i + 1] else : S[i] = A[i - W + 1] - A[i - W + 2] Z = ZFunction(S) cnt = 0 for i in range (W - 1, N + W - 2) : if Z[i] >= W - 1 : cnt += 1 print(cnt) ```
instruction
0
54,350
8
108,700
Yes
output
1
54,350
8
108,701
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights. Horace was the first to finish making his wall. He called his wall an elephant. The wall consists of w towers. The bears also finished making their wall but they didn't give it a name. Their wall consists of n towers. Horace looked at the bears' tower and wondered: in how many parts of the wall can he "see an elephant"? He can "see an elephant" on a segment of w contiguous towers if the heights of the towers on the segment match as a sequence the heights of the towers in Horace's wall. In order to see as many elephants as possible, Horace can raise and lower his wall. He even can lower the wall below the ground level (see the pictures to the samples for clarification). Your task is to count the number of segments where Horace can "see an elephant". Input The first line contains two integers n and w (1 ≤ n, w ≤ 2·105) — the number of towers in the bears' and the elephant's walls correspondingly. The second line contains n integers ai (1 ≤ ai ≤ 109) — the heights of the towers in the bears' wall. The third line contains w integers bi (1 ≤ bi ≤ 109) — the heights of the towers in the elephant's wall. Output Print the number of segments in the bears' wall where Horace can "see an elephant". Examples Input 13 5 2 4 5 5 4 3 2 2 2 3 3 2 1 3 4 4 3 2 Output 2 Note The picture to the left shows Horace's wall from the sample, the picture to the right shows the bears' wall. The segments where Horace can "see an elephant" are in gray. <image> Submitted Solution: ``` def getNext(p): n=len(p) next=[-1]*n j=-1 for i in range(1,n): while j>=0 and (p[j]-p[0])!=(p[i-1]-p[i-j-1]): j=next[j] j+=1 next[i]=j return next read=lambda:map(int,input().split()) n,w=read() a=list(read()) b=list(read()) m=len(b) next=getNext(b) #print(next) i,j=0,0 ans=0 while i<n: if j==-1 or a[i]-a[i-j]==b[j]-b[0]: i+=1 j+=1 else: j=next[j] if j==m: ans+=1 j=next[m-1] i-=1 print(ans) ```
instruction
0
54,351
8
108,702
Yes
output
1
54,351
8
108,703
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights. Horace was the first to finish making his wall. He called his wall an elephant. The wall consists of w towers. The bears also finished making their wall but they didn't give it a name. Their wall consists of n towers. Horace looked at the bears' tower and wondered: in how many parts of the wall can he "see an elephant"? He can "see an elephant" on a segment of w contiguous towers if the heights of the towers on the segment match as a sequence the heights of the towers in Horace's wall. In order to see as many elephants as possible, Horace can raise and lower his wall. He even can lower the wall below the ground level (see the pictures to the samples for clarification). Your task is to count the number of segments where Horace can "see an elephant". Input The first line contains two integers n and w (1 ≤ n, w ≤ 2·105) — the number of towers in the bears' and the elephant's walls correspondingly. The second line contains n integers ai (1 ≤ ai ≤ 109) — the heights of the towers in the bears' wall. The third line contains w integers bi (1 ≤ bi ≤ 109) — the heights of the towers in the elephant's wall. Output Print the number of segments in the bears' wall where Horace can "see an elephant". Examples Input 13 5 2 4 5 5 4 3 2 2 2 3 3 2 1 3 4 4 3 2 Output 2 Note The picture to the left shows Horace's wall from the sample, the picture to the right shows the bears' wall. The segments where Horace can "see an elephant" are in gray. <image> Submitted Solution: ``` tmp = input().split() n = int(tmp[0]) # ����� ������ �������� w = int(tmp[1]) # ����� ������ ����� m = input().split() # ������ �������� s = input().split() # ������ ����� def outline(a, l): # ��������������� ������ � ������� ������ s = '' for i in range(1, l): s += str(int(a[i]) - int(a[i-1])) + ' ' return s def prefix(s, l): # ������� ��� (� ������ ������ ������� p - ������� ���� �������� ��������� � ��������) ans = 0 p = [0]*l for i in range(1, l): j = p[i-1] # ������� �������� �������-�������, ����� �������� ���������������� ������� while (j > 0) and (s[i] != s[j]): j = p[j-1] # ���������, ����� �� �-� ����� ������ ��������, ��������� ����� ������� if s[i] == s[j]: # ���� ������� �������� ������� ��������� ������ � ����� j += 1 p[i] = j if p[i] == w: ans += 1 return ans m = outline(m, n) s = outline(s, w) if w == 1: print(n) else: print(prefix(s+'#'+m, len(m)+len(s)+1)) ```
instruction
0
54,352
8
108,704
No
output
1
54,352
8
108,705
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights. Horace was the first to finish making his wall. He called his wall an elephant. The wall consists of w towers. The bears also finished making their wall but they didn't give it a name. Their wall consists of n towers. Horace looked at the bears' tower and wondered: in how many parts of the wall can he "see an elephant"? He can "see an elephant" on a segment of w contiguous towers if the heights of the towers on the segment match as a sequence the heights of the towers in Horace's wall. In order to see as many elephants as possible, Horace can raise and lower his wall. He even can lower the wall below the ground level (see the pictures to the samples for clarification). Your task is to count the number of segments where Horace can "see an elephant". Input The first line contains two integers n and w (1 ≤ n, w ≤ 2·105) — the number of towers in the bears' and the elephant's walls correspondingly. The second line contains n integers ai (1 ≤ ai ≤ 109) — the heights of the towers in the bears' wall. The third line contains w integers bi (1 ≤ bi ≤ 109) — the heights of the towers in the elephant's wall. Output Print the number of segments in the bears' wall where Horace can "see an elephant". Examples Input 13 5 2 4 5 5 4 3 2 2 2 3 3 2 1 3 4 4 3 2 Output 2 Note The picture to the left shows Horace's wall from the sample, the picture to the right shows the bears' wall. The segments where Horace can "see an elephant" are in gray. <image> Submitted Solution: ``` n, w = map(int, input().split()) a = list(map(int, input().split())) t1 = [0] for i in range(1, n): t1.append(a[i] - a[i - 1]) a = list(map(int, input().split())) t2 = [] for i in range(1, w): t2.append(a[i] - a[i - 1]) s = t2 + ['#'] + t1 n = len(s) pre = [0] for i in range(1,n): j = pre[i-1] while j > 0 and s[j] != s[i]: j = pre[j-1] if s[j] == s[i]: j += 1 pre.append(j) ans = 0 for i in range(len(pre)): if pre[i] == len(t2): ans += 1 print(ans) ```
instruction
0
54,353
8
108,706
No
output
1
54,353
8
108,707
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights. Horace was the first to finish making his wall. He called his wall an elephant. The wall consists of w towers. The bears also finished making their wall but they didn't give it a name. Their wall consists of n towers. Horace looked at the bears' tower and wondered: in how many parts of the wall can he "see an elephant"? He can "see an elephant" on a segment of w contiguous towers if the heights of the towers on the segment match as a sequence the heights of the towers in Horace's wall. In order to see as many elephants as possible, Horace can raise and lower his wall. He even can lower the wall below the ground level (see the pictures to the samples for clarification). Your task is to count the number of segments where Horace can "see an elephant". Input The first line contains two integers n and w (1 ≤ n, w ≤ 2·105) — the number of towers in the bears' and the elephant's walls correspondingly. The second line contains n integers ai (1 ≤ ai ≤ 109) — the heights of the towers in the bears' wall. The third line contains w integers bi (1 ≤ bi ≤ 109) — the heights of the towers in the elephant's wall. Output Print the number of segments in the bears' wall where Horace can "see an elephant". Examples Input 13 5 2 4 5 5 4 3 2 2 2 3 3 2 1 3 4 4 3 2 Output 2 Note The picture to the left shows Horace's wall from the sample, the picture to the right shows the bears' wall. The segments where Horace can "see an elephant" are in gray. <image> Submitted Solution: ``` n, k = map(int, input().split()) a = tuple(map(int, input().split())) b = tuple(map(int, input().split())) if k == 1: print(n) elif k > n: print(0) else: p = int(1e15 + 7) q = 499 h1 = 0 hs = [0] * (n + 1) pw = [1] * (n + 1) z = 1 for i in range(n): hs[i + 1] = (hs[i] * q + a[i]) % p pw[i + 1] = (pw[i] * q) % p if i < k: h1 = (h1 * q + b[i]) % p if i < k - 1: z += ((pw[i] * q) % p) % p def get_hash(a, b): # hash [a, b) return (hs[b] - (hs[a] * pw[b - a]) % p + p) % p ans = 0 for i in range(n - k + 1): if (get_hash(i, i + k) - h1) % z == 0: ans += 1 print(ans) ```
instruction
0
54,354
8
108,708
No
output
1
54,354
8
108,709
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev got hold of lots of wooden cubes somewhere. They started making cube towers by placing the cubes one on top of the other. They defined multiple towers standing in a line as a wall. A wall can consist of towers of different heights. Horace was the first to finish making his wall. He called his wall an elephant. The wall consists of w towers. The bears also finished making their wall but they didn't give it a name. Their wall consists of n towers. Horace looked at the bears' tower and wondered: in how many parts of the wall can he "see an elephant"? He can "see an elephant" on a segment of w contiguous towers if the heights of the towers on the segment match as a sequence the heights of the towers in Horace's wall. In order to see as many elephants as possible, Horace can raise and lower his wall. He even can lower the wall below the ground level (see the pictures to the samples for clarification). Your task is to count the number of segments where Horace can "see an elephant". Input The first line contains two integers n and w (1 ≤ n, w ≤ 2·105) — the number of towers in the bears' and the elephant's walls correspondingly. The second line contains n integers ai (1 ≤ ai ≤ 109) — the heights of the towers in the bears' wall. The third line contains w integers bi (1 ≤ bi ≤ 109) — the heights of the towers in the elephant's wall. Output Print the number of segments in the bears' wall where Horace can "see an elephant". Examples Input 13 5 2 4 5 5 4 3 2 2 2 3 3 2 1 3 4 4 3 2 Output 2 Note The picture to the left shows Horace's wall from the sample, the picture to the right shows the bears' wall. The segments where Horace can "see an elephant" are in gray. <image> Submitted Solution: ``` def getNext(p): n=len(p) next=[-1]*n j=-1 for i in range(1,n): while j>=0 and p[j]!=p[i-1]: j=next[j] j+=1 next[i]=j return next read=lambda:map(int,input().split()) n,w=read() a=list(read()) b=list(read()) m=len(b) next=getNext(b) i,j=0,0 ans=0 while i<n: if j==-1 or a[i]-a[i-j]==b[j]-b[0]: i+=1 j+=1 else: j=next[j] if j==m: ans+=1 j=next[m-1] i-=1 print(ans) ```
instruction
0
54,355
8
108,710
No
output
1
54,355
8
108,711
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Archeologists have found a secret pass in the dungeon of one of the pyramids of Cycleland. To enter the treasury they have to open an unusual lock on the door. The lock consists of n words, each consisting of some hieroglyphs. The wall near the lock has a round switch. Each rotation of this switch changes the hieroglyphs according to some rules. The instruction nearby says that the door will open only if words written on the lock would be sorted in lexicographical order (the definition of lexicographical comparison in given in notes section). The rule that changes hieroglyphs is the following. One clockwise rotation of the round switch replaces each hieroglyph with the next hieroglyph in alphabet, i.e. hieroglyph x (1 ≤ x ≤ c - 1) is replaced with hieroglyph (x + 1), and hieroglyph c is replaced with hieroglyph 1. Help archeologist determine, how many clockwise rotations they should perform in order to open the door, or determine that this is impossible, i.e. no cyclic shift of the alphabet will make the sequence of words sorted lexicographically. Input The first line of the input contains two integers n and c (2 ≤ n ≤ 500 000, 1 ≤ c ≤ 106) — the number of words, written on the lock, and the number of different hieroglyphs. Each of the following n lines contains the description of one word. The i-th of these lines starts with integer li (1 ≤ li ≤ 500 000), that denotes the length of the i-th word, followed by li integers wi, 1, wi, 2, ..., wi, li (1 ≤ wi, j ≤ c) — the indices of hieroglyphs that make up the i-th word. Hieroglyph with index 1 is the smallest in the alphabet and with index c — the biggest. It's guaranteed, that the total length of all words doesn't exceed 106. Output If it is possible to open the door by rotating the round switch, print integer x (0 ≤ x ≤ c - 1) that defines the required number of clockwise rotations. If there are several valid x, print any of them. If it is impossible to open the door by this method, print - 1. Examples Input 4 3 2 3 2 1 1 3 2 3 1 4 2 3 1 2 Output 1 Input 2 5 2 4 2 2 4 2 Output 0 Input 4 4 1 2 1 3 1 4 1 2 Output -1 Note Word a1, a2, ..., am of length m is lexicographically not greater than word b1, b2, ..., bk of length k, if one of two conditions hold: * at first position i, such that ai ≠ bi, the character ai goes earlier in the alphabet than character bi, i.e. a has smaller character in the first position where they differ; * if there is no such position i and m ≤ k, i.e. the first word is a prefix of the second or two words are equal. The sequence of words is said to be sorted in lexicographical order if each word (except the last one) is lexicographically not greater than the next word. In the first sample, after the round switch is rotated 1 position clockwise the words look as follows: 1 3 2 3 1 2 3 1 2 3 In the second sample, words are already sorted in lexicographical order. In the last sample, one can check that no shift of the alphabet will work. Submitted Solution: ``` import sys def main(): n,c = [int(i) for i in sys.stdin.readline().split()] words = [] # pairs of (left, right) wlast = None maxShift = 10**6 minShift = 0 for i in range(n): w = [int(i) for i in sys.stdin.readline().split()][1:] if wlast is None: wlast = w words.append([-1,-1]) continue for i in range(min(len(w),len(wlast))): if w[i] != wlast[i]: words[-1][1] = wlast[i] words.append([w[i],-1]) break else: if len(wlast) > len(w): # prefix of word following word - can't ever be in order print(-1) return wlast = w for i in range(1,len(words)): if words[i][0] > words[i-1][1]: maxShift = min(maxShift, c-words[i][0]+1) elif words[i][0] < words[i-1][1]: minShift = max(minShift, c-words[i-1][1]+1) #print(words[i-1], "vs", words[i]) #print(minShift, maxShift) #print() if maxShift <= minShift: print(-1) else: print(minShift) main() ```
instruction
0
54,458
8
108,916
No
output
1
54,458
8
108,917
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Archeologists have found a secret pass in the dungeon of one of the pyramids of Cycleland. To enter the treasury they have to open an unusual lock on the door. The lock consists of n words, each consisting of some hieroglyphs. The wall near the lock has a round switch. Each rotation of this switch changes the hieroglyphs according to some rules. The instruction nearby says that the door will open only if words written on the lock would be sorted in lexicographical order (the definition of lexicographical comparison in given in notes section). The rule that changes hieroglyphs is the following. One clockwise rotation of the round switch replaces each hieroglyph with the next hieroglyph in alphabet, i.e. hieroglyph x (1 ≤ x ≤ c - 1) is replaced with hieroglyph (x + 1), and hieroglyph c is replaced with hieroglyph 1. Help archeologist determine, how many clockwise rotations they should perform in order to open the door, or determine that this is impossible, i.e. no cyclic shift of the alphabet will make the sequence of words sorted lexicographically. Input The first line of the input contains two integers n and c (2 ≤ n ≤ 500 000, 1 ≤ c ≤ 106) — the number of words, written on the lock, and the number of different hieroglyphs. Each of the following n lines contains the description of one word. The i-th of these lines starts with integer li (1 ≤ li ≤ 500 000), that denotes the length of the i-th word, followed by li integers wi, 1, wi, 2, ..., wi, li (1 ≤ wi, j ≤ c) — the indices of hieroglyphs that make up the i-th word. Hieroglyph with index 1 is the smallest in the alphabet and with index c — the biggest. It's guaranteed, that the total length of all words doesn't exceed 106. Output If it is possible to open the door by rotating the round switch, print integer x (0 ≤ x ≤ c - 1) that defines the required number of clockwise rotations. If there are several valid x, print any of them. If it is impossible to open the door by this method, print - 1. Examples Input 4 3 2 3 2 1 1 3 2 3 1 4 2 3 1 2 Output 1 Input 2 5 2 4 2 2 4 2 Output 0 Input 4 4 1 2 1 3 1 4 1 2 Output -1 Note Word a1, a2, ..., am of length m is lexicographically not greater than word b1, b2, ..., bk of length k, if one of two conditions hold: * at first position i, such that ai ≠ bi, the character ai goes earlier in the alphabet than character bi, i.e. a has smaller character in the first position where they differ; * if there is no such position i and m ≤ k, i.e. the first word is a prefix of the second or two words are equal. The sequence of words is said to be sorted in lexicographical order if each word (except the last one) is lexicographically not greater than the next word. In the first sample, after the round switch is rotated 1 position clockwise the words look as follows: 1 3 2 3 1 2 3 1 2 3 In the second sample, words are already sorted in lexicographical order. In the last sample, one can check that no shift of the alphabet will work. Submitted Solution: ``` import sys from pprint import pprint n,c = [int(i) for i in sys.stdin.readline().split()] words = [] # pairs of (left, right) wlast = None maxShift = 10**6 minShift = 0 for i in range(n): w = [int(i) for i in sys.stdin.readline().split()][1:] if wlast is None: wlast = w words.append([-1,-1]) continue if len(wlast) < len(w): continue for i in range(len(w)): if w[i] != wlast[i]: words[-1][1] = wlast[i] words.append([w[i],-1]) wlast=w break for i in range(1,len(words)): if words[i][0] == -1 or words[i-1][1] == -1: continue if words[i][0] > words[i-1][1]: maxShift = min(maxShift, words[i][0]-c) continue minShift = max(minShift, words[i-1][1]-c+1) if maxShift < minShift: print(-1) else: print(minShift) ```
instruction
0
54,459
8
108,918
No
output
1
54,459
8
108,919
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Archeologists have found a secret pass in the dungeon of one of the pyramids of Cycleland. To enter the treasury they have to open an unusual lock on the door. The lock consists of n words, each consisting of some hieroglyphs. The wall near the lock has a round switch. Each rotation of this switch changes the hieroglyphs according to some rules. The instruction nearby says that the door will open only if words written on the lock would be sorted in lexicographical order (the definition of lexicographical comparison in given in notes section). The rule that changes hieroglyphs is the following. One clockwise rotation of the round switch replaces each hieroglyph with the next hieroglyph in alphabet, i.e. hieroglyph x (1 ≤ x ≤ c - 1) is replaced with hieroglyph (x + 1), and hieroglyph c is replaced with hieroglyph 1. Help archeologist determine, how many clockwise rotations they should perform in order to open the door, or determine that this is impossible, i.e. no cyclic shift of the alphabet will make the sequence of words sorted lexicographically. Input The first line of the input contains two integers n and c (2 ≤ n ≤ 500 000, 1 ≤ c ≤ 106) — the number of words, written on the lock, and the number of different hieroglyphs. Each of the following n lines contains the description of one word. The i-th of these lines starts with integer li (1 ≤ li ≤ 500 000), that denotes the length of the i-th word, followed by li integers wi, 1, wi, 2, ..., wi, li (1 ≤ wi, j ≤ c) — the indices of hieroglyphs that make up the i-th word. Hieroglyph with index 1 is the smallest in the alphabet and with index c — the biggest. It's guaranteed, that the total length of all words doesn't exceed 106. Output If it is possible to open the door by rotating the round switch, print integer x (0 ≤ x ≤ c - 1) that defines the required number of clockwise rotations. If there are several valid x, print any of them. If it is impossible to open the door by this method, print - 1. Examples Input 4 3 2 3 2 1 1 3 2 3 1 4 2 3 1 2 Output 1 Input 2 5 2 4 2 2 4 2 Output 0 Input 4 4 1 2 1 3 1 4 1 2 Output -1 Note Word a1, a2, ..., am of length m is lexicographically not greater than word b1, b2, ..., bk of length k, if one of two conditions hold: * at first position i, such that ai ≠ bi, the character ai goes earlier in the alphabet than character bi, i.e. a has smaller character in the first position where they differ; * if there is no such position i and m ≤ k, i.e. the first word is a prefix of the second or two words are equal. The sequence of words is said to be sorted in lexicographical order if each word (except the last one) is lexicographically not greater than the next word. In the first sample, after the round switch is rotated 1 position clockwise the words look as follows: 1 3 2 3 1 2 3 1 2 3 In the second sample, words are already sorted in lexicographical order. In the last sample, one can check that no shift of the alphabet will work. Submitted Solution: ``` import sys def main(): n,c = [int(i) for i in sys.stdin.readline().split()] words = [] # pairs of (left, right) wlast = None maxShift = 10**6 minShift = 0 for i in range(n): w = [int(i) for i in sys.stdin.readline().split()][1:] if wlast is None: wlast = w words.append([-1,-1]) continue for i in range(min(len(w),len(wlast))): if w[i] != wlast[i]: words[-1][1] = wlast[i] words.append([w[i],-1]) break else: if len(wlast) > len(w): # prefix of word following word - can't ever be in order print(-1) return wlast = w for i in range(1,len(words)): if words[i][0] > words[i-1][1]: maxShift = min(maxShift, c-words[i][0]+1) elif words[i][0] < words[i-1][1]: minShift = max(minShift, c-words[i-1][1]+1) #print(words[i-1], "vs", words[i]) #print(minShift, maxShift) #print() print(minShift, maxShift) if maxShift <= minShift: print(-1) else: print(minShift) main() ```
instruction
0
54,460
8
108,920
No
output
1
54,460
8
108,921
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Archeologists have found a secret pass in the dungeon of one of the pyramids of Cycleland. To enter the treasury they have to open an unusual lock on the door. The lock consists of n words, each consisting of some hieroglyphs. The wall near the lock has a round switch. Each rotation of this switch changes the hieroglyphs according to some rules. The instruction nearby says that the door will open only if words written on the lock would be sorted in lexicographical order (the definition of lexicographical comparison in given in notes section). The rule that changes hieroglyphs is the following. One clockwise rotation of the round switch replaces each hieroglyph with the next hieroglyph in alphabet, i.e. hieroglyph x (1 ≤ x ≤ c - 1) is replaced with hieroglyph (x + 1), and hieroglyph c is replaced with hieroglyph 1. Help archeologist determine, how many clockwise rotations they should perform in order to open the door, or determine that this is impossible, i.e. no cyclic shift of the alphabet will make the sequence of words sorted lexicographically. Input The first line of the input contains two integers n and c (2 ≤ n ≤ 500 000, 1 ≤ c ≤ 106) — the number of words, written on the lock, and the number of different hieroglyphs. Each of the following n lines contains the description of one word. The i-th of these lines starts with integer li (1 ≤ li ≤ 500 000), that denotes the length of the i-th word, followed by li integers wi, 1, wi, 2, ..., wi, li (1 ≤ wi, j ≤ c) — the indices of hieroglyphs that make up the i-th word. Hieroglyph with index 1 is the smallest in the alphabet and with index c — the biggest. It's guaranteed, that the total length of all words doesn't exceed 106. Output If it is possible to open the door by rotating the round switch, print integer x (0 ≤ x ≤ c - 1) that defines the required number of clockwise rotations. If there are several valid x, print any of them. If it is impossible to open the door by this method, print - 1. Examples Input 4 3 2 3 2 1 1 3 2 3 1 4 2 3 1 2 Output 1 Input 2 5 2 4 2 2 4 2 Output 0 Input 4 4 1 2 1 3 1 4 1 2 Output -1 Note Word a1, a2, ..., am of length m is lexicographically not greater than word b1, b2, ..., bk of length k, if one of two conditions hold: * at first position i, such that ai ≠ bi, the character ai goes earlier in the alphabet than character bi, i.e. a has smaller character in the first position where they differ; * if there is no such position i and m ≤ k, i.e. the first word is a prefix of the second or two words are equal. The sequence of words is said to be sorted in lexicographical order if each word (except the last one) is lexicographically not greater than the next word. In the first sample, after the round switch is rotated 1 position clockwise the words look as follows: 1 3 2 3 1 2 3 1 2 3 In the second sample, words are already sorted in lexicographical order. In the last sample, one can check that no shift of the alphabet will work. Submitted Solution: ``` import sys from pprint import pprint n,c = [int(i) for i in sys.stdin.readline().split()] words = [] # pairs of (left, right) wlast = None maxShift = 10**6 minShift = 0 for i in range(n): w = [int(i) for i in sys.stdin.readline().split()][1:] if wlast is None: wlast = w words.append([-1,-1]) continue if len(wlast) < len(w): continue for i in range(len(w)): if w[i] != wlast[i]: words[-1][1] = wlast[i] words.append([w[i],-1]) wlast=w break for i in range(1,len(words)): if words[i][0] > words[i-1][1]: maxShift = min(maxShift, words[i][0]-c) continue minShift = max(minShift, c-words[i-1][1]+1) if maxShift < minShift: print(-1) else: print(minShift) ```
instruction
0
54,461
8
108,922
No
output
1
54,461
8
108,923
Provide a correct Python 3 solution for this coding contest problem. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0
instruction
0
54,577
8
109,154
"Correct Solution: ``` A,B = (int(x) for x in input().split()) print(max(0,A-2*B)) ```
output
1
54,577
8
109,155
Provide a correct Python 3 solution for this coding contest problem. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0
instruction
0
54,578
8
109,156
"Correct Solution: ``` a,b=[int(_) for _ in input().split()] print([a-2*b,0][0>a-2*b]) ```
output
1
54,578
8
109,157
Provide a correct Python 3 solution for this coding contest problem. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0
instruction
0
54,579
8
109,158
"Correct Solution: ``` A,B = map(int,input().split()) x = A-B-B print(max(0,x)) ```
output
1
54,579
8
109,159
Provide a correct Python 3 solution for this coding contest problem. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0
instruction
0
54,580
8
109,160
"Correct Solution: ``` print(eval('max(0,'+input().replace(' ','-2*')+')')) ```
output
1
54,580
8
109,161
Provide a correct Python 3 solution for this coding contest problem. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0
instruction
0
54,581
8
109,162
"Correct Solution: ``` a,b=map(int,input().split()) print(max(0,(a-(b*2)))) ```
output
1
54,581
8
109,163
Provide a correct Python 3 solution for this coding contest problem. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0
instruction
0
54,582
8
109,164
"Correct Solution: ``` #ABC 143A A,B = map(int,input().split()) print(max(0,A-2*B)) ```
output
1
54,582
8
109,165
Provide a correct Python 3 solution for this coding contest problem. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0
instruction
0
54,583
8
109,166
"Correct Solution: ``` a,s=map(int,input().split()) print(max(a-2*s,0)) ```
output
1
54,583
8
109,167
Provide a correct Python 3 solution for this coding contest problem. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0
instruction
0
54,584
8
109,168
"Correct Solution: ``` A, B = map(int, input().split(' ')) print(max(0, A - 2 * B)) ```
output
1
54,584
8
109,169
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0 Submitted Solution: ``` a,b=map(int,input().split()) print(max(0,a-b-b)) ```
instruction
0
54,585
8
109,170
Yes
output
1
54,585
8
109,171
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0 Submitted Solution: ``` a,b=map(int,input().split()) print(a-(b*2) if a>=b*2 else 0) ```
instruction
0
54,586
8
109,172
Yes
output
1
54,586
8
109,173
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0 Submitted Solution: ``` a,b=map(lambda x:int(x),input().split()) print(max([0,a-b*2])) ```
instruction
0
54,587
8
109,174
Yes
output
1
54,587
8
109,175
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0 Submitted Solution: ``` a, b = [ int(v) for v in input().split() ] print(max(a-2*b,0)) ```
instruction
0
54,588
8
109,176
Yes
output
1
54,588
8
109,177
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0 Submitted Solution: ``` # https://atcoder.jp/contests/abc143/tasks/abc143_a # -*- coding: utf-8 -*- stu_bangou = list(map(int, input().strip().split())) print(stu_bangou[0] - (stu_bangou[1] * 2))# https://atcoder.jp/contests/abc143/tasks/abc143_a # -*- coding: utf-8 -*- stu_bangou = list(map(int, input().strip().split())) if stu_bangou[0] < (stu_bangou[1] * 2): print(0) else: print(stu_bangou[0] - (stu_bangou[1] * 2)) ```
instruction
0
54,589
8
109,178
No
output
1
54,589
8
109,179
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0 Submitted Solution: ``` N=int(input()) S=input() c=0 for i in range(N-1): if S[i]==S[i+1]: c+=1 print(N-c) ```
instruction
0
54,590
8
109,180
No
output
1
54,590
8
109,181
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0 Submitted Solution: ``` a=int(input()) b=int(input()) c=b*2 if a-c>0: print(a-c) else: print("0") ```
instruction
0
54,591
8
109,182
No
output
1
54,591
8
109,183
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. The window of Takahashi's room has a width of A. There are two curtains hung over the window, each of which has a horizontal length of B. (Vertically, the curtains are long enough to cover the whole window.) We will close the window so as to minimize the total horizontal length of the uncovered part of the window. Find the total horizontal length of the uncovered parts of the window then. Constraints * 1 \leq A \leq 100 * 1 \leq B \leq 100 * A and B are integers. Input Input is given from Standard Input in the following format: A B Output Print the total horizontal length of the uncovered parts of the window. Examples Input 12 4 Output 4 Input 20 15 Output 0 Input 20 30 Output 0 Submitted Solution: ``` a, b = map(int, input().split()) print(a-n*2) ```
instruction
0
54,592
8
109,184
No
output
1
54,592
8
109,185
Provide a correct Python 3 solution for this coding contest problem. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40
instruction
0
54,602
8
109,204
"Correct Solution: ``` N=int(input()) l1=list(map(int,input().split())) l=[0]*N l[1]=abs(l1[1]-l1[0]) for i in range(2,N): l[i]=min(l[i-1]+abs(l1[i]-l1[i-1]),l[i-2]+abs(l1[i]-l1[i-2])) print(l[N-1]) ```
output
1
54,602
8
109,205
Provide a correct Python 3 solution for this coding contest problem. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40
instruction
0
54,603
8
109,206
"Correct Solution: ``` n=int(input()) h=list(map(int,input().split())) d=[0]*n d[1]=abs(h[1]-h[0]) for i in range(2,n): d[i]=min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2])) print(d[n-1]) ```
output
1
54,603
8
109,207
Provide a correct Python 3 solution for this coding contest problem. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40
instruction
0
54,604
8
109,208
"Correct Solution: ``` n = int(input()) li = list(map(int,input().split())) dp = [0,abs(li[1]-li[0])] for i in range(2,n): dp += [min(dp[-2]+abs(li[i]-li[i-2]),dp[-1]+abs(li[i]-li[i-1]))] print(dp[-1]) ```
output
1
54,604
8
109,209
Provide a correct Python 3 solution for this coding contest problem. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40
instruction
0
54,605
8
109,210
"Correct Solution: ``` N=int(input()) H=list(map(int,input().split())) dp=[0]*N dp[0]=0 dp[1]=abs(H[1]-H[0]) for i in range(2,N): dp[i]=min(dp[i-1]+abs(H[i]-H[i-1]), dp[i-2]+abs(H[i]-H[i-2])) print(dp[N-1]) ```
output
1
54,605
8
109,211
Provide a correct Python 3 solution for this coding contest problem. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40
instruction
0
54,606
8
109,212
"Correct Solution: ``` n=int(input()) h=[int(k) for k in input().split()] dp=[0,abs(h[0]-h[1])] for i in range(2,n): dp.append(min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2])) print(dp[n-1]) ```
output
1
54,606
8
109,213
Provide a correct Python 3 solution for this coding contest problem. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40
instruction
0
54,607
8
109,214
"Correct Solution: ``` n = int(input()) h = [int(e) for e in input().split()] dp = [0, abs(h[1]-h[0])] for i in range(2,n): dp.append(min(dp[-1]+abs(h[i]-h[i-1]),dp[-2]+abs(h[i]-h[i-2]))) print(dp[-1]) ```
output
1
54,607
8
109,215
Provide a correct Python 3 solution for this coding contest problem. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40
instruction
0
54,608
8
109,216
"Correct Solution: ``` N=int(input()) h=list(map(int,input().split())) c=[0]*N c[1]=abs(h[1]-h[0]) for i in range(2,N): c[i]=min(c[i-2]+abs(h[i]-h[i-2]),c[i-1]+abs(h[i]-h[i-1])) print(c[-1]) ```
output
1
54,608
8
109,217
Provide a correct Python 3 solution for this coding contest problem. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40
instruction
0
54,609
8
109,218
"Correct Solution: ``` n=int(input()) h=list(map(int,input().split())) dp=[0]*(n) dp[0]=0 dp[1]=abs(h[1]-h[0]) for i in range(2,n): dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1])) print(dp[-1]) ```
output
1
54,609
8
109,219
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40 Submitted Solution: ``` n=int(input()) h=[int(i) for i in input().split()] dp=[0]*n dp[1]=abs(h[0]-h[1]) for i in range(2,n): dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i])) print(dp[n-1]) ```
instruction
0
54,610
8
109,220
Yes
output
1
54,610
8
109,221
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40 Submitted Solution: ``` n=int(input()) h=list(map(int,input().split())) dp=[0]*n dp[0]=0 dp[1]=abs(h[0]-h[1]) for i in range(2,n): dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2])) print(dp[-1]) ```
instruction
0
54,611
8
109,222
Yes
output
1
54,611
8
109,223
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40 Submitted Solution: ``` N = int(input()) h = list(map(int,input().split())) dp = [0,abs(h[0]-h[1])] for i in range(2,N): dp.append(min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]))) print(dp[N-1]) ```
instruction
0
54,612
8
109,224
Yes
output
1
54,612
8
109,225
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40 Submitted Solution: ``` n,*h=map(int,open(0).read().split());a=[0]+[abs(h[1]-h[0])]+[0]*(n-2) for i in range(2,n): a[i]=min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2])) print(a[-1]) ```
instruction
0
54,613
8
109,226
Yes
output
1
54,613
8
109,227
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40 Submitted Solution: ``` n,k=map(int,input().split()) h=list(map(int,input().split())) dp=[1<<60]*(n) dp[0]=0 for i in range(1,n): for j in range(1,(k+1)): if i>=j: dp[i]=min(abs(h[i-j]-h[i])+dp[i-j],abs(dp[i])) else: break print(dp[-1]) ```
instruction
0
54,614
8
109,228
No
output
1
54,614
8
109,229
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40 Submitted Solution: ``` N = int(input()) hlist = list(map(int, input().split())) dp = [float('inf')] * N def f(i): if dp[i] < float('inf'): return dp[i] if i==0: return 0 if i==1: return abs(hlist[1]-hlist[0]) res = float('inf') res = min(res, f(i-1) + abs(hlist[i]-hlist[i-1])) res = min(res, f(i-2) + abs(hlist[i]-hlist[i-2])) dp[i] = res return dp[i] print(f(N-1)) ```
instruction
0
54,615
8
109,230
No
output
1
54,615
8
109,231
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40 Submitted Solution: ``` # url: https://atcoder.jp/contests/dp/tasks from functools import lru_cache k=int(input()) a=list(map(int,input().split())) @lru_cache(maxsize=None) def f(idx,cost): if idx==k-1: return cost return min([ f(idx+i,cost+abs(a[idx]-a[idx+i])) for i in [1,2] if idx+i<=k-1 ]) print(f(0,0)) ```
instruction
0
54,616
8
109,232
No
output
1
54,616
8
109,233
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are N stones, numbered 1, 2, \ldots, N. For each i (1 \leq i \leq N), the height of Stone i is h_i. There is a frog who is initially on Stone 1. He will repeat the following action some number of times to reach Stone N: * If the frog is currently on Stone i, jump to Stone i + 1 or Stone i + 2. Here, a cost of |h_i - h_j| is incurred, where j is the stone to land on. Find the minimum possible total cost incurred before the frog reaches Stone N. Constraints * All values in input are integers. * 2 \leq N \leq 10^5 * 1 \leq h_i \leq 10^4 Input Input is given from Standard Input in the following format: N h_1 h_2 \ldots h_N Output Print the minimum possible total cost incurred. Examples Input 4 10 30 40 20 Output 30 Input 2 10 10 Output 0 Input 6 30 10 60 10 60 50 Output 40 Submitted Solution: ``` n = int(input()) h = list(map(int, input().split())) def chmin(a, b): if a > b: return b else: return a def rec(i): if dp[i] < float('inf'): return dp[i] if i == 0: return 0 res = float('inf') res = chmin(res, rec(i - 1) + abs(h[i] - h[i - 1])) if i > 1: res = chmin(res, rec(i - 2) + abs(h[i] - h[i - 2])) dp[i] = res return dp[i] dp = [float('inf')] * n print(rec(n - 1)) ```
instruction
0
54,617
8
109,234
No
output
1
54,617
8
109,235
Provide a correct Python 3 solution for this coding contest problem. Aizu Gakuen High School holds a school festival every year. The most popular of these is the haunted house. The most popular reason is that 9 classes do haunted houses instead of 1 or 2 classes. Each one has its own unique haunted house. Therefore, many visitors come from the neighborhood these days. Therefore, the school festival executive committee decided to unify the admission fee for the haunted house in the school as shown in the table below, and based on this, total the total number of visitors and income for each class. Admission fee list (admission fee per visitor) Morning Afternoon 200 yen 300 yen Enter the number of visitors in the morning and afternoon for each class, and create a program that creates a list of the total number of visitors and income for each class. Input The input is given in the following format: name1 a1 b1 name2 a2 b2 :: name9 a9 b9 The input consists of 9 lines, the class name of the i-th class on the i-line namei (a half-width character string of 1 to 15 characters including numbers and alphabets), the number of visitors in the morning ai (0 ≤ ai ≤ 400) , Afternoon attendance bi (0 ≤ bi ≤ 400) is given. Output On the i-line, output the class name of the i-class, the total number of visitors, and the fee income on one line separated by blanks. Example Input 1a 132 243 1c 324 183 1f 93 199 2b 372 163 2c 229 293 2e 391 206 3a 118 168 3b 263 293 3d 281 102 Output 1a 375 99300 1c 507 119700 1f 292 78300 2b 535 123300 2c 522 133700 2e 597 140000 3a 286 74000 3b 556 140500 3d 383 86800
instruction
0
54,702
8
109,404
"Correct Solution: ``` d = [input().split() for _ in range(9)] ans = [ds[0]+" "+str(int(ds[1])+int(ds[2]))+" "+str(200*int(ds[1])+300*(int(ds[2]))) for ds in d] print("\n".join(ans)) ```
output
1
54,702
8
109,405
Provide a correct Python 3 solution for this coding contest problem. Aizu Gakuen High School holds a school festival every year. The most popular of these is the haunted house. The most popular reason is that 9 classes do haunted houses instead of 1 or 2 classes. Each one has its own unique haunted house. Therefore, many visitors come from the neighborhood these days. Therefore, the school festival executive committee decided to unify the admission fee for the haunted house in the school as shown in the table below, and based on this, total the total number of visitors and income for each class. Admission fee list (admission fee per visitor) Morning Afternoon 200 yen 300 yen Enter the number of visitors in the morning and afternoon for each class, and create a program that creates a list of the total number of visitors and income for each class. Input The input is given in the following format: name1 a1 b1 name2 a2 b2 :: name9 a9 b9 The input consists of 9 lines, the class name of the i-th class on the i-line namei (a half-width character string of 1 to 15 characters including numbers and alphabets), the number of visitors in the morning ai (0 ≤ ai ≤ 400) , Afternoon attendance bi (0 ≤ bi ≤ 400) is given. Output On the i-line, output the class name of the i-class, the total number of visitors, and the fee income on one line separated by blanks. Example Input 1a 132 243 1c 324 183 1f 93 199 2b 372 163 2c 229 293 2e 391 206 3a 118 168 3b 263 293 3d 281 102 Output 1a 375 99300 1c 507 119700 1f 292 78300 2b 535 123300 2c 522 133700 2e 597 140000 3a 286 74000 3b 556 140500 3d 383 86800
instruction
0
54,703
8
109,406
"Correct Solution: ``` for i in range (9): N, a, b = map(str,input().split()) a = int(a) b = int(b) print(N, a+b, 200*a+300*b) ```
output
1
54,703
8
109,407
Provide a correct Python 3 solution for this coding contest problem. Aizu Gakuen High School holds a school festival every year. The most popular of these is the haunted house. The most popular reason is that 9 classes do haunted houses instead of 1 or 2 classes. Each one has its own unique haunted house. Therefore, many visitors come from the neighborhood these days. Therefore, the school festival executive committee decided to unify the admission fee for the haunted house in the school as shown in the table below, and based on this, total the total number of visitors and income for each class. Admission fee list (admission fee per visitor) Morning Afternoon 200 yen 300 yen Enter the number of visitors in the morning and afternoon for each class, and create a program that creates a list of the total number of visitors and income for each class. Input The input is given in the following format: name1 a1 b1 name2 a2 b2 :: name9 a9 b9 The input consists of 9 lines, the class name of the i-th class on the i-line namei (a half-width character string of 1 to 15 characters including numbers and alphabets), the number of visitors in the morning ai (0 ≤ ai ≤ 400) , Afternoon attendance bi (0 ≤ bi ≤ 400) is given. Output On the i-line, output the class name of the i-class, the total number of visitors, and the fee income on one line separated by blanks. Example Input 1a 132 243 1c 324 183 1f 93 199 2b 372 163 2c 229 293 2e 391 206 3a 118 168 3b 263 293 3d 281 102 Output 1a 375 99300 1c 507 119700 1f 292 78300 2b 535 123300 2c 522 133700 2e 597 140000 3a 286 74000 3b 556 140500 3d 383 86800
instruction
0
54,704
8
109,408
"Correct Solution: ``` for i in range(1,9+1): name,a,b=input().split() a=int(a) b=int(b) print(name,a+b,a*200+b*300) ```
output
1
54,704
8
109,409
Provide a correct Python 3 solution for this coding contest problem. Aizu Gakuen High School holds a school festival every year. The most popular of these is the haunted house. The most popular reason is that 9 classes do haunted houses instead of 1 or 2 classes. Each one has its own unique haunted house. Therefore, many visitors come from the neighborhood these days. Therefore, the school festival executive committee decided to unify the admission fee for the haunted house in the school as shown in the table below, and based on this, total the total number of visitors and income for each class. Admission fee list (admission fee per visitor) Morning Afternoon 200 yen 300 yen Enter the number of visitors in the morning and afternoon for each class, and create a program that creates a list of the total number of visitors and income for each class. Input The input is given in the following format: name1 a1 b1 name2 a2 b2 :: name9 a9 b9 The input consists of 9 lines, the class name of the i-th class on the i-line namei (a half-width character string of 1 to 15 characters including numbers and alphabets), the number of visitors in the morning ai (0 ≤ ai ≤ 400) , Afternoon attendance bi (0 ≤ bi ≤ 400) is given. Output On the i-line, output the class name of the i-class, the total number of visitors, and the fee income on one line separated by blanks. Example Input 1a 132 243 1c 324 183 1f 93 199 2b 372 163 2c 229 293 2e 391 206 3a 118 168 3b 263 293 3d 281 102 Output 1a 375 99300 1c 507 119700 1f 292 78300 2b 535 123300 2c 522 133700 2e 597 140000 3a 286 74000 3b 556 140500 3d 383 86800
instruction
0
54,705
8
109,410
"Correct Solution: ``` for i in range(9): name, b, c = list(input().split()) print(name, int(b)+int(c), int(b)*200+int(c)*300) ```
output
1
54,705
8
109,411
Provide a correct Python 3 solution for this coding contest problem. Aizu Gakuen High School holds a school festival every year. The most popular of these is the haunted house. The most popular reason is that 9 classes do haunted houses instead of 1 or 2 classes. Each one has its own unique haunted house. Therefore, many visitors come from the neighborhood these days. Therefore, the school festival executive committee decided to unify the admission fee for the haunted house in the school as shown in the table below, and based on this, total the total number of visitors and income for each class. Admission fee list (admission fee per visitor) Morning Afternoon 200 yen 300 yen Enter the number of visitors in the morning and afternoon for each class, and create a program that creates a list of the total number of visitors and income for each class. Input The input is given in the following format: name1 a1 b1 name2 a2 b2 :: name9 a9 b9 The input consists of 9 lines, the class name of the i-th class on the i-line namei (a half-width character string of 1 to 15 characters including numbers and alphabets), the number of visitors in the morning ai (0 ≤ ai ≤ 400) , Afternoon attendance bi (0 ≤ bi ≤ 400) is given. Output On the i-line, output the class name of the i-class, the total number of visitors, and the fee income on one line separated by blanks. Example Input 1a 132 243 1c 324 183 1f 93 199 2b 372 163 2c 229 293 2e 391 206 3a 118 168 3b 263 293 3d 281 102 Output 1a 375 99300 1c 507 119700 1f 292 78300 2b 535 123300 2c 522 133700 2e 597 140000 3a 286 74000 3b 556 140500 3d 383 86800
instruction
0
54,706
8
109,412
"Correct Solution: ``` for i in range (9): name,a,b=map(str,input().split()) print(name,(int(a)+int(b)),(200*int(a)+300*int(b))) ```
output
1
54,706
8
109,413