Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03255 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import itertools

N,B = map(int,input().split())
X = [int(x) for x in input().split()]

Xcum = tuple(itertools.accumulate(X))

coef = [2] * N
coef[0] = 5
coef[1] = 0

answer = min(sum(x*y for x,y in zip(Xcum[::-n], coef[:1+(N-1)//n])) + B*(N+n) for n in range(1,N+1))
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

import numpy as np

N,B = map(int,input().split())
X = np.array(input().split(), dtype=np.int64)

Xcum = X.cumsum()

coef = np.full(N,2,dtype=np.int64)
coef[0] = 5
coef[1] = 0

answer = 10**18
for n in range(1,N+1):
    # 往復回数
    cost = (Xcum[::-n]*coef[:N//n]).sum() + B*(N+n)
    answer = min(answer, cost)

print(answer)
Problem p03260 (python)

Fixed submission:
A,B = map(int,input().split())
print('Yes' if A&B&1 else 'No')

Buggy submission (verdict: Runtime Error):
A,B = int(input()),int(input())
print('Yes' if A&B&1 else 'No')

Buggy submission (verdict: Runtime Error):
A,B = int(input()),int(input())
print('Yes' if A&B&1 else 'No)
Problem p03287 (python)

Fixed submission:
import numpy as np
from collections import Counter

N,M = map(int,input().split())
A = np.array([0]+[int(x) for x in input().split()],dtype=np.int64)
A_cum = np.mod(A.cumsum(),M)

c = Counter(A_cum)

answer = 0
for x in c.values():
  answer += x*(x-1)//2
print(answer)

Buggy submission (verdict: Runtime Error):
import numpy as np

N,M = map(int,input().split())
A = np.array(input().split(), dtype=np.int64)
np.cumsum(A, out = A)
A %= M

counter = np.bincount(A)
counter[0] += 1 # empty
answer = (counter * (counter-1)).sum() // 2
print(answer)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
A = np.array(input().split(), dtype=np.int64)
A_cum = np.mod(A.cumsum(),M)

counter = np.bincount(A_cum)
counter[0] += 1 # empty
answer = (counter * (counter-1)).sum() // 2
print(answer)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
A = np.array([0]+[int(x) for x in input().split()],dtype=np.int64)
A_cum = np.mod(A.cumsum(),M)

counter = np.bincount(A_cum)
counter[0] += 1 # empty
answer = (counter * (counter-1)).sum() // 2
print(answer)

Buggy submission (verdict: Runtime Error):
import numpy as np
N,M = map(int,input().split())
A = np.array([0]+[int(x) for x in input().split()],dtype=np.int64)
A_cum = np.mod(A.cumsum(),M)

counter = np.bincount(A_cum, dtype=np.int64)
counter[0] += 1 # empty
answer = (counter * (counter-1)).sum() // 2
print(answer)
Problem p03296 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

answer = 0
for i in range(1,N):
  if A[i] == A[i-1]:
    A[i] = -1
    answer += 1
print(answer)

Buggy submission (verdict: Runtime Error):
N = input()
A = [int(x) for x in input().split()]

answer = 0
for i in range(1,N):
  if A[i] == A[i-1]:
    A[i] = -1
    answer += 1
print(answer)
Problem p03302 (python)

Fixed submission:
a,b = map(int,input().split())
answer = 'x'
if a+b == 15:
  answer = '+'
elif a*b == 15:
  answer = '*'
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
from heapq import heappush, heappop

N,M,S,T = map(int,input().split())
graph = [[] for _ in range(N+1)]
for _ in range(M):
    u,v,a,b = map(int,input().split())
    graph[u].append((v,a,b))
    graph[v].append((u,a,b))

def dijkstra(start, mode):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    q = [(0,start)]
    while q:
        d,v = heappop(q)
        if dist[v] < d:
            continue
        for w,*a in graph[v]:
            d1 = d + a[mode]
            if dist[w] > d1:
                dist[w] = d1
                heappush(q, (d1,w))
    return dist

d1 = np.array(dijkstra(S,0))
d2 = np.array(dijkstra(T,1))

d1 += d2
answer = 10 ** 15 - np.minimum.accumulate(d1[::-1])[::-1][1:]

print('\n'.join(answer.astype(str)))
Problem p03313 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from heapq import heappushpop

N = int(input())
A = [int(x) for x in input().split()]

# B_x = max {A_y | y\subset x}
# と思ったが、2元ずつ持つ必要がある。
# (値、何番から来たか)
B = []
for n,a in enumerate(A):
    arr = [(0,0),(a,n)]
    m = n
    while m:
        bit = m & (-m)
        (x,i),(y,j) = B[n-bit]
        if (x,i) != arr[-1]:
            heappushpop(arr,(x,i))
        if (y,j) != arr[-1]:
            heappushpop(arr,(y,j))
        m -= bit
    B.append(arr)

answer = [0]
for (x,i),(y,j) in B[1:]:
    z = answer[-1]
    if z < x + y:
        z = x + y
    answer.append(z)
print('\n'.join(map(str,answer[1:])))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import itertools

N = int(input())
A = [int(x) for x in input().split()]

# B_x = max {A_y | y\subset x}
# と思ったが、2元ずつ持つ必要がある。
# (値、何番から来たか)
B = []
for n,a in enumerate(A):
    arr = [(a,n)]
    m = n
    while m:
        bit = m & (-m)
        arr += B[n - bit]
        m -= bit
    se = set(arr)
    B.append(sorted(se, reverse=True)[:2])

answer = itertools.accumulate([x+y for (x,i),(y,j) in B[1:]], max)
print('\n'.join(map(str,answer)))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import itertools

N = int(input())
A = [int(x) for x in input().split()]

# B_x = max {A_y | y\subset x}
# と思ったが、2元ずつ持つ必要がある。
# (値、何番から来たか)
B = []
for n,a in enumerate(A):
    se = set([(a,n)])
    m = n
    while m:
        bit = m & (-m)
        se |= set(B[n - bit])
        m -= bit
    B.append(sorted(se, reverse=True)[:2])

answer = itertools.accumulate([x+y for (x,i),(y,j) in B[1:]], max)
print('\n'.join(map(str,answer)))
Problem p03399 (python)

Fixed submission:
a,b,c,d = [int(input()) for _ in range(4)]
print(min(a,b)+min(c,d))

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
print(min(a,b)+min(c,d))
Problem p03409 (python)

Fixed submission:
from scipy.sparse.csgraph import dijkstra
# 二部グラフ完全マッチング
# 最大フロー
N = int(input())
NN = N * 2
XY = [[int(x) for x in input().split()] for _ in range(NN)]
graph = [[0] * (NN+2) for _ in range(NN+2)]
start = NN
goal = NN+1

for i,(a,b) in enumerate(XY[:N]):
  for j,(c,d) in enumerate(XY[N:], N):
    if a < c and b < d:
      graph[i][j] = 1

for i in range(N):
  graph[start][i] = 1
for i in range(N,NN):
  graph[i][goal] = 1
  
INF = 10 ** 9

def max_flow(graph):
  dist, pred = dijkstra(graph, indices = start, return_predecessors = True)
  if dist[goal] > INF:
    return 0
  y = goal
  while y != start:
    x = pred[y]
    graph[x][y] -= 1
    graph[y][x] += 1
    y = x
  return 1 + max_flow(graph)

answer = max_flow(graph)
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from scipy.optimize import linear_sum_assignment
import numpy as np

N = int(input())
AB = [[int(x) for x in input().split()] for _ in range(N)]
CD = [[int(x) for x in input().split()] for _ in range(N)]

mat = np.zeros((N,N),dtype=np.int32)

for i,(a,b) in enumerate(AB):
    for j,(c,d) in enumerate(CD):
        if a<c and b<d:
            mat[i,j] -= 1


I,J = linear_sum_assignment(mat)

answer = -mat[I,J].sum()
print(answer)
Problem p03412 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
 
def sum_count(A,B,x):
    # A,B is sorted. 
    # return count(a+b < x)
    p = len(B)-1
    result = 0
    for a in A:
        while p != -1 and a + B[p] >= x:
            p -= 1
        result += p+1
    return result
 
		
def f(t,A,B):
    power = (1<<t)
    AA = [x&(2*power-1) for x in A]
    BB = [x&(2*power-1) for x in B]
    AA.sort()
    BB.sort()
    
    x1,x2,x3 = (sum_count(AA,BB,v) for v in [power, 2*power, 3*power])
    zero_cnt = x1 + (x3-x2)
    return (N-zero_cnt)%2
  
ans = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		ans += 1<<t
 
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import bisect

N = int(input())
A = np.array([int(x) for x in input().split()],dtype = np.int64)
B = np.array([int(x) for x in input().split()],dtype = np.int64)

def f(t,A,B):
	power = (1<<t)
	AA = np.mod(A,2*power)
	BB = np.mod(B,2*power)
	AA.sort()
	BB.sort()
	cnt = 0
	for i in range(N):
		a = AA[i]
		R = bisect.bisect_right(BB, power-1-a)
		cnt += R
		L = bisect.bisect_left(BB,2*power-a)
		R = bisect.bisect_right(BB, 3*power-1-a)
		cnt += R-L
	x0 = cnt
	x1 = N*N - cnt
	return x1%2
  
ans = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		ans += 1<<t

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import bisect

N = int(input())
A = np.array([int(x) for x in input().split()],dtype = np.int64)
B = np.array([int(x) for x in input().split()],dtype = np.int64)

def f(t,A,B):
	power = (1<<t)
	AA = np.mod(A,2*power)
	BB = np.mod(B,2*power)
	AA.sort()
	BB.sort()
	cnt = 0
	for i in range(N):
		a = AA[i]
		R = bisect.bisect_right(BB, power-1-a)
		cnt += R
		L = bisect.bisect_left(BB,2*power-a)
		R = bisect.bisect_right(BB, 3*power-1-a)
		cnt += R-L
	x0 = cnt
	x1 = N*N - cnt
	return x1%2
  
ans = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		ans += 1<<t

print(ans)
Problem p03420 (python)

Fixed submission:
# a%b >= K iff xb+K <= a < (x+1)b
# bごとに数えるだけ

N,K = map(int,input().split())
ans = 0

for b in range(K+1,N+1):
  cnt = 0
  x_max = N//b
  # 0 <= x < x_max
  # 各xに対してb-K個ある
  cnt += x_max * (b-K)
  # x = x_max
  lower = x_max*b+K
  if lower <= N:
    upper = min((x_max+1)*b-1,N)
    cnt += upper - lower + 1
  ans += cnt

# N=0除外
if K == 0:
  ans -= N
  
print(ans)

Buggy submission (verdict: Runtime Error):
# a%b >= K iff xb+K <= a < (x+1)b
# bごとに数えるだけ

N,K = map(int,input().split())
ans = 0

for b in range(K+1,N+1):
  cnt = 0
  x_max = N//b
  # 0 <= x < x_max
  # 各xに対してb-K個ある
  cnt += x_max * (b-K)
  # x = x_max
  lower = x_max*b+K
  if lower <= N:
	upper = min((x_max+1)*b-1,N)
    cnt += upper - lower + 1
  ans += cnt
  
print(ans)
Problem p03422 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
AK = np.array(read().split(),np.int32)

A = AK[::2]; K = AK[1::2]

for _ in range(50000):
    q = A//K; r = A%K
    q += 1
    r += (-r)%q
    A -= r

A //= K #grundy
g = np.bitwise_xor.reduce(A)

answer = 'Takahashi' if g else 'Aoki'
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
AK = np.array(read().split(),np.int32)

A = AK[::2]; K = AK[1::2]

G = 0

for t in range(50000):
    q = A//K; r = A%K
    q += 1
    r += (-r)%q
    A -= r
    if t%1000==0:
        ind = r!=0
        G ^= np.bitwise_xor.reduce(A[~ind]//K[~ind])
        A=A[ind];K=K[ind]
        if len(A)==0:
            break

answer = 'Takahashi' if G else 'Aoki'
print(answer)
Problem p03437 (python)

Fixed submission:
x,y = map(int,input().split())
answer = x if x%y else -1
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())

def ask(n):
    print(n, flush=True)
    resp = input().rstrip()[0]
    if resp == 'V':
        exit()
    return resp

resp = ask(0)

def condition(L,R,resp_L,resp_R):
    if (R-L)&1:
        return resp_L == resp_R
    else:
        return resp_L != resp_R

L = 0
R = 0
resp_L = resp
resp_R = resp
for _ in range(19):
    M = (L + R) // 2
    resp_M = ask(M)
    if condition(L,M,resp_L,resp_M):
        R,resp_R = M,resp_M
    else:
        L,resp_L = M,resp_M

Buggy submission (verdict: Runtime Error):
def ask(n):
    print(n, flush=True)
    resp = input().rstrip()[0]
    if resp == 'V':
        exit()
    return resp

resp = ask(0)

def condition(L,R,resp_L,resp_R):
    if (R-L)&1:
        return resp_L == resp_R
    else:
        return resp_L != resp_R

L = 0
R = N
resp_L = resp
resp_R = resp
for _ in range(19):
    M = (L + R) // 2
    resp_M = ask(M)
    if condition(L,M,resp_L,resp_M):
        R,resp_R = M,resp_M
    else:
        L,resp_L = M,resp_M
Problem p03458 (python)

Fixed submission:
#(6,6)周期
#36種の希望

import numpy as np
N,K = map(int,input().split())
KK = 2*K
hope = np.zeros((KK,KK),dtype=np.int32)

XYC = [input().split() for _ in range(N)]

for x,y,c in XYC:
  x = int(x)
  y = int(y)
  if c == 'B':
    x -= K
  x %= KK
  y %= KK
  hope[x,y] += 1
# (x,y)を希望された場合、[x,x+K), [y,y+K)に終点があるべき
# 区間の重なってる枚数を集計。1,0,0,-1, cumsum
A = np.zeros((KK+K,KK+K),dtype=np.int32)
A[:-K,:-K] = hope[:]
A[K:,:-K] += -hope[:]
A[:-K,K:] += -hope[:]
A[K:,K:] += hope[:]
A = A.cumsum(axis = 0).cumsum(axis = 1)

# 実質同じ場所をまとめる
B = A[:,:KK]
B[:,:K] += A[:,KK:] #(3K,2K)
A = B[:KK,:]
A[:K,:] += B[KK:,:] #(2K,2K)
B = A[:K,:] #(K,2K)
B[:,:K] += A[K:,K:]
B[:,K:] += A[K:,:K]

answer = B.max()
print(answer)

Buggy submission (verdict: Runtime Error):
6 2
1 2 B
2 1 W
2 2 B
1 0 B
0 6 W
4 5 W

Buggy submission (verdict: Runtime Error):
#(6,6)周期
#36種の希望

import numpy as np
N,K = map(int,input().split())
KK = 2*K
hope = np.zeros((KK,KK),dtype=np.int32)

XYC = [input().split() for _ in range(N)]

for _ in range(N):
  x,y,c  = input().split()
  x = int(x)
  y = int(y)
  if c == 'B':
    x -= K
  hope[x%KK,y%KK] += 1
# (x,y)を希望された場合、[x,x+K), [y,y+K)に終点があるべき
# 区間の重なってる枚数を集計。1,0,0,-1, cumsum
A = np.zeros((KK+K,KK+K),dtype=np.int32)
A[:-K,:-K] = hope[:]
A[K:,:-K] += -hope[:]
A[:-K,K:] += -hope[:]
A[K:,K:] += hope[:]
A = A.cumsum(axis = 0).cumsum(axis = 1)

# 実質同じ場所をまとめる
B = A[:,:KK]
B[:,:K] += A[:,KK:] #(3K,2K)
A = B[:KK,:]
A[:K,:] += B[KK:,:] #(2K,2K)
B = A[:K,:] #(K,2K)
B[:,:K] += A[K:,K:]
B[:,K:] += A[K:,:K]

answer = B.max()
print(answer)
Problem p03491 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
from collections import deque

N,M = map(int,input().split())
words = [deque(input().rstrip()) for _ in range(N)]

# 深さLのfull treeの小さい方を計算してみる
def G_small():
    G = [0] * 100
    G_cum = [0] * 100
    G[0] = 1
    G_cum[0] = 1
    for n in range(1,100):
        can_make = set(G_cum[n-1]^G_cum[x] for x in range(n)) | set([G_cum[n-1]])
        rest = set(range(n+10)) - can_make
        G[n] = min(rest)
        G_cum[n] = G_cum[n-1] ^ G[n]
    return G

# print([(n,G[n]) for n in range(100)])
# G[n] = 2**ord_2(n+1)
# 値がわかれば証明は易しい

def G(n):
    n += 1
    x = 1
    while not n & 1:
        n >>= 1
        x <<= 1
    return x

def calc_grandy(words,L):
    if not words:
        return G(L)
    if len(words) == 1 and words[0] == deque():
        return 0
    words_0 = []
    words_1 = []
    for word in words:
        first = word.popleft()
        if first == '0':
            words_0.append(word)
        else:
            words_1.append(word)
    return calc_grandy(words_0,L-1) ^ calc_grandy(words_1,L-1)

g = calc_grandy(words,M)

answer = 'Alice' if g != 0 else 'Bob'
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque

N,M = map(int,input().split())
words = [deque(input().rstrip()) for _ in range(N)]

# 深さLのfull treeの小さい方を計算してみる
def G_small():
    G = [0] * 100
    G_cum = [0] * 100
    G[0] = 1
    G_cum[0] = 1
    for n in range(1,100):
        can_make = set(G_cum[n-1]^G_cum[x] for x in range(n)) | set([G_cum[n-1]])
        rest = set(range(n+10)) - can_make
        G[n] = min(rest)
        G_cum[n] = G_cum[n-1] ^ G[n]
    return G

# print([(n,G[n]) for n in range(100)])
# G[n] = 2**ord_2(n+1)
# 値がわかれば証明は易しい

def G(n):
    n += 1
    x = 1
    while not n & 1:
        n >>= 1
        x <<= 1
    return x

def calc_grandy(words,L):
    if not words:
        return G(L)
    if len(words) == 1 and words[0] == deque():
        return 0
    words_0 = []
    words_1 = []
    for word in words:
        first = word.popleft()
        if first == '0':
            words_0.append(word)
        else:
            words_1.append(word)
    return calc_grandy(words_0,L-1) ^ calc_grandy(words_1,L-1)

g = calc_grandy(words,M)

answer = 'Alice' if g != 0 else 'Bob'
print(answer)
Problem p03499 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import deque

MOD = 10 ** 9 + 7

N = int(input())
graph = [[] for _ in range(N+1)]
for i,x in enumerate(input().rstrip().split(),1):
    x = int(x)
    graph[i].append(x)
    graph[x].append(i)

# 各深さから来ている (0個、1個、2個以上) の分布を 確率 mod MODで持つ。

half = (MOD + 1) // 2

def merge(dp,dp1):
    L = len(dp1)
    for i in range(L):
        # 0個,1個,2個以上
        a,b,c = dp[i]
        d,e,f = dp1[i]
        a,b,c = a*d, a*e + b*d, a*f + b*e + b*f + c*d + c*e + c*f
        a %= MOD
        b %= MOD
        c %= MOD
        dp[i] = (a,b,c)
    return

def dfs(v,parent = None):
    dp = None
    L = 0
    for u in graph[v]:
        if u == parent:
            continue
        dp1 = dfs(u,v)
        if dp is None:
            dp = dp1
        else:
            if len(dp) < len(dp1):
                dp,dp1 = dp1,dp
            # 2個以上が入っているインデックス
            if L < len(dp1):
                L = len(dp1)
            merge(dp,dp1)
    if dp is None:
        dp = deque()
    else:
        # 2個以上あるときに、0個化する
        for i in range(L):
            a,b,c = dp[i]
            dp[i] = (a+c,b,0)
    dp.appendleft((half,half,0))
    return dp

dp = dfs(0)

answer = sum(b for a,b,c in dp)
answer *= pow(2,N+1,MOD)
answer %= MOD
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
from collections import deque

MOD = 10 ** 9 + 7

N = int(input())
graph = [[] for _ in range(N+1)]
for i,x in enumerate(input().rstrip().split(),1):
    x = int(x)
    graph[i].append(x)
    graph[x].append(i)

# 各深さから来ている (0個、1個、2個以上) の分布を 確率 mod MODで持つ。

half = (MOD + 1) // 2

def merge(dp,dp1):
    L = len(dp1)
    for i in range(L):
        # 0個,1個,2個以上
        a,b,c = dp[i]
        d,e,f = dp1[i]
        a,b,c = a*d, a*e + b*d, a*f + b*e + b*f + c*d + c*e + c*f
        a %= MOD
        b %= MOD
        c %= MOD
        dp[i] = (a,b,c)
    return

def dfs(v,parent = None):
    dp = None
    L = 0
    for u in graph[v]:
        if u == parent:
            continue
        dp1 = dfs(u,v)
        if dp is None:
            dp = dp1
        else:
            if len(dp) < len(dp1):
                dp,dp1 = dp1,dp
            # 2個以上が入っているインデックス
            if L < len(dp1):
                L = len(dp1)
            merge(dp,dp1)
    if dp is None:
        dp = deque()
    else:
        # 2個以上あるときに、0個化する
        for i in range(L):
            a,b,c = dp[i]
            dp[i] = (a+c,b,0)
    dp.appendleft((half,half,0))
    return dp

dp = dfs(0)

answer = sum(b for a,b,c in dp)
answer *= pow(2,N+1,MOD)
answer %= MOD
print(answer)
Problem p03502 (python)

Fixed submission:
N = int(input())

def F(x):
  if x < 10:
    return x
  return x%10 + F(x//10)

answer = 'Yes' if N%F(N) == 0 else 'No'
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())

def F(x):
  if x < 10:
    return x
  return x%10 + F(x//10)

answer = 'YES' if x%F(N) == 0 else 'NO'
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())

def F(x):
  if x < 10:
    return x
  return x%10 + F(x//10)

answer = 'YES' if x%F(x) == 0 else 'NO'
print(answer)
Problem p03563 (python)

Fixed submission:
r=int(input())
g=int(input())
print(2*g-r)

Buggy submission (verdict: Runtime Error):
r=input()
g=input()
print(2*g-r)
Problem p03564 (python)

Fixed submission:
# 各時点で最小

N,K = int(input()), int(input())

answer = 1
for _ in range(N):
  answer = min(answer*2, answer+K)

print(answer)

Buggy submission (verdict: Runtime Error):
# 各時点で最小

N,K = map(int,input().split())

answer = 1
for _ in range(N):
  answer = min(answer*2, answer+K)

print(answer)
Problem p03578 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]

cnt = defaultdict(int)
for d in D:
  cnt[d] += 1
for t in T:
  cnt[t] -= 1

answer = 'YES' if min(cnt.values()) >= 0 else 'NO'
print(answer)

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
D = [int(x) for x in input().split()]
M = int(input())
T = [int(x) for x in input().split()]

c = Counter(D) - Counter(T)
answer = 'YES' if min(c.values()) >= 0 else 'NO'
print(answer)
Problem p03597 (python)

Fixed submission:
print(int(input())**2-int(input()))

Buggy submission (verdict: Runtime Error):
n,a = map(int,input().split())
print(n*n-a)
Problem p03599 (python)

Fixed submission:
import itertools

A,B,C,D,E,F = map(int,input().split())

WF = F//100+1

water = [False] * (WF+1+30)
sugar = [False] * (F+1+30)

water[0] = True
sugar[0] = True

for n in range(WF):
  if water[n]:
    water[n+A] = True
    water[n+B] = True
for n in range(F):
  if sugar[n]:
    sugar[n+C] = True
    sugar[n+D] = True

water = set(100*x for x in range(1,1+WF) if water[x])
sugar = set(x for x in range(1+F) if sugar[x])

# at most 30 * 3000なので全てやる
ans_per = -1
for w, s in itertools.product(water, sugar):
  if w//100*E < s:
    continue
  if w+s > F:
    continue
  x = s/(w+s)
  if x > ans_per:
    ans_per = x
    ans_w = w
    ans_s = s

print(ans_w + ans_s, ans_s)

Buggy submission (verdict: Runtime Error):
import itertools

A,B,C,D,E,F = map(int,input().split())

WF = F//100+1

water = [False] * (WF+1+30)
sugar = [False] * (F+1+30)

water[0] = True
sugar[0] = True

for n in range(WF):
  if water[n]:
    water[n+A] = True
    water[n+B] = True
for n in range(F):
  if sugar[n]:
    sugar[n+C] = True
    sugar[n+D] = True

water = set(100*x for x in range(1,1+WF) if water[x])
sugar = set(x for x in range(1,1+F) if sugar[x])

# at most 30 * 3000なので全てやる
ans_per = -1
for w, s in itertools.product(water, sugar):
  if w//100*E < s:
    continue
  if w+s > F:
    continue
  x = s/(w+s)
  if x > ans_per:
    ans_per = x
    ans_w = w
    ans_s = s

print(ans_w + ans_s, ans_s)
Problem p03611 (python)

Fixed submission:
import numpy as np
# 前後1まで回収できる
N = int(input())

# n以下のものをかぞえる
A = np.bincount(np.array(input().split(), dtype=np.int32))

B = A.copy() # そのままとる
B[1:] += A[:-1] # 1増やして回収
B[:-1] += A[1:] # 1減らして回収

answer = B.max()
print(answer)

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(input().split(), dtype = np.int32)

counter = np.bincount(A)
answer = (counter[2:] + counter[1:-1] + counter[:-2]).max()
print(answer)
Problem p03633 (python)

Fixed submission:
N = int(input())

def gcd(a,b):
  while b:
    a,b = b,a%b
  return a

answer = 1
for _ in range(N):
  x = int(input())
  answer *= x//gcd(answer, x)
               
print(answer)

Buggy submission (verdict: Runtime Error):
N = int(input())

def gcd(a,b):
  while b:
    a,b = b,a%b
  return a

answer = 0
for _ in range(N):
  answer = gcd(answer, int(input())
               
print(answer)
Problem p03658 (python)

Fixed submission:
n,k = map(int,input().split())
A = [int(x) for x in input().split()]
A.sort()

answer = sum(A[-k:])
print(answer)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
A = [int(x) for x in input().split()]
A.sort()

answer = sum(A[-K:])
print(answer)