Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
X,N = list(map(int,input().split()))
if N == 0:
  print(X)
  exit()
P = sorted(list(map(int,input().split())))
ans1 = P[0] - 1
ans2 = P[-1] + 1
isx = 0
for i in range(1,N+1):
  if (P[i]-X) > 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[i-1] != (P[i]-1):
    ans1 = P[i] -1
  if P[i] == X:
    isx = 1
    break

for i in range(1,N+1):
  if (P[-i]-X) < 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[-i+1] != (P[-i]+1):
    ans2 = P[-i] + 1
  if P[-i] == X:
    isx = 1
    break

if not isx:
  print(X)
  exit()

aa1 = abs(X-ans1)
aa2 = abs(X-ans2)
if aa1 == aa2:
  print(ans1)
elif aa1 > aa2:
  print(ans2)
else:
  print(ans1)


Fixed submission:
X,N = list(map(int,input().split()))
if N == 0:
  print(X)
  exit()
P = sorted(list(map(int,input().split())))
ans1 = P[0] - 1
ans2 = P[-1] + 1
isx = 0
for i in range(1,N):
  if (P[i]-X) > 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[i-1] != (P[i]-1):
    ans1 = P[i] -1
  if P[i] == X:
    isx = 1
    break

for i in range(1,N+1):
  if (P[-i]-X) < 0:
    if not isx:
      ans1 = X
      break
    else:
      break
  if P[-i+1] != (P[-i]+1):
    ans2 = P[-i] + 1
  if P[-i] == X:
    isx = 1
    break

if not isx:
  print(X)
  exit()

aa1 = abs(X-ans1)
aa2 = abs(X-ans2)
if aa1 == aa2:
  print(ans1)
elif aa1 > aa2:
  print(ans2)
else:
  print(ans1)
Buggy python submission (verdict: Runtime Error):
import numpy as np
N = input()
X = list(map(int,input().split()))

muf = np.floor(np.mean(X))
muc = np.ceil(np.mean(X))
ansf = 0
ansc = 0
for i in X:
    ansf += (muf-i)**2
    ansc += (muc-i)**2

print(min(int(ansf),int(ansc)))

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

s = 0
for i in X:
    s += i
s = s/N

muf = math.floor(s)
muc = math.ceil(s)
ansf = 0
ansc = 0
for i in X:
    ansf += (muf-i)**2
    ansc += (muc-i)**2

print(min(int(ansf),int(ansc)))
Buggy python submission (verdict: Time Limit Exceeded):
H = int(input())
div2 = 0
ans = 0
while True:
    H = H // 2
    div2 += 1
    ans += 2**(div2)
    if H == 1:
        break
print(ans+1)

Fixed submission:
H = int(input())
div2 = 0
ans = 0
if H == 1:
    print(1)
    exit()
while True:
    H = H // 2
    div2 += 1
    ans += 2**(div2)
    if H == 1:
        break
print(ans+1)
Buggy python submission (verdict: Runtime Error):
A=int(inpur())
B=int(inpur())
print(6-A-B)

Fixed submission:
A = int(input())
B = int(input())

if A == 1 and B== 2:
    print(3)
if A == 1 and B== 3:
    print(2)
if A == 2 and B== 1:
    print(3)
if A == 2 and B== 3:
    print(1)
if A == 3 and B== 1:
    print(2)
if A == 3 and B== 2:
    print(1)
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

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

print(lcm(A,B))

Fixed submission:
import fractions

def lcm(x, y):
    ans  =(x * y) // fractions.gcd(x, y)
    return ans

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

print(lcm(A,B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
for i in range(N):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        for k in range(j+1,N):
            c = L[k]
            if (c < a + b):
                ans += 1
            else:
                break
print(ans)


Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
for i in range(N):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        ans += bisect_left(L[j+1:], a+b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
for i in range(N):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        for k in range(j+1,N):
            c = L[k]
            if (c < a + b):
                ans += 1
            else:
                break
print(ans)


Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
for i in range(N):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        ans += bisect_left(L[j+1:], a+b)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
for i in range(N):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        for k in range(j+1,N):
            c = L[k]
            if (c < a + b) and (b < a + c) and (a < b + c):
                ans += 1
            else:
                break
print(ans)


Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
for i in range(N):
    for j in range(i+1,N):
        a = L[i]
        b = L[j]
        ans += bisect_left(L[j+1:], a+b)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
D = [[0] * n for i in range(n)]
 
for i in range(n):
    D[0][i] = int(s[0]==s[i])
    D[i][0] = int(s[0]==s[i])
D[0][0] = 0

for i in range(1,n):
    for j in range(i+1,n):
        print(f"i,j = {i,j}")
        mae = D[i-1][j-1]
        print(f"mae = {mae}")
        if s[i] == s[j]:
            if j-i <= mae:
                D[i][j] = mae
            else:
                D[i][j] = mae + 1

print(max([max(D[i]) for i in range(n)]))


Fixed submission:
n = int(input())
s = input()
D = [[0] * n for i in range(n)]
 
for i in range(n):
    D[0][i] = int(s[0]==s[i])
    D[i][0] = int(s[0]==s[i])
D[0][0] = 0

for i in range(1,n):
    for j in range(i+1,n):
        mae = D[i-1][j-1]
        if s[i] == s[j]:
            if j-i <= mae:
                D[i][j] = mae
            else:
                D[i][j] = mae + 1

print(max([max(D[i]) for i in range(n)]))
Buggy python submission (verdict: Time Limit Exceeded):
import copy
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

for i in range(n):
    b = copy.deepcopy(a)
    b.pop(i)
    b.sort()
    print(b[-1])

Fixed submission:
import copy
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
b = copy.deepcopy(a)
b.sort()
firint = b[-1]
secint = b[-2]

for i in a:
    if i == firint:
        print(secint)
    else:
        print(firint)
Buggy python submission (verdict: Time Limit Exceeded):
import math
l,r = list(map(int,input().split()))
MOD = 2019
res = 100000000000000000000000000000000
ans = []
for i in range(l,r+1):
    for j in range(i+1,r+1):
        if (i*j)%2019 < res:
            res = (i*j)%2019
print(res)


Fixed submission:
import math
l,r = list(map(int,input().split()))
MOD = 2019
res = 100000000000000000000000000000000
ans = []
for i in range(l,r+1):
    if res == 0:
        break
    for j in range(i+1,r+1):
        if res == 0:
            break
        if (i*j)%2019 < res:
            res = (i*j)%2019
print(res)
Buggy python submission (verdict: Runtime Error):
a,b,c,d=map(int,input().split())

e = c*d//gcd(c,d)

b_c = b//c
b_d = b//d
b_e = b//e
a_c = (a-1)//c
a_d = (a-1)//d
a_e = (a-1)//e

print(b-a+1 - (b_c - a_c) - (b_d - a_d) + (b_e - a_e))

Fixed submission:
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while a%b!=0:
        a,b = b,a%b
    return b

a,b,c,d=map(int,input().split())

e = c*d//gcd(c,d)

b_c = b//c
b_d = b//d
b_e = b//e
a_c = (a-1)//c
a_d = (a-1)//d
a_e = (a-1)//e

print(b-a+1 - (b_c - a_c) - (b_d - a_d) + (b_e - a_e))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

A.sort()
A.reverse()
ans = 0
ans += A[0]

if len(A) % 2 == 0:
  tmp = 0
  for i in range(1, int((N-2)/2)+1):
    tmp += A[i] * 2
else:
  for i in range(1, int((N-1)/2)+1):
    tmp += A[i] * 2
  tmp -= A[int((N-3)/2)]

ans += tmp
print(ans)


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

A.sort()
A.reverse()
ans = 0
ans += A[0]

if len(A) % 2 == 0:
  tmp = 0
  for i in range(1, int((N-2)/2)+1):
    tmp += A[i] * 2
else:
  tmp = 0
  for i in range(1, int((N-1)/2)+1):
    tmp += A[i] * 2
  tmp -= A[int((N-1)/2)]

ans += tmp
print(ans)

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

A.sort()
A.reverse()
ans = 0
ans += A[0]

if len(A) % 2 == 0:
  tmp = 0
  for i in range(1, int((N-2)/2)+1):
    tmp += A[i] * 2
else:
  for i in range(1, int((N-3)/2)+1):
    tmp += A[i] * 2
  tmp += A[int((N-3)/2)+1]

ans += tmp
print(ans)

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

A.sort()
A.reverse()
ans = 0
ans += A[0]

if len(A) % 2 == 0:
  tmp = 0
  for i in range(1, int((N-2)/2)+1):
    tmp += A[i] * 2
else:
  tmp = 0
  for i in range(1, int((N-1)/2)+1):
    tmp += A[i] * 2
  tmp -= A[int((N-1)/2)]

ans += tmp
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

A.sort()
cnt = [0] * (A[-1]+1)

for a in A:
  cnt[::a] += 1

ans = 0
for a in A:
  if cnt[a] == 1:
    ans += 1

print(ans)

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

A.sort()
cnt = [0] * (A[-1]+1)

for a in A:
  for i in range(a, A[-1]+1, a):
    cnt[i] += 1

ans = 0
for a in A:
  if cnt[a] == 1:
    ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
K = min(41, K)
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)
ans = [N] * N

def operation():
  global A, B, N
  for i in range(1, N+1):
    left = max(1, math.ceil(i - A[i] - 0.5))
    right = min(N, math.floor(i + A[i] + 0.5))
    B[left] += 1
    if right+1 <= N:
      B[right+1] -= 1
  for i in range(1, N+1):
    B[i] += B[i-1]


operation()

#print(A)
#print(B)

for _ in range(K):
  A = B
  B = [0] * (N+1)
  operation()

print(*A[1:])



Fixed submission:
S = input()

print(S[:3])

Buggy python submission (verdict: Runtime Error):
import math
import sys

N, K = map(int, input().split())
if K > 41:
  K = 41
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N+1)
ans = [N] * N

def operation():
  global A, B, N
  for i in range(1, N+1):
    left = max(1, math.ceil(i - A[i] - 0.5))
    right = min(N, math.floor(i + A[i] + 0.5))
    B[left] += 1
    B[right] -= 1
  for i in range(1, N+1):
    B[i] += B[i-1]


operation()

#print(A)
#print(B)

for _ in range(K):
  for i in range(1, N+1):
    if A[i] != B[i]:
      A[i] = B[i]
    B[i] = 0
  operation()

print(A[1:])



Fixed submission:
S = input()

print(S[:3])
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if len(T)-len(S) == 1:
  print(Yes)
else:
  print(No)

Fixed submission:
S = input()
T = input()
T.rstrip()
 
if T[:-1] == S:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, M, Q = map(int, input().split())
List = [list(map(int, input().split())) for i in range(Q)]
Max = 0

for a in itertools.combinations_with_replacement(range(1, M+1), N):
  A = list(a)
  A.sort()
  point = 0
  for i in range(Q):
    ai = List[i][0]
    bi = List[i][1]
    if ai < 1 or N < ai or bi < 1 or N < bi:
      continue
    if A[bi-1]-A[ai-1] == List[i][2]:
      point += List[i][3]
  if Max < point:
    Max = point

print(Max)

Fixed submission:
import itertools
N, M, Q = map(int, input().split())
List = [list(map(int, input().split())) for i in range(Q)]
Max = 0
 
for a in itertools.combinations_with_replacement(range(1, M+1), N):
  A = list(a)
  A.sort()
  point = 0
  for i in range(Q):
    ai = List[i][0]
    bi = List[i][1]
    if ai < 1 or N < ai or bi < 1 or N < bi:
      continue
    if A[bi-1]-A[ai-1] == List[i][2]:
      point += List[i][3]
  if Max < point:
    Max = point
 
print(Max)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N, M, Q = map(int, input().split())
List = [list(map(int, input().split())) for i in range(Q)]
Max = 0

for a in itertools.combinations_with_replacement(range(1, M+1), N):
  A = list(a)
  A.sort()
  point = 0
  for i in range(Q):
    ai = List[i][0]
    bi = List[i][1]
    if 1 <= ai <= N and 1 <= bi <= N:
      if A[bi-1]-A[ai-1] == List[i][2]:
        point += List[i][3]
    if Max < point:
      Max = point

print(Max)


Fixed submission:
import itertools
N, M, Q = map(int, input().split())
List = [list(map(int, input().split())) for i in range(Q)]
Max = 0
 
for a in itertools.combinations_with_replacement(range(1, M+1), N):
  A = list(a)
  A.sort()
  point = 0
  for i in range(Q):
    ai = List[i][0]
    bi = List[i][1]
    if ai < 1 or N < ai or bi < 1 or N < bi:
      continue
    if A[bi-1]-A[ai-1] == List[i][2]:
      point += List[i][3]
  if Max < point:
    Max = point
 
print(Max)
Buggy python submission (verdict: Runtime Error):
import itertools
 
N = int(input)
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutation(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
Ave = dis / N
print(Ave)

Fixed submission:
import itertools
 
N = int(input())
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutations(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
ave = dis / len(list(itertools.permutations(range(N))))
print(ave)

Buggy python submission (verdict: Runtime Error):
import itertools
 
N = int(input)
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutations(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
Ave = dis / N
print(Ave)

Fixed submission:
import itertools
 
N = int(input())
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutations(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
ave = dis / len(list(itertools.permutations(range(N))))
print(ave)

Buggy python submission (verdict: Runtime Error):
import itertools

N = int(input)
coords = [list(map(int, input().split())) for i in range(N)]
dis = 0
n = list(range(N))

for order in itertools.permutations(n):
  for i in range(1, N):
    dis += ((coords[order[i]][0]-coords[order[i-1]][0])**2 + (coords[order[i]][1]-coords[order[i-1]][1])**2)**0.5

ave = dis / N
print(ave)

Fixed submission:
import itertools
 
N = int(input())
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutations(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
ave = dis / len(list(itertools.permutations(range(N))))
print(ave)

Buggy python submission (verdict: Runtime Error):
import itertools

N = int(input)
coords = [list(map(int, input().split())) for i in range(N)]
dis = 0
n = list(range(N))

for order in itertools.permutations(n):
  for i in range(1, N):
    dis += ((coords[order[i]][0]-coords[order[i-1]][0])**2 + (coords[order[i]][1]-coords[order[i-1]][1])**2)**0.5

ave dis / N
print(ave)

Fixed submission:
import itertools
 
N = int(input())
coord = [list(map(int, input().split())) for _ in range(N)]
dis = 0

for order in itertools.permutations(range(N)):
  for i in range(1, N):
    dis += ((coord[order[i]][0]-coord[order[i-1]][0])**2 + (coord[order[i]][1]-coord[order[i-1]][1])**2)**0.5
 
ave = dis / len(list(itertools.permutations(range(N))))
print(ave)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
min = N - 1
for i in range(N):
  cnt = S[:i].count('W') + S[i+1:].count('E')
  if cnt < min:
    min = cnt
print(min)

Fixed submission:
N = int(input())
S = list(input())
W = 0
E = S[1:].count('E')
Turn = []
Turn.append(E)

for i in range(1, N):
  if S[i] == 'E':
    E -= 1
  if S[i-1] == 'W':
    W += 1
  Turn.append(E+W)

print(min(Turn))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
min = N - 1
for i in range(N-1):
  cnt = S[:i].count('W') + S[i+1:].count('E')
  if cnt < min:
    min = cnt
print(min)

Fixed submission:
N = int(input())
S = list(input())
W = 0
E = S[1:].count('E')
Turn = []
Turn.append(E)

for i in range(1, N):
  if S[i] == 'E':
    E -= 1
  if S[i-1] == 'W':
    W += 1
  Turn.append(E+W)

print(min(Turn))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
min = N - 1
for i in range(N-1):
  cnt = S[:i].count('W') + S[i+1:].count('E')
  if cnt < min:
    min = cnt
print(min)

Fixed submission:
N = int(input())
S = list(input())
W = 0
E = S[1:].count('E')
Turn = []
Turn.append(E)

for i in range(1, N):
  if S[i] == 'E':
    E -= 1
  if S[i-1] == 'W':
    W += 1
  Turn.append(E+W)

print(min(Turn))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
max = N - 1
for i in range(N-1):
  cnt = S[:i].count('W') + S[i+1:].count('E')
  if cnt < min:
    min = cnt
print(min)

Fixed submission:
N = int(input())
S = list(input())
W = 0
E = S[1:].count('E')
Turn = []
Turn.append(E)

for i in range(1, N):
  if S[i] == 'E':
    E -= 1
  if S[i-1] == 'W':
    W += 1
  Turn.append(E+W)

print(min(Turn))

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
max = N - 1
for i in range(N):
  cnt = S[:i].count('W') + S[i+1:].count('E')
  if cnt < min:
    min = cnt
print(min)

Fixed submission:
N = int(input())
S = list(input())
W = 0
E = S[1:].count('E')
Turn = []
Turn.append(E)

for i in range(1, N):
  if S[i] == 'E':
    E -= 1
  if S[i-1] == 'W':
    W += 1
  Turn.append(E+W)

print(min(Turn))
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = [int(input()) for i in range(N)]
i = 0

while cnt <= N:
  lgt = a[i]
  cnt += 1
  if lgt == 2:
    print(cnt)
    break
  i = lgt - 1
else:
  print(-1)

Fixed submission:
N = int(input())
a = [int(input()) for i in range(N)]
i = 0
cnt = 0

while cnt <= N:
  lgt = a[i]
  cnt += 1
  if lgt == 2:
    print(cnt)
    break
  i = lgt - 1
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

def f(n):
  lx = math.ceil(math.sqrt(n))
  ans = 0

  for x in range(1, lx):
    x2 = x ** 2

    ly = math.ceil(math.sqrt(max(1, n - x2)))

    for y in range(1, ly):
      y2 = y ** 2
      lz = math.ceil(math.sqrt(max(1, n - x2 - y2 - (x * y))))

      for z in range(1, lz):
        z2 = z ** 2

        if x2 + y2 + z2 + x * y + y * z + z * x == n:
          ans += 1

  return ans

def main():
  N = int(input())

  for i in range(1, N+1):
    print(f(i))

if __name__ == "__main__":
  main()

Fixed submission:
import math


def main():
  N = int(input())

  dp = [0] * N

  lx = math.ceil(math.sqrt(N))

  for x in range(1, lx):
    x2 = x ** 2

    ly = math.ceil(math.sqrt(max(1, N - x2)))

    for y in range(1, ly):
      y2 = y ** 2
      lz = math.ceil(math.sqrt(max(1, N - x2 - y2 - (x * y))))

      for z in range(1, lz):
        z2 = z ** 2

        v = x2 + y2 + z2 + x * y + y * z + z * x
        if(v <= N):
          dp[v-1] += 1

  for v in dp:
    print(v)

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import math

def f(n):
  max_loop = math.ceil(math.sqrt(n))
  ans = 0

  for x in range(1, max_loop):
    x2 = x ** 2

    for y in range(1, max_loop):
      y2 = y ** 2

      for z in range(1, max_loop):
        z2 = z ** 2

        if x2 + y2 + z2 + x * y + y * z + z * x == n:
          ans += 1

  return ans

def main():
  N = int(input())

  for i in range(1, N+1):
    print(f(i))

if __name__ == "__main__":
  main()

Fixed submission:
import math


def main():
  N = int(input())

  dp = [0] * N

  lx = math.ceil(math.sqrt(N))

  for x in range(1, lx):
    x2 = x ** 2

    ly = math.ceil(math.sqrt(max(1, N - x2)))

    for y in range(1, ly):
      y2 = y ** 2
      lz = math.ceil(math.sqrt(max(1, N - x2 - y2 - (x * y))))

      for z in range(1, lz):
        z2 = z ** 2

        v = x2 + y2 + z2 + x * y + y * z + z * x
        if(v <= N):
          dp[v-1] += 1

  for v in dp:
    print(v)

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
import math

def f(n):
  mx = math.ceil(math.sqrt(n))
  ans = 0

  for x in range(1, mx + 1):
    x2 = x ** 2
    my = math.ceil(max(0, n - x2))

    for y in range(1, my + 1):
      y2 = y ** 2
      mz = math.ceil(max(0, my - y2));

      for z in range(1, mz + 1):
        z2 = z ** 2

        if x2 + y2 + z2 + x * y + y * z + z * x == n:
          ans += 1

  return ans

def main():
  N = int(input())

  for i in range(1, N+1):
    print(f(i))

if __name__ == "__main__":
  main()

Fixed submission:
import math


def main():
  N = int(input())

  dp = [0] * N

  lx = math.ceil(math.sqrt(N))

  for x in range(1, lx):
    x2 = x ** 2

    ly = math.ceil(math.sqrt(max(1, N - x2)))

    for y in range(1, ly):
      y2 = y ** 2
      lz = math.ceil(math.sqrt(max(1, N - x2 - y2 - (x * y))))

      for z in range(1, lz):
        z2 = z ** 2

        v = x2 + y2 + z2 + x * y + y * z + z * x
        if(v <= N):
          dp[v-1] += 1

  for v in dp:
    print(v)

if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
import math

def main():
  N = int(input())
  A = list(map(int, input().split()))
  MAX = A[-1]
  dp = [True] * MAX
  c = [0] * MAX
  ans = 0

  A.sort()

  for v in A:
    c[v - 1] += 1

    if(not dp[v - 1] and c[v - 1] > 1):
      continue

    e = v * 2    
    while e < MAX:
      dp[e-1] = False
      e += v
      
  for v in A:
    if dp[v - 1] and c[v - 1] == 1:
      ans += 1

  print(ans)

if __name__ == "__main__":
  main()

Fixed submission:
import math

def main():
  N = int(input())
  A = list(map(int, input().split()))
  A.sort()
  MAX = A[-1]
  dp = [True] * MAX
  c = [0] * MAX
  ans = 0

  for a in A:
    i = a - 1
    c[i] += 1

    if((not dp[i]) and c[i] > 1):
      continue

    e = a * 2    
    while e <= MAX:
      dp[e-1] = False
      e += a
      
  for v in A:
    i = v - 1
    if dp[i] and c[i] == 1:
      ans += 1

  print(ans)

if __name__ == "__main__":
  main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  N = int(input())
  A = list(map(int, input().split()))

  m = 10 ** 18
  ans = A[0]

  for i in range(1, N):
    ans *= A[i]

  if(ans > m):
    ans = -1

  print(ans)

if __name__ == "__main__":
  main()

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

  A.sort()

  m = 10 ** 18
  ans = A[0];

  if(A[0] == 0):
    ans = 0;
  else:
    for i in range(1, N):
      ans *= A[i]

      if(ans > m):
        ans = -1
        break

  print(ans)

if __name__ == "__main__":
  main()

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

  m = 10 ** 18
  ans = A[0]

  for i in range(1, N):
    ans *= A[i]

  if(ans > m):
    ans = -1

  print(ans)

if __name__ == "__main__":
  main()

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

  A.sort()

  m = 10 ** 18
  ans = A[0];

  if(A[0] == 0):
    ans = 0;
  else:
    for i in range(1, N):
      ans *= A[i]

      if(ans > m):
        ans = -1
        break

  print(ans)

if __name__ == "__main__":
  main()