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

for i in range(1, n+1):
    print(str(a.index(i)+1)+" ", end = "")

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

b = [0 for _ in range(n)]
for i in range(n):
    b[ a[i] - 1] = i+1
for i in range(n):
    print(str(b[i]) + " ", end = "")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

for i in range(n):
    pnt = a.count(i+1) - q + k
    if pnt > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
t = k - q
a = [0 for _ in range(n)]

for i in range(q):
    a[int(input())-1] += 1

for i in range(n):
    pnt = a[i] + t
    if pnt > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

for i in range(n):
    pnt = a.count(i+1) - q + k
    if pnt > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
t = k - q
a = [0 for _ in range(n)]

for i in range(q):
    a[int(input())-1] += 1

for i in range(n):
    pnt = a[i] + t
    if pnt > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

pnt = [q*(-1)+k for _ in range(n)]
for i in range(n):
    pnt[i] += a.count(i+1)
    if pnt[i] > 0:
        print("Yes")
    else:
        print("No")

Fixed submission:
import sys
input = sys.stdin.readline

n, k, q = map(int, input().split())
t = k - q
a = [0 for _ in range(n)]

for i in range(q):
    a[int(input())-1] += 1

for i in range(n):
    pnt = a[i] + t
    if pnt > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 0
if n%2 = 0:
    ans = (n//2)*(n-1)
else:
    ans = ((n-1)//2)*n
print(ans)

Fixed submission:
n = int(input())

ans = 0
if n%2 == 0:
    ans = (n//2)*(n-1)
else:
    ans = ((n-1)//2)*n
print(ans)

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

if n%2 = 0:
    ans = (n//2)*(n-1)
else:
    ans = ((n-1)//2)*n
print(ans)

Fixed submission:
n = int(input())

ans = 0
if n%2 == 0:
    ans = (n//2)*(n-1)
else:
    ans = ((n-1)//2)*n
print(ans)
Buggy python submission (verdict: Runtime Error):
num = int(input())
dic = [input() for i in range(num)]

sdic = []
ans = 0
for i in range(num):
    dic[i] = "".join(sorted(dic[i]))
for i in range(num):
    now = dic[0]
    cnt = dic.count(now)
    ans += int((cnt * (cnt - 1)) / 2)
    for now in dic:
        dic.remove(now)
print(ans)

Fixed submission:
num = int(input())
li = [input() for i in range(num)]

dic = {}
ans = 0
for i in range(num):
    now = "".join(sorted(li[i]))
    if now in dic:
        dic[now] += 1
    else:
        dic[now] = 1
for i in dic:
    n = dic[i]
    ans += int((n*(n-1))/2)

print(ans)

Buggy python submission (verdict: Runtime Error):
num = int(input())
dic = [input() for i in range(num)]

sdic = []
ans = 0
for i in range(num):
    dic[i] = "".join(sorted(dic[i]))
for i in range(num)
    now = dic[0]
    cnt = dic.count(now)
    ans += int((cnt * (cnt - 1)) / 2)
    for i in range(cnt):
        dic.remove(now)
    i += cnt - 1
print(ans)

Fixed submission:
num = int(input())
li = [input() for i in range(num)]

dic = {}
ans = 0
for i in range(num):
    now = "".join(sorted(li[i]))
    if now in dic:
        dic[now] += 1
    else:
        dic[now] = 1
for i in dic:
    n = dic[i]
    ans += int((n*(n-1))/2)

print(ans)

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

sdic = []
ans = 0
for i in range(num):
    dic[i] = "".join(sorted(dic[i]))
while len(dic) > 0:
    now = dic[0]
    cnt = dic.count(now)
    ans += int((cnt * (cnt - 1)) / 2)
    for i in range(cnt):
        dic.remove(now)
print(ans)

Fixed submission:
num = int(input())
li = [input() for i in range(num)]

dic = {}
ans = 0
for i in range(num):
    now = "".join(sorted(li[i]))
    if now in dic:
        dic[now] += 1
    else:
        dic[now] = 1
for i in dic:
    n = dic[i]
    ans += int((n*(n-1))/2)

print(ans)

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

sdic = []
ans = 0
for i in range(num):
    sdic.append("".join(sorted(dic[i])))
while len(sdic) > 0:
    now = sdic[0]
    cnt = sdic.count(now)
    ans += int((cnt * (cnt - 1)) / 2)
    for i in range(cnt):
        sdic.remove(now)
print(ans)

Fixed submission:
num = int(input())
li = [input() for i in range(num)]

dic = {}
ans = 0
for i in range(num):
    now = "".join(sorted(li[i]))
    if now in dic:
        dic[now] += 1
    else:
        dic[now] = 1
for i in dic:
    n = dic[i]
    ans += int((n*(n-1))/2)

print(ans)

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

sdic = []
ans = 0
for i in range(num):
    sdic.append("".join(sorted(dic[i])))
for i in range(num):
    ans += (sdic.count(sdic[0]) - 1)
    sdic.pop(0)
print(ans)

Fixed submission:
num = int(input())
li = [input() for i in range(num)]

dic = {}
ans = 0
for i in range(num):
    now = "".join(sorted(li[i]))
    if now in dic:
        dic[now] += 1
    else:
        dic[now] = 1
for i in dic:
    n = dic[i]
    ans += int((n*(n-1))/2)

print(ans)
Buggy python submission (verdict: Runtime Error):
cell_num = int(input())
height = list(map(int, input().split()))
flag = True

if cell_num != 1:
    for i in range(cell_num):
        if height[i+1] - height[i] == 1: height[i+1] -= 1
        elif height[i+1] - height[i] > 1:
            flag = False
            break

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

Fixed submission:
cell_num = int(input())
height = list(map(int, input().split()))
flag = True

if cell_num != 1:
    if height[0] - height[1] <= 1:
        height[0] -= 1
    elif height[0] - height[1] > 1:
        flag = False
    
    for i in range(1,cell_num-1):
        if height[i] - height[i+1] > 1:
            flag = False
            break
        elif height[i] -  height[i+1] <= 1 and height[i-1] < height[i]:
            height[i] -= 1
        elif height[i] -  height[i+1] == 1 and height[i-1] == height[i]:
            flag = False
            break
            
if flag: print("Yes")
else: print("No")

Buggy python submission (verdict: Runtime Error):
cell_num = int(input())
height = list(map(int, input().split()))
flag = True

for i in range(cell_num):
    if height[i+1] - height[i] == 1: height[i+1] -= 1
    elif height[i+1] - height[i] > 1:
        flag = False
        break

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

Fixed submission:
cell_num = int(input())
height = list(map(int, input().split()))
flag = True

if cell_num != 1:
    if height[0] - height[1] <= 1:
        height[0] -= 1
    elif height[0] - height[1] > 1:
        flag = False
    
    for i in range(1,cell_num-1):
        if height[i] - height[i+1] > 1:
            flag = False
            break
        elif height[i] -  height[i+1] <= 1 and height[i-1] < height[i]:
            height[i] -= 1
        elif height[i] -  height[i+1] == 1 and height[i-1] == height[i]:
            flag = False
            break
            
if flag: print("Yes")
else: print("No")
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
mem = list(map(int, input().split()))

mod = 10 ** 9 + 7
flag = True
while 0 in mem:
    mem.remove(0)
for i in mem:
    if not mem.count(i) == 2:
        flag = False
        break
if flag:
    print(int((2 ** (int(len(mem)) / 2) % mod)))
else:
    print(0)

Fixed submission:
num = int(input())
mem = list(map(int, input().split()))

dic = {}
mod = 10 ** 9 + 7
zeros = 0
flag = True
for i in range(num):
    temp = mem[i]
    if not temp == 0:
        dic.setdefault(str(temp), 0)
        dic[str(temp)] += 1
    else:
        zeros += 1
for key in dic:
    if not dic[key] == 2:
        flag = False
        break
        
if (zeros == 0 or zeros == 1) and flag:
    print(int((2 ** (len(mem) // 2) % mod)))
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
num = int(input())
arr = [list(map(int, input().split())) for i in range(num)]

ans = [[arr[0][0], arr[0][1]]]
for i in range(num-1):
    ans.append([arr[i+1][0], arr[i+1][1]])
    while ans[i][0] > ans[i+1][0] or ans[i][1] > ans[i+1][1]:
        ans[i+1][0] += arr[i+1][0]
        ans[i+1][1] += arr[i+1][1]
print(ans[num-1][0] + ans[num-1][1])

Fixed submission:
def divceil(a, b):
    if a%b == 0:
        return a//b
    else:
        return a//b + 1

num = int(input())
arr = [list(map(int, input().split())) for i in range(num)]
 
t = 1
a = 1
r = 0
for i in range(num):
    r = max(divceil(t, arr[i][0]), divceil(a, arr[i][1]))
    t = arr[i][0] * max(r, 1)
    a = arr[i][1] * max(r, 1)
print(t + a)

Buggy python submission (verdict: Runtime Error):
num = int(input())
arr = [list(map(int, input().split())) for i in range(num)]

ans = [[arr[0][0], arr[0][1]]
for i in range(num-1):
    ans.append([arr[i+1][0], arr[i+1][1]])
    while ans[i][0] > ans[i+1][0] or ans[i][1] > ans[i+1][1]:
        ans[i+1][0] += arr[i+1][0]
        ans[i+1][1] += arr[i+1][1]
print(ans[num-1][0] + ans[num-1][1])

Fixed submission:
def divceil(a, b):
    if a%b == 0:
        return a//b
    else:
        return a//b + 1

num = int(input())
arr = [list(map(int, input().split())) for i in range(num)]
 
t = 1
a = 1
r = 0
for i in range(num):
    r = max(divceil(t, arr[i][0]), divceil(a, arr[i][1]))
    t = arr[i][0] * max(r, 1)
    a = arr[i][1] * max(r, 1)
print(t + a)
Buggy python submission (verdict: Runtime Error):
tcd = input()

def dp(i, cnt, g, p):
    if g == p:
        if tcd[i] == "p":
            cnt -= 1
        g += 1

    else:
        if tcd[i] == "g":
            cnt += 1
        p += 1
    if i == len(tcd)-1:
        return cnt
    else:
        return dp(i+1, cnt, g, p)

print(dp(1, 0, 1, 0))

Fixed submission:
tcd = input()

cnt = 0
for i in range(len(tcd)):
    if i%2 == 0:
        if tcd[i] == "p":
            cnt -= 1
    else:
        if tcd[i] == "g":
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
#coding:utf-8

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

lis = []
for i in range(1,100):
    lis.append((100**D)*i)

print(lis[N-1])


Fixed submission:
#coding:utf-8

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

lis = []
for i in range(1,101):
    if i == 100:
        lis.append(101*(100**D))
    else:
        lis.append((100**D)*i)

print(lis[N-1])
Buggy python submission (verdict: Runtime Error):
import math
inputs = [int(s) for s in input().split()]
a = inputs[0]
b = inputs[1]
c = inputs[2]
d = inputs[3]
count = 0
minCD = min(c, d)
maxCD = max(c, d)

x0 = b-a+1
x1 = b//minCD - (a-1)//minCD
x2 = b//maxCD - (a-1)//maxCD
lcm = minCD * maxCD // math.gcd(minCD, maxCD)
x3 = b//lcm - (a-1)//lcm
print(x0, x1, x2, x3)
if maxCD % minCD == 0:
    print(x0-x1)
else:
    print(x0-(x1+x2-x3))


Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
inputs = [int(s) for s in input().split()]
a = inputs[0]
b = inputs[1]
c = inputs[2]
d = inputs[3]
count = 0
minCD = min(c, d)
maxCD = max(c, d)

x0 = b-a+1
x1 = b//minCD - (a-1)//minCD
x2 = b//maxCD - (a-1)//maxCD
lcm = minCD * maxCD // gcd(minCD, maxCD)
x3 = b//lcm - (a-1)//lcm
if maxCD % minCD == 0:
    print(x0-x1)
else:
    print(x0-(x1+x2-x3))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
for x in range(N):
    if x == 0:
        ans = S.count(".")
        continue
    count = S[:x].count("#") + S[x:].count(".")
    if count < ans:
        ans = count
count = S.count("#")
if count < ans:
    ans = count
print(ans)

Fixed submission:
N = int(input())
S = input()
LB = 0
RW = S.count(".")
ans = LB +RW
for x in range(N):
    if S[x] == "#":
        LB += 1
    else:
        RW -= 1
    count = LB +RW
    if count < ans:
        ans = count
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = S.count(".")
for x in range(N):
    count = S.count("#",0,x) + S.count(".",x+1,N)
    if count < ans:
        ans = count
count = S.count("#")
if count < ans:
    ans = count
print(ans)

Fixed submission:
N = int(input())
S = input()
LB = 0
RW = S.count(".")
ans = LB +RW
for x in range(N):
    if S[x] == "#":
        LB += 1
    else:
        RW -= 1
    count = LB +RW
    if count < ans:
        ans = count
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import math

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

print(len(factorization(math.gcd(A,B)))+1)

Fixed submission:
# -*- coding:utf-8 -*-
import fractions

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if fractions.gcd(A,B) == 1:
    print(1)
else:
    print(len(factorization(fractions.gcd(A,B)))+1)

Buggy python submission (verdict: Runtime Error):
# -*- coding:utf-8 -*-
import math

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

print(len(factorization(math.gcd(A,B)))+1)

Fixed submission:
# -*- coding:utf-8 -*-
import fractions

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

if fractions.gcd(A,B) == 1:
    print(1)
else:
    print(len(factorization(fractions.gcd(A,B)))+1)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
N,K,Q = map(int,input().split())
A_list = []
point_list = []

for i in range(Q):
    A_list.append(int(input()))

for i in range(N):
     if (K - (Q - A_list.count(i+1))) > 0 :
        print("Yes")
     else:
        print("No")
       

Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np
N,K,Q = map(int,input().split())
point_list = [K-Q]*N

for i in range(Q):
    point_list[int(input())-1] += 1 


for i in range (N):
    if point_list[i] > 0:
        print("Yes")
    else:
        print("No")

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import numpy as np
N,K,Q = map(int,input().split())
A_list = []
point_list = []

for i in range(Q):
    A_list.append(int(input()))

for i in range(N):
    point_list.append(Q-A_list.count(i+1))

np_point_list = np.array(point_list)

last = K - np_point_list
for i in range(len(last)):
    if last[i] > 0:
        print("Yes")
    elif last[i] <= 0:
        print("No")


Fixed submission:
# -*- coding: utf-8 -*-
import numpy as np
N,K,Q = map(int,input().split())
point_list = [K-Q]*N

for i in range(Q):
    point_list[int(input())-1] += 1 


for i in range (N):
    if point_list[i] > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N = int(input())

print((N**2-N)/2

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())
a = (N*(N-1)//2)
print (a)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

 N = int(input())

 print(N**2-N)

Fixed submission:
# -*- coding: utf-8 -*-

N = int(input())
a = (N*(N-1)//2)
print (a)
Buggy python submission (verdict: Time Limit Exceeded):

N=int(input())
li=[input() for i in range(N)]
count=0
from collections import Counter

dic=[Counter(s.upper().replace(' ', '')) for s in li]
#print(dic)
for i in range(N):
  for j in range(i):
    if i != j:
      if dic[i]==dic[j]:
        count+=1
print(count)

Fixed submission:
N=int(input())
#li=[input() for i in range(N)]
count=0
dic={}
for i in range(N):
  s=input()
  sorted_s="".join(sorted(s))
  count += dic.get(sorted_s, 0)
  dic[sorted_s] = dic.get(sorted_s, 0) + 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):

N=int(input())
li=[]
for i in range(N):
  li.append(input())
count=0
from collections import Counter
 
def verify_anagrams(w1, w2):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(w1) == f(w2)
for i in range(N):
  for j in range(i+1):
    if i != j:
      if verify_anagrams(li[i],li[j]):
        count+=1
print(count)

Fixed submission:
N=int(input())
#li=[input() for i in range(N)]
count=0
dic={}
for i in range(N):
  s=input()
  sorted_s="".join(sorted(s))
  count += dic.get(sorted_s, 0)
  dic[sorted_s] = dic.get(sorted_s, 0) + 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):

N=int(input())
li=[]
for i in range(N):
  li.append(input())
count=0
from collections import Counter
 
def verify_anagrams(w1, w2):
    f = lambda y: "".join(sorted(map(lambda x: x.replace(' ', '').lower(), y)))
    return f(w1) == f(w2)
for i in range(N):
  for j in range(i+1):
    if i != j:
      if verify_anagrams(li[i],li[j]):
        count+=1
print(count)

Fixed submission:
N=int(input())
#li=[input() for i in range(N)]
count=0
dic={}
for i in range(N):
  s=input()
  sorted_s="".join(sorted(s))
  count += dic.get(sorted_s, 0)
  dic[sorted_s] = dic.get(sorted_s, 0) + 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):

N=int(input())
li=[]
for i in range(N):
  li.append(input())
count=0
from collections import Counter
 
def verify_anagrams(first_word, second_word):
    def get_counter(s):
        return Counter(s.upper().replace(' ', ''))
 
    return get_counter(first_word) == get_counter(second_word)
for i in range(N):
  for j in range(i+1):
    if i != j:
      if verify_anagrams(li[i],li[j]):
        count+=1
print(count)

Fixed submission:
N=int(input())
#li=[input() for i in range(N)]
count=0
dic={}
for i in range(N):
  s=input()
  sorted_s="".join(sorted(s))
  count += dic.get(sorted_s, 0)
  dic[sorted_s] = dic.get(sorted_s, 0) + 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ans=1
for i in range(1,N+1):
  ans*=i

result=ans%(10**9+7)
print(result)

Fixed submission:
import math
N=int(input())
ans=1

ans=math.factorial(N)
result=ans%(10**9+7)
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())  
A = [int(i) for i in input().split()] 
B=[0]*N
ans=0
for i in range(N):
    B[i]=(A.index(i+1)+1)
print(' '.join(map(str, B)))

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()] 
A.insert(0, 0)
B = [0]*N
mydict={}
for i in range(1,N+1):
    mydict[A[i]]=i
sorted(mydict.items(), key=lambda x: x[1])
for i in range(1,N+1):
    B[i-1]=mydict[i]
print(' '.join(map(str, B)))
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
if A==B:
  K=1
  print(K)
else A!=B:
  if (A+B)%2==0:
    K=(A+B)/2
    print(K)
  else:
    print('IMPOSSIBLE')


Fixed submission:
A, B = map(int, input().split())
if A==B:
  K=1
  print(K)
else:
  if (A+B)%2==0:
    K=(A+B)/2
    print(int(K))
  else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = [int(input()) for i in range(N)]
q=[]
cnt=0
for i in range(N):
  q.append(i+1)
for i in range(N):
  if p[i]==q[i]:
    cnt=cnt
  else:
    cnt=cnt+1
if cnt==2:
  print('YES')
else:
  print('NO')

Fixed submission:
N = int(input())
p = list(map(int, input().split()))
q=[]
cnt=0
for i in range(N):
  q.append(i+1)
for i in range(N):
  if p[i]==q[i]:
    cnt=cnt
  else:
    cnt=cnt+1
if cnt==2 or cnt==0:
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
def second(s):
    s.sort()
    s.reverse()
    return s[1]

N = int(input())
A = [int(input()) for i in range(N)]
B=A
for i in range(0,N):
    if A[i]==max(A):
        ans=second(B)
        print(ans)
    else:
        print(max(A))

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
a1=max(A)
a2=0
j=0
for i in range(N):
    if A[i]==a1:
        j=j+1
    else:
        j=j
if j!=1:
    for i in range(N):
        print(a1)
else:
    for i in range(N):
        if A[i]>a2 and A[i]!=a1:
            a2=A[i]
    for i in range(N):
        if A[i]==a1:
            print(a2)
        else:
            print(a1)

Buggy python submission (verdict: Time Limit Exceeded):
def second(s):
    s.sort()
    s.reverse()
    return s[1]

N = int(input())
A = [int(input()) for i in range(N)]
for i in range(0,N):
    if A[i]==max(A):
        ans=second(A)
        print(ans)
    else:
        print(max(A))
    

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
a1=max(A)
a2=0
j=0
for i in range(N):
    if A[i]==a1:
        j=j+1
    else:
        j=j
if j!=1:
    for i in range(N):
        print(a1)
else:
    for i in range(N):
        if A[i]>a2 and A[i]!=a1:
            a2=A[i]
    for i in range(N):
        if A[i]==a1:
            print(a2)
        else:
            print(a1)
Buggy python submission (verdict: Time Limit Exceeded):
L,R = (int(i) for i in input().split())
ans=0
amari=2018
if L-R>=2018:
    print(ans)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            if amari>=(i*j)%2019:
                amari=(i*j)%2019
    print(amari)

Fixed submission:
L,R = (int(i) for i in input().split())
ans=0
amari=2018
if R-L>=2018:
    print(ans)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            if amari>=(i*j)%2019:
                amari=(i*j)%2019
    print(amari)

Buggy python submission (verdict: Runtime Error):
L,R = (int(i) for i in input().split()) 
S=[]
j=0
if R-L>=2:
    for i in range(L,R):
        S.append((L+j)%2019)
        j=j+1
    S.sort()
    ans=(S[0]*S[1])%2019
print(ans)

Fixed submission:
L,R = (int(i) for i in input().split())
ans=0
amari=2018
if R-L>=2018:
    print(ans)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            if amari>=(i*j)%2019:
                amari=(i*j)%2019
    print(amari)

Buggy python submission (verdict: Runtime Error):
L,R = (int(i) for i in input().split()) 
S=[]
j=0
if R-L>=2:
    for i in range(L,R):
        S.append((L+j)%2019)
        j=j+1
    S.sort()
    for i in range(L,R):
        if S[i]%673==0 or S[0]==0:
            print(0)
        else:
            ans=(S[0]*S[1])%2019
            print(ans)
else:
    ans=(R*L)%2019
    print(ans)

Fixed submission:
L,R = (int(i) for i in input().split())
ans=0
amari=2018
if R-L>=2018:
    print(ans)
else:
    for i in range(L,R+1):
        for j in range(i+1,R+1):
            if amari>=(i*j)%2019:
                amari=(i*j)%2019
    print(amari)
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
s=0
N=int(n/2)
k=int(abs(d[N]-d[N-1]))
K=(d[N]+d[N-1])/2)
for i in range(n):
    if d[i]>=K:
        s=s+1
    else:
        s=s
if s==N:
    print(k)
else:
    print(0)

Fixed submission:
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
s=0
N=int(n/2)
k=int(abs(d[N]-d[N-1]))
K=(d[N]+d[N-1])/2
for i in range(n):
    if d[i]>=K:
        s=s+1
    else:
        s=s
if s==N:
    print(k)
else:
    print(0)