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

Fixed submission:
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [0]*n
    for i in reversed(range(n)):
        x = n//(i+1)
        now = 0
        for j in range(1,x+1):
            now += b[j*(i+1)-1]
        if a[i] != now%2:
            b[i]=1
    m = b.count(1)
    print(m)
    if not m==0:
        for i in range(n):
            if b[i]==1:
                print(str(i+1),end=" ")
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [0]*n
    for i in reversed(range(n)):
        x = n//(i+1)
        now = 0
        for j in range(1,x+1):
            now += b[k*(i+1)-1]
        if a[i] != now%2:
            b[i]=1
    print(b.count(1))
    if not m==0:
        for i in range(n):
            if b[i]==1:
                print(str(i+1),end=" ")
    
if __name__ == '__main__':
    main()
Problem p03000 (python)

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

l = [int(x) for x in input().split()]

cnt = 1
now = 0
for i in l:
    now += i
    if now>x:
        break
    cnt += 1

print(cnt)

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

l = [int(x) for x in input().split()]
import sys

sys.setrecursionlimit(20000)

def solve(now,ls,x,cnt):
    if now>x:
        return print(cnt)
    else:
        return solve(now+ls[cnt],ls,x,cnt+1)
solve(0,l,x,0)

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

l = [int(x) for x in input().split()]

def solve(now,ls,x,cnt):
    if now>x:
        return print(cnt)
    else:
        return solve(now+ls[cnt-1],ls,x,cnt+1)
solve(0,l,x,0)
Problem p03059 (python)

Fixed submission:
A,B,T = map(int,input().split())
print(int((T//A)*B))

Buggy submission (verdict: Runtime Error):
A,B,T = input().split()
print(int((T//A)*B)
Problem p03076 (python)

Fixed submission:
import numpy as np

ls = [int(input()) for _ in range(5)]


a=0
for h in ls:
    if h%10 == 0:
        pass
    else:
        re =(h//10+1)*10-h
        if re>=a:
            a = re


time = 0
for i in ls:
    if i%10 == 0:
        time += i
    else:
        time += (i//10+1)*10

time -= a
print(time)

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

ls = [int(input()) for _ in range(5)]


max_=0
for h in ls:
    if h%10 == 0:
        pass
    else:
        re =10-h
        if re>=max_:
            max_ = re

time = 0
for i in ls:
    if i%10 == 0:
        time += i
    else:
        time += (i//10+1)*10

time -= re

print(time)
Problem p03087 (python)

Fixed submission:
N,Q = map(int,input().split())
S = str(input())
l,r = [0]*Q,[0]*Q
for i in range(Q):
    l[i],r[i] = map(int,input().split())
    
count_list = []
count = 0
count_list.append(0)
for i in range(1,N):
    if S[i-1] == "A" and S[i] == "C":
        count += 1
        count_list.append(count)
    else:
        count_list.append(count)
    
for j in range(Q):
    print(count_list[r[j]-1]-count_list[l[j]-1])

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = str(input())
l,r = map(int,input().split())
count_list = []
for i in range(1,N-1):
    if S[i-1] == "A" and S[i] == "C":
        count_list.append(1)
    else:
        count_list.append(0)
    
for j in range(Q):
    sub_count = count_list[l[j]-1:r[j]-1]
    print(sum(sub_count))

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = str(input())
lr = [input().split() for i in range(Q)]
for i in range(Q):
    sub = S[int(lr[i][0])-1:int(lr[i][1])]
    A_index = [i for i,x in enumerate(sub) if x == 'A']
    count = 0
    for j in A_index:
        if i == len(sub)-1:
            pass
        elif sub[i+1] == 'C':
            count += 1
        else:
            pass
    print(count)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Thu Apr  4 14:43:20 2019

@author: fumito
"""

def create_sub(lr,S):
    sub = S[int(lr[0])-1:int(lr[1])]
    list = [i for i in sub]
    return list

def A_index(sub):
    A_index = [i for i,x in enumerate(sub) if x == 'A']
    return A_index

def count(sub,index):
    count = 0
    for i in index:
        if i == len(sub):
            pass
        elif sub[i+1] == 'C':
            count += 1
        else:
            pass
    return count

if __name__ == "__main__":
    N,Q = map(int,input().split())
    S = str(input())
    lr = [input().split() for i in range(Q)]
    
    ans = []
    for i in range(Q):
        Sub = create_sub(lr[i],S)
        Index = A_index(Sub)
        Count = count(Sub,Index)
        ans.append(Count)
    for j in ans:
        print(j)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Thu Apr  4 14:43:20 2019

@author: fumito
"""

def create_sub(lr,S):
    sub = S[int(lr[0])-1:int(lr[1])]
    list = [i for i in sub]
    return list

def A_index(sub):
    A_index = [i for i,x in enumerate(sub) if x == 'A']
    return A_index

def count(sub,index):
    count = 0
    for i in index:
        if sub[i+1] == 'C':
            count += 1
        else:
            pass
    return count

if __name__ == "__main__":
    N,Q = map(int,input().split())
    S = str(input())
    lr = [input().split() for i in range(Q)]
    
    ans = []
    for i in range(Q):
        Sub = create_sub(lr[i],S)
        Index = A_index(Sub)
        Count = count(Sub,Index)
        ans.append(Count)
    for j in ans:
        print(j)
    a = create_sub([1,4],'ACAAAC')   
    b = A_index(a)
Problem p03110 (python)

Fixed submission:
count = 0
N =int(input())
for _ in range(N):
    x, u =[_ for _ in input().split()]
    x= float(x)
    if u =='JPY':
        count += x
    else:
        count += x * 380000
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
for _ in range(n):
    x,u = map(int,input().split())
c = 0    
for i in range(n):
    if u[i] == "JPY":
        c += x[i]
    else:
        c += x[i]*380000.0
print(int(c))

Buggy submission (verdict: Runtime Error):
n = int(input())
for _ in range(n):
    x,u = map(int,input().split())
c = 0    
for i in range(n):
    if u[i] == "JPY":
        c += x[i]
    else:
        c += x[i]*380000.0
print(c)
Problem p03141 (python)

Fixed submission:
def main():
    N = int(input())
    ls = [[int(x) for x in input().split()] for _ in range(N)]
    ans = 0
    for i in range(N):
        ls[i].append(ls[i][0]+ls[i][1])
    ls = sorted(ls,key=lambda x:-x[2])
    if N==1:
        print(ls[0][1])
        exit()
    for i in range(N):
        ans -= ls[i][1]

    for i in range(N//2):
        ans += ls[2*i][2]

    if N%2==1:
        ans += ls[2*i+2][2]
    
    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    ls = [[int(x) for x in input().split()] for _ in range(N)]
    ans = 0
    for i in range(N):
        ls[i].append(ls[i][0]+ls[i][1])
    ls = sorted(ls,key=lambda x:-x[2])
    if N==1:
        print(ls[0][1])
    for i in range(N):
        ans -= ls[i][1]

    for i in range(N//2):
        ans += ls[2*i][2]

    if N%2==1:
        ans += ls[2*i+2][2]
    
    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    ls = [[int(x) for x in input().split()] for _ in range(N)]
    ans = 0
    for i in range(N):
        ls[i].append(ls[i][0]+ls[i][1])
    ls = sorted(ls,key=lambda x:-x[2])
    
    for i in range(N):
        ans -= ls[i][1]
    for i in range(N//2):
        ans += ls[2*i][2]

    if N%2==1:
        ans += ls[2*i+2][2]
    
    print(ans)
if __name__ == '__main__':
    main()
Problem p03240 (python)

Fixed submission:
n = int(input())
x = [0]*n
y = [0]*n
h = [0]*n
for i in range(n):
    x[i],y[i],h[i] = map(int,input().split())

H = max(h)
while 1:
  for i in range(101):
    for j in range(101):
      flg =True
      for k in range(n):
        dx,dy = abs(x[k]-i),abs(y[k]-j)
        if max(H-dx-dy,0)!=h[k]:
          flg = False
      if flg:
        print(i,j,H)
        exit()
  H +=1

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

H = max(h)
while 1:
  for i in range(101):
    for j in range(101):
      for k in range(n):
        dx,dy = abs(x[k]-i),abs(x[k]-j)
        if max(H-dx-dy)!=h[k]:
          break
        else:
          print(i,j,H)
          exit()
  H +=1
Problem p03244 (python)

Fixed submission:
n = int(input())
ls = [int(i) for i in input().split()]


from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(n):
    if i%2==0:
        d1[ls[i]]+=1
    else:
        d2[ls[i]]+=1


d1=sorted(d1.items(),key=lambda x:x[1],reverse=True)
d2=sorted(d2.items(),key=lambda x:x[1],reverse=True)


if d1[0][0] != d2[0][0]:
    print(n-d1[0][1]-d2[0][1])
else:
    if len(d1)==1 and len(d2)==1:
        print(min(n-d1[0][1],n-d2[0][1]))
    elif len(d1)==1 and len(d2)==2:
        print(min(n-d1[0][1]-d2[1][1],n-d2[0][1]))
    elif len(d1)==2 and len(d2)==1:
        print(min(n-d1[1][1]-d2[0][1],n-d1[0][1]))
    else:
        print(min(n-d1[1][1]-d2[0][1],n-d1[0][1]-d2[1][1]))

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


from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(n):
    if i%2==0:
        d1[ls[i]]+=1
    else:
        d2[ls[i]]+=1


d1=sorted(d1.items())
d2=sorted(d2.items())


if d1[0][0] != d2[0][0]:
    print(n-d1[0][1]-d2[0][1])
else:
    if len(d1)==1 and len(d2)==1:
        print(min(n-d1[0][1],n-d2[0][1]))
    elif:len(d1)==1 and len(d2)==2:
        print(min(n-d1[0][1]-d2[1][1],n-d2[0][1]))
    elif len(d1)==2 and len(d2)==1:
        print(min(n-d1[1][1]-d2[0][1],n-d1[0][1]))
    else:
        print(min(n-d1[1][1]-d2[0][1],n-d1[0][1]-d2[1][1]))

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


from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(n):
    if i%2==0:
        d1[ls[i]]+=1
    else:
        d2[ls[i]]+=1


d1=sorted(d1.items())
d2=sorted(d2.items())


if d1[0][0] != d2[0][0]:
    print(n-d1[0][1]-d2[0][1])
else:
    if len(d1)==1 and len(d2)==2:
        print(min(n-d1[0][1]-d2[1][1],n-d2[0][1]))
    elif len(d1)==2 and len(d2)==1:
        print(min(n-d1[1][1]-d2[0][1],n-d1[0][1]))
    else:
        print(min(n-d1[1][1]-d2[0][1],n-d1[0][1]-d2[1][1]))

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


from collections import defaultdict
d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(n):
    if i%2==0:
        d1[ls[i]]+=1
    else:
        d2[ls[i]]+=1


d1=sorted(d1.items(),reverse=True)
d2=sorted(d2.items(),reverse=True)


if d1[0][0] != d2[0][0]:
    print(n-d1[0][1]-d2[0][1])
else:
    try:
        print(min(n-d1[1][1]-d2[0][1],n-d1[0][1]-d2[1][1]))
    except:
        print(min(n-d1[0][1],n-d2[0][1])
Problem p03261 (python)

Fixed submission:
n = int(input())
w = [input()  for _ in range(n)]



def solve(n,ls):
    if n == 0:
        return "Yes"
    else:
        if ls[n-1][-1] == ls[n][0]:
            return solve(n-1,ls)
        else:
            return "No"


flg = solve(n-1,w)
if flg == "No":
    pass
else:
    if not len(w) == len(list(set(w))):
        flg ="No"

print(flg)

Buggy submission (verdict: Runtime Error):
n = int(input())
w = [str(input()) for _ in range(n)]

def solve(n,ls):
    if n == -1:
        return print("Yes")
    else:
        if ls[n][-1] == ls[n+1][0]:
            return solve(n-1,ls)
        else:
            return print("No")

solve(n,w)
Problem p03289 (python)

Fixed submission:
s = list(input())

a = [chr(i) for i in range(97, 97+26)]
A = [chr(i) for i in range(65, 65+26)]

flg = "AC"

if not s[0] == "A":
    flg = "WA"

if not s[2:-1].count("C") ==1:
    flg = "WA"

b = set(s)-set(["A","C"])

if not b<=set(a):
    flg = "WA"

print(flg)

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

flg = "AC"

if s[0] != "A":
    flg ="WA"

if {"C"}  <= set(list(s)[2:-2]):
    pass
elif list(s)[2:-2].count("C") !=1
    flg = "WA" 
else:
    flg ="WA"

a = [chr(i) for i in range(97, 97+26)]
a.append("A")
a.append("C")
if  set(list(s)) <= set(a):
    pass
else:
    flg == "WA"
    
print(flg)

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

flg = "AC"

if s[0] != "A":
    flg ="WA"

if {"C"}  <= set(list(s)[2:-2]):
    pass
elif list(s)[2:-2].count("C") !=1
    flg = "WA" 
else:
    flg ="WA"

a = [chr(i) for i in range(97, 97+26)]
a.append("A")
a.append("C")
if  set(list(s)) <= set(a):
    pass
else:
    flg == "WA"
    
print(flg)
Problem p03309 (python)

Fixed submission:
n = int(input())
a = [int(x)-i-1 for i,x in enumerate(input().split())]
a.sort()
if len(a)%2==1:
    md = a[len(a)//2]
    ans = 0
    for i in a:
        ans += abs(i-md)
    print(ans)
else:
    md1 = a[len(a)//2]
    md2 = a[len(a)//2-1]
    ans1 = 0
    ans2 = 0
    for i in a:
        ans1 += abs(i-md1)
        ans2 += abs(i-md2)
    print(min(ans1,ans2))

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

if len(a)%2==1:
    md = a[len(a)//2]
    ans = 0
    for i in a:
        ans += abs(i-md)
    print(ans)
else:
    md1 = a[len(a)//2]
    md2 = a[len(a)//2]
    ans1 = 0
    ans2 = 0
    for i in a:
        ans1 += abs(i-md1)
        ans2 += abs(i-md2)
    print(min(ans1,ans2))
Problem p03325 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    while 1:
        if a[i]%2==0:
            a[i] = int(a[i]//2)
            cnt+=1
        else:
            break
    
print(cnt)

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

def solve(n,i):
	if n%2!=0:
		return i
	else:
		return(n//2,i+1)

cnt = 0

for i in a:
	cnt +=solve(i,0)

print(cnt)
Problem p03351 (python)

Fixed submission:

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

if abs(a-c) <= d or(abs(a-b)<=d and abs(c-b)<=d):
    print('Yes')
else:
    print('No')

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

if abs(a-c) <= d or(abs(a-b)<=d and abs(c-b)<=d:
    print('Yes')
else:
    print('No')

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

if abs(a-c) <= d or(abs(a-b)<=d and abs(c-b)<=d:
	print('Yes')
else:
	print('No')
Problem p03360 (python)

Fixed submission:
abc = [int(x) for x in input().split()]
k = int(input())

m = max(abc)

for i in range(k):
    m  *= 2

print(sum(abc)+m-max(abc))

Buggy submission (verdict: Runtime Error):
abc = [input(x) for x in input().split()]
k = int(input())

m = max(abc)

for i in ragne(k):
    m  *= 2

print(sum(abc)+m-max(abc))
Problem p03363 (python)

Fixed submission:
from collections import defaultdict
def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    cumsum = [0]*(n+1)
    for i in range(1,n+1):
        cumsum[i] = cumsum[i-1]+ls[i-1]
    cnt = defaultdict(int)
    for i in cumsum:
        cnt[i] +=1
    ans = 0
    for i in cnt.values():
        if i==1:
            continue
        ans += int(i*(i-1)/2)
    print(ans)



if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
from collections import defaultdict
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0] -q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

#　aの逆元を求める
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def combination(m,k):
    res = 1
    for i in range(1,m+1):
        res = res*i%(10**9+7)
    for i in range(1,k+1):
        res = res*mod_inv(i,10**9+7)
    for i in range(1,m-k+1):
        res = res*mod_inv(i,10**9+7)
    return res%(10**9+7)

def main():
    n = int(input())
    ls = [int(x) for x in input().split()]
    ls.insert(0,0)
    cumsum = np.cumsum(ls)
    cnt = defaultdict(int)
    for i in cumsum:
        cnt[i] +=1
    ans = 0
    for i in cnt.values():
        if i==1:
            pass
        else:
            ans += combination(i,2)
    print(ans)



if __name__ == '__main__':
    main()
Problem p03386 (python)

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

result = set()

for i in range(a,min(a+k,b+1)):
    result.add(i)
for j in range(max(a,b-k+1),b+1):
    result.add(j)

for k in sorted(list(result)):
    print(k)

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

result = set()

for i in range(a,min(a+k,b+1)):
    result.add(i)
for j in arnge(max(a,b-k+1),b+1):
    result.add(j)

for k in sorted(list(result)):
    print(k)
Problem p03387 (python)

Fixed submission:
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 3*max_- sum(ls)
    print(int(cnt/2))


else:
    ls.remove(max_)
    if ls[0]%2 == ls[1]%2:
        cnt = 2*max_- sum(ls) -2
        print(int(cnt/2 +1))    
    else:
        cnt = 2*max_- sum(ls) + 1
        print(int(cnt/2 +1))

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 2*max_- sum(ls)
    print(int(cnt/2))


ls.pop(max_)
if ls[0]%2 == ls[1]%2:
    cnt = 2*max_- sum(ls) -2
    print(int(cnt/2 +1))    
else:
    cnt = 2*max_- sum(ls) + 1
    print(int(cnt/2 +1))
print(cnt)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]

if ls[0]%2 == ls[1]%2 == ls[2]%2:
    cnt = 2*max_- sum(ls)
    print(int(cnt/2))


ls.pop(max_)
if ls[0]%2 == ls[1]%2:
    cnt = 2*max_- sum(ls) -2
    print(int(cnt/2 +1))    
else:
    cnt = 2*max_- sum(ls) + 1
    print(int(cnt/2 +1))
print(cnt)

Buggy submission (verdict: Runtime Error):
a,b,c = map(int,input().split())
max_ = max([a,b,c])
ls = [a,b,c]
ls.pop(max_)

if ls[0]%2 == ls[1]%2:
    cnt = 2*max_- sum(ls) -2
    
else:
    cnt = 2*max_- sum(ls)
    
print(cnt)
Problem p03408 (python)

Fixed submission:
n = int(input())
lsn = [input() for _ in range(n)]
m = int(input())
lsm = [input() for _ in range(m)]
 
from collections import defaultdict
 
d = defaultdict(int)
 
for i in lsn:
    d[i] += 1
for j in lsm:
    d[j] -= 1
 
print(max(max(d.values()),0))

Buggy submission (verdict: Runtime Error):
n = int(input())
lsn = [input() for _ in range(n)]
m = int(input())
lsm = [input() for _ in range(m)]

from collections import defaultdict

d = defaultdict(str)

for i in lsn:
    d[i] += 1
for j in lsm:
    d[j] -= 1

cnt = 0
for k in d.values():
    if k > 0:
        cnt +=k

print(cnt)
Problem p03437 (python)

Fixed submission:
def main():
    X,Y = map(int,input().split())
    if X%Y==0:
        print(-1)
    else:
        for i in range(1,10**8):
            if (X*i)%Y != 0:
                print(X*i)
                exit()
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    X,Y = map(int,input())
    if X%Y==0:
        print(-1)
    else:
        for i in range(1,10**8):
            if (X*i)%Y != 0:
                print(X*i)
                exit()
if __name__ == "__main__":
    main()
Problem p03447 (python)

Fixed submission:
x = int(input())
a = int(input())
b = int(input())
s= x-a
print(int(s-(b*(s//b))))

Buggy submission (verdict: Runtime Error):
x = int(input())
a = int(input())
b = int(input())
s= x-a
print(int(s-s*(b*(s//b)))
Problem p03472 (python)

Fixed submission:
from collections import defaultdict
import sys
from math import ceil
input = sys.stdin.readline

def main():
    # init
    n,h = map(int,input().split())
    a,b = [0 for _ in range(n)],[0 for _ in range(n)]
    for i in range(n):
        a[i],b[i] = map(int,input().split())
    b.sort(reverse=True)
    max_a = max(a)
    # memo
    

    # ans
    ans = 0
    for i in range(n):
        if b[i]>=max_a:
            h -= b[i]
            ans += 1
        if h<=0:
            print(ans)
            exit()
    ans += ceil(h/max_a)
    print(ans)
    
if __name__ == "__main__":

    main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys
from math import ceil
input = sys.stdin.readline

def main():
    # init
    n,h = map(int,input().split())
    a,b = [0 for _ in range(n)],[0 for _ in range(n)]
    for i in range(n):
        a[i],b[i] = map(int,input().split())
    b.sort(reversed=True)
    max_a = max(a)
    # memo
    

    # ans
    ans = 0
    for i in range(n):
        if b[i]>=max_a:
            h -= b[i]
            ans += 1
        if h<=0:
            print(ans)
            exit()
    ans += ceil(h/max_a)
    print(ans)
    
if __name__ == "__main__":

    main()
Problem p03478 (python)

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

def add(n,a,b):
    ls = list(str(n))
    pl = sum([int(i) for i in ls])
    if a<= pl and pl<= b:
        return n
    else:
        return 0

flg = 0
for i in range(n+1):
    flg += add(i,a,b)

print(flg)

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

def add(n,a,b):
    ls = list(str(n))
    pl = sum([int(i) for i in ls])
    if a<= pl<= b:
        return 1
    else:
        pass

flg = 0
for i in range(n+1):
    flg += add(i,a,b)

print(flg)
Problem p03493 (python)

Fixed submission:
ls = list(input())
c = ls.count('1')
print(c)

Buggy submission (verdict: Runtime Error):
ls = lisr(input())
c = ls.count('1')
print(c)
Problem p03555 (python)

Fixed submission:
c1 = input()
c2 = input()

if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0] :
	print('YES')
	
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
c1 = input()
c2 - input()

if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0] :
	print('YES')
	
else:
	print('NO')

Buggy submission (verdict: Runtime Error):
c1 = input()
c2 - input()

if c1[0]==c2[2] and c1[1]=c2[1] and c1[2]==c2[0] :
	print('YES')
	
else:
	print('NO')
Problem p03556 (python)

Fixed submission:
n = int(input())
import sys
sys.setrecursionlimit(10**5)
def solve(i,n):
    if i**2 >n:
        return print((i-1)**2)
    else:
        return solve(i+1,n)

solve(1,n)

Buggy submission (verdict: Runtime Error):
n = int(input())
def solve(i,n):
    if i**2 >n:
        return print((i-1)**2)
    else:
        return solve(i+1,n)

solve(1,n)
Problem p03574 (python)

Fixed submission:
h,w = map(int,input().split())

ls = [[x for x in input()] for _ in range(h)]

for i in range(h):
    ls[i].append(".")
    ls[i].insert(0,".")
a = ["." for _ in range(w+2)]
ls.append(a)
ls.insert(0,a)

ans = [['#' for _ in range(w)] for _ in range(h)]

for j in range(1,h+1):
    for k in range(1,w+1):
        if ls[j][k] == ".":
            c = [ls[j-1][k-1],ls[j-1][k],ls[j-1][k+1],ls[j][k-1],ls[j][k+1],ls[j+1][k-1],ls[j+1][k],ls[j+1][k+1]]
            ans[j-1][k-1] = str(c.count("#"))

for l in ans:
    print("".join(l))

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

ls = ['.' for i in range(w)]

s.insert(0,ls)
s.insert(-1,ls)

for i in range(h+2):
    s[i].insert(0,".")
    s[i].insert(-1,".")

for j in range(1,h+1):
    for k in range(1,w+1):
        
        if s[i][j] == ".":
            ls = [ls[j-1][k-1],ls[j-1][k],ls[j-1][k+1],ls[j][k-1],ls[j][k+1],ls[j+1][k-1],ls[j+1][k],ls[j+1][k+1]]
    
            s[i][j] = ls.count("#")

ls = ls[1:h+1][1:w+1]
for l in range(h):
    print(''.join(ls[l]))
Problem p03607 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = [int(input()) for _ in range(n)]

cnt = Counter(a).values()


flg = 0
for i in cnt:
    if i%2 == 1:
        flg += 1

print(flg)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = [int(input()) for _ in range(n)]

cnt = Counter(a).value()


flg = 0
for i in cnt:
    if i%2 == 1:
        flg += 1

print(flg)
Problem p03623 (python)

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

if abs(x-a)>abs(x-b):
  print("B")
  
else:
  print("A")

Buggy submission (verdict: Runtime Error):
x,a,b = map(int,input().split())
print(min(abs(x-a),abs(x-b))