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

Fixed submission:
n,m=map(int,input().split())
l=list(input().split() for _ in range(m))
l=sorted(l,key=lambda x:x[0])
import itertools
lll=[]
for (k,g) in itertools.groupby(l,key=lambda x:x[0]):
    lll.append(list(g))
a=0
w=0
for i in range(len(lll)):
    for j in lll[i]:
        if j[1]=="AC":
            a+=1
            w+=lll[i].index(j)
            break
print(a,w)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=list(input().split() for _ in range(m))
l=sorted(l,key=lambda x:x[0])
ll=[l[i][0] for i in range(m)]
import itertools
for (k,g) in itertools.groupby(l,key=lambda x:x[0]):
    lll.append(list(g))
a=0
w=0
for i in range(len(lll)):
    for j in lll[i]:
        if j[1]=="WA":
            w+=1
        elif j[1]=="AC":
            a+=1
            break
print(a,w)
Problem p02811 (python)

Fixed submission:
n,k=map(int,input().split())
g=500*n
if g>=k:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
c=list(map(int,input().split()))
c.sort(reverse=True)
res=0
ans=0
mod=10**9+7
p=pow(2,n*2-2,mod)
for i in range(n):
   ans+=(c[i]*(i+2)%mod)*p
prit(ans%mod)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
import fractions
lmc=a[0]
for i in range(1,n):
    lmc=lmc*a[i]//fractions.gcd(lmc,a[i])
    if lmc>m:
        print("0")
        exit()
if i in range(n):
   if (lmc//a[i])%2==0:
      print("0")
      exit()
if (m%lmc)<lmc//2:
    print((m//lmc))
else:
    print((m//lmc)+1)
Problem p02813 (python)

Fixed submission:
from itertools import permutations
n=int(input())
a=tuple(map(int, input().split())) 
b=tuple(map(int, input().split())) 
l=list(i for i in permutations(range(1,n+1)))
print(abs((l.index(a))-(l.index(b))))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
n=int(input())
a=list(map(int, input().split())) 
b=list(map(int, input().split())) 
l=list(permutations(a)))
print(abs((l.find(a))-(l.find(b))))

Buggy submission (verdict: Runtime Error):
from itertools import permutations
a=list(map(int, input().split())) 
b=list(map(int, input().split())) 
l=list(permutations(a)))
print(abs((l.find(a))-(l.find(b))))
Problem p02814 (python)

Fixed submission:
n,m=map(int,input().split())
a = [int(x)//2 for x in input().split()]
import fractions
lmc=a[0]
for i in range(1,n):
    lmc=lmc*a[i]//fractions.gcd(lmc,a[i])
    if lmc>m:
        print("0")
        exit()
for i in range(n):
   if (lmc//a[i])%2==0:
      print("0")
      exit()
if (m//lmc)%2==0:
    print((m//lmc)//2)
else:
    print(((m//lmc)+1)//2)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
import fractions
lmc=a[0]
for i in range(1,n):
    lmc=lmc*a[i]//fractions.gcd(lmc,a[i])
    if lmc>m:
        print("0")
        exit()
if i in range(n):
   if (lmc//a[i])%2==0:
      print("0")
      exit()
if (m%lmc)<lmc//2:
    print((m//lmc))
else:
    print((m//lmc)+1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
import fractions
lmc=a[0]
for i in range(1,n):
    lmc=lmc*a[i]//fractions.gcd(lmc,a[i])
    if lmc>m:
        print("0")
        exit()
if i in range(n):
   if (lmc//a[i])%2==0:
   print("0")
   exit()
if (m%lmc)<lmc//2:
    print((m//lmc))
else:
    print((m//lmc)+1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=list(map(int,input().split()))
import fractions
lmc=a[0]
for i in range(1,n):
    lmc=lmc*a[i]//fractions.gcd(lmc,a[i])
    if lmc>m:
        print("0")
        exit()
if i in range(n):
   if (lmc//a[i])%2==0
   print("0")
   exit()
if (m%lmc)<lmc//2:
    print((m//lmc))
else:
    print((m//lmc)+1)
Problem p03433 (python)

Fixed submission:
n=int(input())
a=int(input())
m=n%500-a
if m<=0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
from collections import deque
H,W=map(int,input().split())
white=0
s=[]
for y in range(H):
    line=input()
    white+=line.count('.')
    s.append(list(line))

q = deque([(0,0,1)])
q_append=q.append
q_popleft=q.popleft
while q:
    x,y,l=q_popleft()
    if s[y][x]!='.':
        continue
    if x==W-1 and y==H-1:
        print(white-l)
        break
    s[y][x]='*'
    for d in [(1,0),(0,1),(-1,0),(0,-1)]:
        nx, ny=(x+d[0],y+d[1])
        if 0<=nx<W and 0<=ny<H:
            q_append((nx,ny,l+1))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
    from collections import deque
    H,W=map(int,input().split())
    white=0
    s=[]
    for y in range(H):
        line=input()
        white+=line.count('.')
        s.append(list(line))
     
    q = deque([(0,0,1)])
    q_append=q.append
    q_popleft=q.popleft
    while q:
        x,y,l=q_popleft()
        if s[y][x]!='.':
            continue
        if x==W-1 and y==H-1:
            print(white-l)
            break
        for d in [(1,0),(0,1),(-1,0),(0,-1)]:
            nx, ny=(x+d[0],y+d[1])
            if 0<=nx<W and 0<=ny<H:
                q_append((nx,ny,l+1))
    else:
        print(-1)

Buggy submission (verdict: Runtime Error):
l1=list(map(int,input().split()))
l2=list(map(int,input().split()))
l3=list(map(int,input().split()))
l=[l1,l2,l3]
for i in range(3):
    for j in range(3):
        l[i][j] -=l[0][0]
if (l[1][1]==l[0][1]+l[1][0]) and (l[2][1]==l[0][1]+l[2][0]) and (l[1][2]==l[0][2]+l[1][0])and (l[2][2]==l[2][0]+l[0][2]):
    print('Yes')
else:
    print("No")
Problem p03434 (python)

Fixed submission:
n=int(input())
l=(list(map(int,input().split()))) 
l.sort(reverse=True)
for i in range(n):
    if i%2==1:
        l[i]=-l[i]
print(sum(l))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int,input().split())).sort()
for i in range(n):
    if i%2==1:
        l[i]=(-1)*l[i]
print(sum(l))
Problem p03436 (python)

Fixed submission:
from collections import deque
H,W=map(int,input().split())
white=0
s=[]
for y in range(H):
    line=input()
    white+=line.count('.')
    s.append(list(line))

q = deque([(0,0,1)])
q_append=q.append
q_popleft=q.popleft
while q:
    x,y,l=q_popleft()
    if s[y][x]!='.':
        continue
    if x==W-1 and y==H-1:
        print(white-l)
        break
    s[y][x]='*'
    for d in [(1,0),(0,1),(-1,0),(0,-1)]:
        nx, ny=(x+d[0],y+d[1])
        if 0<=nx<W and 0<=ny<H:
            q_append((nx,ny,l+1))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
H,W=map(int,input().split())
white=0
s=[]
for y in range(H):
   line=input()
    white+=line.count('.')
    s.append(list(line))
     
q = deque([(0,0,1)])
q_append=q.append
q_popleft=q.popleft
while q:
    x,y,l=q_popleft()
    if s[y][x]!='.':
        continue
    if x==W-1 and y==H-1:
        print(white-l)
        break
    s[y][x]='*'
    for d in [(1,0),(0,1),(-1,0),(0,-1)]:
        nx, ny=(x+d[0],y+d[1])
        if 0<=nx<W and 0<=ny<H:
            q_append((nx,ny,l+1))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
H,W=map(int,input().split())
white=0
s=[]
for y in range(H):
   line=input()
    white+=line.count('.')
    s.append(list(line))
     
q = deque([(0,0,1)])
q_append=q.append
q_popleft=q.popleft
while q:
    x,y,l=q_popleft()
    if s[y][x]!='.':
        continue
    if x==W-1 and y==H-1:
        print(white-l)
        break
    s[y][x]='*'
    for d in [(1,0),(0,1),(-1,0),(0,-1)]:
        nx, ny=(x+d[0],y+d[1])
        if 0<=nx<W and 0<=ny<H:
            q_append((nx,ny,l+1))
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
    from collections import deque
    H,W=map(int,input().split())
    white=0
    s=[]
    for y in range(H):
        line=input()
        white+=line.count('.')
        s.append(list(line))
     
    q = deque([(0,0,1)])
    q_append=q.append
    q_popleft=q.popleft
    while q:
        x,y,l=q_popleft()
        if s[y][x]!='.':
            continue
        if x==W-1 and y==H-1:
            print(white-l)
            break
        for d in [(1,0),(0,1),(-1,0),(0,-1)]:
            nx, ny=(x+d[0],y+d[1])
            if 0<=nx<W and 0<=ny<H:
                q_append((nx,ny,l+1))
    else:
        print(-1)
Problem p03447 (python)

Fixed submission:
x,a,b=map(int,[input() for i in range(3)])
print((x-a)%b)

Buggy submission (verdict: Runtime Error):
a,b,c,x=map(int,[input() for i in range(4)])

ans=0
for p in range(a+1): 
    for q in range(b+1):
        for r in range(c+1):
            if 500*p+100*q+50*r==x:
                ans=ans+1
print(ans)
Problem p03448 (python)

Fixed submission:
a,b,c,x=map(int,[input() for i in range(4)])

ans=0
for p in range(a+1): 
    for q in range(b+1):
        for r in range(c+1):
            if 500*p+100*q+50*r==x:
                ans=ans+1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,x=map(int,[input() for i in range(4)])

ans=0
for p in range(a+1): 
    for q in range(b+1):
        for r in range(c+1):
            if 500*p+100*q+50*r=x:
                ans=ans+1
print(ans)
Problem p03449 (python)

Fixed submission:
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
i=1
ans=0
while i<n+1:
    ans=max(sum(a1[0:i])+sum(a2[i-1:n]),ans)
    i=i+1
else:
    print(ans)

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

i=1
ans=0
while i<n+1:
    ans=max(sun(a1[0:i]+a2[i-1:n]),ans)
    i=i+1
else: 
    print(ans)
Problem p03457 (python)

Fixed submission:
n=int(input())

from numpy import array

i=0
o=array([0,0,0])
while i<n:
   c=list(map(int,input().split()))
   z=array(c)
   w=z-o
   a,b=map(int,[w[0],abs(w[1])+abs(w[2])])

   if a<b:
       print("No")
       break

   else:
       if (a+b)%2==0:
           o=z
           i=i+1
       else:
           print("No")
           break
else:
    print("Yes")

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

from numpy import array

i=0
o=array([0,0,0])
while i<n:
   c=list(map(int,input().split()))
   z=array(c)
   w=z-o
   a,b=map(int,[w[0],abs(w[1])+abs(w[2])])

   if a<b:
       print("No")
        break

   else:
       if (a+b)%2==0:
           o=z
           i=i+1
       else:
           print("No")
           break
else:
    print("Yes")

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

from numpy import array

i=0
o=array([0,0,0])
while i<n:
   c=list(map(int,input().split()))
   z=array(c)
   w=z-o
   a,b=map(int,[w[0],abs(w[1])+abs(w[2])])

   if a<b:
       print("No")
        break

   else:
       if (a+b)%2==0:
           o=z
           i=i+1
       else:
           print("No")
           break
else:
    print("Yes")

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

from numpy import array

i=0
o=array([0,0,0])
while i<n:
   t,x,y=map(int,input().split())
   z=array([t,x,y])
   w=z-o
   a,b=map(str,[w[0],w[1]+w[2]])

   if w[0]<w[1]+w[2]:
       print("No")
       break

   else:
       if (a+b)%2==0:
           o=o+w
           i=i+1
       else:
           print("No")
           break
else:
    print("Yes")

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

import array from numpy

i=0
o=array([0 0 0])
while i<n
   t,x,y=map(int,input().split())
   z=array([t x y])
   w=z-o
   a,b=map(str,bin(w[1]),bin(w[2]+w[3]))

   if w[1]<w[2]+w[3]:
       print("No")
       break

   else:
       if a==b:
           o=o+w
           i=i+1
       else:
           print("No")
           break
else:
    print("Yes")
Problem p03469 (python)

Fixed submission:
s=list(str(input()))
s[3]=str(int(s[3])+1)
print("".join(s))

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

A = int(max(a))
B = [i for i in b if i > A]

B.sort(reverse=True)

Sum = 0

for i in range(len(B)):
    H -= B[i]
    Sum += 1
    if H <= 0:
        break

if H > 0:
    Sum += int((H-1)//A)+1


print(Sum)

Buggy submission (verdict: Runtime Error):
n,h=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n):
   a[i],b[i]=map(int,input().split()) 
x=max((a))
y=[i for i in b if i>x]
y.sort(reverse=True)
count=0
for i in range(len(y)):
    if h>0:
        count+=1
        h-=y[i]
    else:
        break

if h>0:
     count +=int(h//x)+1
print(count)

Buggy submission (verdict: Runtime Error):
s=[map(str,input().split())]
s[3]=str(int(s[3])+1)
print("".join(s))
Problem p03472 (python)

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

A = int(max(a))
B = [i for i in b if i > A]

B.sort(reverse=True)

Sum = 0

for i in range(len(B)):
    H -= B[i]
    Sum += 1
    if H <= 0:
        break

if H > 0:
    Sum += int((H-1)//A)+1


print(Sum)

Buggy submission (verdict: Runtime Error):
n,h=map(int,input().split())
a=[0]*n
b=[0]*n
for i in range(n)
a[i],b[i]=map(int,input().split()) 
x=max((a))
y=[i for i in b if i>A]
y.sort(reverse=True)
count=0
for i in range(len(y)):
    if h>0:
        count+=1
        h-=y[i]
    else:
        break
 if h>0:
     count +=int(h//x)+1
print(count)

Buggy submission (verdict: Runtime Error):
n,h=map(int,input().split())
l=[[map(int,input().split())] for _ in range(n)]
la=sorted(l,key=lambda x:x[0],reverse=True)
a=l[0][0]
lb=sorted(l,key=lambda x:x[1],reverse=True)
count=0
total=0
for i in lb:
    if i[1]>a:
        count+=1
        total+=i[1]
    else:
        break
print((h-total)//a+1+count
Problem p03478 (python)

Fixed submission:
n,a,b=map(int,input().split())
total=0
i=1
while i in range(1,n+1):
   l=list(str(i))
   ll=[int(s) for s in l]
   if a<=sum(ll)<=b:
        total+=i
        i+=1
   else:
           i=i+1
else:
    print(total)

Buggy submission (verdict: Runtime Error):
l=input().split()
a,b=map(int,[l[1],l[2]])
n=len(list(l[0]))
total=0
while i in range(1,n+1):
    if a<=i<=b:
        total+=1
        i+=1
else:
    print(total)
Problem p03479 (python)

Fixed submission:
x,y=map(int,input().split())
n=y//x
print(len(bin(n))-2)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
n=y//x
m=len(bin(n))-bin(n).rfind("1")-1
print(sum(len(i*m) for i in range(i,m+1)))
Problem p03480 (python)

Fixed submission:
s=input()
n=len(s)
ans=n
for i in range(n-1):
    if s[i]!=s[i+1]:
        t=max(i+1,n-i-1)
        ans=min(ans,t)

print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
a=l.find("0")
b=l.rfind("0")
c=l.find("1")
d=l.rfind("1")
x=max(a,n-b-1)
y=max(c,n-b-1)
print(min(x,y,n-a,n-b))
Problem p03493 (python)

Fixed submission:
print(input().count("1"))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(map(int,input().split()))
f=[l.count(i) for i in range(1,n+1)]
f.sort()
print(sum(f[0:n-k]))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=list(map(int,input().split()))
f=[l.count(i) for i in range(0,n)]
f.sort()
print(sum(f[0:n-k]))

Buggy submission (verdict: Runtime Error):
print(input().count(1))
Problem p03494 (python)

Fixed submission:
import math
n = input()
a = list(map(int, input().split()))
ans = float("inf")
for i in a:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") - 1)
print(round(ans))

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list(map(int(input().split())))
m=list(map(bin,l))

print(min(m[i].rfind(1)-1 for i in range(1,n+1)))

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

a=list(map(int,input(),split()))

b=map(bin,a)

c=map(rfind('1')-1,c)

print(min(c))

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

a=list(map(bin(int),input(),split()))

b=map(rfind('1')-1,a)

print(min(b))

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

a=list(map(int,input(),split()))

b=list(map(rfind('1')-1,a))

print(min(b))
Problem p03545 (python)

Fixed submission:
from itertools import product
s=input()
for b in list(product(["+","-"],repeat=3)):
    ans=s[0]+b[0]+s[1]+b[1]+s[2]+b[2]+s[3]
    if eval(ans)==7:
        print(ans+"=7")
        break

Buggy submission (verdict: Runtime Error):
from itertools import product
s=input()
for b in list(product(["+","-"],repeat=3)):
    ans=s[0]+b[0]+s[1]+b[1]+s[2]+b[2]+s[3]
    if evel(ans)==7:
        print(ans+"7")
        break

Buggy submission (verdict: Runtime Error):
from itertools import product
s=input()
for b in list(product["+","-"],repeat=3):
    ans=s[0]+b[0]+s[1]+b[1]+s[2]+b[2]+s[3]
    if evel(ans)==7:
        print(ans+"7")
        break
Problem p03747 (python)

Fixed submission:
n,l,t=map(int,input().split())
inf=[]
s=0
for _ in range(n):
   x,y=map(int,input().split())
   if y==1:
       x+=t
   else:
       x-=t
   inf.append(x%l)
   s+=x//l
inf.sort()
for i in range(n):
    print(inf[(i+s)%n])

Buggy submission (verdict: Runtime Error):
n,l,t=map(int,input().split())
inf=[]
s=0
for _ in range(n):
x,y=map(int,input().split())
   if y==1:
       x+=t
   else:
       x-=t
    inf.append(x%l)
    s+=x//l
inf.sort()
s%n
for i in range(n):
    print(inf[(i+s)%n])

Buggy submission (verdict: Runtime Error):
n,l,t=map(int,input().split())
inf=[]
s=0
for _ in range(n):
x,y=map(int,input().split())
   if y==1:
       x+=t
   else:
       x-=t
    inf.append(x%l)
    s+=x//l
inf.sort()
s%n
for i in range(n):
    print(inf[(i+p)%n])

Buggy submission (verdict: Runtime Error):
n,l,t=map(int,input().split())
inf=[]
s=0
for _ in range(n)
x,y=map(int,input().split())
   if y==1:
       x+=t
   else:
       x-=t
    inf.append(x%l)
    s+=x//l
inf.sort()
s%n
for i in range(n):
    print(inf[(i+p)%n])
Problem p03852 (python)

Fixed submission:
c=input()
if c=="a" or c=='e' or c=="o" or c=="i" or c=="u":
    print("vowel")
else:
    print("consonant")

Buggy submission (verdict: Runtime Error):
c=input()
if c="a" or c= 'e' or c="o" or c="i" or c="u":
    print("vowel")
else:
    print("consonant")
Problem p03853 (python)

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

for i in range(h):
   print(" ".join(a[i]))
   print(" ".join(a[i]))

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

for i in range(h)
print(" ".join(a[i]))
print(" ".join(a[i]))
Problem p03854 (python)

Fixed submission:
s=input().replace('eraser',"").replace('eraser',"").replace('erase',"").replace('dreamer',"").replace('dream',"")
if s:
    print("NO")
else:
    print("YES")

Buggy submission (verdict: Runtime Error):
s=input().replace('eraser',"").replace('eraser',"").replace('erase',"")replace('dreamer',"").replace('dream',"")
if s:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
s=input().replace('eraser',"")replace('eraser',"").replace('erase',"")replace('dreamer',"")replace('dream',"")
if s:
    print("No")
else:
    print("Yes")
Problem p04001 (python)

Fixed submission:
from itertools import product
s=input()
n=len(s)-1
ans=0
for b in list(product(['+',''],repeat=n)):
    a=s[0]
    for i in range(n):
        a=a+b[i]+s[i+1]
    ans+=eval(a)
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)-1
ans=0
for b in list(product(['+',''],repeat=n)):
    a=s[0]
    for i in range(n):
        a=a+b[i]+s[i+1]
    ans+=eval(a)
print(ans)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)-1
ans=0
for b in list(product(['+',''],repeat=n))
    a=s[0]
    for i in range(n):
        a=a+b[i]+s[i+1]
    ans+=eval(a)
print(ans)
Problem p02696 (python)

Fixed submission:
import numpy as np

s=input().split(' ')
A,B,N=int(s[0]),int(s[1]),int(s[2])

def f(x):
    a=np.floor(A*x/B)-A*np.floor(x/B)
    return a.astype(int)

if N<B-1:
    print(f(N))
else:
    print(f(B-1))

Buggy submission (verdict: Runtime Error):
s=input().split(' ')
A,B,N=int(s[0]),int(s[1]),int(s[2])

def f(x):
    a=np.floor(A*x/B)-A*np.floor(x/B)
    return a.astype(int)

if N<B-1:
    print(f(N))
else:
    print(f(B-1))
Problem p02953 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
f=True
m=0
for i in range(n):
    if h[i]>m:
        m=h[i]-1
    elif h[i]==m:
        continue
    else:
        f=False
        break
print('Yes' if f else 'No')

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

sa = []

for i in range(n-1):
    sa.append(h[i+1]-h[i])

#print(sa)

ans = 0
for i in range(n-1):
    if sa[i] == 0 and sa[i+1] < 0:
        print('No')
        exit(0)
    else:
        if sa[i] == -1:
            ans += 1
        elif sa[i] < -1:
            ans += sa[i]

    if ans > 1:
        print('No')
        exit(0)
        
#print(ans)
print('Yes')

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

sa = []

for i in range(n-1):
    sa.append(h[i+1]-h[i])

#print(sa)

ans = 0
for i in range(n-1):
    if sa[i] == 0 and sa[i+1] < 0:
        print('No')
        exit(0)
    else:
        if sa[i] == -1:
            ans += 1
        elif sa[i] >= 0:
            ans += sa[i]
        else:
            ans += 999
    
    if ans > 1:
        print('No')
        exit(0)
        
#print(ans)
print('Yes')

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

sa = []

for i in range(n-1):
    sa.append(h[i+1]-h[i])

#print(sa)

ans = 0
for i in range(n-1):
    if sa[i] == 0 and sa[i+1] < 0:
        print('No')
        exit(0)
    else:
        if sa[i] < 0:
            ans += 1
    
    if ans > 1:
        print('No')
        exit(0)
        
#print(ans)
print('Yes')

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

sa = []

for i in range(n-1):
    sa.append(h[i+1]-h[i])

#print(sa)

ans = 0
for i in range(n-1):
    if sa[i] == 0 and sa[i+1] == -1:
        print('No')
        exit(0)
    else:
        if sa[i] < 0:
            ans += 1
    
    if ans > 1:
        print('No')
        exit(0)
        
#print(ans)
print('Yes')
Problem p02995 (python)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
    
def lcm(x, y):
    return (x * y) // gcd(x, y)


A, B, C, D = map(int, input().split())
target = B - A + 1

hoge1 = B // C - (A - 1) // C
hoge2 = B // D - (A - 1) // D
hoge3 = B // (C * D) - (A - 1) // (C * D)

saisho = lcm(C, D)
hoge4 = B // saisho - (A - 1) // saisho

print(target - hoge1 - hoge2 + hoge4)

Buggy submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)


A, B, C, D = map(int, input().split())
target = B - A + 1

hoge1 = int(B / C) - int((A - 1) / C)
hoge2 = int(B / D) - int((A - 1) / D)
hoge3 = int(B / (C * D)) - int((A - 1) / (C * D))

saisho = lcm(C, D)
hoge4 = B // saisho - (A - 1) // saisho

print(target - hoge1 - hoge2 + hoge4)
Problem p03192 (python)

Fixed submission:
text = input()
cnt = 0
for i in text:
	if i == "2":
		cnt += 1
print (cnt)

Buggy submission (verdict: Runtime Error):
text = input()
cnt = 0
if 1000 <= int(text) and int(text) <= 9000:
	for i in range(len(text)):
		if i == "2":
			cnt += 1
		else:
			pass
print (i)

Buggy submission (verdict: Runtime Error):
text = input()
cnt = 0
if 1000 <= int(text) and int(text) <= 9000:
	for i in range(len(text)):
		if i == 2:
			cnt += 1
		else:
			pass
print (i)
Problem p03211 (python)

Fixed submission:
x = str(input())
target = 753
ok = 999
for i in range(len(x)-2):
	num = x[i:i+3]
	sa = abs(target - int(num))
	if (ok > sa):
		ok = sa
	#print (sa)
print (ok)

Buggy submission (verdict: Runtime Error):
x = str(input())
target = 753
ok = 999
for i in range(len(x)-3):
	num = x[i:i+3]
	sa = target - num
	if (ok < sa):
		ok = sa
print (sa)

Buggy submission (verdict: Runtime Error):
x = int(input())
target = 753
ok = 999
for i in range(len(x)-3):
	num = x[i:i+3]
	sa = target - num
	if (ok < sa):
		ok = sa
print (sa)