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

Fixed submission:
s = list(input())

# Note: init
# cnt = 0
# i = 1
#
# while i < len(s):
#     while len(s) != 0 and s[i - 1] != s[i]:
#         s.pop(i)
#         s.pop(i - 1)
#         i -= 1
#         cnt += 2
#     i += 1
#
# print(cnt)


cnt = min(s.count("0"), s.count("1"))
print(cnt*2)

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

cnt = 0
i = 0

while i < len(s):
    while len(s) != 0 and s[i] != s[i + 1]:
        s.pop(i)
        s.pop(i)
        cnt += 2
        i -= 1
    i += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import deque
s = deque(input())

cnt = 0
i = 1

while i < len(s):
    while len(s) != 0 and s[i - 1] != s[i]:
        s.pop(i)
        s.pop(i - 1)
        i -= 1
        cnt += 2
    i += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import deque
s = deque(input())

cnt = 0
i = 1

while i < len(s):
    while len(s) != 0 and s[i - 1] != s[i]:
        s.pop(i)
        s.pop(i - 1)
        i -= 1
        cnt += 2
    i += 1

print(cnt)

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

cnt = 0
i = 1

while i < len(s):
    while len(s) != 0 and s[i - 1] != s[i]:
        s.pop(i)
        s.pop(i - 1)
        i -= 1
        cnt += 2
    i += 1

print(cnt)
Problem p03631 (python)

Fixed submission:
N = input()
print("Yes" if N[0] == N[2]  else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if input() == reversed(input()) else "No")
Problem p02831 (python)

Fixed submission:
import fractions

A, B = map(int, input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(A, B))

Buggy submission (verdict: Runtime Error):
import math
import sys
sys.setrecursionlimit(200000)
A, B = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())

def lcm(x, y):
    if x == 0 or y == 0:
        return 0
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))

Buggy submission (verdict: Runtime Error):
import math

A, B = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(A, B))
Problem p03242 (python)

Fixed submission:
char = input()
chars = list(char)

for cha in chars:
  if cha == "1":
    cha = "9"
  elif cha == "9":
    cha = "1"
  print(cha, end="")

Buggy submission (verdict: Runtime Error):
char = input()
chars = []
chars.append(char.split())

for cha in chars:
  if cha == 1:
    cha = 9
  else cha == 9:
    cha = 1
  print(cha, end="")
Problem p03250 (python)

Fixed submission:
N = input().split()
N.sort()

Nmax = N[2] + N[1]
print(int(Nmax) + int(N[0]))

Buggy submission (verdict: Runtime Error):
N = input().split()
N.sort()
print(N)

N1 = N[2] + N[1]
print(int(Nmax) + int(N[0]))
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2 = map(int, input().split())
ylen = y2 - y1
xlen = x2 - x1

x3 = x2 - ylen
y3 = y2 + xlen
x4 = x3 - xlen
y4 = y3 - ylen

print(str(x3) + " " + str(y3) + " " + str(x4) + " " + str(y4))

Buggy submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int, input().split())
len = abs(x1 - x2)

x4 = x1 - len
x3 = x2 - len
y4 = y1 - len
y3 = y2 - len

print(x3 + " " + y3 + " " + x4 + " " + y4)
Problem p03127 (python)

Fixed submission:
import fractions
a=int(input())
A=list(map(int,input().split()))
x=0
for i in range(a):
    x=fractions.gcd(x,A[i])
print(x)

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

Fixed submission:
a,b=input().split()
c,d=int(a),int(b)
l=[int(input()) for i in range(c)]
L=sorted(l)
x=L[d-1]-L[0]
for i in range(c-d+1):
    if L[d+i-1]-L[i]<x:
        x=L[d+i-1]-L[i]
print(x)

Buggy submission (verdict: Runtime Error):
a,b=input().split()
c,d=int(a),int(b)
l=[int(input()) for i in range(c)]
L=sorted(l)
x=L[d]-L[0]
for i in range(c-d+1):
    if L[d+i]-L[i]<x:
        x=L[d+i]-L[i]
print(x)
Problem p03221 (python)

Fixed submission:
a,b=map(int,input().split())
L=[[] for i in range(a)]
u=0
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)
for i in L:
    i.sort(key=lambda x:x[1])
for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in L:
   q.extend(w) 
q.sort(key=lambda x:x[2])
for r in range(b):
        print('0'*(6-len(str(q[r][0])))+str(q[r][0])+'0'*(6-len(str(q[r][3])))+str(q[r][3]))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
L=[[] for i in range(a)]
u=0
# i番目の県の情報（[i，年，入力順]）をLのi番目に入れる
for i in range(b):
    u+=1
    c=list(map(int,input().split()))
    c.append(u)
    L[int(c[0])-1].append(c)
# Lの要素を年でソート
for i in L:
    i.sort(key=lambda x:x[1])
#　ソートしたので、要素ごとに何番目にできたかを末尾に付け加えておく
for i in L:
    e=0
    for j in i:
        e+=1
        j.append(e)
q=[]
for w in L:
   q.extend(w) #flatten
q.sort(key=lambda x:x[2])　#入力順に並べ替えて、入力した順に出力できるようにする
for r in range(b):
        print(str(q[r][0]).zfill(6)+str(q[r][3]).zfill(6))　#zfill
Problem p03286 (python)

Fixed submission:
n=int(input())
L=[]
if n==0:
    print('0')
else:    
    while n!=0:
        if n>0 and n%2==0:
            n=-n//2
            L.append('0')
        elif n>0 and n%2==1:
            n=(-n+1)//2
            L.append('1')
        elif n<0 and -n%2==0:
            n=-n//2
            L.append('0')
        elif n<0 and -n%2==1:
            n=(-n+1)//2
            L.append('1')
    print(int(''.join(L[::-1])))

Buggy submission (verdict: Runtime Error):
n=int(input())
L=[]
while n!=0:
    if n>0 and n%2==0:
        n=-n//2
        L.append('0')
    elif n>0 and n%2==1:
        n=(-n+1)//2
        L.append('1')
    elif n<0 and -n%2==0:
        n=-n//2
        L.append('0')
    elif n<0 and -n%2==1:
        n=(-n+1)//2
        L.append('1')
print(int(''.join(L[::-1])))
Problem p02970 (python)

Fixed submission:
n,d=list(map(int, input().split()))
 
d1=d*2+1
print(int((n+d1-1)/d1))

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

d1=d*2+1
print((n+d1-1)/d1)
Problem p02987 (python)

Fixed submission:
S = input()

ans="No"
if S[0] == S[1] and S[0] != S[2] and S[0] != S[3] and S[2] == S[3]:
  ans = "Yes"
elif S[1] == S[2] and S[1] != S[0] and S[1] != S[3] and S[0] == S[3]:
  ans = "Yes"
elif S[2] == S[3] and S[2] != S[0] and S[2] != S[1] and S[0] == S[1]:
  ans = "Yes"
elif S[3] == S[0] and S[3] != S[1] and S[3] != S[2] and S[1] == S[2]:
  ans = "Yes"
elif S[1] == S[3] and S[1] != S[0] and S[1] != S[2] and S[2] == S[0]:
  ans = "Yes"

print(ans)

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

ans="No"
if S[0] == S[1] and S[0] != S[2] and S[0] != S[3] and S[2] == S[3]:
  ans = "Yes"
elif S[1] == S[2] and S[1] != S[0] and S[1] != S[3] and S[0] == S[3]:
  ans = "Yes"
elif S[2] == S[3] and S[2] != S[0] and S[2] != S[1] and S[0] == S[1]:
  ans = "Yes"
elif S[3] == S[0] and S[3] != S[1] and S[3] != S[2] and S[1] == S[2]:
  ans = "Yes"
elif S[1] == S[3] and S[1] != S[0] and S[1] != S[2] and S[2] == S[4]:
  ans = "Yes"

print(ans)
Problem p03011 (python)

Fixed submission:
def resolve():
    P,Q,R = map(int,input().split())

    if P+Q <= Q+R and P+Q <= R+P:
        print(P+Q)
    elif Q+R <= R+P and Q+R <= P+Q:
        print(Q+R)
    elif R+P <= P+Q and R+P <= Q+R:
        print(R+P)

resolve()

Buggy submission (verdict: Runtime Error):
N=int(input())
W = list(map(int,input().split()))
tmp = 10000000
for i in range(N):
  if tmp >= abs(sum(W[:i+1]) - sum(W[i:])):
    tmp = abs(sum(W[:i+1]) - sum(W[i:]))
    ans = i-1
print(ans)
Problem p03250 (python)

Fixed submission:
A,B,C = list(map(int,input().split()))
if A >= B and B >= C:
  print(A*10 + B+C)
elif B >= C and C >=A:
  print(B*10 + C+A)
elif C >= A and A >= B:
  print(C*10 + A+B)
elif A >= B and C >= B:
  print(A*10 + B+C)
elif B >= A and A >= C:
  print(B*10 + A+C)
elif C >= A and B >= A:
  print(C*10 + A+B)

Buggy submission (verdict: Runtime Error):
A,B,C = list(map(int,input()))
if A >= B and B >= C:
  print(A*10 + B+C)
elif B >= C and C >=A:
  print(B*10 + C+A)
elif C >= A and A >= B:
  print(C*10 + A+B)
Problem p03272 (python)

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

print(A-B+1)

Buggy submission (verdict: Runtime Error):
A,B = list(map(int,input()))

print(A-B+1)
Problem p03072 (python)

Fixed submission:
n=int(input())
lis=list(map(int,input().split()))
ans=0
 
 
for i in range(1,n):
    if max(lis[:i])<=lis[i]:
        ans+=1
 
print(ans+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = map(int, input().split())
count = 0
view = 0
for i in range(1, n):
    for con in h:
        if con <= h[i]:
            count += 1
    if n == count:
        view += 1
print(view)
Problem p02984 (python)

Fixed submission:
#奇数だから一個仲間外れにできるとの神(ki..sh..ak..i)の啓示

n = int(input())
a = [int(i) for i in input().split()]
w = [] #逆向きの答え
s = sum(a)/2
k = n//2
#w(n-1)を求める
a_odd = [a[2*i] for i in range(0,k)]
w.append(s-sum(a_odd))
for i in reversed(range(n-1)):
  w.append(a[i]-w[-1])
w.reverse()
for i in range(n):
  print(int(2*w[i]), end=" ")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]

import numpy as np
A = np.zeros((n,n))
for i in range(n): #左の行列
  if i<n-1:
    A[i][i]=1
    A[i][i+1]=1
  else:
    A[i][0]=1
    A[i][i]=1
b = np.array(a) #右辺
x = np.linalg.solve(A, b)
x_list = x.tolist()
x_list = [2*i for i in x_list]
for i in range(n):
  print(int(x_list[i]), end=" ")
Problem p03013 (python)

Fixed submission:
n,m = map(int,input().split())
a = [-1]
flag = True
 
if m>0:
  for i in range(m):
    a.append(int(input()))
    if a[i+1]==a[i]+1:
      flag = False
      break
  if not flag:
    print(0)
  else:
    a.append(n+1)
    step = [a[i+1]-a[i]-1 for i in range(m+1)]
    onestep = [1,1]
    if max(step)>=3:
      for i in range(3,max(step)+1):
        onestep.append(onestep[-2]+onestep[-1])
  
    ans = 1
    for i in range(m+1):
      ans *= onestep[step[i]-1]
    print(ans%1000000007)
else:
  onestep=[1,1]
  if n==1:
    print(1)
  else:
    for i in range(2,n+1):
      onestep.append(onestep[-2]+onestep[-1])
    print(onestep[-1]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [-1]
flag = True

if m>0:
  for i in range(m):
    a.append(int(input()))
    if i>0 and a[i+1]==a[i]+1:
      flag = False
    break
  if not flag:
    print(0)
  
  a.append(n+1)
  step = [a[i+1]-a[i]-1 for i in range(m+1)]
  onestep = [1,1]
  if max(step)>=3:
    for i in range(3,max(step)+1):
      onestep.append(onestep[-2]+onestep[-1])
  
  ans = 1
  for i in range(m+1):
    ans *= onestep[step[i]-1]
  if flag:
    print(ans%1000000007)
else:
  onestep=[1,1]
  for i in range(2,n+1):
    onestep.append(onestep[-2]+onestep[-1])
  print(onestep[-1])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
a = [-1]
flag = True
for i in range(m):
  a.append(int(input()))
  if i>0 and a[i+1]==a[i]+1:
    flag = False
    break
if not flag:
  print(0)
a.append(n+1)

step = [a[i+1]-a[i]-1 for i in range(m+1)]

onestep = [1,1]
if max(step)>=3:
  for i in range(3,max(step)+1):
    onestep.append(onestep[-2]+onestep[-1])

ans = 1
for i in range(m+1):
  ans *= onestep[step[i]-1]
if flag:
  print(ans%1000000007)
Problem p02881 (python)

Fixed submission:
n = int(input())

for i in range(1, int(n**.5)+1):
  if n%i == 0:
    p = i

q = n//p

print(p+q-2)

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

for i in range(1, n**.5+1):
  if n%i == 0:
    p = i

q = n//p

print(p+q-2)

Buggy submission (verdict: Runtime Error):
from sympy import divisors as d

n = int(input())
p = max([i for i in d(n) if i <= n**.5])
q = n//p

print(p+q-2)
Problem p02759 (python)

Fixed submission:
import sys

n = int(sys.stdin.readline())
rem = n%2
print(n//2 + rem)

Buggy submission (verdict: Runtime Error):
import sys
n = int(sys.stdin.readline())
rem = n%2
return n/2 + 1
Problem p02990 (python)

Fixed submission:
import math
N, K = input().split()
N = int(N)
K = int(K)
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)
for i in range(1,K+1):
  if N-K+1<i:
    print(0)
  else:
  	ans= (C(K-1,i-1)*C(N-K+1,i))%(10**9+7)
  	print(ans)

Buggy submission (verdict: Runtime Error):
import math
N, K = input().split()
N = int(N)
K = int(K)
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)
for i in range(K):
  ans= (C(K-1,i)*C(N-K+1,i+1))%(10**9+7)
  print(ans)

Buggy submission (verdict: Runtime Error):
import math
N, K = input().split()
N = int(N)
K = int(K)
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)
for i in range(K):
  ans= C(K-1,i)*C(N-K+1,i+1)
  print(ans%(10**9+7))
Problem p03011 (python)

Fixed submission:
a=[int(x) for x in input().split()]
min_h = min([a[0]+a[1],a[1]+a[2],a[2]+a[0]])

print(min_h)

Buggy submission (verdict: Runtime Error):
H,W = map(int, input().split())
a = []
for_at = []
at = []
for i in range(H):
  new_a = str(input())
  for_at.append(list(new_a))
  a.append(new_a)

for i in range(W):
  ai = ''
  for j in range(H):
    ai = ai+for_at[j][i]
  at.append(ai)
tate=0
yoko=0
max_len = '.'*W
max_j = -1
for i in range(W):
  max_len = '.'*(W-i)
  for j in range(H):
    if max_len in a[j]:
      max_j = j
      tate=W-i
      break
  if max_j != -1:
    break


max_len = '.'*W
max_j = -1
for i in range(W):
  max_len = '.'*(W-i)
  for j in range(H):
    if max_len in at[j]:
      max_j = j
      yoko=W-i
      break
  if max_j != -1:
    break
print(tate+yoko-1)
Problem p03327 (python)

Fixed submission:
N = int(input())

if N <= 999:
    print("ABC")
else:
    print("ABD")

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

s = set()
acc = 0
for i in range(1, 1000):
    acc += i
    s.add(acc)

for i in range(1, 4995001):
    if (a + i) in s and (b + i) in s:
        print(i)
Problem p03834 (python)

Fixed submission:
def main():
    print(input().replace(",", " "))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
print(input().replace(",", " ")
Problem p03075 (python)

Fixed submission:
max_distance = 0
previous = int(input())
for i in range(4):
    current = int(input())
    distance = current - previous
    if distance > max_distance:
        max_distance = distance

k = int(input())

if max_distance > k:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
anntena = []
for i in range(5):
  anntena.append(int(input())
k = int(input())
                 
if anntena[4] - anntena[0] <= k:
  print('Yey!')
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
anntena = []
for i in range(5):
    anntena.append(int(input())
k = int(input())
                 
if anntena[4] - anntena[0] <= k:
    print('Yey!')
else:
    print(':(')

Buggy submission (verdict: Runtime Error):
anntena = []
for i in range(5):
	anntena.append(int(input())
k = int(input())
                 
if anntena[4] - anntena[0] <= k:
	print('Yey!')
else:
    print(':(')
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H.sort()

min_diff = 1000000000
for i in range(N-K+1):
    min_diff = min(min_diff, H[i+K-1] - H[i])

print(min_diff)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]
H.sort()

min_diff = 1000000000
for i in range(N-K+1):
    min_diff = min(min_diff, H[i+2] - H[i])

print(min_diff)
Problem p02759 (python)

Fixed submission:
N = int(input())
print((N+1)//2)

Buggy submission (verdict: Runtime Error):
N = int(input())
pritn((N+1)//2)
Problem p02831 (python)

Fixed submission:
from fractions import gcd
A,B=map(int,input().split())
print(A*B//gcd(A,B))

Buggy submission (verdict: Runtime Error):
import math
A,B=map(int,input().split())
print(A*B//math.gcd(A,B))
Problem p03327 (python)

Fixed submission:
N=int(input())
print('ABC' if N<1000 else 'ABD')

Buggy submission (verdict: Runtime Error):
N=int(input())
print('ABC' if N<1000 else 'A
Problem p03329 (python)

Fixed submission:
N=int(input())
dp=[N]*(N+1)
dp[0]=0
for i in range(1,N+1):
    dp[i]=min(dp[i],dp[i-1]+1)
    pow6 = 1
    while i>=pow6:
        dp[i]=min(dp[i],dp[i-pow6]+1)
        pow6*=6
    pow9 = 1
    while i>=pow9:
        dp[i]=min(dp[i],dp[i-pow9]+1)
        pow9*=9
print(dp[N])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

N=int(input())

memo=[-1]*(N+1)
memo[0]=0

def f(n):
    global memo
    if memo[n]!=-1:
        return memo[n]
    cnt=n
    pow6=1
    while pow6<=n:
        cnt=min(cnt,f(n-pow6)+1)
        pow6*=6
    pow9=1
    while pow9<=n:
        cnt=min(cnt,f(n-pow9)+1)
        pow9*=9
    memo[n]=cnt
    return cnt

print(f(N))
Problem p03242 (python)

Fixed submission:
s = input()
s = s.replace('1','2')
s = s.replace('9','1')
s = s.replace('2','9')
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
for i in range(len(s)):
  if s[i]=='1':
    s[i]='9'
  else:
    s[i]='1'

print(s)
Problem p03317 (python)

Fixed submission:
import math, sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]


n, k = LI()
a = LI()

result = math.ceil((n - k) / (k - 1)) + 1

print(result)

Buggy submission (verdict: Runtime Error):
n, k = LI()
a = LI()
l = len(a[:a.index(1)]) + 1
r = len(a[a.index(1):])

if l == 1:
    left = 0
elif l < k:
    left = 1
else:
    left = math.ceil((l - k) / (k - 1)) + 1

if r == 1:
    right = 0
elif r < k:
    right = 1
else:
    right = math.ceil((r - k) / (k - 1)) + 1

print(left + right)

Buggy submission (verdict: Runtime Error):
n, k = LI()
a = LI()
l = len(a[:a.index(1)])
r = len(a[a.index(1):])

if l == 0:
    left = 0
elif l < k:
    left = 1
else:
    left = math.ceil((l - k) / (k - 1)) + 1

if r == 0:
    right = 0
elif r < k:
    right = 1
else:
    right = math.ceil((r - k) / (k - 1)) + 1

print(left + right)

Buggy submission (verdict: Runtime Error):
import math

def LI(): return [int(x) for x in sys.stdin.readline().split()]

n, k = LI()
a = LI()
l = len(a[:a.index(1)])
r = len(a[a.index(1):])

left = math.ceil((l - k) / (k - 1)) + 1
right = math.ceil((r - k) / (k - 1)) + 1

print(left + right)
Problem p03821 (python)

Fixed submission:
n = int(input())
ab = []
for i in range(n):
	a, b = map(int, input().split())
	ab.append((a, b))

ans = 0
for i in range(n)[::-1]:
	a, b = ab[i][0]+ans, ab[i][1]
	if a%b != 0:
		ans += ((a//b + 1)*b - a)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a, b = [], []
for i in range(n):
	a[i], b[i] = map(int, input().split())

ans = 0
for i in range(n)[::-1]:
	a_, b_ = a[i] + ans, b[i]
	if a_%b_ != 0:
		ans += ((a_ // b_ + 1) * b_ - a_)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a, b = [], []
for i in range(n):
	a[i], b[i] = map(int, input().split())

ans = 0
for i in range(n)[::-1]:
	a_, b_ = a[i] + ans, b[i]
	if a_%b_ != 0:
		ans += ((a_ // b_ + 1) * b_ - a_)

print(p)

Buggy submission (verdict: Runtime Error):
n = int(input())
a, b = [0]*n, [0]*n
for i in range(n):
	a[i], b[i] = map(int, input().split())

ans = 0
for i in range(n)[::-1]:
	a_, b_ = a[i] + p, b[i]
	if a_%b_ != 0:
		ans += (a_ // b_ + 1) * b_ - a_

print(p)

Buggy submission (verdict: Runtime Error):
n = int(input())
a, b = [0]*n, [0]*n
for i in range(n):
	a[i], b[i] = map(int, input().split())

ans = 0
for i in range(n)[::-1]:
	a_, b_ = a[i] + p, b[i]
	if a%b != 0:
		ans += (a_ // b_ + 1) * b_ - a_

print(p)
Problem p02759 (python)

Fixed submission:
print((int(input())+1)//2)

Buggy submission (verdict: Runtime Error):
n = input()
print((n+1)/2)
Problem p02831 (python)

Fixed submission:
# coding: utf-8
a,b = map(int, input().split())

def lcm(x, y):
    return (x * y) // gcd(x, y)

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

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

a,b = sorted(map(int, input().split()))

gcd = math.gcd(a,b)

print(a//gcd * b)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import math

a,b = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02951 (python)

Fixed submission:
def solve():
    a,b,c = map(int, input().split())
    return max(c-(a-b),0)

if __name__ == '__main__':
    print(solve())

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

if __name__ == '__main__':
    print(solve())
Problem p03013 (python)

Fixed submission:
def solve():
    N,M = map(int, input().split())
    if N == 1 and M == 0:
        return 1
    elif N == 1 and M == 1:
        return 0
    elif N == 2 and M == 0:
        return 2
    elif N == 2 and M == 1:
        return 1
    elif N == 2 and M == 2:
        return 0
    
    l = [-1]*(N+1)
    for m in range(M):
        a = int(input())
        l[a] = 0
    if l[1] == 0 and l[2] == 0:
        return 0
    elif l[1] == 0 and l[2] != 0:
        l[2] = 1
    elif l[1] != 0 and l[2] == 0:
        l[1] = 1
    else:
        l[1] = 1
        l[2] = 2
    
    l.pop(0)
    for i in range(2,N):
        if l[i] == 0:
            continue
        else:
            l[i] = l[i-1] + l[i-2]
    
    return l[-1]%1000000007


if __name__ == '__main__':
    print(solve())

Buggy submission (verdict: Runtime Error):
def solve():
    N,M = map(int, input().split())
    
    l = [-1]*(N+1)
    for m in range(M):
        a = int(input())
        l[a] = 0
    if l[1] == 0 and l[2] == 0:
        return 0
    elif l[1] == 0 and l[2] != 0:
        l[2] = 1
    elif l[1] != 0 and l[2] == 0:
        l[1] = 1
    else:
        l[1] = 1
        l[2] = 2
    
    if N == 1:
        return 1
    if N == 2:
        return 2
    
    l.pop(0)
    for i in range(2,N):
        if l[i] == 0:
            continue
        else:
            l[i] = l[i-1] + l[i-2]
    
    return l[-1]%1000000007


if __name__ == '__main__':
    print(solve())

Buggy submission (verdict: Runtime Error):
import sys

def solve():
    N,M = map(int, input().split())
    
    l = [-1]*(N+1)
    for m in range(M):
        a = int(input())
        l[a] = 0
    if l[1] == 0 and l[2] == 0:
        return 0
    elif l[1] == 0 and l[2] != 0:
        l[2] = 1
    elif l[1] != 0 and l[2] == 0:
        l[1] = 1
    else:
        l[1] = 1
        l[2] = 2
    
    if N == 1:
        return 1
    if N == 2:
        return 2
    
    l.pop(0)
    for i in range(2,N):
        if l[i] == 0:
            continue
        else:
            l[i] = l[i-1] + l[i-2]
    
    return l[-1]%1000000007


if __name__ == '__main__':
    print(solve())
Problem p03107 (python)

Fixed submission:
S = input()
a = []
for s in S:
    if not a:
        a.append(s)
        continue
    if s != a[-1]:
        a.pop()
    else:
        a.append(s)
print(len(S)-len(a))

Buggy submission (verdict: Runtime Error):
s = list(input())
count = 0
while True:
    for i,n in enumerate(s):
        if s[i] != s[i+1]:
            del s[i:i+2]
            count += 2
            break
    else:
        break
print(count)

Buggy submission (verdict: Runtime Error):
s = input()
count = 0
while True:
    for i,n in enumerate(s):
        if s[i] != s[i+1]:
            s = s[:i] + s[i+2:]
            count += 2
            break
    else:
        break
print(count)
Problem p03317 (python)

Fixed submission:
def solve():
    n,k = map(int, input().split())
    A = map(int, input().split())
    if (n-1)%(k-1) != 0:
        return (n-1)//(k-1) + 1
    else:
        return (n-1)//(k-1)

if __name__ == '__main__':
    print(solve())

Buggy submission (verdict: Runtime Error):
3 3
1 2 3
Problem p02759 (python)

Fixed submission:
x = int(input())
if(x%2 == 0):
  print(x//2)
else:
  print(x//2 +1)

Buggy submission (verdict: Runtime Error):
x = input()
if(x%2 == 0):
  print(x/2)
else:
  print(x/2 +1)