Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

T = list(input())
location_q = []
Tstr = []
count_D_PD = []
count_q = T.count('?')

for s in range(len(T)):
    if T[s] == '?':
        location_q.append(s)

for i in itertools.product(['P','D'], repeat=count_q):
    for j in range(len(location_q)):
        T[location_q[j]] = i[j]
    Tstr.append(''.join(T))
# print(Tstr)

for k in range(len(Tstr)):
    count_D_PD.append(Tstr[k].count('D') + Tstr[k].count('PD'))
# print(count_D_PD)
# print(max(count_D_PD))
# print(count_D_PD.index(max(count_D_PD)))
print(Tstr[count_D_PD.index(max(count_D_PD))])


Fixed submission:
T = list(input())
for i in range(len(T)):
    if T[i] == '?':
        T[i] = 'D'

print(''.join(T))

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

T = list(input())
location_q = []
Tstr = []
count_D_PD = []
count_q = T.count('?')

for s in range(len(T)):
    if T[s] == '?':
        location_q.append(s)

for i in itertools.product(['P','D'], repeat=count_q):
    for j in range(len(location_q)):
        T[location_q[j]] = i[j]
    Tstr.append(''.join(T))
# print(Tstr)

for k in range(len(Tstr)):
    count_D_PD.append(Tstr[k].count('D') + Tstr[k].count('PD'))
# print(count_D_PD)
# print(max(count_D_PD))
# print(count_D_PD.index(max(count_D_PD)))
print(Tstr[count_D_PD.index(max(count_D_PD))])


Fixed submission:
T = list(input())
for i in range(len(T)):
    if T[i] == '?':
        T[i] = 'D'

print(''.join(T))

Buggy python submission (verdict: Runtime Error):
import itertools

T = list(input())
location_q = []
Tstr = []
count_D_PD = []

for s in range(len(T)):
    if T[s] == '?':
        location_q.append(s)

for i in itertools.product(['P','D'], repeat=3):
    for j in range(len(location_q)):
        T[location_q[j]] = i[j]
    Tstr.append(''.join(T))
# print(Tstr)

for k in range(len(Tstr)):
    count_D_PD.append(Tstr[k].count('D') + Tstr[k].count('PD'))
# print(count_D_PD)
# print(max(count_D_PD))
# print(count_D_PD.index(max(count_D_PD)))
print(Tstr[count_D_PD.index(max(count_D_PD))])


Fixed submission:
T = list(input())
for i in range(len(T)):
    if T[i] == '?':
        T[i] = 'D'

print(''.join(T))
Buggy python submission (verdict: Runtime Error):
S = stdin.readline().rstrip()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')


Fixed submission:
from sys import stdin

S = stdin.readline().rstrip()

if S == 'ABC':
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = ''
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))

for i in range((N//(A+B))+1):
    S += 'b'*A
    S += 'r'*B
print(S[:N].count('b'))

Fixed submission:
N, A, B = list(map(int, input().split()))
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))
#print(A*(N//(A+B)), min(A, N%(A+B)))
print(A*(N//(A+B)) + min(A, N%(A+B)))

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = ''
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))

for i in range((N//(A+B))+1):
    S += 'b'*A
    S += 'r'*B
print(S[:N].count('b'))

Fixed submission:
N, A, B = list(map(int, input().split()))
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))
#print(A*(N//(A+B)), min(A, N%(A+B)))
print(A*(N//(A+B)) + min(A, N%(A+B)))

Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = ''
print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))

for i in range((N//(A+B))+1):
    S += 'b'*A
    S += 'r'*B
print(S[:N].count('b'))

Fixed submission:
N, A, B = list(map(int, input().split()))
#print('N:{}'.format(N), 'A:{}'.format(A), 'B:{}'.format(B))
#print(A*(N//(A+B)), min(A, N%(A+B)))
print(A*(N//(A+B)) + min(A, N%(A+B)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
whole_length = sum(A)
middle_length = whole_length / 2
sum_length_before = 0
sum_length = 0
sum = 0
cost_before = abs(sum_length_before - middle_length)
cost_after = abs(sum_length_after - middle_length)

for i in range(N):
    if A[i] < middle_length:
        sum_length_before = sum_length
        sum_length_after += A[i]
        sum = i
    else:
        break

if cost_before >= cost_after:
    print(cost_after)

else:
    print(cost_before)


Fixed submission:
X, Y = map(int, input().split())

if X == 1 and Y == 1:
    print(1000000)

elif (X == 1 and Y == 2) or (X == 2 and Y == 1):
    print(500000)

elif (X == 1 and Y == 3) or (X == 3 and Y == 1) or (X == 2 and Y == 2):
    print(400000)

elif (X == 1 and Y >= 4) or (X >= 4 and Y == 1) or (X == 2 and Y == 3) or (X == 3 and Y == 2):
    print(300000)

elif (X == 2 and Y >= 4) or (X >= 4 and Y == 2) or (X == 3 and Y == 3):
    print(200000)

elif (X == 3 and Y >= 4) or (X >= 4 and Y == 3):
    print(100000)

else:
    print(0)
Buggy python submission (verdict: Runtime Error):
number = input(N)
word = list(input((S))
judge = 'Yes'
            
if N%2 == 1:
    print('No')
elif for i in range(N/2 - 1):
    if word[i] != word[N/2+i]:
        judge = 'No'

print(judge)            	
            		


Fixed submission:
number = int(input())
word = list(input())
judge = 'Yes'
            
if number%2 == 1:
	judge = 'No'
    
else:
	for i in range(int(number/2)):
		if word[i] != word[int(number/2 + i)]:
			judge = 'No'

print(judge)

Buggy python submission (verdict: Runtime Error):
number = input(N)
word = list(input((S))
judge = 'Yes'
            
if N%2 == 1:
    print('No')
elif for i in range(N/2):
    if word[i] != word[2i]:
        judge = 'No'

print(judge)            	
            		


Fixed submission:
number = int(input())
word = list(input())
judge = 'Yes'
            
if number%2 == 1:
	judge = 'No'
    
else:
	for i in range(int(number/2)):
		if word[i] != word[int(number/2 + i)]:
			judge = 'No'

print(judge)
Buggy python submission (verdict: Runtime Error):
n = int((

Fixed submission:
n = int(input())
d = {"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
    s = input()
    d[s] += 1 
    

p = str(d["AC"])
q = str(d["WA"])
r = str(d["TLE"])
s = str(d["RE"])

print("AC x " + p)
print("WA x " + q)
print("TLE x " + r)
print("RE x " + s)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = []
ans = 0
for i in range(n):
  x = int(input())
  a.append(x)
for i in range(1, n):
  if a[i] < a[i - 1]:
    ans += a[i - 1] - a[i]
print(ans)


Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in range(1, n):
  if a[i] < a[i - 1]:
    ans += a[i - 1] - a[i]
    a[i] += (a[i - 1] - a[i])
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input.split()]
ans = 0
for i in range(1, n):
  if a[i] < a[i - 1]:
    ans += a[i - 1] - a[i]
print(ans)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
for i in range(1, n):
  if a[i] < a[i - 1]:
    ans += a[i - 1] - a[i]
    a[i] += (a[i - 1] - a[i])
print(ans)
Buggy python submission (verdict: Runtime Error):
s,t = input().split()

t = t[:-1]

if s == t:
    print('Yes')
else:
    print('No1')





Fixed submission:
s = input()
t = input()

t = t[:-1]
if s == t:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int,input().split())

ans = 0
for _ in range(k):
    if a > 0:
        a -= 1
        ans += 1
    elif b > 0:
        b -=1
    elif c > 0:
        c -= 1
        ans -= 1

print(ans)



Fixed submission:
a,b,c,k = map(int,input().split())

out = min(a,k) - max(0,k-a-b)
print(out)

Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,k = map(int,input().split())

ans = 0
for _ in range(k):
    if a > 0:
        a -= 1
        ans += 1
    elif b > 0:
        b -=1
    elif c > 0:
        c -= 1
        ans -= 1

print(ans)



Fixed submission:
a,b,c,k = map(int,input().split())

out = min(a,k) - max(0,k-a-b)
print(out)
Buggy python submission (verdict: Runtime Error):
p_num = int(input())
p = list(map(int,input().split()))

count = 0
for i in range(p_num):
    for j in range(i+1):
        if p[i] > p[j]:
            break
    else:
        count += 1
        

print(count)


Fixed submission:
n,m = map(int,input().split())
if n == m:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
p_num = int(input())
p = list(map(int,input().split()))

count = 1
min = p[0]


for i in p[1:]:
    if i < min_num:
        min_num = i
        count += 1
        

print(count)


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

count = 1
min_num = p[0]


for i in p[1:]:
    if i < min_num:
        min_num = i
        count += 1
        

print(count)

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

count = 1
min = List[0]


for i in List[1:]:
    if i < min_num:
        min_num = i
        count += 1
        

print(count)


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

count = 1
min_num = p[0]


for i in p[1:]:
    if i < min_num:
        min_num = i
        count += 1
        

print(count)

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

count = 0
for i in range(p_num):
    for j in range(i+1):
        if p[i] > p[j]:
            break
    else:
        count += 1
        

print(count)


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

count = 1
min_num = p[0]


for i in p[1:]:
    if i < min_num:
        min_num = i
        count += 1
        

print(count)

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

count = 0
for i in range(p_num):
    for j in range(i+1):
        if p[i] > p[j]:
            break
    else:
        count += 1
        

print(count)


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

count = 1
min_num = p[0]


for i in p[1:]:
    if i < min_num:
        min_num = i
        count += 1
        

print(count)
Buggy python submission (verdict: Runtime Error):
listnum = int(input())
string = input()

halfnum = listnum // 2
halfstr = string[0:halfnum]
if string == halfstr + halfstr:
	print('Yes')
else:
	print('No')

Fixed submission:
r = int(input())
print(r*r)
Buggy python submission (verdict: Runtime Error):
listnum = int(input())
string = input()

halfnum = listnum / 2
halfstr = string[0:halfnum]
if string == halfstr + halfstr:
	print('Yes')
else:
	print('No')

Fixed submission:
listnum = int(input())
string = input()

halfnum = listnum // 2
halfstr = string[0:halfnum]
if string == halfstr + halfstr:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
z = list(map(int,input().split()))

def half(n,z):
	existodd = 0
	count = 0
	while True: 
		for i in z:
			if i % 2 != 0:
				existodd = 1

		if existodd:
			print(count)
			break
		
		for i in range(n):		
			z[i] /= 2
		
		count += 1
	
half(n,z)


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

def judge(a,b):
	c = a*b
	if a*b % 2 == 0:
		print('Even')
	else:
		print('Odd')

judge(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
z = list(map(int,input().split()))

def half(n,z):
	exist_odd = False
	count = 0
	while True: 
		for i in z:
			if i % 2 != 0:
				exist_odd = True

		if exist_odd:
			print(count)
			break
		
		for i in z:		
			i /= 2
		
		count += 1

half(n,z)


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

def half(n,z):
	existodd = 0
	count = 0
	while True: 
		for i in z:
			if i % 2 != 0:
				existodd = 1

		if existodd:
			print(count)
			break
		
		for i in range(n):		
			z[i] /= 2
		
		count += 1
	
half(n,z)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul
l = int(input())
x = list(map(int, input().split()))
# print(x)
result = reduce(mul, x)
if 10 ** 18 < result:
  result = -1
print(result)


Fixed submission:
from functools import reduce
from operator import mul
l = int(input())
x = list(map(int, input().split()))
# print(x)
# result = reduce(mul, x)
result = 1
limit = 10 ** 18
for i in x:
  if result < limit or i == 0:
    result = result * i
if limit < result:
  result = -1
print(result)
Buggy python submission (verdict: Runtime Error):
N,D = map(int,input().split())
xy = []
for i in range(N):
    x,y = map(int,input().split())
    xy.append([x,y])
ans = 0
for i in range(N):
    x = xy[i][0]
    y = xy[i][1]
    if(D >= (x*x + y*y) / D):
        ans+=1
print(ans)

Fixed submission:
N,D = map(int,input().split())
xy = []
for i in range(N):
    x,y = map(int,input().split())
    xy.append([x,y])
ans = 0
for i in range(N):
    x = xy[i][0]
    y = xy[i][1]
    if(D*D >= (x*x + y*y)):
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = [list(map(int, input().split())) for l in range(Q)]

l = [0] * 10**5
tot = 0
for i in range(N) :
    l[A[i]]+=1
    tot += A[i]
for i in range(Q):
    s0 = S[i][0]
    s1 = S[i][1]
    tot += s1 * (l[s0] + l[s1]) - (s0 * l[s0] + s1*l[s1])
    l[s1] += l[s0]
    l[s0] = 0
    print(tot)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = [list(map(int, input().split())) for l in range(Q)]

l = [0] * 10**6
tot = 0
for i in range(N) :
    l[A[i]]+=1
    tot += A[i]
for i in range(Q):
    s0 = S[i][0]
    s1 = S[i][1]
    tot += s1 * (l[s0] + l[s1]) - (s0 * l[s0] + s1*l[s1])
    l[s1] += l[s0]
    l[s0] = 0
    print(tot)

Buggy python submission (verdict: Runtime Error):
l = [0] * 10**5
tot = 0
for i in range(N) :
    l[A[i]]+=1
    tot += A[i]
for i in range(Q):
    s0 = S[i][0]
    s1 = S[i][1]
    tot += s1 * (l[s0] + l[s1]) - (s0 * l[s0] + s1*l[s1])
    l[s1] += l[s0]
    l[s0] = 0
    print(tot)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = [list(map(int, input().split())) for l in range(Q)]

l = [0] * 10**6
tot = 0
for i in range(N) :
    l[A[i]]+=1
    tot += A[i]
for i in range(Q):
    s0 = S[i][0]
    s1 = S[i][1]
    tot += s1 * (l[s0] + l[s1]) - (s0 * l[s0] + s1*l[s1])
    l[s1] += l[s0]
    l[s0] = 0
    print(tot)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = [list(map(int, input().split())) for l in range(Q)]

l = [0] * 10**5
s = set()
for i in range(N) :
    l[A[i]]+=1
    s.add(A[i])
for i in range(Q):
    s0 = S[i][0]
    s1 = S[i][1]
    l[s1] += l[s0]
    try:
        s.remove(s0)
        s.add(s1)
    except :
        pass
    l[s0] = 0
    tot = 0
    for j in s:
        tot += j * l[j]
    print(tot)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
S = [list(map(int, input().split())) for l in range(Q)]

l = [0] * 10**6
tot = 0
for i in range(N) :
    l[A[i]]+=1
    tot += A[i]
for i in range(Q):
    s0 = S[i][0]
    s1 = S[i][1]
    tot += s1 * (l[s0] + l[s1]) - (s0 * l[s0] + s1*l[s1])
    l[s1] += l[s0]
    l[s0] = 0
    print(tot)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

ans = 1
for i in range(N) :
    ans = ans * A[i]
if(ans > 10**18):
    ans = -1
print(ans)

Fixed submission:
def solve(N,A) :
    ans = 1
    for i in range(N) :
        if(A[i] == 0) :
            print(0)
            return
    for i in range(N) :
        ans = ans * A[i]
        if(ans > 10**18):
            ans = -1
            break
    print(ans)
    
N = int(input())
A = list(map(int, input().split()))
solve(N,A)
Buggy python submission (verdict: Runtime Error):
A, B, H, M = map(int, input().split())
sitaH = (H*60+M) / 720 * 2 * math.pi
sitaM =  M/60 * 2 * math.pi

posXH = A * math.cos(sitaH)
posYH = A * math.sin(sitaH)
posXM = B * math.cos(sitaM)
posYM = B * math.sin(sitaM)

delX = posXH - posXM
delY = posYH - posYM

d = (delX*delX + delY*delY)**(1/2)
print(d)

Fixed submission:
import math
A, B, H, M = map(int, input().split())
sitaH = (H*60+M) / 720 * 2 * math.pi
sitaM =  M/60 * 2 * math.pi

posXH = A * math.cos(sitaH)
posYH = A * math.sin(sitaH)
posXM = B * math.cos(sitaM)
posYM = B * math.sin(sitaM)

delX = posXH - posXM
delY = posYH - posYM

d = (delX*delX + delY*delY)**(1/2)
print(d)

Buggy python submission (verdict: Runtime Error):
sitaH = (H*60+M) / 720 * 2 * math.pi
sitaM =  M/60 * 2 * math.pi

posXH = A * math.cos(sitaH)
posYH = A * math.sin(sitaH)
posXM = B * math.cos(sitaM)
posYM = B * math.sin(sitaM)

delX = posXH - posXM
delY = posYH - posYM

d = (delX*delX + delY*delY)**(1/2)
print(d)

Fixed submission:
import math
A, B, H, M = map(int, input().split())
sitaH = (H*60+M) / 720 * 2 * math.pi
sitaM =  M/60 * 2 * math.pi

posXH = A * math.cos(sitaH)
posYH = A * math.sin(sitaH)
posXM = B * math.cos(sitaM)
posYM = B * math.sin(sitaM)

delX = posXH - posXM
delY = posYH - posYM

d = (delX*delX + delY*delY)**(1/2)
print(d)
Buggy python submission (verdict: Time Limit Exceeded):
import copy
N, M = map(int, input().split())
res = [[] for i in range(N+5)]


for i in range(M) :
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    res[a].append(b)
    res[b].append(a)
    
pre = [-1] * N
d = 1
dl = []
pre[0] = 0

for i in res[0] :
    dl.append((i,0))

while(len(dl) != 0) :
    a,b = dl[0]
    dl.pop(0)
    if(pre[a] != -1) :
        continue
    pre[a] = b
    for i in res[a] :
        if(pre[i] != -1):
            continue
        dl.append((i,a))
        
for i in range(N) :
    if(i == 0) :
        print("Yes")
        continue
    print(pre[i] + 1)

Fixed submission:
import copy
N, M = map(int, input().split())
res = [[] for i in range(N+5)]


for i in range(M) :
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    res[a].append(b)
    res[b].append(a)
    
pre = [-1] * N
dist = [-1] * N
d = 1
dl = []
pre[0] = 0
dist[0] = 0
dl.append(0)

while(len(dl) != 0) :
    a = dl[0]
    dl.pop(0)
    for i in res[a] :
        if(dist[i] != -1):
            continue
        dist[i] = dist[a] + 1
        pre[i] = a
        dl.append(i)
        
for i in range(N) :
    if(i == 0) :
        print("Yes")
        continue
    print(pre[i] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
N, M = map(int, input().split())
res = [[] for i in range(N+5)]


for i in range(M) :
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    res[a].append(b)
    res[b].append(a)
    
pre = [-1] * N
d = 1
dl = []
pre[0] = 0

for i in res[0] :
    dl.append((i,0))

while(len(dl) != 0) :
    a,b = dl[0]
    dl.pop(0)
    if(pre[a] != -1) :
        continue
    pre[a] = b
    for i in res[a] :
        dl.append((i,a))
        
for i in range(N) :
    if(i == 0) :
        print("Yes")
        continue
    print(pre[i] + 1)

Fixed submission:
import copy
N, M = map(int, input().split())
res = [[] for i in range(N+5)]


for i in range(M) :
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    res[a].append(b)
    res[b].append(a)
    
pre = [-1] * N
dist = [-1] * N
d = 1
dl = []
pre[0] = 0
dist[0] = 0
dl.append(0)

while(len(dl) != 0) :
    a = dl[0]
    dl.pop(0)
    for i in res[a] :
        if(dist[i] != -1):
            continue
        dist[i] = dist[a] + 1
        pre[i] = a
        dl.append(i)
        
for i in range(N) :
    if(i == 0) :
        print("Yes")
        continue
    print(pre[i] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
AList = list(map(int, input().split()))
divider = 10**9 + 7
count = 0

for i in range(N-1) :
    for j in range(i+1,N) :
        count += AList[i]^AList[j]
print(count%divider)

Fixed submission:
import numpy as np
 
N = int(input())
A = np.fromiter(map(int, input().split()), np.int64)
 
result = 0
for bit in range(60):
    c = int((A & 1).sum())
    result = (result + c * (N - c) * (1 << bit)) % 1000000007
    A >>= 1
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
print(sum([i for i in range(N)]))

Fixed submission:
import math
N = int(input())
print(math.floor((N*(N-1)//2)))
Buggy python submission (verdict: Runtime Error):
m,d = map(int,input())
count = 0
for i in range(m) :
  for j in range(d) :
    if j <11 :
      continue
    str_j = str(j)
    temp = int(str_j[0]) * int(str_j[1])
    if temp == i :
      count+=1
print(count)

Fixed submission:
m,d = map(int,input().split(" "))
count = 0
for i in range(1, m+1) :
  for j in range(1, d+1) :
    if j < 10 :
      continue
    str_j = str(j)
    d1, d2 = int(str_j[0]), int(str_j[1])
    if d1 < 2 or d2 < 2 :
    	continue
    temp = d1 * d2
    if temp == i :
      count+=1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
AList = [input() for i in range(N)]

resultCash = {}

for i in range(N) :
    if AList[i] not in resultCash :
        resultCash[AList[i]] = max(AList[0:i] + AList[i+1:N])
    print(resultCash[AList[i]])

Fixed submission:
N = int(input())
AList = [int(input()) for i in range(N)]
max_AList = max(AList)
max2nd_AList = sorted(AList, reverse = True)[1]

for i in range(N) :
    if AList[i] == max_AList :
        print(max2nd_AList)
    else :
        print(max_AList)

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

for i in range(N) :
    print(max(AList[0:i] + AList[i+1:N]))

Fixed submission:
N = int(input())
AList = [int(input()) for i in range(N)]
max_AList = max(AList)
max2nd_AList = sorted(AList, reverse = True)[1]

for i in range(N) :
    if AList[i] == max_AList :
        print(max2nd_AList)
    else :
        print(max_AList)
Buggy python submission (verdict: Runtime Error):
def check(S) :
    mae = int(S[:2])
    ato = int(S[2:])
    if mae == 0 :
        return "NA"
    if ato == 0 :
        return "NA"
    if mae > 12 and ato > 12 :
        return "NA"
    if mae < 13 and ato < 13 :
        return "AMBIGUOUS"
    
    if mae < 13 :
        return "MMYY"
    if mae > 12
        return "YYMM"


S = input()
print(check(S))


Fixed submission:
def check(S) :
    mae = int(S[:2])
    ato = int(S[2:])
    
    if mae == 0 and ato <= 12 and ato > 0 :
        return "YYMM"
    if ato == 0 and mae <= 12 and mae > 0 :
        return "MMYY"
    
    if mae == 0 or ato == 0 :
        return "NA"
    if mae > 12 and ato > 12 :
        return "NA"
    if mae <= 12 and ato <= 12 :
        return "AMBIGUOUS"
    if mae > 12 :
        return "YYMM"

    return "MMYY"
    
    

S = input()
print(check(S))
Buggy python submission (verdict: Runtime Error):
N = int(input())
HList = [int(i) for i in input().split(" ")]
stn = HList[0]

count = 0
for i in range(len(HList)) :
    if i == 0 :
        count += 1
    elif HList[i] >= stn and HList[i] >= HList[i-1] :
        count += 1
        if stn > HList[i] :
            stn = HList[i]

print(count + "\n")

Fixed submission:
N = int(input())
HList = [int(i) for i in input().split(" ")]
stn = -1
count = 0

for i in range(len(HList)) :
    if HList[i] >= stn  :
        count += 1
    if stn < HList[i] :
        stn = HList[i]

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
HList = [int(i) for i in input().split(" ")]
stn = HList[0]
stn2 = HList[1]

count = 0
for i in range(len(HList)) :
    if i == 0 :
        count += 1
    elif HList[i] >= stn and HList[i] >= HList[i-1] :
        count += 1
        if stn > HList[i] :
            stn = HList[i]

print(count)

Fixed submission:
N = int(input())
HList = [int(i) for i in input().split(" ")]
stn = -1
count = 0

for i in range(len(HList)) :
    if HList[i] >= stn  :
        count += 1
    if stn < HList[i] :
        stn = HList[i]

print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
HList = [int(i) for i in input().split(" ")]
stn = HList[0]
stn2 = HList[1]

count = 0
for i in range(len(HList)) :
    if i == 0 :
        count += 1
    elif (HList[i] >= stn and HList[i] >= stn2) and HList[i] >= HList[i-1] :
        count += 1

print(count)

Fixed submission:
N = int(input())
HList = [int(i) for i in input().split(" ")]
stn = -1
count = 0

for i in range(len(HList)) :
    if HList[i] >= stn  :
        count += 1
    if stn < HList[i] :
        stn = HList[i]

print(count)