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

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

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

Buggy submission (verdict: Runtime Error):
s1s2s3=str(input())
print(s1s2s3.count(1))
Problem p03502 (python)

Fixed submission:
n=int(input())
f=sum(list(map(int,str(n))))
if n%f==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=str(input())
f=0
for i in range(len(l)):
  f+=n[i]
if int(n)%f==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=str(input())
f=0
for i in range(len(n)):
  f+=n[i]
if n%f==0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
f=0
for i in range(len(n)):
  f+=i
if n%f==0:
  print('Yes')
else:
  print('No')
Problem p03606 (python)

Fixed submission:
n=int(input())
ans=0
for i in range(n):
  l,r=map(int,input().split())
  ans+=r-l+1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(n):
  l[i],r[i]=map(int,input().split())
  ans+=r[i]-l[i]+1
print(ans)
Problem p03729 (python)

Fixed submission:
A,B,C=map(str,input().split())
x=len(A)
y=len(B)
if A[x-1]==B[0] and B[y-1]==C[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
A,B,C=map(str,input().split())
x=len(A)
y=len(B)
if A[x-1]==B[1] and B[y-1]==C[1]:
  print("YES")
else:
  print("NO")
Problem p03737 (python)

Fixed submission:
s=list(map(str,input().split()))
x=s[0]
y=s[1]
z=s[2]
small=x[0]+y[0]+z[0]
print(small.upper())

Buggy submission (verdict: Runtime Error):
s=list(map(int,input().split()))
x=s[0]
y=s[1]
z=s[2]
small=x[0]+y[0]+z[0]
print(small.upper())
Problem p03827 (python)

Fixed submission:
n=int(input())
s=str(input())
x=0
l=[0]
for i in range(n):
  if s[i]=='I':
    x+=1
    l.append(x)
  else:
    x-=1
    l.append(x)
print(max(l))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=str(input())
x=0
l=[0]
for i in range(n):
  if s[i]=='I':
    x+=1
    l.append(x)
  else:
    x-=1
    l.append(x)
print(max(x))
Problem p03844 (python)

Fixed submission:
A,op,B=map(str,input().split())
if op=="+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))

Buggy submission (verdict: Runtime Error):
A op B=map(str,input().split())
if op=="+":
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
Problem p02854 (python)

Fixed submission:
import math
n=int(input())
a=list(map(int,input().split()))
ans=9999999999
hidari=sum(a)
migi=0
for i in range(n):
    hidari-=a[i]
    migi+=a[i]
    sa=math.fabs(hidari-migi)
    if sa<ans:
        ans=sa
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
ans=9999999999
hidari=sum(a)
migi=0
for i in range(n):
    hidari-=a[i]
    migi+=a[i]
    sa=math.abs(hidari-migi)
    if sa<ans:
        ans=sa
print(ans)
Problem p02995 (python)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
a=a-1
x=(c*d)//fractions.gcd(c,d)
n=b//c-a//c
m=b//d-a//d
o=b//x-a//x
ans=b-a-n-m+o
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split())
a=a-1
x=(c*d)//math.gcd(c,d)
n=b//c-a//c
m=b//d-a//d
o=b//x-a//x
ans=b-a-n-m+o
print(ans)
Problem p03076 (python)

Fixed submission:
abc=[]
answer=0
for i in range(5):
    d=int(input())
    if d%10==0:
        answer+=d
    else:
        answer+=(int(d/10+1))*10
        abc.append(d%10)
if len(abc)>0:
    answer-=10-min(abc)
print(answer)

Buggy submission (verdict: Runtime Error):
abc=[]
answer=0
for i in range(5):
    d=int(input())
    if d%10==0:
        answer+=d
    else:
        answer+=(int(d/10+1))*10
        abc.append(d%10)
answer-=10-min(abc)
print(answer)
Problem p03086 (python)

Fixed submission:
s=input()
cnt=0
cntlen=[]
for i in range(len(s)):
    if s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T':
        cnt+=1
    else:
        cntlen.append(cnt)
        cnt=0
cntlen.append(cnt)
print(max(cntlen))

Buggy submission (verdict: Runtime Error):
s=input()
cnt=0
cntlen=[]
for i in range(len(s)):
    if s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T':
        cnt+=1
    else:
        cntlen.append(cnt)
        cnt=0
print(max(cntlen))
Problem p03106 (python)

Fixed submission:
import fractions
li = list(map(int,input().split()))
a=li[0]
b=li[1]
k=li[2]
saidai=fractions.gcd(a,b)
yakusuu=[]
for i in range(100):
    if saidai%(i+1)==0:
        yakusuu.append(i+1)
yakusuu.sort()
yakusuu.reverse()
print(yakusuu[k-1])

Buggy submission (verdict: Runtime Error):
import math
li = list(map(int,input().split()))
a=li[0]
b=li[1]
k=li[2]
saidai=math.gcd(a,b)
yakusuu=[]
for i in range(100):
    if saidai%(i+1)==0:
        yakusuu.append(i+1)
yakusuu.sort()
yakusuu.reverse()
print(yakusuu[k-1])
Problem p03238 (python)

Fixed submission:
n=int(input())
if n==1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n=1:
    print("Hello World")
else:
    a=int(input())
    b=int(input())
    print(a+b)
Problem p03294 (python)

Fixed submission:
#coding: UTF-8
import sys
import os
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
m=list(map(int,input().split()))
k=lcm_list(m)
k=k-1
answer=0
for i in range(n):
    answer=answer+(k%m[i])
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
import os
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
m=list(map(int,input().split()))
k=lcm_list(m)
answer=0
for i in range(n):
    answer=answer+(m[i]%k)
print(answer-n)
Problem p02612 (python)

Fixed submission:
n = int(input())
if n % 1000 == 0:
    print(0)
else:
    print(1000 - n%1000)

Buggy submission (verdict: Runtime Error):
n = input()
if n % 1000:
    print(0)
else:
    print(1000 - n%1000)

Buggy submission (verdict: Runtime Error):
n = input()
print(1000- n%1000)
Problem p02613 (python)

Fixed submission:
num = int(input())
lst = [input() for _ in range(num)]
print("AC x", lst.count("AC"))
print("WA x", lst.count("WA"))
print("TLE x", lst.count("TLE"))
print("RE x", lst.count("RE"))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [input() for _ in range(num)]
print("AC x", l.count("AC"))
print("WA x", l.count("WA"))
print("TLE x", l.count("TLE"))
print("RE x", l.count("RE"))

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [input() for i in range(num)]
print("AC x", l.count("AC"))
print("WA x", l.count("WA"))
print("TLE x", l.count("TLE"))
print("RE x", l.count("RE"))
Problem p02684 (python)

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

s = [True] * n  
c = [1]  
now = 0  
while s[now]:
    s[now] = False  
    now = a[now] - 1
    c.append(now+1)

start_cycle = c.index(c[-1]) 
loop = c[start_cycle:-1]  
cycle = len(loop)

if k < start_cycle:  
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
A = list(map(int,input().split()))
flag = [True]*n
root = [1]
now = 0

while flag[now]:
    flag[now] = False
    now = A[now] -1
    root.append(now+1)

to_p = root.index(root[-1])
p2p = root[to_p:-1]
rooplen = len(p2p)

if k < rooplen:
    print(root[k])
else:    
    idx = (k-to_p)
    idx %= p2p_len
    print(p2p[idx])

Buggy submission (verdict: Runtime Error):

n, k = map(int, input().split())
A = map(int,input().split())
flag = [True]*n
p = 0
rt = [1]

while flag[p]:
    flag[p] = False
    p = A[p] -1
    rt.append(p+1)

to_p = rt.index(rt[-1])
p2p = rt[to_p:-1]
p2p_len = len(p2p)

if k < p2p_len:
    print(rt[k])
else:
    print(p2p[(k-to_p)%p2p_len])
Problem p02612 (python)

Fixed submission:
n = int(input())
a = n%1000
if a ==0:
    print(0)
    exit()
a = 1000-a
print(a)

Buggy submission (verdict: Runtime Error):
n = input()
a = n%1000
a = 1000-a
print(a)
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a + a * a + a * a * a)

Buggy submission (verdict: Runtime Error):

    a = int(input())

    print(a + a*a + a*a*a)
Problem p02658 (python)

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

def foo(n):
    total = 1  
    for number in n:
        total = total * number
        if total > 10**18:
            print('-1')
            return
    print(total)
if '0' in str_list :
    print(0)
else:
    foo(n)

Buggy submission (verdict: Runtime Error):
dontt_use = input()
n = map(int,list(input().split()))
total = 1
for number in n:
    total = total * number
    if total > 10**18:
        print('-1')
        return
print(total)
Problem p02812 (python)

Fixed submission:
n=int(input())
s=input()
cnt=0
i=1
while(i<n-1):
    if(s[i-1]=='A' and s[i]=='B' and s[i+1]=='C'):
        cnt+=1
    i+=1
        
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
cnt=0
i=1
while(i<n):
    if(s[i-1]=='A' and s[i]=='B' and s[i+1]=='C'):
        cnt+=1
    i+=1
        
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
cnt=0
for i in range(1,n):
  if(s[i-1]=='A' and s[i]=='B' and s[i+1]=='C'):
    cnt+=1
print(cnt)
Problem p02612 (python)

Fixed submission:
a = input()
amari = int(a)%1000
otsuri = 1000 - amari
if otsuri == 1000:
  otsuri = 0

print(otsuri)

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


amari  = a % 1000
otsuri = 1000 - amari
print(otsuri)
Problem p03494 (python)

Fixed submission:
s = int,input()
i = list(map(int,input().split()))
err = 0
total = 0
while err == 0:
    count = 0
    for nom in i:
        if nom % 2 == 1:
            err = 1
            count += 1
        else:
            i[count] = nom / 2
            count += 1
    if err == 0:
        total += 1
print(total)

Buggy submission (verdict: Runtime Error):
s = int,input()
i = list(int,input())
Problem p02612 (python)

Fixed submission:
N = int(input())
remainder = N % 1000
if remainder == 0:
  print(0)
else:
  print(1000 - remainder)

Buggy submission (verdict: Runtime Error):
N = input()
remainder = N % 1000
if remainder == 0:
  print(0)
else:
  print(1000 - remainder)

Buggy submission (verdict: Runtime Error):
N = input()
remainder = N % 1000
print(remainder)

Buggy submission (verdict: Runtime Error):
def main():
  N = input()
  remainder = N % 1000
  print(remainder)

main()
Problem p02612 (python)

Fixed submission:
taka = int(input())
remainder = taka % 1000
ans = 1000 - remainder
print(ans % 1000)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = input()
A = A.split()
A = [int(i) for i in A]
A = sorted(A, reverse = True)
ans = 0

for x in A:
	ans += x

ans -= A[n-1]

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
for v in ['AC', 'WA', 'TLE', 'RE']:
	print('{} x {}'.format(v, S.count(v)))

Buggy submission (verdict: Runtime Error):

taka = input()
remainder = taka%1000
ans = 1000 - remainder
Problem p02613 (python)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
for v in ['AC', 'WA', 'TLE', 'RE']:
	print('{0} x {1}'.format(v, S.count(v)))

Buggy submission (verdict: Runtime Error):
N = int(input)
S = [input() for i in range(n)]
for v in ['AC', 'WA', 'TLE', 'RE']:
  print('{} x {}'.format(v, s.count(v))
Problem p02658 (python)

Fixed submission:
n = int(input())
ans = 1;
tem = 0
ok = 1
s = input().split()
for i in s:
    if(int(i) == 0):
        tem = 1
        break
    if(ok == 1):
        ans *= int(i) 
        if(ans > 10**18):
            ok = 0
if(tem):
    print(0)
elif(ok):
    print(ans)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 1;
tem = 0
ok = 1
s = input().split()
for i in s:
    if(int(i) == 0):
        tem = 1
        break
    ans *= int(i) 
    if(ans > 10**18):
        ok = 0
if(tem):
    print(0)
elif(ok)
    print(ans)
else:
    print("-1")
Problem p02843 (python)

Fixed submission:
X = int(input())
N = X // 100
n = X % 100

if N == 0:
  print(0)
elif n / N > 5:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
X = int(input())
N = X // 100
n = X % 100

if n / N > 5:
  print(0)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
X = int(input())
N = X // 100
n = X % 100

if n / N > 5:
  print(0)
else:
  print(1)
Problem p02903 (python)

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

ans = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
  for j in range(A):
    ans[i][j] = 1

for i in range(B):
  for j in range(W):
    ans[i][j] ^= 1

for i in range(H):
  for j in range(W):
    print(ans[i][j], end = "")
  print()

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

ans = [[0 for _ in range(W)] for _ in range(H)]

if A == 0:
  for i in range(H):
    for j in range(W):
      if i < B:
        ans[i][j] = 1
      else:
        ans[i][j] = 0
elif B == 0:
  for i in range(H):
    for j in range(W):
      if j < A:
        ans[i][j] = 1
      else:
        ans[i][j] = 0
else:
  w, h = 0, 0
  while w < W or h < H:
    for i in range(w, min(w + B, W)):
      for j in range(h, min(h + A, H)):
        ans[i][j] = 1
    w += B
    h += A

for i in range(H):
  for j in range(W):
    print(ans[i][j], end = "")
  print()
Problem p02909 (python)

Fixed submission:
S = input()

if S == "Sunny":
  print("Cloudy")
elif S == "Cloudy":
  print("Rainy")
else:
  print("Sunny")

Buggy submission (verdict: Runtime Error):
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
for _ in range(M):
  a = A.pop(-1) // 2
  bisect.insort_left(A, a)

print(sum(A))
Problem p02918 (python)

Fixed submission:
N, K = map(int, input().split())
S = list(input())

l = []
tmp = 0
for i in range(1, N):
  if S[i - 1] != S[i]:
    l.append([tmp, i - 1, i - tmp])
    tmp = i
  if i == N - 1:
    l.append([tmp, i, i - tmp + 1])

for k in range(K):
  i = 2 * k + 1
  if i >= len(l):
    break
  if S[l[i][0]] == "L":
    S[l[i][0] : l[i][1] + 1] = "R" * l[i][2]
  else:
    S[l[i][0] : l[i][1] + 1] = "L" * l[i][2]

ans = 0
for i in range(N - 1):
  if S[i] == S[i + 1]:
    ans += 1

print(ans)

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

l = []
for i in range(N):
  if i == 0:
    tmp = i
  elif S[i - 1] != S[i]:
    l.append([tmp, i - 1, i - tmp])
    tmp = i
  elif i == N - 1:
    l.append([tmp, i, i - tmp + 1])

for k in range(K):
  i = 2 * k + 1
  if S[l[i][0]] == "L":
    S[l[i][0] : l[i][1] + 1] = "R" * l[i][2]
  else:
    S[l[i][0] : l[i][1] + 1] = "L" * l[i][2]

ans = 0
for i in range(N - 1):
  if S[i] == S[i + 1]:
    ans += 1

print(ans)

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

l = []
for i in range(N):
  if i == 0:
    tmp = i
  if S[i - 1] != S[i]:
    l.append([tmp, i - 1, i - tmp])
    tmp = i
  if i == N - 1:
    l.append([tmp, i, i - tmp + 1])
l.sort(key = lambda x:x[2], reverse = True)

for k in range(K):
  if S[l[k][0]] == "L":
    S[l[k][0] : l[k][1] + 1] = "R" * l[k][2]
  else:
    S[l[k][0] : l[k][1] + 1] = "L" * l[k][2]

ans = 0
for i in range(N):
  if S[i] == "L":
    if i != 0 and S[i - 1] == "L":
      ans += 1
  else:
    if i != N - 1 and S[i + 1] == "R":
      ans += 1

print(ans)
Problem p03006 (python)

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

ans = float("inf")

if N < 3:
  ans = 1
else:   
  for i in range(N):
    x, y = xy[i][0], xy[i][1]
    for j in range(N):
      if i == j:
        continue
      p, q = xy[j][0] - x, xy[j][1] - y
      cnt = 0
      for k in range(N):
        xk, yk = xy[k][0], xy[k][1]
        for l in range(N):
          if k == l:
            continue
          if xy[l][0] - xk == p and xy[l][1] - yk == q:
            cnt += 1
      ans = min(ans, N - cnt)
print(ans)

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

xy.sort()

ans = 0
while len(xy) > 2:
  rem_list = [[] for _ in range(N)]
  rem_cnt = 0
  rem_num = 0
  for i in range(1, N):
    p, q = xy[i][0] - xy[0][0], xy[i][1] - xy[0][1]
    cnt = 0
    for j in range(1, N):
      if p == 0 and xy[j][0] == xy[0][0] or q == 0 and xy[j][1] == xy[0][1]:
        cnt += 1
        rem_list[i].append(xy[j])
      elif p * q != 0 and (xy[j][0] - xy[0][0]) * p * (xy[j][1] - xy[0][1]) * q > 0 and (xy[j][0] - xy[0][0]) % p == 0 and (xy[j][1] - xy[0][1]) % q == 0:
        cnt += 1
        rem_list[i].append(xy[j])
    if rem_cnt < cnt:
      rem_cnt = cnt
      rem_num = i
  for r in rem_list[rem_num]:
    xy.remove(r)
  del xy[0]
  ans += 1

if len(xy) > 0:
  ans += 1
print(ans)

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

xy.sort()

ans = 0
while len(xy) > 2:
  rem_list = [[] for _ in range(N)]
  rem_cnt = 0
  rem_num = 0
  for i in range(1, N):
    p, q = xy[i][0] - xy[0][0], xy[i][1] - xy[0][1]
    cnt = 0
    for j in range(1, N):
      if p == 0 and xy[j][0] == xy[0][0] or q == 0 and xy[j][1] == xy[0][1]:
        cnt += 1
        rem_list[j].append(xy[j])
      elif p != 0 and q != 0 and (xy[j][0] - xy[0][0]) % p == 0 and (xy[j][0] - xy[0][0]) * p > 0 and (xy[j][1] - xy[0][1]) % q == 0 and (xy[j][1] - xy[0][1]) * q > 0:
        cnt += 1
        rem_list[j].append(xy[j])
    if rem_cnt < cnt:
      rem_cnt = cnt
      rem_num = i
  for r in rem_list[rem_num]:
    xy.remove(r)
  del xy[0]
  ans += 1

if len(xy) > 0:
  ans += 1
print(ans)

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

cnt = 0
while len(xy) > 0:
  tmp = xy.pop(0)
  if len(xy) == 0:
    cnt += 1
    break
  p, q = xy[0][0] - tmp[0], xy[0][1] - tmp[1]
  for l in xy:
    if p == 0 and abs(l[1] - tmp[1]) % q == 0 or q == 0 and abs(l[0] - tmp[0]) % p == 0 or abs(l[0] - tmp[0]) % p == 0 and abs(l[1] - tmp[1]) % q == 0:
      xy.remove(l)
  cnt += 1
print(cnt)
Problem p03014 (python)

Fixed submission:
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

cnt = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
  done = [0 for _ in range(W)]
  for j in range(W):
    if S[i][j] == "#":
      continue
    if done[j]:
      continue
    l = 0
    while j + l < W:
      if S[i][j + l] == "#":
        break
      l += 1
    for k in range(l):
      cnt[i][j + k] += l
      done[j + k] = 1

for j in range(W):
  done = [0 for _ in range(H)]
  for i in range(H):
    if S[i][j] == "#":
      continue
    if done[i]:
      continue
    l = 0
    while i + l < H:
      if S[i + l][j] == "#":
        break
      l += 1
    for k in range(l):
      cnt[i + k][j] += l
      done[i + k] = 1

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, cnt[i][j] - 1)
print(ans)

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

cnt = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
  done = [0 for _ in range(W)]
  for j in range(W):
    if S[i][j] == "#":
      continue
    if done[j]:
      continue
    l = 0
    while j + l < W:
      if S[i][j] == "#":
        break
      l += 1
    for k in range(l):
      cnt[i][j + k] += l
      done[j + k] = 1

for i in range(W):
  done = [0 for _ in range(H)]
  for j in range(H):
    if S[i][j] == "#":
      continue
    if done[i]:
      continue
    l = 0
    while i + l < H:
      if S[i][j] == "#":
        break
      l += 1
    for k in range(l):
      cnt[i + k][j] += l
      done[i + k] = 1

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, cnt[i][j] - 1)
print(ans)
Problem p03044 (python)

Fixed submission:
N = int(input())
to = [[] for _ in range(N)]
cost = [[] for _ in range(N)]

for _ in range(N - 1):
  a, b, w = map(int, input().split())
  a -= 1
  b -= 1
  to[a].append(b)
  to[b].append(a)
  cost[a].append(w)
  cost[b].append(w)

ans = [-1 for _ in range(N)]
queue = []
queue.append(0)
while len(queue) > 0:
  v = queue.pop(0)
  for i in range(len(to[v])):
    u = to[v][i]
    w = cost[v][i]
    if ans[u] != -1:
      continue
    ans[u] = (ans[v] + w) % 2
    queue.append(u)

for a in ans:
  print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
UVW = [list(map(int, input().split())) for _ in range(N - 1)]

UVW.sort(key = lambda x: (x[0], x[1]))
color = [2 for _ in range(N)]
color[0] = 0

def coloring(l):
  for i in range(len(l)):
    uvw = UVW[i]
    if uvw[2] % 2 == 0:
      if color[uvw[0] - 1] != 2:
        color[uvw[1] - 1] = color[uvw[0] - 1]
      elif color[uvw[1] - 1] != 2:
        color[uvw[0] - 1] = color[uvw[1] - 1]
    else:
      if color[uvw[0] - 1] != 2:
        color[uvw[1] - 1] = color[uvw[0] - 1] ^ 1
      elif color[uvw[1] - 1] != 2:
        color[uvw[0] - 1] = color[uvw[1] - 1] ^ 1

coloring(UVW)
tmp = []
cnt = 0
for i in range(N):
  if color[i] == 2:
    cnt += 1
    for uvw in UVW:
      if uvw[0] == i + 1 or uvw[1] == i + 1:
        tmp.append(uvw)
if cnt > 0:
  color[tmp[0][0] - 1] = 0
  coloring(tmp)

for c in color:
  print(c)
Problem p03050 (python)

Fixed submission:
import math

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
  if i > N / 2:
    continue
  tmp = int((N - i) / i)
  if (N - i) % i == 0 and N % tmp != 0 and tmp >= math.sqrt(N):
    ans += tmp

print(ans)

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

def make_divisors(n):
  divisors = []
  for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n // i)
  return divisors

div = make_divisors(N)
ans = 0
for d in div:
  if N // (d - 1) == N % (d - 1):
    ans += d - 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
  tmp = int((N - i) / i)
  if (N - i) % i == 0 and N % tmp != 0 and tmp >= math.sqrt(N):
    ans += tmp

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
  tmp = int((N - i) / i)
  if (N - i) % i == 0 and N % tmp != 0 and tmp >= math.sqrt(N):
    ans += tmp

print(ans)
Problem p03076 (python)

Fixed submission:
menu = [int(input()) for _ in range(5)]

cnt = 0
l = [10]
for m in menu:
  cnt += m
  mod = cnt % 10
  if mod != 0:
    cnt += 10 - mod
    l.append(mod)

cnt -= 10 - min(l)
print(cnt)

Buggy submission (verdict: Runtime Error):
menu = [int(input()) for _ in range(5)]

cnt = 0
l = []
for m in menu:
  cnt += m
  mod = cnt % 10
  if mod != 0:
    cnt += 10 - mod
    l.append(mod)

if l.count != 0:
  cnt -= 10 - min(l)
print(cnt)

Buggy submission (verdict: Runtime Error):
menu = [int(input()) for _ in range(5)]

cnt = 0
l = []
for m in menu:
  cnt += m
  mod = cnt % 10
  if mod != 0:
    cnt += 10 - mod
    l.append(mod)

cnt -= 10 - min(l)
print(cnt)