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

Fixed submission:
N=int(input())
A=list(map(int,input().split()))

A_set=set(A)
A_lst=list(A_set)

# すべてが0のとき
if sum(A_set)==0 and len(A_set)==1:
    print('Yes')
    exit()

# x…2N/3,0…N/3
if len(A_set)==2 and A_lst.count(0)==1 and len(A)%3==0:
    cnt=0
    for i in range(N):
        if A[i]==0:
            cnt+=1
    if cnt==N//3:
        print('Yes')
    else:
        print('No')
    exit()

# x^y^z==0
if len(A_set)==3 and A_lst[0]^A_lst[1]^A_lst[2]==0 and len(A)%3==0:
    cnt_x,cnt_y,cnt_z=0,0,0
    x,y,z=A_lst[0],A_lst[1],A_lst[2]
    for i in range(N):
        if A[i]==x:
            cnt_x+=1
            continue
        if A[i]==y:
            cnt_y+=1
            continue
        if A[i]==z:
            cnt_z+=1
    if cnt_x==cnt_y==cnt_z:
        print('Yes')
    else:
        print('No')
    exit()

# それ以外
print('No')

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

A_set=set(A)
A_lst=list(A_set)

# すべてが0のとき
if sum(A_set)==0 and len(A_set)==1:
    print('Yes')
    exit()

# x…2N/3,0…N/3
if len(A_set)==2 and A_set.count(0)==1 t and A_set.count(sum(A_set)//2)==2 and len(A)%3==0:
    print('Yes')
    exit()

# x^y^z==0
if len(A_set)==3 and A_lst[0]^A_lst[1]^A_lst[2]==0 and len(A)%3==0:
    print('Yes')
    exit()

# それ以外
print('No')

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

A_set=set(A)
A_lst=list(A_set)

# すべてが0のとき
if sum(A_set)==0:
    print('Yes')
    exit()

# x…2N/3,0…N/3
if 0 in A_set and A_set.count(sum(A_set)//2)==2 and len(A)%3==0:
    print('Yes')
    exit()

# x^y^z==0
if A_lst[0]^A_lst[1]^A_lst[2]==0 and len(A)%3==0:
    print('Yes')
    exit()

# それ以外
print('No')
Problem p02995 (python)

Fixed submission:
import fractions
a,b,c,d=map(int,input().split())
lcm=c*d//fractions.gcd(c,d)
print(b-a+1-((b//c-(a-1)//c)+(b//d-(a-1)//d)-(b//lcm-(a-1)//lcm)))

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

def func(x,y,z):
    if (x-y)%z==0:
        return (x-y)//z
    else:
        return (x-y)//z+1
def gid(x,y):
    ans=x%y
    x=y
    y=ans
    while True:
        ans=x%y
        if ans==0:
            return y
            break
        x=y
        y=ans
cd=[c,d]
cd.sort()
cd2=cd[1]*cd[0]//(gid(cd[1],cd[0]))
_c=func(b,a,c)
_d=func(b,a,d)
_cd2=func(b,a,cd2)
print((b-a+1)-(_c+_d-_cd2))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())
cd=[c,d]
cd.sort()
l=b-a+1

def func(n,m):
    if m%n!=0:
        return m//n+1
    else:
        return m//n

def func2(x,y):
    ans=x%y
    x=y
    y=ans
    while True:
        ans=x%y
        if ans==0:
            return y
        x=y
        y=ans
cd2=cd[1]*cd[0]//(func2(cd[1],cd[0]))
print(l-(func(c,l)+func(d,l)-func(cd2,l)))
Problem p03000 (python)

Fixed submission:
import sys
read=sys.stdin.buffer.readline

N,X=map(int,read().split())
L=list(map(int,read().split()))

ans=1
res=0
for l in L:
    res+=l
    if res<=X:
        ans+=1
    else:
        break
print(ans)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
d,cnt=0,0
for i in range(1,N+2):
    if d<=X:
        d=d+L[i-1]
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
d,cnt=0,0
for i in range(1,N+2):
    if d>X:
        break
    d=d+L[i-1]
    cnt+=1
print(cnt)
Problem p03086 (python)

Fixed submission:
S=input()

ans_lst=[0]*len(S)
l=['A','C','G','T']
if S[0] in l:
    ans_lst[0]=1

for i in range(1,len(S)):
    if S[i] in l:
        ans_lst[i]=ans_lst[i-1]+1

print(max(ans_lst))

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

ans_lst=[]
ans=0
for s in S:
    if s in ['A','C','G','T']:
        ans+=1
    else:
        ans_lst.append(ans)
        ans=0

print(max(ans_lst))
Problem p03160 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))

dp=[0]*N

dp[1]=abs(H[0]-H[1])

for i in range(2,N):
    a,b=dp[i-1]+abs(H[i-1]-H[i]),dp[i-2]+abs(H[i-2]-H[i])
    if a<b:
        dp[i]+=a
    else:
        dp[i]+=b

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
read_=sys.stdin.buffer.readline

N=int(read_())
H=list(map(int,read_().split()))

dp=[10**4+1]*N

def f(i):
    if dp[i]<10**4+1: 
        return dp[i]
    if i==0: 
        return 0
    res=10**4+1
    res=min(res,f(i-1)+abs(H[i]-H[i-1]))
    if i>1: res=min(res,f(i-2)+abs(H[i]-H[i-2]))
    dp[i]=res
    return dp[i]

print(f(N-1))

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

dp=[float('inf')]*N

def f(i):
    if dp[i]<float('inf'): return dp[i]
    if i==0: return 0
    res=10**4+1
    res=min(res,f(i-1)+abs(H[i]-H[i-1]))
    if i>1: res=min(res,f(i-2)+abs(H[i]-H[i-2]))
    dp[i]=res
    return dp[i]

print(f(N-1))
Problem p03274 (python)

Fixed submission:
N,K=map(int,input().split())
X=list(map(int,input().split()))
ans=float('inf')
for l in range(N-K+1):
    r=l+K-1
    ans=min(ans,min(abs(X[l]),abs(X[r]))+X[r]-X[l])
print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
X=list(map(int,input().split()))
ans=float('inf')
for i in range(N-K+1):
  	l=i
    r=l+K-1
    ans=min(ans,min(abs(X[l]),abs(X[r]))+X[r]-X[l])
print(ans)
Problem p03282 (python)

Fixed submission:
s=input()
len_s=len(s)
cnt=0
k=int(input())
for v in s:
    if v!='1':
        print(int(v))
        break
    else:
        cnt+=1
        if k==cnt:
            print(1)
            break

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
if s[0]=='1':
    print(s[1])
else:
    print(s[0])
Problem p03361 (python)

Fixed submission:
H,W=map(int,input().split())
s=[list(input()) for _ in range(H)]
cnt=0
for i in range(H):
    for j in range(W):
        if s[i][j]=='#':
            l=[[i-1,j],[i+1,j],[i,j-1],[i,j+1]]
            OK=0
            for v in l:
                if H>v[0]>=0 and W>v[1]>=0:
                    if s[v[0]][v[1]]=='#':
                        OK=1
            if OK==0:
                print('No')
                exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())
s=[list(input()) for _ in range(H)]
l=[-1,1]
cnt=0
for i in range(H):
    for j in range(W):
        a=set()
        if s[i][j]=='#':
            cnt+=1
            for v in l:
                if H>i-v>=0:
                    a.add(s[i-v][j])
                if H>j-v>=0:
                    s[i][j-v]
                    a.add(s[i][j-v])
            if '#' not in a:
                print('No')
                exit()
if cnt==0:
    print('No')
else:
    print('Yes')
Problem p03393 (python)

Fixed submission:
S=input()
abc=[chr(ord('a')+i) for i in range(26)]

if len(S)<26:
    for s in S:
        abc.remove(s)
    print(S+abc[0])
    exit()
for i in range(24,-1,-1):
    for j in range(25,i,-1):
        if S[i]<S[j]:
            print(S[:i]+S[j])
            exit()

print(-1)

Buggy submission (verdict: Runtime Error):
S=input()
abc=[chr(ord('a')+i) for i in range(26)]

if len(S)<26:
    for s in S:
        abc.remove(s)
    print(S+abc[0])
else:
    index_z=S.index('z')
    index_=abc.index(S[index_z-1])
    abc_=abc[index_:]
    for s in S[:index_z]:
        abc_.remove(s)
    print(S[:index_z-1]+abc_[0])
Problem p03401 (python)

Fixed submission:
N=int(input())
A=[0]
a=list(map(int,input().split()))
a.append(0)
A.extend(a)

res=0

for i in range(1,N+2):
    res+=abs(A[i-1]-A[i])

for i in range(1,N+1):
    print(res+abs(A[i-1]-A[i+1])-(abs(A[i]-A[i-1])+abs(A[i]-A[i+1])))

Buggy submission (verdict: Runtime Error):
import sys
read_=sys.stdin.buffer.readline

N=int(input())
A=[0]
a=list(map(int,read_().split()))
a.append(0)
A.extend(a)

res=0

for i in range(1,N+2):
    res+=abs(A[i-1]-A[i])

for i in range(1,N+1):
    print(res+abs(A[i-1]-A[i+1])-(abs(A[i]-A[i-1])+abs(A[i]-A[i+1])))
Problem p03828 (python)

Fixed submission:
N=int(input())
p=10**9+7

def primeryNum(n):
    n_=int(n**0.5)
    ary=list(range(n+1))
    ary[1]=0 
    for a in ary:
        if a>n_: break
        elif a==0: continue
        
        for i in range(a*2,n+1,a):
            ary[i]=0           
    return ary

primeryN=primeryNum(N)

divN=[0]*(N+1)
for pn in primeryN:
    if pn==0:
        continue
    # print(pn)
    i=1
    cnt=0
    while (pn**i<=N):
        cnt+=(N//pn**i)
        i+=1
    divN[pn]=cnt

# print(divN)
ans=1
for d in divN:
    if d==0:
        continue
    ans=(ans*(d+1))%p
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
p=10**9+7

def primeryNum(n):
    n_=int(n**0.5)
    ary=list(range(n+1))
    ary[1]=0 
    for a in ary:
        if a>n_: break
        elif a==0: continue
        
        for i in range(a*2,n+1,a):
            ary[i]=0           
    return ary

primeryN=primeryNum(N)
divN=[0]*N
for pn in primeryN:
    if pn==0:
        continue
    i=1
    cnt=0
    while (pn**i<N):
        cnt+=(N//pn**i)
        i+=1
    divN[pn]=cnt

ans=1
for d in divN:
    if d==0:
        continue
    ans=(ans*(d+1))%p
print(ans)
Problem p02732 (python)

Fixed submission:
n = int(input())
number = list(map(int,input().split()))
num = sorted(number)
num.append(0)
p = num[0]
combi = dict()
u = 0

for i in range (n+1) :
    q = num[i]
    if p != q :
        combi[p] = u
        u = 0
    u += 1
    p = q

t = 0

for j in combi.values() :
    t += j*(j-1)//2

for k in range (n) :
    x = number[k]
    print(t + (combi[x]-1)*(combi[x]-2)//2 - combi[x]*(combi[x]-1)//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
number = list(map(int,input().split()))
num = sorted(number)
num.append(0)
p = num[0]
combi = dict()
u = 0

for i in range (n+1) :
    q = num[i]
    if p != q :
        combi[p] = u
        u = 0
    u += 1
    p = q

t = 0

for j in combi.values() :
    t += j*(j-1)//2

for k in range (n) :
    x = combi[j]
    print(t + (combi[x]-1)*(combi[x]-2)//2 - combi[x]*(combi[x]-1)//2)
Problem p03497 (python)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
kosu = [0]*n
kaburi = []

for i in range(n):
    kosu[a[i]-1] += 1

for j in range(n):
    if kosu[j] != 0:
        kaburi.append(kosu[j])

kaburi.sort()
print(sum(kaburi[:len(kaburi)-k]))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
kaburi = []

for i in range(n):
    if not a[i] in kaburi:
        kaburi.append(a[i])

kaisu = 0

while True:
    p = n
    q = 0
    if k >= len(kaburi):
        print(kaisu)
        break
    else:
        for j in range(len(kaburi)):
            p = min(p,a.count(kaburi[j]))
            if p > a.count(kaburi[j]):
                q = kaburi[j]
        kaisu += p
        print(p,q,kaisu,len(kaburi))
        kaburi.remove(q)
Problem p03633 (python)

Fixed submission:
import fractions
n = int(input())
p = 1
for i in range(n) :
    t = int(input())
    p = p*t//fractions.gcd(p,t)
print(p)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
p = 1
for i in range(n) :
    t = int(input())
    p = p*t//math.gcd(p,t)
print(p)
Problem p02576 (python)

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

from math import ceil
time = ceil(n/x) * t
print(time)

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

from math import ceil
time = ceil(t/n) * x
print(time)
Problem p02717 (python)

Fixed submission:
A,B,C = map(int, input().split())

A,B = B,A
A,C = C,A

print(A,B,C)

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

print(min(n%k, abs(n%k-k)))

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())

min = 10**18+1
flag = True

while flag==True:
  N = abs(N-K)
  if N < min: min = N
  else: flag = False
    
return min
Problem p02718 (python)

Fixed submission:
N,M = map(int, input().split())
A = input().split()
A = [int(i) for i in A]

limit = sum(A) / (4*M)
flag = 0

for i in A:
  if i>=limit: flag += 1
    
if flag>=M: print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = list(map(int,input().split()))
limit = 1/(4*m)
count = 0
for i in range(n):
  if num[i] >= limit: count += 1
if count >= m: print(‘Yes’)
else: print(‘No’)
Problem p02719 (python)

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

print(min(n%k, abs(n%k-k)))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().aplit())
print(min(n%k,abs(n%k-k)))

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

print min(n%k, abs(n%k-k))

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())

min_num = 10**18+1
flag = True

while flag:
  N = abs(N-K)
  if N < min_num: min_num = N
  else: break
    
return min_num

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())

min = 10**18+1
flag = True

while flag==True:
  N = abs(N-K)
  if N < min: min = N
  else: flag = False
    
return min

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())

min = 10**18+1
flag = True

while flag==True:
  N = abs(N-K)
  if N < min: min = N
  else: flag == False
    
return min
Problem p02730 (python)

Fixed submission:
s = input()

ss = s[::-1]
n = len(s)
s1 = s[0:int((n-1)/2)]
ss1 = s1[::-1]
s2 = s[int((n+3)/2-1):n]
ss2 = s2[::-1]

if s==ss and s1==ss1 and s2==ss2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s = list(input())
n = len(s)
if n==n[::-1] and n[0:int((n-1)/2)]==n[0:int((n-1)/2)][::-1] and n[int((n+3)/2-1):n]==n[int((n+3)/2-1):n][::-1]:
  print('Yes')
else:
  print('No')
Problem p02761 (python)

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

num = 0
dic = {}

for i in range(m):
  s,c = map(int, input().split())
  if n!=1 and s==1 and c==0: 
    print(-1)
    exit()
  if s not in dic:
    dic[s] = c
    num = num + c*(10**(n-s))
  elif c!=dic[s]:
    print(-1)
    exit()

if 1 not in dic and n>1:
  num = num + 10**(n-1)

print(num)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!=c:
    print(-1)
    eixt()
for i in range(n):
  if num[i] == -1: num[i] = 0
if num[0] == 0 and len(num)!=1: num[0] = 1
for i in range(n):
  print(num[i],end='')

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!==c:
    print(-1)
    eixt()
for i in range(n):
  if num[i] == -1: num[i] = 0
if num[0] == 0 and len(num)!=1: num[0] = 1
print(int(''.join(num)))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!=c:
    print(-1)
    eixt()
for i in range(n):
  if num[i] == -1: num[i] = 0
if num[0] == 0 and len(num)!=1: num[0] = 1
print(int(''.join(num)))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
num = [-1]*n
for i in range(m):
  s,c = map(int,input().split())
  if n!=1 and s==1 and c==0:
    print(-1)
    exit()
  if num[s-1]==-1: num[s-1] = c
  elif num[s-1]!=c:
    print(-1)
    eixt()
for i in range(n):
  if num[i] = -1: num[i] = 0
if num[0] = 0 and len(num)!=1: num[0] = 1
print(int(''.join(num)))
Problem p02802 (python)

Fixed submission:
N, M = map(int, input().split())
WA = [0] * N
AC = [0] * N

for i in range(M):
  p,s = input().split()
  p = int(p)
  if AC[p-1] == 0:
    if s == "AC":
      AC[p-1] = 1
    else:
        WA[p-1] += 1
        
wa = 0
for j in range(N):
  if AC[j] == 1:
    wa += WA[j]
print(sum(AC),wa)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
WA = [0] * N
AC = [0] * N

for i in range(M):
  p,s = input().split()
  p = int(p)
  if AC[p-1] == 0:
    if s == "AC":
      AC[p-1] = 1
      else:
        WA[p-1] += 1
        
wa = 0
for j in range(N):
  if AC[j] == 1:
    wa += WA[j]
print(sum(AC),wa)
Problem p02812 (python)

Fixed submission:
n = int(input())
s = input()

count = 0
for i in range(n-2):
  if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
    count += 1
    
print(count)

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

count = 0
flag = 0
for ch in s:
  if ch=='A' and flag==0:
    flag = 1
  else:
    flag = 0
  if ch=='B' and flag==1:
    flag = 2
  else:
    flag = 0
  if ch=='C' and flag==2
  	flag = 3
  else: flag = 0
  if flag==3:
    count += 1
    flag = 0

print(count)
Problem p02830 (python)

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

s = ''
for i in range(n):
  s = s + s1[i]
  s = s + s2[i]

print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
s,t = map(list,input().split())
ans = []
for i in range(n)
  ans.append(s[i])
  ans.append(t[i])
print(''.join(ans))
Problem p02861 (python)

Fixed submission:
n = int(input())
location = [list(map(int, input().split())) for _ in range(n)]

from itertools import permutations
import math
distance = []
for route in list(permutations(range(1,n+1))):
  route = list(route)

  dis = 0
  for i in range(0,n-1):
    d = math.sqrt(pow(location[route[i]-1][0]-location[route[i+1]-1][0],2) + pow(location[route[i]-1][1]-location[route[i+1]-1][1],2))
    dis = dis + d
  distance.append(dis)
  
ans = sum(distance)/len(list(permutations(range(1,n+1))))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
dis = [list(map(int,input().split())) for _ in range(n)]
ans = 0
num = 0
from itertools import permutations
for path in list(permutations(range(n))):
  num += 1
  path = list(path)
  distance = 0
  for i in range(1,n):
    xi = dis[path[i-1]][0]
    xj = dis[path[i]][0]
    yi = dis[path[i-1]][1]
    xj = dis[path[i]][1]
    distance += (pow(xi-xj,2)+pow(yi-yj,2))**0.5
  ans = ans + distance
ans = ans/num
print(ans)
Problem p02899 (python)

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

ans = [0]*n
for a in list(enumerate(l)):
  a = list(a)
  ans[a[1]-1] = a[0]+1

for _ in ans:
  print(_, ' ', end='')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = map(int,input().split())
ans = [0]*n
for i,j in enumerate(a,start=1):
  ans[j] = i
for i in range(n):
  print(ans[i],' ', end='')
Problem p02947 (python)

Fixed submission:
n = int(input())
dic = {}
for i in range(n):
  s = input()
  s = sorted(s)
  s = ''.join(s)
  if s not in dic:
    dic[s] = 1
  else:
    dic[s] += 1

ans = 0
for _ in dic:
  if dic[_]>1: ans = ans + int(dic[_]*(dic[_]-1)/2)
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
dic = {}
from collections import Counter
for i in range(n):
  s = list(input())
  s = sorted(s)
  if s not in dic: dic[s] = 1
  else: dic[s] += 1
a = dic.values()
ans = 0
for i in range(len(a)):
  ans += a[i]*(a[i]-1)/2
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
counters = {}
from collections import Counter
for i in range(n):
  s = input()
  c = Counter(s)
  if c not in counters: counters[c] = 1
  else: counters[c] += 1
a = counters.values()
ans = 0
for i in range(len(a)):
  ans += a[i]*(a[i]-1)/2
print(ans)
Problem p02953 (python)

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

flag = True
for i in range(n-1,0,-1):
  if h[i]>=h[i-1]:
    continue
  elif h[i-1]-h[i]==1:
    h[i-1] -= 1
  else:
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')

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

flag = True
for i in range(n,0,-1):
  if h[i]>=h[i-1]:
    continue
  elif h[i-1]-h[i]==1:
    h[i-1] -= 1
  else:
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')

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

if n==1:
  print('Yes')
  exit()
  
if h[0]>=h[1]: h[0] -= 1
for i in range(1,n-1):
  if h[i]>=h[i-1] and h[i]>=h[i+1]:
    h[i] -= 1
  print(h)


if h == sorted(h):
  print('Yes')
else:
  print('No')

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

if h[0]>h[1]: h[0] -= 1
for i in range(1,n-1):
  if h[i]>h[i-1] and h[i]>h[i+1]:
    h[i] -= 1
    
if h == sorted(h):
  print('Yes')
else:
  print('No')
Problem p02971 (python)

Fixed submission:
n = int(input())
num = []
maxnum = 0
count = 1
for i in range(n):
  a = int(input())
  if a>maxnum:
    maxnum = max(maxnum,a)
    count = 1
  elif a==maxnum:
    count += 1
  num.append(a)
  
for i in range(n):
  if count>1:
    print(maxnum)
  else:
    if num[i]!=maxnum:
      print(maxnum)
    else:
      subnum = num[0:i] + num[i+1:n]
      subnum = sorted(subnum)
      print(subnum[n-2])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
a1 = sorted(a)
if a1[n-1]==a1[n-2]:
  flag = True ## true = have repeat
  maxone = a1[n-1]
else:
  flag = False ## false = no repeat
  maxone = a1[n-1]
  maxtwo = a1[n-2]
for i in range(n):
  if a[i]==1max and flag==True: print(maxone)
  elif a[i]==1max and flag==False: print(maxtwo)
  elif a[i]!=1max: print(maxone)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]
a1 = sorted(a)
if a1[n-1]==a1[n-2]:
  flag = True ## true = have repeat
  1max = a1[n-1]
else:
  flag = False ## false = no repeat
  1max = a1[n-1]
  2max = a1[n-2]
for i in range(n):
  if a[i]==1max and flag==True: print(1max)
  elif a[i]==1max and flag==False: print(2max)
  elif a[i]!=1max: print(1max)
Problem p02993 (python)

Fixed submission:
s = input()
for i in range(1,4):
  if s[i]==s[i-1]:
    print('Bad')
    exit()
print('Good')

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
total_num = b-a+1
# # of x%c==0
c_num = b//c - (a-1)//c
d_num = b//d - (a-1)//d
from fractions import gcd
lcm = c*d/gcd(c,d)
cd_num = b//lcm - (a-1)//lcm
print(total_num-c_num-d_num+cd_num)

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

n = b-a-1
n_c = n//c
n_d = n//d
n_gap = n//(c*d)

print(n-n_c-n_d+n_gap+1)

Buggy submission (verdict: Runtime Error):
s = list(map(int, input().split()))
for i in range(1,4):
  if s[i]==s[i-1]:
    print('Bad')
    exit()
print('Yes')
Problem p03029 (python)

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

p += a*3
ans = int(p/2)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
X=[]
for i in range(n):
    s,p=input().split()
    X.append((s,100-int(p),i+1))
X=sorted(X,key=lambda x:(x[0],x[1]))
for i in range(n):
    print(X[i][2])
Problem p03031 (python)

Fixed submission:
n,m = map(int,input().split())
light = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in range(1<<n):
  flag = True
  for j in range(m):
    l = light[j][1:]
    count = 0
    for s in l:
      if i & (1<<(s-1)):
        count += 1
    if count%2 != p[j]:
      flag = False
  if flag==True:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = []
for i in range(m):
  ks = list(map(int,input().split()))
  s.append(ks)
p = list(map(int,input().split()))
ans = 0
for i in range(2**n):
  flag = True
  for j in range(m):
    count = 0
    for k in range(s[m][0]):
      if i & (1<<(s[m][k+1]-1)): count += 1
    if count%2!=p[j]: flag = False
  if flag==True: ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
light = [list(map(int,input().split())) for _ in range(m)]
p = list(map(int,input().split()))

ans = 0
for i in range(1<<n):
  flag = True
  for i in range(m):
    l = light[m][1:]
    count = 0
    for s in l:
      if i & (1<<(s-1)):
        count += 1
    if count%2 != p[m]:
      flag = False
  if flag==True:
    ans += 1
print(ans)