Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import networkx as nx

N, M = map(int,input().split())
G = nx.Graph()

for _ in range(M):
    A, B = map(int,input().split())
    G.add_edge(A, B)

print_str = 'Yes\n'
for i in range(2, N + 1):
    ans = nx.shortest_path(G, source = i, target = 1)
    print_str += (str(ans[1]) + '\n')
        
print(print_str[:-1])

Fixed submission:
from collections import deque
N, M = map(int,input().split())
graph = [[] for i in range(N + 1)]
for _ in range(M):
    A, B = map(int,input().split())
    graph[A].append(B)
    graph[B].append(A)

queue = deque([1]) 
flag = [-1] * (N + 1)

while queue: 
    node = queue.popleft()
    children = graph[node] 
    for child in children:
        if flag[child] == -1:
            flag[child] = node
            queue.append(child)

if -1 in flag[2:]:
    print('No')
else:
    print('Yes')
    print(*flag[2:], sep='\n')

Buggy python submission (verdict: Runtime Error):
import networkx as nx

N, M = map(int,input().split())
G = nx.Graph()

for _ in range(M):
    G.add_edge(map(int,input().split()))

print_str = 'Yes\n'
for i in range(2, N + 1):
    ans = nx.shortest_path(G, source = i, target = 1)
    print_str += (str(ans[1]) + '\n')
        
print(print_str[:-1])

Fixed submission:
from collections import deque
N, M = map(int,input().split())
graph = [[] for i in range(N + 1)]
for _ in range(M):
    A, B = map(int,input().split())
    graph[A].append(B)
    graph[B].append(A)

queue = deque([1]) 
flag = [-1] * (N + 1)

while queue: 
    node = queue.popleft()
    children = graph[node] 
    for child in children:
        if flag[child] == -1:
            flag[child] = node
            queue.append(child)

if -1 in flag[2:]:
    print('No')
else:
    print('Yes')
    print(*flag[2:], sep='\n')

Buggy python submission (verdict: Time Limit Exceeded):
import networkx as nx

N, M = map(int,input().split())
G = nx.Graph()
[G.add_node(i + 1) for i in range(N)]

for _ in range(M):
    A, B = map(int,input().split())
    G.add_edge(A, B)

flag = 1
print_str = 'Yes\n'
for i in range(2, N + 1):
    haspath = nx.has_path(G, source = i, target = 1)
    
    if haspath == False:
        flag = 0
        break
    else:
        ans = nx.shortest_path(G, source = i, target = 1)
        print_str += (str(ans[1]) + '\n')
        
if flag == 1:
    print(print_str[:-1])
else:
    print('No')

Fixed submission:
from collections import deque
N, M = map(int,input().split())
graph = [[] for i in range(N + 1)]
for _ in range(M):
    A, B = map(int,input().split())
    graph[A].append(B)
    graph[B].append(A)

queue = deque([1]) 
flag = [-1] * (N + 1)

while queue: 
    node = queue.popleft()
    children = graph[node] 
    for child in children:
        if flag[child] == -1:
            flag[child] = node
            queue.append(child)

if -1 in flag[2:]:
    print('No')
else:
    print('Yes')
    print(*flag[2:], sep='\n')
Buggy python submission (verdict: Runtime Error):
X = int(input())

N = []
for i in range(66):
    N.append(i**5)

for i in reversed(range(100)):
    for j in reversed(range(i)):
        if X == N[i] - N[j]:
            print(i, j)
            break
        if X == N[i] + N[j]:
            print(i, j * -1)
            break

Fixed submission:
X = int(input())

N = []
for i in range(123):
    N.append(i**5)

for i in reversed(range(123)):
    for j in reversed(range(i)):
        if X == N[i] - N[j]:
            print(i, j)
            break
        if X == N[i] + N[j]:
            print(i, j * -1)
            break
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int,input().split())
mmax=0
N_min = A//B+1
N_max = N if B > N else B
for n in range(N_min, N_max + 1):
    _max = int(A*n/B)-(A*int(n/B))
    if mmax < _max:
        mmax=_max

print(mmax)

Fixed submission:
A, B, N = map(int,input().split())
mmax=0
N_max = N if B > N else B
for n in reversed(range(N_max - A, N_max + 1)):
    _max = int(A*n/B)-(A*int(n/B))
    if mmax < _max:
        mmax=_max

print(mmax)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int,input().split())
mmax=0
N_max = N if B > N else B
for n in range(1, N_max + 1):
    _max = int(A*n/B)-(A*int(n/B))
    if mmax < _max:
        mmax=_max

print(mmax)

Fixed submission:
A, B, N = map(int,input().split())
mmax=0
N_max = N if B > N else B
for n in reversed(range(N_max - A, N_max + 1)):
    _max = int(A*n/B)-(A*int(n/B))
    if mmax < _max:
        mmax=_max

print(mmax)
Buggy python submission (verdict: Runtime Error):
a = int(input())
printf(a * 2 * 3.1415926535)

Fixed submission:
a = int(input())
print(a * 2 * 3.1415926535)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
    print(a.count(i + 1))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
for i in range(n):
    print(c[i + 1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))
for i in range(n):
    print(np.count_nonzero(a == i + 1))

Fixed submission:
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
for i in range(n):
    print(c[i + 1])
Buggy python submission (verdict: Time Limit Exceeded):
import math
import numpy as np
import itertools

k = int(input())
tot = 0

g = np.array([[-1] * (k + 1)] * (k + 1), dtype=np.int64)

for l, m, n in itertools.product(range(1, k + 1), 
                                 range(1, k + 1), range(1, k + 1)):
    if g[l][m] == -1:
        g[l][m] = math.gcd(l, m)
    lm_gcd = g[l][m]

    if g[lm_gcd][n] == -1:
        g[lm_gcd][n] = math.gcd(lm_gcd, n)
    tot += g[lm_gcd][n]
    
print(tot) 

Fixed submission:
from math import gcd

k = int(input())
tot = 0

for l in range(1, k + 1):
    for m in range(1, k + 1):
        for n in range(1, k + 1):
            tot += gcd(gcd(l, m), n)
print(tot)

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
import itertools

for l, m, n in itertools.product(range(k), range(k), range(k))

k = int(input())
tot = 0

# 二つの数のgcdを計算した結果を入れる配列
g = np.array([[-1] * (k + 1)] * (k + 1), dtype=np.int64)

for l in range(1, k + 1):
    for m in range(1, k + 1):
        for n in range(1, k + 1):
            if g[l][m] == -1:
                g[l][m] = math.gcd(l, m)
            lm_gcd = g[l][m]
            
            if g[lm_gcd][n] == -1:
                g[lm_gcd][n] = math.gcd(lm_gcd, n)
            
            tot += g[lm_gcd][n]
print(tot) 

Fixed submission:
from math import gcd

k = int(input())
tot = 0

for l in range(1, k + 1):
    for m in range(1, k + 1):
        for n in range(1, k + 1):
            tot += gcd(gcd(l, m), n)
print(tot)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())
tot = 0

for l in range(1, k + 1):
    for m in range(1, k + 1):
        for n in range(1, k + 1):
            __ = math.gcd(l, m)
            tot += math.gcd(__, n)
print(tot)  

Fixed submission:
from math import gcd

k = int(input())
tot = 0

for l in range(1, k + 1):
    for m in range(1, k + 1):
        for n in range(1, k + 1):
            tot += gcd(gcd(l, m), n)
print(tot)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n - 1):
    for j in range(i + 1, n):
        k = j + j - i

        if k >= n:
            continue

        if (s[i] != s[j]) & (s[i] != s[k]) & (s[j] != s[k]):
            ans -= 1
            
print(ans)

Fixed submission:
n = int(input())
s = str(input())
ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n - 1):
    for j in range(i + 1, n):
        k = j + j - i

        if k >= n:
            break

        if (s[i] != s[j]) & (s[i] != s[k]) & (s[j] != s[k]):
            ans -= 1
            
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
count = {'R': 0, 'G': 0, 'B': 0}
for c in s:
    count[c] += 1
R, G, B = count.values()
ans = R * G * B

for i in range(n - 1):
    for j in range(i + 1, n):
        k = j + j - i
        if k >= n:
            continue
        if (s[i] != s[j]) & (s[i] != s[k]) & (s[j] != s[k]):
            ans -= 1
            
print(ans)

Fixed submission:
n = int(input())
s = str(input())
ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n - 1):
    for j in range(i + 1, n):
        k = j + j - i

        if k >= n:
            break

        if (s[i] != s[j]) & (s[i] != s[k]) & (s[j] != s[k]):
            ans -= 1
            
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = str(input())
count = 0

for i in range(n):
    for j in range(i + 1, n):
        if (s[i] != s[j]):
            for k in range(j + 1, n):
                if (s[i] != s[k]) & (s[j] != s[k]) & (j - i != k - j):
                    count += 1
print(count)

Fixed submission:
n = int(input())
s = str(input())
ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n - 1):
    for j in range(i + 1, n):
        k = j + j - i

        if k >= n:
            break

        if (s[i] != s[j]) & (s[i] != s[k]) & (s[j] != s[k]):
            ans -= 1
            
print(ans)
Buggy python submission (verdict: Runtime Error):
if a[0] == 0:
    print(a[len(a) - 1] - a[1])
else:
    print(a[len(a) - 1] - a[0])

Fixed submission:
import numpy as np

k, n = map(int,input().split())
a = np.array(list(map(int, input().split())))
diff = a[1:] - a[:-1]
diff = np.append(diff, k - a[-1] + a[0])
if np.argmax(diff) == len(a) - 1:
    print(a[-1] - a[0])
else:
    print(k - a[np.argmax(diff) + 1] + a[np.argmax(diff)])
Buggy python submission (verdict: Runtime Error):
def dp_cost(h, dp, i, n):
    
    new_dp = min(dp[1] + abs(h[i] - h[i - 1]), dp[0] + abs(h[i] - h[i - 2]))
    
    if i == n - 1:
        return new_dp

    dp[0] = dp[1]
    dp[1] = new_dp    
    return dp_cost(h, dp, i + 1, n)

n = int(input())
h = list(map(int, input().split()))

if n == 1:
    print(0)
elif n == 2:
    print(abs(h[1] - h[0]))
else:
    dp = [0, abs(h[1] - h[0])]
    print(dp_cost(h, dp, 2, n))

Fixed submission:
import numpy as np

n = int(input())
h = np.array(list(map(int, input().split())))

dp = np.full_like(h, np.inf)

dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, len(h)):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[(len(h) - 1)])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [int(w) for w in input().split()]

ans = 0
mod = 10**9 + 7
for i in range(n-1):
    for j in range(i+1,n):
        ans += (((x[i])%mod)*(x[j]%mod))%mod
        
print((ans)%mod)

Fixed submission:
n = int(input())
x = [int(w) for w in input().split()]

ans = 0
mod = 10**9 + 7
s = sum(x)

for i in range(n):
    ans += ((x[i])**2)

ans = (s**2 - ans)//2
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x = [int(w) for w in input().split()]

d = {}

for i in x:
    d[i] = d.get(i, 0) + 1
    
ans = 0
l = list(d.keys())
l = sorted(l)
#print(l)
for i in range(len(l)-2):
    for j in range(i+1, len(l)-1):
        for k in range(j+1, len(l)):
            if l[k] < l[i] + l[j]:
                #print(l[i], l[j], l[k])
                ans += d[l[i]]*d[l[j]]*d[l[k]]
            
            else:
                break
            
print(ans)

Fixed submission:
x, k, d = map(int, input().split())
x = abs(x)

t = float(abs(x/d))

 
if t >= k:
    print(abs(x - (k*d)))
    
elif (k-int(t))%2==0:
    print(abs(x-abs(int(t)*d)))
    
else:
    print(abs(x-abs(int(t)*d)-d))
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
h=[int(w) for w in input().split()]
x=[[0]*(n) for j in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    x[a-1][b-1]=1
    x[b-1][a-1]=1
ans=0
for i in range(n):
    if sum(x[i])==0:
        #print(i)
        ans+=1
    else:
        t=0
        for j in range(len(x[i])):
            if x[i][j]==1:
                t=max(t,h[j])
        if h[i]>t:
            ans+=1
            #print(i,j)
print(ans)

Fixed submission:
n,m=map(int,input().split())
h=[int(w) for w in input().split()]
x=[0]*(n)
for i in range(m):
    a,b=map(int,input().split())
    
    x[a-1]=max(h[b-1],x[a-1])
    x[b-1]=max(h[a-1],x[b-1])
        
ans=0
for i in range(n):
    if (h[i]>x[i]) or x[i]==0:
        ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
dp=[10**9]*(n)

x=[int(w) for w in input().split()]
dp[0]=0

for i in range(n):
    for j in range(i+1,i+3):
        if j<n:
            dp[j]=min(dp[j],dp[i]+abs(x[i]-x[j]))

print(dp[n-1])

Fixed submission:
n=int(input())
x=[int(q) for q in input().split()]

dp=[0,abs(x[0]-x[1])]
for i in range(2,n):
    y=min(dp[i-2]+abs(x[i]-x[i-2]),dp[i-1]+abs(x[i-1]-x[i]))
    dp.append(y)
print(dp[-1])
Buggy python submission (verdict: Runtime Error):
N=int(input())

for i in reversed(range(1,10)):
    print(i)
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(1)
        else:
            print('Yes')
            exit(1)
    

Fixed submission:
N=int(input())

for i in reversed(range(1,10)):
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(0)
        else:
            print('Yes')
            exit(0)

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

for i in reversed(range(1,10)):
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(0)
    print('Yes')
    exit(1)  


Fixed submission:
N=int(input())

for i in reversed(range(1,10)):
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(0)
        else:
            print('Yes')
            exit(0)

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

for i in reversed(range(1,10)):
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(1)
    print('Yes')
    exit(1)  


Fixed submission:
N=int(input())

for i in reversed(range(1,10)):
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(0)
        else:
            print('Yes')
            exit(0)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import numpy as np
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=list(map(float,item))
npitem=np.array(item)
for i in np.arange(1,M+1):
  npitem[np.argmax(npitem)]=np.floor(np.max(npitem)/2.0)
    
print(int(np.sum(npitem)))












Fixed submission:
import sys
import math
import numpy as np
from heapq import heappush, heappop
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])
sum=0

item=input()
item=item.split()
item=list(map(float,item))

hq=[]
for i in item:
  heappush(hq,-i)
  
for j in range(1,M+1):
  temp=heappop(hq)
  heappush(hq,math.ceil(temp/2.0))
  
for k in range(0,N):
  sum-=heappop(hq)
print(int(sum))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import numpy as np
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=list(map(float,item))
npitem=np.array(item)
for i in np.arange(1,M+1):
  npitem[np.argmax(npitem)]=np.floor(np.max(npitem)/2.0)
    
print(int(np.sum(npitem)))












Fixed submission:
import sys
import math
import numpy as np
from heapq import heappush, heappop
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])
sum=0

item=input()
item=item.split()
item=list(map(float,item))

hq=[]
for i in item:
  heappush(hq,-i)
  
for j in range(1,M+1):
  temp=heappop(hq)
  heappush(hq,math.ceil(temp/2.0))
  
for k in range(0,N):
  sum-=heappop(hq)
print(int(sum))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import numpy as np
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=[float(d) for d in item]
npitem=np.array(item)
for i in np.arange(1,M+1):
  npitem[np.argmax(npitem)]=np.floor(np.max(npitem)/2.0)
    
print(int(np.sum(npitem)))








Fixed submission:
import sys
import math
import numpy as np
from heapq import heappush, heappop
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])
sum=0

item=input()
item=item.split()
item=list(map(float,item))

hq=[]
for i in item:
  heappush(hq,-i)
  
for j in range(1,M+1):
  temp=heappop(hq)
  heappush(hq,math.ceil(temp/2.0))
  
for k in range(0,N):
  sum-=heappop(hq)
print(int(sum))

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])

item=input()
item=item.split()
item=[float(d) for d in item]
for i in range(1,M+1):
    item[item.index(max(item))]=math.floor(max(item)/(2.0))
    
print(int(sum(item)))

Fixed submission:
import sys
import math
import numpy as np
from heapq import heappush, heappop
pos=input()
pos=pos.split()
N=int(pos[0])
M=int(pos[1])
sum=0

item=input()
item=item.split()
item=list(map(float,item))

hq=[]
for i in item:
  heappush(hq,-i)
  
for j in range(1,M+1):
  temp=heappop(hq)
  heappush(hq,math.ceil(temp/2.0))
  
for k in range(0,N):
  sum-=heappop(hq)
print(int(sum))
Buggy python submission (verdict: Runtime Error):
N=input()
N=int(N)
a=input()
a=a.split()
score=[0]*8
legend=0
inrank=0
a=[int(item) for item in a]
for i in range(N):
    p=int(a[i]/400)
    if p >= 8:
        legend+=1
    else:
        score[p]=1
inrank=score.count(1)
if legend!=0:
    if inrank==0:
        t_max=legend
        t_min=0
    else:
        t_max=inrank+legend
        t_min=inrank
print(str(t_min)+" "+str(t_max))





Fixed submission:
N=input()
N=int(N)
a=input()
a=a.split()
score=[0]*8
legend=0
inrank=0
a=[int(item) for item in a]
for i in range(0,N):
    p=int(a[i]/400)
    if p >= 8:
        legend+=1
    else:
        score[p]=1
inrank=score.count(1)
if legend!=0:
    if inrank==0:
        t_max=legend
        t_min=1
    else:
        t_max=inrank+legend
        t_min=inrank
else:
    t_max=inrank
    t_min=inrank
print(str(t_min)+" "+str(t_max))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

total = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        total += a[i] * a[j]
print(total % (pow(10, 9) + 7))

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

s_1 = 0
s_2 = 0
m = 10 ** 9 + 7
for i in range(n):
    s_1 += a[i] % m
    s_2 += (a[i] ** 2) % m
s = (s_1 * s_1 - s_2) * pow(2, -1, m) % m
print(s)
Buggy python submission (verdict: Runtime Error):
import math
a, b = list(map(int, input().split()))
for i in range(1, 1250):
    p8 = math.floor(i * 0.08)
    p10 = math.floor(i * 0.10)
    if p8 == a and p10 == b:
        print(i)
        return
print(-1)

Fixed submission:
import math
a, b = list(map(int, input().split()))
for i in range(1, 1250):
    p8 = math.floor(i * 0.08)
    p10 = math.floor(i * 0.10)
    if p8 == a and p10 == b:
        print(i)
        exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
s = []
c = []
for _ in range(m):
    s_i, c_i = list(input().split())
    s.append(int(s_i))
    c.append(c_i)
for i in range(10 ** n):
    num = list(str(i))
    for j in range(m):
        if len(num) != n or num[s[j] - 1] != c[j]:
            break
    else:
        print(i)
        return
print(-1)

Fixed submission:
n, m = list(map(int, input().split()))
s = []
c = []
for _ in range(m):
    s_i, c_i = list(input().split())
    s.append(int(s_i))
    c.append(c_i)
for i in range(10 ** n):
    num = str(i)
    if len(num) == n and all([num[s[j] - 1] == c[j] for j in range(m)]):
        print(num)
        exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int, input().split()))
c = 1
for i in range(1, n):
    flg = True
    for j in range(0, i):
        if p[j] < p[i]:
            flg = False
            break
    c += 1 if flg else 0
print(c)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
m = [p[0]]
c = 1
for i in range(1, n):
    m.append(min(m[i - 1], p[i]))
    if m[i] == p[i]:
        c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
s = list(input())
for i in range(len(s)):
    if i % 2 == 0 and s[i] == "L":
        print("No")
        return
    if i % 2 != 0 and s[i] == "R":
        print("No")
        return
print("Yes")

Fixed submission:
s = list(input())
for i in range(len(s)):
    if i % 2 == 0 and s[i] == "L":
        print("No")
        exit()
    if i % 2 != 0 and s[i] == "R":
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
n, k, q = list(map(int, input().split()))
p = [k] * n
for _ in range(q):
    a = int(input())
    for j in range(n):
        if j != a - 1:
            p[j] -= 1
for c in p:
    print('Yes' if c > 0 else 'No')

Fixed submission:
n, k, q = list(map(int, input().split()))
pp = [0] * n
for _ in range(q):
    a = int(input())
    pp[a - 1] += 1
for i in range(n):
    print('Yes' if k - (q - pp[i]) > 0 else 'No')
Buggy python submission (verdict: Runtime Error):
n, x = list(map(int, input().split()))
l = list(map(int, input().split()))
d = 0
b = 0
while d <= x and b <= n + 1:
    d += l[b]
    b += 1
print(b)

Fixed submission:
n, x = list(map(int, input().split()))
l = list(map(int, input().split()))
d = [0]
for i in range(len(l)):
    d.append(d[i] + l[i])
print(len(list(filter(lambda d_i: d_i <= x, d))))
Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt
n = int(input())

n_cnt = [0]*n

for x in range(1, int(sqrt(2*n))+1):
    for y in range(1, int(sqrt(2*n))+1):
        for z in range(1, int(sqrt(2*n))+1):
            t = (x+y)**2 + (y+z)**2 + (z+x)**2
            if t % 2 == 0 and t // 2 - 1 < n:
                n_cnt[t // 2 - 1] += 1


for i in range(n):
    print(n_cnt[i])


Fixed submission:
from math import sqrt
n = int(input())

n_cnt = [0]*n

for x in range(1, int(sqrt(2*n))+1):
    for y in range(1, int(sqrt(2*n))+1):
        for z in range(1, int(sqrt(2*n))+1):
            t = (x+y)**2 + (y+z)**2 + (z+x)**2
            if t % 2 == 0 and t // 2 - 1 < n:
                n_cnt[t // 2 - 1] += 1


for i in range(n):
    print(n_cnt[i])

Buggy python submission (verdict: Time Limit Exceeded):
from math import sqrt
n = int(input())

for i in range(1, n+1):
    cnt = 0
    for x in range(1, int(sqrt(2*i))+1):
        for y in range(1, x+1):
            for z in range(1, y+1):
                if (x+y)**2 + (y+z)**2 + (z+x)**2 == 2*i:
                    if x == y == z:
                        cnt += 1
                    else:
                        cnt += 3
    print(cnt)

Fixed submission:
from math import sqrt
n = int(input())

n_cnt = [0]*n

for x in range(1, int(sqrt(2*n))+1):
    for y in range(1, int(sqrt(2*n))+1):
        for z in range(1, int(sqrt(2*n))+1):
            t = (x+y)**2 + (y+z)**2 + (z+x)**2
            if t % 2 == 0 and t // 2 - 1 < n:
                n_cnt[t // 2 - 1] += 1


for i in range(n):
    print(n_cnt[i])
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))

l = list(range(1, 101))

p = list(set(l)-set(p))
sa = [abs(x - p[i]) for i in range(len(p))]
sa_min = min(sa)

for i in range(len(p)):
    if sa[i] == sa_min:
        print(p[i])
        break

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

cnt = 0
while True:
    if x+cnt not in p:
        print(x+cnt)
        break
    cnt *= -1
    if x+cnt not in p:
        print(x+cnt)
        break
    cnt *= -1
    cnt -= 1

Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))

l = list(range(1, 101))

p = list(set(l)-set(p))
sa = [abs(x - p[i]) for i in range(len(p))]
sa_min = min(sa)

for i in range(len(l)):
    if sa[i] == sa_min:
        print(p[i])
        break

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

cnt = 0
while True:
    if x+cnt not in p:
        print(x+cnt)
        break
    cnt *= -1
    if x+cnt not in p:
        print(x+cnt)
        break
    cnt *= -1
    cnt -= 1