Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
a = list(map(int, input().split()))
b = deque()
ans = 0

for i in range(N):
  t = N-1-i
  k = N-i
  s = 0
  while k-1 < N:
    if k in b:
      s += 1
    k += t+1
  if (a[t]+s) % 2 == 1:
    b.appendleft(t+1)
    ans += 1
    
print(ans)
print(' '.join(map(str, b)))

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

b = [0] * N
for i in range(N):
  tmp = 0
  n = N-i
  for j in range(n*2-1, N, n):
    if b[j] == 1:
      tmp += 1
  if a[n-1] != tmp%2:
    b[n-1] = 1

ans = []
for i in range(N):
  if b[i] == 1:
    ans.append(i+1)
if ans != []:
  print(len(ans))
  print(*ans)
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
a = list(map(int, input().split()))
b = deque()
ans = 0

for i in range(1, N):
  t = N-1-i
  k = N-i
  s = 0
  while k-1 < N:
    if k in b:
      s += 1
    k += t+1
  if (a[t]+s) % 2 == 1:
    b.appendleft(t+1)
    ans += 1
    
if (a[0]+len(b)) % 2 == 1:
  b.appendleft(1)
  ans += 1
    
print(ans)
print(' '.join(map(str, b)))

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

b = [0] * N
for i in range(N):
  tmp = 0
  n = N-i
  for j in range(n*2-1, N, n):
    if b[j] == 1:
      tmp += 1
  if a[n-1] != tmp%2:
    b[n-1] = 1

ans = []
for i in range(N):
  if b[i] == 1:
    ans.append(i+1)
if ans != []:
  print(len(ans))
  print(*ans)
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
a = list(map(int, input().split()))
b = deque()
ans = 0

for i in range(N):
  t = N-1-i
  k = N-i
  s = 0
  while k-1 < N:
    if k in b:
      s += 1
    k += t+1
  if (a[t]+s) % 2 == 1:
    b.appendleft(t+1)
    ans += 1
    
print(ans)
print(' '.join(map(str, b)))

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

b = [0] * N
for i in range(N):
  tmp = 0
  n = N-i
  for j in range(n*2-1, N, n):
    if b[j] == 1:
      tmp += 1
  if a[n-1] != tmp%2:
    b[n-1] = 1

ans = []
for i in range(N):
  if b[i] == 1:
    ans.append(i+1)
if ans != []:
  print(len(ans))
  print(*ans)
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
a = list(map(int, input().split()))
b = deque()
ans = 0

for i in range(N):
  t = N-1-i
  s = 0
  while t < N:
    if t+1 in b:
      s += 1
    t += N-i
  if (a[N-1-i]+s) % 2 == 1:
    b.appendleft(N-i)
    ans += 1
    
print(ans)
print(' '.join(map(str, b)))

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

b = [0] * N
for i in range(N):
  tmp = 0
  n = N-i
  for j in range(n*2-1, N, n):
    if b[j] == 1:
      tmp += 1
  if a[n-1] != tmp%2:
    b[n-1] = 1

ans = []
for i in range(N):
  if b[i] == 1:
    ans.append(i+1)
if ans != []:
  print(len(ans))
  print(*ans)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = list(map(int, input().split()))

a = []
for i in range(N):
  l = [0] * N
  l[i] = 1/2
  if i < N-1:
    l[i+1] = 1/2
  else:
    l[0] = 1/2
  a.append(l)

a = np.array(a)
b = np.array(A)
n = np.linalg.solve(a, b)
ans = []
for i in range(N):
  ans.append(int(n[i]))
print(*ans)

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

tmp = 0
for i in range(N//2):
  tmp += A[2*i+1]
  
ans = []
if sum(A) > 2*tmp:
  ans.append(sum(A)-2*tmp)
else:
  ans.append(0)
  
for i in range(N-1):
  ans.append(2*A[i]-ans[-1])
print(*ans)
Buggy python submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
for i in range(1, K+1):
  ans = 0
  blue = math.factorial(K-1) // (math.factorial(i-1)*math.factorial(K-i))
  red = math.factorial(N-K+1) // (math.factorial(i)*math.factorial(N-K+1-i))
  ans = blue * red
  ans = ans % (10**9+7)
  print(int(ans))

Fixed submission:
import math
N, K = map(int, input().split())
for i in range(1, K+1):
  ans = 0
  blue = math.factorial(K-1) // (math.factorial(i-1)*math.factorial(K-i))
  if N-K+1-i < 0:
    red = 0
  else:
    red = math.factorial(N-K+1) // (math.factorial(i)*math.factorial(N-K+1-i))
  ans = blue * red
  ans = ans % (10**9+7)
  print(int(ans))
Buggy python submission (verdict: Runtime Error):
S = input()
judge = 0

for i in range(4):
  if S[i] == S[i+1]:
    judge += 1
    
if judge == 0:
  print('Good')
else:
  print('Bad')


Fixed submission:
S = input()
judge = 0

for i in range(3):
  if S[i] == S[i+1]:
    judge += 1
    
if judge == 0:
  print('Good')
else:
  print('Bad')
Buggy python submission (verdict: Runtime Error):
#両端のりんごの味は、(L, L+N-1)
N, L = map(int, input().split(''))
sum_all = N(L+((N+1)/2)-1)

if L*(L+N-1) <= 0:
  print(sum_all)
elif L < 0:
  print(sum_all - L - N + 1)
else:
  print(sum_all - L)

Fixed submission:
#両端のりんごの味は、(L, L+N-1)
N, L = map(int, input().split())
sum_all = N*(L+((N+1)/2)-1)

if L*(L+N-1) <= 0:
  print(int(sum_all))
elif L < 0:
  print(int(sum_all - L - N + 1))
else:
  print(int(sum_all - L))
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = list(map(int, input().split()))

dist = 0
cnt = 0
for i in range(N):
  if dist <= X:
    dist += list[i]
    cnt += 1
  else:
    break;
    
print(cnt)

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

dist = 0
cnt = 1
for i in range(N):
  dist += L[i]
  if dist <= X:
    cnt += 1
  else:
    break;
  
print(cnt)
Buggy python submission (verdict: Runtime Error):
s = str(input())

ans = 0
for i in range(len(s)-1):
  if s[i:i+2] == 'BC':
    cnt = 0
    for j in range(i):
      if s[i-1-j] == 'A':
        cnt += 1
      else:
        break
    s = s[:i-cnt] + 'BC' + 'A'*cnt + s[i+2:]
    ans += cnt
    print(s)
print(ans)

Fixed submission:
s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())

ans = 0
for i in range(len(s)-1):
  if s[i:i+2] == 'BC':
    cnt = 0
    for j in range(i):
      if s[i-1-j] == 'A':
        cnt += 1
      else:
        break
    s = s[:i-cnt] + 'BC' + 'A'*cnt + s[i+2:]
    ans += cnt
print(ans)

Fixed submission:
s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
s = str(input())

ans = 0
for i in range(len(s)-1):
  if s[i:i+2] == 'BC':
    cnt = 0
    for j in range(i):
      if s[i-1-j] == 'A':
        cnt += 1
      else:
        break
    s = s[:i-j-cnt] + 'BC' + 'A'*cnt + s[i+2:]
    ans += cnt
print(ans)

Fixed submission:
s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())

ans = 0
for i in range(len(s)-1):
  if s[i:i+2] == 'BC':
    tmp = i
    cnt = 0
    while (0<tmp) and (s[tmp-1]=='A'):
      cnt += 1
      tmp -= 1
    else:
      ans += cnt
      s = s[:tmp] + 'BC' + 'A'*cnt + s[i+2:]
print(ans)

Fixed submission:
s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())

ans = 0
for i in range(len(s)-1):
  if s[i:i+2] == 'BC':
    tmp = i
    cnt = 0
    while (0<tmp) and (s[tmp-1]=='A'):
      cnt += 1
      tmp -= 1
    else:
      ans += cnt
      s = s[:tmp] + 'BC' + 'A'*cnt + s[i+2:]
print(ans)

Fixed submission:
s = str(input())

ans, cnt, i = 0, 0, 0
while i < len(s)-1:
  if s[i] == 'A':
    cnt += 1
    i += 1
  else:
    if s[i:i+2] == 'BC':
      ans += cnt
      i += 2
    else:
      cnt = 0
      i += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
C = []
for i in range(M):
  b, c = map(int, input().split())
  for i in range(b):
    C.append(c)

A.sort()
C.sort(reverse=True)
j = 0
while (j < len(C)) and (A[j] < C[j]):
  A[j] = C[j]
  j += 1
  
print(sum(A))

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

if 13 <= A:
  ans = B
elif A < 6:
  ans = 0
else:
  ans = B / 2
  
print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())

w = S.count('.')
b = S.count('#')
cnt = N+1
for i in range(1, N+1):
  tmp = S[:i].count('#') + S[i:].count('.')
  cnt = min(cnt, tmp)
    
ans = min(w, b, cnt)
print(ans)

Fixed submission:
N = int(input())
S = str(input())

w = S.count('.')
b = S.count('#')
cnt = N+1
tmp = w
for i in range(N):
  if S[i] == '.':
    tmp -= 1
  else:
    tmp += 1
  cnt = min(cnt, tmp)
    
ans = min(w, b, cnt)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = str(input())
li = []
cnt = 0

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    cnt += 1
    li.append(cnt)
  else:
    li.append(cnt)

for i in range(Q):
  l, r = map(int, input().split())
  ans = li[r-1] - li[:l-1]
  print(ans)


Fixed submission:
N, Q = map(int, input().split())
S = str(input())
li = []
cnt = 0

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    cnt += 1
    li.append(cnt)
  else:
    li.append(cnt)

for i in range(Q):
  l, r = map(int, input().split())
  if l > 1:
    ans = li[r-2] - li[l-2]
  else:
    ans = li[r-2]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = str(input())
li = []

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    li.append(1)
  else:
    li.append(0)

for i in range(Q):
  l, r = map(int, input().split())
  ans = sum(li[:r-1]) - sum(li[:l-1])
  print(ans)


Fixed submission:
N, Q = map(int, input().split())
S = str(input())
li = []
cnt = 0

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    cnt += 1
    li.append(cnt)
  else:
    li.append(cnt)

for i in range(Q):
  l, r = map(int, input().split())
  if l > 1:
    ans = li[r-2] - li[l-2]
  else:
    ans = li[r-2]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = str(input())
li = []

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    li.append(1)
  else:
    li.append(0)

for i in range(Q):
  l, r = map(int, input().split())
  s = li[l-1:r-1]
  ans = sum(s)
  print(ans)

Fixed submission:
N, Q = map(int, input().split())
S = str(input())
li = []
cnt = 0

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    cnt += 1
    li.append(cnt)
  else:
    li.append(cnt)

for i in range(Q):
  l, r = map(int, input().split())
  if l > 1:
    ans = li[r-2] - li[l-2]
  else:
    ans = li[r-2]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = str(input())

for i in range(Q):
  l, r = map(int, input().split())
  s = S[l-1:r]
  ans = s.count('AC')
  print(ans)

Fixed submission:
N, Q = map(int, input().split())
S = str(input())
li = []
cnt = 0

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    cnt += 1
    li.append(cnt)
  else:
    li.append(cnt)

for i in range(Q):
  l, r = map(int, input().split())
  if l > 1:
    ans = li[r-2] - li[l-2]
  else:
    ans = li[r-2]
  print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = str(input())

for i in range(Q):
  l, r = map(int, input().split())
  s = S[l-1:r]
  ans = s.count('AC')
  print(ans)

Fixed submission:
N, Q = map(int, input().split())
S = str(input())
li = []
cnt = 0

for i in range(N-1):
  if S[i]=='A' and S[i+1]=='C':
    cnt += 1
    li.append(cnt)
  else:
    li.append(cnt)

for i in range(Q):
  l, r = map(int, input().split())
  if l > 1:
    ans = li[r-2] - li[l-2]
  else:
    ans = li[r-2]
  print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input())
if A*C <= B:
  print(C)
else:
  print(B//A)

Fixed submission:
A, B, C = map(int, input().split())
if A*C <= B:
  print(C)
else:
  print(B//A)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
A = list(map(int, input().split()))

A.sort()
A = deque(A)
while len(A) > 1:
  s = []
  for i in range(len(A)-1):
    div = A[-1] % A[0]
    A.pop()
    if (div != 0) and (div not in s):
      s.append(div)
  s.append(A[0])
  s.sort()
  A = deque(s)
print(*A)

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

A.sort()
A = deque(A)
while len(A) > 1:
  s = []
  for i in range(len(A)-1):
    div = A[-1] % A[0]
    A.pop()
    if div != 0:
      s.append(div)
  s.append(A[0])
  s.sort()
  A = deque(s)
print(*A)

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

A.sort()
A = deque(set(A))
while len(A) > 1:
  s = []
  for i in range(len(A)-1):
    div = A[-1] % A[0]
    A.pop()
    if (div != 0) and (div not in s):
      s.append(div)
  s.append(A[0])
  s.sort()
  A = deque(s)
print(*A)

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

A.sort()
A = deque(A)
while len(A) > 1:
  s = []
  for i in range(len(A)-1):
    div = A[-1] % A[0]
    A.pop()
    if div != 0:
      s.append(div)
  s.append(A[0])
  s.sort()
  A = deque(s)
print(*A)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A, B = [], []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
x, y = 0, 0
for i in range(N//2):
  if A.index(max(A)) == B.index(max(B)):
    s = A.index(max(A))
    x += A[s]
    A.pop(s)
    B.pop(s)
    t = B.index(max(B))
    y += B[t]
    A.pop(t)
    B.pop(t)
  else:
    s = max(A)
    t = max(B)
    u = A[B.index(t)]
    w = sorted(B)[-2]
    if s-t >= u-w:
      x += s
      y += t
    else:
      x += u
      y += w
      
if N % 2 == 1:
  x += A[0]
print(x-y)


Fixed submission:
N = int(input())
A, B = [], []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
l = []
for i in range(N):
  l.append(A[i]+B[i])
l.sort(reverse=True)

ans = 0
for i in range(N//2):
  ans += l[2*i]
if N % 2 == 1:
  ans += l[-1]
ans -= sum(B)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A, B = [], []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
x, y = 0, 0
for i in range(N//2):
  if A.index(max(A)) == B.index(max(B)):
    s = A.index(max(A))
    x += A[s]
    A.pop(s)
    B.pop(s)
    t = B.index(max(B))
    y += B[t]
    A.pop(t)
    B.pop(t)
  else:
    s = max(A)
    t = max(B)
    u = A[B.index(t)]
    w = sorted(B)[-2]
    if s-t >= u-w:
      x += s
      y += t
    else:
      x += u
      y += w
      
if N % 2 == 1:
  x += A[0]
print(x-y)

Fixed submission:
N = int(input())
A, B = [], []
for i in range(N):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
l = []
for i in range(N):
  l.append(A[i]+B[i])
l.sort(reverse=True)

ans = 0
for i in range(N//2):
  ans += l[2*i]
if N % 2 == 1:
  ans += l[-1]
ans -= sum(B)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
if input():
  A = int(input())
  B = int(input())
 
if N == 1:
  print('Hello World')
else:
  print(A + B)

Fixed submission:
N = int(input())
 
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A + B)

Buggy python submission (verdict: Runtime Error):
N = input()
 
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A + B)

Fixed submission:
N = int(input())
 
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A + B)

Buggy python submission (verdict: Runtime Error):
N = input()
A = int(input())
B = int(input())

if N == 1:
  print('Hello World')
else:
  print(A + B)
  

Fixed submission:
N = int(input())
 
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A + B)
Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
c = []
t = []
for i in range(N):
  c[i], t[i] = map(int, input().split())
 
costs = []
for i in range(N):
  if t[i] <= T:
    costs.append(c[i])
    
print(min(costs))

Fixed submission:
N, T = map(int, input().split())
cost = 10000

for i in range(N):
  c, t = map(int, input().split())
  if t <= T:
    cost = min(cost, c)
    
if cost == 10000:
  print('TLE')
else:
  print(cost)

Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
c = []
t = []
c[i], t[i] = map(int, input().split())
 
costs = []
for i in range(N):
  if t[i] <= T:
    costs.append(c[i])
    
print(min(costs))

Fixed submission:
N, T = map(int, input().split())
cost = 10000

for i in range(N):
  c, t = map(int, input().split())
  if t <= T:
    cost = min(cost, c)
    
if cost == 10000:
  print('TLE')
else:
  print(cost)

Buggy python submission (verdict: Runtime Error):
N, T = map(int, input().split())
c, t = list(map(int, input().split()))

costs = []
for i in range(N):
  if t[i] <= T:
    costs.append(c[i])
    
print(min(costs))

Fixed submission:
N, T = map(int, input().split())
cost = 10000

for i in range(N):
  c, t = map(int, input().split())
  if t <= T:
    cost = min(cost, c)
    
if cost == 10000:
  print('TLE')
else:
  print(cost)
Buggy python submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())

l = []
for i in range(1, int(math.sqrt(M))):
  if M % i == 0:
    l.append(i)
    if i != M//i:
      l.append(M//i)
      
l.sort(reverse=True)
for n in l:
  if n*N <= M:
    ans = n
    break
print(ans)

Fixed submission:
import math
N, M = map(int, input().split())

l = []
for i in range(1, int(math.sqrt(M))+1):
  if M % i == 0:
    l.append(i)
    if i != M//i:
      l.append(M//i)
      
l.sort(reverse=True)
for n in l:
  if n*N <= M:
    ans = n
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)

li = []
x.sort()
for i in range(N):
  li.append(x[i+1]-x[i])
  
li.sort()
while len(li) > 1:
  l = []
  div = li[0]
  for n in li:
    mod = n % div
    if mod != 0:
      mod.append(l)
  l.append(div)
  l.sort()
  li = l
print(*li)

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

li = []
x.sort()
for i in range(N):
  li.append(x[i+1]-x[i])
  
li.sort()
while len(li) > 1:
  l = []
  div = li[0]
  for n in li:
    mod = n % div
    if mod != 0:
      l.append(mod)
  l.append(div)
  l.sort()
  li = l
print(*li)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = str(input())

ans = 10**6
for i in range(N+1):
  tmp = S[:i].count('W') + S[i+1:].count('E')
  ans = min(ans, tmp)
print(ans)

Fixed submission:
N = int(input())
S = str(input())

ans = S[1:].count('E')
tmp = S[1:].count('E')
for i in range(N-1):
  if S[i] == 'W':
    tmp += 1
  if S[i+1] == 'E':
    tmp -= 1
  ans = min(ans, tmp)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

cnt = 0
ans = [a[0], a[1]]
for i in range(n-1):
  num = a[i]
  tmp = a[i+1]
  for j in range(i+1, n):
    if abs(tmp-num/2) >= abs(a[j]-num/2):
      tmp = a[j]
    else:
      break
  if abs(tmp-num/2) < 1:
    ans = [num, tmp]
    break
  mul = math.factorial(num) // (math.factorial(tmp)*math.factorial(num-tmp))
  if cnt < mul:
    cnt = mul
    ans = [num, tmp]
print(*ans)

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

num = a[0]
tmp = a[1]
for j in range(1, n):
  if abs(tmp-num/2) >= abs(a[j]-num/2):
    tmp = a[j]
  else:
    break
ans = [num, tmp]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

cnt = 0
ans = [a[0], a[1]]
for i in range(n-1):
  num = a[i]
  half = num // 2
  mx = math.factorial(num) // (math.factorial(half)*math.factorial(num-half))
  if cnt > mx:
    break
  tmp = a[i+1]
  for j in range(i+1, n):
    if abs(tmp-num/2) >= abs(a[j]-num/2):
      tmp = a[j]
    else:
      break
  mul = math.factorial(num) // (math.factorial(tmp)*math.factorial(num-tmp))
  if cnt < mul:
    cnt = mul
    ans = [num, tmp]
  if abs(a[j]-num/2) < 1:
    break
print(*ans)

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

num = a[0]
tmp = a[1]
for j in range(1, n):
  if abs(tmp-num/2) >= abs(a[j]-num/2):
    tmp = a[j]
  else:
    break
ans = [num, tmp]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

cnt = 0
ans = [a[0], a[1]]
for i in range(n-1):
  num = a[i]
  half = num // 2
  mx = math.factorial(num) // (math.factorial(half)*math.factorial(num-half))
  if cnt > mx:
    break
  tmp = a[i+1]
  for j in range(i+1, n):
    if abs(tmp-num/2) >= abs(a[j]-num/2):
      tmp = a[j]
    else:
      break
  mul = math.factorial(num) // (math.factorial(tmp)*math.factorial(num-tmp))
  if cnt < mul:
    cnt = mul
    ans = [num, tmp]
print(*ans)

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

num = a[0]
tmp = a[1]
for j in range(1, n):
  if abs(tmp-num/2) >= abs(a[j]-num/2):
    tmp = a[j]
  else:
    break
ans = [num, tmp]
print(*ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
H, W = map(int, input().split())
S = []
white = 0
for i in range(H):
  s = str(input())
  S.append(s)
  white += s.count('.')
  
def main(h, w):
  global H
  global W
  global S
  global l
  tmp = []
  if h < H-1:
    if (S[h+1][w]=='.') and ([h+1, w] not in l):
      tmp.append([h+1, w])
  if w < W-1:
    if (S[h][w+1]=='.') and ([h, w+1] not in l):
      tmp.append([h, w+1])
  if 0 < h:
    if (S[h-1][w]=='.') and ([h-1, w] not in l):
      tmp.append([h-1, w])
  if 0 < w:
    if (S[h][w-1]=='.') and ([h, w-1] not in l):
      tmp.append([h, w-1])
  return tmp
    
cnt = 0
l = [[0, 0]]
tmp = [[0, 0]]
for i in range(10000):
  t = []
  for n in tmp:
    u = main(n[0], n[1])
    l += u
    t += u
  if [H-1, W-1] in t:
    ans = i+2
    break
  else:
    tmp = t
print(white-ans)

Fixed submission:
import sys
sys.setrecursionlimit(10000)
H, W = map(int, input().split())
S = []
white = 0
for i in range(H):
  s = str(input())
  S.append(s)
  white += s.count('.')
  
def main(h, w):
  global H
  global W
  global S
  global l
  tmp = []
  if h < H-1:
    if (S[h+1][w]=='.') and ([h+1, w] not in l):
      tmp.append([h+1, w])
  if w < W-1:
    if (S[h][w+1]=='.') and ([h, w+1] not in l):
      tmp.append([h, w+1])
  if 0 < h:
    if (S[h-1][w]=='.') and ([h-1, w] not in l):
      tmp.append([h-1, w])
  if 0 < w:
    if (S[h][w-1]=='.') and ([h, w-1] not in l):
      tmp.append([h, w-1])
  return tmp
    
cnt = 0
l = [[0, 0]]
tmp = [[0, 0]]
for i in range(10000):
  t = []
  for n in tmp:
    u = main(n[0], n[1])
    l += u
    t += u
  if t == []:
    ans = white+1
  elif [H-1, W-1] in t:
    ans = i+2
    break
  else:
    tmp = t
print(white-ans)
Buggy python submission (verdict: Runtime Error):
M = int(input())
ans = 48 - M
printg(ans)

Fixed submission:
M = int(input())
ans = 48 - M
print(ans)