Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
li=[]
for i in range(m):
    li.append(int(input()))

def convi(li):
    m=max(li)
    a=[1,1]
    if m>2:
        for i in range(2,m+1):
            a.append(a[i-2]+a[i-1])
            
    ans=1    
    for j in li:
        ans=ans*a[j-1]%1000000007
    return ans

def count(li,n):
    t=1
    ans=1
    li2=[]
    for i in range(1,n+1):
        if i in li:
            if i+1 in li:
                return(0)
            else:
                li2.append(t)
                t=0
        else:
            t+=1
    if t>0:        
        li2.append(t)   
    if 0 in li2:
    	li2.remove(0)
        

        
    return convi(li2)

                

print(count(li,n)%1000000007)   


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

def convi(li):
    m=max(li)
    a=[1,1]
    if m>2:
        for i in range(2,m+1):
            a.append(a[i-2]+a[i-1])
            
    ans=1    
    for j in li:
        ans=ans*a[j-1]%1000000007
    return ans

def count(li,n):
    t=1
    ans=1
    li2=[]
    li.append(n+1)
    if len(li)>0:
        for i in range(len(li)):
            
            if i>0:
                li2.append(li[i]-li[i-1]-1)
                if li[i]-li[i-1]==1 and i<len(li):
                    return 0
            else:
                li2.append(li[i])
                
    #print(li2)      
    return convi(li2)
                

print(count(li,n)%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
li=[]
for i in range(m):
    li.append(int(input()))

def convi(li):
    m=max(li)
    a=[1,1]
    if m>2:
        for i in range(2,m+1):
            a.append(a[i-2]+a[i-1])
            
    ans=1    
    for j in li:
        ans*=a[j-1]
    return ans

def count(li,n):
    t=1
    ans=1
    li2=[]
    for i in range(1,n+1):
        if i in li:
            if i+1 in li:
                return(0)
            else:
                li2.append(t)
                t=0
        else:
            t+=1
    if t>0:        
        li2.append(t)   
    if 0 in li2:
    	li2.remove(0)
        

        
    return convi(li2)

                

print(count(li,n)%1000000007)   

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

def convi(li):
    m=max(li)
    a=[1,1]
    if m>2:
        for i in range(2,m+1):
            a.append(a[i-2]+a[i-1])
            
    ans=1    
    for j in li:
        ans=ans*a[j-1]%1000000007
    return ans

def count(li,n):
    t=1
    ans=1
    li2=[]
    li.append(n+1)
    if len(li)>0:
        for i in range(len(li)):
            
            if i>0:
                li2.append(li[i]-li[i-1]-1)
                if li[i]-li[i-1]==1 and i<len(li):
                    return 0
            else:
                li2.append(li[i])
                
    #print(li2)      
    return convi(li2)
                

print(count(li,n)%1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
    b,c=map(int,input().split())
    a+=[c]*b
    
a.sort(reverse=True)
print(sum(a[:n]))

Fixed submission:
n,m=map(int,input().split())
a=list(map(int,input().split()))
k=[[i,1] for i in a]

for i in range(m):
    b,c=map(int,input().split())
    k+=[[c,b]]
    


kli=sorted(k,reverse=True)
count=0
for i in kli:
    if n-i[1]>=0:
        count+=i[0]*i[1]
        n+=-i[1]
    else:
        count+=i[0]*n
        n=0
    if n==0:
        break


print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
s=input()
li=[]
li_z=[]
li_o=[]


    
check="1"
seq=0
for i in s:
    if check!=i:
        check=i
        li.append(seq)
        seq=1
    else:
        seq+=1
        
li.append(seq)

for  i in range(len(li)):
    if i%2==0:
        li_o.append(li[i])
    else:
        li_z.append(li[i])
    
if s[n-1]=="0":
    li_o.append(0)


if len(li_o)<=k:
    print(n)
else:
    m=0
    for i in range(len(li_o)-k):
        tmp=sum(li_o[i:i+k+1])+sum(li_z[i:i+k])
        m=max(tmp,m)
        
    print(m)

Fixed submission:
n,k = map(int,input().split())
s=input()
li=[]
li_z=[]
li_o=[]


    
check="1"
seq=0
for i in s:
    if check!=i:
        check=i
        li.append(seq)
        seq=1
    else:
        seq+=1
        
li.append(seq)

for  i in range(len(li)):
    if i%2==0:
        li_o.append(li[i])
    else:
        li_z.append(li[i])
    
if s[n-1]=="0":
    li_o.append(0)


if len(li_o)<=k:
    print(n)
else:
    m=sum(li_o[0:0+k+1])+sum(li_z[0:0+k])
    tmp=m
    for i in range(1,len(li_o)-k):
        tmp=tmp-li_o[i-1]+li_o[i+k]-li_z[i-1]+li_z[i+k-1]
        m=max(tmp,m)
        
    print(m)
Buggy python submission (verdict: Runtime Error):
s=input()
if s=="C":
  print("G")
elif s=="G":
  print("C")
elif s=="A":
  print("T"):
else:
  print("A")

Fixed submission:
s=input()

if s=="A":
    print("T")
elif s=="T":
    print("A")
elif s=="C":
    print("G")
else:
    print("C")
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
s=input()
k=list(set(s))

d = {}

counta=0
for i in k:
    p=s.count(i)
    d[i]=p
    counta+=p



for i in range(2,len(k)+1):
    li=itertools.combinations(k,i) 
    for h in li:
        z="".join(h)
        q=d[z[0:(len(h)-1)]]*d[z[-1]]
        d[z]=q
        counta+=q
    
print(counta%(10**9+7))

Fixed submission:
n=int(input())
s=input()
k=list(set(s))
d = {i: s.count(i) for i in k}
counta=0

for i in k:
    counta=counta*d[i]+d[i]+counta


print(counta%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
s=input()
k=list(set(s))

d = {i: s.count(i) for i in k}

counta=0
for i in k:
    counta+=s.count(i)



for i in range(2,len(k)+1):
    li=list(itertools.combinations(k,i))    
    for h in li:
        z="".join(h)
        q=d[z[0:(len(h)-1)]]*d[z[-1]]
            
        d[z]=q
        counta+=q
    
print(counta%(10**9+7))

Fixed submission:
n=int(input())
s=input()
k=list(set(s))
d = {i: s.count(i) for i in k}
counta=0

for i in k:
    counta=counta*d[i]+d[i]+counta


print(counta%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input())
s=input()
k=list(set(s))

d = {i: s.count(i) for i in k}



counta=0

for i in range(1,len(k)+1):
    li=list(itertools.combinations(k,i))

    
    for h in li:
        q=1
        for l in h:
            q*=d[l]
     
        counta+=q
    
print(counta%(10**9+7))

Fixed submission:
n=int(input())
s=input()
k=list(set(s))
d = {i: s.count(i) for i in k}
counta=0

for i in k:
    counta=counta*d[i]+d[i]+counta


print(counta%(10**9+7))
Buggy python submission (verdict: Runtime Error):
num_drink=0
price=0
a.sort()
for i in a:

    if num_drink+i[1]<m:
        
        num_drink+=i[1]
        price+=i[1]*i[0]

    else:
        price+=(m-num_drink)*i[0]

        break
    
print(price)

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

num_drink=0
price=0
a.sort()
for i in a:

    if num_drink+i[1]<m:
        
        num_drink+=i[1]
        price+=i[1]*i[0]

    else:
        price+=(m-num_drink)*i[0]

        break
    
print(price)
Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
k=list(map(int,input().split()))
c=k[0]

for i in range(len(k)):
    c=math.gcd(c,k[i])
    
print(c)

Fixed submission:

n=int(input())
k=list(map(int,input().split()))
c=k[0]

def regcd(a,b):
    while b != 0:
        a, b = b, a%b
    return a

for i in k:
    c=regcd(max(c,i),min(c,i))

    
print(c)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=input()
b=input()
c=input()
al=list(a)
bl=list(b)
cl=list(c)

count=0

for i in range(n):
    if al[i]==bl[i]:
        if al[i]==cl[i]:
            plus=2
        else:
            plus=1
    elif bl[i]==cl[i]:
        plus=1
    elif al[i]==cl[i]:
        plus=1
    else:
        plus=0
        
    count+=plus
    
print(count)

Fixed submission:
n,a,b=map(int,input().split())
mxs=min(a,b)
mns=max(0,a+b-n)
print(mxs,mns)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=input()
b=input()
c=input()
al=list(a)
bl=list(b)
cl=list(c)

count=0
for i in range(n):
    if al[i]==bl[i]:
        if al[i]==cl[i]:
            plus=2
        elif:
            plus=1
    elif bl[i]==cl[i]:
        plus=1
    elif al[i]==cl[i]:
        plus=1
    else:
        plus=0
        
    count+=plus
    
print(count)

Fixed submission:
n=int(input())
a=input()
b=input()
c=input()
al=list(a)
bl=list(b)
cl=list(c)

count=0

for i in range(n):
    if al[i]==bl[i]:
        if al[i]==cl[i]:
            plus=0
        else:
            plus=1
    elif bl[i]==cl[i]:
        plus=1
    elif al[i]==cl[i]:
        plus=1
    else:
        plus=2
        
    count+=plus
    
print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())

a = [0  for i in range(n)]
b = [0  for i in range(n)]
x = [[0,0,0]  for i in range(n+2)]

for i in range(n):
    a[i],b[i]=map(int,input().split())
    x[i][0]=abs(a[i]-b[i])
    x[i][1]=a[i]
    x[i][2]=b[i]

s=sorted(x,reverse=True)


nu=n//2
mod=n%2

count=0
for i in range(nu):
    count+=x[i*2][1]

    count-=x[i*2+1][2]


if mod==1:
    counta=x[2*nu][1]

    

    

print(counta)

Fixed submission:
n = int(input())

a = [0  for i in range(n)]
b = [0  for i in range(n)]
x = [[0,0,0]  for i in range(n)]

for i in range(n):
    a[i],b[i]=map(int,input().split())
    x[i][0]=abs(a[i]+b[i])
    x[i][1]=a[i]
    x[i][2]=b[i]

s=sorted(x,reverse=True)
#print(s)

nu=n//2
mod=n%2

count=0
for i in range(nu):
    count+=s[i*2][1]
  #  print(count)
    count-=s[i*2+1][2]
 #   print(count)

if mod==1:
    count+=s[2*nu][1]

    

    

print(count)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
li=[[0,0] for i in range(n)]
for i in range(n):
    li[i][0],li[i][1]=map(int,input().split())

li.sort(reverse=True,key=lambda x:x[1])

def find_num_neta(choice,li):
    k=[]
    for i in choice:
        k.append(li[i][0])
    return len(set(k))

#-----------------------------------------
best_list=[]
best_list_neta=[]
not_best_list=[]

for i in li:
    if i[0] in best_list_neta:
        not_best_list.append(i[1])
    else:
        best_list.append(i[1])
        best_list_neta.append(i[0])


s2=min(len(best_list_neta),k)
s1=find_num_neta(list(range(k)),li)


score=-1
for i in range(s1,s2+1):
    oishisa=0
    for j in range(i):
        oishisa+=best_list[j]
    for j in range(k-i):
        oishisa+=not_best_list[j]
    
    new_score=i**2+oishisa

    if score<new_score:
        score=new_score
        
    
print(score)

Fixed submission:
a,b,c=map(int,input().split())
print(int(a*b/2))
Buggy python submission (verdict: Runtime Error):
N,P=list(map(int,input().split()))
 
root=P**(1/N)
x=round(root)

if n==1:
    print(p)
else:
	for i in range(x):
		if P%((x-i)**N)==0:
			print(x-i)
			break

Fixed submission:
n=input()
count=0

for k in n:
    if k== "2":
        count+=1

print(count)

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


def kouyaku(n,p):
    if n==1:
        return p 
    
    else:
        if int(p**(1/n))-p**(1/n)< 1e-11:
            return int(p**(1/n))
        else:
            for i in range(round((p**(1/n)/2+1)),0,-1):        
                if p%i==0:
                    if p%(i**2)==0:
                        if p%(i**n)==0:
                            return i

            
print(kouyaku(n,p))

Fixed submission:
n=input()
count=0

for k in n:
    if k== "2":
        count+=1

print(count)

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


def kouyaku(n,p):
    if n==1:
        return p 
    else:
        if int(p**(1/n))*n-p< 1e-6:
            return int(p**(1/n))
        else:
            for i in range(round((p**(1/n)/2+1)),0,-1):        
                if p%i==0:
                    if p%(i**2)==0:
                        if p%(i**n)==0:
                            return i

            
print(kouyaku(n,p))

Fixed submission:
n=input()
count=0

for k in n:
    if k== "2":
        count+=1

print(count)

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

def kouyaku(n,p):
    for i in range(round((p**(1/n)+1)),0,-1):
        if p%i==0:
            if p%(i**n)==0:
                return i
            
print(kouyaku(n,p))

Fixed submission:
n=input()
count=0

for k in n:
    if k== "2":
        count+=1

print(count)
Buggy python submission (verdict: Runtime Error):

n,k=map(int,(input().split()))
a=[]
for i in range(k):
    a.append(int(input()))
    
a.sort(reverse=True)
for i in range(n-k):
    b=int(input())
    if max(a)>b:
        a.remove(max(a))
        a.append(b)
    elif min(a)<b:
        a.remove(min(b))
        a.append(b)

print(max(a)-min(a))

Fixed submission:

n,k=map(int,(input().split()))
a=[]
for i in range(n):
    a.append(int(input()))

a.sort()
min_high=1000000000000

for i in range(n-k+1):
    high=-a[i]+a[i+k-1]
#    print(high,a[i],i)
    if high<min_high:
        min_high=high

print(min_high)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
    
print(len(set(a)))

Fixed submission:
a,b=map(int,input().split())
if a*b%2==1:
  print("Odd")
else:
  print("Even")
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
k = int(input())
s = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        a = gcd(i,j)
        for z in range(1,k+1):
            s+=gcd(a,z)
print(s)

Fixed submission:
from math import gcd
k = int(input())
s = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        a = gcd(i,j)
        for z in range(1,k+1):
            s+=gcd(a,z)
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
def gcd(a, b):
    while b > 0:
        r = a%b
        a = b
        b = r
    return a
s = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        a = gcd(i,j)
        for z in range(1,k+1):
            s+=gcd(a,z)
print(s)

Fixed submission:
from math import gcd
k = int(input())
s = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        a = gcd(i,j)
        for z in range(1,k+1):
            s+=gcd(a,z)
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
def gcd(a, b):
    while b > 0:
        r = a%b
        a = b
        b = r
    return a
s = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for z in range(1,k+1):
            s+=gcd(gcd(i,j),z)
print(s)

Fixed submission:
from math import gcd
k = int(input())
s = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        a = gcd(i,j)
        for z in range(1,k+1):
            s+=gcd(a,z)
print(s)
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input())
K = int(input())
if A > (B + C):
    print("No")
else:
    print("Yes")

Fixed submission:
A,B,C = map(int,input().split())
K = int(input())
i = 0
while True:
    if B > A:
        break
    else:
        B = B * 2
    i += 1
q = 0
while True:
    if C > B:
        break
    else:
        C = C * 2
    q += 1
if (i + q) > K:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))

if sum(A) < A:
    print(-1)
else:
    print(A - sum(A))

Fixed submission:
N , M = map(int,input().split())
A = list(map(int,input().split()))
if N < sum(A):
    print(-1)
else:
    print(N - sum(A))
Buggy python submission (verdict: Runtime Error):
def main():
    X = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(input())
    return X[K]
print(main())

Fixed submission:
def main():
    k = input()
    n = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    ]
    print(n[int(k) - 1])
main()

Buggy python submission (verdict: Runtime Error):
def main():
    k = input()
    n = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    ]
    print(n[int(k)])
main()


Fixed submission:
def main():
    k = input()
    n = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    ]
    print(n[int(k) - 1])
main()

Buggy python submission (verdict: Runtime Error):
def main():
    k = input()
    n = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    ]
    print(n[k])
main()


Fixed submission:
def main():
    k = input()
    n = [
        1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
    ]
    print(n[int(k) - 1])
main()
Buggy python submission (verdict: Runtime Error):
def main():
    n,a,b = map(int,input().split())
    print((n // (a + b) ) * a + n % a)
main()

Fixed submission:
def main():
    import numpy as numpy
    import sys
    n,a,b=list(map(int,sys.stdin.readline().split()))
 
    print(a*(n//(a+b))+min(a,n%(a+b)))
 
 
 
main()
Buggy python submission (verdict: Runtime Error):
S,T = map(int,input().split())
print(T + S)

Fixed submission:
def main():
    S,T = input().split()
    print("{}{}".format(T,S))
main()
Buggy python submission (verdict: Time Limit Exceeded):
A,B,K = map(int,input().split())
i = 0
while i < K:
    if A != 0:
        A -= 1
    else:
        B -= 1
    i += 1
print(str(A) + " " + str(B))

Fixed submission:
def main():
    a,b,k = map(int,input().split())
    if a >= k:
        a-=k
    else:
        b -= (k - a)
        a = 0
        if b < 0:
            b = 0
    print(str(a)+" "+str(b))
main()

Buggy python submission (verdict: Runtime Error):
def main():
    a,b,k = map(int,input().split())
    if a >= k:
        a-=k
    else:
        b -= (k - a)
        a = 0
        if b < 0:
            b = 0
    print(str(A)+" "+str(B))
main()

Fixed submission:
def main():
    a,b,k = map(int,input().split())
    if a >= k:
        a-=k
    else:
        b -= (k - a)
        a = 0
        if b < 0:
            b = 0
    print(str(a)+" "+str(b))
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    A,B,K = map(int,input().split())
    while K > 0:
        if A >= 1:
            A -= 1
        elif B >= 1:
            B -= 1
        K -= 1
    print("{} {}".format(A,B))
main()

Fixed submission:
def main():
    a,b,k = map(int,input().split())
    if a >= k:
        a-=k
    else:
        b -= (k - a)
        a = 0
        if b < 0:
            b = 0
    print(str(a)+" "+str(b))
main()
Buggy python submission (verdict: Runtime Error):
import math
A,B = map(int,input().split())
print(int(A * B / math.gcd(A,B)))

Fixed submission:
A,B = map(int,input().split())
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
print(A*B // euclid(A, B))

Buggy python submission (verdict: Time Limit Exceeded):
A,B = map(int,input().split())
i = 0
while True:
    i1 = i + 1
    if i1 % A == 0 and i1 % B == 0:
        print(i1)
        break
    i += 1

Fixed submission:
A,B = map(int,input().split())
def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
print(A*B // euclid(A, B))
Buggy python submission (verdict: Runtime Error):
r = int(input().split())
print(r ** 2)

Fixed submission:
r = int(input())
print(r ** 2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
if N % 2 == 0:   
    if S[:N / 2] == S[N / 2:]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Fixed submission:
N = int(input())
S = input()
if N <= 1 or (N % 2) == 1:
    print("No")
else:
    S1 = S[:int((N / 2))]
    S2 = S[int((N / 2)):]
    if S1 == S2:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
S1 = S[:N / 2]
S2 = S[N / 2:]
if N > 1 or (N % 2) != 0 or S1 != S2:
    print("No")
else:
    print("Yes")

Fixed submission:
N = int(input())
S = input()
if N <= 1 or (N % 2) == 1:
    print("No")
else:
    S1 = S[:int((N / 2))]
    S2 = S[int((N / 2)):]
    if S1 == S2:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
A,B,C = map(int,input())
print(B + C - A)

Fixed submission:
A,B,C = map(int,input().split())
if B + C - A <= 0:
    print(0)
else:
    print(B + C - A)
Buggy python submission (verdict: Runtime Error):
#-*- coding:utf-8 -*-
import math

a = int(input())
print(math.gcd(a, 2))

Fixed submission:
#-*- coding:utf-8 -*-

a = int(input())

if a % 2 == 1:
        print(2*a)
else:
        print(a)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

nums = [0]*N
for i in range(0, N):
    nums[i] = int(input())

for i in range (0, N):
    test = nums[:i] + nums[i+1:]
    print(max(test))

Fixed submission:
N = int(input())
no_1 = 0
pos_1 = 0
no_2 = 0
for i in range(0, N):
    num = int(input())
    
    if no_1 <= num:
        no_2 = no_1
        no_1 = num
        pos_1 = i
        
    elif no_2 < num:
        no_2 = num
    
for i in range (0, N):
    if i == pos_1:
        print(no_2)
    else:
        print(no_1)
Buggy python submission (verdict: Time Limit Exceeded):
size = int(input())
waters = list(map(int, input().split()))

# 奇数の場合のみ、たとえば size = 5 なら、
# m1 = d1 - d2 + d3 - d4 + d5 のように求められる

# 各山に振った水量を、mとする
m = [0]*size
m[0] = sum(waters[::2]) - sum(waters[1::2])

for i in range(1, size):
    m[i] = 2 * (waters[i-1]) - m[i - 1]

ans_msg = str(m[0])
for ans_i in m[1:]:
    ans_msg = ans_msg + " " + str(ans_i)

print(ans_msg)

Fixed submission:
size = int(input())
waters = list(map(int, input().split()))

# 奇数の場合のみ、たとえば size = 5 なら、
# m1 = d1 - d2 + d3 - d4 + d5 のように求められる

# 各山に振った水量を、mとする
m = [0]*size
m[0] = str(sum(waters[::2]) - sum(waters[1::2]))

for i in range(1, size):
    m[i] = str(2 * (waters[i-1]) - int(m[i - 1]))


print(" ".join(m))

Buggy python submission (verdict: Time Limit Exceeded):
size = int(input())
waters = list(map(int, input().split()))

# 奇数の場合のみ、たとえば size = 5 なら、
# m1 = d1 - d2 + d3 - d4 + d5 のように求められる

# 各山に振った水量を、mとする
m = [0]*size
m[0] = sum(waters[::2]) - sum(waters[1::2])

for i in range(1, size):
    m[i] = 2 * (waters[i-1]) - m[i - 1]

ans_msg = str(m[0])
for ans_i in m[1:]:
    ans_msg = ans_msg + " " + str(ans_i)

print(ans_msg)

Fixed submission:
size = int(input())
waters = list(map(int, input().split()))

# 奇数の場合のみ、たとえば size = 5 なら、
# m1 = d1 - d2 + d3 - d4 + d5 のように求められる

# 各山に振った水量を、mとする
m = [0]*size
m[0] = str(sum(waters[::2]) - sum(waters[1::2]))

for i in range(1, size):
    m[i] = str(2 * (waters[i-1]) - int(m[i - 1]))


print(" ".join(m))
Buggy python submission (verdict: Runtime Error):
import sys
msg = str(input())

# 逆から、大きい文字数から、見ていけば重複は生じない
len_l1 = 0
while len(msg) != len_l1:
    len_l1 = len(msg)
    print(msg)
    
    # dreamer
    if msg[-7:] == "dreamer":
        msg = msg[:-7]
    # eraser
    if msg[-6:] == "eraser":
        msg = msg[:-6]
        
    # dreame
    if msg[-5:] == "dream":
        msg = msg[:-5]
    # erase
    if msg[-5:] == "erase":
        msg = msg[:-5]
        
    if len(msg) == 0:
        print('YES')
        sys.exit()    
    
print('NO')

Fixed submission:
import sys
msg = str(input())

# 逆から、大きい文字数から、見ていけば重複は生じない
len_l1 = 0
while len(msg) != len_l1:
    len_l1 = len(msg)
    
    # dreamer
    if msg[-7:] == "dreamer":
        msg = msg[:-7]
    # eraser
    if msg[-6:] == "eraser":
        msg = msg[:-6]
        
    # dreame
    if msg[-5:] == "dream":
        msg = msg[:-5]
    # erase
    if msg[-5:] == "erase":
        msg = msg[:-5]
        
    if len(msg) == 0:
        print('YES')
        sys.exit()    
    
print('NO')