Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
print(360/X)

Fixed submission:
X = int(input())
x = 1
while True:
    if X*x % 360  == 0:
        print(x)
        break
    x += 1
Buggy python submission (verdict: Runtime Error):
from collections import Counter

n = int(input())
alist = [int(v) for v in input().split()]
dup_set = {k for k, v in Counter(alist).items() if v >= 2}
alist = sorted(set(alist))
adict = {a: False for a in alist}
a_max = alist[-1]
max_ind = -1

count = 0
if 1 in adict:
    count = 0 if 1 in dup_set else 1
else:
    for a, f in adict.items():
        if f:
            continue
        if a not in dup_set:
            count += 1
        for k in range(a, a_max + 1, a):
            if k in adict:
                adict[k] = True
                if k == a_max:
                    max_ind -= 1
                    a_max = alist[max_ind]

print(count)


Fixed submission:
from collections import Counter

n = int(input())
alist = [int(v) for v in input().split()]
dup_set = {k for k, v in Counter(alist).items() if v >= 2}
alist = sorted(set(alist))
adict = {a: False for a in alist}
a_max = alist[-1]
max_ind = -1

count = 0
if 1 in adict:
    count = 0 if 1 in dup_set else 1
else:
    for a, f in adict.items():
        if f:
            continue
        if a not in dup_set:
            count += 1
        for k in range(a, a_max + 1, a):
            if k in adict:
                adict[k] = True
                if k == a_max:
                    max_ind -= 1
                    if abs(max_ind) <= len(alist):
                        a_max = alist[max_ind]

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
alist = sorted([int(v) for v in input().split()], reverse=True)

last = 0
count = 0
for i, a in enumerate(alist):
    if a == last:
        continue
    last = a
    res = True
    for b in alist[i + 1:]:
        if a % b == 0:
            res = False
            break
    if res:
        count += 1

print(count)


Fixed submission:
from collections import Counter

n = int(input())
alist = [int(v) for v in input().split()]
dup_set = {k for k, v in Counter(alist).items() if v >= 2}
alist = sorted(set(alist))
adict = {a: False for a in alist}
a_max = alist[-1]
max_ind = -1

count = 0
if 1 in adict:
    count = 0 if 1 in dup_set else 1
else:
    for a, f in adict.items():
        if f:
            continue
        if a not in dup_set:
            count += 1
        for k in range(a, a_max + 1, a):
            if k in adict:
                adict[k] = True
                if k == a_max:
                    max_ind -= 1
                    if abs(max_ind) <= len(alist):
                        a_max = alist[max_ind]

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
a, b = [int(v) for v in input().split()]

count = 1
div = 3
if a % 2 == 0 and b % 2 == 0:
    count += 1
while a % 2 == 0:
    a //= 2
while b % 2 == 0:
    b //= 2
if a < b:
    a, b = b, a
while b > 1:
    if a % div == 0 and b % div == 0:
        count += 1
    while a % div == 0:
        a //= div
    while b % div == 0:
        b //= div
    div += 2
    if a < b:
        a, b = b, a

print(count)

Fixed submission:
a, b = [int(v) for v in input().split()]

count = 1
div = 3
if a % 2 == 0 and b % 2 == 0:
    count += 1
while a % 2 == 0:
    a //= 2
while b % 2 == 0:
    b //= 2
if a < b:
    a, b = b, a
while b >= div * div:
    if a % div == 0 and b % div == 0:
        count += 1
    while a % div == 0:
        a //= div
    while b % div == 0:
        b //= div
    div += 2
    if a < b:
        a, b = b, a
if b > 1 and a % b == 0:
    count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = [int(v) for v in input().split()]
values = sorted([int(v) for v in input().split()], reverse=True)

def insert(arr, val):
    left, right = 0, len(arr) - 1
    while right - left > 1:
        index = (left + right) // 2
        if val <= arr[index]:
            left = index
        else:
            right = index
    return arr[0:(left + 1)] + [val] + arr[(left + 1):]

for _ in range(m):
    v = values[0] >> 1
    values = insert(values[1:], v)

print(sum(values))

Fixed submission:
from heapq import heappush, heappop, heapify

n, m = [int(v) for v in input().split()]
values = [-int(v) for v in input().split()]
heapify(values)

for _ in range(m):
    v = -((-heappop(values)) >> 1)
    heappush(values, v)

print(-sum(values))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n = int(input())
s = '^' + input().strip() + '$'

dp = (np.zeros((n + 2, n + 2)) - np.identity(n + 2) * 9999999).astype(int)
longest = 0
for i in range(1, n + 2):
    for j in range(i + 1, n + 2):
        if s[i] == s[j]:
            dp[i, j] = dp[i - 1, j - 1] + 1
        else:
            val = dp[i - 1, j - 1]
            if j - i < val:
                val = j - i
            if val > longest:
                longest = val

print(longest)

Fixed submission:
n = int(input())
s = '^' + input().strip() + '$'

dp = [[0 for _ in range(n + 2)] for _ in range(n + 2)]
longest = 0
for i in range(1, n + 2):
    for j in range(i + 1, n + 2):
        if s[i] == s[j]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            val = dp[i - 1][j - 1]
            if j - i < val:
                val = j - i
            if val > longest:
                longest = val

print(longest)
Buggy python submission (verdict: Runtime Error):
a, p = (int(v) for f in input().split(' '))
print((a*3 + p)//2)

Fixed submission:
a, p = (int(v) for v in input().split(' '))
print((a*3 + p)//2)
Buggy python submission (verdict: Runtime Error):
input()
A = map(int, input().split())
for a in A:
  if A % 2 == 0:
    if A % 3 != 0 and A % 5 != 0:
      print('DENIED')
      exit()
print('APPROVED')

Fixed submission:
input()
A = map(int, input().split())
for a in A:
  if a % 2 == 0:
    if a % 3 != 0 and a % 5 != 0:
      print('DENIED')
      exit()
print('APPROVED')
Buggy python submission (verdict: Runtime Error):
n = int(input())

def is_product_of_two_digits(n):
  for i in range(10):
    if n % i == 0 and 1 <= n // i <= 9:
      return True
  return False
    
if is_product_of_two_digits(n):
  print('Yes')
else:
  print('No')
  

Fixed submission:
n = int(input())
 
def is_product_of_two_digits(n):
  for i in range(1, 10):
    if n % i == 0 and 1 <= n // i <= 9:
      return True
  return False
    
if is_product_of_two_digits(n):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
s = input()
for c, d in zip(s, s[1:]):
  if c == d:
    print('Bad')
 	break
else:
  print('Good')
 

Fixed submission:
s = input()
for c, d in zip(s, s[1:]):
  if c == d:
    print('Bad')
    break
else:
  print('Good')
Buggy python submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
p = 1 - K/N
for i in range(1, K):
  n = floor(math.log(N/i, 2))
  p += 1/N * (1/2 ** n)
print(p)

Fixed submission:
import math

N, K = map(int, input().split())
if K <= N:
  p = 1 - (K-1)/N
else:
  p = 0
for i in range(1, min(N+1, K)):
  n = math.ceil(math.log(K/i, 2))
  p += 1/N * (1/2 ** n)
print(p)
Buggy python submission (verdict: Runtime Error):
input()
A=list(map(int,input()))
s=0
for a in A:
  if a < 0:
    s += 1
S=0
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)

Fixed submission:
input()
A=list(map(int,input().split()))
s=0
for a in A:
  if a < 0:
    s += 1
S=0
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)

Buggy python submission (verdict: Runtime Error):
input()
A=list(map(int,input()))
s=0
for a in A:
  if a < 0:
    s += 1
S=0
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)

Fixed submission:
input()
A=list(map(int,input().split()))
s=0
for a in A:
  if a < 0:
    s += 1
S=0
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)

Buggy python submission (verdict: Runtime Error):
input()
A=list(map(int,input()))
s=0
for a in A:
  if a < 0:
    s += 1
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)

Fixed submission:
input()
A=list(map(int,input().split()))
s=0
for a in A:
  if a < 0:
    s += 1
S=0
if s % 2 == 0:
  S = sum([abs(a) for a in A])
else:
  B = [abs(a) for a in A]
  m = min(B)
  S = sum(B) - 2*m
print(S)
Buggy python submission (verdict: Runtime Error):
N=input()
S=input()
K=input()
C=S[K-1]
S_=''
for c in S:
  if c == C:
    S_+=c
  else:
    S_+="*"
print(S_)

Fixed submission:
N=int(input())
S=input()
K=int(input())
C=S[K-1]
S_=''
for c in S:
  if c == C:
    S_+=c
  else:
    S_+="*"
print(S_)
Buggy python submission (verdict: Runtime Error):
def get_ints():
  return map(int, input().split())

N, _, C = get_ints()
B = list(get_ints())

n = 0
for _ in range(N):
  A = list(get_ints())
  J = sum(a * b for a, b in zip(A, B)) + C
  if J > 0:
  	n += 1
    
print(n)


Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())

print((H - h) * (W - w))
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
n = min(B / A, C)
print n

Fixed submission:
A, B, C = map(int, input().split())
print(min(B // A, C))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
ans = 1
flag = True
for i in range(n):
  ans *= A[i]
if ans > 10**18:
  print(-1)
else:
  print(ans)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
ans = 1
flag = True
if 0 in A:
  print(0)
  flag = False
if flag:
  for i in range(n):
    ans *= A[i]
    if ans > 10**18:
      print(-1)
      flag = False

      break
  if flag:
    print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b = input().split()
a = int(a)
b = float(b)
b = int(b*100)
a *= b
a //= 100
print(a)

Fixed submission:
from decimal import Decimal
import math
a, b = map(Decimal, input().split())

a *= b

print(math.floor(a))
Buggy python submission (verdict: Runtime Error):
a = input()
if a == ABC:
  print('ARC')
else:
  print('ABC')

Fixed submission:
a = input()
if a == 'ABC':
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Runtime Error):
import math
a, b, n = map(int, input().split())

y = b-1
if x < n:
  x = y
else:
  x = n

print(math.floor(a*x/b))

Fixed submission:
import math
a, b, n = map(int, input().split())

y = b-1
x = 0
if y < n:
  x = y
else:
  x = n
print(math.floor(a*x/b))
Buggy python submission (verdict: Time Limit Exceeded):
n, x, y = map(int, input().split())
dp = [[0 for _ in range(n)] for _ in range(n)]
ans = [0 for _ in range(n-1)]
for i in range(1, n):
  for j in range(i+1, n+1):
    a = min(j-i, abs(x-i)+abs(y-j)+1, abs(x-j)+abs(y-i)+1)
    ans[a-1] += 1
for i in range(n-1):
  print(ans[i])

Fixed submission:
n, x, y = map(int, input().split())
ans = [0 for _ in range(n-1)]
for i in range(1, n):
  for j in range(i+1, n+1):
    a = min(j-i, abs(x-i)+abs(y-j)+1, abs(x-j)+abs(y-i)+1)
    ans[a-1] += 1
for i in range(n-1):
  print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

ans = 0
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
p = p[:x]
q = q[:y]

P = sum(i for i in p)
Q = sum(j for j in q)
ans = P+Q
apples = p+q
apples.sort()
for i in range(len(r)):
  if apples[i] < r[0]:
    ans = ans-apples[i] + r[0]
    del r[0]
  else:
    break
print(ans)

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

ans = 0
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
p = p[:x]
q = q[:y]

P = sum(i for i in p)
Q = sum(j for j in q)
ans = P+Q
apples = p+q
apples.sort()
for i in range(len(r)):
  if apples[i] < r[0]:
    ans = ans-apples[i] + r[0]
    del r[0]
  else:
    break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
a = list(map(int, input().split()))
def combinations_count(n, r):
  if n == 0 or n == 1:
    return 0
  else:
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
C = [0]*n
for i in range(n):
  C[a[i]-1] += 1
for i in range(n):
  ans = sum(combinations_count(a, 2) for a in C)
for i in range(n):
  print(ans -max(0,C[a[i]-1]-1))

Fixed submission:
n=int(input())
a=list(map(int, input().split()))
b=[0]*n
ans=0

for i in range(n):
    b[a[i]-1]+=1
for i in range(n):
    ans+=(b[i]*(b[i]-1))//2
for i in range(n):
    print(ans-b[a[i]-1]+1)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
p = list(map(int, input().split()))
A = [0]
for i in range(1, 1000):
    A.append(A[i-1]+i)
S = [0]*n
for j in range(n):
    S[j] = A[p[j]]/p[j]
ANS = [sum(S[a] for a in range(k))]
for i in range(n-k):
    ANS.append(ANS[i]-S[i]+S[k+i])
print(max(ANS))
        

Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))
A = [0]
for i in range(1, 1001):
    A.append(A[i-1]+i)
S = [0]*n
for j in range(n):
    S[j] = A[p[j]]/p[j]
ANS = [sum(S[a] for a in range(k))]
for i in range(n-k):
    ANS.append(ANS[i]-S[i]+S[k+i])
print(max(ANS))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
S=str(s)
A = set([])
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):

    x = int(S[i])
    y = int(S[j])

    if not((10*x+y) in A):
      A.add(10*x+y)
      ans += len(set(list(S[j+1::])))
print(ans)


Fixed submission:
def my_index2(l, x, default=-1):
    return l.index(x) if x in l else default
n = int(input())
S = list(input())
for i in range(n):
  S[i] = int(S[i])
ans = 0
for i in range(10):
  a = my_index2(S[0:n-2],i)
  if a != -1:
    for j in range(10):
      b = my_index2(S[a+1:n-1], j) 
      if b!=-1:
        for k in range(10):
          c = my_index2(S[a+1+b+1::], k)
          if c!= -1:
            ans+=1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
S=str(s)
A = set([])
ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):

    x = int(S[i])
    y = int(S[j])

    if not((10*x+y) in A):
      A.add(10*x+y)
      ans += len(set(list(S[j+1::])))
print(ans)

Fixed submission:
def my_index2(l, x, default=-1):
    return l.index(x) if x in l else default
n = int(input())
S = list(input())
for i in range(n):
  S[i] = int(S[i])
ans = 0
for i in range(10):
  a = my_index2(S[0:n-2],i)
  if a != -1:
    for j in range(10):
      b = my_index2(S[a+1:n-1], j) 
      if b!=-1:
        for k in range(10):
          c = my_index2(S[a+1+b+1::], k)
          if c!= -1:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, x = map(int, input().split())
import math
if x >= (a**2)*b/2:
    z = math.atan((a**3)/(2*(b*(a**2)-x)))
else:
    z = math.atan(2*x/(a*(b**2)))

print(90-math.degrees(z))

Fixed submission:
a, b, x = map(int, input().split())
import math
if x == (a**2)*b:
    print(0)
elif x >= (a**2)*b/2:
    z = math.atan((a**3)/(2*(b*(a**2)-x)))
    print(90-math.degrees(z))
else:
    z = math.atan(2*x/(a*(b**2)))
    print(90-math.degrees(z))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
for i in range(m):
  A[-1] = A[-1]//2
  A.sort()
print(sum(a for a in A))

Fixed submission:
import heapq
n, m = map(int, input().split())
A = list(map(int, input().split()))
for i in range(n):
  A[i] = -A[i]
B = heapq.heapify(A)
i = 0
while i < m:
  h = heapq.heappop(A) 
  heapq.heappush(A, -(-h//2))
  i += 1
print(-sum(a for a in list(A)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int, input().split()))
import heapq
heap = []
for i in range(n):
  m = 0
  for j in range(i,n-1):
    if h[j] >= h[j+1]:
      m += 1
    else:
      break
  heapq.heappush(heap, -m)
print(-heapq.heappop(heap))

Fixed submission:
n = int(input())
H = list(map(int, input().split()))
A = [0]*(n*1)
for i in range(1,n):
  A[-(i+1)] = (A[-i] + 1 if H[-(i+1)] >= H[-i] else 0)
print(max(A))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
print(sum(i for i in range(n)))

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
n = input()
a = list(map(int, input()))
for i in a:
    i = 1/i
print(sum(i) for i in a)

Fixed submission:
n = input()
a = list(map(int, input().split()))
a = [1/i for i in a]
b = sum(t for t in a )
print(1/b)
Buggy python submission (verdict: Runtime Error):
input()
A = list(map(int, input().split()))
A.sort()
while len(A)>=1:
    A.append((A[0]+A[1])/2)
    del(A[0:2])
    A.sort()
print(A)

Fixed submission:
input()
A = list(map(int, input().split()))
A.sort()
while len(A)>1:
  b = A[0:2]
  c = sum(i for i in b)
  A.append(c/2)
  del(A[0:2])
  A.sort()
z = [str(a) for a in A]
z = ''.join(z)
print(z)

Buggy python submission (verdict: Time Limit Exceeded):
input()
A = list(map(int, input().split()))
A.sort()
while len(A)>0:
    A.append((A[0]+A[1])/2)
    del A[0:1]
    A.sort()
print(A)

Fixed submission:
input()
A = list(map(int, input().split()))
A.sort()
while len(A)>1:
  b = A[0:2]
  c = sum(i for i in b)
  A.append(c/2)
  del(A[0:2])
  A.sort()
z = [str(a) for a in A]
z = ''.join(z)
print(z)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = a + b
t = a - b
u = a * b
x = [s, t, u].sort()
print(x[-1])

Fixed submission:
a, b = map(int, input().split())
s = a + b
t = a - b
u = a * b
x = sorted([s, t, u])
print(x[-1])

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
s = a + b
t = a - b
u = a * b
x = [s, t, u].sort()
print(x[-1])

Fixed submission:
a, b = map(int, input().split())
s = a + b
t = a - b
u = a * b
x = sorted([s, t, u])
print(x[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]
for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
        jobs[d-1].append(r)

m = 0
li = []
for i in range(M):
    li.extend(jobs[i])
    if len(li) > 0:
        m += max(li)
        li.remove(max(li))
print(m)

Fixed submission:
import heapq
N, M = list(map(int, input().split()))
jobs = [[] for _ in range(M)]
for i in range(N):
    d, r = list(map(int, input().split()))
    if d-1 < M:
        jobs[d-1].append(-r)

m = 0
heap = []
for i in range(M):
    for a in jobs[i]:
        heapq.heappush(heap, a)
    if len(heap) > 0:
        b = heapq.heappop(heap)
        m += -b
print(m)
Buggy python submission (verdict: Runtime Error):
n = int(input())
m == 0
for i in range(n):
  if len(str(i))%2 != 0:
    m += 1
print(m)

Fixed submission:
n = int(input())
m = 0
for i in range(1,n+1):
  if (len(str(i))-1)%2 == 0:
    m += 1
print(m)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in range(n):
    print(a_second if i == a.index(a_first) else a_first)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in range(n):
    if i != a.index(a_first):
        print(a_first)
    else:
        print(a_second)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in range(n):
    if i == a.index(a_first):
        print(a_second)
    else:
        print(a_first)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
if a_first == a_second:
    for i in range(n):
        print(a_first)
else:
    for i in range(n):
        if i == a.index(a_first):
            print(a_second)
        else:
            print(a_first)

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    if max(a) == a[i]:
        print(sorted(a)[-2])
    else:
        print(sorted(a)[-1])

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    b = copy.copy(a)
    del b[i]
    b.sort()
    print(b[-1])

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n):
    b = copy.deepcopy(a)
    del b[i]
    b.sort()
    print(b[-1])

Fixed submission:
n = int(input())
a = [int(input()) for i in range(n)]
a_first = sorted(a)[-1]
a_second = sorted(a)[-2]
for i in a:
    print(a_second if i == a_first else a_first)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
num = [i for i in range(n)]
B = [0]*(n)
C = []
ans = 0
for i in range(n):
  if sum(B[j-1] for j in list(filter(lambda x:x%(n-i) == 0, num))) != A[n-i-1]:
    B[n-i-1] = 1
    ans += 1
    C.append(n-i)
print(ans)
print(*C)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
num = [i for i in range(n)]
B = [0]*(n)
C = []
ans = 0
for i in range(n-1, -1, -1):
  ms = sum(B[i::i+1])
  if ms % 2 != A[i]:
    ans += 1
    C.append(i+1)
    B[i] = 1
print(ans)
print(*C)
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(set(A))
if len(B) >= 4:
  print('No')
else:
  if B[-1] == 0:
    print('Yes')
  elif A.count(0) == n/3 and len(B) == 2:
    print('Yes')
  elif B[0]^B[1]^B[2] == 0 and A.count(B[0]) == A.count(B[1]) == n/3:
    print('Yes')
  else:
    print('No')

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
A.sort()
B = list(set(A))
if len(B) >= 4:
  print('No')
else:
  if B[-1] == 0:
    print('Yes')
  elif A.count(0) == n/3 and len(B) == 2:
    print('Yes')
  elif len(B) == 3 and B[0]^B[1]^B[2] == 0 and A.count(B[0]) == A.count(B[1]) == n/3:
    print('Yes')
  else:
    print('No')