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

Fixed submission:
class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)

        if i == j:
            return

        if i > j:
            i, j = j, i

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

N, M = map(int, input().split())
p = [int(i) - 1 for i in input().split()]

forest = UnionFind(N)

for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    forest.unite(x, y)

ans = 0
for i in range(N):
    if forest.same(i, p[i]):
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
from logging import root
from tokenize import group
import numpy
from pandas.core.resample import f
from regex.regex import U

class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)

        if i == j:
            return

        if i > j:
            i, j = j, i

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

N, M = map(int, input().split())
p = [int(i) - 1 for i in input().split()]

forest = UnionFind(N)

for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    forest.unite(x, y)

ans = 0
for i in range(N):
    if forest.same(i, p[i]):
        ans += 1

print(ans)
Problem p02621 (python)

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

Buggy submission (verdict: Runtime Error):
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
min = 0
i = 0
j = 0
while min <= K:
	if (i < N) or (j < M):
		if (i < N) and (j < M):
			if A[i]<=B[j]:
				min = min+A[i]
				i = i+1
				ans = ans+1
			else:
				min = min+B[j]
				j = j+1
				ans = ans+1
		elif (i == N):
				min = min+B[j]
				j = j+1
				ans = ans+1
		else:
				min = min+A[i]
				i = i+1
				ans = ans+1
	else:
		ans = ans+1
		break
ans = ans-1
print(ans)
Problem p02536 (python)

Fixed submission:
import sys,io,os
I = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
#I = input

n,m = map(int, I().split())
p=[-1]*(n+1)
s=[0]*(n+1)
S=n-1
def t(a):
	b = a
	while p[b] != -1:
		b = p[b]
	while p[a] != -1:
		p[a],a = b,p[a]
	return a
for _ in range(m):
	a,b=map(int, I().split())
	a,b = t(a), t(b)
	if a != b:
		S -= 1
		if s[a] > s[b]:
			a,b = b,a
		p[a] = b
		s[b] += s[a]
print(S)

Buggy submission (verdict: Runtime Error):
import sys,io,os
I = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
I = input

n,m = map(int, I().split())
p=[-1]*(n+1)
s=[0]*(n+1)
S=n-1
def t(a):
	while p[a] != -1:
		a = p[a]
	return a
for _ in range(m):
	a,b=map(int, I().split())
	a,b = t(a), t(b)
	if a != b:
		S -= 1
		if s[a] > s[b]:
			a,b = b,a
		p[a] = b
		s[b] += s[a]
print(S)
Problem p02608 (python)

Fixed submission:
n=int(input())
import math
nn=int(math.sqrt(n))+1
a=[0]*(100*n)
for x in range(1,nn+1):
    for y in range(1,nn+1):
        for z in range(1,nn+1):
            a[(x+y+z)**2-x*y-x*z-y*z]+=1
for i in range(1,n+1):
    print(a[i])

Buggy submission (verdict: Runtime Error):
#c
n=int(input())
import math
nn=int(math.sqrt(n))+1
a=[0]*(8*n)
for x in range(1,nn+1):
    for y in range(1,nn+1):
        for z in range(1,nn+1):
            a[(x+y+z)**2-x*y-x*z-y*z]+=1
for i in range(1,n+1):
    print(a[i])
Problem p02614 (python)

Fixed submission:
h,w,k=map(int,input().split())
c=[]
#行ごと
hk=[]
for i in range(h):
    kki=0
    hwi=input()
    hw=[]
    for j in range(w):
        if hwi[j]=='#':
            hw.append(1)
            kki+=1
        else:
            hw.append(0)
    c.append(hw)
    hk.append(kki)
kk=sum(hk)
ans=0
#残す行を選ぶ
for i in range(2**h):
    #列ごと
    wk=[0]
    wk*=w
    for j in range(h):
        if (i>>j &1):
            #残った行の列ごとの和
            for l in range(w):
                wk[l]+=c[j][l]
    #残す列を選ぶ
    for j in range(2**w):
        ansi=0
        for l in range(w):
            if (j>>l & 1):
                ansi+=wk[l]
        if ansi==k:
            ans+=1
    
print(ans)

Buggy submission (verdict: Runtime Error):
h,w,k=map(int,input().split())
c=[]
#行ごと
hk=[]
for i in range(h):
    kki=0
    hwi=list(map(str,input().split()))
    hw=[]
    for j in range(w):
        if hwi[j]=='#':
            hw.append(1)
            kki+=1
        else:
            hw.append(0)
    c.append(hw)
    hk.append(kki)
kk=sum(hk)
ans=0
#残す行を選ぶ
for i in range(2**h):
    #列ごと
    wk=[0]
    wk*=w
    for j in range(h):
        if (i>>j &1):
            #残った行の列ごとの和
            for l in range(w):
                wk[l]+=c[j][l]
    #残す列を選ぶ
    for j in range(2**w):
        ansi=0
        for l in range(w):
            if (j>>l & 1):
                ansi+=wk[l]
        if ansi==k:
            ans+=1
    
print(ans)
Problem p02630 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]
b*=10**5+1
for i in a:
    b[i]+=1
ans=sum(a)
q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    d=b[bi]
    b[ci]+=d
    b[bi]=0
    ans=ans+d*(ci-bi)
    print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
q=int(input())
for i in range(q):
    bi,ci=map(int,input().split())
    t=0
    for j in range(n):
        if a[j]==bi:
            a[j]=ci
            d=j+1
            while a[d]==bi:
                a[d]=ci
                d+=1
            t=1
        elif t==1:
            break
    print(sum(a))
Problem p02658 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    s=1
    for i in a:
        s=s*i
        if s>10**18:
            s=-1
            break
    print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    s=1
    for i in a:
    s=s*i
    if s>10**18:
        s=-1
        break
    print(s)
Problem p02687 (python)

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

Buggy submission (verdict: Runtime Error):
s=int(input())
if s=='ABC':
    print('ARC')
else: print('ABC')
Problem p02690 (python)

Fixed submission:
x=int(input())
ma=200
for i in range(ma):
    for j in range(-ma,ma):
        if (i**5 - j**5) ==x:
            print(i,j)
            exit()

Buggy submission (verdict: Runtime Error):
x=int(input())
for a in range(200):
    for b in range(-200,200):
        if a**5-b**5==:
            print(a,b)
            exit()

Buggy submission (verdict: Runtime Error):
x=int(input())
for a in range(200):
    for b in range(-200,200):
        if a**5-b**5=x:
            print(a,b)
            exit()

Buggy submission (verdict: Runtime Error):
x=int(input())
a=0
b=0
t=0
while a**5<x:
    while b**5<x:
        if a**+b**5==x:
            print(a,-b)
            t=1
            break
        b+=1
    if t==1:
        break
    a+=1
if t==0:
    for i in range(a+1,10**3):
        for j in range(10**3):
            if i**5-j**5==x:
            print(i,j)
            t=1
            break
    if t==1:
        break

Buggy submission (verdict: Runtime Error):
x=int(input())
a=0
b=0
t=0
while a**5<x:
    while b**5<x:
        if a**+b**5==x:
            print(a,-b)
            t=1
            break
        b+=1
    if t==1:
        break
    a+=1
if t==0:
    for i in range(a+1:10**3):
        for j in range(10**3):
            if i**5-j**5==x:
            print(i,j)
            t=1
            break
    if t==1:
        break

Buggy submission (verdict: Runtime Error):
x=int(input())
t=x
c=[]
while x%2==0:
    c.append(2)
    n//=2
f=3
while f*f<=x:
    if x%f==0:
        c.append(f)
    else: f+=2
if x!=1:
    c.append(x)
while i in c:
    for a in range(10*3):
        if i*(a**4+a**3*(a-i)+a**2*(a-i)**2+a*(a-i)**3+(a-i)**4)==t:
            print(a,a-i)
            break
        if -i*(a**4+a**3*(a+i)+a**2*(a+i)**2+a*(a+i)**3+(a+i)**4)==t:
            print(a,a+i)
            break

Buggy submission (verdict: Runtime Error):
x=int(input())
t=x
c==0
while x%2==0:
    c.append(2)
    n//=2
f=3
while f*f<=x:
    if x%f==0:
        c.append(f)
    else: f+=2
if x!=1:
    c.append(x)
while i in c:
    for a in range(10*3):
        if i*(a**4+a**3*(a-i)+a**2*(a-i)**2+a*(a-i)**3+(a-i)**4)==t:
            print(a,a-i)
            break
        if -i*(a**4+a**3*(a+i)+a**2*(a+i)**2+a*(a+i)**3+(a+i)**4)==t:
            print(a,a+i)
            break

Buggy submission (verdict: Runtime Error):
x=int(input())
c==0
while x%2==0:
    c.append(2)
    n//=2
f=3
while f*f<=x:
    if x%f==0:
        c.append(f)
    else: f+=2
if x!=1:
    c.append(x)
while i in c:
    for a in range(10*3):
        if i*(a**4+a**3*(a-i)+a**2*(a-i)**2+a*(a-i)**3+(a-i)**4)==x:
            print(a,a-i)
            break
        if -i*(a**4+a**3*(a+i)+a**2*(a+i)**2+a*(a+i)**3+(a+i)**4)==x:
            print(a,a+i)
            break
Problem p02696 (python)

Fixed submission:
a,b,n=map(int,input().split())
import math
if n<b:
    m=math.floor(a*n/b)
else:
    e=b-1
    m=math.floor(a*e/b)
print(m)

Buggy submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
import math
x=b-1
if n<b-1:
    m=[math.floor(a*n/b)]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

Buggy submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
import math
x=b-1
if n<b-1:
    m=[math.floor(a*n/b)]
while x<=n:
    f=math.floor(a*x/b)-a*(math.floor(x/b))
    m.append(f)
    x+=b
print(max(m))

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
import math
a,b,n=map(int,input().split())
for x in range(n+1):
    f=math.floor(a*x/b)-a*math.floor(x/b)
    m.append(f)
print(max(m))
Problem p02706 (python)

Fixed submission:
n,m=map(int,input().split())
mm=list(map(int,input().split()))
a=n-sum(mm)
if a>=0:
    print(a)
else: print(-1)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mm=[]
for i in range(m):
    s=int(input())
    mm.append(s)
a=n-sum(mm)
if a>=0:
    print(a)
else: print(-1)
Problem p02708 (python)

Fixed submission:
n,k=map(int,input().split())
d=0
for i in range(k,n+2):
    b=i*(i-1)/2
    c=i*(2*n-i+1)/2
    d+=(c-b+1)
print(int(d)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=0
while k<=n+1:
    b=1
    s=1
    for t in range(k):
        b*=(t+1)
        s*=(n+1-t)
    a+=s/b
    k+=1
print(a)
Problem p02714 (python)

Fixed submission:
n=int(input())
s=str(input())
t=len(s)
r=set()
g=set()
b=set()
a=0
for i in range(n):
    if s[i]=='R':
        r.add(i)
    if s[i]=='G':
        g.add(i)
    if s[i]=='B':
        b.add(i)
d=len(r)*len(g)*len(b)
for ri in r:
    for gi in g:
        rg=gi-ri
        if rg+gi in b:
            d-=1
        if  ri-rg in b:
            d-=1
        if (gi+ri)/2 in b:
            d-=1

print(d)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=str(input())
t=len(s)
#setの方が参照速度が速い
r=set()
g=set()
b=set()
a=0
for i in range(n):
    if s[i]=='R':
        r.add(i)
    if s[i]=='G':
        g.add(i)
    if s[i]=='B':
        b.add(i)
d=len(r)*len(g)*len(b)
for ri in r:
    for gi in g:
        if 2ri-gi in b:
            d-=1
        if 2gi-ri in b:
            d-=1
        if (gi+ri)/2 in b:
            d-=1

print(d)
Problem p02755 (python)

Fixed submission:
a,b=map(int,input().split())
ans=-1
for i in range(1300):
    if int(i*2/25)==a and int(i/10)==b:
        ans=i
        break
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
ans=-1
for i in range(101):
    if int(i*/25)==a and int(i/10)==b:
        ans=i
        break
print(ans)
Problem p02756 (python)

Fixed submission:
S=input()
q=int(input())
s=[]
r=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if int(qv[1])^t==0 or int(qv[1])^t==2:
            r.append(qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    ss=s.copy()
    s=[]
    for j in range(len(ss)):
        s.append(ss[-1-j])
    ans=s
    ans.extend(r)
else:
    rr=r.copy()
    r=[]
    for j in range(len(rr)):
        r.append(rr[-1-j])
    ans=r
    ans.extend(s)
answer=''.join(ans)
print(answer)

Buggy submission (verdict: Runtime Error):
s=input()
q=int(input())
s=[]
r=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if int(qv[1])^t==0 or int(qv[1])^t==2:
            r.append(qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    ss=s.copy()
    s=[]
    for j in range(len(ss)):
        s.append(ss[-1-j])
    ans=s
    ans.extend(r)
else:
    rr=r.copy()
    r=[]
    for j in range(len(rr)):
        r.append(rr[-1-j])
    ans=r
    ans.extend(s)
answer=''.join(ans)
print(answer)

Buggy submission (verdict: Runtime Error):
S=input()
q=int(input())
s=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if int(qv[1])^t==0 or nt(qv[1])^t==2:
            s.insert(0,qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    ss=s.copy()
    s=[]
    for j in range(len(ss)):
        s.append(ss[-1-j])
ans=''.join(s)
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
q=int(input())
s=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if int(qv[1])^t==0:
            s.insert(0,qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    for j in range(len(s)):
        ss.append(s[-1-j])
ans=''.join(s)
print(ans)

Buggy submission (verdict: Runtime Error):
S=input()
q=int(input())
s=[]
for i in S:
    s.append(i)
t=1
for i in range(q):
    qv=list(input().split())
    if qv[0]=='1':
        t^=1
    else:
        if (qv[1]=='1' and t==1) or (qv[1]=='2' and t==0):
            s.insert(0,qv[2])
        else:
            s.append(qv[2])
            
if t==0:
    for j in range(len(s)):
        ss.append(s[-1-j])
ans=''.join(s)
print(ans)
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
a=['.']
a*=n
ans=0
for i in range(m):
    si,ci=input().split()
    si=int(si)
    ci=str(ci)
    if a[si-1]=='.':
        a[si-1]=ci
    else:
        if a[si-1]==ci:
            continue
        else:
            ans=-1
            break

if ans==-1 or (n>=2 and a[0]=='0'):
    print(-1)
else:
    if n==1 and a[0]=='.':
        a[0]='0'
    elif a[0]=='.':
        a[0]='1'
    for i in range(1,n):
        if a[i]=='.':
            a[i]='0'
    a=''.join(a)
    print(a)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=['.']
a*=n
ans=0
for i in range(m):
    si,ci=input().split()
    si=int(si)
    ci=str(ci)
    if a[si-1]=='.':
        a[si-1]=ci
    else:
        if a[si-1]==ci:
            continue
        else:
            ans=-1
            break

if ans==-1 or (n>=2 and a[0]=='0'):
    print(-1)
else:
    if n==1 and a[0]=='.':
        a[0]=0
    elif a[0]=='.':
        a[0]='1'
    for i in range(1,n):
        if a[i]=='.':
            a[i]='0'
    a=''.join(a)
    print(a)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=['.']
a*=n
ans=0
for i in range(m):
    si,ci=input().split()
    si=int(si)
    ci=str(ci)
    if a[si-1]=='.':
        a[si-1]=ci
    else:
        if a[si-1]==ci:
            continue
        else:
            ans=-1
            break

if ans==-1 or (n>=2 and a[0]=='0'):
    print(-1)
else:
    if n==1 and a[0]=='.':
        a[0]=0
    elif a[0]=='.':
        a[0]=1
    for i in range(1,n):
        if a[i]=='.':
            a[i]='0'
    a=''.join(a)
    print(a)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=['.']
a*=n
ans=0
for i in range(m):
    si,ci=input().split()
    si=int(si)
    ci=str(ci)
    if a[si-1]=='.':
        a[si-1]=ci
    else:
        if a[si-1]==ci:
            continue
        else:
            ans=-1
            break

if ans==-1 or (n>=2 and a[0]=='0'):
    print(-1)
else:
    if a[0]=='.':
        a[0]=1
    for i in range(1,n):
        if a[i]=='.':
            a[i]='0'
    a=''.join(a)
    print(a)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=['.']
a*=n
ans=0
for i in range(m):
    si,ci=input().split()
    si=int(si)
    ci=str(ci)
    if a[si-1]=='.':
        a[si-1]=ci
    else:
        if a[si-1]==ci:
            continue
        else:
            ans=-1
            break

if ans==-1 or a[0]=='0':
    print(-1)
else:
    if a[0]=='.':
        a[0]=1
    for i in range(1,n):
        if a[i]=='.':
            a[i]='0'
    a=''.join(a)
    print(a)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=['.']
a*=n
ans=0
for i in range(m):
    si,ci=input().split()
    si=int(si)
    ci=str(ci)
    if a[si-1]=='.':
        a[si-1]=ci
    else:
        if a[si-1]==ci:
            continue
        else:
            ans=-1
            break

if ans==-1:
    print(-1)
else:
    if a[0]=='.':
        a[0]=1
    for i in range(1,n):
        if a[i]=='.':
            a[i]='0'
    a=''.join(a)
    print(a)
Problem p02953 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t==h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t==h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print(Yes)
else:
    print(No)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
t=0
f=0
for i in range(n-1):
    if h[i]<=h[i+1]+1 and t<h[i]:
        h[i]-=1
        t=h[i]
    elif h[i]<=h[i+1] and t=h[i]:
        t=h[i]
    else:
        f=1
        break
if f==0:
    print(Yes)
else:
    print(No)
Problem p03061 (python)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
r=[a[-1]]
l=[a[0]]
for i in range(1,n-1):
    l.append(gcd(l[i-1],a[i]))
    r.append(gcd(r[i-1],a[-1-i]))
ans=r[-1]    
for i in range(n-2):
    ans=max(ans,gcd(l[i],r[-2-i]))
ans=max(ans,l[-1])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
r=[a[-1]]
l=[a[0]]
for i in range(1,n-1):
    l.append(math.gcd(l[i-1],a[i]))
    r.append(math.gcd(r[i-1],a[-1-i]))
ans=r[-1]    
for i in range(n-2):
    ans=max(ans,math.gcd(l[i],r[-2-i]))
ans=max(ans,l[-1])
print(ans)
Problem p03147 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
hm=max(h)

ans=0
for i in range(hm,0,-1):
    t=1
    for j in range(n):
        if h[j]>=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)

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

ans=0
for i in range(hm,-1,-1):
    t=1
    for j in range(n):
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
hm=max(h)
t=1
ans=0
for i in range(hm,-1,-1):
    for j in range(n):
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input.split()))
hm=max(h)
t=1
ans=0
for i in range(hm,-1,-1):
    for j in range(n):
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input.split()))
hm=max(h)
t=1
for i in range(hm,-1,-1):
    for j in range(n):
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input.split()))
hm=max(h)
t=1
for i in range(hm,-1,-1):
    for j in range(n)
        if h[j]=i:
            ans+=t
            t=0
        else:
            t=1

print(ans)
Problem p03342 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.append(0)
x=a[0]
xi=1
ans=0
x_s=0
x_e=0
a_sum=a[0]
while x_e<n:
    if x_s==x_e:
        x_e+=1
        ans+=1
        xi=2
        x^=a[x_e]
        a_sum+=a[x_e]
    elif x==a_sum:
        ans+=xi
        xi+=1
        x_e+=1
        x=x^a[x_e]
        a_sum=a_sum+a[x_e]
    else:
        xi-=1
        x=x^a[x_s]
        a_sum=a_sum-a[x_s]
        x_s+=1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.append(0)
x=a[0]
xi=1
ans=0
x_s=0
x_e=0
a_sum=a[0]
while x_e<n:
    if x_s==x_e:
        x_e+=1
        ans+=1
        xi=2
        x^=a[x_e]
        a_sum+=a[x_e]
    elif x==a_sum:
        ans+=xi
        xi+=1
        x_e+=1
        x=x^a[x_e]
        a_sum=a_sum+a[x_e]
    else:
        xi-=1
        x=x^a[x_s]
        a_sum=a_sum-a[x_a]
        x_s+=1

print(ans)
Problem p03433 (python)

Fixed submission:
a=int(input())
b=int(input())
if a%500 <= b:
  print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a%500 < b:
  print('Yes')
else('No')

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if a%500<b:
  print('Yes')
else('No')
Problem p03448 (python)

Fixed submission:
A=int(input())
B=int(input())
C=int(input())
X=int(input())
s=0
for i in range(A+1):
  x=X-500*i
  if x<0: break
  for t in range(B+1):
    if x<0: break
    elif 50*C>=x:
      s+=1
      x-=100
    else: x-=100
print(s)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
x=int(input())
s=0
for i in range(A+1):
  if x<=0: break
  else:
    for t in range(B+1):
    if x<=0: break
    elif 50*C>=x:
      s+=1
      x-=100
    else: x-=100
  x-=500
print(s)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
x=int(input())
s=0
for i in range(A+1):
  if x==0: break
  else:
    for t in range(B+1):
    if x==0: break
    elif 50*C>=x:
      s+=1
      x-=100
    else: x-=100
  x-=500
print(s)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
x=int(input())
s=0
for i in range(A+1):
  if x=0: break
  else:
    for t in range(B+1):
    if x=0: break
    elif 50*C>=x:
      s+=1
      x-=100
    else: x-=100
  x-=500
print(s)

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())
C=int(input())
x=int(input())
s=0
for i in range(A+1):
  if x=0: break
  else:
    for t in range(B+1):
    if x=0: break
    else 50*C>=x:
      s+=1
      x-=100
  x-=500
print(s)