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

Fixed submission:
from sys import stdin
input = stdin.buffer.readline

n = int(input())
*a, = map(int, input().split())
b = 1000
for i in range(n - 1):
	if a[i] < a[i + 1]:
		b = b // a[i] * a[i + 1] + b % a[i]
print(b)

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

n = int(input())
*a, = map(int, input().split())
dp = [[-1] * 1000001 for i in range(n + 1)]
dp[0][0] = 1000
for i in range(n):
	for j in range(1000001):
		if dp[i][j] >= 0:
			dp[i + 1][j + dp[i][j] // a[i]] = max(dp[i + 1][j + dp[i][j] // a[i]], dp[i][j] % a[i])
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + a[i] * j)
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][0])

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

n = int(input())
*a, = map(int, input().split())
dp = [[-1] * 100001 for i in range(n + 1)]
dp[0][0] = 1000
for i in range(n):
	for j in range(100001):
		if dp[i][j] >= 0:
			dp[i + 1][j + dp[i][j] // a[i]] = max(dp[i + 1][j + dp[i][j] // a[i]], dp[i][j] % a[i])
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + a[i] * j)
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][0])

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

n = int(input())
*a, = map(int, input().split())
dp = [[-1] * 1001 for i in range(n + 1)]
dp[0][0] = 1000
for i in range(n):
	for j in range(1001):
		if dp[i][j] >= 0:
			if dp[i][j]:
				dp[i + 1][j + dp[i][j] // a[i]] = max(dp[i + 1][j + dp[i][j] // a[i]], dp[i][j] % a[i])
			dp[i + 1][0] = max(dp[i + 1][0], dp[i][j] + a[i] * j)
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][0])
Problem p02641 (python)

Fixed submission:
x, n = [int(x) for x in input().split()]
ps = [int(x) for x in input().split()]

best = 100000000
ret = x

if n:
	mn = min(ps)
	mx = max(ps)
	s = set(ps)
	for i in range(mn, mx+1):
		if i not in s:
			d = abs(x-i)
			if d < best:
				best = d
				ret = i
	if ret == x:
		up = abs(mx + 1 - x)
		down = abs(mn - 1 - x)
		ret = mn-1 if down <= up else mx+1
	if x not in s:
		ret = x

print(ret)

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

best = 100000000
ret = x

if n:
	mn = min(ps)
	mx = max(ps)
	s = set(ps)
	for i in range(mn, mx+1):
		if i not in s:
			d = abs(x-i)
			if d < best:
				best = d
				ret = i
	if ret == x:
		up = abs(mx + 1 - x)
		down = abs(mn - 1 - x)
		ret = mn-1 if down <= up else mx+1
		
if x not in s:
	ret = x

print(ret)
Problem p02778 (python)

Fixed submission:
s = input()
  
ans = "x" * len(s)

print(ans)

Buggy submission (verdict: Runtime Error):
s = readline()
  
ans = "x" * len(s)

print(ans)
Problem p02582 (python)

Fixed submission:
S = list(input())

cnt = 0

for i in range(len(S)):
  if S[i] == 'R':
    if cnt == 0:
      cnt += 1
    elif S[i - 1] == 'R':
      cnt += 1

print(cnt)

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

cnt = 0

for i in range(len(S)):
  if S[i] == 'R':
	  if cnt == 0:
    	cnt += 1
  	  elif S[i - 1] == 'R':
      	cnt += 1

print(cnt)
Problem p03999 (python)

Fixed submission:
S = input()
n = len(S)

def dfs(i, f):
  if i == n - 1:
    return sum(list(map(int, f.split('+'))))

  return dfs(i+1, f+S[i+1]) + dfs(i+1, f+'+'+S[i+1])

print(dfs(0, S[0]))

Buggy submission (verdict: Runtime Error):
fS = input()
n = len(S)

def dfs(i, f):
  if i == n - 1:
    return sum(list(map(int, f.split('+'))))
  
  return dfs(i+1, f+S[i+1]) + dfs(i+1, f+'+'+S[i+1]) 

print(dfs(0, S[0]))
Problem p02607 (python)

Fixed submission:
n = int(input())
arr = list(map(int,input().split()))
ans = 0
for i in range(0,len(arr)+(n%2),2):
    if arr[i] % 2 != 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = list(map(int,input().split()))
ans = 0
for i in range(0,len(arr)+1,2):
    if arr[i] % 2 != 0:
        ans += 1
print(ans)
Problem p02684 (python)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
#"tel"は既に訪れている町
tel = set()
route = []
#"town"は今いる町
town = 1
route.append(town)
tel.add(town)
time_loop = 0
for i in range(k):
    town = a[town-1]
    if town in tel:
        time_loop += 1
        break
    tel.add(town)
    route.append(town)
    #テレポートした回数をカウント
    time_loop += 1

#"start"は"route"内のループの起点のとなる町のインデックス番号
start = route.index(town)
if time_loop != start:
    k = (k - start) % (time_loop - start)
    print(route[k+start])
else:
    print(town)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
#"tel"は既に訪れている町
tel = set()
route = []
#"town"は今いる町
town = 1
route.append(town)
tel.add(town)
time_loop = 0
for i in range(k):
    town = a[town-1]
    if town in tel:
        time_loop += 1
        break
    tel.add(town)
    route.append(town)
    #テレポートした回数をカウント
    time_loop += 1

#"start"は"route"内のループの起点のとなる町のインデックス番号
start = route.index(town)
k = (k - start) % (time_loop - start)
print(route[k+start])
Problem p02718 (python)

Fixed submission:
N,M = map(int,input().split())
Ai = list(map(int,input().split()))
Ai.sort(reverse=True)
soutokuhyou = sum(Ai[:])
seigen = soutokuhyou / (4*M)
if Ai[M-1] < seigen:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
Ai = list(map(int,input().split()))
Ai.sort(reverse=True)
x = sum(Ai[0:M])
soutokuhyou = sum(Ai[:])
seigen = soutokuhyou / (4*M)
if Ai[M] < seigen:
    print("No")
else:
    print("Yes")
Problem p02576 (python)

Fixed submission:
import sys

import math
def gcd(a,b):
	if a == 0:
		return b
	return gcd(b%a,a)

def main():
	n,x,t = map(int,input().split())
	print((math.ceil(n/x))*t)
if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
import sys
sys.stdout = open("output.txt",'w')
sys.stdin = open("input.txt",'r')
import math
def gcd(a,b):
	if a == 0:
		return b
	return gcd(b%a,a)

def main():
	n,x,t = map(int,input().split())
	print((math.ceil(n/x))*t)
if __name__ == "__main__":
	main()
Problem p02854 (python)

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

s=0
for i in range(len(x)):
	s+=x[i]
i=0
l=0
while (l<(s//2)):
	l+=x[i]
	i+=1
r=abs(s-l-l) 
i=len(x)-1
l=0
while(l<(s//2)):
	l+=x[i]
	i-=1
if abs((s-l)-l)<r:
	r=abs(s-l-l) 
print (r)

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

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

s=0

for i in range(len(x)):

	s+=x[i]i=0

l=0

while (l<(s//2)):

	l+=x[i]

	i+=1

r=abs((s-l)-l) 

i=len(x)-1

l=0

while(l<(s//2)):

	l+=x[i]

	i-=1

if abs((s-l)-l)<r:

	r=abs((s-l)-l) 

print (r)
Problem p02576 (python)

Fixed submission:
import math

line = input()

strL = line.split()

N = int(strL[0])
X = int(strL[1])
T = int(strL[2])

ans = math.ceil(N/X) * T

print(ans)

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    
    m = A[0]
    S = 0
 
    for a in A:
        if m - a > 0:
            S += m - a
        if m < a:
            m = a
    
    print(S)
 
 
if __name__ == "__main__":
    main()
Problem p03854 (python)

Fixed submission:
import re
s = input()
s = re.sub('eraser', '', s)
s = re.sub('erase', '', s)
s = re.sub('dreamer', '', s)
s = re.sub('dream', '', s)
print('YES' if len(s) == 0 else 'NO')

Buggy submission (verdict: Runtime Error):
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$"), input() else "NO")
Problem p02576 (python)

Fixed submission:
N, X, T  = map(int,input().split())
if N%X == 0:
  print( N//X *T )
else:
  print( ( N//X + 1)*T )

Buggy submission (verdict: Runtime Error):
N, X, T  = map(int,input))
ans = (N//X + N%X)*T
print(ans)
Problem p02602 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = A[0]
r = A[K]
for i in range(1,N-K):
  if l < r:
    print('Yes')
  else:
    print('No')
  l = A[i]
  r = A[K+i]
if l < r:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = A[0]
r = A[K]
for i in range(K-2):
  if l < r:
    print('Yes')
  else:
    print('No')
  l = A[1+i]
  r = A[K+1+i]
if l < r:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
l = A[0]
r = A[K]
for i in range(K-2):
  if l < r:
    print(l,r)
    print('Yes')
  else:
    print(l,r)
    print('No')
  l = A[1+i]
  r = A[K+1+i]
if l < r:
  print('Yes')
else:
  print('No')
Problem p02743 (python)

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

Buggy submission (verdict: Runtime Error):
eps = 1.0e-14
if math.sqrt(a) + math.sqrt(b) + eps < math.sqrt(c):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int,input().split())
#if math.sqrt(a)+math.sqrt(b) < math.sqrt(c):
if a**0.5 + b**0.5 < c**0.5
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
if a**0.5 + b**0.5 < c**0.5
    print("Yes")
else:
    print("No")
Problem p02761 (python)

Fixed submission:
N, M = map(int,input().split())
SC = [-1]*(N+1)
ans = [0]*N
for _ in range(M):
    s,c = map(int,input().split())
    if SC[s] != -1 and SC[s] != c:
        print(-1)
        exit()
    SC[s] = c
flg = 1
if N == 1:
    st = 10**(N-1) -1
else:
    st = 10**(N-1)
for i in range(st,10**N):
    s = str(i)
    for j in range(1,N+1):
        if SC[j] == -1:
            continue
        if SC[j] != int(s[j-1]):
            flg = 0
            break
    if not flg:
        flg = 1
        continue
    if flg:
        print(i)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
SC = [-1]*(N+1)
ans = [0]*N
for _ in range(M):
    s,c = map(int,input().split())
    if SC[s] != -1 and SC[s] != c:
        print(-1)
        exit()
    SC[s] = c
flg = 1
for i in range(10**(N-1)-1,10**N):
    s = str(i)
    for j in range(1,N+1):
        if SC[j] == -1:
            continue
        if SC[j] != int(s[j-1]):
            flg = 0
            break
    if not flg:
        flg = 1
        continue
    if flg:
        print(i)
        exit()
print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
SC = [-1]*(N+1)
ans = [0]*N
for _ in range(M):
    s,c = map(int,input().split())
    if SC[s] != -1 and SC[s] != c:
        print(-1)
        exit()
    SC[s] = c

for i in range(10**(N-1),10**N):
    s = str(i)
    for j in range(1,N+1):
        if SC[j] == -1:
            continue
        if SC[j] != int(s[j-1]):
            flg = 0
            break
    if not flg:
        flg = 1
        continue
    if flg:
        print(i)
        exit()
print(-1)
Problem p02765 (python)

Fixed submission:
N,R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(R+100*(10-N))

Buggy submission (verdict: Runtime Error):
N,R = map(int,input().split())
if N<=10:
    print(R)
else:
    print(R-100*(10-K))
Problem p02789 (python)

Fixed submission:
N,M = map(int,input().split())
if M ==N:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
M = int(input())
if M ==N:
    print("Yes")
else:
    print("No")
Problem p02854 (python)

Fixed submission:
import numpy as np
import bisect
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)
cumsum = np.cumsum(A)
ans = 2020202020
for a in cumsum:
    ans = min(ans,abs(2*a-sumA))
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
import bisect
#input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)
ans = 0
if sumA%2 != 0:
    ans += 1
cumsum = np.cumsum(A)
half = sumA//2
id = bisect.bisect_left(cumsum,half)
mini = min(abs(half-cumsum[id]),abs(cumsum[id+1]-half))
ans += mini
print(ans)
Problem p02865 (python)

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

Buggy submission (verdict: Runtime Error):
mod = 998244353
N = int(input())
A = list(map(int,input().split()))
D = [1 for _ in range(max(A)+1)]
if N == 1:
    if A[0] == 0:
        print(1)
        exit()
    else:
        print(0)
        exit()

D[1] = A.count(1)
ans = 1
if A[0] > 0 or D[0] > 1:
    print(0)
else:
    for i in range(2,max(A)+1):
        D[i] = A.count(i)
        ans *= (D[i-1]**D[i])%mod
    print(ans)
Problem p02888 (python)

Fixed submission:
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(len(L)-1):
    for j in range(i+1,len(L)-1):
        a = L[i]
        b = L[j]
        c = L[j+1]
        if c-a < b and b < c+a:
            ans += bisect.bisect_left(L,b+a)-j-1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
L = list(map(int,input().split()))
L.sort()
ans = 0
for i in range(len(L)-1):
    for j in range(i+1,len(L)-1):
        a = L[i]
        b = L[j]
        c = L[j+1]
        if c-a < b and b < c+a:
            ans += bisect.bisect_left(L,b+a)-j-1
print(ans)
Problem p02900 (python)

Fixed submission:
import sys
import os
sys.setrecursionlimit(100000)

def gcd(a,b):
    if b>=a:
        a,b = b,a
    if b<= 0:
        return a
    return gcd(b,a%b)

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

A, B = map(int,input().split())
P = factorize(gcd(A,B))
P = set(P)

print(len(P)+1)

Buggy submission (verdict: Runtime Error):
import sys
import os
import math
A, B = map(int,input().split())
gcdAB = math.gcd(A,B)
P = []
for i in range(2,gcdAB):
    if gcdAB%i==0:
        P.append(i)
        gcdAB /=i
    i+=2
cnt =1
for p in P:
    if p!= 0:
        cnt +=1
print(cnt)
Problem p02963 (python)

Fixed submission:
S = int(input())
X2 = 10**9
Y2 = 1
X3 = (X2-(S%X2))%(10**9)
Y3 = (S+X3)//X2
print(0,0,X2,Y2,X3,Y3)

Buggy submission (verdict: Runtime Error):
S = int(input())
KL = [i for i in range(S)]
for i in range(1,S):
    for j in range(1,S):
        id = bisect.bisect_right(KL,i*j-S)
        if KL[id-1] == i*j-S:
            print(0,0,i,KL[id-1],j,1)
            exit()

Buggy submission (verdict: Runtime Error):
S = int(input())
KL = [i for i in range(S)]
for i in range(1,S):
    for j in range(1,S):
        id = bisect.bisect_right(KL,i*j-S)
        if KL[id-1] == i*j-S:
            if [i,KL[id-1]] == [j,1]:
                continue
            else:
                print(0,0,i,KL[id-1],j,1)
                exit()
Problem p02971 (python)

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
b = a[:]
mx = max(b)
b.remove(mx)
mx2 = max(b)

for t in a:
    if t == mx:
        print(mx2)
    else:
        print(mx)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
tmp = sorted(a)
mx = max(a)
cnt = a.count(mx)

for t in a:
    if t == mx and -cnt-1 < len(a):
        print(tmp[-cnt-1])
    else:
        print(mx)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
tmp = sorted(a)
mx = max(a)
cnt = a.count(mx)

for t in a:
    if t == mx:
        print(tmp[-cnt-1])
    else:
        print(mx)
Problem p02999 (python)

Fixed submission:
x, a = map(int, input().split())
print(0 if x<a else 10)

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

#右側のindex
r=0

sum = 0
cnt = 0

for l in range(N):
    while sum < K:
        if r == N:
            break
        else:
            sum += a[r]
            r += 1
    if sum < K :
        break
    cnt += N-r+1
    sum -= a[l]

print(cnt)
Problem p03076 (python)

Fixed submission:
import math

times = [0]*5
for i in range(5):
    times[i] = int(input())

#1桁目が一番小さいものを判断する
mini = 10
idx = 9
for time in times:
    if time%10 < mini and time%10 > 0:
        mini = min(mini,time%10)
        idx = times.index(time)

total = 0
for i in range(5):
    if i == idx:
        total += times[i]
    else:
        total += math.ceil(times[i]/10)*10
print(total)

Buggy submission (verdict: Runtime Error):
import sys
import os
f = open('input.txt','r')
sys.stdin = f

import math

times = [0]*5
for i in range(5):
    times[i] = int(input())

#1桁目が一番小さいものを判断する
mini = 9
idx = 9
for time in times:
    if time%10 < mini and time%10 > 0:
        mini = min(mini,time%10)
        idx = times.index(time)

total = 0
for i in range(5):
    if i == idx:
        total += times[i]
    else:
        total += math.ceil(times[i]/10)*10
print(total)
Problem p03085 (python)

Fixed submission:
b = input()
out = ""

if b == "A":
    out = "T"
elif b == "C":
    out = "G"
elif b == "G":
    out = "C"
else:
    out = "A"
print(out)

Buggy submission (verdict: Runtime Error):
import sys
import os
f = open('input.txt','r')
sys.stdin = f

b = input()
out = ""

if b == "A":
    out = "T"
elif b == "C":
    out = "G"
elif b == "G":
    out = "C"
else:
    out = "A"
print(out)

Buggy submission (verdict: Runtime Error):
b = input()
out = ""

if b == "A":
    out = "T"
elif b == "C":
    out = G
elif b = "G":
    out = "C"
else:
    out = "A"
print(out)
Problem p03095 (python)

Fixed submission:
mod = 10**9 + 7
N = int(input())
S = list(input())
al = [chr(ord("a") + i ) for i in range(26)]
cntAl = [ S.count(chr(ord("a") + i )) for i in range(26)]
ans = 1
for a in cntAl:
    if a != 0:ans *= (a+1)%mod
print((ans-1)%mod)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
listS = list(S)
setS = set(listS)

#異なる文字から2個を選ぶ場合（2項定理の利用）
if len(listS) == len(setS):
    res = 2**len(setS)-1
    print(res)
    sys.exit()
else:
    res = 0
for x in setS:
    n = listS.count(x)
    if n == 1:
        res += 1
    else:
        res += (2**(len(setS)-1))*n
print(res)
Problem p03161 (python)

Fixed submission:
n,k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [(10**4)*(10**5)]*n
dp[0]=0
for i in range(n-1):
    loop = min(k+1,n-i)
    for j in range(1,loop):
        dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j])) 
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [(10**4)*(10**5)]*n
dp[0]=0
for i in range(n-1):
    loop = min(k+1,n-i)
    for j in range(1,loop):
        dp[i+j] = min(dp[i+j],dp[i]+np.abs(h[i]-h[i+j])) 
print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
n,k = map(int, input().split())
h = [int(i) for i in input().split()]
dp = [(10**4)*(10**5)]*n
dp[0]=0
loop = min(k+1,n-i)
for i in range(n-1):
     for j in range(1,loop):
#            if i+j>n-1: break
            dp[i+j] = min(dp[i+j],dp[i]+np.abs(h[i]-h[i+j]))
print(dp[n-1])
Problem p03282 (python)

Fixed submission:
S = input()
K = int(input())
cnt = 0
for s in S:
    cnt += 1
    if s == "1" and cnt < K:
        continue
    else:
        print(s)
        exit()

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
for i in range(1,K+1):
    if S[i] != "1":
        print(S[i])
        exit()
print(1)
Problem p03387 (python)

Fixed submission:
A,B,C = map(int,input().split())
maxi = max(A,B,C)
mini = min(A,B,C)
mid = sum([A,B,C]) - (maxi+mini)
i,j,k,l = 0,0,0,0
if mini%2 != mid%2:
    #midだけ偶奇が違うとき
    if maxi%2 == mini%2 and maxi%2 != mid%2:
        if mid - maxi != 1:
            i = (maxi+1-mid)//2
            mid = maxi + 1
    #miniだけ偶奇が違うとき
    if maxi%2 != mini%2 and maxi%2 == mid%2:
        if mini - maxi != 1:
            j = (maxi+1-mini)//2
            mini = maxi + 1
while maxi - mini > 1:
    mini += 2
    k += 1
while maxi - mid > 1:
    mid += 2
    l += 1
if maxi == mini and maxi == mid:
    print(i+j+k+l)
else:
    print(i+j+k+l+1)

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
maxi = max(A,B,C)
mini = min(A,B,C)
mid = sum([A,B,C]) - (maxi+mini)
i,j,k,l = 0,0,0,0
if mini%2 != mid%2:
    #midだけ偶奇が違うとき
    if maxi%2 == mini%2 and maxi%2 != mid%2:
        if mid - maxi != 1:
            ans += (maxi+1-mid)//2
            mid = maxi + 1
    #miniだけ偶奇が違うとき
    if maxi%2 != mini%2 and maxi%2 == mid%2:
        if mini - maxi != 1:
            ans += (maxi+1-mini)//2
            mini = maxi + 1
while maxi - mini > 1:
    mini += 2
    k += 1
while maxi - mid > 1:
    mid += 2
    l += 1
if maxi == mini and maxi == mid:
    print(i+j+k+l)
else:
    print(i+j+k+l+1)
Problem p03472 (python)

Fixed submission:
import sys
import os
import math
from operator import itemgetter
 
N, H  = map(int,input().split())
katana = [0 for _ in range(N)]
 
for i in range(N):
    a,b = map(int,input().split())
    katana[i] = [a,b]
katana = sorted(katana,key=itemgetter(1),reverse=True)
maxA = 0
for i in range(N):
    maxA = max(maxA,katana[i][0])
 
cnt = 0
for k in katana:
    if H <= 0:
        print(cnt)
        sys.exit()
    if k[1] > maxA:
        H -= k[1]
        cnt += 1
cnt += math.ceil(H/maxA)
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
import os
import math

N, H  = map(int,input().split())
katana = [0 for _ in range(N)]

for i in range(N):
    a,b = map(int,input().split())
    katana[i] = [a,b]
katana = sorted(katana,key=itemgetter(1),reverse=True)
maxA = 0
for i in range(N):
    maxA = max(maxA,katana[i][0])

cnt = 0
for k in katana:
    if H <= 0:
        print(cnt)
        sys.exit()
    if k[1] > maxA:
        H -= k[1]
        cnt += 1
cnt += math.ceil(H/maxA)
print(cnt)
Problem p03543 (python)

Fixed submission:
a,b,c,d = input()
print("Yes" if b==c and( a==b or c==d ) else "No" )

Buggy submission (verdict: Runtime Error):
a,b,c,d = input()
print("Yes" b==c and(a==b or c==d) else "No" )
Problem p03569 (python)

Fixed submission:
S = list(input())
invS = []
for s in reversed(S):
    invS.append(s)
cnt = 0
loop = 0
i,j = 0,0
while i+j < len(S)-1 and i <= len(S)-1 and j <= len(S)-1 :
    if S[i] == invS[j]:
        i += 1
        j += 1
    elif S[i] == "x":
        cnt += 1
        i += 1
    elif invS[j] == "x":
        cnt += 1
        j += 1
    else:
        cnt = -1
        break
print(cnt)

Buggy submission (verdict: Runtime Error):
S = list(input())
invS = []
for s in reversed(S):
    invS.append(s)
cnt = 0
loop = 0
i,j = 0,0
while i+j != len(S)-1:
    if S[i] == invS[j]:
        i += 1
        j += 1
    elif S[i] == "x":
        cnt += 1
        i += 1
    elif invS[j] == "x":
        cnt += 1
        j += 1
    else:
        cnt = -1
        break
print(cnt)

Buggy submission (verdict: Runtime Error):
S = list(input())
invS = []
for s in reversed(S):
    invS.append(s)
cnt = 0
loop = 0
i,j = 0,0
while i <= len(S)//2+1 and j <= len(S)//2+1:
    if S[i] == invS[j]:
        i += 1
        j += 1
    elif S[i] == "x":
        cnt += 1
        i += 1
    elif invS[j] == "x":
        cnt += 1
        j += 1
    loop += 1
    if loop > len(S):
        cnt = -1
        break
print(cnt)
Problem p03605 (python)

Fixed submission:
N = input()
if "9" in N:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 7)
#f = open('input.txt','r')
input = sys.stdin.readline
#sys.stdin = f

N = int(input())
A = [int(input()) for _ in range(N)]
cntA = [0 for _ in range(max(A)+1)]
for a in A:
    cntA[a] += 1
    cntA[a] %= 2
print(sum(cntA))
Problem p03607 (python)

Fixed submission:
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
cnt = 1
ans = 0
if len(A) == 1:
    print(1)
    exit()
for i in range(1,N):
    if A[i-1] == A[i]:
        cnt += 1
    else:
        ans += cnt%2
        cnt = 1
if cnt >= 1:
    ans += cnt%2
print(ans)

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

N = int(input())
A = [ int(input()) for _ in range(N)]
cntA = [0 for _ in range(max(A)+1)]
for a in A:
    cntA[a] += 1
    cntA[a] %= 2
print(sum(cntA))