Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
X,K,D = map(int, input().split())
Ans = 0

if abs(X) >= K * D:
  if X >= 0:
    Ans = X - (K * D)
  else:
    Ans = abs(X + (K * D))
    
else:
  abX = abs(X)
#  if X >= 0:
  if (K - abX // D) % 2 == 0:
      Ans = abX - ((abX // D) * D)
    else:
      Ans = abs(abX - ((abX // D) * D) - D)
      
#  else:
#    print(abs(X // D))
#    if (K - abs(X // D)) % 2 == 0:
#      Ans = abs(X + (abs((X // D)) * D))
#    else:
#      Ans = abs(X + (abs((X // D)) * D) - D)
    
print(Ans)


Fixed submission:
X,K,D = map(int, input().split())
Ans = 0

if abs(X) >= K * D:
  if X >= 0:
    Ans = X - (K * D)
  else:
    Ans = abs(X + (K * D))
    
else:
  abX = abs(X)
#  if X >= 0:
  if (K - abX // D) % 2 == 0:
    Ans = abX - ((abX // D) * D)
  else:
    Ans = abs(abX - ((abX // D) * D) - D)
      
#  else:
#    print(abs(X // D))
#    if (K - abs(X // D)) % 2 == 0:
#      Ans = abs(X + (abs((X // D)) * D))
#    else:
#      Ans = abs(X + (abs((X // D)) * D) - D)
    
print(Ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
A = list(map(int, input().split()))

Hyoten = [0] * (N-K+1)

for i in range(K,N+1):
  if i == K:
    Hyoten[i-K] = 1
    for j in range(i-K,i):
      Hyoten[i-K] *= A[j]
  else:
    s_val = A[i-K-1]
    Hyoten[i-K] = Hyoten[i-K-1] / s_val * A[i-1]
    
for i in range(0,N-K+1):
  if i == 0:
    pre_Hyoten = Hyoten[i]
  else:
    if pre_Hyoten < Hyoten[i]:
      print("Yes")
    else:
      print("No")
      
    pre_Hyoten = Hyoten[i]



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

for i in range(K+1,N+1):
  if A[i-K-1] < A[i-1]:
    print("Yes")
  else:
    print("No")

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

Hyoten = [0] * (N-K+1)

for i in range(K,N+1):
  Hyoten[i-K] = 1
  for j in range(i-K,i):
    Hyoten[i-K] *= A[j]

for i in range(0,N-K+1):
  if i == 0:
    pre_Hyoten = Hyoten[i]
  else:
    if pre_Hyoten < Hyoten[i]:
      print("Yes")
    else:
      print("No")
      
    pre_Hyoten = Hyoten[i]



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

for i in range(K+1,N+1):
  if A[i-K-1] < A[i-1]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N,M,K = map(int, input().split())
Nnums = list(map(int, input().split()))
Mnums = list(map(int, input().split()))

Nmax=len(Nnums)
Mmax=len(Mnums)
Nsum=0
Ncnt=0

#Nのみの場合に何冊読めるか
for Ni,Nl in enumerate(Nnums):
  Nsum += Nl
  Ncnt = Ni
  if Nsum > K:
    Nsum -= Nl
    Ncnt = Ni-1
    break
    
chkSum = Nsum
chkCnt = Ncnt + 1
AnsCnt = Ncnt + 1
  
#Mを組み入れて最大数を探す
for Mi,Ml in enumerate(Mnums):
  chkSum += Ml
  chkCnt += 1
  if (chkSum > K):
    if 
    while chkSum > K:
      if not Ncnt < 0:
        chkSum -= Nnums[Ncnt]
        chkCnt -= 1
        Ncnt -= 1
      elif:
        break
  
  if (AnsCnt < chkCnt):
    AnsCnt = chkCnt
  
  if (Ncnt < 0):
    break

print(AnsCnt)


Fixed submission:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N,M,K = map(int, input().split())
Nnums = list(map(int, input().split()))
Mnums = list(map(int, input().split()))

Nmax=len(Nnums)
Mmax=len(Mnums)
Nsum=0
Ncnt=0

#Nのみの場合に何冊読めるか
for Ni,Nl in enumerate(Nnums):
  Nsum += Nl
  Ncnt = Ni
  if Nsum > K:
    Nsum -= Nl
    Ncnt = Ni-1
    break
    
chkSum = Nsum
chkCnt = Ncnt + 1
AnsCnt = Ncnt + 1

#Mを組み入れて最大数を探す
for Mi,Ml in enumerate(Mnums):
  chkSum += Ml
  chkCnt += 1
  if (chkSum > K):
    flg = 0
    while chkSum > K:
      if Ncnt >= 0:
        chkSum -= Nnums[Ncnt]
        chkCnt -= 1
        Ncnt -= 1
        flg = 1
      else:
        if flg == 0:
          #chkSum -= Ml
          chkCnt -= 1
          #AnsCnt -= 1
        break
  
  if (AnsCnt < chkCnt):
    AnsCnt = chkCnt
  

  
#  if (Ncnt < 0):
  if (chkSum > K):
    break
    
print(AnsCnt)
Buggy python submission (verdict: Runtime Error):
X,Y,Z=map(int,input())
print(str(Z)+' '+str(X)+' '+str(Y))

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

print(str(Z)+' '+str(X)+' '+str(Y))
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))

A.sort(reverse=True)
if A[M]>=sum(A)/(4*M):
  print('Yes')
else:
  print('No')


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

A.sort(reverse=True)
if A[M-1]>=sum(A)/(4*M):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
#-----------------------------------
#リストera_list[n]を返す
#0～ｎの各インデックスが素数であれば1、そうでなければ0
#ex：eratosthenes(10)
#　　→ [0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0]
#-----------------------------------

def eratosthenes(n):
  era_list = [1] * (n + 1)
  era_list[0] = 0; era_list[1] = 0
  
  for i in range(2,n+1):
    if era_list[i] == 0:
      continue
    else:
      j = i + i
      while j <= n:
        era_list[j] = 0
        j += i
        
  return era_list

Q = int(input())
PN = eratosthenes(100001)
TF = [0] * 100001

for i in range(1,100001,2):
  if PN[i] == 1 and PN[int((i+1)/2)] == 1:
    TF[i] = 1
    
for j in range(1,Q+1):
  l,r = map(int, input().split())
  Ans = sum(TF[:r+1]) - sum(TF[:l])
  print(Ans)

Fixed submission:
#-----------------------------------
#リストera_list[n]を返す
#0～ｎの各インデックスが素数であれば1、そうでなければ0
#ex：eratosthenes(10)
#　　→ [0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0]
#-----------------------------------

def eratosthenes(n):
  era_list = [1] * (n + 1)
  era_list[0] = 0; era_list[1] = 0
  
  for i in range(2,n+1):
    if era_list[i] == 0:
      continue
    else:
      j = i + i
      while j <= n:
        era_list[j] = 0
        j += i
        
  return era_list

Q = int(input())
PN = eratosthenes(100001)
TF = [0] * 100001

for i in range(1,100001,2):
  if PN[i] == 1 and PN[int((i+1)/2)] == 1:
    TF[i] = 1 + TF[i-2]
  else:
    TF[i] = TF[i-2]
    
for j in range(1,Q+1):
  l,r = map(int, input().split())
  Ans = TF[r] - TF[l-2]
  print(Ans)
Buggy python submission (verdict: Runtime Error):
S= input()

if S.count('RRR') == 1:
    print(3)
elif S.count('RR') == 1:
    print(2)
elif S.count('RSR') == 1 or S.count('RSS') == 1 or S.count('SRS') == 1 or S.count('SSR') == 1
    print(1)
else:
    print(0)


Fixed submission:
S= input()

if S.count('RRR') == 1:
    print(3)
elif S.count('RR') == 1:
    print(2)
elif S.count('RSR') == 1 or S.count('RSS') == 1 or S.count('SRS') == 1 or S.count('SSR') == 1:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
P = list(map(int,input().split()))

result = 0
if N == 0:
    result = X
else:
    list = [i for i in range(101)]
    for i in P:
        list.remove(i)
    for i in range(len(list)):
        list[i] = abs(list[i] - X)
    list.sort()
    if list[0] == list[1]:
        result = X - list[0]
    else:
        result = X + list[0]
print(result)

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

result = 0
if N == 0:
    result = X
else:
    list = [i for i in range(201)]
    for i in P:
        list.remove(i)
    if len(list) == 0:
        result = 0
    else:
        min = 100
        for i in list:
            if min > abs(X-i):
                min = abs(X - i)
                result = i
print(result)

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

result = 0
if N == 0:
    result = X
else:
    list = [i for i in range(-100,100)]
    for i in P:
        list.remove(i)
    min = 100
    for i in list:
        if min > abs(X-i):
            min = abs(X - i)
            result = i

print(result)

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

result = 0
if N == 0:
    result = X
else:
    list = [i for i in range(201)]
    for i in P:
        list.remove(i)
    if len(list) == 0:
        result = 0
    else:
        min = 100
        for i in list:
            if min > abs(X-i):
                min = abs(X - i)
                result = i
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
# Nの入力
N = int(input())

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

result = 1
if 0 in A:
    result = 0
else:
    for i in A:
        result *= i
        if result > 10 ** 18:
            result = -1
print(result) 
    

Fixed submission:
# Nの入力
N = int(input())

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

result = 1
if 0 in A:
    result = 0
else:
    for i in A:
        result *= i
        if result > 10 ** 18:
            result = -1
            break
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
# Nの入力
N = int(input())

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

result = 1
for i in A:
    result *= i

if result > 10 ** 18:
    result = -1
        

print(result) 
    

Fixed submission:
# Nの入力
N = int(input())

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

result = 1
if 0 in A:
    result = 0
else:
    for i in A:
        result *= i
        if result > 10 ** 18:
            result = -1
            break
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N,M =map(int,input().split())
H = list(map(int,input().split()))
ab = [map(int, input().split()) for _ in range(M)]
a, b = map(list, zip(*ab))

cnt = 0

for i in range(1,N+1):
  Boolean = True
  # aの中からiから続く道があるかを全件検索
  for j in range(len(a)):
    # aの中にiがあり、その道先の展望台の山が高かったらiは破棄して次へ
    if ((i == a[j] and H[i-1] <= H[b[j]-1]) or (i == b[j] and H[i-1] <= H[a[j]-1])):
      Boolean = False
      break

  # abを全件調査してセーフだった場合にcntをあげる
  if(Boolean):
    cnt += 1
print(cnt)

Fixed submission:
N,M =map(int,input().split())
H = list(map(int,input().split()))
ab = [map(int, input().split()) for _ in range(M)]
a, b = map(list, zip(*ab))

cnt = 0
removeList = []

for i in range(len(a)):
  if (H[a[i]-1] > H[b[i]-1]):
    removeList.append(b[i])
  elif (H[a[i]-1] < H[b[i]-1]):
    removeList.append(a[i])
  else:
    removeList.append(a[i])
    removeList.append(b[i])

set(removeList)
print(N - len(set(removeList)))

Buggy python submission (verdict: Runtime Error):
N,M =map(int,input().split())
H = list(map(int,input().split()))
ab = [map(int, input().split()) for _ in range(M)]
a, b = map(list, zip(*ab))

cnt = 0

for i in range(N):
  Boolean = True
  # aの中からiへ続く道があるかを全件検索
  for j,k in enumerate(a):
    # aの中にiがあり、その道先の展望台の山が高かったらiは破棄して次へ
    if (i == k and H[i] <= H[b[j] - 1]):
      Boolean = False
      break

  for j,k in enumerate(b):
    # bの中にiがあり、その道先の展望台の山が高かったらiは破棄して次へ
    if (i == k and H[i] <= H[a[j]]):
      Boolean = False
      break
  # abを全件調査してセーフだった場合にcntをあげる
  if(Boolean):
    cnt += 1
print(cnt)

Fixed submission:
N,M =map(int,input().split())
H = list(map(int,input().split()))
ab = [map(int, input().split()) for _ in range(M)]
a, b = map(list, zip(*ab))

cnt = 0
removeList = []

for i in range(len(a)):
  if (H[a[i]-1] > H[b[i]-1]):
    removeList.append(b[i])
  elif (H[a[i]-1] < H[b[i]-1]):
    removeList.append(a[i])
  else:
    removeList.append(a[i])
    removeList.append(b[i])

set(removeList)
print(N - len(set(removeList)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
  for j in range(i+1,N,1):
    ans += A[i]*A[j]
print(ans%(10**9+7))

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
tmp = sum(A[1:])
ans = 0
for i in range(N-1):
  ans += A[i]*tmp
  tmp -=A[i+1]
print(ans%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K+1,N+1):
#  print(A[i-K-1:i-1],A[i-K:i])
  if sum(A[i-K-1:i-1]) < sum(A[i-K:i]):
    print("Yes")
  else:
    print("No")

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
prev = sum(A[0:K])
for i in range(K+1,N+1):
  curr = prev - A[i-K-1] + A[i-1]
  if prev < curr:
    print("Yes")
  else:
    print("No")
  prev = curr
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for n in range(1,N+1,1):
  flag = False
  count=0
  for x in range(1,10**2+1,1):
    for y in range(1,n//x,1):
      for z in range(1,n-x**2-y**2,1):
        if n == x**2+y**2+z**2+x*y+y*z+z*x:
          count+=1
        if n<x**2+y**2+z**2+x*y+y*z+z*x:
          flag = True
          continue
      if flag:
        continue
    if flag:
      continue
  print(count)

Fixed submission:
N = int(input())

ans = [0]*N

for i in range(1,101,1):
  for j in range(1,101,1):
    for k in range(1,101,1):
      n = i**2+j**2+k**2+i*j+j*k+k*i
      if n > N:
        continue
      ans[n-1]+=1
      
for i in range(N):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
x, y = map(int,input().split())
flag=False
for i in range(x+1):
  yi=2*i+4(x-i)
  if y==yi:
    flag=True
    break
    
print("Yes") if flag else print("No")

Fixed submission:
x, y = map(int,input().split())
flag=False
for i in range(x+1):
  yi=2*i+4*(x-i)
  if y==yi:
    flag=True
    break
    
print("Yes") if flag else print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
if N == 0:
  ans = 0
else:
  for i in range(len(A)-1,-1,-1):
    for j in range(0,i+1,1):
      if i==j:
        ans+=1
        if i==0 and A[0]==A[1]:
          ans-=1
        break
      if A[i]%A[j]==0:
        break
      if A[i]<A[j]*2:
        ans+=1
        break

print(ans)


Fixed submission:
X, N = map(int, input().split())
if N!=0:
  p = list(map(int, input().split()))
else:
  p =[]

p = set(p)
i=0
while i<101:
  n = X-i
  if not(n in p):
    ans = n
    break
  n = X+i
  if not(n in p):
    ans = n
    break
  i+=1

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 0
A = sorted(A)
if N == 0:
  ans = 0
else:
  for i in range(len(A)-1,-1,-1):
    for j in range(0,i+1,1):
      if i==j:
        ans+=1
        if i==0 and A[0]==A[1]:
          ans-=1
        break
      if A[i]%A[j]==0:
        break
      if A[i]<A[j]*2:
        ans+=1
        break

print(ans)

Fixed submission:
X, N = map(int, input().split())
if N!=0:
  p = list(map(int, input().split()))
else:
  p =[]

p = set(p)
i=0
while i<101:
  n = X-i
  if not(n in p):
    ans = n
    break
  n = X+i
  if not(n in p):
    ans = n
    break
  i+=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int, input().split()))
ans=1
flag=True
for i in range(len(A)):
  ans*=A[i]

if ans>10**18:
  flag=False
    
print(ans) if flag else print(-1)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
A.sort()
ans=1
for i in range(N):
  ans=ans*A[i]
  if ans==0 or ans>10**18:
    break
    
    
if ans>10**18:
  print(-1)
else:
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()

for i in range(len(S)):
  if S[i]=="?":
    S= S[:i]+"D"+S[i+1:]
    
print(S)

Fixed submission:
S=input()

S=S.replace("?","D")    
print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

c = [0]*N
ans = 0
for i in range(N):
  c[i] = A.count(i+1)
  if c[i]>1:
    ans+=c[i]*(c[i]-1)//2

for i in range(N):
  print(ans-(c[A[i]-1]-1)) if c[A[i]-1]>1 else print(ans)

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

c = collections.Counter(A)
ans = 0
for i in c:
  ans+=c[i]*(c[i]-1)//2

for i in range(N):
  print(ans-(c[A[i]]-1))

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

c = [0]*N
ans = 0
for i in range(N):
  c[i] = A.count(i+1)
  if c[i]>1:
    ans+=c[i]*(c[i]-1)//2

for i in range(N):
  print(ans-c[A[i]-1]*(c[A[i]-1]-1)//2+(c[A[i]-1]-1)*(c[A[i]-1]-2)//2) if c[A[i]-1]>1 else print(ans)

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

c = collections.Counter(A)
ans = 0
for i in c:
  ans+=c[i]*(c[i]-1)//2

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

i = 0
while i<N:
  b = int(input())
  j=0
  while j<3:
    k=0
    while k<3:
      if A[j][k]==b:
        A[j][k]=0
      k+=1
    j+=1
  i+=1

flag = False
i = 0
while i<3:
  if A[i][0]+A[i][1]+A[i][2] == 0:
    flag = True
    break
  if A[0][i]+A[1][i]+A[2][i] == 0:
    flag = True
    break
  i += 1

if A[0][0]+A[1][1]+A[2][2] == 0:
  flag = Trueå
if A[2][0]+A[1][1]+A[0][2] == 0:
  flag = True

if flag == True:
  print("Yes")
else:
    print("No")
    


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

i = 0
while i<N:
  b = int(input())
  j=0
  while j<3:
    k=0
    while k<3:
      if A[j][k]==b:
        A[j][k]=0
      k+=1
    j+=1
  i+=1

flag = False
i = 0
while i<3:
  if A[i][0]+A[i][1]+A[i][2] == 0:
    flag = True
    break
  if A[0][i]+A[1][i]+A[2][i] == 0:
    flag = True
    break
  i += 1

if A[0][0]+A[1][1]+A[2][2] == 0:
  flag = True
if A[2][0]+A[1][1]+A[0][2] == 0:
  flag = True

if flag == True:
  print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [0]*N
for i in range(M):
  s, c = map(int, input().split())
  if A[s-1] == 0:
    A[s-1] = c
  elif A[s-1] != c:
    print(-1)
    exit()

if A[0]>0:
  ans = A[0]*100+A[1]*10+A[2]
else:
  ans = -1
  
print(ans)

Fixed submission:
N, M = map(int, input().split())
A = ["x"]*N
for i in range(M):
  s, c = map(int, input().split())
  if A[s-1] == "x":
    A[s-1] = c
  elif A[s-1] != c:
    print(-1)
    exit()


if A[0]==0 and N>1:
  print(-1)
  exit()
elif N==1 and (A[0]=="x" or A[0] == 0):
  print(0)
  exit()
elif A[0]=="x" or A[0] == 0:
  A[0]=1

for i in range(1,N):
  if A[i]=="x":
    A[i]=0

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

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
Ad = {}
ans = [0]*N
i=0
for i in range(len(A)):
  Ad[i] = A[i]

i=0
for k, v in sorted(Ad.items(), key=lambda x: x[1]):
  ans[i] = k+1
  i+=1

print(*ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

  M = max(A)
for i in range(N):
  if M == A[i]:
    ans = max(max(A[0:i]),max(A[i+1:N]))
    print(ans)
  else:
    print(M)


Fixed submission:
N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

As = sorted(A, reverse=True)
M = As[0]
Ms = As[1]

for i in range(N):
  if M == A[i]:
    print(Ms)
  else:
    print(M)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

  M = max(A)
for i in range(N):
  if M == A[i]:
    Atmp = A[0:i]
    Atmp.extend(A[i+1:N])
    ans = max(Atmp)
    print(ans)
  else:
    print(M)


Fixed submission:
N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

As = sorted(A, reverse=True)
M = As[0]
Ms = As[1]

for i in range(N):
  if M == A[i]:
    print(Ms)
  else:
    print(M)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

for i in range(N):
  Atmp = A[0:i]
  Atmp.extend(A[i+1:N])
  ans = max(Atmp)
  print(ans)


Fixed submission:
N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

As = sorted(A, reverse=True)
M = As[0]
Ms = As[1]

for i in range(N):
  if M == A[i]:
    print(Ms)
  else:
    print(M)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

for i in range(N):
  ans = max(A[0:i].extend(A[i+1:N]))
  print(ans)


Fixed submission:
N = int(input())
A = [0]*N

for i in range(N):
  A[i] = int(input())

As = sorted(A, reverse=True)
M = As[0]
Ms = As[1]

for i in range(N):
  if M == A[i]:
    print(Ms)
  else:
    print(M)
Buggy python submission (verdict: Runtime Error):
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans=0
for i in range(N)
  x = x-a[i]
  if x>=0:
    ans+=1
  else:
    break
print(ans)

Fixed submission:
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans=0
for i in range(N):
  x = x-a[i]
  if x>=0:
    ans+=1
  else:
    break
if x>0:
  print(ans-1)
else:
  print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
S = S.replace("1","")
print(S[0])

Fixed submission:
S = input()
K = int(input())

if len(S)>=K and S[:K] == "1"*K:
  print("1")
else:
  S = S.replace("1","")
  print(S[0])
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C, K = map(int, input().split())

if A==B and B==C:
  ans = 0
else:
  for i in range(K):
    A, B, C = B+C, A+C, A+B
    if abs(A-B)>10**18:
      break
  ans = A-B
  
if abs(ans)>10**18:
  print("Unfair")
else:
  print(ans)

Fixed submission:
A, B, C, K = map(int, input().split())

if K%2==1:
  print(-A+B)
else:
  print(A-B)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K= map(int, input().split())

for i in range(A,B+1,1):
  if i<A+K or i>B-K:
    print(i)

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

for i in range(A,min([A+K+1,B+1]),1):
  if i<A+K:
    print(i)
    
for i in range(max([A+K, B-K-1]),B+1,1):
  if i>B-K:
    print(i)

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

ab = set(list(range(A,B+1,1)))
a = set(list(range(A,A+K,1)))&ab
b = set(list(range(B-K+1,B+1,1)))&ab
ans=list(a|b)
ans = sorted(ans)

if len(ansi)>0:
  for ansi in ans:
    print(ansi)


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

for i in range(A,min([A+K+1,B+1]),1):
  if i<A+K:
    print(i)
    
for i in range(max([A+K, B-K-1]),B+1,1):
  if i>B-K:
    print(i)

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

ab = set(list(range(A,B+1,1)))
a = set(list(range(A,A+K,1)))&ab
b = set(list(range(B-K+1,B+1,1)))&ab
ans=list(a|b)
ans = sorted(ans)

for ansi in ans:
  print(ansi)


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

for i in range(A,min([A+K+1,B+1]),1):
  if i<A+K:
    print(i)
    
for i in range(max([A+K, B-K-1]),B+1,1):
  if i>B-K:
    print(i)

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

ab = set(list(range(A,B+1,1)))
a = list(range(A,A+K,1))
b = list(range(B-K+1,B+1,1))
a.extend(b)
ans=a
ans = set(ans)
ans = list(ans&ab)
ans = sorted(ans)

for ansi in ans:
  print(ansi)


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

for i in range(A,min([A+K+1,B+1]),1):
  if i<A+K:
    print(i)
    
for i in range(max([A+K, B-K-1]),B+1,1):
  if i>B-K:
    print(i)
Buggy python submission (verdict: Runtime Error):
s = input()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])

flag = [0]*3
tmp = 0
for i in range(8):
  flag[0]=(i>>2)&1
  flag[1]=(i>>1)&1
  flag[2]=(i)&1
  
  tmp = A +(-1)**flag[0]*B +(-1)**flag[0]*C +(-1)**flag[0]*D
  if tmp==7:
    ans=s[0]
    for j in range(3):
      if flag[i]:
        ans+="-"+s[i+1]
      else:
        ans+="+"+s[i+1]
    ans+="=7"
    print(ans)
    break

Fixed submission:
s = input()
A = int(s[0])
B = int(s[1])
C = int(s[2])
D = int(s[3])

flag = [0]*3
tmp = 0
for i in range(8):
  flag[0]=(i>>2)&1
  flag[1]=(i>>1)&1
  flag[2]=(i)&1
  
  tmp = A +(-1)**flag[0]*B +(-1)**flag[1]*C +(-1)**flag[2]*D
  if tmp==7:
    ans=s[0]
    for j in range(3):
      if flag[j]:
        ans+="-"+s[j+1]
      else:
        ans+="+"+s[j+1]
    ans+="=7"
    print(ans)
    break
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int, input().split()))
c2=c4=0

for i in range(len(N)):
  if a[i]%4==0:
    c4+=1
  if a[i]%2==0:
    c2+=1

nodd=N-c2
c4=c4-c2

if nodd<c4:
  print("Yes")
else:
  print("No")

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
c2=c4=0

for i in range(N):
  if a[i]%4==0:
    c4+=1
  if a[i]%2==0:
    c2+=1

nodd=N-c2
c2=c2-c4
if c2>0:
  nodd+=1
if c4>=nodd-1:
  print("Yes")
else:
  print("No")