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

Fixed submission:
n,k = map(int,input().split())
a=[int(aa)-1 for aa in input().split() ]

now=0

been = [0]*n
been[0]=1
for i in range(n):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        t_stack=sum(been)
        break

start=now

been = [0]*n
been[now]=1
for i in range(n):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        period=sum(been)
        break

        
if k<=t_stack:
    now=0
    for i in range(k):
        now=a[now]
    print(now+1)
    
else:
    n_itr = (k-t_stack+period)%period
    now=start
    for i in range(n_itr):
        now=a[now]
    print(now+1)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a=[int(aa)-1 for aa in input().split() ]

been = [0]*n

now=0
been[0]=1
for i in range(k):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        t_stack=sum(been)
        break


start=now

been = [0]*n
been[now]=1
for i in range(k):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        period=sum(been)
        break

now=start
for i in range((k-(t_stack-period))%period):
    now=a[now]
print(now+1)
Problem p02687 (python)

Fixed submission:
s = input()
if s=="ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
s = input()
if s="ABC":
    print("ARC")
else:
    print("ABC")
Problem p02702 (python)

Fixed submission:
s=input()
n=len(s)
m=2019

ak10k = [(pow(10,n-k-1,m)*int(s[k]))%m for k in range(0,n)]+[0]

ruiseki=[0]*n
ruiseki[0]=ak10k[0]
for i in range(1,n):
    ruiseki[i]=(ruiseki[i-1]+ak10k[i])%2019

from collections import Counter
c = Counter(ruiseki)

ans=sum(cc*(cc-1)//2 for cc in c.values()) + c[0]

print(ans)

Buggy submission (verdict: Runtime Error):
#d
s=input()
n=len(s)

ak10k = [(pow(10,n-k-1,m)*int(s[k]))%m for k in range(0,n)]

ruiseki=[0]*n
ruiseki[0]=ak10k[0]
for i in range(1,n):
    ruiseki[i]=(ruiseki[i-1]+ak10k[i])%2019

from collections import Counter
c = Counter(ruiseki)

ans=sum(cc*(cc-1)//2 for cc in c.values()) + list(c.keys()).count(0)

print(ans)
Problem p02780 (python)

Fixed submission:
n,k = map(int,input().split())
p = [(int(i)+1)/2 for i in input().split()]


if n==k:
    print(sum(p))
else:
    sump = [0]*n
    sump[0]=p[0]
    for i in range(n-1):
        sump[i+1] = sump[i]+p[i+1]
    ans=max(sump[i+k]-sump[i] for i in range(n-k))
    print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = [(int(i)+1)/2 for i in input().split()]

sump = [0]*n
sump[0]=p[0]
for i in range(n-1):
    sump[i+1] = sump[i]+p[i+1]
ans=max(sump[i+k]-sump[i] for i in range(n-k))
print(ans)
Problem p02821 (python)

Fixed submission:
n,m=map(int,input().split())
a=sorted([int(i) for i in input().split()])
import bisect

def hantei(now):
    num=0
    for ax in a:
        bi = bisect.bisect_left(a,now-ax)
        num+= bi
#         print(now,ax,bi)
    return n**2-num

mi = a[0]*2-1
ma = a[-1]*2+1
kotae=ma
while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)<=m#なんか判定
    if which:
        ma=now
        kotae=now
    else:
        mi=now+1
kotae-=1

suma=[0]*(n+1)
suma[-2]=a[-1]
for i in range(n-2,-1,-1):
    suma[i] = suma[i+1]+a[i]
    
ans=0
kazu=0
for ax in a:
    bi = bisect.bisect_left(a,kotae-ax)
    ans+= (n-bi)*ax+suma[bi]
    kazu+=n-bi
print(ans-(kazu-m)*kotae)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=sorted([int(i) for i in input().split()])
import bisect

def hantei(now):
    num=0
    for ax in a:
        bi = bisect.bisect_left(a,now-ax)
        num+= bi
#         print(now,ax,bi)
    return n**2-num

mi = a[0]*2-1
ma = a[-1]*2+1
while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)<=m#なんか判定
    if which:
        ma=now
        kotae=now
    else:
        mi=now+1
kotae-=1

suma=[0]*(n+1)
suma[-2]=a[-1]
for i in range(n-2,-1,-1):
    suma[i] = suma[i+1]+a[i]
    
ans=0
kazu=0
for ax in a:
    bi = bisect.bisect_left(a,kotae-ax)
    ans+= (n-bi)*ax+suma[bi]
    kazu+=n-bi
print(ans-(kazu-m)*kotae)
Problem p02844 (python)

Fixed submission:
def main():
    n=int(input())
    s=input()
    ans=0
    f00=[False if str(i) in set(str(s)) else True for i in range(10)]
    f0=f00.copy()
    for i0 in range(n-2):
        if all(f0):
            break
        if not f0[int(s[i0])]:
            f1=f00.copy()
            for i1 in range(i0+1,n-1):
                if all(f1):
                    break
                if not f1[int(s[i1])]:
                    ans+=len( set( s[i1+1:] ) )
                    f1[int(s[i1])]=True
        f0[int(s[i0])]=True
    print(ans)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n=int(input())
    s=input()
    ans=0
    f00=[False if str(i) in set(str(s)) else True for i in range(10)]
    f0=f00.copy()
    for i0 in range(n-2):
        if all(f0):
            break
        if not f0[int(s[i0])]:
            f1=f00.copy()
            for i1 in range(i0+1,n-1):
                if all(f1):
                    break
                if not f1[int(s[i1])]:
                    ans+=len( set( s[i1+1:] ) )
                    f1[int(s[i1])]=True
        f0[int(s[i0])]=True
    print(ans)
if __name__ == '__main__':
    main()
Problem p02845 (python)

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

c=[0,0,0]
ans=1
mod=1000000007
out=0
for aa in a:
    if aa-1 in c:
        ans = ans*c.count(aa-1) %mod
        c[c.index(aa-1)]+=1
    else:
        out=1
        break
if out==1:
    print(0)
else:
    print(ans)

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

c=[0,0,0]
ans=1
mod=1000000007
for aa in a:
    ans = ans*c.count(aa-1) %mod
    c[c.index(aa-1)]+=1
print(ans)
Problem p02866 (python)

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

import collections
c = collections.Counter(d)

m=998244353
ans=1
if d[0]!=0 or set(d)!=set(range(len(set(d)))) or 0 in d[1:]:
    print(0)
else:
    for i in range(1,len(c)):
        ans = (ans* c[i-1]**c[i]) %m
    print(ans)

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

import numpy 
c = collections.Counter(d)

m=998244353
ans=1
if d[0]!=0 or len(set(d))!=max(d)+1 or 0 in d[1:]:
    print(0)
else:
    for i in range(1,len(c)):
        ans = ams* i**c[i] %m
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=[int(i) for i  in input().split()]
from operator import mul
from functools import reduce

def cmb(n,r,mod):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under % mod

c=[d.count(i) for i in set(d)]
m=998244353
ans=1
if d[0]!=0:
    print(0)
else:
    for i in range(1,len(c)):
        ans=ans*cmb(c[i-1]*2,c[i],m) % m
    print(ans)
Problem p02882 (python)

Fixed submission:
import math
a,b,x=map(int,input().split())
h=x/(a*a)
if 2*x>=a*a*b:
    print(math.atan((b-h)*2/a)/math.pi*180)
else:
    print(math.atan(b*b/2/a/h)/math.pi*180)

Buggy submission (verdict: Runtime Error):
import math
a,b,x=map(int,input().split())
h=x/(a*a)
if 2*x>=a*a*b:
    print(90-math.atan(a/(b-h)/2)/math.pi*180)
else:
    print(90-math.atan(2*a*h/b/b)/math.pi*180)
Problem p02888 (python)

Fixed submission:
import bisect
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        a=l[i]
        b=l[j]
        ans+=bisect.bisect_left(l,a+b,lo=j)-j-1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
l=[int(i) for i in input().split()]
l.sort()
ans=0
for i in range(n):
    for j in range(i+1,n):
        a=l[i]
        b=l[j]
        ans+=bisect.bisect_left(l,a+b,lo=j)-j-1
print(ans)
Problem p02936 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    
    n,q=map(int,input().split())
    tree=[[] for _ in range(n)]
    for i in range(n-1):
        a,b=map(int,input().split())
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)
    p=[0]*q
    x=[0]*q
    for i in range(q):
        p[i],x[i] = map(int,input().split())
        
    px=[[] for i in range(n)]
    for pp,xx in zip(p,x):
        px[pp-1].append(xx)
    px=[sum(i) for i in px]
    c=[0]*n
    flag=[True]*n
     
    from collections import deque
    q = deque([(-1,0,0)])
    while q:
        parent,child,point = q.popleft()
        if parent!=-1:
            flag[parent]=False
        point+=px[child]
        c[child]=point
        for y in tree[child]:
            if y == parent:
                continue
            if flag[y]:
                q.append((child,y,point))
    print(*c)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.readlin
    
    n,q=map(int,input().split())
    tree=[[] for _ in range(n)]
    for i in range(n-1):
        a,b=map(int,input().split())
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)
    p=[0]*q
    x=[0]*q
    for i in range(q):
        p[i],x[i] = map(int,input().split())
        
    px=[[] for i in range(n)]
    for pp,xx in zip(p,x):
        px[pp-1].append(xx)
    px=[sum(i) for i in px]
    c=[0]*n
    flag=[True]*n
     
    from collections import deque
    q = deque([(-1,0,0)])
    while q:
        parent,child,point = q.popleft()
        if parent!=-1:
            flag[parent]=False
        point+=px[child]
        c[child]=point
        for y in tree[child]:
            if y == parent:
                continue
            if flag[y]:
                q.append((child,y,point))
    print(*c)
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
n,q=map(int,input().split())
tree=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)
p=[0]*q
x=[0]*q
for i in range(q):
    p[i],x[i] = map(int,input().split())
    
px=[[] for i in range(n)]
for pp,xx in zip(p,x):
    px[pp-1].append(xx)
px=[sum(i) for i in px]
c=[0]*n
flag=[True]*n

from collections import deque
q = deque([(-1,0,0)])
while q:
    parent,child,point = q.popleft()
    if parent!=-1:
        flag[parent]=False
    point+=px[child]
    c[child]=point
    print(parent,child,point,tree[child],c)
    for y in tree[child]:
        if y == parent
            continue
        if flag[y]:
            q.append((child,y,point))
print(*c)
Problem p02972 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
b=[99]*n
for i in range(n//2,n):
    b[i]=a[i]
for i in range(n//2-1,-1,-1):
    s = sum(b[(i+1)*j-1] for j in range(2,n//(i+1)+1))
    if s%2==0:
        b[i]=a[i]
    else:
        b[i]=1-a[i]
print(sum(b))
print(*[i+1 for i in range(n) if b[i]==1])

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
a=np.array( [int(i) for i in input().split()])
b=np.array([99]*n)
for i in range(n//2,n):
    b[i]=a[i]
print(b)
for i in range(n//2,0,-1):        
    cand = np.array([i*j for j in range(2,n//i+1)])
    print(i,cand,a[cand-1])
    if sum(a[cand-1])%2==0:
        b[i-1]=a[i-1]
    else:
        b[i-1]=1-a[i-1]
posi=np.where(b==1)[0]
print(len(posi))
for j in range(len(posi))):
    print(posi[j],end=" ")
Problem p03043 (python)

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

import math
ans=0
for m in range(1,n+1):
    if m>=k:
        l=0
    else:
        l=math.ceil( math.log(k/m,2) )
    ans+=(0.50)**l /n
print(ans)

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

import math
ans=0
for m in range(1,n+1):
    if m>=k:
        l=0
    else:
        l=math.ceil( math.log2(k/m) )
    ans+=(0.50)**l /n
print(ans)
Problem p03044 (python)

Fixed submission:
#d
n=int(input())
tree=[[] for _ in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    tree[u-1].append((v-1,w))
    tree[v-1].append((u-1,w))

color=[0]*(n+1)
q = [(-1,0,0)]
while q:
    parent,x,l = q.pop()
    for y in tree[x]:
        if y[0] == parent:
            continue
        q.append((x,y[0],y[1]))
    if l%2==1:
        color[x+1]=1-color[parent+1]
    else:
        color[x+1]=color[parent+1]

for i in range(1,n+1):
    print(color[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
tree=[[] for _ in range(n)]
for i in range(n-1):
    u,v,w = map(int,input().split())
    tree[u-1].append((v-1,w))
    tree[v-1].append((u-1,w))
    
color=[0]*(n+1)
q = [(-1,0,0)]
while q:
    parent,x,l = q.pop()
    for y in tree[x]:
        if y[0] == parent:
            continue
        q.append((x,*y))
    if l%2==1:
        color[x+1]=1
for i in range(1,n+1):
    print(color[i])
Problem p03061 (python)

Fixed submission:
#c
n=int(input())
a=[int(i) for i in input().split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
l=[1]*n
r=[1]*n
l[0]=a[0]
r[0]=a[n-1]
for i in range(1,n):
    l[i] = gcd(l[i-1],a[i])
    r[i] = gcd(r[i-1],a[n-i-1])
if n>=3:
    ans = max(l[-2],r[-2],max(gcd(l[i-1],r[n-i-2]) for i in range(1,n-1)))
    print(ans)
else:
    print(max(a))

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
#a=list(set(a))
#n=len(a)

ans=0
if n==2: print(max(a))
else:
    for i in range(n):
        b=np.array([a[j] for j in np.delete(np.array(range(n)),i)]) 
        while len(b)>1:
            d=math.gcd(b[0],b[1])
            b=np.delete(b,0)
            b[0]=d
        c=b[0]
        if ans<c: ans=c
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
n=int(input())
a=[int(i) for i in input().split()]
a=list(set(a))
n=len(a)

ans=0
if n<3: print(max(a))
else:
    for i in range(n):
        b=np.array([x for x in a if not x==a[i]])
        while len(b)>1:
            d=math.gcd(b[0],b[1])
            b=np.delete(b,0)
            b[0]=d
        c=b[0]
        if ans<c: ans=c
    print(ans)

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

n=int(input())
a=np.array([int(i) for i in input().split()])

ans=0
for i in range(n):
    b=np.array([x for x in a if not x==a[i]])
    for j in range(n-2):
        d=math.gcd(b[0],b[1])
        b=np.delete(b,0)
        b[0]=d
    c=b[0]
    if ans<c: ans=c
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
import numpy as np


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


n=int(input())
a=np.array([int(i) for i in input().split()])

if n==2:print(max(a))
else:
    ans=0
    for i in range(n):
        b=np.array([x for x in a if not x==a[i]])
        c=gcd_list(b)
        if ans<c: ans=c
    print(ans)
Problem p03141 (python)

Fixed submission:
n=int( input())
a=[0]*n
b=[0]*n
for i in range(n):
    a[i],b[i] = map(int,input().split() )
c=[[a[i],b[i],a[i]+b[i]] for i in range(n)]
c.sort(reverse=True,key=lambda x:x[2])
tsum=sum(c[i*2][0] for i in range((n+1)//2))
asum=sum(c[i*2+1][1] for i in range(n//2))
print( tsum- asum )

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

d=[[a[i],b[i],a[i]+b[i]] for i in range(n)]
d.sort(reverse=True,key=lambda x:x[2])
print( sum( d[i][0] for i in range((m+1)//2) ) - sum( d[i][1] for i in range((m+1)//2,m))  )
Problem p03260 (python)

Fixed submission:
#a
A,B = map(int,input().split())
if A*B%2==1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#a
A,B = map(int,input().split)
if A*B%2==1:
    print("Yes")
else:
    print("No")
Problem p03352 (python)

Fixed submission:
x=int(input())
beki=[]
for i in range(1,33):
    for j in range(2,10):
        if (i**j<=x):
            beki.append(i**j)
print(max(beki))

Buggy submission (verdict: Runtime Error):
x=int(input())
beki=[]
for i in range(1,33):
    for j in range(2,10):
        if (i**j<x):
            beki.append(i**j)
print(max(beki))

Buggy submission (verdict: Runtime Error):
x=int(input())
beki=[]
for i in range(1,33):
    for j in range(2,10):
        beki.append(i**j)
beki.sort()
for i in range(256):
    if (beki[i] < x):
        ans=beki[i]
    else:
        break
print(ans)
Problem p03354 (python)

Fixed submission:
n,m=map(int,input().split())
p = [int(i)-1 for i in input().split() ]


tree=[[] for _ in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

from collections import deque

groups=[]
been=[0]*n
for i in range(n):
    if been[i]==0:
        group=[i]
        been[i]=1
        q = deque([(i,togo) for togo in tree[i]]) 
        while q:
            parent,x = q.popleft()
            if been[x]==1:
                continue
            been[x]=1
            group.append(x)
            for y in tree[x]:
                if y == parent:#親ノードを飛ばし
                    continue
                q.append((x,y))#子ノードを追加
        groups.append(group)

ans=0
for group in groups:
    ans+= len( set(group) & set(p[g] for g in group) )

print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
p = [int(i)-1 for i in input().split() ]

uf = UnionFind(n)
for i in range(m):
    x,y = map(int,input().split())
    uf.union(x-1,y-1)

ans=0
groups = uf.all_group_members().values()

for c in groups:
    ans+= len( set(c) & set(p[i] for i in c ) ) 
print(ans)
Problem p03436 (python)

Fixed submission:
H,W = map(int,input().split())
s = [None]*H
for i in range(H):
    s[i] = input()

from collections import deque
def cango(x,y):
    cand =[]
    if x+1<=H-1:
        cand.append((x+1,y))
    if x-1>=0:
        cand.append((x-1,y))
    if y+1<=W-1:
        cand.append((x,y+1))
    if y-1>=0:
        cand.append((x,y-1))
    return cand
    
q = deque([(-1,-1,0,0,0)]) 
been = [[False]*W for _ in range(H)]

reach=False
while q:
    x_old,y_old,x_now,y_now,time = q.popleft()
    
    cand = cango(x_now,y_now)
    
    if x_now==H-1 and y_now==W-1:
        reach=True
        break
    
    for x_new,y_new in cand:
        if not been[x_new][y_new] and s[x_new][y_new]==".":
            q.append((x_now,y_now,x_new,y_new,time+1))
            been[x_new][y_new]=True
if reach:
    print( sum(ss.count(".") for ss in s)-time-1 )
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
def cango(x,y):
    cand =[]
    if x+1<=H-1:
        cand.append((x+1,y))
    if x-1>=0:
        cand.append((x-1,y))
    if y+1<=W-1:
        cand.append((x,y+1))
    if y-1>=0:
        cand.append((x,y-1))
    return cand
    
q = deque([(-1,-1,0,0,0)]) 
been = [[False]*W for _ in range(H)]

while q:
    x_old,y_old,x_now,y_now,time = q.popleft()
    been[x_now][y_now]=True
    cand = cango(x_now,y_now)
    
    if x_now==H-1 and y_now==W-1:
        break
    
    for x_new,y_new in cand:
        if not been[x_new][y_new] and s[x_new][y_new]==".":
            q.append((x_now,y_now,x_new,y_new,time+1))

print( sum(ss.count(".") for ss in s)-time-1 )
Problem p03640 (python)

Fixed submission:
#19 Grid Coloring
h,w=map(int,input().split() )
n=int(input())
a=list(map(int,input().split()))


import numpy as np

lis=[]
for i in range(n):
    lis.extend([i+1]*a[i])

lis = np.array(lis).reshape((h,w))

for i in range(1,h,2):
    lis[i] = lis[i][::-1]

for i in range(h):
    print(*lis[i])

Buggy submission (verdict: Runtime Error):
#19 Grid Coloring
h,w=map(int,input().split() )
n=int(input())
a=list(map(int,input().split()))

import numpy as np

lis=[]
for i in range(n):
    lis.extend([i+1]*a[i])

lis = np.array(lis).reshape((h,w))

for i in range(1,h,2):
    lis[i] = lis[i][::-1]

for i in range(h):
    print(*lis[i])
Problem p03700 (python)

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

def hantei(now):
    ab=a-b
    nokori = sum(kiriage( max(0,hh-now*b) ,ab)//ab  for hh in h)
    return nokori<=now
def kiriage(x,c):
    if x%c==0:
        return x
    else:
        return (x//c+1) *c

ma = 10**9 +1
mi = 1

while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)
#     print(which,mi,now,ma)
    if which:
        ma=now
        ans=now
    else:
        mi=now+1
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
h =[0]*n
for i in range(n):
    h[i]=int(input())
def hantei(now):
    ab=a-b
    nokori = sum(kiriage( max(0,hh-now*b) ,ab)//ab  for hh in h)
    return nokori<=now
def kiriage(x,c):
    if x%c==0:
        return x
    else:
        return (x//c+1) *c

ma = 10**9//b +1
mi = 1
while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)
#     print(which,mi,now,ma)
    if which:
        ma=now
        ans=now
    else:
        mi=now+1
print(ans)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
h =[0]*n
for i in range(n):
    h[i]=int(input())
def hantei(now):
    ab=a-b
    nokori = sum(kiriage( max(0,hh-now*b) ,ab)//(ab)  for hh in h)
    return nokori<=now
def kiriage(x,c):
    if x%c==0:
        return x
    else:
        return (x//c+1) *c

ma = 10**9//b +1
mi = 1
while mi<ma:
    now=(mi+ma)//2
    which = hantei(now)
#     print(which,mi,now,ma)
    if which:
        ma=now
        ans=now
    else:
        mi=now+1
print(ans)
Problem p02683 (python)

Fixed submission:
import numpy as np

n,m,x=list(map(int,input().split()))
lis=[]
for i in range(n):
    l=list(map(int,input().split()))
    lis.append(l)


min=-1
for nnn in range(2**n):
    index=[]
    a=nnn
    for i in range(n):
        index.append(a%2)
        a//=2

    money=0
    xs=np.zeros(m)
    for i in range(n):
        if index[i]==1:
            money+=lis[i][0]
            xs+=np.array(lis[i][1:])
    if np.amin(xs)>=x:
        if min==-1:
            min=money
        elif min>money:
            min=money

print(min)

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

n,m,x=list(map(int,input().split()))
lis=[]
for i in range(n):
    l=list(map(int,input().split()))
    lis.append(l)


min=-1
for nnn in range(2**n):
    index=[]
    a=nnn
    for i in range(n):
        index.append(a%2)
        a//=2

    money=0
    xs=np.zeros(n)
    for i in range(n):
        if index[i]==1:
            money+=lis[i][0]
            xs+=np.array(lis[i][1:])
    if np.amin(xs)>=x:
        if min==-1:
            min=money
        elif min>money:
            min=money
print(min)
Problem p02694 (python)

Fixed submission:
x=int(input())
m=100
cnt=0
while x>m:
    cnt+=1
    m=(m*1.01)//1
print(str(cnt))

Buggy submission (verdict: Runtime Error):
x=int(input)
m=100
cnt=0
while x>m:
    cnt+=1
    m=(m*1.01)//1
print(str(cnt))
Problem p02715 (python)

Fixed submission:
N,K=list(map(int,input().split()))
l=[0]*(K+1)
ans=0
mod=10**9+7

for x in range(K,0,-1):
    l[x]=pow((K//x),N,mod)
    for y in range(2*x,K+1,x):
        l[x]-=l[y]
        l[x]=pow(l[x],1,mod)
    ans+=l[x]*x
    ans=pow(ans,1,mod)
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=list(map(int,input().split()))
l=[0]*(K+1)
ans=0
mod=10**9+7

for x in range(K,0,-1):
    l[x]=pow((K//x),N,mod)
    for y in range(2*x,K+1,x):
        l[x]-=l[y]
        l[x]=pow(l[i],1,mod)
    ans+=l[x]*x
    ans=pow(ans,1,mod)
print(ans)
Problem p02885 (python)

Fixed submission:
n=input().split(" ")
A=int(n[0])
B=int(n[1])
print(A-B*2 if A-B*2>=0  else 0)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
count=0
for i in range(N-1):
    if S[i]!=S[i+1]:
        count+=1
if N!=1 and S[N-2]!=S[N-1]:
    count+=1
if count==0:
    count+=1
print(count)