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

Fixed submission:
k = int(input())
a,b = map(int, input().split())

aa = a % k
bb = b % k

if(b - a >= k):
    print('OK')
elif(aa > bb):
    print('OK')
elif(aa == 0):
    print('OK')
else:
    print('NG')

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

aa = a % k
bb = b % k

if(b - a > k):
    print('OK')
if(aa > bb):
    print('OK')
if(aa == 0):
    print('OK')
else:
    print('NG')

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

aa = a % k
bb = b % k

if(b - a > k):
    print('OK')
if(aa > bb):
    print('OK')
if(aa == 0):
    print('OK')
else:
    print('NG')
Problem p02729 (python)

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

print(int(n*(n-1)/2 + m*(m-1)/2))

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

print(int(n(n+1)/2 + m(m+1)/2))
Problem p02757 (python)

Fixed submission:
n,p = map(int, input().split())
s = list(map(int, input().strip()))

count = 0

if(p == 2 or p == 5): #10と互いに素ではない場合
    co = 0
    for i in range(n): #1の位から順に数を追加していく
        ne = int(s[n-i-1]) % p
        if(ne == 0):
            co += 1
        count += co
    print(count)
else:
    sta = [0]*p
    sta[0] += 1
    d = 1
    co = 0
    for i in range(n):
        ne = int(s[n-i-1]) * d % p
        co += ne
        co %= p
        sta[co] += 1
        d *= 10
        d %= p
    for i in range(p):
        count += sta[i] * (sta[i]-1) // 2
    print(count)

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

n,p = map(int, input().split())
s = list(map(int, input().strip()))

dp = np.zeros(p,dtype = int)

count = 0
d = 1
for i in range(n):
    ne_ar = np.zeros(p,dtype = int)
    if(p == 2 or p == 5):
        ne = int(s[n-i-1]) % p
        if(ne == 0):
            dp[0] += 1
        count += dp[0]
    else:
        ne = (int(s[n-i-1]) * d) % p
        ne_ar[ne:] += dp[:(p-ne)]
        ne_ar[:ne] += dp[(p-ne):]
        ne_ar[ne] += 1
        dp = ne_ar
        d *= 10
        d %= p
        count += ne_ar[0]

print(count)
Problem p02598 (python)

Fixed submission:
n,k = map(int,input().split())
L = list(map(int,input().split()))
ok = 0
ng = 10**9
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    cur = 0
    for i in range(n):
        cur += L[i]//mid
    if cur > k:
        ok = mid
    elif cur <= k:
        ng = mid
K = [mid-1, mid, mid+1]
P = []
for i in range(3):
    res = 0
    if K[i] > 0:
        for j in range(n):
            res += (L[j]-1)//K[i]
        if res <= k:
            P.append(K[i])
print(min(P))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
L = list(map(int,input().split()))
ok = 0
ng = 10**9
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    cur = 0
    for i in range(n):
        cur += L[i]//mid
    if cur > k:
        ok = mid
    elif cur <= k:
        ng = mid
K = [mid-1, mid, mid+1]
P = []
for i in range(3):
    res = 0
    for j in range(n):
        res += (L[j]-1)//K[i]
    if res <= k:
        P.append(K[i])
print(min(P))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
L = list(map(int,input().split()))
ok = 0
ng = 10**9
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    cur = 0
    for i in range(n):
        cur += L[i]//mid
    if cur > k:
        ok = mid
    elif cur <= k:
        ng = mid
    print(mid,cur)
K = [mid-1, mid, mid+1]
P = []
for i in range(3):
    res = 0
    for j in range(n):
        res += (L[j]-1)//K[i]
    if res <= k:
        P.append(K[i])
print(min(P))
Problem p02781 (python)

Fixed submission:
n = input()
k = int(input())
dp = [[[0,0,0,0],[0,0,0,0]] for i in range(len(n))] #dp[p][0][count]は、p桁目まではnより小さいことが確定している
#countは「0以外の桁」の登場回数、あくまで各桁に登場したt「以下」の数字かどうかを判定する。dp[p][1]は「〜と同じ」
dp[0][0][0] = 0
dp[0][0][1] = 1
dp[0][1][0] = 1
dp[0][1][1] = int(n[0])-1
for i in range(1,len(str(n))):
    if n[i] != '0':
        dp[i][0][0] = 0 #遷移前に同じで、遷移後に0でないものが0個かつ遷移前と同じ遷移はありえない
        dp[i][0][1] = dp[i-1][0][0] #ぴったりの数字(0でない)が入ればOK 下二つも同じ
        dp[i][0][2] = dp[i-1][0][1]
        dp[i][0][3] = dp[i-1][0][2]
        dp[i][1][0] = dp[i-1][1][0] #0を入れればOK
        dp[i][1][1] = dp[i-1][0][0]*(max(0,int(n[i])-1))+dp[i-1][0][1]+dp[i-1][1][1]+dp[i-1][1][0]*9
        dp[i][1][2] = dp[i-1][0][1]*(max(0,int(n[i])-1))+dp[i-1][0][2]+dp[i-1][1][2]+dp[i-1][1][1]*9
        dp[i][1][3] = dp[i-1][0][2]*(max(0,int(n[i])-1))+dp[i-1][0][3]+dp[i-1][1][3]+dp[i-1][1][2]*9
    else:
        dp[i][0][0] = dp[i-1][0][0]
        dp[i][0][1] = dp[i-1][0][1]
        dp[i][0][2] = dp[i-1][0][2]
        dp[i][0][3] = dp[i-1][0][3]
        dp[i][1][0] = dp[i-1][1][0] #0を入れればOK
        dp[i][1][1] = dp[i-1][1][0]*9+dp[i-1][1][1]
        dp[i][1][2] = dp[i-1][1][1]*9+dp[i-1][1][2]
        dp[i][1][3] = dp[i-1][1][2]*9+dp[i-1][1][3]
print(dp[len(n)-1][0][k]+dp[len(n)-1][1][k])

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
if k == 1:
  flag = True
  cnt = 0
  while flag:
    for i in range(101):
      for j in range(1,10):
        if j*(10**i) <= n:
          cnt += 1
        else:
          flag = False
          break
elif k == 2:
  flag = True
  cnt = 0
  while flag:
    for i in range(1,101):
      for j in range(1,10):
        for l in range(i):
          for m in range(1,10):
            if j*(10**i)+m*(10**l) <= n:
              cnt += 1
            else:
              flag = False
              break
else:
  print(0)
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = int(input())
if k == 1:
  flag = True
  cnt = 0
  while flag:
    for i in range(101):
      for j in range(1,10):
        if j*(10**i) <= n:
          cnt += 1
        else:
          flag = False
          break
elif k == 2:
  flag = True
  cnt = 0
  while flag:
    for i in range(1,101):
      for j in range(1,10):
        for l in range(i):
          for m in range(1,10):
            if j*(10**i)+m*(10**l) <= n:
              cnt += 1
            else:
              flag = False
              break
else:
  
print(cnt)
Problem p02793 (python)

Fixed submission:
n = int(input())
L = list(map(int,input().split()))
m = 10**9+7
ans = 0
def gcd(x,y):
  while y != 0:
    cur = x
    x = y
    y = cur%y
  return x
if n != 1:
  lcm = L[0]*L[1]//gcd(L[0],L[1])
  for i in range(2,n):
    p = gcd(L[i],lcm)
    lcm = L[i]*lcm//p
  for i in range(n):
    k = (lcm%m)*pow(L[i],10**9+5,m)
    ans = (ans+k)%m
else:
  ans = 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
L = list(map(int,input().split()))
m = 10**9+7
def gcd(x,y):
  while y != 0:
    cur = x
    x = y
    y = cur%y
  return x
lcm = L[0]*L[1]//gcd(L[0],L[1])
for i in range(2,n):
  p = gcd(L[i],lcm)
  lcm = L[i]*lcm//p
ans = 0
for i in range(n):
  ans = (ans+((lcm//L[i])%m))%m
print(ans)
Problem p02820 (python)

Fixed submission:
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
L = [[] for i in range(k)]
for i in range(n):
    L[i%k].append(t[i])
ans = 0
for i in range(k):
    if L[i][0] == 's':
        ans += r
    elif L[i][0] == 'p':
        ans += s
    else:
        ans += p
    lose = False
    for j in range(1,len(L[i])):
        if L[i][j] != L[i][j-1]:
            lose = False
            if L[i][j] == 's':
                ans += r
            elif L[i][j] == 'p':
                ans += s
            else:
                ans += p
        elif L[i][j] == L[i][j-1]:
            if lose == True:
                if L[i][j] == 's':
                    ans += r
                elif L[i][j] == 'p':
                    ans += s
                else:
                    ans += p
                lose = False
            else:
                lose = True
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()
count_rsp = [0,0,0]
for i in range(k):
  hand = ['N']*(n//k+1)
  if t[i] == 'r':
      hand[0] = 'p'
      count_rsp[2] += 1
  elif t[i] == 's':
      hand[0] = 'r'
      count_rsp[0] += 1
  else:
      hand[0] = 's'
      count_rsp[1] += 1
  for j in range(i+k,n,k):
    if t[j] == 'r':
      if hand[j//k-1] != 'p':
        hand[j//k] = 'p'
        count_rsp[2] += 1
      else:
        if j+k <= n and t[j+k] == 'p':
          hand[j//k] = 'r'
        else:
          hand[j//k] = 's'
    elif t[j] == 's':
      if hand[j//k-1] != 'r':
        hand[j//k] = 'r'
        count_rsp[0] += 1
      else:
        if j+k <= n and t[j+k] == 's':
          hand[j//k] = 'p'
        else:
          hand[j//k] = 's'
    else:
      if hand[j//k-1] != 's':
        hand[j//k] = 's'
        count_rsp[1] += 1
      else:
        if j+k <= n and t[j+k] == 's':
          hand[j//k] = 'p'
        else:
          hand[j//k] = 'r'
print(count_rsp[0]*r+count_rsp[1]*s+count_rsp[2]*p)
Problem p02862 (python)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
x,y = map(int,input().split())
if (x+y)%3 != 0:
  print(0)
else:
  n = (x+y)//3
  r = min(abs(2*n-x),abs(n-x))
  if 2*n < x or x < n:
    print(0)
  else:
    a = cmb(n,r,mod)
    print(a)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
x,y = map(int,input().split())
if (x+y)%3 != 0:
  print(0)
else:
  n = (x+y)//3
  r = min(abs(2*n-x),abs(n-x))
a = cmb(n,r,mod)
print(a)
Problem p03053 (python)

Fixed submission:
import collections
h,w = map(int,input().split())
q = collections.deque()
A = []
for i in range(h):
    s = input()
    L = []
    for j in range(w):
        if s[j] == '.':
            L.append(s[j])
        else:
            L.append(0)
            q.append([i,j])
    A.append(L)
dy_dx = [[1,0],[0,1],[-1,0],[0,-1]]
while len(q) > 0:
    cur = q.popleft()
    for i in range(4):
        y = cur[0]+dy_dx[i][0]
        x = cur[1]+dy_dx[i][1]
        if 0 <= y < h and 0 <= x < w:
            if A[y][x] == '.':
                A[y][x] = A[cur[0]][cur[1]]+1
                q.append([y,x])
ans = 0
for i in range(h):
    for j in range(w):
        if ans < A[i][j]:
            ans = A[i][j]
print(ans)

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
L = []
for i in range(h):
  L.append(list(input()))
B = []
W = []
for i in range(h):
  for j in range(w):
    if L[i][j] == '.':
      W.append([i,j])
    else:
      B.append([i,j])
anslist = []
for i in range(len(W)):
  ans = float('inf')
  for j in range(len(B)):
    if ans >= abs(W[i][0]-B[j][0])+abs(W[i][1]-B[j][1]):
      ans = abs(W[i][0]-B[j][0])+abs(W[i][1]-B[j][1])
  anslist.append(ans)
print(max(anslist))

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
L = []
for i in range(h):
  L.append(list(input()))
B = []
W = []
for i in range(h):
  for j in range(w):
    if L[i][j] == '.':
      W.append([i,j])
    else:
      B.append([i,j])
anslist = []
for i in range(len(W)):
  ans = float('inf')
  for j in range(len(B)):
    if ans >= abs(W[i][0]-B[j][0])+abs(W[i][1]-B[j][1]):
      ans = abs(W[i][0]-B[j][0])+abs(W[i][1]-B[j][1])
  anslist.append(ans)
print(max(anslist))
Problem p03222 (python)

Fixed submission:
H,W,K = map(int,input().split())
dp = []
for i in range(H+1):
  L = [0]*W
  dp.append(L)
fb = [1,1]
for i in range(W-2):
  fb.append(fb[i]+fb[i+1])
dp[0][0] = 1
if W != 1:
  for i in range(1,H+1):
    for j in range(W):
      if 1 <= j <= W-2:
        dp[i][j] = dp[i-1][j-1]*fb[j-1]*fb[W-j-1]+dp[i-1][j]*fb[j]*fb[W-j-1]+dp[i-1][j+1]*fb[j]*fb[W-j-2]
      elif j == 0:
        dp[i][j] = dp[i-1][j]*fb[W-1]+dp[i-1][j+1]*fb[W-2]
      else:
        dp[i][j] = dp[i-1][j]*fb[W-1]+dp[i-1][j-1]*fb[W-2]
else:
  dp[H][0] = 1
print(dp[H][K-1]%(10**9+7))

Buggy submission (verdict: Runtime Error):
H,W,K = map(int,input().split())
dp = []
for i in range(H+1):
  L = [0]*W
  dp.append(L)
fb = [1,1]
for i in range(W-2):
  fb.append(fb[i]+fb[i+1])
dp[0][0] = 1
for i in range(1,H+1):
  for j in range(W):
    if 1 <= j <= W-2:
      dp[i][j] = dp[i-1][j-1]*fb[j-1]*fb[W-j-1]+dp[i-1][j]*fb[j]*fb[W-j-1]+dp[i-1][j+1]*fb[j]*fb[W-j-2]
    elif j == 0:
      dp[i][j] = dp[i-1][j]*fb[W-1]+dp[i-1][j+1]*fb[W-2]
    else:
      dp[i][j] = dp[i-1][j]*fb[W-1]+dp[i-1][j-1]*fb[W-2]
print(dp[H][K-1]%(10**9+7))
Problem p03286 (python)

Fixed submission:
N = int(input())
if N == 0:
  print(0)
else:
  ans = ''
  flag = False
  while flag == False:
    if N%2 == 0:
      ans = '0'+ans
      N = N/(-2)
    else:
      ans = '1'+ans
      N -= 1
      if N == 0:
        flag = True
      else:
        N = N/(-2)
  print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
if N == 0:
  print(0)
else:
  ans = ''
  flag = False
  while flag == False:
    if N%2 == 0:
      ans = '0'+ans
      N = N/(-2)
    else:
      ans = '1'+ans
      N -= 1
      if N == 0:
        flag = True
      else:
        N = N/(-2)
print(ans)
Problem p03803 (python)

Fixed submission:
A,B = map(int,input().split())
if (A == 1):
  if (B == 1):
    print('Draw')
  else:
    print('Alice')
else:
  if (B == 1):
    print('Bob')
  elif (A == B):
    print('Draw')
  elif (A > B):
    print('Alice')
  else:
    print('Bob')

Buggy submission (verdict: Runtime Error):
n,ma,mb = map(int,input().split())
L = []
for i in range(n):
    a,b,c = map(int,input().split())
    L.append([a,b,c])
dp = [[10**5]*401 for i in range(401)]
make = [[0,0],[L[0][0],L[0][1]]]
dp[L[0][0]][L[0][1]] = L[0][2]
dp[0][0] = 0
for i in range(1,n):
    a = L[i][0]
    b = L[i][1]
    c = L[i][2]
    for j in range(len(make)):
        t = make[j][0]
        u = make[j][1]
        dp[t+a][u+b] = min(dp[t][u]+c,dp[t+a][u+b])
        make.append([t+a, u+b])
    make = list(set(make))
if ma <= mb:
    cnt = 1
    ans = 10**5
    while mb*cnt <= 400:
        ans = min(ans, dp[ma*cnt][mb*cnt])
        cnt += 1
    if ans == 10**5:
        print(-1)
    else:
        print(ans)
else:
    cnt = 1
    ans = 10**5
    while ma*cnt <= 400:
        ans = min(ans, dp[ma*cnt][mb*cnt])
        cnt += 1
    if ans == 10**5:
        print(-1)
    else:
        print(ans)
Problem p03804 (python)

Fixed submission:
N,M = map(int,input().split())
A = []
for i in range(N):
  A.append(list(input()))
B = []
for j in range(M):
  B.append(list(input()))
for k in range(N-M+1):
  for l in range(N-M+1):
    cnt = 0
    if B[0][0:M] == A[k][l:l+M]:
      p = k
      q = l
      for m in range(M):
        if B[m][0:M] == A[p+m][q:q+M]:
          cnt += 1
        if cnt == M:
          print('Yes')
          exit()
print('No')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = []
for i in range(N):
  A.append(list(input()))
B = []
for j in range(M):
  B.append(list(input()))
for k in range(N-M+1):
  for l in range(N-M+1):
    cnt = 0
    if B[0][0:M] == A[k][l:l+M]:
      p = k
      q = l
      for m in range(N-M+1):
        if B[m][0:M] == A[p+m][q:q+M]:
          cnt += 1
        if cnt == M:
          print('Yes')
          exit()
print('No')
Problem p03806 (python)

Fixed submission:
n,ma,mb = map(int,input().split())
L = []
sa = 0
sb = 0
for i in range(n):
    a,b,c = map(int,input().split())
    sa += a
    sb += b
    L.append([a,b,c])
dp = [[[10000 for i in range(sb+1)] for i in range(sa+1)] for i in range(n+1)]
dp[0][0][0] = 0
for i in range(n):
    a = L[i][0]
    b = L[i][1]
    c = L[i][2]
    for j in range(sa+1):
        for k in range(sb+1):
            if j-a >= 0 and k-b >= 0:
                dp[i+1][j][k] = min(dp[i][j-a][k-b]+c,dp[i+1][j][k],dp[i][j][k])
            else:
                dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k])
k = max(ma,mb)
t = min(sa,sb)
cur = 1
ans = 10000
while k*cur <= t:
    ans = min(ans,dp[n][ma*cur][mb*cur])
    cur += 1
if ans == 10000:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,ma,mb = map(int,input().split())
L = []
sa = 0
sb = 0
for i in range(n):
    a,b,c = map(int,input().split())
    sa += a
    sb += b
    L.append([a,b,c])
dp = [[[10000 for i in range(sa+1)] for i in range(sb+1)] for i in range(n+1)]
dp[0][0][0] = 0
for i in range(n):
    a = L[i][0]
    b = L[i][1]
    c = L[i][2]
    for j in range(sa+1):
        for k in range(sb+1):
            if j-a >= 0 and k-b >= 0:
                dp[i+1][j][k] = min(dp[i][j-a][k-b]+c,dp[i+1][j][k],dp[i][j][k])
            else:
                dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k])
k = max(ma,mb)
t = max(sa,sb)
cur = 1
ans = 10000
while k*cur <= t:
    ans = min(ans,dp[n][ma*cur][mb*cur])
    cur += 1
if ans == 10000:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
n,ma,mb = map(int,input().split())
L = []
for i in range(n):
    a,b,c = map(int,input().split())
    L.append([a,b,c])
dp = [[10**5]*401 for i in range(401)]
make = [[0,0],[L[0][0],L[0][1]]]
dp[L[0][0]][L[0][1]] = L[0][2]
dp[0][0] = 0
for i in range(1,n):
    a = L[i][0]
    b = L[i][1]
    c = L[i][2]
    for j in range(len(make)):
        t = make[j][0]
        u = make[j][1]
        dp[t+a][u+b] = min(dp[t][u]+c,dp[t+a][u+b])
        make.append([t+a, u+b])
    make = list(set(make))
if ma <= mb:
    cnt = 1
    ans = 10**5
    while mb*cnt <= 400:
        ans = min(ans, dp[ma*cnt][mb*cnt])
        cnt += 1
    if ans == 10**5:
        print(-1)
    else:
        print(ans)
else:
    cnt = 1
    ans = 10**5
    while ma*cnt <= 400:
        ans = min(ans, dp[ma*cnt][mb*cnt])
        cnt += 1
    if ans == 10**5:
        print(-1)
    else:
        print(ans)
Problem p02623 (python)

Fixed submission:
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
A = [0] * (n+1)
B = [0] * (m+1)
for i in range(1, n+1):
    A[i] = A[i-1] + a[i]
for i in range(1, m+1):
    B[i] = B[i-1] + b[i]
ans = 0
j = m
for i in range(n+1):
    while j >= 0:
        if A[i] + B[j] <= k:
            ans = max(ans, i + j)
            break
        else:
            j -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [0] * k
aidx = 0
bidx = 0
ans = 0
time = 0
while True:
    if aidx < n and bidx < m:
        if a[aidx] < b[bidx]:
            time += a[aidx]
            if time > k:
                break
            aidx += 1
            ans += 1
        else:
            time += b[bidx]
            if time > k:
                break
            bidx += 1
            ans += 1
    elif aidx < n:
        time += a[aidx]
        if time > k:
            break
        ans += 1
        aidx += 1
    elif bidx < m:
        time += b[bidx]
        if time > k:
            break
        ans += 1
        bidx += 1
    else:
        break
print(ans)
Problem p02819 (python)

Fixed submission:
import math
x = int(input())
n = x
while True:
  isPrime = True
  for i in range(2, int(math.sqrt(n))):
    if n % i == 0:
      isPrime = False
      break
  if isPrime:
    print(n)
    break
  n += 1

Buggy submission (verdict: Runtime Error):
import math
x = int(input())
if x % 2 == 0:
  n += 1
else:
  n += 2
while True:
  isPrime = True
  for i in range(2, int(math.sqrt(n))):
    if n % i == 0:
      isPrime = False
      break
  if isPrime:
    print(n)
    break
  n += 2

Buggy submission (verdict: Runtime Error):
x = int(input())
n = x
while True:
  isPrime = True
  for i in range(2, int(sqrt(n))):
    if n % i == 0:
      isPrime = False
      break
  if isPrime:
    print(n)
    break
  if n % 2 == 0:
    n += 1
  else:
    n += 2
Problem p02759 (python)

Fixed submission:
def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

import math
N= n_in()
print(math.ceil(N/2))

Buggy submission (verdict: Runtime Error):
import math
N= n_in()
print(math.ceil(N/2))
Problem p02873 (python)

Fixed submission:
def s_in():
    return input()

S = s_in()

if len(S) == 1:
    print(1)
    exit()


lis = []
cnt = 1
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        lis.append((S[i], cnt))
        cnt = 1
else:
    lis.append((S[len(S)-1], cnt))


res = 0
idx = 0


if lis[0][0] == ">":
    res += sum(range(lis[0][1]+1))
    idx += 1

while idx < len(lis):
    if idx+1 == len(lis):
        res += sum(range(lis[idx][1]+1))
        break

    x = lis[idx][1]
    y = lis[idx+1][1]

    res += sum(range(max(x,y)+1)) + sum(range(min(x,y)))

    idx += 2


print(res)

Buggy submission (verdict: Runtime Error):
def s_in():
    return input()

S = s_in()

if len(S) == 1:
    print(1)
    exit()


lis = []
cnt = 1
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        lis.append((S[i], cnt))
        cnt = 1
else:
    lis.append((S[len(S)-1], cnt))


res = 0
idx = 0


if lis[0][0] == ">":
    res += sum(range(lis[0][1]+1))
    idx += 1

while True:
    if idx+1 == len(lis):
        res += sum(range(lis[idx][1]+1))
        break

    x = lis[idx][1]
    y = lis[idx+1][1]

    res += sum(range(max(x,y)+1)) + sum(range(min(x,y)))

    idx += 2

    if idx == len(lis):
        break


print(res)

Buggy submission (verdict: Runtime Error):
def s_in():
    return input()

S = s_in()

if len(S) == 1:
    print(1)
    exit()


lis = []
cnt = 1
for i in range(len(S)-1):
    if S[i] == S[i+1]:
        cnt += 1
    else:
        lis.append((S[i], cnt))
        cnt = 1
else:
    lis.append((S[len(S)-1], cnt))


res = 0
idx = 0


if lis[0][0] == ">":
    res += sum(range(lis[0][1]+1))
    idx += 1

while True:
    if idx+1 == len(lis):
        res += sum(range(lis[idx][1]+1))
        break

    x = lis[idx][1]
    y = lis[idx+1][1]

    if x == y:
        res += sum(x+1)*2
    else:
        res += sum(range(max(x,y)+1)) + sum(range(min(x,y)))

    idx += 2

    if idx == len(lis):
        break


print(res)
Problem p03127 (python)

Fixed submission:
def gcd(a,b):
    return gcd(b, a % b) if b else abs(a)
N = int(input())
a = list(map(int,input().split()))
import math
ans = a[0]
for i in range(1,N):
    ans = gcd(ans,a[i])
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))
import math
ans = a[0]
for i in range(1,N):
    ans = math.gcd(ans,a[i])
print(ans)
Problem p02629 (python)

Fixed submission:
N = int(input())

ans = ''
while N > 0:
    N -= 1#この行の意味が分からずに失敗した。今も分からない
    ans += chr(ord('a') + N % 26)
    N //= 26
print(ans[::-1])

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
A = [chr(ord('a') + i) for i in range(26)]

if N <= 26:
    print(A[N-1])
    exit()

B = math.log(N, 26)
B = math.ceil(B)
#print(B)

C = [26]
for i in range(2, B):
        D = 26**i
        C.append(D)

#print(C[::-1])

ans = []
for i in C[::-1]:
    D = int(N // i)
    if D == 0:
        ans.append(A[N-1])
        print(''.join(ans))
    else:
#        print(D)
        ans.append(A[D-1])
        N %= i
#        print(N)