Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

for i in range(n):
    if a[0]<a[i]:
        up=True
        nin=a[0]
        break
    elif a[0]>a[i]:
        up=False
        break
    if i==n-1:
        print(1000)
        exit()

total=1000

for i in range(1,n-1):
    if up:
        if a[i-1]<=a[i] and a[i]>a[i+1]:
            total+=(total//nin)*(a[i]-nin)
            up=False
    else:
        if a[i-1]>=a[i] and a[i]<a[i+1]:
            nin=a[i]
            up=True
if nin<a[n-1]:
    total+=(total//nin)*(a[n-1]-nin)
print(total)

Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().split()))
ave=[0 for i in range(n-k+1)]


for i in range(n-k):
    if A[i+k]>A[i]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
A=list(map(int,input().split()))
ave=[0 for i in range(n-k+1)]

for i in range(n-k+1):
    temp=1
    for s in range(i,i+k):
        temp*=A[s]
    ave[i]=temp

for i in range(n-k):
    if ave[i+1]>ave[i]:
        print('Yes')
    else:
        print('No')

Fixed submission:
n,k=map(int,input().split())
A=list(map(int,input().split()))
ave=[0 for i in range(n-k+1)]


for i in range(n-k):
    if A[i+k]>A[i]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

for i in range(n):
    if a[0]<a[i]:
        up=True
        nin=a[0]
        break
    elif a[0]>a[i]:
        up=False
        break
    if i==n-1:
        print(1000)
        exit()

total=1000

for i in range(1,n-1):
    if up:
        if a[i-1]<=a[i] and a[i]>a[i+1]:
            total+=(total//nin)*(a[i]-nin)
            up=False
    else:
        if a[i-1]>=a[i] and a[i]<a[i+1]:
            nin=a[i]
            up=True
if nin<a[n-1]:
    total+=(total//nin)*(a[n-1]-nin)
print(total)

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

for i in range(n):
    if a[0]<a[i]:
        up=True
        nin=a[0]
        break
    elif a[0]>a[i]:
        up=False
        nin=a[i]
        break
    if i==n-1:
        print(1000)
        exit()

total=1000

for i in range(1,n-1):
    if up:
        if a[i-1]<=a[i] and a[i]>a[i+1]:
            total+=(total//nin)*(a[i]-nin)
            up=False
    else:
        if a[i-1]>=a[i] and a[i]<a[i+1]:
            nin=a[i]
            up=True
if nin<a[n-1]:
    total+=(total//nin)*(a[n-1]-nin)
print(total)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
minmax=[]
ninli=[]
naxli=[]
nin=a[0]
nax=0

for i in range(n):
    if a[0]<a[i]:
        up=True
        nin=a[0]
        break
    elif a[0]>a[i]:
        up=False
        break

total=1000

for i in range(1,n-1):
    if up:
        if a[i-1]<=a[i] and a[i]>a[i+1]:
            total+=(total//nin)*(a[i]-nin)
            up=False
    else:
        if a[i-1]>=a[i] and a[i]<a[i+1]:
            nin=a[i]
            up=True
if nin<a[n-1]:
    total+=(total//nin)*(a[n-1]-nin)
print(total)

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

for i in range(n):
    if a[0]<a[i]:
        up=True
        nin=a[0]
        break
    elif a[0]>a[i]:
        up=False
        nin=a[i]
        break
    if i==n-1:
        print(1000)
        exit()

total=1000

for i in range(1,n-1):
    if up:
        if a[i-1]<=a[i] and a[i]>a[i+1]:
            total+=(total//nin)*(a[i]-nin)
            up=False
    else:
        if a[i-1]>=a[i] and a[i]<a[i+1]:
            nin=a[i]
            up=True
if nin<a[n-1]:
    total+=(total//nin)*(a[n-1]-nin)
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N=int(input())
ans=[0 for i in range(N)]

for n in range(N):
    nax=int(math.sqrt(n))
    for x in range(1,nax):
        for y in range(1,x+1):
            for z in range(1,y+1):
                temp=x**2+y**2+z**2+x*y+y*z+z*x
                if temp==n+1:
                    ans[n]+=1
                    if x==y and y!=z:
                        ans[n]+=2
                    if y==z and x!=y:
                        ans[n]+=2
                    if x==z and y!=x:
                        ans[n]+=2
                    if x!=y and y!=z and z!=x:
                        ans[n]+=5

for anss in ans:
    print(anss)


Fixed submission:
import math
N=int(input())
ans=[0 for i in range(N)]

nax=int(math.sqrt(N))

for x in range(1,nax):
    for y in range(1,x+1):
        for z in range(1,y+1):
            temp=x**2+y**2+z**2+x*y+y*z+z*x
            if temp<=N:
                if x==y and y!=z:
                    ans[temp-1]+=3
                elif y==z and z!=x:
                    ans[temp-1]+=3
                elif z==x and x!=y:
                    ans[temp-1]+=3
                elif x==y==z:
                    ans[temp-1]+=1
                elif x!=y and y!=z and z!=x:
                    ans[temp-1]+=6

                
                
for anss in ans:
    print(anss)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
bcs=[list(map(int,input().split())) for i in range(Q)]
total=sum(A)
c=collections.Counter(A)
ans=[0 for i in range(Q)]




for i in range(Q):
    B=bcs[i][0]
    C=bcs[i][1]
    if c[B]!=0:
        tempcounterpl=collections.Counter([C for j in range(c[B])])
        total=total+c[B]*(C-B)
        ans[i]=total
        c[B]=0
        c=c+tempcounterpl
    else:
        ans[i]=total
for i in range(Q):
    print(ans[i])

Fixed submission:
import collections

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
bcs=[list(map(int,input().split())) for i in range(Q)]
total=sum(A)
c=collections.Counter(A)
ans=[0 for i in range(Q)]


for i in range(Q):
    B=bcs[i][0]
    C=bcs[i][1]
    if c[B]!=0:
        total+=c[B]*(C-B)
        ans[i]=total
        c[C]+=c[B]
        c[B]=0
    else:
        ans[i]=total
for i in range(Q):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
def product(list):
    i=1
    for j in list:
        if j!=0:
            i*=j
        else:
            return 0
    return i
 
N=int(input())
A=list(map(int,input().split()))

ans=product(A)
if ans>10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=1
flag=True
if 0 in A:
    print(0)
else:
    for j in A:
        ans*=j
        if ans>10**18:
            print(-1)
            flag=False
            break
    if flag:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def product(list):
    i=1
    for j in list:
        i*=j
    return i

N=int(input())
A=list(map(int,input().split()))
ans=product(A)
if ans>10**18:
    print(-1)
else:
    print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=1
flag=True
if 0 in A:
    print(0)
else:
    for j in A:
        ans*=j
        if ans>10**18:
            print(-1)
            flag=False
            break
    if flag:
        print(ans)
Buggy python submission (verdict: Runtime Error):
A,B=map(str,input().split())
A=int(A)
B=list(B)
if len(B)<=2:
    B.append('0')
    B.append('0')
elif B[-3]=='.':
        B.remove('.')
elif B[-2]=='.' :
    B.remove('.')
    B.append('0')
else:
    B.append('0')
    B.append('0')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
ans.pop(len(ans)-1)
ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)


Fixed submission:
A,B=map(str,input().split())
A=int(A)
B=list(B)
if len(B)<=2:
    B.append('0')
    B.append('0')
elif B[-3]=='.':
        B.remove('.')
elif B[-2]=='.' :
    B.remove('.')
    B.append('0')
else:
    B.append('0')
    B.append('0')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
if len(ans)<=2:
    ans='0'
else:
    ans.pop(len(ans)-1)
    ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)

Buggy python submission (verdict: Runtime Error):
A,B=map(str,input().split())
A=int(A)
B=list(B)
if '.' in B:
    B.remove('.')
else:
    B.append('0')
    B.append('0')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
ans.pop(len(ans)-1)
ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)

Fixed submission:
A,B=map(str,input().split())
A=int(A)
B=list(B)
if len(B)<=2:
    B.append('0')
    B.append('0')
elif B[-3]=='.':
        B.remove('.')
elif B[-2]=='.' :
    B.remove('.')
    B.append('0')
else:
    B.append('0')
    B.append('0')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
if len(ans)<=2:
    ans='0'
else:
    ans.pop(len(ans)-1)
    ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)

Buggy python submission (verdict: Runtime Error):
A,B=map(str,input().split())
A=int(A)
B=list(B)
B.remove('.')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
ans.pop(len(ans)-1)
ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)

Fixed submission:
A,B=map(str,input().split())
A=int(A)
B=list(B)
if len(B)<=2:
    B.append('0')
    B.append('0')
elif B[-3]=='.':
        B.remove('.')
elif B[-2]=='.' :
    B.remove('.')
    B.append('0')
else:
    B.append('0')
    B.append('0')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
if len(ans)<=2:
    ans='0'
else:
    ans.pop(len(ans)-1)
    ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M=map(int, input().split())
H=list(map(int,input().split()))
List=[list(map(int,input().split())) for i in range(M)]
ans=0
alllist=[[0 for i in range(N)]for j in range(N)]

for j in range(M):
    alllist[List[j][0]-1][List[j][1]-1]=1
    alllist[List[j][1]-1][List[j][0]-1]=1


for s in range(N):
    flag=True
    for t in range(N):
        if H[s]>alllist[s][t]*H[t]:
            a=1
        else:
            flag=False   
            break
    if flag:
        ans=ans+1
print(ans)  

Fixed submission:
N,M=map(int, input().split())
H=list(map(int,input().split()))
List=[list(map(int,input().split())) for i in range(M)]

sup_list=[1 for i in range(N)]

for j in range(M):
    if H[List[j][0]-1]>H[List[j][1]-1]:
        sup_list[List[j][1]-1]=0
    elif H[List[j][0]-1]==H[List[j][1]-1]:
        sup_list[List[j][0]-1]=0
        sup_list[List[j][1]-1]=0
    else:
        sup_list[List[j][0]-1]=0


print(sum(sup_list))

Buggy python submission (verdict: Runtime Error):
N,M=map(int, input().split())
H=list(map(int,input().split()))
List=[list(map(int,input().split())) for i in range(M)]
ans=0
alllist=[[0 for i in range(N)]for j in range(N)]

for j in range(M):
    alllist[List[j][0]-1][List[j][1]-1]=1
    alllist[List[j][1]-1][List[j][0]-1]=1


for s in range(M):
    flag=True
    for t in range(M):
        if H[s]<alllist[s][t]*H[t]:
            flag=False
            break
    if flag:
        ans=ans+1

print(ans)  

Fixed submission:
N,M=map(int, input().split())
H=list(map(int,input().split()))
List=[list(map(int,input().split())) for i in range(M)]

sup_list=[1 for i in range(N)]

for j in range(M):
    if H[List[j][0]-1]>H[List[j][1]-1]:
        sup_list[List[j][1]-1]=0
    elif H[List[j][0]-1]==H[List[j][1]-1]:
        sup_list[List[j][0]-1]=0
        sup_list[List[j][1]-1]=0
    else:
        sup_list[List[j][0]-1]=0


print(sum(sup_list))
Buggy python submission (verdict: Runtime Error):
K=int(input())
A,B=map(int,input().split())
flag=True
for i in range(A:B+1):
    if i%K==0:
        print("OK")
        flag=False
        break
if flag:
    print("NG")

Fixed submission:
K=int(input())
A,B=map(int,input().split())
flag=True
for i in range(A,B+1):
    if i%K==0:
        print("OK")
        flag=False
        break
if flag:
    print("NG")
Buggy python submission (verdict: Runtime Error):
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
List=[list(map(int,input().split())) for i in range(M)]
minn=min(a)+min(b)

table=[[a[i]+b[j] for i in range(A)]for j in range(B)]
for i in range(M):
    minn=min(minn,table[List[i][0]-1][List[i][1]-1]-List[i][2])

print(minn)

Fixed submission:
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
List=[list(map(int,input().split())) for i in range(M)]
minn=min(a)+min(b)

for i in range(M):
    minn=min(minn,a[List[i][0]-1]+b[List[i][1]-1]-List[i][2])

print(minn)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=[]
places=[]
for i in range(N):
    inp=input()
    X.append(inp)
    places.append(X.count(inp))
ans=[]
mode=max(places)
for j in range(N):
    if places[j]==mode:
        ans.append(X[j])
ans.sort()
for a in ans:
    print(a)


Fixed submission:
import collections
N=int(input())
X=[input().strip() for i in range(N)]

cc=collections.Counter(X)
maximum=max(cc.values())

ans=sorted([ss[0] for ss in cc.items() if ss[1]==maximum])
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
X=[]
places=[]
for i in range(N):
    inp=input()
    X.append(inp)
    places.append(X.count(inp))
ans=[]
for j in range(N):
    if places[j]==max(places):
        ans.append(X[j])
ans.sort()
for a in ans:
    print(a)

Fixed submission:
import collections
N=int(input())
X=[input().strip() for i in range(N)]

cc=collections.Counter(X)
maximum=max(cc.values())

ans=sorted([ss[0] for ss in cc.items() if ss[1]==maximum])
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
flag=True
inList=list(map(int,input().split()))
for i in range(len(inList)):
    for j in range(i+1,len(inList)):
        if inList[j]==inList[i]:
            print('NO')
            flag=False
            break
    if not flag:
        break

if flag:
    print('YES')

Fixed submission:
from collections import Counter
N=int(input())
flag=True
inList=list(map(int,input().split()))

c=Counter(inList)
cv=list(c.values())
for i in cv:
    if i!=1:
        print('NO')
        flag=False
        break
if flag:
    print('YES')

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
flag=True
inList=list(map(int,input().split()))
List=[]
for a in inList:
    for numbers in List:
        if numbers==a:
            print('NO')
            flag=False
            break
    if flag:
        List.append(a)
    else:
        break

if flag:
    print('YES')

Fixed submission:
from collections import Counter
N=int(input())
flag=True
inList=list(map(int,input().split()))

c=Counter(inList)
cv=list(c.values())
for i in cv:
    if i!=1:
        print('NO')
        flag=False
        break
if flag:
    print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
List=list(map(int,input().split()))
ans=0
for i in range(N):
    if min(List[:i+1])==List[i]:
        ans+=1
print(ans)

Fixed submission:
N=int(input())
ans=0
champ=10**6
for p in list(map(int,input().split())):
    if p<champ:
        ans+=1
        champ=p

print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
acs=[0 for i in range(N)]
wa=[0 for i in range(N)]

for  i in range(M):
    p,S=map(str,input().split())
    p=int(p)
    if S=='AC':
        acs[p-1]=1
    elif S=='WA' and acs[p-1]==0: 
        wa[p-1]+=1
for i in range(M):
    if acs[i]==0:
        wa[i]=0
ans=[sum(acs),sum(wa)]


Fixed submission:
N,M=map(int,input().split())
acs=[0 for i in range(N)]
wa=[0 for i in range(N)]

for  i in range(M):
    p,S=map(str,input().split())
    p=int(p)
    if S=='AC':
        acs[p-1]=1
    elif S=='WA' and acs[p-1]==0: 
        wa[p-1]+=1
for i in range(N):
    if acs[i]==0:
        wa[i]=0
ans=[sum(acs),sum(wa)]
print(*ans)
Buggy python submission (verdict: Runtime Error):
S=list(str(input()))
ans=0
sofar=0
j=1
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        ans+=j
        j+=1
    elif S[i]=='<' and S[i+1]=='>':
        ans+=j
        nax=j
        j=1    
    else:
        ans+=j
        if nax!=0:
            ans-=j
        j=1
        nax=0
    if j>nax:
        ans-=nax
        nax=0
ans+=j
print(ans)

Fixed submission:
S=list(str(input()))
ans=0
sofar=0
j=1
nax=0
for i in range(len(S)-1):
    if S[i]==S[i+1]:
        ans+=j
        j+=1
    elif S[i]=='<' and S[i+1]=='>':
        ans+=j
        nax=j
        j=1    
    else:
        ans+=j
        if nax!=0:
            ans-=j
        j=1
        nax=0
    if j>nax:
        ans-=nax
        nax=0
if j>nax:
    ans+=j
    ans-=nax
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
sqn=math.floor(math.sqrt(N))

for fac in reversed(range(sqn)):
    if N%fac==0:
        print(int(fac+N/fac-2))
        break

Fixed submission:
import math
N=int(input())
sqn=math.floor(math.sqrt(N))

for fac in reversed(range(sqn+1)):
    if N%fac==0:
        print(int(fac+N/fac-2))
        break
Buggy python submission (verdict: Runtime Error):
N,K=map(int, input().split())
List=list(map(int,input().split())) 
print(sum(1 for x in List if x>=K))

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=[0 for i in range(N)]

for a in range(N):
    ans[A[a]-1]=a+1

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int, input().split())

points=[K for i in range(N)]

for i in range(Q):
    temp=int(input())
    points=[j-1 for j in points]
    points[temp-1]+=1

for p in points:
    if p>0:
        print('Yes')
    else:
        print('No')

Fixed submission:
import collections

N,K,Q=map(int, input().split())
List=[int(input()) for i in range(Q)]
cc=collections.Counter(List)

points=[K-Q for i in range(N)]
for j in range(N):
    points[j]+=cc[j+1]

for p in points:
    if p>0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
d=0
i=0
ans=0

while d<=X:
    ans+=1
    d+=L[i]
    i+=1


print(ans)


Fixed submission:
N,X=map(int,input().split())
L=list(map(int,input().split()))
d=0
i=0
ans=0


while d<=X:
    ans+=1
    d+=L[i]
    i+=1
    if i==N:
        if d<=X:
            ans+=1
        break


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
cards=[i for i in range(n)]
for j in range(m):
    l,r=map(int,input().split())
    for i in range(l-1):
        cards[i]=-1
    for i  in range(r,n):
        cards[i]=-1

ans=sum(1 for cars in cards if cars>=0)
print(ans)

Fixed submission:
n,m=map(int,input().split())
l=[]
r=[]
for j in range(m):
    templ,tempr=map(int,input().split())
    l.append(templ)
    r.append(tempr)
ans=min(r)-max(l)+1
if ans<0:
    ans=0
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=map(int,input().split())
ans=0
naxR=N//R
naxG=N//G
for r in range(naxR+1):
    for g in range(naxG+1):
        if (N-r*R-g*G)/B>=0 and (N-r*R-g*G)%B==0:
            ans+=1
print(ans)

Fixed submission:
R,G,B,N=map(int,input().split())
ans=0
naxR=N//R
naxG=N//G
for r in range(naxR+1):
    for g in range(naxG+1):
        if (N-r*R-g*G)/B>=0 and (N-r*R-g*G)%B==0:
            ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K=map(int,input().split())

for i in range(A,B+1):
    if abs(A-i)<K or abs(B-i)<K:
        print(i)

Fixed submission:
A,B,K=map(int,input().split())
if B-A>=2*K:
    for i in range(A,A+K-1+1):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)
    exit()
else:
    for i in range(A,B+1):
        print(i)
Buggy python submission (verdict: Runtime Error):
N=list(str(input()))
ans=0
if len(N)==1:
    print(int(N[0]))
    exit()
for i in range(1,len(N)):
    if N[i]!='9':
        ans+=int(N[0])-1
        ans+=(len(N)-1)*9
        print(ans)
        exit()
for i in range(N):
    ans+=int(N[i])
print(ans)
        

Fixed submission:
N=list(str(input()))
ans=0
if len(N)==1:
    print(int(N[0]))
    exit()
for i in range(1,len(N)):
    if N[i]!='9':
        ans+=int(N[0])-1
        ans+=(len(N)-1)*9
        print(ans)
        exit()
for i in range(len(N)):
    ans+=int(N[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
N=list(str(input()))
ans=0
for i in range(1,len(N)):
    if N[i]!='9':
        ans+=int(N[0])-1
        ans+=(len(N)-1)*9
        print(ans)
        exit()
for i in range(N):
    ans+=int(N[i])
print(ans)
        

Fixed submission:
N=list(str(input()))
ans=0
if len(N)==1:
    print(int(N[0]))
    exit()
for i in range(1,len(N)):
    if N[i]!='9':
        ans+=int(N[0])-1
        ans+=(len(N)-1)*9
        print(ans)
        exit()
for i in range(len(N)):
    ans+=int(N[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
N=list(str(input()))
ans=0
for i in range(1,N):
    if N[i]!='9':
        ans+=int(N[0])-1
        ans+=(len(N)-1)*9
        print(ans)
        exit()
for i in range(N):
    ans+=int(N[i])
print(ans)
        

Fixed submission:
N=list(str(input()))
ans=0
if len(N)==1:
    print(int(N[0]))
    exit()
for i in range(1,len(N)):
    if N[i]!='9':
        ans+=int(N[0])-1
        ans+=(len(N)-1)*9
        print(ans)
        exit()
for i in range(len(N)):
    ans+=int(N[i])
print(ans)
Buggy python submission (verdict: Runtime Error):


H,W=map(int,input().split())

c=[list(str(input())) for i in range(H)]
#1<=sy<=R
d=[[0 for j in range(W)]for i in range(H)]
inf=10**6
ans=0
for i in range(H):
    for j in range(W):
        if c[i][j]=='#':
            d[i][j]=-1
        else:
            d[i][j]=inf
            ans+=1


d[0][0]=0
queue=collections.deque([[0,0]])
gy,gx=H-1,W-1

moves=[[1,0],[-1,0],[0,1],[0,-1]]

flag=False
while len(queue)>0:
    now=queue.popleft()
    for i in range(4):
        ny=now[0]+moves[i][0]
        nx=now[1]+moves[i][1]
        
        if 0<=ny and ny<H and 0<=nx and nx<W and c[ny][nx]=='.' and d[ny][nx]==inf:
            d[ny][nx]=d[now[0]][now[1]]+1
            queue.append([ny,nx])
            if ny==gy and nx==gx:
                print(ans-d[ny][nx]-1)
                exit()
print(-1)     

Fixed submission:
import collections
import math


H,W=map(int,input().split())

c=[list(str(input())) for i in range(H)]
#1<=sy<=R
d=[[0 for j in range(W)]for i in range(H)]
inf=10**6
ans=0
for i in range(H):
    for j in range(W):
        if c[i][j]=='#':
            d[i][j]=-1
        else:
            d[i][j]=inf
            ans+=1


d[0][0]=0
queue=collections.deque([[0,0]])
gy,gx=H-1,W-1

moves=[[1,0],[-1,0],[0,1],[0,-1]]

flag=False
while len(queue)>0:
    now=queue.popleft()
    for i in range(4):
        ny=now[0]+moves[i][0]
        nx=now[1]+moves[i][1]
        
        if 0<=ny and ny<H and 0<=nx and nx<W and c[ny][nx]=='.' and d[ny][nx]==inf:
            d[ny][nx]=d[now[0]][now[1]]+1
            queue.append([ny,nx])
            if ny==gy and nx==gx:
                print(ans-d[ny][nx]-1)
                exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=list(map(int,input().split()))

nin=min(a)
nax=max(a)
ans=0
for x in range(nin,nax+1):
    temp=[]
    for i in range(N):
        tt=abs(a[i]-x)
        if -1<=tt and tt<=1:
            temp.append(1)
    ans=max(ans,sum(temp))

print(ans)


Fixed submission:
import collections
N=int(input())
a=list(map(int,input().split()))

for i in range(N):
    a.append(a[i]-1)
    a.append(a[i]+1)

cc=collections.Counter(a)
ans=max(list(cc.values()))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
a=[]
for i in range(N):
    a.append(int(input()))
ans=0
position=1
visited=[1]
while position!=2: 
    position=a[position-1]
    if position in visited:
        ans=-1
        break
    else:
        visited.append(position)
        ans+=1


print(ans)

Fixed submission:
N=int(input())
a=[]
for i in range(N):
    a.append(int(input()))
ans=0
position=1
flag=True
for i in range(N):
    if position==2:
        print(ans)
        flag=False
        break 
    else:
        position=a[position-1]
        ans+=1

if flag:
    print(-1)