Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S_dict={}

for s_idx in range(N):
    s = input()
    
    if s not in S_dict.keys():
        S_dict.update({s:1})
    else:
        S_dict.update({s:S_dict[s]+1})
        
s_max=max(S_dict.values())

ans = []    
 
for a,b in S_dict.items():
    if b == s_max:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Fixed submission:
N = int(input())
 
counter = {}
 
for i in range(N):
    temp = input()
    if temp not in counter:
        counter.update({temp : 1})
    else:
        counter.update({temp : counter[temp] + 1})
 
m = max(counter.values())
        
ans = []    
 
for a,b in counter.items():
    if b == m:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S_dict={}

for s_idx in range(N):
    s = input()
    
    if s not in S_dict.keys():
        S_dict[s]=1
    else:
        S_dict[s]+=1
        
s_max=max(S_dict.values())

ans = []    
 
for a,b in S_dict.items():
    if b == s_max:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Fixed submission:
N = int(input())
 
counter = {}
 
for i in range(N):
    temp = input()
    if temp not in counter:
        counter.update({temp : 1})
    else:
        counter.update({temp : counter[temp] + 1})
 
m = max(counter.values())
        
ans = []    
 
for a,b in counter.items():
    if b == m:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S_dict={}

for s_idx in range(N):
    s = input()
    
    if s not in S_dict.keys():
        S_dict[s]=1
    else:
        S_dict[s]+=1

s_max=0
s_max_key=[]

for s_key in S_dict.keys():
    if s_max < S_dict[s_key]:
        s_max_key=[]
        s_max=S_dict[s_key]
        s_max_key.append(s_key)
    elif s_max == S_dict[s_key]:
        s_max=S_dict[s_key]
        s_max_key.append(s_key)
        
s_max_key.sort()

for ans in s_max_key:
    print(ans)

Fixed submission:
N = int(input())
 
counter = {}
 
for i in range(N):
    temp = input()
    if temp not in counter:
        counter.update({temp : 1})
    else:
        counter.update({temp : counter[temp] + 1})
 
m = max(counter.values())
        
ans = []    
 
for a,b in counter.items():
    if b == m:
        ans.append(a)
    
ans.sort()
 
for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=list(map(int,input().split()))
P=list(map(int,input().split()))

E_P=[(1+p)/2 for p in P] 

max_ = 0
for k_ in range(len(P)-K+1):
    if max_ < sum(E_P[k_:k_+K]):
        max_=sum(E_P[k_:k_+K])
        
print(max_)

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

E_P=[(1+p)/2 for p in P] 

E_P_sum=[0]
E_P_sum_=0
for n in range(N):
    E_P_sum_=E_P_sum_+E_P[n]
    E_P_sum.append(E_P_sum_)

max_ = 0
for k_ in range(len(P)-K+1):
    sum_=E_P_sum[k_+K]-E_P_sum[k_]
#     print(E_P_sum[k_+K],E_P_sum[k_],sum_)
    if max_ < sum_:
        max_=sum_
        
print(max_)
Buggy python submission (verdict: Runtime Error):
N,K = list(map(int,input().split()))
H = list(map(int,input().split()))

H.soat(reverse=True)

H=H[K:]

H_cumsum=[0]
H_sum_=0
for n in range(len(H)):
    H_sum_=H_sum_+H[n]
    H_cumsum.append(H_sum_)
print(H_sum_)

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

H.sort(reverse=True)

H=H[K:]

H_cumsum=[0]
H_sum_=0
for n in range(len(H)):
    H_sum_=H_sum_+H[n]
    H_cumsum.append(H_sum_)
print(H_sum_)
Buggy python submission (verdict: Runtime Error):
H=int(input())

H_list=[]
while H > 1:
    if H % 2 != 0:
        H=H-1
    H_list.append(H)
        
    H = H//2
    
H_list.sort()

ans_list=[]
for h in H_list:
    if h == 2:
        ans = 3
    else :
        ans = 2*ans+1
    ans_list.append(ans)
    
print(ans)

Fixed submission:
H=int(input())

if H == 1:
  ans=1
  
H_list=[]
while H > 1:
    if H % 2 != 0:
        H=H-1
    H_list.append(H)
        
    H = H//2
    
H_list.sort()
 
ans_list=[]
for h in H_list:
    if h == 2:
        ans = 3
    else :
        ans = 2*ans+1
    ans_list.append(ans)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
H,W = list(map(int,input().split()))
N=H*W

#壁のノード
wall=[]
for h in range(H):
    for w_idx,w in enumerate(list(input())):
        if w == '#':
            wall.append(W*h+w_idx+1)
#道のノード        
path=[_ for _ in range(1,N+1) if _ not in wall]

#隣接リスト
ad = {}
for n in range(N):
    ad[n+1]=[]
    
for n in range(N):
    n=n+1
    if n not in wall:
        up = n-W
        if up > 0 and up not in wall:
            ad[n].append(up)
            
        down = n+W
        if down <= N and down not in wall:
            ad[n].append(down)
            
        left = n-1
        if n % W != 1 and left not in wall:
            ad[n].append(left)
        
        right = n+1
        if n % W != 0 and right not in wall:
            ad[n].append(right)      

from collections import deque

def BFS(start):
    que = deque([start])
    visit = deque([])

    color = {}
    for n in range(N):
        color[n+1] = -1
    color[start] = 0

    depth = {}
    for n in range(N):
        depth[n+1] = -1

    depth[start]=0
    while len(que) > 0:
        start = que[0]
        for v in ad[start]:
            if color[v] == -1:
                que.append(v)
                color[v] = 0
                depth[v] = depth[start]+1

        color[start]=1
        visit.append(que.popleft())

    return depth[start]

ans=-1
for start in path:
    ans_=BFS(start)
    if ans < BFS(start):
        ans = ans_
    
#     print(start,ans_)
    
print(ans)

Fixed submission:
H,W = list(map(int,input().split()))
N=H*W

#壁のノード
wall=[]
for h in range(H):
    for w_idx,w in enumerate(list(input())):
        if w == '#':
            wall.append(W*h+w_idx+1)
#道のノード        
path=[_ for _ in range(1,N+1) if _ not in wall]

#隣接リスト
ad = {}
for n in range(N):
    ad[n+1]=[]
    
for n in range(N):
    n=n+1
    if n not in wall:
        up = n-W
        if up > 0 and up not in wall:
            ad[n].append(up)
            
        down = n+W
        if down <= N and down not in wall:
            ad[n].append(down)
            
        left = n-1
        if n % W != 1 and left not in wall and left > 0:
            ad[n].append(left)
        
        right = n+1
        if n % W != 0 and right not in wall:
            ad[n].append(right)      

from collections import deque

def BFS(start):
    que = deque([start])
    visit = deque([])

    color = {}
    for n in range(N):
        color[n+1] = -1
    color[start] = 0

    depth = {}
    for n in range(N):
        depth[n+1] = -1

    depth[start] = 0
    while len(que) > 0:
        start = que[0]
        for v in ad[start]:
            if color[v] == -1:
                que.append(v)
                color[v] = 0
                depth[v] = depth[start]+1

        color[start] = 1
        visit.append(que.popleft())

    return depth[start]

ans=-1
for start in path:
    ans_=BFS(start)
    if ans < BFS(start):
        ans = ans_
    
#     print(start,ans_)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools

N = int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

for v_idx,v in enumerate(itertools.permutations(range(1,N+1))):
    if v==P:
        a=v_idx
    elif v==Q:
        b=v_idx
        
print(abs(a-b))

Fixed submission:
import itertools
 
N = int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
 
for v_idx,v in enumerate(itertools.permutations(range(1,N+1))):
    if v==P:
        a=v_idx
    if v==Q:
        b=v_idx
        
print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

#input
N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))

T = list(input())
T_ =T.copy()

# N=2*10**5
# T=[random.choice(['s', 'r', 'p']) for _ in range(N)]

check=set(['s', 'r', 'p'])

#得点
point={'r':P,'s':R,'p':S}
point

T_point = [0]*N
for n in range(N):
    T_point[n]=point[T[n]]
    
for k in range(K,N):
    check_out = set()
    if T[k] == T[k-K]: # K回前の手と同じ場合
        check_out.add(T[k])
        if k+K <= N:
            check_out.add(T[k+K])
            
        check_out=check-check_out
        
        T[k]=list(check_out)[0]
         
ans=0

for t in range(len(T)):
    if T[t] == T_[t]:
        ans += point[T[t]]
print(ans)

Fixed submission:
from collections import Counter

#input
N,K = list(map(int,input().split()))
R,S,P = list(map(int,input().split()))

T = list(input())
T_ =T.copy()

# N=2*10**5
# T=[random.choice(['s', 'r', 'p']) for _ in range(N)]

check=set(['s', 'r', 'p'])

#得点
point={'r':P,'s':R,'p':S}
point

T_point = [0]*N
for n in range(N):
    T_point[n]=point[T[n]]
    
for k in range(K,N):
    check_out = set()
    if T[k] == T[k-K]: # K回前の手と同じ場合
        check_out.add(T[k])
        if k+K < N:
            check_out.add(T[k+K])
            
        check_out=check-check_out
        
        T[k]=list(check_out)[0]
         
ans=0

for t in range(len(T)):
    if T[t] == T_[t]:
        ans += point[T[t]]
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
T = []

while len(input())>0:
    t = int(input())
    T_temp=[]
    for t_ in range(t) :
        temp = list(map(int,input().split()))
        T_temp.append(temp)
    T.append(T_temp)
    
def check_Contradiction(true_list):
    S = {}
    for n in range(N):
        if n in true_list:
            S[n]=set([1])
        else:
            S[n]=set([0])

    for t in true_list:
        for T_ in T[t]:
            S[T_[0]-1].add(T_[1])
    ok=True
    for s in S.keys():
        if len(S[s])!=1:
            ok='False'
            break

    return ok

ok_max = -1
for i in range(2**N):
#     print('=====',i)
    true_list=[]
    for j in range(N):
        if i>>j&1 ==True:
            true_list.append(j)
#     print(true_list)
#     print(check_Contradiction(true_list))
            
    if check_Contradiction(true_list)==True:
        if ok_max < len(true_list):
            ok_max=len(true_list)
            
print(ok_max)

Fixed submission:
N = int(input())
T = []
try:
	while True:
		t = input()
		t=int(t)
		T_temp=[]
		for t_ in range(t) :
			temp = list(map(int,input().split()))
			T_temp.append(temp)
		T.append(T_temp)
except EOFError:
	pass
    
def check_Contradiction(true_list):
    S = {}
    for n in range(N):
        if n in true_list:
            S[n]=set([1])
        else:
            S[n]=set([0])

    for t in true_list:
        for T_ in T[t]:
            S[T_[0]-1].add(T_[1])
    ok=True
    for s in S.keys():
        if len(S[s])!=1:
            ok='False'
            break

    return ok

ok_max = -1
for i in range(2**N):
#     print('=====',i)
    true_list=[]
    for j in range(N):
        if i>>j&1 ==True:
            true_list.append(j)
#     print(true_list)
#     print(check_Contradiction(true_list))
            
    if check_Contradiction(true_list)==True:
        if ok_max < len(true_list):
            ok_max=len(true_list)
            
print(ok_max)
Buggy python submission (verdict: Runtime Error):
def mod_fact(N,p):
    mod=1
    for n in range(1,N+1):
        mod = (mod*(n%p))%p
        
    mod = mod%p
    
    return mod

X,Y = list(map(int,input().split()))

Z = X+Y

if Z%3 != 0:
    ans=0
    
elif min(X,Y) >= Z//3:
    b=0
    for z in range(Z//3,((Z//3)*2)+1):
        if z == X:
            break
        b+=1
    a = Z//3 - b 
    
    p=(10**9)+7

    Z_= mod_fact(Z//3 , p)
    a_= mod_fact(a , p)
    b_= mod_fact(b , p)

    a_= pow(a_,p-2,p)
    b_= pow(b_,p-2,p)

    ans=(Z_*(a_*b_))%p
    
print(ans)

Fixed submission:
def mod_fact(N,p):
    mod=1
    for n in range(1,N+1):
        mod = (mod*(n%p))%p
        
    mod = mod%p
    
    return mod

X,Y = list(map(int,input().split()))

Z = X+Y

ans=0

if Z%3 != 0:
    ans=0
    
elif min(X,Y) >= Z//3:
    b=0
    for z in range(Z//3,((Z//3)*2)+1):
        if z == X:
            break
        b+=1
    a = Z//3 - b 
    
    p=(10**9)+7

    Z_= mod_fact(Z//3 , p)
    a_= mod_fact(a , p)
    b_= mod_fact(b , p)

    a_= pow(a_,p-2,p)
    b_= pow(b_,p-2,p)

    ans=(Z_*(a_*b_))%p
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans=0
for a_idx in range(len(L)):
    a = L[a_idx]
    for b_idx in range(a_idx+1,len(L)):
        b = L[b_idx]
        c_low = b - a + 1
        c_up = a + b - 1
        
        c_low_idx = bisect.bisect(L,c_low)
        c_up_idx = bisect.bisect(L,c_up)
        c_low_idx = max(b_idx,c_low_idx)
        
        ans += max(0,c_up_idx-c_low_idx-1)
#         print(a,b,ans,c_up_idx,c_low_idx)
print(ans)

Fixed submission:
import bisect

N = int(input())
L = list(map(int,input().split()))
L.sort()

# print(L)

ans=0
for a_idx in range(len(L)):
    a = L[a_idx]
    for b_idx in range(a_idx+1,len(L)):
        b = L[b_idx]
        c_low = b - a
        c_up = a + b - 1
        
        c_low_idx = bisect.bisect(L,c_low)
        c_up_idx = bisect.bisect(L,c_up)
        
#         print('=====')
#         print(a,b)
#         print(c_low_idx,c_up_idx)
        
        c_low_idx = max(b_idx,c_low_idx)
        
        ans += max(0,c_up_idx-c_low_idx-1)
#         print(ans,c_low_idx,c_up_idx)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int(input())
A = list(map(int,input().split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')


Fixed submission:
from collections import deque

N = int(input())
A = deque(map(int,input().split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')

Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int(input_[0])
A = list(map(int,input_[1].split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')

Fixed submission:
from collections import deque

N = int(input())
A = deque(map(int,input().split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')

Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int(input_[0])
A = list(map(int,input_[1].split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

# print(*ans, sep=' ')

Fixed submission:
from collections import deque

N = int(input())
A = deque(map(int,input().split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans=[]

A_dict={}

for n in range(N):
    a = A.pop(0)
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')

Fixed submission:
from collections import deque

N = int(input())
A = deque(map(int,input().split()))

ans=[]

A_dict={}

for n in range(N):
    a = A.popleft()
    A_dict[a]=n+1
    
for n in range(N):
    ans.append(A_dict[n+1])

print(*ans, sep=' ')
Buggy python submission (verdict: Runtime Error):
N,M = list(map(int,input().split()))
S = list(input())

s_=''
S_=[]

for s in S:
    if s != s_:
        S_.append(s)
        s_=s
        
    else:
        S_[-1]+=s
        

change_str_dict={'R':'L','L':'R'}
change_str=change_str_dict[S_[1][0]]

for m in range(1,min(2*M,len(S_)),2):
    S_[m]=change_str*len(S_[m])

S_=''.join(S_)
# print(S_)

s_=S_[0]
ans=0
for s in S_[1:]:
    if s == s_:
        ans+=1
    else:
        s_=s
        
print(ans)

Fixed submission:
N,M = list(map(int,input().split()))
S = list(input())

s_=''
S_=[]

if len(set(S))==1:
    ans = len(S)-1
    
else:
    for s in S:
        if s != s_:
            S_.append(s)
            s_=s

        else:
            S_[-1]+=s

    change_str_dict={'R':'L','L':'R'}
    change_str=change_str_dict[S_[1][0]]

    for m in range(1,min(2*M,len(S_)),2):
        S_[m]=change_str*len(S_[m])

    S_=''.join(S_)
    # print(S_)

    s_=S_[0]
    ans=0
    for s in S_[1:]:
        if s == s_:
            ans+=1
        else:
            s_=s

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H=[int(x) for x in input().split()]

ans='Yes'
for n in range(N-1,0,-1):
    num=H[n]
    check=max(set(H[:n]))
    if check > num+1:
        ans='No'
print(ans)

Fixed submission:
N=int(input())
H=[int(x) for x in input().split()]

max_h=0
ans='Yes'

for n in range(N):
    if H[n] > max_h:
        max_h = H[n]
        
    if H[n] < max_h-1:
        ans='No'
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
H=[int(x) for x in input().split()]

ans='Yes'
for n in range(N-1,0,-1):
    num=H[n]
    check=max(H[:n])
    if check > num+1:
        ans='No'
print(ans)

Fixed submission:
N=int(input())
H=[int(x) for x in input().split()]

max_h=0
ans='Yes'

for n in range(N):
    if H[n] > max_h:
        max_h = H[n]
        
    if H[n] < max_h-1:
        ans='No'
        
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()

check_str = 'LR'
S_=[]
s_temp = ''
for s in range(len(S)):
    s_temp += S[s]
    
    if s < len(S)-1:
        s_= s+1 
        if S[s]=='L' and S[s_] == 'R':
            S_.append(Counter(s_temp))
            s_temp =''
            
    else:
        S_.append(Counter(s_temp))

def get_ans_temp(S_temp):
    S_R = S_temp['R']
    S_L = S_temp['L']
    
    S_R_ans=[0]*S_R
    S_L_ans=[0]*S_L
    
    if (S_R + S_L) % 2 ==0 :#偶数の時
        S_R_ans[-1] = (S_R + S_L) // 2
        S_L_ans[0] = (S_R + S_L) // 2

    elif S_R != S_L :#奇数の時
        if S_R > S_L:
            S_R_ans[-1] = (S_R + S_L) // 2 +1
            S_L_ans[0] = (S_R + S_L) // 2         
        else:
            S_R_ans[-1] = (S_R + S_L) // 2
            S_L_ans[0] = (S_R + S_L) // 2 + 1
            
        max_RL_num = max(S_R,S_L)
        if max_RL_num % 2 == 0:
            _ = S_R_ans[-1]
            S_R_ans[-1]=S_L_ans[0]
            S_L_ans[0]=_

    ans_temp = []
    ans_temp.extend(S_R_ans)
    ans_temp.extend(S_L_ans)
    return ans_temp

ans_list=[]
for S_temp in S_:
    ans_list.extend(get_ans_temp(S_temp))
    
ans=' '.join(map(str,ans_list))

print(ans)

Fixed submission:
from collections import Counter
S = input()

check_str = 'LR'
S_=[]
s_temp = ''
for s in range(len(S)):
    s_temp += S[s]
    
    if s < len(S)-1:
        s_= s+1 
        if S[s]=='L' and S[s_] == 'R':
            S_.append(Counter(s_temp))
            s_temp =''
            
    else:
        S_.append(Counter(s_temp))

def get_ans_temp(S_temp):
    S_R = S_temp['R']
    S_L = S_temp['L']
    
    S_R_ans=[0]*S_R
    S_L_ans=[0]*S_L
    
    if (S_R + S_L) % 2 ==0 :#偶数の時
        S_R_ans[-1] = (S_R + S_L) // 2
        S_L_ans[0] = (S_R + S_L) // 2

    elif S_R != S_L :#奇数の時
        if S_R > S_L:
            S_R_ans[-1] = (S_R + S_L) // 2 +1
            S_L_ans[0] = (S_R + S_L) // 2         
        else:
            S_R_ans[-1] = (S_R + S_L) // 2
            S_L_ans[0] = (S_R + S_L) // 2 + 1
            
        max_RL_num = max(S_R,S_L)
        if max_RL_num % 2 == 0:
            _ = S_R_ans[-1]
            S_R_ans[-1]=S_L_ans[0]
            S_L_ans[0]=_

    ans_temp = []
    ans_temp.extend(S_R_ans)
    ans_temp.extend(S_L_ans)
    return ans_temp

ans_list=[]
for S_temp in S_:
    ans_list.extend(get_ans_temp(S_temp))
    
ans=' '.join(map(str,ans_list))

print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(read_input())
P=[int(x) for x in read_input().split()]

N_J=list(range(1,N+1))
ans='NO'
for i in range(N):
    for j in range(N):
        P_temp=P.copy()
        p_i=P[i]
        p_j=P[j]

        P_temp[i]=p_j
        P_temp[j]=p_i
        
        if P_temp==N_J:
            ans='YES'
            
print(ans)

Fixed submission:
N=int(input())
P=[int(x) for x in input().split()]
 
N_J=list(range(1,N+1))
ans='NO'
for i in range(N):
    for j in range(N):
        P_temp=P.copy()
        p_i=P[i]
        p_j=P[j]
 
        P_temp[i]=p_j
        P_temp[j]=p_i
        
        if P_temp==N_J:
            ans='YES'
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
P=[int(x) for x in input().split()]
 
N_J=list(range(1,N+1))
ans='NO'
for i in range(N):
    for j in range(N):
        P_temp=P.copy()
        p_i=P[i]
        p_j=P[j]
 
        P_temp[i]=p_j
        P_temp[j]=p_i
        
        if P==N_J:
            ans='YES'
print(ans)
N=int(input())
P=[int(x) for x in input().split()]

N_J=list(range(1,N+1))
ans='NO'
for i in range(N):
    for j in range(N):
        P_temp=P.copy()
        p_i=P[i]
        p_j=P[j]

        P_temp[i]=p_j
        P_temp[j]=p_i
        
        if P==N_J:
            ans='YES'
print(ans)

Fixed submission:
N=int(input())
P=[int(x) for x in input().split()]
 
N_J=list(range(1,N+1))
ans='NO'
for i in range(N):
    for j in range(N):
        P_temp=P.copy()
        p_i=P[i]
        p_j=P[j]
 
        P_temp[i]=p_j
        P_temp[j]=p_i
        
        if P_temp==N_J:
            ans='YES'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))

L_max=max(L)

for i in range(N):
    now=L[i]
    
    if now!=L_max:
        ans=L_max
        
    else:
        L_temp=L.copy()
        L_temp_p=L_temp.pop(i)
        ans=max(L_temp)
    
    print(ans)

Fixed submission:
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))

L_max=max(L)

L_max_count=0
for l in L:
    if l==L_max:
        L_max_count+=1
    if L_max_count > 1:
        break

for i in range(N):
    now=L[i]
    
    if L_max_count > 1:
        ans=L_max
    
    elif now!=L_max:
        ans=L_max
        
    else:
        L_temp=L.copy()
        L_temp_p=L_temp.pop(i)
        ans=max(L_temp)
    
    print(ans)

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

for i in range(N):
    L_temp=L.copy()
    L_temp_p=L_temp.pop(i)
    print(max(L_temp))

Fixed submission:
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))

L_max=max(L)

L_max_count=0
for l in L:
    if l==L_max:
        L_max_count+=1
    if L_max_count > 1:
        break

for i in range(N):
    now=L[i]
    
    if L_max_count > 1:
        ans=L_max
    
    elif now!=L_max:
        ans=L_max
        
    else:
        L_temp=L.copy()
        L_temp_p=L_temp.pop(i)
        ans=max(L_temp)
    
    print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))
L

for i in range(N):
    now=L[i]
    L_temp=[x for x in L if x != now ]
    print(max(L_temp))

Fixed submission:
N=int(input())
L=[]
for i in range(N):
    L.append(int(input()))

L_max=max(L)

L_max_count=0
for l in L:
    if l==L_max:
        L_max_count+=1
    if L_max_count > 1:
        break

for i in range(N):
    now=L[i]
    
    if L_max_count > 1:
        ans=L_max
    
    elif now!=L_max:
        ans=L_max
        
    else:
        L_temp=L.copy()
        L_temp_p=L_temp.pop(i)
        ans=max(L_temp)
    
    print(ans)