Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
listn = list(map(int,input().split()))

ans = 0
for i in range(1,n+1):
    if min(listn[:i]) >= listn[i-1]:
        ans += 1

print(ans)
    



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

a = 10**6
ans = 0
for i in range(n):
    if listn[i] <= a:
        a = listn[i]
        ans += 1

print(ans)

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

ans = 0
for i in range(1,n+1):
    if listn[i-1]==min(listn[:i]):
        ans+=1

print(ans)
    



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

a = 10**6
ans = 0
for i in range(n):
    if listn[i] <= a:
        a = listn[i]
        ans += 1

print(ans)

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

ans = 0
for i in range(1,n+1):
    list = listn[:i]
    if listn[i-1]==min(list):
        ans+=1

print(ans)
    



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

a = 10**6
ans = 0
for i in range(n):
    if listn[i] <= a:
        a = listn[i]
        ans += 1

print(ans)

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

ans = 0
for i in range(1,n+1):
    list = sorted(listn[:i])
    if listn[i-1]==list[0]:
        ans+=1

print(ans)
    

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

a = 10**6
ans = 0
for i in range(n):
    if listn[i] <= a:
        a = listn[i]
        ans += 1

print(ans)

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

ans = 0
for i in range(1,n+1):
    list = sorted(listn[:i])
    if listn[i-1]==list[0]:
        ans+=1

print(ans)
    

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

a = 10**6
ans = 0
for i in range(n):
    if listn[i] <= a:
        a = listn[i]
        ans += 1

print(ans)

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

ans = 0
for i in range(1,n+1):
    list = sorted(listn[:i])
    if listn[i-1]==list[0]:
        ans+=1

print(ans)
    

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

a = 10**6
ans = 0
for i in range(n):
    if listn[i] <= a:
        a = listn[i]
        ans += 1

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

k = n*m-sum(list)
if 0<= k <=100:
    print(k)
elif k<0:
    print(0)
else:
    print(-1)

Fixed submission:
c=input()
s='abcdefghijklmnopqrstuvwxyz'
list=list(s)

n=list.index(c)
print(list[n+1])
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

s =[2]
a = x

if x==2:
    print(x)
else:
  for i in range(3,2*x,2):
    if all(i%k!=0 for k in s):
        s.append(i)
        if i >=x:
          print(i)
          exit()
    





Fixed submission:
x = int(input())

s =[2]

if x==2:
    print(x)
    exit()
else:
    for i in range(3,int(x/2),2):
        if all(i%k!=0 for k in s):
            s.append(i)

while any(x%k==0 for k in s):
  x+=1
else:
  print(x)

Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())

s =[2]
a = x

if x==2:
    print(x)
else:
  for i in range(3,x,2):
    if all(i%k!=0 for k in s):
        s.append(i)
        
  for t in range(x,2*x):
    if all(t%k!=0 for k in s):
      print(t)
      exit()






Fixed submission:
x = int(input())

s =[2]

if x==2:
    print(x)
    exit()
else:
    for i in range(3,int(x/2),2):
        if all(i%k!=0 for k in s):
            s.append(i)

while any(x%k==0 for k in s):
  x+=1
else:
  print(x)
Buggy python submission (verdict: Runtime Error):
import collections

# input
N = int(input())
A = map(int,input().split())
# calculatioin
cnt = collections.Counter(A)
full_cnt = int(sum(cnt[key]*(cnt[key]-1)/2 for key in cnt))
for i in range(N):
  print(full_cnt - cnt[A[i]]+1)

Fixed submission:
import collections

# input
N = int(input())
A = input().split()
# calculatioin
cnt = collections.Counter(A)
full_cnt = int(sum(cnt[key]*(cnt[key]-1)/2 for key in cnt))
for i in range(N):
  print(full_cnt - cnt[A[i]]+1)
Buggy python submission (verdict: Runtime Error):
S = input()
Q = int(input())
head = True # True: left side is head
for i in range(Q):
  Query_i = list(map(str, input().split()))
  if Query_i[0]=='1':
    head = not head
  elif Query_i[1] == '1' and head:
    S = Query_i[2] + S
  elif Query_i[1] == '1' and not head:
    S = S + Query_i[2]
  elif Query_i[1] == '2' and head:
    S = S + Query_i[2]
  else Query_i[1] == '2' and not head:
    S = Query_i[2] + S
  if not head:
    S = S[::-1]
print(S)

Fixed submission:
# input
S = input()
# judge and print
if S[0]==S[1] and S[1]==S[2]:
  print('No')
else:
  print('Yes')

Buggy python submission (verdict: Runtime Error):
S = input()
Q = int(input())
for i in range(Q):
  Query_i = list(map(str, input().split()))
  if Query_i[0]=='1':
    S = S[::-1]
  elif Query_i[1] == '1':
    S = Query_i[2] + S
  else:
    S = S + Query_i[2]
print(S)

Fixed submission:
# input
S = input()
# judge and print
if S[0]==S[1] and S[1]==S[2]:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Runtime Error):
N,M = map(int, input().split())
candidate = [-1]*N
flag = False
if N == 1:
  if M == 0:
    candidate = [0]
  else:
    s_temp,c_temp = map(int, input().split())
    candidate = [c_temp]
else:
  for i in range(M):
    s_temp,c_temp = map(int, input().split())
    s_temp = s_temp - 1
    if candidate[s_temp] == -1:
      candidate[s_temp] = c_temp
    elif candidate[s_temp] == c_temp:
      pass
    elif candidate[s_temp] != c_temp:
      flag = True
      break
if flag == True:
  print(-1)
else:
  print(int(''.join(map(str, candidate))))

Fixed submission:
N, M = map(int, input().split())
flag = True
ex = [-1]*N
for i in range(M):
  S,C = map(int, input().split())
  if ex[S-1]==-1 or ex[S-1]==C:
    ex[S-1] = C
  else:
    flag = False
    break
if N>1 and ex[0]==0:
  flag = False
if flag:
  for i in range(1,N):
    if ex[i]==-1:
      ex[i] = 0
  if ex[0]==-1 and N>1:
    ex[0] = 1
  elif ex[0]==-1:
    ex[0] = 0
  print(int("".join(map(str, ex))))
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
def solve():
  val = str(input())
  return val[2] == val[3] && val[4] == val[5]
solve();

Fixed submission:
def solve():
  val = str(input())
  if val[2] == val[3] and val[4] == val[5]:
    print('Yes')
  else:
    print('No')
solve();
Buggy python submission (verdict: Runtime Error):
def solve():
  K = int(input())
  N = int(input())
  vals = [None] * N
  ans = 99999999
  for i in range(N):
    vals[i] = int(input())
  for i in range(N):
    cc = -1
    if i == 0:
      cc = vals[N-1] - vals[0]
    else:
      cc = vals[i-1] + K - vals[i]
    ans = min(ans, cc)
  print(ans)
solve()
  


Fixed submission:
def solve():
  raw = input().split()
  K = int(raw[0])
  N = int(raw[1])
  vals = [None] * N
  ans = 99999999
  raw = input().split()
  for i in range(N):
    vals[i] = int(raw[i])
  for i in range(N):
    cc = -1
    if i == 0:
      cc = vals[N-1] - vals[0]
    else:
      cc = vals[i-1] + K - vals[i]
    ans = min(ans, cc)
  print(ans)
solve()
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, A, B, C = map(int, input().split())
p = [int(a) for a in input().split()]
q = [int(a) for a in input().split()]
r = [int(a) for a in input().split()]
s = []

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

for i in range(X):
    s.append(p.pop(0))
for i in range(Y):
    s.append(q.pop(0))
s.sort()
for i in range(C):
    if(s[0] < r[0]):
        s.pop(0)
        s.append(r.pop(0))
        
print(sum(s))

Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = [int(a) for a in input().split()]
q = [int(a) for a in input().split()]
r = [int(a) for a in input().split()]
s = []

p.sort(reverse=True)
q.sort(reverse=True)

p = p[:X]
q = q[:Y]
s = p + q + r
s.sort(reverse=True)

s = s[:(X + Y)]
        
print(sum(s))

Buggy python submission (verdict: Time Limit Exceeded):
X, Y, A, B, C = map(int, input().split())
p = [int(a) for a in input().split()]
q = [int(a) for a in input().split()]
r = [int(a) for a in input().split()]
s = []

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

for i in range(X):
    s.append(p.pop(0))
for i in range(Y):
    s.append(q.pop(0))
s.sort()
for i in range(C):
    if(s[0] < r[0]):
        s[0] = r.pop(0)
        s.sort()
        
print(sum(s))

Fixed submission:
X, Y, A, B, C = map(int, input().split())
p = [int(a) for a in input().split()]
q = [int(a) for a in input().split()]
r = [int(a) for a in input().split()]
s = []

p.sort(reverse=True)
q.sort(reverse=True)

p = p[:X]
q = q[:Y]
s = p + q + r
s.sort(reverse=True)

s = s[:(X + Y)]
        
print(sum(s))
Buggy python submission (verdict: Runtime Error):
if num[2] == num[3] and num[-1] == num[-2]:
    print('Yes')
else:
    print('No')

Fixed submission:
num = input()
if num[2] == num[3] and num[-1] == num[-2]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
X = int(input())
if X >0:   
    num = X / 500
    w = X-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
 else:
     sum = 0   
print(sum)

Fixed submission:
X = int(input())
if X >0:   
    num = X / 500
    w = X-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
else:
     sum = 0   
print(sum)

Buggy python submission (verdict: Runtime Error):
x = int(input())
 if x >0:   
    num = x / 500
    w = x-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
 else:
     sum = 0   
print(sum)

Fixed submission:
X = int(input())
if X >0:   
    num = X / 500
    w = X-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
else:
     sum = 0   
print(sum)

Buggy python submission (verdict: Runtime Error):
x = int(input())
 if x >0:   
    num = x / 500
    w = x-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
 else:
     sum = 0 

Fixed submission:
X = int(input())
if X >0:   
    num = X / 500
    w = X-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
else:
     sum = 0   
print(sum)
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(x,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])


Fixed submission:
import sys

for S in sys.stdin:
    if(S[2]==S[3] and S[4]==S[5]):
        print("Yes")
    else:
        print ("No")

Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(0,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])


Fixed submission:
import sys

for S in sys.stdin:
    if(S[2]==S[3] and S[4]==S[5]):
        print("Yes")
    else:
        print ("No")

Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(0,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])


Fixed submission:
import sys

for S in sys.stdin:
    if(S[2]==S[3] and S[4]==S[5]):
        print("Yes")
    else:
        print ("No")
Buggy python submission (verdict: Runtime Error):
from sys import stdin, stdout  

n = stdin.readline() 
arr = [int(x) for x in stdin.readline().split()] 
K=arr[0]
N=arr[1]
n = stdin.readline() 
A = [int(x) for x in stdin.readline().split()] 
dist=[]
for i in range(0,N-1):
    dist.append(A[i+1]-A[i])
dist.append(abs(A[0]-A[-1]+K))

m=max(dist)
for idx,val in enumerate(dist):
    if(val==m):
        dist[idx]=0
        break
print(sum(dist))

Fixed submission:
from sys import stdin, stdout  

K, N = [int(c) for c in input().split()]
A = [int(c) for c in input().split()]
dist=[]
for i in range(0,N-1):
    dist.append(A[i+1]-A[i])
dist.append(abs(A[0]-A[-1]+K))

m=max(dist)
for idx,val in enumerate(dist):
    if(val==m):
        dist[idx]=0
        break
print(sum(dist))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*(2*N)        
for x in range(0,N):
    for y in range(0,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])


Fixed submission:
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(x,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]
A=[]
for i in range(1,N+1):
    A.append([0]*N)

        
res1={}
for x in range(0,N):
    for y in range(0,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        A[x][y]=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        if(x>=y):
            A[x][y]=0

for row in A:
    for y in row:
        if(y in res1):
                res1[y]=res1[y]+1
        else:
            res1[y]=1              

for i in range(1,N):
    if(i in res1):
        print(res1[i])
    else:
        print(0)

Fixed submission:
from sys import stdin, stdout  

N,X,Y = [int(c) for c in input().split()]


res=[0]*N        
for x in range(0,N):
    for y in range(x,N):
        #print(x,y,abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1),min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1)))
        r=min(abs(x-y),abs(abs(X-1-x)+abs(Y-1-y)+1))
        res[r]=res[r]+1
        if(x>y):
            res[r]=res[r]-1


for i in range(1,N):
    print(res[i])
Buggy python submission (verdict: Runtime Error):
K,N = map(int,input().split())
A = list(map(int,input().split()))

per_dist = list(A[i+1]-A[i] for i in range(0,N-1))
last_dist = A[0] + K - A[N - 1]
per_dist = per_dist.append(last_dist)
max_dist = max(per_dist)
print(K - max_dist)

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

per_dist = list(A[i+1]-A[i] for i in range(0,N-1))
last_dist = A[0] + K - A[N - 1]
type(last_dist)
per_dist.append(last_dist)
max_dist = max(per_dist)
print(K - max_dist)

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

per_dist = list(A[i+1]-A[i] for i in range(0,N-1))
last_dist = A[0] + K - A[N]
per_dist = per_dist.append(last_dist)
max_dist = max(per_dist)
print(K - max_dist)

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

per_dist = list(A[i+1]-A[i] for i in range(0,N-1))
last_dist = A[0] + K - A[N - 1]
type(last_dist)
per_dist.append(last_dist)
max_dist = max(per_dist)
print(K - max_dist)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q):
    query = input()
    if query == "1":
        s = s[::-1]
    else:
        t, f, c = query.split()
        if f == "1":
            s = c + s
        else:
            s = s + c

print(s)

Fixed submission:
from collections import deque

s = deque(input())
q = int(input())
reversed_flag = False

for i in range(q):
    query = input()
    if query == "1":
        reversed_flag = not reversed_flag
    else:
        t, f, c = query.split()
        if f == "1":
            if reversed_flag:
                s.append(c)
            else:
                s.appendleft(c)
        else:
            if reversed_flag:
                s.appendleft(c)
            else:
                s.append(c)

if reversed_flag:
    s.reverse()

print("".join(s))
Buggy python submission (verdict: Runtime Error):
S = str(input())
if S[2]==S[3] & S[4]==S[5]:
  print("Yes")
else:
  print("No")

Fixed submission:
S = str(input())
if S[2]==S[3] and S[4]==S[5]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s = str(input())
if s[2]==s[3] & s[4]==s[5]:
  print("Yes")
else:
  print("No")

Fixed submission:
S = str(input())
if S[2]==S[3] and S[4]==S[5]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s = str(input())
if s[2]=s[3] & s[4]=s[5]:
  print("Yes")
else:
  print("No")

Fixed submission:
S = str(input())
if S[2]==S[3] and S[4]==S[5]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
if s[2]=s[3] && s[4]=s[5]:
  print("Yes")
else:
  print("No")

Fixed submission:
S = str(input())
if S[2]==S[3] and S[4]==S[5]:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s = input()
if s[3]=s[4] && s[5]=s[6]:
  print("Yes")
else:
  print("No")

Fixed submission:
S = str(input())
if S[2]==S[3] and S[4]==S[5]:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
s = input()

if  a[0] == a[1] == a[2]:
    print("Np")
else:
    print("Yse")

Fixed submission:
import sys
input = sys.stdin.readline
s = input()

if  s[0] == s[1] == s[2]:
    print("No")
else:
    print("Yes")

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

s = [import()] 

if  a[0] == a[1] == a[2]:
	print("Yes")
else:
	print("No")

Fixed submission:
import sys
input = sys.stdin.readline
s = input()

if  s[0] == s[1] == s[2]:
    print("No")
else:
    print("Yes")
Buggy python submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split())  
sum=a+b
dif=a-b
mul=a*b


if sum > dif:
	if mul>sum:
    	print("{}".format(mul))
	else:
    	print("{}"format(sum))
else:
	if mul>dif:
    	print("{}".format(mul))
	else:
    	print("{}"format(dif))


Fixed submission:
a, b = (int(i) for i in input().split())  
sum=a+b
dif=a-b
mul=a*b
 
 
if sum > dif:
    if mul>sum:
        print('{}'.format(mul))
    else:
        print('{}'.format(sum))
else:
    if mul>dif:
        print('{}'.format(mul))
    else:
        print('{}'.format(dif))

Buggy python submission (verdict: Runtime Error):
a, b = (int(i) for i in input().split())  

if a+b > a-b:
	if a*b>a+b:
    	print("{}".format(a*b))
	else:
    	print("{}"format(a+b))
else:
	if a*b>a-b:
    	print("{}".format(a*b))
	else:
    	print("{}"format(a-b))

Fixed submission:
a, b = (int(i) for i in input().split())  
sum=a+b
dif=a-b
mul=a*b
 
 
if sum > dif:
    if mul>sum:
        print('{}'.format(mul))
    else:
        print('{}'.format(sum))
else:
    if mul>dif:
        print('{}'.format(mul))
    else:
        print('{}'.format(dif))
Buggy python submission (verdict: Runtime Error):
import numpy as np
from math import ceil, floor

n = int(input())
l = [int(input()) for x in range(n)]

c = ceil(np.array(l).mean())
f = floor(np.array(l).mean())


print(min(sum([(x-c)**2 for x in l]), sum([(x-f)**2 for x in l])))

Fixed submission:
import numpy as np
from math import ceil, floor
 
n = int(input())
l = [int(x) for x in input().split()]
 
c = ceil(np.array(l).mean())
f = floor(np.array(l).mean())

print(min(sum([(x-c)**2 for x in l]), sum([(x-f)**2 for x in l])))
Buggy python submission (verdict: Runtime Error):
k, x = map(int, input().split())
l =  [x-n for n in range(1,k)] + [x+n for n in range(k)]
l = [x for x in l if x <= 1000000]
l = [x for x in l if x >= 1000000 * -1]
l = sorted(l)
print(" ".join(map(str, s_l)))

Fixed submission:
k, x = map(int, input().split())
l =  [x-n for n in range(1,k)] + [x+n for n in range(k)]
l = [x for x in l if x <= 1000000]
l = [x for x in l if x >= 1000000 * -1]
l = sorted(l)
print(" ".join(map(str, l)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
cnt = 0
for i in range(len(a)):
    if l == sorted(l):
        break
    for j in range(len(a)-1, i, -1):
        if a[j] < a[j-1]:
            a[j], a[j-1] = a[j-1], a[j]
        cnt += 1

print("YES" if cnt < 2 else "NO")

Fixed submission:
n = int(input())
l = [int(x) for x in input().split()]
s_l = sorted(l)
print("YES" if sum([1 if l[i]!=s_l[i] else 0 for i in range(n)]) <= 2 else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = [int(input()) for _ in range(n)]
l = [0] + l + [0,0]
for i in range(1,n+1):
    print(max(max(l[:i]), max(l[i+1:])))

Fixed submission:
n = int(input())
l = [int(input()) for _ in range(n)]
_l = l.copy()
_l.sort(reverse=True)
lmax = _l[0]
lsec = _l[1]

for i in range(n):
    if l[i] == lmax:
        print(lsec)
    else:
        print(lmax)

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

for i in range(n):
    if i == 0:
        print(max(l[i+1:]))
    elif i == n-1:
        print(max(max(l[:i]), l[-1]))
    elif i == n:
        print(max(l[:i]))
    else:
        print(max(max(l[:i]), max(l[i+1:])))

Fixed submission:
n = int(input())
l = [int(input()) for _ in range(n)]
_l = l.copy()
_l.sort(reverse=True)
lmax = _l[0]
lsec = _l[1]

for i in range(n):
    if l[i] == lmax:
        print(lsec)
    else:
        print(lmax)