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

Fixed submission:


def func():
    N, k = map(int, input().split() )
    h = list( map(int,input().split()) )

    dp = [float('inf')] * N
    dp[0] = 0
    for n in range(1, N):
        # can_min = 10**4
        # for k in range(1,K+1l):
        #     if n-k >= 0 :
        #         can = dp[n-k] + abs(h[n]-h[n-k])
        #         can_min = min(can, can_min)
        # dp[n] = can_min 
        dp[n] = min([ dp[j] + abs(h[n]-h[j]) for j in range(max(n-k,0), n) ])
    print(dp[N-1])

if __name__=='__main__':
    func()

Buggy submission (verdict: Runtime Error):


def func():
    N, k = map(int, input().split() )
    h = list( map(int,input().split()) )

    dp = [0] * N
    for n in range(1, N):
        # can_min = 10**4
        # for k in range(1,K+1l):
        #     if n-k >= 0 :
        #         can = dp[n-k] + abs(h[n]-h[n-k])
        #         can_min = min(can, can_min)
        # dp[n] = can_min 
        dp[n] = min([ dp[max(n-k, 0)] + abs(h[n]-h[max(n-k,0)]) for k in range(max(n-k,0)) ])
    print(dp[N-1])

if __name__=='__main__':
    func()

Buggy submission (verdict: Runtime Error):


def func():
    N, K = map(int, input().split() )
    h = list( map(int,input().split()) )

    dp = [0] * N
    for n in range(1, N):
        can_min = 10**4
        # for k in range(1,K+1l):
        #     if n-k >= 0 :
        #         can = dp[n-k] + abs(h[n]-h[n-k])
        #         can_min = min(can, can_min)
        # dp[n] = can_min 
        dp[n] = min([ dp[max(n-k, 0)] + abs(h[n]-h[max(n-k,0)]) for k in range(max(n-k,0)) ])
    print(dp[N-1])

if __name__=='__main__':
    func()
Problem p03163 (python)

Fixed submission:
import numpy as np

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = np.maximum(dp[n-1][w:W+1], dp[n-1][:W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])

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

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = max(dp[n-1][w:W+1], dp[n-1][:W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])

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

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
wv = [[0,0]]
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][:] = dp[n-1][:]
    dp[n][w:W+1] = max(dp[n-1][w:W+1], dp[n-1][W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])

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

N, W = map(int, input().split())
dp = np.array([ [0]*(W+1) ] * (N+1))
wv = [[0,0]]
for n in range(1,N+1):
    w, v = map(int, input().split() )
    dp[n][w:W+1] = max(dp[n-1][w:W+1], dp[n-1][W+1-w]+v )
    # for w_lim in range(1,W+1):
    #     if w_lim - wv[n][0] >= 0 :
    #         dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
    #     else :
    #         dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])

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

N, W = map(int, input().split())
wv = [[0,0]]
for _ in range(N):
    wv.append( list(map(int, input().split())))
dp = np.array([ [0]*(W+1) ] * (N+1))
for n in range(1,N+1):
    for w_lim in range(1,W+1):
        if w_lim - wv[n][0] >= 0 :
            dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
        else :
            dp[n][w_lim] = dp[n-1][w_lim]
print(dp[N][W])

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

N, W = map(int, input().split())
wv = [[0,0]]
for _ in range(N):
    wv.append([ list(map(int, input().split())) ])
# N,W = 3, 8
# wv = [[0,0],[3,30], [4,50], [5,60]]
dp = np.array([ [0]*(W+1) ] * (N+1))
# print(dp.shape)
# print(np.array(dp))

for n in range(1,N+1):
    for w_lim in range(1,W+1):
        # print(n, w_lim)
        # print(np.array(dp))
        # v[n]を追加するとき
        if w_lim - wv[n][0] >= 0 :
            dp[n][w_lim] = max( dp[n-1][w_lim], dp[n-1][w_lim-wv[n][0]]+wv[n][1] )
        else :
            dp[n][w_lim] = dp[n-1][w_lim]

# print('\n',np.array(dp))
print(dp[N][W])
Problem p02657 (python)

Fixed submission:
n,m = map(int,input().split())

print(n*m)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())

pirnt(n*m)
Problem p02658 (python)

Fixed submission:
n= int(input())
a= list(map(int,input().split()))
 
ans = 1
over = -1
 
if 0 in a:
    print(0)
    exit(0)

for i in a:
  ans = i * ans
  if ans > 10**18:
      print(-1)
      exit(0)

print(ans)

Buggy submission (verdict: Runtime Error):
n= int(input())
a= list(map(int,input().split()))
 
ans = 1
over = -1
 
if 0 in a:
    print(0)
    exit(0)

for i in a:
  ans = i * ans
  if ans > 10**18:
	print(over)
    exit(0)

print(ans)

Buggy submission (verdict: Runtime Error):
n= int(input())
a= list(map(int,input().split()))
 
ans = 1
 
if 0 in a:
    print(0)
    exit(0)

for i in a:
  ans = i * ans
  if ans > 10**18:
	print(-1)
    exit(0)

print(ans)

Buggy submission (verdict: Runtime Error):
n= int(input())
a= list(map(int,input().split()))

ans = 1

for i in a:
  ans = i * ans

  
if ans > 10**18:
 	print (-1)
    exit()
    
print(ans)
Problem p02675 (python)

Fixed submission:
s=[]
s=list(input())

if s[-1]=='3':
    print("bon")
elif s[-1]=='0' or s[-1]=='1' or s[-1] =='6' or s[-1]=='8':
    print("pon")
else:
    print("hon")

Buggy submission (verdict: Runtime Error):
a,b,c,k = map(int,input().split())

if a>k:
    ans = k
elif a+b>k:
    ans = a
else:
    ans = a-(k-a-b)

print(ans)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())

import sys

if n==0:
  print(x)
  sys.exit()
  
P = list(map(int, input().split()))
P.sort()
notP = [i for i in range(0, 102) if i not in P]

ans = notP[0]
min_delta = abs(x - ans)

for p in notP:
  delta = abs(x - p)
  if delta<min_delta:
    ans = p
    min_delta = abs(x - ans)
    
print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())

if n==0:
  print(x)
  import sys
  sys.exit()
  
P = list(map(int, input().split()))
P.sort()
notP = [i for i in range(1, 101) if i not in P]

ans = notP[0]
min_delta = abs(x - ans)

for p in notP:
  delta = abs(x - p)
  if delta<min_delta:
    ans = p
    min_delta = abs(x - ans)
    
print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
notP = [i for i in range(1, 101) if i not in P]

ans = notP[0]
min_delta = abs(x - ans)

for p in notP:
  delta = abs(x - p)
  if delta<min_delta:
    ans = p
    min_delta = abs(x - ans)
    
print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
P = list(map(int, input().split()))
P.sort()
notP = [i for i in range(1, 101) if i not in P]

ans = notP[0]
for p in notP:
  delta = abs(x - p)
  if delta<ans:
    ans = p
    
print(ans)
Problem p02768 (python)

Fixed submission:
n, a, b = map(int, input().split())
MOD = 10**9 + 7
ans = pow(2, n, MOD)
ans -= 1 # select no flowers

def ncr(n, r, MOD):
  res = 1
  for i in range(r):
    res = res*(n-i)%MOD
  
  f = [1]*(r+1)
  inv = [1]*(r+1)

  for i in range(r):
    f[i+1] = f[i]*(i+1)%MOD
  
  inv[r] = pow(f[r], MOD-2, MOD)
  
  for i in range(r, 0, -1):
    inv[i-1] = inv[i]*i%MOD
    
  return res*inv[r]%MOD
    
ans -= ncr(n, a, MOD)
ans -= ncr(n, b, MOD)

print(ans%MOD)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())

P = 10**9 + 7
N = 2*10**5+2

f = [1]
for i in range(1, N):
  f.append(f[i-1]*i%P)

def modinv(a, mod):
    return pow(a, mod - 2, mod)

def comb(n,r):
  return ((f[n]*modinv(n-r, P))%P*modinv(r, P))%P

#print(a,b)
#print((n*modinv(n,P))%P)
#print(comb(n,b))

ans = ((n%P)*(n%P) - comb(n,a) - comb(n,b))%P - 1
print(int(ans))
Problem p02786 (python)

Fixed submission:
H = int(input())
#H = 1000000000000

import numpy as np

cnt=0
for i in range(100):
    if H<2**(i+1):
        break
    else:
        cnt+=1
        
if cnt == 0:
    print(1)
else:    
    print(np.sum([2**i for i in range(cnt+1)]))

Buggy submission (verdict: Runtime Error):
H = int(input())
#H = 1000000000000

#K = 1
#N = 3
#An = [4,1,5]

import numpy as np

cnt=0
for i in range(1000000):
    if H<2**(i+1):
        break
    else:
        cnt+=1
        
#import math

if cnt ==0:
    break_cnt==0
else:    
    break_cnt = np.sum([2**i for i in range(cnt)])
    
kill_cnt = 2**cnt 

print(kill_cnt + break_cnt)

Buggy submission (verdict: Runtime Error):
H = int(input())
#H = 1000000000000

#K = 1
#N = 3
#An = [4,1,5]

import numpy as np

cnt=0
for i in range(1000):
    if H<2**(i+1):
        break
    else:
        cnt+=1
        
import math

if cnt ==0:
    break_cnt==0
else:    
    break_cnt = np.sum([2**i for i in range(cnt)])
    
kill_cnt = 2**cnt 

print(kill_cnt + break_cnt)
Problem p02787 (python)

Fixed submission:
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
max_A = max([a for a, _b in AB])

dp = [10**18] * (H+max_A)
dp[0] = 0
#print(dp)

for i in range(H):
  for a, b in AB:
    dp[i+a] = min(dp[i]+b, dp[i+a])
    
print(int(min(dp[H:])))

Buggy submission (verdict: Runtime Error):

H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
max_A = max([a for a, _b in AB])

dp = [10**18] * (N+max_A)
dp[0] = 0

for i in range(N+max_A):
  for a, b in AB:
    dp[i+a] = min(dp[i]+b, dp[i+a])
    
print(int(min(dp[H:])))
Problem p02788 (python)

Fixed submission:
#import numpy as np
import math
from bisect import bisect

N, D, A = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(N)]
xh.sort(key=lambda x: x[0])
x = [i[0] for i in xh]
h = [i[1] for i in xh]
#h_int = np.ceil(h/A)

cnt=0
damage=[0]*(N+1)

for i in range(len(x)):
    damage[i] += damage[i-1]
    h[i] -= damage[i]
    if h[i]<=0: continue
    h_int =  math.ceil(h[i]/A)
    cnt+=h_int
    damage[i]+=h_int*A
    r=bisect(x,x[i]+2*D)
    #print(damage[i])
    damage[r]-= A*h_int
    

print(int(cnt))

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

N, D, A = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(N)]
xh.sort(key=lambda x: x[0])
x = np.array([i[0] for i in xh])
h = np.array([i[1] for i in xh])
h_int = np.ceil(h/A)

cnt=0
for i in range(len(x)):
    if h_int[i]<=0: continue
    cnt+=h_int[i]
    r = bisect(x, x[i]+2*D)
    h_int[i+1:r] = h_int[i+1:r]-h_int[i]

print(int(cnt))
Problem p02789 (python)

Fixed submission:
n, m = map(int, input().split())

if n==m:
  print('Yes')
else:
  print('No')

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

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from fractions import gcd

l = a[0]
for i in range(1,n):
  l = l*a[i]//gcd(l,a[i])

ans = 0
for i in range(n):
  ans += l//a[i]

print(ans%mod)
Problem p02813 (python)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
np = [i for i in range(1, n+1)]

import itertools

all_list = list(itertools.permutations(np))

cnt=0
a, b = 0, 0
for seq in all_list:
  cnt += 1
  if list(seq) == p:
    a = cnt
  if list(seq) == q:
    b = cnt

print(abs(a-b))

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
np = [i for i in range(1, n+1)]

import itertools

all_list = list(itertools.permutations(np))

cnt=0
for seq in all_list:
  cnt += 1
  if seq == p:
    a = cnt
  if seq == q:
    b = cnt

print(abs(a-b))
Problem p02838 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7

dig = 60
Abn = [[0]*dig for _ in range(n)]

b0 = [0]*dig
b1 = [0]*dig
for i in range(n):
  for j in range(dig):
    if A[i]>>j&1:
      b1[j] += 1
    else:
      b0[j] += 1
      
pow2 = [pow(2, i, MOD) for i in range(dig)]

ans = 0
for i in range(dig):
  ans += b1[i]*b0[i]*pow2[i]%MOD
  
print(ans%MOD)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7

dig = 60
Abn = [[0]*dig for _ in range(n)]

for i in range(n):
  for j in range(dig):
    if A[i]>>j&1:
      Abn[i][j] = 1
      

Cbn = [[[0]*2 for j in range(dig)] for i in range(n)]

for j in range(dig):
  if Abn[n-1][j]==1:
    Cbn[n-1][j][1] = 1
  else:
    Cbn[n-1][j][0] = 1
    
for i in range(n-2, 0, -1):
  for j in range(dig):
    if Abn[i][j]==1:
      Cbn[i][j][0] = Cbn[i+1][j][0]
      Cbn[i][j][1] = Cbn[i+1][j][1] + 1
    else:
      Cbn[i][j][0] = Cbn[i+1][j][0] + 1
      Cbn[i][j][1] = Cbn[i+1][j][1]

ans = 0
two = [pow(2, i, MOD) for i in range(dig)]

for i in range(n-1):
  for j in range(dig):
    if Abn[i][j] == 1:
      ans += Cbn[i+1][j][0] * two[i] % MOD
    else:
      ans += Cbn[i+1][j][1] * two[i] % MOD
    ans %= MOD
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))

MOD = 10**9 + 7

dig = 60
Abn = [[0]*dig for _ in range(n)]

for i in range(n):
  for j in range(dig):
    if A[i]>>j&1:
      Abn[i][j] = 1
      

Cbn = [[[0]*2 for j in range(dig)] for i in range(n)]

for j in range(dig):
  if Abn[n-1][j]==1:
    Cbn[n-1][j][1] = 1
  else:
    Cbn[n-1][j][0] = 1
    
for i in range(n-2, 0, -1):
  for j in range(dig):
    if Abn[i][j]==1:
      Cbn[i][j][0] = Cbn[i+1][j][0]
      Cbn[i][j][1] = Cbn[i+1][j][1] + 1
    else:
      Cbn[i][j][0] = Cbn[i+1][j][0] + 1
      Cbn[i][j][1] = Cbn[i+1][j][1]

ans = 0
two = [pow(2, i, MOD) for i in range(dig)]

for i in range(n-1):
  for j in range(dig):
    if Abn[i][j] == 1:
      ans += Cbn[i+1][j][0] * two[i] % MOD
    else:
      ans += Cbn[i+1][j][1] * two[i] % MOD
    ans %= MOD
    
print(ans)
Problem p02936 (python)

Fixed submission:
#138_D
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 6)

n, q = map(int, input().split())

edges = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for _ in range(n-1):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
    
for _ in range(q):
    p, x = map(int, input().split())
    cnt[p-1] += x
    
def dfs(frm, cur):
    for to in edges[cur]:
        if to != frm:
            cnt[to] += cnt[cur]
            dfs(cur, to)
dfs(-1, 0)          
print(*cnt)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())

e = [list(map(int, input().split())) for _ in range(n-1)]
cm = [list(map(int, input().split())) for _ in range(q)]
parent = [-1]*n
child = [[]]*n
counter = [0]*n

for i, v in cm:
  counter[i-1] += v

parent[0] = 0
for a, b in e:
  if parent[a-1]<0:
    parent[a-1] = b-1
    child[b-1] = child[b-1] + [a-1]
  else:
    parent[b-1] = a-1
    child[a-1] = child[a-1] + [b-1]

cum_counter = [0]*n
def check(i, cum_cnt):
  cum_cnt += counter[i]
  cum_counter[i] = cum_cnt
  if len(child[i])>0:
    for c in child[i]:
      check(c, cum_cnt)

check(0, 0)
print(*cum_counter)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())

e = [list(map(int, input().split())) for _ in range(n-1)]
cm = [list(map(int, input().split())) for _ in range(q)]
parent = [-1]*n
child = [[]]*n
counter = [0]*n

for i, v in cm:
  counter[i-1] += v

parent[0] = 0
for a, b in e:
  if parent[a-1]<0:
    parent[a-1] = b-1
    child[b-1] = child[b-1] + [a-1]
  else:
    parent[b-1] = a-1
    child[a-1] = child[a-1] + [b-1]

cum_counter = [0]*n
def check(i, cum_cnt):
  cum_cnt += counter[i]
  cum_counter[i] = cum_cnt
  if len(child[i])>0:
    for c in child[i]:
      check(c, cum_cnt)

check(0, 0)
print(*cum_counter)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())

e = [list(map(int, input().split())) for _ in range(n-1)]
cm = [list(map(int, input().split())) for _ in range(q)]
parent = [-1]*n
child = [[]]*n
counter = [0]*n

for i, v in cm:
  counter[i-1] += v

for a, b in e:
  parent[b-1] = a-1
  child[a-1] = child[a-1] + [b-1]
  
done = [0]*n

cum_counter = [0]*n
def check(i, cum_cnt):
  cum_cnt += counter[i]
  cum_counter[i] = cum_cnt
  if len(child[i])>0:
    for c in child[i]:
      check(c, cum_cnt)

check(0, 0)
print(*cum_counter)
Problem p03281 (python)

Fixed submission:
n = int(input())
 
total = 0
for i in range(1, n+1):
  if i%2==0: continue
  cnt = 0
  for j in range(1, n+1):
    if i%j ==0: cnt+=1
  
  if cnt==8:
    total += 1
 
print(total)

Buggy submission (verdict: Runtime Error):
n = int(input())
 
total = 0
for i in range(1, n+1):
  if i%2==0: continue
  cnt = 0
  for j in range(1, j+1):
    if i%j ==0: cnt+=1
  
  if cnt==8:
    total += 1
 
print(total)

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

total = 0
for i in range(1, n+1):
  if i%2==0: continue
  cnt = 0
  for j in range(1, j+1):
    if i%j ==0: cnt+=1
  
  if cnt==8:
    total += 1

print(total)
Problem p03600 (python)

Fixed submission:
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

ans = 0
cannot = 0
for i in range(n-1):
  for j in range(i+1,n):
    detour = min([A[i][k] + A[k][j] for k in range(n) if k!=i and k!=j]+[10**18])
    if detour<A[i][j]:
      cannot = 1
    elif detour>A[i][j]:
      ans += A[i][j]
if cannot:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]

ans = 0
cannot = 0
for i in range(n-1):
  for j in range(i+1,n):
    detour = min([A[i][k] + A[k][j] for k in range(n) if k!=i and k!=j])
    if detour<A[i][j]:
      cannot = 1
    elif detour>A[i][j]:
      ans += A[i][j]
if cannot:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
n = int(intpu())
A = [list(map(int, input().split())) for _ in range(n)]

ans = 0
cannot = 0
for i in range(n):
  for j in range(n):
    detour = min([A[i][k] + A[k][j] for k in range(n) if k!=i and k!=j])
    if detour<A[i][j]:
      cannot = 1
    elif detour>A[i][j]:
      ans += A[i][j]
if cannot:
  print(-1)
else:
  print(ans)
Problem p03720 (python)

Fixed submission:
n, m = map(int, input().split())

m_a = []
m_b = []
for i in range(m):
  m_a_tmp, m_b_tmp = map(int, input().split())
  m_a.append(m_a_tmp)
  m_b.append(m_b_tmp)

n_n = [0 for i in range(n)]

for a,b in zip(m_a, m_b):
  n_n[a-1] += 1
  n_n[b-1] += 1

for n in n_n:
  print(n)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

m_a = []
m_b = []
for i in range(m):
  m_a_tmp, m_b_tmp = map(int, input().split())
  m_a.append(m_a_tmp)
  m_b.append(m_b_tmp)

n_n = [0 for i in range(n)]

for a,b in zip(m_a, m_b):
  n_n[a] += 1
  n_n[b] += 1

for n in n_n:
  print(n)
Problem p03860 (python)

Fixed submission:
s = input().split()[1]

print('A' + s[0] + 'C')

Buggy submission (verdict: Runtime Error):
s = list(input().split()[1])[0]

print(f'A{s}C')

Buggy submission (verdict: Runtime Error):
s = input().split()[1][0]

print(f'A{s}C')
Problem p03998 (python)

Fixed submission:
A = list(input())
B = list(input())
C = list(input())

A = A[::-1]
B = B[::-1]
C = C[::-1]

next = A.pop()

while 1:    
  if next=='a':
    if len(A)==0:
      print('A')
      break
    next = A.pop()
  elif next=='b':
    if len(B)==0:
      print('B')
      break
    next = B.pop()
  else:
    if len(C)==0:
      print('C')
      break
    next = C.pop()

Buggy submission (verdict: Runtime Error):
A = input()
B = input()
C = input()

next = A.popleft()

while 1:
  if len(A)==0:
    print('A')
    break
  elif len(B)==0:
    print('B')
    break
  elif len(C)==0:
    print('C')
    break
    
  if next=='a':
    next = A.popleft()
  elif next=='b':
    next = B.popleft()
  else:
    next = C.popleft()
Problem p04012 (python)

Fixed submission:
import collections
import sys 

s = input()

c = collections.Counter(s)

for i in c:
  if c[i]%2!=0:
    print('No')
    sys.exit()
    
print('Yes')

Buggy submission (verdict: Runtime Error):
import collections

s = input()

c = collections.Counter(s)

for i in c:
  if c[i]%2!=0:
    print('No')
    sys.exit()
    
print('Yes')
Problem p02730 (python)

Fixed submission:
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True
  
s = input()

s_1 = s[:(int)((len(s)-1)/2)]
s_2 = s[(int)((len(s)+3)/2)-1:len(s)]

if is_kaibun(s) and is_kaibun(s_1) and is_kaibun(s_2):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True
  
s = input()

s_1 = s[:(len(s)-1)/2]
s_2 = s[(len(s)-3)/2:]

if is_kaibun(s) and is_kaibun(s_1) and is_kaibun(s_2):
  print('Yes')
else:
  print('No')
Problem p02743 (python)

Fixed submission:
a, b, c = map(int,input().split())
 
if c-a-b > 0 and 4*a*b < (c-a-b)*(c-a-b):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int,input().split())

if c-a-b > 0 and 4*a*b < (c-a-b)(c-a-b):
  print("Yes")
else:
  print("No")
Problem p02747 (python)

Fixed submission:
S = input()

if len(S) % 2 != 0:
    print("No")
    exit()

if len(S) == 2 and S == "hi":
    print("Yes")
    exit()
elif len(S) == 4 and S == "hihi":
    print("Yes")
    exit()
elif len(S) == 6 and S == "hihihi":
    print("Yes")
    exit()
elif len(S) == 8 and S == "hihihihi":
    print("Yes")
    exit()
elif len(S) == 10 and S == "hihihihihi":
    print("Yes")
    exit()

print("No")

Buggy submission (verdict: Runtime Error):
S = list(input())

for i in range(len(S) - 1):
    if S[i] == "h" and S[i + 1] == "i" and S[i + 2] != "i":
        print("Yes")
        exit()

print("No")
Problem p03029 (python)

Fixed submission:
A, P = map(int, input().split())

print((3*A + P)//2)

Buggy submission (verdict: Runtime Error):
A, P = map(int, input().split())

print((3A + P)//2)
Problem p02641 (python)

Fixed submission:
# -*- coding: utf-8 -*-
x, N = map(int, input().split())

num_list = list(map(int, input().split()))

i = 0            
while True:
    a = x - i
    b = x +i
    if not a in num_list:
        min_num = a
        break
    elif not b in num_list:
        min_num = b
        break
    else:
        i += 1
            
print(min_num)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x, N = map(int, input().split())

if N != 0:
    num_list = list(map(int, input().split()))

min_abs = 100
min_num = 0

for num in range(1, 101):
    if not num_list:
        min_num = x
        break
    if num in num_list:
        continue
    else:
        b = abs(num-x)
        if b < min_abs:
            min_abs = b
            min_num = num
            
print(min_num)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x, N = map(int, input().split())

if N != 0:
    p1, p2, p3, p4, p5 = map(int, input().split())
    num_list = [p1, p2, p3, p4, p5]

min_abs = 100
min_num = 0

for num in range(1, 101):
    if not num_list:
        min_num = x
        break
    if num in num_list:
        continue
    else:
        b = abs(num-x)
        if b < min_abs:
            min_abs = b
            min_num = num
            
print(min_num)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
x, N = map(int, input().split())
p1, p2, p3, p4, p5 = map(int, input().split())
num_list = [p1, p2, p3, p4, p5]

min_abs = 100
min_num = 0

for num in range(1, 101):
    if num in num_list:
        continue
    else:
        b = abs(num-x)
        if b < min_abs:
            min_abs = b
            min_num = num
            
print(min_num)