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

Fixed submission:
h,w = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[y][x]=="#":
            if x-1>=0 and s[y][x-1]=="#":
                continue
            elif y-1>=0 and s[y-1][x]=="#":
                continue
            elif x+1<w and s[y][x+1]=="#":
                continue
            elif y+1<h and s[y+1][x]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
w,h = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[x][y]=="#":
            if x-1>=0 and s[x-1][y]=="#":
                continue
            elif y-1>=0 and s[x][y-1]=="#":
                continue
            elif x+1<w and s[x+1][y]=="#":
                continue
            elif y+1<h and s[x][y+1]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
h,w = (int(i) for i in input().split())
s = []
for i in range(h):
    s.append(input())

isPaintable = True
for y in range(h):
    for x in range(w):
        if s[x][y]=="#":
            if x-1>=0 and s[x-1][y]=="#":
                continue
            elif y-1>=0 and s[x][y-1]=="#":
                continue
            elif x+1<w and s[x+1][y]=="#":
                continue
            elif y+1<h and s[x][y+1]=="#":
                continue
            isPaintable=False
if isPaintable:
    print("Yes")
else:
    print("No")
Problem p03363 (python)

Fixed submission:

n = int(input())
a = list(int(i) for i in input().split())
sa = [0] * (n+1)
num_cnt = {}    
# 累積和
for i in range(n):
    sa[i + 1] = sa[i] + a[i]

for num in sa:
    if num in num_cnt:
        num_cnt[num] += 1
    else:
        num_cnt[num] = 1


res = 0
for cnt in num_cnt.values():
    res += cnt*(cnt-1)//2

print(res)

Buggy submission (verdict: Runtime Error):

n = int(input())
a = list(int(i) for i in input().split())
sa = [0] * (n+1)
num_cnt = {}    
# 累積和
for i in range(n):
    sa[i + 1] = sa[i] + a[i]

for num in sa:
    if num in num_cnt:
        num_cnt[num] += 1
    else:
        num_cnt[num] = 1

for cnt in num_cnt.values():
    res += cnt*(cnt-1)//2

print(res)
Problem p03425 (python)

Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(input())
tmp_nums = {"M":0, "A":0, "R":0, "C":0, "H":0}
for i in range(n):
    if s[i][0] in tmp_nums.keys():
        tmp_nums[s[i][0]] += 1
nums=[]
for i in tmp_nums.values():
    nums.append(i)
p = [0,0,0,0,0,0,1,1,1,2]
q = [1,1,1,2,2,3,2,2,3,3]
r = [2,3,4,3,4,4,3,4,4,4]
sum = 0
for i in range(10):
    sum += nums[p[i]]*nums[q[i]]*nums[r[i]]
print(sum)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
    s.append(input())
tmp_nums = {"M":0, "A":0, "R":0, "C":0, "H":0}
for i in range(n):
    tmp_nums[s[i][0]] += 1
nums=[]
for i in tmp_nums.values():
    nums.append(i)
p = [0,0,0,0,0,0,1,1,1,2]
q = [1,1,1,2,2,3,2,2,3,3]
r = [2,3,4,3,4,4,3,4,4,4]
sum = 0
for i in range(10):
    sum += nums[p[i]]*nums[q[i]]*nums[r[i]]
print(sum)
Problem p03471 (python)

Fixed submission:
n,y = (int(i) for i in input().split())
y/=1000
payed = False
for i in range(n+1):
    if payed:
        break
    for j in range(n+1-i):
        k = n-i-j
        if k>=0:
            if i*10+j*5+k==y:
                print(i,j,k)
                payed = True
                break
if not payed:
    print(-1,-1,-1)

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
Payable = False
try:
    for i in range(N+1):
        for j in range(N+1-i):
            k = N-i-j
            if i*10000+j*5000+k*1000 == Y:
                print(i,j,k)
                Payable = True
                raise Exception
except Exception:
    break

if not Payable:
    print(-1, -1, -1)
Problem p03476 (python)

Fixed submission:
q = int(input())
a = [list(int(i) for i in input().split()) for i in range(q)]
MAX = 10**5
is_prime = [1]*MAX
for i in range(2, MAX):
    if not is_prime[i]:
        continue
    for j in range(i*2, MAX, i):
        is_prime[j] = 0
s = [0]*MAX
for i in range(3,MAX):
    s[i] = s[i-1] + 1 if is_prime[i] and is_prime[(i+1)//2] else s[i-1]
for i in range(q):
    l,r = a[i]
    print(s[r]-s[l-1])

Buggy submission (verdict: Runtime Error):
q = int(input())
a = [list(int(i) for i in input().split()) for i in range(q)]
MAX = 10**5
is_prime = [1]*MAX
for i in range(2, MAX):
    if not is_prime[i]:
        continue
    for j in range(i*2, MAX, i):
        is_prime[j] = 0
s = [0]*MAX
for i in range(3,MAX):
    s[i] = s[i-1] + 1 if is_prime[i] and is_prime[(i+1)//2]
for i in range(q):
    l,r = a[i]
    print(s[r]-s[l-1])
Problem p03493 (python)

Fixed submission:
s = str(input())
print(s.count('1'))

Buggy submission (verdict: Runtime Error):
s = string(input())
print(s.count('1'))

Buggy submission (verdict: Runtime Error):
s = strings(input())
print(s.count('1'))
Problem p03583 (python)

Fixed submission:
N = int(input())
w1 = 10**5
w2 = 1
try:
    for h in range(1,3501):
        for n in range(1,3501):
            if (4*h*n-N*(h+n))>0:
                w1 = (N*h*n)//(4*h*n-N*(h+n))
                w2 = (N*h*n)/(4*h*n-N*(h+n))
            if w1==w2 and w1>0:
                raise(Exception)
except Exception:
    print(h,n,w1)

Buggy submission (verdict: Runtime Error):
N = int(input())
try:
    for h in range(1,3501):
        for n in range(1,3501):
            w1 = (N*h*n)//(4*h*n-N*(h+n))
            w2 = (N*h*n)/(4*h*n-N*(h+n))
            if w1==w2:
                raise(Exception)
except Exception:
    print(h,n,w1)

Buggy submission (verdict: Runtime Error):
N = int(input())
h = N
n = max(N//3,1)
w = 1
while True:
    if (N*n)//(3*n-N) == (N*n)/(3*n-N):
        print(h,n,(N*n)//(3*n-N))
        break
    n += 1
Problem p03588 (python)

Fixed submission:
n = int(input())
a,b = [],[]
for i in range(n):
    ta,tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
mii = a[b.index(min(b))]
print(mii+(min(b)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a,b = [],[]
for i in range(n):
    ta,tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
mai = a[b.index(max(b))]
mii = a[index(min(b))]
print(mii+(min(b))+mai-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a,b = [],[]
for i in range(n):
    ta,tb = map(int, input().split())
    a.append(ta)
    b.append(tb)
mai = a.index(max(b))
mii = a.index(min(b))
print(mii+(min(b))+mai-1)
Problem p03609 (python)

Fixed submission:
x, t = map(int, input().split())
print(max(x-t,0))

Buggy submission (verdict: Runtime Error):
x, t = map(int, input().split())
print(x-t)x, t = map(int, input().split())
print(max(x-t,0))
Problem p03697 (python)

Fixed submission:
A,B = (int(i) for i in input().split())
if A+B >= 10:
    print("error")
else:
    print(A+B)

Buggy submission (verdict: Runtime Error):
A,B = int(i) for i in input().split()
if A+B >= 10:
    print("error")
else:
    print(A+B)
Problem p03837 (python)

Fixed submission:
N, M = map(int, input().split())
INF = 10**9

edges = []

for i in range(M):
    edges.append(list(map(int, input().split())))

dist = [[INF for j in range(N)] for i in range(N)]

for i in range(N):
    dist[i][i] = 0

for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    dist[a][b] = c
    dist[b][a] = c
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j])

res = M
for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    shortest = False
    for j in range(N):
        if dist[j][a] + c == dist[j][b]:
            shortest = True
            break
    if shortest:
        res -= 1

print(res)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
INF = 10**9

edges = []

for i in range(M):
    edges.append(list(map(int, input().split())))

dist = [[INF for j in range(N)] for i in range(N)]

for i in range(N):
    dist[i][i] = 0

for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    dist[a][b] = c[i]
    dist[b][a] = c[i]
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j])

res = M
for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    shortest = False
    for j in range(N):
        if dist[j][a] + c == dist[j][b]:
            shortest = True
            break
    if shortest:
        res -= 1

print(res)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
INF = 10**9

edges = []

for i in range(M):
    edges.append(list(map(int, input().split())))

dist = [[INF for j in range(N)] for i in range(N)]

for i in range(N):
    dist[i][i] = 0

for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    dist[a][b] = c[i]
    dist[b][a] = c[i]
    
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j])

res = M
for i in range(M):
    a, b, c = edges[i]
    a, b = a - 1, b - 1
    shortest = False
    for j in range(N):
        if dist[j][a] + c == dist[j][b]:
            shortest = True
            break
    res -= 1

print(res)
Problem p03966 (python)

Fixed submission:
n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 1,1
for i in range(n):
    tmp = max(-(-p//t[i]),-(-q//a[i]))
    p = t[i]*tmp 
    q = a[i]*tmp
print(p+q)

Buggy submission (verdict: Runtime Error):
n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 0,0
for zip(x,y) in t,a:
    tmp = max(p//x,q//y)
    p = x*tmp 
    q = y*tmp
print(p+q)

Buggy submission (verdict: Runtime Error):
n = int(input())
t,a = [],[]
for i in range(n):
    tmp = [int(i) for i in input().split()]
    t.append(tmp[0])
    a.append(tmp[1])

p,q = 0,0
for x,y in t,a:
    tmp = max(p//x,q//y)
    p = x*tmp 
    q = y*tmp
print(p+q)
Problem p02747 (python)

Fixed submission:
s=input()
if len(s)%2!=0:
  print('No')
  exit()
else:
  if s=='hi':
    print('Yes')
    exit()
  if s=='hihi':
    print('Yes')
    exit()
  if s=='hihihi':
    print('Yes')
    exit()
  if s=='hihihihi':
    print('Yes')
    exit()
  if s=='hihihihihi':
    print('Yes')
    exit()
  else:
    print('No')

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
l=[]
t=0
c=0
for _ in range(N):
  L=list(map(int,input().split()))
  l.append(L)
l.sort()
def f(x):
  ls=[]
  for i in range(len(l)):
    v=l[i][0]*x+l[i][1]
    ls.append([v,i])
  return min(ls)
if f(1)[0]+1>T:
  print(0)
  exit()
for i in range(N):
  t+=1
  t+=f(t)[0]
  if f(t)[0]<=T:
    c+=1
    del l[f(t)[1]]
  else:
    print(c+1)
    exit()
print(N)
Problem p02971 (python)

Fixed submission:
N=int(input())
a=[]
b=[]
for _ in range(N):
  a_=int(input())
  a.append(a_)
  b.append(a_)
x=max(a)
b.sort()
if a.count(x)>=2:
  for i in range(N):
    print(x)
else:
  for i in range(N):
    if a[i]==x:
      print(b[-2])
    else:print(x)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[]
for _ in range(N):
  a_=int(input())
  a.append(a_)
x=max(a)
if a.count(x)>=2:
  for i in range(N):
    print(x)
else:
  for i in range(N):
    if a[i]==x:
      print(a.sort(-2))
    else:print(x)
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):
import math
 
N = int(input())
X = list(map(int, input().split()))
sum = 0
all = True
for a in X:
    sum = sum + a
C = int(sum / N + 0.5)
ans = 0
for b in X:
    ans = ans + (b-C)**2
print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
X = list(map(int, input().split()))
for a in X:
    sum = sum + a
C = sum/N
for b in X:
    ans = (b-C)**2
print(ans)

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

Fixed submission:
N = int(input())
X = list(map(int, input().split()))
sum = 0
all = True
for a in X:
    sum = sum + a
C = int(sum / N + 0.5)
ans = 0
for b in X:
    ans = ans + (b-C)**2
print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
X = list(map(int, input().split()))
cen = sorted(X)[int(-(sorted(len(X)/2)))]
sum = 0
all = True
for a in X:
    sum = sum + a
    for c in X:
            all = False
ans = 0
for b in X:
    ans = ans + (b-cen)**2
if all == True:
    ans = 0
    print(ans)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
X = list(map(int, input().split()))
cen = sorted(X)[-(sorted(int(len(X)/2)))]
sum = 0
all = True
for a in X:
    sum = sum + a
    for c in X:
            all = False
ans = 0
for b in X:
    ans = ans + (b-cen)**2
if all == True:
    ans = 0
    print(ans)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
X = list(map(int, input().split()))
cen = sorted(X)[-(sorted(len(X)/2))]
sum = 0
all = True
for a in X:
    sum = sum + a
    for c in X:
            all = False
ans = 0
for b in X:
    ans = ans + (b-cen)**2
if all == True:
    ans = 0
    print(ans)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
sum = 0
all = True
max = 0
for a in X:
    sum = sum + a
    if max <= a:
        max = a + 1
    for c in X:
        if(a != c):
            all = False
ans = 0
for b in X:
    ans = ans + (b-math.ceil(max))**2
if all == True:
    ans = 0
    print(ans)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))
sum = 0
for a in X:
    sum = sum + a
C = sum/N
ans = 0
for b in X:
    ans = ans + (b-C)**2
print(math.ceil(ans))

Buggy submission (verdict: Runtime Error):
import math

N = input()
X = list(map(int, input().split()))
sum = 0
for a in X:
    sum = sum + a
C = sum/N
ans = 0
for b in X:
    ans = ans + (b-C)**2
print(math.ceil(ans))

Buggy submission (verdict: Runtime Error):
N = input()
X = list(map(int, input().split()))
sum = 0
for a in X:
    sum = sum + a
C = sum/N
ans = 0
for b in X:
    ans = ans + (b-C)**2
print(int(ans))

Buggy submission (verdict: Runtime Error):
N = input()
X = list(map(int, input().split()))
sum = 0
for a in X:
    sum = sum + a
C = sum/N
for b in X:
    ans = (b-C)**2
print(int(ans))

Buggy submission (verdict: Runtime Error):
N = input()
X = list(map(int, input().split()))
for a in X:
    sum = sum + a
C = sum/N
for b in X:
    ans = (b-C)**2
print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
X = list(map(int, input().split()))
for a in X:
    sum = sum + a
C = sum/N
for b in X:
    ans = (b-C)**2
Problem p02830 (python)

Fixed submission:
n=int(input())
s,t=map(str,input().split())
ans=""
for i in range(n):
	ans+=s[i]+t[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s,t=map(str,input().split())
ans=""
for i in range(n)
	ans+=s[i]+t[i]
print(ans)
Problem p03323 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a,b = na()

if a >= 9 or b >= 9:
    print(":(")
else:
    print("Yay!")

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a = ni()
b = ni()

if a >= 9 or b >= 9:
    print(":(")
else:
    print("Yay!")
Problem p03353 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
k = ni()
ans = []

for i in range(len(s)):
    ans.append(s[i])
    if i < len(s)-1:
        t = i+2
        while True:
            ans.append(s[i:t])
            if t == len(s):
                break
            t += 1
            if t - i > 5:
                break

ans = list(set(ans))
ans.sort()
print(ans[k-1])

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

s = ns()
k = ni()
ans = []

for i in range(len(s)):
    for j in range(1,len(s)+1):
        if j - i > 5:
            break
        ans.append(s[i:j])

ans = list(set(ans))
ans.remove("")
ans.sort()
print(ans[k-1])
Problem p03409 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
red = []
for _ in range(n):
    red.append(na())
blue = []
for _ in range(n):
    blue.append(na())

red.sort()
blue.sort()
ans = 0

tmp = []
for i in blue:
    for j in red:
        if i[0] > j[0] and i[1] > j[1]:
            tmp.append(j)
    if tmp != []:
        max_red = max(tmp, key=lambda x:x[1])
        ans += 1
        red.remove(max_red)
        tmp = []
    else:
        pass

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
red = []
for _ in range(n):
    red.append(na())
blue = []
for _ in range(n):
    blue.append(na())

red_1 = sorted(red)
blue_1 = sorted(blue)
ans_1 = 0

for i in red_1:
    for j in blue_1:
        if i[0] < j[0] and i[1] < j[1]:
            ans_1 += 1
            blue_1.remove(j)
            break

red.sort()
blue.sort()
red_2 = sorted(red, key=lambda x:sum(x))
blue_2 = sorted(blue, key=lambda x:sum(x))
ans_2 = 0

for i in red_2:
    for j in blue_2:
        if i[0] < j[0] and i[1] < j[1]:
            ans_2 += 1
            blue_2.remove(j)
            break
red_3 = sorted(red, key=lambda x:x[1])
blue_3 = sorted(red, key=lambda x:x[1])
red_3 = sorted(red_3, key=lambda x:sum(x))
blue_3 = sorted(blue_3, key=lambda x:sum(x))
ans_4
for i in red_3:
    for j in blue_3:
        if i[0] < j[0] and i[1] < j[1]:
            ans_4 += 1
            blue_3.remove(j)
            break

from operator import itemgetter
red.sort(key=itemgetter(1))
blue.sort(key=itemgetter(1))
ans_3 = 0

for i in red:
    for j in blue:
        if i[0] < j[0] and i[1] < j[1]:
            ans_3 += 1
            blue.remove(j)
            break

ans = []
ans.append(ans_1)
ans.append(ans_2)
ans.append(ans_3)
ans.append(ans_4)
print(max(ans))
Problem p03427 (python)

Fixed submission:
def is_9(arr):
    s = []
    for i in range(len(arr)):
        if arr[i] != '9':
            return False
        s.append(arr[i])
    return True


n = list(input())
fd = int(n.pop(0))
if is_9(n):
    print(fd + int(9 * len(n)))
else:
    print(fd - 1 + int(9 * len(n)))

Buggy submission (verdict: Runtime Error):
def is_9(arr):
    s = []
    for i in range(len(arr)):
        if arr[i] != '9':
            return False
        s.append(arr[i])
    return sum(s)


n = list(input())
fd = int(n.pop(0))
if is_9(n):
    print(fd + int(is_9(n)))
print(fd - 1 + int(9 * len(n)))
Problem p03547 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

x,y = ns().split()
hx = {"A":1, "B":2, "C":3, "D":4, "E":5, "F":6}

if hx[x] > hx[y]:
    print(">")
elif hx[x] < hx[y]:
    print("<")
else:
    print("=")

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

x,y = na()
hx = {"A":1, "B":2, "C":3, "D":4, "E":5, "F":6}

if hx[x] > hx[y]:
    print(">")
elif hx[x] < hx[y]:
    print("<")
else:
    print("=")
Problem p03607 (python)

Fixed submission:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
s = set()
for i in range(n):
    x = ni()
    if x in s:
        s.remove(x)
    else:
        s.add(x)
print(len(s))

Buggy submission (verdict: Runtime Error):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = [ni() for _ in range(n)]

if n == 1:
    print(1)
else:
    a.sort()
    count = 1
    ans = 0
    for i in range(1,n):
        if i == n-1:
            if a[i-1] == a[i]:
                count += 1
            count % 2 != 0:
                ans += 1
        else:
            if a[i-1] == a[i]:
                count += 1
            else:
                if count % 2 != 0:
                    ans += 1
                count = 1
    print(ans)
Problem p03680 (python)

Fixed submission:
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

if a[0] == 2:
    print(1)
else:
    count = 0
    i = a[0]
    flag = False
    for _ in range(n):
        count += 1
        if a[i-1] == 2:
            flag = True
            break
        i = a[i-1]
    if flag:
        print(count+1)
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

if a[0] == 2:
    print(0)
else:
    count = 0
    flag = False
    i = a[0]
    for _ in range(n):
        count += 1
        if a[i-1] == 2:
            flag = True
            break
        i = a[i-1]

if flag:
    print(count+1)
else:
    print(-1)
Problem p03697 (python)

Fixed submission:
a,b = map(int, input().split())
if a + b >= 10:
    print("error")
else:
    print(a+b)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input())
if a + b >= 10:
    print("error")
else:
    print(a+b)
Problem p03699 (python)

Fixed submission:
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = int(input())

max = sum(s)

if max % 10 == 0:
    s.sort()
    min = 0
    for i in s:
        if i % 10 != 0:
            min = i
            break
    if min == 0:
        print(0)
    else:
        print(max-min)
else:
    print(max)

Buggy submission (verdict: Runtime Error):
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int sum = 0;
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int s = sc.nextInt();
            sum += s;
            if (s % 10 != 0 && s < min) {
                min = s;
            }
        }

        if (sum % 10 != 0) {
            System.out.println(sum);
        } else {
            sum -= min;
            if (sum < 0) {
                System.out.println(0);
            } else {
                System.out.println(sum);
            }
        }
    }
}
Problem p03860 (python)

Fixed submission:
n = input().split()
b = []
for i in n:
    b.append(i[0])
b = ','.join(b)
b = b.replace(',','')
print(b)

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
fb = b // x
if a == 0:
    fb += 1
    fa = 0
else:
    fa = (a-1) // x
print(fb-fa)

Buggy submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
fb = b // x
if a == 0:
    fa = 0
else:
    fa = (a-1) // x
print(fb-fa)