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

s=sum(A)
import math
def yakusu(n):
  ans_local=set()
  for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
      ans_local = ans_local | set([i,n//i]) #setなので平方数でもOK
  return list(ans_local)  #必要に応じてsort

yaku=sorted(yakusu(s), reverse=1)
#print(yaku)
for mod in yaku:
    B=[i%mod for i in A if i%mod!=0]
    B.sort()
    r=[B[0]]*len(B)
    for i in range(len(B)-1):
        r[i+1]= r[i]+B[i+1]
    now=float("INF")
    for i in range(1,len(B)): #切り方
        if r[i-1] ==  mod*(len(B)-i)-(r[-1]-r[i-1]) and r[i-1]<=k:
            print(mod);exit()

    


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

s=sum(A)
import math
def yakusu(n):
  ans_local=set()
  for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
      ans_local = ans_local | set([i,n//i]) #setなので平方数でもOK
  return list(ans_local)  #必要に応じてsort

yaku=sorted(yakusu(s), reverse=1)
#print(yaku)
for mod in yaku:
    B=[i%mod for i in A if i%mod!=0]
    if B==[] : print(mod);exit()
    if len(B)==1:
        q=B[0]
        if 0<=q<=k or mod-k<=q: print(mod);exit()
        else:continue
    B.sort()
    r=[B[0]]*len(B)
    for i in range(len(B)-1):
        r[i+1]= r[i]+B[i+1]
    now=float("INF")
    for i in range(1,len(B)): #切り方
        if r[i-1] ==  mod*(len(B)-i)-(r[-1]-r[i-1]) and r[i-1]<=k:
            print(mod);exit()

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

s=sum(A)
import math
def yakusu(n):
  ans_local=set()
  for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
      ans_local = ans_local | set([i,n//i]) #setなので平方数でもOK
  return list(ans_local)  #必要に応じてsort

yaku=sorted(yakusu(s), reverse=1)
#print(yaku)
for mod in yaku:
    B=[i%mod for i in A if i%mod!=0]
    B.sort()
    r=[B[0]]*len(B)
    for i in range(len(B)-1):
        r[i+1]= r[i]+B[i+1]
    now=float("INF")
    for i in range(1,len(B)):
        now= min(max(r[i-1], mod*(len(B)-i)-(r[-1]-r[i-1])),now)
    if now<=k:
        print(mod);exit()
    

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

s=sum(A)
import math
def yakusu(n):
  ans_local=set()
  for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
      ans_local = ans_local | set([i,n//i]) #setなので平方数でもOK
  return list(ans_local)  #必要に応じてsort

yaku=sorted(yakusu(s), reverse=1)
#print(yaku)
for mod in yaku:
    B=[i%mod for i in A if i%mod!=0]
    if B==[] : print(mod);exit()
    if len(B)==1:
        q=B[0]
        if 0<=q<=k or mod-k<=q: print(mod);exit()
        else:continue
    B.sort()
    r=[B[0]]*len(B)
    for i in range(len(B)-1):
        r[i+1]= r[i]+B[i+1]
    now=float("INF")
    for i in range(1,len(B)): #切り方
        if r[i-1] ==  mod*(len(B)-i)-(r[-1]-r[i-1]) and r[i-1]<=k:
            print(mod);exit()
Buggy python submission (verdict: Runtime Error):
n=int(input())
sp=0
A=list(map(int,input.split()))
for i in range(n):
  if i+1!=A[i]:
    sp+=1
if sp==0 or sp==2:
  print("YES")
  exit()
print("NO")


Fixed submission:
n=int(input())
sp=0
A=list(map(int,input().split()))
for i in range(n):
  if i+1!=A[i]:
    sp+=1
if sp==0 or sp==2:
  print("YES")
  exit()
print("NO")

Buggy python submission (verdict: Runtime Error):
n=int(input())
sp=0
A=list(map(int,input.split()))
for i in range(n):
  if i+1!=A[i]:
    sp+=1
if sp==0 or 2:
  print("YES")
  exit()
print("NO")


Fixed submission:
n=int(input())
sp=0
A=list(map(int,input().split()))
for i in range(n):
  if i+1!=A[i]:
    sp+=1
if sp==0 or sp==2:
  print("YES")
  exit()
print("NO")
Buggy python submission (verdict: Runtime Error):
S=int(input())

for i in range(10**6):
  if int((S+i**2)**(1/2))==(S+i**2)**(1/2):
    y=i
    x=int((S+i**2)**(1/2))
    
print("{} {} {} {} {} {}".format(0,0,x,y,y,x))

Fixed submission:
k=int(input())

print(3*k*k)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
prnit((a-0.01)//(2*b+1)+1)

Fixed submission:
a,b=map(int,input().split())
print(int((a-0.01)//(2*b+1)+1))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(input()) for i in range(n)]
if n==2:
  print(A[1])
  print(A[0])
  exit()

for i in range(n):
  if i==0:
    q=max(A[1:])
    print(q)
    continue
  if A[i]!=q:
    print(q)
  else:
    print(max(A[:i]+A[i+1:]))


Fixed submission:
n=int(input())
A=[int(input()) for i in range(n)]
B=sorted(A)
f=B[-1]
s=B[-2]
q=A.index(f)

for i in range(q):
  print(f)
print(s)
for i in range(n-q-1):
  print(f)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=[int(input()) for i in range(n)]


for i in range(n):
  p=A[i]
  A[i]=0
  print(max(A))
  A[i]=p

Fixed submission:
n=int(input())
A=[int(input()) for i in range(n)]
B=sorted(A)
f=B[-1]
s=B[-2]
q=A.index(f)

for i in range(q):
  print(f)
print(s)
for i in range(n-q-1):
  print(f)
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
M=[0]*n
K=[k for k in range(n)][1::2]+[k for k in range(n)][::2]
for i in K:
  M[i+1]=M[i-1]+2*(M[i]-M[i-1])
  
d=(sum(A)-sum(M))//n
for i in range(n):
  print(M[i]+d)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
M=[0]*n
K=[k for k in range(n)][1::2]+[k for k in range(n)][::2]
for i in K:
  M[(i+1)%n]=M[i-1]+2*(A[i%n]-A[i-1])
  
d=(sum(A)-sum(M))//n
for i in range(n):
  print(M[i]+d)
Buggy python submission (verdict: Runtime Error):
import math
n,b=map(int,input().split())
def kaijo(x):
  return math.factorial(x)

def C(x,y):
  return(kaijo(x)//(kaijo(y)*kaijo(x-y)))

r=n-b
if n==b:
  for i in range(b):
    print(1)
    exit()
for i in range(1,b+1):
  print((C(b-1,i-1)*C(r+1,i))%(10**9+7))


Fixed submission:
import math
n,b=map(int,input().split())
def kaijo(x):
  return math.factorial(x)

def C(x,y):
  if x>=y:
    return(kaijo(x)//(kaijo(y)*kaijo(x-y)))

r=n-b

for i in range(1,b+1):
  if r+1<i:
    print(0)
    continue
  print((C(b-1,i-1)*C(r+1,i))%(10**9+7))
Buggy python submission (verdict: Runtime Error):
w,h=map(int,input().split())
cx,cy=w/2,h/2
x,y=map(int,input().split())
if x==cx and y==cy:
    print(w*h/2,1);exit()
else:
    print(w*h/2,0)
    exit()
    

Fixed submission:
w,h,x,y=map(int,input().split())
cx,cy=w/2,h/2
# x,y=map(int,input().split())
if x==cx and y==cy:
    print(w*h/2,1);exit()
else:
    print(w*h/2,0)
    exit()
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=[int(input()) for i in range(m)]
NG=[0]*10**5
for i in range(m):
    NG[A[i]]=1
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

@lru_cache(maxsize=10**10)
def qwe(x):
    if x==n:return 1
    if x>n:return 0
    if NG[x+1] and NG[x+2]: print(0);exit()
    if NG[x+1]:return qwe(x+2)%mod
    if NG[x+2]:return qwe(x+1)%mod
    return (qwe(x+2)+qwe(x+1))%mod
print(qwe(0))
    



    

Fixed submission:
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
n,m=map(int,input().split())
A=[int(input()) for i in range(m)]
NG=[0]*(10**5+10)
for i in A:
    NG[i]=1


@lru_cache(maxsize=10**10)
def qwe(x):
    if x==n:return 1
    if x>n:return 0
    if NG[x+1] and NG[x+2]: print(0);exit()
    if NG[x+1]:return qwe(x+2)%mod
    if NG[x+2]:return qwe(x+1)%mod
    return (qwe(x+2)+qwe(x+1))%mod
print(qwe(0))
Buggy python submission (verdict: Runtime Error):
L=input()
mod=10**9+7



N=[int(i) for i in L]
keta=len(N)
dp=[[0 for i in range(2)] for j in range(101)]
dp[0][0] = 1
#dp[0][0][1] =0
#dp[0][1][0] =0
#dp[0][1][1] =0

for i in range(keta):
    for smaller in [0,1]:
        if 1:
            for x in range(2 if smaller else (N[i]+1)):
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))]+= dp[i][smaller]*(2 if x==1 else 1)
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))] %=mod
print((dp[keta][0]+ dp[keta][1])%mod)


Fixed submission:
L=input()
mod=10**9+7



N=[int(i) for i in L]
keta=len(N)
dp=[[0 for i in range(2)] for j in range(keta+1)]
dp[0][0] = 1
#dp[0][0][1] =0
#dp[0][1][0] =0
#dp[0][1][1] =0

for i in range(keta):
    for smaller in [0,1]:
        if 1:
            for x in range(2 if smaller else (N[i]+1)):
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))]+= dp[i][smaller]*(2 if x==1 else 1)
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))] %=mod
print((dp[keta][0]+ dp[keta][1])%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=[];C=[];Q=[]
A.sort()
for i in range(m):
    b,c=map(int,input().split())
    Q.append([b,c])

import bisect as bi

#Qの統合
s=set([l[1] for l in Q])
dicts={}
for i in s:
    dicts[i]=0
for l in Q:
    dicts[l[1]]+=l[0]
Q=[[j,i] for i,j in dicts.items()]
Q=sorted(Q, key=lambda x:x[1], reverse=1)
######
#print(Q)

for l in Q:
    b,c=l
    a=bi.bisect_left(A,c)
    if A[0]>=c:
        break
    if a< b:
        A=[c]*a + A[a:]
        break
    
    A= A[b:a]+ [c]*b + A[a:]
    #print(A)
print(sum(A))

Fixed submission:
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
Q=[]
for i in range(m):
    b,c=map(int,input().split())
    Q.append([b,c])

Q=sorted(Q, key=lambda x:x[1], reverse=1)
kae=0

d=[-1]*(n)
now=0
for l in Q:
    b,c=l
    if n-now<b:
        d[now:]=[c]*(n-now)
        break
    d[now:now+b]=[c]*b
    now+=b

#print(d)
ans=sum(A)
now=ans
for kae in range(1,n+1):
    now+=d[kae-1]
    now-=A[kae-1]
    ans=max(ans,now)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=[];C=[];Q=[]
A.sort()
for i in range(m):
    b,c=map(int,input().split())
    Q.append([b,c])

import bisect as bi

#Qの統合
s=set([l[1] for l in Q])
dicts={}
for i in s:
    dicts[s]=0
for l in Q:
    dicts[l[1]]+=l[0]
Q=[[j,i] for i,j in dicts.items()]
Q=sorted(Q, key=lambda x:x[1], reverse=1)
######
print(Q)

for l in Q:
    b,c=l
    a=bi.bisect_left(A,c)
    if A[0]>=c:
        break
    if a< b:
        A=[c]*a + A[a:]
        break
    
    A= A[b:a]+ [c]*b + A[a:]
    print(A)
print(sum(A))

Fixed submission:
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
Q=[]
for i in range(m):
    b,c=map(int,input().split())
    Q.append([b,c])

Q=sorted(Q, key=lambda x:x[1], reverse=1)
kae=0

d=[-1]*(n)
now=0
for l in Q:
    b,c=l
    if n-now<b:
        d[now:]=[c]*(n-now)
        break
    d[now:now+b]=[c]*b
    now+=b

#print(d)
ans=sum(A)
now=ans
for kae in range(1,n+1):
    now+=d[kae-1]
    now-=A[kae-1]
    ans=max(ans,now)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=[];C=[];Q=[]
A.sort()
for i in range(m):
    b,c=map(int,input().split())
    Q.append([b,c])

import bisect as bi
Q=sorted(Q, key=lambda x:x[1], reverse=1)

for l in Q:
    b,c=l
    a=bi.bisect_left(A,c)
    if A[0]>=c:
        break
    if a< b:
        A=[c]*a + A[a:]
        break
    
    A= A[b:a]+ [c]*b + A[a:]
    #print(A)
print(sum(A))

Fixed submission:
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
Q=[]
for i in range(m):
    b,c=map(int,input().split())
    Q.append([b,c])

Q=sorted(Q, key=lambda x:x[1], reverse=1)
kae=0

d=[-1]*(n)
now=0
for l in Q:
    b,c=l
    if n-now<b:
        d[now:]=[c]*(n-now)
        break
    d[now:now+b]=[c]*b
    now+=b

#print(d)
ans=sum(A)
now=ans
for kae in range(1,n+1):
    now+=d[kae-1]
    now-=A[kae-1]
    ans=max(ans,now)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
print(s.replace(s[b-1],lower(s[b-1])))

Fixed submission:
a,s=map(int,input().split())
k=input()
lk=list(k)
l=lk[s-1]
lk[s-1]=l.lower()
print("".join(lk))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input(),split());print(c//a*b)

Fixed submission:
a,b,c=map(int,input().split());print(c//a*b)
Buggy python submission (verdict: Runtime Error):
A=[int(input()) for i in range(5)]
k=int(input())

for i in range(4):
	for i in range(i):
		if A[i]-A[j]>k:
			print(""":(""")
			exit()
print("Yay!")

Fixed submission:
A=[int(input()) for _ in range(5)]
k=int(input())

for i in range(5):
  for j in range(i):
    if A[i]-A[j]>k:
      print(":(")
      exit()
print("Yay!")
Buggy python submission (verdict: Runtime Error):
A=[int(input()) for  i in range(5)]
B=[int(str(A[i])[-1]) for i in range(5)]
if B==[0]*5:
	print(sum(A))
else:
	for i in range(5):
		if B[i]==0:
			B[i]=10
	ans=min(B)
	o=B.index(ans)
print((sum(A)-A[o])+10-(sum(A)-A[o])%10+A[o])

Fixed submission:
A=[int(input()) for i in range(5)]
B=[10 if A[i]%10==0 else A[i]%10 for i in range(5)]
k=B.index(min(B))
C=[(A[i]-0.001)//10*10+10 for i in range(5)]
print(int(sum(C)-C[k]+A[k]))
Buggy python submission (verdict: Runtime Error):
n,m=map(int,iput().split())
s=input()
ACsuu=[0 for i in range(n)]
for i in range(1,n):
  Acsuu[i]=ACsuu[i-1]+(1 if s[i-1:i+1]=="AC" else 0)
for i in range(m):
  a,b=map(int,input().split())
  print(ACsuu[b-1]-ACsuu[a-1])

Fixed submission:
n,m=map(int,input().split())
s=input()
ACsuu=[0 for i in range(n)]
for i in range(1,n):
  ACsuu[i]=ACsuu[i-1]+(1 if s[i-1:i+1]=="AC" else 0)
for i in range(m):
  a,b=map(int,input().split())
  print(ACsuu[b-1]-ACsuu[a-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
s=input()
for i in range(m):
  a,b=map(int,input().split())
  lan=s[a-1:b]
  print(lan.count("AC"))


Fixed submission:
n,m=map(int,input().split())
s=input()
ACsuu=[0 for i in range(n)]
for i in range(1,n):
  ACsuu[i]=ACsuu[i-1]+(1 if s[i-1:i+1]=="AC" else 0)
for i in range(m):
  a,b=map(int,input().split())
  print(ACsuu[b-1]-ACsuu[a-1])

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=input()
for i in m:
  a,b=map(int,input().split())
  lan=s[a-1:b]
  print(lan.count("AC"))

Fixed submission:
n,m=map(int,input().split())
s=input()
ACsuu=[0 for i in range(n)]
for i in range(1,n):
  ACsuu[i]=ACsuu[i-1]+(1 if s[i-1:i+1]=="AC" else 0)
for i in range(m):
  a,b=map(int,input().split())
  print(ACsuu[b-1]-ACsuu[a-1])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append([a,b])

A=sorted(A,key=lambda x:x[0])
ko=0
pri=0
i=0
while ko<=m:
  pri+=A[i][0]*A[i][1]
  ko+=A[i][1]
  i+=1
print(pri-(ko-m)*A[i-1][0])

Fixed submission:
n,m=map(int,input().split())
A=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append([a,b])

A=sorted(A,key=lambda x:x[0])
ko=0
pri=0
i=0
while ko<=m:
  pri+=A[i][0]*A[i][1]
  ko+=A[i][1]
  i+=1
  if ko==m:
    print(pri)
    exit()
print(pri-(ko-m)*A[i-1][0])
Buggy python submission (verdict: Time Limit Exceeded):
a,b=map(int,input().split())
ans=a
for i in range(1,b-a+1):
  ans^=(a+i)
print(ans)

Fixed submission:
a,b=map(int,input().split())
a-=1

def allx(n):
    ans=0
    for i in range(40):
        if i==0:
            if n%4==2 or n%4==1:
                ans+=1
                continue
        c= pow(2,i+1)
        k=n% c
        
        if k>=c//2 and k%2==0:
          ans+=pow(2,i)
    return ans

print(allx(b)^allx(a))
Buggy python submission (verdict: Time Limit Exceeded):
s=input()

ans=0
while "10" in s:
  s=s.replace("10","",1)
  ans+=1
while "01" in s:
  s=s.replace("01","",1)
  ans+=1
print(ans*2)

Fixed submission:
s=input()
print(min(s.count("1"),s.count("0"))*2)
Buggy python submission (verdict: Runtime Error):
n=int(input())
ans=0
for i in range(n):
  a,b=map(str,input().split())
  a=int(a)
  if b=="BTC":
    ans+=a*380000
  elif b=="JPY":
    ans+=a
print(ans)

Fixed submission:
n=int(input())
ans=0
for i in range(n):
  a,b=map(str,input().split())
  a=float(a)
  if b=="BTC":
    ans+=a*380000
  elif b=="JPY":
    ans+=a
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
q=min(b,c)
w=b+c-a
print("{} {}".format(q,max(0,w))


Fixed submission:
a,b,c=map(int,input().split())
q=min(b,c)
w=b+c-a
print("{} {}".format(q,max(0,w)))

Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input(),split())
q=min(b,c)
w=b+c-a
print("{} {}".format(q,w))

Fixed submission:
a,b,c=map(int,input().split())
q=min(b,c)
w=b+c-a
print("{} {}".format(q,max(0,w)))
Buggy python submission (verdict: Runtime Error):
n=input()
A=[]
A.append(n)
for i in range(2,10**6):
  if n%2==0:
    n/=2
  else:
    n=3*n+1
  if n in A:
    print(i)
    exit()
  else:
    A.append(n)

Fixed submission:
n=int(input())
A=[]
A.append(n)
for i in range(2,10**6):
  if n%2==0:
    n/=2
  else:
    n=3*n+1
  if n in A:
    print(i)
    exit()
  else:
    A.append(n)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))+[0]
ans=0

while 1:
  for i in range(n):
    if A[i]>0:
      A[i]-=1
      if A[i+1]==0:
        ans+=1
  if A==[0 for i in range(n)]:
    break
print(ans)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))+[0]
ans=0

while 1:
  for i in range(n):
    if A[i]>0:
      A[i]-=1
      if A[i+1]==0:
        ans+=1
  if not A==[0 for i in range(n+1)]:
    continue
  break
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
print((a-b+1)*(a-c+1))

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
print((a-b+1)*(a-c+1))
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
inf=float("inf")
dp=[inf for i in range(n)]
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(2,n):
	dp[i]=min(dp[i],abs(A[i-1]-A[i]),abs(A[i-2]-A[i]))
print(dp[n])

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
inf=float("inf")
dp=[inf for i in range(n)]
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(2,n):
	dp[i]=min(dp[i],abs(A[i-1]-A[i])+dp[i-1],abs(A[i-2]-A[i])+dp[i-2])
print(dp[n-1])

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
dp=[inf for i in range(n)]
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(2,n):
	dp[i]=min(dp[i],abs(A[i-1]-A[i]),abs(A[i-2]-A[i]))
print(dp[n])

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
inf=float("inf")
dp=[inf for i in range(n)]
dp[0]=0
dp[1]=abs(A[1]-A[0])
for i in range(2,n):
	dp[i]=min(dp[i],abs(A[i-1]-A[i])+dp[i-1],abs(A[i-2]-A[i])+dp[i-2])
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
n,P=map(int,input().split())
A=[]
for i in range(2,10**6+1):
  if P%(i**n)==0:
    A.append(i)
for i in range(2,10**3+1):
  if P%(i**(2*n))==0:
    A.append(i)
for i in range(2,101):
  if P%(i**(3*n))==0:
    A.append(i)
for i in range(2,33):
  if P%(i**(4*n))==0:
    A.append(i)
for i in range(2,30):
  if P%(i**(5*n))==0:
    A.append(i)




if P==10**12:
  A.append(10)
print(max(A))

Fixed submission:
n,P=map(int,input().split())
if n==1:
	print(P)
	exit()
if n>39:
  print(1)
  exit()
ans=1
if n==2:
	for i in range(2,10**6+1):
		while P%(i**2)==0:
			ans*=i
			P/=(i**n)
	
if n==3:
	for i in range(2,10**4+1):
		while P%(i**3)==0:
			ans*=i
			P/=(i**n)
	
if n==4:
	for i in range(2,10**3+1):
		while P%(i**4)==0:
			ans*=i
			P/=(i**n)
	  
if n==5:
	for i in range(2,int(10**2.4)+1):
		while P%(i**5)==0:
			ans*=i
			P/=(i**n)
else:
	for i in range(2,101):
		while P%(i**n)==0:
			ans*=i
			P/=(i**n)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ans=0
for  i in range(10**5):
  if s.count("BW")==0:
    print(ans)
    exit()
  ans+=s.count("BW")
  s=s.replace("BW","WB")



Fixed submission:
s=input()
t=list(s).count("W")
A=[i for i,x in enumerate (list(s)) if x=="W"]
print(int(sum(A)-t*(t-1)/2))

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
ans=0
for  i in range(10**5):
  if s.count("BW")==0:
    print(ans)
    exit()
  s=s.replace("BW","WB",1)
  ans+=1
print(ans)

Fixed submission:
s=input()
t=list(s).count("W")
A=[i for i,x in enumerate (list(s)) if x=="W"]
print(int(sum(A)-t*(t-1)/2))
Buggy python submission (verdict: Runtime Error):
if input()=="22":
  print("Christmas Eve Eve Eve")
if input()=="23":
  print("Christmas Eve Eve")
if input()=="24":
  print("Christmas Eve")
if input()=="25":
  print("Christmas")

Fixed submission:
d=input()
if d=="22":
	print("Christmas Eve Eve Eve")
if d=="23":
	print("Christmas Eve Eve")
if d=="24":
	print("Christmas Eve")
if d=="25":
	print("Christmas")
Buggy python submission (verdict: Runtime Error):
n=int(input())
A=[]
for i in range(n):
  A.append(int(input())
A.sort()
print(sum(A)-A[-1]/2)

Fixed submission:
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
A.sort()
print(int(sum(A)-A[-1]/2))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
A=[]
for i in range(n):
	A.append(int(input()))
C=[]
A.sort()
for i in range(n-k+1):
	B=[]
	for j in range(k):
		B.append(A[i+j])
	C.append(max(B)-min(B))
print(min(C))

Fixed submission:
n,k=map(int,input().split())
A=[]
for i in range(n):
	A.append(int(input()))
C=[]
A.sort()
for i in range(n-k+1):
  C.append(A[i+k-1]-A[i])
print(min(C))
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
PY=[list(map(int,input().split()))+[i] for i in range(M)] #定義終了

PY.sort(key= lambda x:x[1])
num=[0]*N
w=[""]*M

for p,y,i in PY:
	num[p-1]+=1
	w[i]=str(p).zfill(6)+str(num[p-1]).zfill(6)

for a in range(M):
	print(w)

Fixed submission:
N,M=map(int,input().split())
PY=[list(map(int,input().split()))+[i] for i in range(M)] #定義終了

PY.sort(key= lambda x:x[1])
num=[0]*N
w=[""]*M

for p,y,i in PY:
	num[p-1]+=1
	w[i]=str(p).zfill(6)+str(num[p-1]).zfill(6)

for i in range(M):
  	print(w[i])
Buggy python submission (verdict: Runtime Error):
A,B,K=map(int,input().split())
if K%2==0:
	K=K/2
	for i in range(K):
		if A%2==0:
			A=A/2
			B=B+A
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
				
		else:
			A= (A-1)/2
			B=A+B
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
				
else:
	K=(K-1)/2
	for i in range(int(K)):
		if A%2==0:
			A=A/2
			B=B+A
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
				
		else:
			A= (A-1)/2
			B=A+B
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
	
	if A%2==0:
		A=A/2
		B=B+A
	else:
		A=(A-1)/2
		B=A+B
	
print(str(int(A))+" "+str(int(B)))

Fixed submission:
A,B,K=map(int,input().split())
if K%2==0:
	K=K/2
	for i in range(int(K)):
		if A%2==0:
			A=A/2
			B=B+A
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
				
		else:
			A= (A-1)/2
			B=A+B
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
				
else:
	K=(K-1)/2
	for i in range(int(K)):
		if A%2==0:
			A=A/2
			B=B+A
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
				
		else:
			A= (A-1)/2
			B=A+B
			if B%2==0:
				B= B/2
				A=A+B
				
			else:
				B=(B-1)/2
				A=A+B
	
	if A%2==0:
		A=A/2
		B=B+A
	else:
		A=(A-1)/2
		B=A+B
	
print(str(int(A))+" "+str(int(B)))