Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def dfs(u):
    if(dp[u]!=-1):
        return dp[u]
    for i in d[u]:
        if(dp[i]!=-1):
            dp[u]=max(dp[u],dp[i]+1)
        else:
            dp[u]=max(dp[u],dfs(i)+1)
    return max(dp[u],0)
from collections import defaultdict as dd
n,m=map(int,input().split())
d=dd(list)
for i in range(m):
    u,v=map(int,input().split())
    d[u].append(v)
dp=dd(lambda: -1)
mx=0
for i in range(1,n+1):
    if(dp[i]==-1):
        dp[i]=dfs(i)
    mx=max(mx,dp[i])
print(mx)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
def dfs(u):
    if(dp[u]!=-1):
        return dp[u]
    for i in d[u]:
        if(dp[i]!=-1):
            dp[u]=max(dp[u],dp[i]+1)
        else:
            dp[u]=max(dp[u],dfs(i)+1)
    return max(dp[u],0)
from collections import defaultdict as dd
n,m=map(int,input().split())
d=dd(list)
for i in range(m):
    u,v=map(int,input().split())
    d[u].append(v)
dp=dd(lambda: -1)
mx=0
for i in range(1,n+1):
    if(dp[i]==-1):
        dp[i]=dfs(i)
    mx=max(mx,dp[i])
print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict as dd    
n=int(input())
l=list(map(float,input().split()))
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(n+1):
        if(j==0):
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])
        else:
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])+dp[i-1][j-1]*l[i-1]
ans=0
for i in range(n//2+1,n+1):
    ans+=dp[n][i]
print(ans)

Fixed submission:
import sys
input=sys.stdin.readline
from collections import defaultdict as dd    
n=int(input())
l=list(map(float,input().split()))
dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(n+1):
        if(j==0):
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])
        else:
            dp[i][j]=dp[i-1][j]*(1.0-l[i-1])+dp[i-1][j-1]*l[i-1]
ans=0
for i in range(n//2+1,n+1):
    ans+=dp[n][i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    #start here
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0 for i in range(n)]
    for i in range(1, n):
        x = float('inf')
        for j in range(1, 1 + min(k, i)):
            x = min(x, dp[i-j] + abs(h[i]-h[i-j]))
        dp[i] = x
    print(dp[n-1])
 
solve()

Fixed submission:
def solve():
    #start here
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0 for i in range(n)]
    for i in range(1, n):
        x = float('inf')
        for j in range(1, 1 + min(k, i)):
            x = min(x, dp[i-j] + abs(h[i]-h[i-j]))
        dp[i] = x
    print(dp[n-1])

solve()

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, setrecursionlimit as srl
from threading import stack_size, Thread
from math import *
from collections import *
from heapq import *

srl(int(1e9)+7)
stack_size(int(1e8))

'''
deque
1) append
2) appendleft
3) pop
4) popleft
5) insert, remove, index, count, extend, extendleft, reverse
6) rotate           # negative value rotates to the left , positive to the right
'''

'''
heapq

minheap by default but can be used as maxheap by pushing elements after multiplying them with -1

1) heapify ( iterable )
2) heappush ( heap, element)
3) heappop (heap)                   # smallest is removed
4) heappushpop (heap, element)
5) heapreplace (heap, element)      # same as heappushpop but first popped then pushed
'''

def solve():
    #start here
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0 for i in range(n)]
    for i in range(1, n):
        x = float('inf')
        for j in range(1, 1 + min(k, i)):
            x = min(x, dp[i-j] + abs(h[i]-h[i-j]))
        dp[i] = x
    print(dp[n-1])


Thread(target=solve).start()

Fixed submission:
def solve():
    #start here
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0 for i in range(n)]
    for i in range(1, n):
        x = float('inf')
        for j in range(1, 1 + min(k, i)):
            x = min(x, dp[i-j] + abs(h[i]-h[i-j]))
        dp[i] = x
    print(dp[n-1])

solve()
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    #start here
    n, W = map(int,input().split())
    if (W > 10**5+1):
        ans = 0
        for i in range(n):
            w, v = map(int,input().split())
            ans+=v
        print(ans)
    l = []
    dp = [[0 for i in range(W+1)] for j in range(n)]
    for i in range(n):
        w, v = map(int,input().split())
        for j in range(1, W+1):
            if(w>j):
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j], v+dp[i-1][j-w])
    print(dp[n-1][W])
solve()

Fixed submission:
n, W = map(int,input().split())
dp = [[float('inf') for i in range(10**5+1)] for j in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0
ans = 0
for i in range(1, n+1):
    w, v = map(int,input().split())
    for j in range(1, 10**5+1):
        if v>j:
            dp[i][j] = dp[i-1][j]
            continue
        dp[i][j] = min(dp[i-1][j], w+dp[i-1][j-v])
        if dp[i][j] <= W:
            ans = max(ans, j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    #start here
    n, W = map(int,input().split())
    l = []
    dp = [[0 for i in range(W+1)] for j in range(n)]
    for i in range(n):
        w, v = map(int,input().split())
        for j in range(1, W+1):
            if(w>j):
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j], v+dp[i-1][j-w])
    print(dp[n-1][W])
solve()

Fixed submission:
n, W = map(int,input().split())
dp = [[float('inf') for i in range(10**5+1)] for j in range(n+1)]
for i in range(n+1):
    dp[i][0] = 0
ans = 0
for i in range(1, n+1):
    w, v = map(int,input().split())
    for j in range(1, 10**5+1):
        if v>j:
            dp[i][j] = dp[i-1][j]
            continue
        dp[i][j] = min(dp[i-1][j], w+dp[i-1][j-v])
        if dp[i][j] <= W:
            ans = max(ans, j)
print(ans)
Buggy python submission (verdict: Runtime Error):
def get(i, value, vis):
    if vis[i]:
        return value[i]
    vis[i] = True
    ans = 0
    for j in adj[i]:
        ans = max(ans, 1+get(j, value, vis))
    value[i] = ans
    return ans


n, m = map(int, input().split())
adj = {}
for i in range(n):
    adj[i] = []
for i in range(m):
    x, y = map(int,input().split())
    adj[x-1].append(y-1)
vis = [False for i in range(n)]
value = [0 for i in range(n)]
for i in range(n):
    value[i] = get(i, value, vis)
x = 0
for i in value:
    x = max(x, i)
print(x)

Fixed submission:
from sys import stdin, setrecursionlimit as srl
from threading import stack_size
srl(int(1e9)+7)
stack_size(int(1e8))

def get(i, value, vis):
    if vis[i]:
        return value[i]
    vis[i] = True
    ans = 0
    for j in adj[i]:
        ans = max(ans, 1+get(j, value, vis))
    value[i] = ans
    return ans


n, m = map(int, input().split())
adj = {}
for i in range(n):
    adj[i] = []
for i in range(m):
    x, y = map(int,input().split())
    adj[x-1].append(y-1)
vis = [False for i in range(n)]
value = [0 for i in range(n)]
for i in range(n):
    value[i] = get(i, value, vis)
x = 0
for i in value:
    x = max(x, i)
print(x)
Buggy python submission (verdict: Time Limit Exceeded):
X,K,D=map(int,input().split())
key=abs(X)
if key<D:
  if K%2==0:
    print(key)
    exit()
  else:
    print(abs(key-D))
    exit()
for i in range(K):
  key-=D
  K-=1
  if key<D:
    break
if K==0:
  print(key)

else:
  Key=key-D
  if K%2==0:
    ans=abs(key)
  else:
    ans=abs(Key)
  print(ans)

Fixed submission:
X,K,D=map(int,input().split())
x=abs(X)
key=x//D
Key=x%D
if key>K:
  print(x-K*D)
  exit()
KEY=Key-D
if (K-key)%2==0:
  ans=abs(Key)
else:
  ans=abs(KEY)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(0,N+1,2):
  if A[i]%2!=0:
    ans+=1
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(0,N,2):
  if A[i]%2==1:
    ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(0,N+1,2):
  if A[i]%2==1:
    ans+=1
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(0,N,2):
  if A[i]%2==1:
    ans+=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
num = min(N,M)
C= [None]*(num*2)
C[::2] = A[:num]
C[1::2] = B[:num]
C.extend(A[num:])
C.extend(B[num:])
if N>M:
  C.extend(A[N-M:N])
elif M>N:
  C.extend(B[M-N:M])
  
if min(C[0],C[1])>K:
  print('0')
  exit()
k=0
ans=0
for i in range(len(C)):
  key=min(C[0],C[1])
  k+=key
  ans+=1
  C.remove(key)
  if k>=K:
    break
  if len(C)==1:
    k+=C[0]
    ans+=1
    break
if k==K:
  print(ans)
else:
  print(ans-1)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
     break
  else:
    while b[j] > K - a[i]:
      j -= 1
  ans = max(ans, i + j)
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans=sum(A)
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  #Bの数だけ（C-B)足す、BはCに置き換わるのでLB＝０になおす。
  key=L[B]
  L[C]+=key
  ans+=key*(C-B)
  L[B]=0
  print(ans)

Fixed submission:
S=input()
if S.isupper()==True:
  print('A')
else:
  print('a')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans=sum(A)
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  #Bの数だけ（C-B)足す、BはCに置き換わるのでLB＝０になおす。
  L[C]+=L[B]
  ans+=L[B]*(C-B)
  L[B]=0
  print(ans)

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans+=a
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  key=L[B]
  L[C]+=key
  ans+=key*(C-B)
  L[B]=0
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans=sum(A)
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  #Bの数だけ（C-B)足す、BはCに置き換わるのでLB＝０になおす。
  key=L[B]
  L[C]+=key
  ans+=key*(C-B)
  L[B]=0
  print(ans)

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans+=a
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  key=L[B]
  L[C]+=key
  ans+=key*(C-B)
  L[B]=0
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans=sum(A)
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  #Bの数だけ（C-B)足す、BはCに置き換わるのでLB＝０になおす。
  L[C]+=L[B]
  ans+=L[B]*(C-B)
  L[B]=0
  print(ans)

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans+=a
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  key=L[B]
  L[C]+=key
  ans+=key*(C-B)
  L[B]=0
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
for i in range(Q):
  b,c=map(int, input().split())
  A= [c if x==b else x for x in A]
  print(sum(A))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans+=a
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  key=L[B]
  L[C]+=key
  ans+=key*(C-B)
  L[B]=0
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
Q=int(input())
bc=[map(int, input().split()) for _ in range(Q)]
b,c=[list(i) for i in zip(*bc)]

for i in range(Q):
  A=[c[i] if x==b[i] else x for x in A]
  print(sum(A))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
L=[0]*(100001)
#何回その数字が出てきたかのリスト
ans=0
for a in A:
  L[a]+=1
  #aが出てきた数（2回出てきたら2になる）
  ans+=a
Q=int(input())
for i in range(Q):
  B,C=map(int, input().split())
  key=L[B]
  L[C]+=key
  ans+=key*(C-B)
  L[B]=0
  print(ans)
Buggy python submission (verdict: Runtime Error):
X,N=map(int,input().split())
n=list(map(int,input().split()))
if X<min(n) or X>max(n):
  print(X)
  exit()

key=min(n)-1
Key=max(n)+1
l=list(range(key,Key+1))
ll=[x for x in l if x not in n]
ll.append(X)
ll.sort()
i=ll.index(X)
if abs(X-ll[i-1])>abs(X-ll[i+1]):
  print(ll[i+1])
else:
  print(ll[i-1])

  

Fixed submission:
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
n=list(map(int,input().split()))
if X<min(n) or X>max(n):
  print(X)
  exit()

key=min(n)-1
Key=max(n)+1
l=list(range(key,Key+1))
ll=[x for x in l if x not in n]
ll.append(X)
ll.sort()
i=ll.index(X)
if abs(X-ll[i-1])>abs(X-ll[i+1]):
  print(ll[i+1])
else:
  print(ll[i-1])
Buggy python submission (verdict: Runtime Error):
T=list(input())
if T[0]=='?' and T[1]=='D':
  T[0]='P'
elif T[0]=='?' and T[1]=='?':
  T[0]='P'
elif T[0]=='?' and T[1]=='P':
  T[0]='D'
for i in range(1,len(T)-1):
  if T[i]=='?' and T[i+1]=='D'and T[i-1]=='P':
    T[i]='D'
  elif T[i]=='?' and T[i+1]=='D':
    T[i]='P'
  elif T[i]=='?' and T[i+1]=='P':
    T[i]='D'
  elif T[i]=='?' and T[i+1]=='?':
    T[i]='P'
if T[-1]=='?':
  T[-1]='D'
  
print(''.join(T))

Fixed submission:
T=list(input())
if len(T)==1:
  print('D')
  exit()
if T[0]=='?' and T[1]=='D':
  T[0]='P'
elif T[0]=='?' and T[1]=='?':
  T[0]='P'
elif T[0]=='?' and T[1]=='P':
  T[0]='D'
for i in range(1,len(T)-1):
  if T[i]=='?' and T[i-1]=='P':
    T[i]='D'
  elif T[i]=='?' and T[i+1]=='D':
    T[i]='P'
  elif T[i]=='?' and T[i+1]=='P':
    T[i]='D'
  elif T[i]=='?' and T[i+1]=='?':
    T[i]='P'
if T[-1]=='?':
  T[-1]='D'
  
print(''.join(T))
Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())
for A in range(X):
  for B in range(-X,X):
    if A*A*A*A*A-B*B*B*B*B==X:
      print(A,B)
      exit()

Fixed submission:
X=int(input())
for A in range(-120,120):
  for B in range(-120,120):
    if A**5-B**5==X:
      print(A,B)
      exit()

Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())
for A in range(-X,X):
  for B in range(-X,X):
    if A*A*A*A*A-B*B*B*B*B==X:
      print(A,B)
      exit()

Fixed submission:
X=int(input())
for A in range(-120,120):
  for B in range(-120,120):
    if A**5-B**5==X:
      print(A,B)
      exit()
Buggy python submission (verdict: Time Limit Exceeded):
import math
A,B,N=map(int,input().split())
l=list()

for x in range(N+1):
  a=math.floor((A*x)/B)
  b=math.floor(x/B)
  ans=a-A*b
  l.append(ans)
  
print(max(l))

Fixed submission:
import math
A,B,N=map(int,input().split())
if N<B-1:
  x=N
else:
  x=B-1
  
a=(A*x)/B
aa=math.floor(a)
print(aa)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
for i in range(N):
  print(A.count(i+1))

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
ans=list([0]*N)
for i in range(N-1):
  tmp=A[i]
  ans[tmp - 1]+=1
for i in range(N):
  print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
ans=N
while ans>=K:
  ans-=K
  
nk=abs(ans-K)
if nk<K and nk<N:
  print(nk)
else:
  print(ans)  


Fixed submission:
N,K=map(int,input().split())
ans=N%K
  
nk=abs(ans-K)
if nk<K and nk<N:
  print(nk)
else:
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
L=list()
ans=0
for n in A:
  L.append(n)
  if n==min(L):
    ans+=1
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
a=A[0]
ans=1
for n in range(1,N):
  if a>A[n]:
    ans+=1
    a=A[n]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.ceil(x)
  if X<=50000:
    for i in range(X,2*X):
      l.append(i)
  else:
    for i in range(X,100000):
      l.append(i)
    
for n in range(2,key+1):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Fixed submission:
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.floor(x)
  for i in range(X,(key+1)**2):
    l.append(i)
    
for n in range(2,key+1):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Buggy python submission (verdict: Runtime Error):
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.ceil(x)
  if X<=50000:
    for i in range(X,key**2):
      l.append(i)
  else:
    for i in range(X,key**2):
      l.append(i)
    
for n in range(2,key):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Fixed submission:
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.floor(x)
  for i in range(X,(key+1)**2):
    l.append(i)
    
for n in range(2,key+1):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Buggy python submission (verdict: Runtime Error):
X=int(input())
l=list()
if X<=50000:
  for i in range(X,2*X):
    l.append(i)
else:
  for i in range(X,100000):
    l.append(i)
    
for n in range(2,317):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])

Fixed submission:
import math
X=int(input())
if X==2:
  print('2')
  exit()
else:
  l=list()
  x=math.sqrt(X)
  key=math.floor(x)
  for i in range(X,(key+1)**2):
    l.append(i)
    
for n in range(2,key+1):
  for x in l:
    if x%n==0:
      l.remove(x)
print(l[0])
Buggy python submission (verdict: Time Limit Exceeded):
X=int(input())
N=X//100
for a in range(N+1):
  for b in range(N+1):
    for c in range(N+1):
      for d in range(N+1):
        for e in range(N+1):
          for f in range(N+1):
            if 100*a+101*b+102*c+103*d+104*e+105*f==X:
              print('1')
              exit()
print('0')

Fixed submission:
X=int(input())
N=X%100
if N%5==0:
  if N//5<=X//100:
    print('1')
  else:
    print('0')
else:
  if N//5+1<=X//100:
    print('1')
  else:
    print('0')
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
l=list()
for n in range(Q):
  A=int(input())
  l.append(A)
for n in range(N):
  key=l.count(n+1)
  ans=key+K-Q
  if ans<=0:
    print('No')
  else:
    print('Yes')

Fixed submission:
N,K,Q=map(int,input().split())
l=[K-Q]*N
for n in range(Q):
  A=int(input())
  l[A-1]+=1
for n in range(N):
  if l[n]<=0:
    print('No')
  else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for _ in range(N)]
ll=sorted(A)
  
for n in A:
  if n==max(A):
    print(ll[-2])
  else:
    print(max(A))

Fixed submission:
N=int(input())
A=[int(input()) for _ in range(N)]
ll=sorted(A)
a=max(A)
b=ll[-2]
  
for n in A:
  if n==a:
    print(b)
  else:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for _ in range(N)]
ll=sorted(A)
  
for n in range(N):
  if A[n]==max(A):
    print(ll[-2])
  else:
    print(max(A))

Fixed submission:
N=int(input())
A=[int(input()) for _ in range(N)]
ll=sorted(A)
a=max(A)
b=ll[-2]
  
for n in A:
  if n==a:
    print(b)
  else:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=[int(input()) for _ in range(N)]
ll=sorted(A,reverse=True)
  
for n in range(N):
  if A[n]==max(A):
    print(ll[1])
  else:
    print(max(A))

Fixed submission:
N=int(input())
A=[int(input()) for _ in range(N)]
ll=sorted(A)
a=max(A)
b=ll[-2]
  
for n in A:
  if n==a:
    print(b)
  else:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=list()
for n in range(N):
  A=int(input())
  l.append(A)
  ll=sorted(l,reverse=True)
  
for n in range(N):
  if l[n]==max(l):
    print(ll[1])
  else:
    print(max(l))

Fixed submission:
N=int(input())
A=[int(input()) for _ in range(N)]
ll=sorted(A)
a=max(A)
b=ll[-2]
  
for n in A:
  if n==a:
    print(b)
  else:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
l=list()
for n in range(N):
  A=int(input())
  l.append(A)
  
for n in range(N):
  if l[n]==max(l):
    ll=sorted(l,reverse=True)
    print(ll[1])
  else:
    print(max(l))

Fixed submission:
N=int(input())
A=[int(input()) for _ in range(N)]
ll=sorted(A)
a=max(A)
b=ll[-2]
  
for n in A:
  if n==a:
    print(b)
  else:
    print(a)
Buggy python submission (verdict: Runtime Error):
N=int(input())
L=list(map(int,input().split())
M=list[]
m=list[]
for i in range(N):
  for x in range(N):
    if L[x]<i:
      L[x].append(M)
    else:
      L[x].append(m)
  if len(M)=len(m):
    ans+=1

print(ans)

Fixed submission:
N=int(input())
L=list(map(int,input().split()))
l=sorted(L)
if N%2==0:
  n=int(N/2)
  a=l[n-1]
  b=l[n]
  if a==b:
    print('0')
  else:
    print(b-a)
    
else:
  print('0')
Buggy python submission (verdict: Runtime Error):
l=list()
L=list()
for i in range(5):
  n=int(input())
  if n%10==0:
    l.append(n)
  else:
    L.append(n)
    
LL=list()
for n in L:
  N=n%10
  LL.append(N)
key=min(LL)
LL.remove(key)

x=len(LL)*10

M=list()
for n in L:
  nn=n//10*10
  M.append(nn)
  
  
print(sum(l)+sum(M)+x+key)
  


Fixed submission:
l=list()
L=list()
for i in range(5):
  n=int(input())
  if n%10==0:
    l.append(n)
  else:
    L.append(n)
if len(l)==5:
  print(sum(l))
  exit()
    
LL=list()
for n in L:
  N=n%10
  LL.append(N)
key=min(LL)
LL.remove(key)

x=len(LL)*10

M=list()
for n in L:
  nn=n//10*10
  M.append(nn)
  
  
print(sum(l)+sum(M)+x+key)
Buggy python submission (verdict: Runtime Error):
S=input()
s=list(S)
T=input()
t=list(T)
for i in range(len(s)):
  s.insert(0,s[-1])
  print(s)
  s.pop(-1)
  
  print(s)
  if s==t:
    print('Yes')
    exit()
  
print('N

Fixed submission:
S=input()
s=list(S)
T=input()
t=list(T)
for i in range(len(s)):
  s.insert(0,s[-1])
  s.pop(-1)
  if s==t:
    print('Yes')
    exit()
  
print('No')
Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K=map(int,input().split())
if A==B==C:
  print('0')
  exit()
  
else:
  a=A
  b=B
  c=C
  for n in range(K):
    aa=b+c
    bb=a+c
    cc=a+b
    a=aa
    b=bb
    c=cc
    if a-b>10**18:
      print('Unfair')
      exit()
      
print(a-b)

Fixed submission:
A,B,C,K=map(int,input().split())
if A==B==C:
  print('0')
  exit()
  
else:
  if K%2==0:
    key=A-B
    if key>10**18:
      print('Unfair')
    else:
      print(key)
  else:
    key=B-A
    if key>10**18:
      print('Unfair')
    else:
      print(key)

Buggy python submission (verdict: Time Limit Exceeded):
A,B,C,K=map(int,input().split())
if A==B==C:
  print('0')
  exit()
  
else:
  a=A
  b=B
  c=C
  for n in range(K):
    aa=b+c
    bb=c+a
    cc=a+b
    a=aa
    b=bb
    c=cc

if a-b>10**18:
  print('Unfair')
else:
  print(a-b)

Fixed submission:
A,B,C,K=map(int,input().split())
if A==B==C:
  print('0')
  exit()
  
else:
  if K%2==0:
    key=A-B
    if key>10**18:
      print('Unfair')
    else:
      print(key)
  else:
    key=B-A
    if key>10**18:
      print('Unfair')
    else:
      print(key)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
key=1
for i in range(1,N+1):
  key*=i
print(key%1000000007)

Fixed submission:
N=int(input())
key=1
for i in range(1,N+1):
  key=(key*i)%1000000007
print(key)