Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def main()
  a=int(input())
  s=input()
  if 3200<=a<5000:
    print(s)
  elif 2800<=a<3200:
    print("red")
main()


Fixed submission:
a=int(input())
s=input()
if 2800<=a<3200:
  print("red")
elif 3200<=a<5000:
  print(s)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=map(int,input().split())
s=sum(1/i) for i in A
t=1/s
print(t)

Fixed submission:
N=int(input())
A=map(int,input().split())
s=sum(1/i for i in A)
t=1/s
print(t)
Buggy python submission (verdict: Runtime Error):
N=int(input())
v=list(map(int,input().split()))
while len(v)>1:
  v=v.sort()
  v1=v.pop(0)
  v2=v.pop(0)
  v.append((v1+v2)/2)
print(v[0])

Fixed submission:
N=int(input())
v=list(map(int,input().split()))
while len(v)>1:
  v=sorted(v)
  v_1=v.pop(0)
  v_2=v.pop(0)
  v.append((v_1+v_2)/2)
print(v[0])

Buggy python submission (verdict: Runtime Error):
N=int(input())
v=list(map(int,input().split()))
while len(v)>1:
  v=v.sort()
  v1=v[0]
  del v[0]
  v2=v[0]
  del v[0]
  v.append((v1+v2)/2)
print(v)

Fixed submission:
N=int(input())
v=list(map(int,input().split()))
while len(v)>1:
  v=sorted(v)
  v_1=v.pop(0)
  v_2=v.pop(0)
  v.append((v_1+v_2)/2)
print(v[0])

Buggy python submission (verdict: Runtime Error):
N=int(input())
v=list(map(int,input().split()))
s=v.sort()
s[0]=(s[0]+s[1])/2
for i in range(1,N):
  s[i]=(s[i]+s[i+1])/2
print(sum(s))


Fixed submission:
N=int(input())
v=list(map(int,input().split()))
while len(v)>1:
  v=sorted(v)
  v_1=v.pop(0)
  v_2=v.pop(0)
  v.append((v_1+v_2)/2)
print(v[0])
Buggy python submission (verdict: Runtime Error):
,X=map(int,input().split())
a=[]
for i in range(0,K):
  a.append(X-i)
for j in range(1,K):
  a.append(X+j)
s=a.sort()
print(s)

Fixed submission:
K,X=map(int,input().split())
for i in range(X-K+1,X+K):
  print(i)

Buggy python submission (verdict: Runtime Error):
,X=map(int,input().split())
a=[]
for i in range(0,K):
  a.append(X-i)
for i in range(1,K):
  a.append(X+i)
s=a.sort()
print(s)

Fixed submission:
K,X=map(int,input().split())
for i in range(X-K+1,X+K):
  print(i)
Buggy python submission (verdict: Runtime Error):
def main:
  s=0
  N=int(input())
  for i in range(1,N+1):
    if (len(str(i)))%2!=0:
      s+=1
  print(s)
main

Fixed submission:
s=0
N=int(input())
for i in range(1,N+1):
  if (len(str(i)))%2!=0:
    s+=1
print(s)

Buggy python submission (verdict: Runtime Error):
def main:
  s=0
  N=int(input())
  for i in range(1,N+1):
    if (len(str(i)))%2!=0:
      s+=1
  print(s)
main()

Fixed submission:
s=0
N=int(input())
for i in range(1,N+1):
  if (len(str(i)))%2!=0:
    s+=1
print(s)

Buggy python submission (verdict: Runtime Error):
def main:
  s=0
  N=int(input())
  for i in range(1,N+1):
    if (len(str(i)))%2!=0:
      s+=1
  print(s)
  

Fixed submission:
s=0
N=int(input())
for i in range(1,N+1):
  if (len(str(i)))%2!=0:
    s+=1
print(s)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
if A-K==-(B-K):
  print(K)
else:
  print("IMPOSSIBLE")


Fixed submission:
A,B=map(int,input().split())
if (A+B)%2==0:
  print((A+B)//2)
else:
  print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
k=set(list)
A_1=k[0]
A_2=k[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(list[1])


Fixed submission:
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
A_1=l[0]
A_2=l[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(A_2)

Buggy python submission (verdict: Runtime Error):
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  del list[j]
  print(max(list))
 

Fixed submission:
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
A_1=l[0]
A_2=l[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(A_2)

Buggy python submission (verdict: Runtime Error):
N=int(input())
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  del list[j]
  print(max(list))
 

Fixed submission:
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
A_1=l[0]
A_2=l[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(A_2)

Buggy python submission (verdict: Runtime Error):
N=int(input()
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  del list[j]
  print(max(list))

  

Fixed submission:
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
A_1=l[0]
A_2=l[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(A_2)

Buggy python submission (verdict: Runtime Error):
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  del list[j]
  print(max(list))

Fixed submission:
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
A_1=l[0]
A_2=l[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(A_2)

Buggy python submission (verdict: Runtime Error):
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  list=list.remove(list[j])
  print(max(list))

Fixed submission:
N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
A_1=l[0]
A_2=l[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(A_2)
Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
list=[]
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
print(ans)

Fixed submission:
L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)

Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
list=[]
if (R-L)>=2018 or L==0:
  print(0)
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      s=i*j
      m=s%2019
      list.append(m)
print(min(list))

Fixed submission:
L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)

Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
list=[]
if (R-L)>=2018 or L==0:
  print(0)
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      s=i*j
      m=s%2019
      list.append(m)
print(min(list))

Fixed submission:
L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)

Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
list=[]
if (R-L)>=2018:
  print(0)
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      s=i*j
      m=s%2019
      list.append(m)
print(min(list))
  

Fixed submission:
L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)

Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,I*j//2019)
print(ans)
  

Fixed submission:
L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)

Buggy python submission (verdict: Runtime Error):
L,R=map(int,input().split())
if (L-R)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,I*j//2019)
print(ans)
  

Fixed submission:
L,R=map(int,input().split())
if (R-L)>=2018:
  print(0)
else:
  ans=2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)
Buggy python submission (verdict: Runtime Error):
S=input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3}:
  print("Bad")
else:
  print("Good")


Fixed submission:
S=input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print("Bad")
else:
  print("Good")

Buggy python submission (verdict: Runtime Error):
S=int(input())
if S[0]==S[1] or S[1]==S[2} or S[2]==S[3]:
  print("Bad")
else:
  print("Good")

Fixed submission:
S=input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print("Bad")
else:
  print("Good")
Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
t=s.remove(min(abs(s)))
print(sum(t))

Fixed submission:
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
s.sort(key=lambda x: abs(x))
del s[0]
print(sum(s))

Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
s.remove(min(abs(s)))
print(sum(s))

Fixed submission:
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
s.sort(key=lambda x: abs(x))
del s[0]
print(sum(s))

Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
＃リンゴの味のリスト
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
＃リンゴの味の絶対値のリスト
s.remove(min(abs(s[i-1])))
print(sum(s))

  

Fixed submission:
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
s.sort(key=lambda x: abs(x))
del s[0]
print(sum(s))

Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
t=min(abs(s[i-1]))
s.remove(t)
print(sum(s))

Fixed submission:
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
s.sort(key=lambda x: abs(x))
del s[0]
print(sum(s))

Buggy python submission (verdict: Runtime Error):
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
s.remove(min(abs(j for j in s)))
print(sum(s))

Fixed submission:
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
s.sort(key=lambda x: abs(x))
del s[0]
print(sum(s))
Buggy python submission (verdict: Runtime Error):
import fractions
A,B,C,D=map(int,input().split())
#B以下のものの数からA-1以下のものの数を引く
e=fractions.gcd(C,D)
a_c=(A-1)//C #A-1以下のCの倍数の個数
b_c=B//C  #B以下のCの倍数の個数
a_d=(A-1)//D
b_d=B//D
a_cd=A//e
b_cd=B//e
s=A-1-(a_c+a_d-a_cd)　＃A-1以下の数字のうちCでもDでも割り切れないものの個数
t=B-(b_c+b_d-b_cd)　#B以下の数字の
u=t-s
print(u)

Fixed submission:
A,B,C,D=map(int,input().split())
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
def lcm(a,b):
  return (a*b)//gcd(a,b)
s=(A-1)//C
t=(A-1)//D
u=(A-1)//lcm(C,D)
v=s+t-u
w=A-1-v
S=B//C
T=B//D
U=B//lcm(C,D)
V=S+T-U
W=B-V
print(W-w)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,D=map(int,input().split())
s=0
for i in range(A,B+1):
  if i%C!=0 and i%D!=0:
    s+=1
print(s)

Fixed submission:
A,B,C,D=map(int,input().split())
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
def lcm(a,b):
  return (a*b)//gcd(a,b)
s=(A-1)//C
t=(A-1)//D
u=(A-1)//lcm(C,D)
v=s+t-u
w=A-1-v
S=B//C
T=B//D
U=B//lcm(C,D)
V=S+T-U
W=B-V
print(W-w)

Buggy python submission (verdict: Runtime Error):
A,B,C,D=map(int,input().split())
s=0
for i in range(A,B+1):
  if i%C!=0 and i$D!=0:
    s+=1
print(s)

Fixed submission:
A,B,C,D=map(int,input().split())
def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
def lcm(a,b):
  return (a*b)//gcd(a,b)
s=(A-1)//C
t=(A-1)//D
u=(A-1)//lcm(C,D)
v=s+t-u
w=A-1-v
S=B//C
T=B//D
U=B//lcm(C,D)
V=S+T-U
W=B-V
print(W-w)
Buggy python submission (verdict: Runtime Error):
N=input()
X=[list(map(int,input().split())) for i in range(N)]
X=sorted(X,key=lambda x:x[1])
s=0
t=0
for i in range(N):
  s+=X[i][0]
  if s>X[i][1]:
    print("No")
    break
  else:
    t+=1
if t==N:
  print("Yes")
    

Fixed submission:
N=int(input())
X=[list(map(int,input().split())) for i in range(N)]
X=sorted(X,key=lambda x:x[1])
s=0
t=0
for i in range(N):
  s+=X[i][0]
  if s>X[i][1]:
    print("No")
    break
  else:
    t+=1
if t==N:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N,X=map(int,input().split())
L=list(map(int,input().split()))
D=[]
D.append(0)
for i in range(1,N+1):
  D.append(D[i-1]+L[i-1])
s=0
for j in range(0,N+1):
  if D[j]<=X:
    s+=1
print(s)

Fixed submission:
X,A=map(int,input().split())
if X<A:
  print(0)
else:
  print(10)
Buggy python submission (verdict: Runtime Error):
A,P=map(int,input())
print((A*3+P)//2)

Fixed submission:
A,P=map(int,input().split())
c=(A*3+P)//2
print(c)
Buggy python submission (verdict: Runtime Error):
def main():
  x=[]
  r,D,X=map(int,input().split())
  x.append(X)
  for i in range(1:11):
    x.append(r*x[i-1]-D)
    print(x[i])
main()

Fixed submission:
def main():
  r,D,X_2000=map(int,input().split())
  x=[]
  x.append(X_2000)
  for i in range(1,11):
    x.append(r*x[i-1]-D)
    print(x[i])
main()

Buggy python submission (verdict: Runtime Error):
def main():
  r,D,X_2000=map(int,input().split())
  x=[]
  x.append(X_2000)
  for i in range(1:11):
    x.append(r*x[i-1]-D)
    print(x[i])
main()

Fixed submission:
def main():
  r,D,X_2000=map(int,input().split())
  x=[]
  x.append(X_2000)
  for i in range(1,11):
    x.append(r*x[i-1]-D)
    print(x[i])
main()

Buggy python submission (verdict: Runtime Error):
def main():
  r,D,X_2000=map(int,input().split())
  x=[]
  x.append(X_2000)
  for i in range(1:11):
    x[i]=r*x[i-1]-D
    x.append(x[i])
    print(x[i])
main()

  

Fixed submission:
def main():
  r,D,X_2000=map(int,input().split())
  x=[]
  x.append(X_2000)
  for i in range(1,11):
    x.append(r*x[i-1]-D)
    print(x[i])
main()
Buggy python submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
s=0
for i in range(N):
  if H[i]>=max(H[0:i]):
    s+=1
print(s)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
s=1
for i in range(1,N):
  if H[i]>=max(H[0:i]):
    s+=1
print(s)
Buggy python submission (verdict: Runtime Error):
S=input()
s=0
for i in range(len(S)):
  if S[i]==S[i+1]==S[i+2]==0:
    s+=1
    S[i+1]=1
  elif S[i]==S[i+1]==S[i+2]==1:
    s+=1
    S[i+1]==0
  elif S[i]==S[i+1] and S[i+1]!=S[i+2]:
    s+=1
    S[i]=S[i+2]
  elif S[i]!=S[i+1] and S[i+1]==S[i+2]:
    s+=1
    S[i+2]==S[i]
  else:
    s=s
print(s)

Fixed submission:
S=input()
s=0
t=0
for i in range(len(S)):
  if i%2==0 and S[i]=="0":
    s+=1
  elif i%2!=0 and S[i]=="1":
    s+=1
for j in range(len(S)):
  if j%2==0 and S[j]=="1":
    t+=1
  elif j%2!=0 and S[j]=="0":
    t+=1
print(min(s,t))
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
cnt=0 #本数
ans=0 #値段
for i in range(N):
  cnt+=A[i][1]
  if cnt>=m:
    over=cnt-m
    ans+=over*A[i][0]
    cnt+=over
  else:
    ans+=A[i][0]*A[i][1]
print(ans)

Fixed submission:
N,M=map(int,input().split())
k=M
s=0
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
while k>0:
  for i in range(N):
    if k>A[i][1]:
      s+=A[i][0]*A[i][1]
      k=k-A[i][1]
    else:
      s+=A[i][0]*k
      k=0
print(s)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
k=M
s=0
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
for i in range(N):
while k>0:
  for i in range(N):
    if k>A[i][1]:
      s+=A[i][0]*A[i][1]
      k=k-A[i][1]
    else:
      s+=A[i][0]*k
      k=0
print(s)

Fixed submission:
N,M=map(int,input().split())
k=M
s=0
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
while k>0:
  for i in range(N):
    if k>A[i][1]:
      s+=A[i][0]*A[i][1]
      k=k-A[i][1]
    else:
      s+=A[i][0]*k
      k=0
print(s)
Buggy python submission (verdict: Runtime Error):
i

Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)

Buggy python submission (verdict: Runtime Error):
S=list(input())
s=0 #取り除いたキューブの数
i=0 
while len(set(S))!=len(S):
  if S[i]==S{i+1]==0 or S{i]==S[i+1]==1:
    s=s
    i+=1
  else:
    s+=2
    del S[i:i+2]
    i=0
print(s)

Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)

Buggy python submission (verdict: Runtime Error):
S=list(input())
N=len(S)
s=0 #取り除いたキューブの数
i=0 
while len(set(S))!=len(S):
  if S[i]==S{i+1]==0 or S{i]==S[i+1]==1:
    s=s
    i+=1
  else:
    s+=2
    i=0
print(s)
    


Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)

Buggy python submission (verdict: Runtime Error):
S=list(input())
s=0
i=0
if S[i]==S[i+1]==0 or S[i]==S[i+1]==1:
  s=s
  i+=1
else:
  s+=2
  del S[i:i+2]
  i=0
print(s)

Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)

Buggy python submission (verdict: Runtime Error):
S=list(int(input()))
s=0
i=0
if S[i]==S[i+1]==0 or S[i]==S[i+1]==1:
  s=s
  i+=1
else:
  s+=2
  del S[i:i+2]
  i=0
print(s)

Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)

Buggy python submission (verdict: Runtime Error):
S=list(int(input()))
s=0
i=0
if S[i]==S{i+1]==0 or S[i]==S[i+1]==1:
  s=s
  i+=1
else:
  s+=2
  del S[i:i+2]
  i=0
print(s)

Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)

Buggy python submission (verdict: Runtime Error):
S=list(input())
N=len(S)
def main():
  ans=0
  i=0
  while len(S)>0 and i<N-1:
    if (S[i]==0 and S[i+1]==1) or (S[i]==1 and S[i+1]==0):
      S=S.remove(S[i:i+2])
      ans+=1
      i=0
    else:
      ans=ans
      i+=1
  print(ans)
main()

Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)

Buggy python submission (verdict: Runtime Error):
S=list(input())
N=len(S)
def main():
  ans=0
  i=0
  while len(S)>0 :
    if (S[i]==0 and S[i+1]==1) or (S[i]==1 and S[i+1]==0):
      S.remove(S[i:i+2])
      ans+=1
    else:
      ans=ans
      i+=1
  print(ans)
main()

Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)

Buggy python submission (verdict: Runtime Error):
S=list(input())
N=len(S)
ans=0
i=0
while len(S)>0:
  if S[i]==0 and S[i+1]==1 or S[i]==1 and S[i+1]==0:
    S.remove(S[i:i+2])
    ans+=1
  else:
    ans=ans
    i+=1
print(ans)

Fixed submission:
S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)
Buggy python submission (verdict: Runtime Error):
N=int(input())
h=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
DP[1]=abs(h[0]-h[1])
for i in raange(1,N-1):
  DP[i+1]=min(DP[i]+abs(h[i]-h[i+1]),DP[i-1]+abs(h[i-1]-h[i+1]))
print(DP[N-1])
  

Fixed submission:
N=int(input())
h=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
DP[1]=abs(h[0]-h[1])
for i in range(1,N-1):
  DP[i+1]=min(DP[i]+abs(h[i]-h[i+1]),DP[i-1]+abs(h[i-1]-h[i+1]))
print(DP[N-1])
Buggy python submission (verdict: Runtime Error):
import collections
import math
N,P=map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c=collections.Counter(prime_factorize(P))
n=len(c.keys())
w=1
for i in c.keys():
  if c[i]>=N:
    k=math.ceil(c.values(i)/N)
    w=w*(i**k)
print(w)

Fixed submission:
import collections
import math
N,P=map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c=collections.Counter(prime_factorize(P))
w=1
for i in c.keys():
  if c[i]>=N:
    k=math.floor(c[i]/N)
    w=w*(i**k)
  else:
    w=w
print(w)

Buggy python submission (verdict: Runtime Error):
import collections
import math
N,P=map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c=collections.Counter(prime_factorize(P))
n=len(c.keys())
w=1
for i in c.keys():
  if c.values(i)>=N:
    k=math.ceil(c.values(i)/N)
    w=w*(i**k)
print(w)
    
    

Fixed submission:
import collections
import math
N,P=map(int,input().split())
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c=collections.Counter(prime_factorize(P))
w=1
for i in c.keys():
  if c[i]>=N:
    k=math.floor(c[i]/N)
    w=w*(i**k)
  else:
    w=w
print(w)
Buggy python submission (verdict: Runtime Error):
import collections
S=list(input())
c=collections.Counter(S)
n=c["W"]
s=0
i=0
while "B" in S[0:n]:
  if S[i]=="B" and S[i+1]=="W":
    S[i]="W" and S[i+1]="B"
    s+=1
    i=i
  else:
    i+=1
print(s)


Fixed submission:
S=list(input())
N=len(S)
s=0
ans=0
for i  in range(N):
  if S[i]=="B":
    s+=1
  elif S[i]=="W":
    ans+=s
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h=sorted(h)
t=[]
for i in range(N-K+1):
  s=h[i+k-1]-h[i]
  t.append(s)
print(min(t))
  

Fixed submission:
N,K=map(int,input().split())
h=list(int(input()) for i in range(N))
h=sorted(h)
t=[]
for i in range(N-K+1):
  s=h[i+K-1]-h[i]
  t.append(s)
print(min(t))
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
print(math.ceil((N-1)/(K-1)))

Fixed submission:
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
print(math.ceil((N-1)/(K-1)))
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
DP=[0]*N
l=0
for i,x in enumerate(S):
  DP[i]+=l
    if S[i]=="W":
      l+=1
r=0
for j,y in enumerate(S[::-1]):
  DP[N-1-j]+=r
    if S[N-1-j]=="E":
      r+=1
print(min(DP))
  

Fixed submission:
N=int(input())
S=input()
DP=[0]*N
l=0
for i,x in enumerate(S):
  DP[i]+=l
  if x=="E":
    l+=1
r=0
for i,y in enumerate(S[::-1]):
  DP[N-1-i]+=r
  if y=="W":
    r+=1
print(N-1-max(DP))

Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
DP=[0]**N
DP[0]=S[1:].count("E")
for i in range(1,N):
  if S[i]=="E":
    DP[i]=DP[i-1]-1+S[:i].count("W")
  else:
    DP[i]=DP[i-1]+S[:i].count("W")
print(min(DP))


Fixed submission:
N=int(input())
S=input()
DP=[0]*N
l=0
for i,x in enumerate(S):
  DP[i]+=l
  if x=="E":
    l+=1
r=0
for i,y in enumerate(S[::-1]):
  DP[N-1-i]+=r
  if y=="W":
    r+=1
print(N-1-max(DP))
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=[list(map(int,input().split())) for i in range(N)]
m=0
a=0
r=0
c=0
h=0
for i in range(N):
  if S[i][0]=="M":
    m+=1
  if S[i][0]=="A":
    a+=1
  if S[i][0]=="R":
    r+=1
  if S[i][0]=="C":
    c+=1
  if S[i][0]=="H":
    h+=1
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h*a*c*h+r*c*h)

Fixed submission:
N=int(input())
s=[]
for i in range(N):
  S=input()
  s.append(S)
m=0
a=0
r=0
c=0
h=0
for i in range(N):
  if s[i][0]=="M":
    m+=1
  if s[i][0]=="A":
    a+=1
  if s[i][0]=="R":
    r+=1
  if s[i][0]=="C":
    c+=1
  if s[i][0]=="H":
    h+=1
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)
Buggy python submission (verdict: Runtime Error):
N,Y=map(int,input().split())
for x in range(0,N+1):
  for y in range(N+1-x):
    for z in range(N+1-x-y):
      if 10000*x+5000*y+1000*z==Y:
        print(x,y,z)
        break
     else:
       print(-1,-1,-1)

Fixed submission:
N,Y=map(int,input().split())
for x in range(N+1):
  for y in range(N+1-x):
    z=N-x-y
    if 10000*x+5000*y+1000*z==Y:
      print(x,y,z)
      exit()
print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
s_=sorted(s,reverse=True)
t_=sorted(t)
A.append(s_)
A.append(t_)
B=sorted(A)
if B[0]=s_t:
  print("Yes")
else:
  print("No")

Fixed submission:
s=input()
t=input()
s_=sorted(s)
t_=sorted(t,reverse=True)
A=[]
A.append(s_)
A.append(t_)
B=sorted(A)
if B[0]==s_ and B[0]!=B[1]:
  print("Yes")
else:
  print("No")