Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = 0
for i in range(1000):
    if i<10: i = "00"+str(i)
    elif i<100: i = "0"+str(i)
    else: i = str(i)
    for j in range(n-2):
        if s[j] == i[0]:
            for k in range(j+1, n-1):
                if s[k] == i[1]:
                    for l in range(k+1, n):
                        if s[l] == i[2]:
                            ans += 1
                            break
                    break
            break
print(ans)

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    x = s.find(num[0])
    y = s.find(num[1], x+1)
    z = s.find(num[2], y+1)
    if x != -1 and y != -1 and z != -1:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = []
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            res = s[i]+s[j]+s[k]
            if not res in ans:
                ans.append(res)
print(len(ans))

Fixed submission:
n = int(input())
s = input()
ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    x = s.find(num[0])
    y = s.find(num[1], x+1)
    z = s.find(num[2], y+1)
    if x != -1 and y != -1 and z != -1:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
d = "ABCDEFGHIJKLMNOPQRSTUVXYZ"
print(''.join([d[(d.index(i) + n) % 26] for i in s]))

Fixed submission:
n = int(input())
s = input()
d = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
print(''.join([d[(d.index(i) + n) % 26] for i in s]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
d = "ABCDEFGHIJKLMNOPQRSTUVXYZ"
print("".join([d[(d.index(i)+n)%26] for i in s]))

Fixed submission:
n = int(input())
s = input()
d = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
print(''.join([d[(d.index(i) + n) % 26] for i in s]))
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
for i in range(int(n**0.5), 0, -1):
    if n%i==0:
        j=n//i
        print(i+j-2)
        sys.exit()

Fixed submission:
a, b = map(int, input().split())
n = a*b
if a > 9 or b > 9:
  print(-1)
else:
  print(n)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = n-1
for i in range(1, n//2+1):
    for j in range(i, n//2+1):
        if n == i*j:
            ans_ = i + j -2
            ans = min(ans, ans_)
print(ans)

Fixed submission:
import sys
n = int(input())
for i in range(int(n**0.5), 0, -1):
    if n%i==0:
        j=n//i
        print(i+j-2)
        sys.exit()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
l = list(map(int, input().split()))
count = 0
for a, b, c in itertools.combinations(l, 3):
    if a < b+c and b < a+c and c < a+b:
        count += 1
print(count)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()
count = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        a = l[i]+l[j]
        index = bisect.bisect_left(l, a)
        count += index - j -1
print(count)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
al = [1]
bl = [1]
for i in range(2, min(int(a**0.5+1), int(b**0.5+1))):
    if a%i==0:
        resa, resb = a, b
        while resa%i==0:
            resa //= i
        al.append(i)
    if b%i==0:
        while resb%i==0:
            resb //= i
        bl.append(i)
print(len(set(al)&set(bl))) 

Fixed submission:
def prime_factorize(n):
    res = []
    while n % 2 == 0:
        res.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            res.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        res.append(n)
    return res
from fractions import gcd
a, b = map(int, input().split())
print(len(set(prime_factorize(gcd(a, b))))+1)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
for i in range(m):
    a[0] = a[0] // 2
    a.sort(reverse=True)
print(sum(a))

Fixed submission:
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for i in range(m):
    heapq.heappush(a, ((heapq.heappop(a)*-1//2)*(-1)))
print(sum(a)*-1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
ans = []
res = 0
nh = h[0]
for i in range(1, n):
    if nh >= h[i]:
        res += 1
        nh = h[i]
    else:
        res = 0
        nh = h[i]
    ans.append(res)
print(max(ans))

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
ans = []
res = 0
nh = h[0]
for i in range(1, n):
    if nh >= h[i]:
        res += 1
        nh = h[i]
    else:
        ans.append(res)
        res = 0
        nh = h[i]
ans.append(res)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s = []
for _ in range(n):
    s.append(list(input()))
count = 0
for i in range(n-1):
    for j in range(i+1, n):
        if Counter(s[i]) == Counter(s[j]):
            count += 1
print(count)

Fixed submission:
n = int(input())
d = {}
ans = 0
for i in range(n):
    s = "".join(sorted(input()))
    if s in d:
        d[s] += 1
        ans += d[s]
    else:
        d[s] = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
import heapq
n, m = map(int, input().split())
ab = [[] for _ in range(m+1)]
for _ in range(n):
    a, b = map(int, input().split())
    ab[a-1].append(-b)
heap = []
ans = 0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(heap, j)
    if heap:
        res = heapq.heappop(heap)
        ans += -res
print(ans)

Fixed submission:
import heapq
n, m = map(int, input().split())
ab = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    if m >= a:
        ab[a-1].append(-b)
heap = []
ans = 0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(heap, j)
    if heap:
        res = heapq.heappop(heap)
        ans += -res
print(ans)

Buggy python submission (verdict: Runtime Error):
import heapq
n, m = map(int, input().split())
ab = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    ab[a-1].append(-b)
heap = []
ans = 0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(heap, j)
    if heap:
        res = heapq.heappop(heap)
        ans += -res
print(ans)

Fixed submission:
import heapq
n, m = map(int, input().split())
ab = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    if m >= a:
        ab[a-1].append(-b)
heap = []
ans = 0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(heap, j)
    if heap:
        res = heapq.heappop(heap)
        ans += -res
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))
ab.sort(key=lambda x:x[1], reverse=True)
ans = 0
for i in range(1, m+1):
    for j in range(len(ab)):
        if ab[j][0] <= i:
            res = ab.pop(j)
            ans += res[1]
            break
print(ans)

Fixed submission:
import heapq
n, m = map(int, input().split())
ab = [[] for _ in range(m)]
for _ in range(n):
    a, b = map(int, input().split())
    if m >= a:
        ab[a-1].append(-b)
heap = []
ans = 0
for i in range(m):
    for j in ab[i]:
        heapq.heappush(heap, j)
    if heap:
        res = heapq.heappop(heap)
        ans += -res
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a1 = int(input())
a2 = int(input())
if a[0] >= a[1]:
    maxa1 = a1
    maxa2 = a2
    res = 0
else:
    maxa1 = a2
    maxa2 = a1
    res = 1

for i in range(2, n):
    a_ = int(input())
    if maxa1 <= a_:
        maxa2 = maxa1
        maxa1 = a_
        res = i
    elif maxa2 <= a_:
        maxa2 = a_

for i in range(n):
    if i == res:
        print(maxa2)
    else:
        print(maxa1)

Fixed submission:
n = int(input())
a1 = int(input())
a2 = int(input())
if a1 >= a2:
    maxa1 = a1
    maxa2 = a2
    res = 0
else:
    maxa1 = a2
    maxa2 = a1
    res = 1

for i in range(2, n):
    a_ = int(input())
    if maxa1 <= a_:
        maxa2 = maxa1
        maxa1 = a_
        res = i
    elif maxa2 <= a_:
        maxa2 = a_

for i in range(n):
    if i == res:
        print(maxa2)
    else:
        print(maxa1)
Buggy python submission (verdict: Runtime Error):
l, r = map(int, input().split())
if (r-l) >= 2019:
    print(0
    exit()
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)
print(ans)

Fixed submission:
l, r = map(int, input().split())
if (r-l) >= 2019:
    print(0)
    exit()
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
if (r-l) >= 2019:
    print(0)
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)
print(ans)

Fixed submission:
l, r = map(int, input().split())
if (r-l) >= 2019:
    print(0)
    exit()
ans = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)
print(ans)
Buggy python submission (verdict: Runtime Error):
def nCr(n, r, mod):
    x, y = 1, 1
    for r_ in range(1, r+1):
        x = x*(n+1-r_)%mod
        y = y*r_%mod
    return x*pow(y, mod-2, mod)%mod

n, k = map(int, input().split())
for i in range(1, k+1): print(nCr(n-k+1, i, mod)*nCr(k-1, i-1, mod))

Fixed submission:
def nCr(n, r, mod):
    x, y = 1, 1
    for r_ in range(1, r+1):
        x = x*(n+1-r_)%mod
        y = y*r_%mod
    return x*pow(y, mod-2, mod)%mod

n, k = map(int, input().split())
mod = 10**9+7
for i in range(1, k+1): print(nCr(n-k+1, i, mod)*nCr(k-1, i-1, mod)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
d = [0]*(10**5)
for _ in range(m):
    l, r = map(int, input().split())
    for i in range(l-1, r):
        d[i] += 1
ans = 0
for i in d:
    if i == m:
        ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
for _ in range(1, m):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)
if r-l<0:
    print(0)
else:
    print(r-l+1)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
d = [0]*(10**5)
for _ in range(m):
    l, r = map(int, input().split())
    for i in range(l-1, r):
        d[i] += 1
ans = 0
for i in d:
    if i == m:
        ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
l, r = map(int, input().split())
for _ in range(1, m):
    l_, r_ = map(int, input().split())
    l = max(l, l_)
    r = min(r, r_)
if r-l<0:
    print(0)
else:
    print(r-l+1)
Buggy python submission (verdict: Runtime Error):
a = [int(input()) for _ in range(6)]
for i in range(4):
    for j in range(i+1, 5):
        if abs(i-j) > k:
            print(":(")
            exit()
print("Yay!")

Fixed submission:
a = [int(input()) for _ in range(6)]
for i in range(4):
    for j in range(i+1, 5):
        if abs(a[i]-a[j]) > a[5]:
            print(":(")
            exit()
print("Yay!")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(1, n):
    for j in range(min(i, k)):
        dp[i] = min(dp[i], dp[i-j-1]+abs(h[i-j-1]-h[i]))
print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(1, n):
    for j in range(min(i, k)):
        dp[i] = min(dp[i], dp[i-j-1]+abs(h[i-j-1]-h[i]))
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [0]*n
dp[1] = abs(h[0]-h[1])
for i in range(2, n):
    res = 10**9+7
    for j in range(1, min(k+1, i+1)):
        res_ = dp[i-j]+abs(h[i]-h[i-j])
        res = min(res, res_)
    dp[i] = res
print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')]*n
dp[0] = 0
for i in range(1, n):
    for j in range(min(i, k)):
        dp[i] = min(dp[i], dp[i-j-1]+abs(h[i-j-1]-h[i]))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, w = map(int, input().split())
wv = []
for i in range(n):
    wv_ = list(map(int, input().split()))
    wv.append(wv_)
dp = [0]*(w+1)
for i in range(n):
    for j in range(w, wv[i][0]-1, -1):
        dp_ = dp[j - wv[i][0]] + wv[i][1]
        if dp[j] < dp_:
            dp[j] = dp_
print(max(dp))

Fixed submission:
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    w_, v_ = wv[i]
    for j in range(w+1):
        if j < w_:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j-w_]+v_, dp[i][j])
print(dp[n][w])
Buggy python submission (verdict: Runtime Error):
IN = iter(Input.split('\n')).__next__
def input():
    return IN()

# 入力
N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    w_, v_ = map(int, input().split())
    w.append(w_)
    v.append(v_)
V = sum(v)
dp = [[float("INF")]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        if j >= v[i]: dp[i+1][j] = dp[i][j-v[i]]+w[i]
        else: dp[i+1][j] = dp[i][j]
ans = 0
for i in range(V+1):
    if dp[N][i]<=W: ans=i
print(ans)

Fixed submission:
N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    w_, v_ = map(int, input().split())
    w.append(w_)
    v.append(v_)
V = sum(v)
dp = [[float("INF")]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        if j >= v[i]: dp[i+1][j] = min(dp[i][j] ,dp[i][j-v[i]]+w[i])
        else: dp[i+1][j] = dp[i][j]
ans = 0
for i in range(V+1):
    if dp[N][i]<=W: ans=i
print(ans)

Buggy python submission (verdict: Runtime Error):
n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0]*(w+1) for _ in range(n+1)]
for i in range(n):
    w_, v_ = wv[i]
    for j in range(w+1):
        if j < w_:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j-w_]+v_, dp[i][j])
print(dp[n][w])

Fixed submission:
N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    w_, v_ = map(int, input().split())
    w.append(w_)
    v.append(v_)
V = sum(v)
dp = [[float("INF")]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        if j >= v[i]: dp[i+1][j] = min(dp[i][j] ,dp[i][j-v[i]]+w[i])
        else: dp[i+1][j] = dp[i][j]
ans = 0
for i in range(V+1):
    if dp[N][i]<=W: ans=i
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    edge[x-1].append(y-1)
dp = [-1]*n
    
def calc(x):
    if dp[x] != -1:
        return dp[x]
    if not len(edge[x]):
        dp[x] = 0
        return 0
    dp[x] = max(calc(i) for i in edge[x])+1
    return dp[x]
    
ans = 0
for i in range(n):
    if dp[i] != -1: continue
    ans = max(ans, calc(i))
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    edge[x-1].append(y-1)
dp = [-1]*N

def calc(x):
    if dp[x]!=-1:
        return dp[x]
    if not len(edge[x]):
        dp[x] = 0
        return 0
    dp[x] = max([calc(i) for i in edge[x]])+1
    return dp[x]

ans = 0
for i in range(N):
    if dp[i] != -1: continue
    ans = max(ans, calc(i))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    edge[x-1].append(y-1)
dp = [-1]*n
    
def calc(x):
    if dp[x] != -1:
        return dp[x]
    if not len(edge[x]):
        dp[x] = 0
        return 0
    dp[x] = max(calc(i) for i in edge[x])+1
    return dp[x]
    
ans = 0
for i in range(n):
    ans = max(ans, calc(i))
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)

N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for _ in range(M):
    x, y = map(int, input().split())
    edge[x-1].append(y-1)
dp = [-1]*N

def calc(x):
    if dp[x]!=-1:
        return dp[x]
    if not len(edge[x]):
        dp[x] = 0
        return 0
    dp[x] = max([calc(i) for i in edge[x]])+1
    return dp[x]

ans = 0
for i in range(N):
    if dp[i] != -1: continue
    ans = max(ans, calc(i))
print(ans)
Buggy python submission (verdict: Runtime Error):
IN = iter(Input.split('\n')).__next__
def input():
    return IN()

# 入力
from collections import deque
h, w = map(int, input().split())
c = []
for _ in range(h):
    c.append(input())

ans = 0
for i in range(h):
    for j in range(w):
        if c[i][j] == ".": ans+=1

d = [[-1]*w for _ in range(h)]
d[0][0] = 1
que = deque([[0, 0]])
while que:
    x, y = que.popleft()
    for i, j in [[1,0],[0,1],[-1,0],[0,-1]]:
        nx, ny = x+i, y+j
        if 0<=nx<w and 0<=ny<h and c[ny][nx]=="." and d[ny][nx]==-1:
            d[ny][nx] = d[y][x]+1
            que.append([nx, ny])
if d[h-1][w-1] == -1:
    print(-1)
else:
    print(ans-d[h-1][w-1])

Fixed submission:
from collections import deque
h, w = map(int, input().split())
c = []
for _ in range(h):
    c.append(input())

ans = 0
for i in range(h):
    for j in range(w):
        if c[i][j] == ".": ans+=1

d = [[-1]*w for _ in range(h)]
d[0][0] = 1
que = deque([[0, 0]])
while que:
    x, y = que.popleft()
    for i, j in [[1,0],[0,1],[-1,0],[0,-1]]:
        nx, ny = x+i, y+j
        if 0<=nx<w and 0<=ny<h and c[ny][nx]=="." and d[ny][nx]==-1:
            d[ny][nx] = d[y][x]+1
            que.append([nx, ny])
if d[h-1][w-1] == -1:
    print(-1)
else:
    print(ans-d[h-1][w-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = [0] * n
for i in a:
  d[i-1] += 1
d.sort()
ans = 0
for i in range(n):
  if len(d[i:n]) == k:
    print(ans)
    break
  if d[i] == 0: continue
  ans += d[i]


Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = [0] * n
for i in a: d[i-1] += 1
d.sort(reverse=True)
print(n-sum(d[0:k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = [0] * n
for i in a:
  d[i-1] += 1
d.sort()
ans = 0
for i in range(n):
  if len(d[i:n]) == k:
    print(ans)
    break
  if d[i] == 0: continue
  ans += d[i]

Fixed submission:
n, k = map(int, input().split())
a = list(map(int, input().split()))
d = [0] * n
for i in a: d[i-1] += 1
d.sort(reverse=True)
print(n-sum(d[0:k]))
Buggy python submission (verdict: Runtime Error):
#20　AtCoder Beginner Contest 077 C - Snuke Festival
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
ans = 0
for i in b:
    if i <= a[n-1]: lena=len(a[:bisect.bisect_left(a, i)])
    else: lena=n
    if i+1<= c[n-1]: lenc=len(a[bisect.bisect_left(c, i+1):])
    ans += lena*lenc
print(ans)

Fixed submission:
#20　AtCoder Beginner Contest 077 C - Snuke Festival
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
c.sort()
ans = 0
for i in b:
    ans+= (bisect.bisect_right(a, i-1))*(n-bisect.bisect_left(c, i+1))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
for i in range(1,n+1):
    k=0
    j=int(math.sqrt(i))
    for x in range(1,j+1):
        for y in range(1,j+1):
            for z in range(1,j+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    k+=1
    print(k)

Fixed submission:
import math
n=int(input())
j=int(math.sqrt(n))
k=[0]*n
for x in range(1,j+1):
     for y in range(1,j+1):
        for z in range(1,j+1):
            p=x**2+y**2+z**2+x*y+y*z+z*x
            if p<=n:
                k[p-1]+=1
[print(i)for i in k]

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
for i in range(1,n+1):
    p=int(math.sqrt(i))
    k=0
    for x in range(1,p+1):
        for y in range(x,p+1):
            for z in range(y,p+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    s=len(set([x,y,z]))
                    if s==1:
                        k+=1
                    if s==2:
                        k+=3
                    if s==3:
                        k+=6
    print(k)

Fixed submission:
import math
n=int(input())
j=int(math.sqrt(n))
k=[0]*n
for x in range(1,j+1):
     for y in range(1,j+1):
        for z in range(1,j+1):
            p=x**2+y**2+z**2+x*y+y*z+z*x
            if p<=n:
                k[p-1]+=1
[print(i)for i in k]

Buggy python submission (verdict: Time Limit Exceeded):
import math
n=int(input())
for i in range(1,n+1):
    p=int(math.sqrt(i))
    k=0
    for x in range(1,p+1):
        for y in range(1,p+1):
            for z in range(1,p+1):
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    k+=1
    print(k)

Fixed submission:
import math
n=int(input())
j=int(math.sqrt(n))
k=[0]*n
for x in range(1,j+1):
     for y in range(1,j+1):
        for z in range(1,j+1):
            p=x**2+y**2+z**2+x*y+y*z+z*x
            if p<=n:
                k[p-1]+=1
[print(i)for i in k]
Buggy python submission (verdict: Runtime Error):
=int(input())
print((1000-n%1000)%1000)

Fixed submission:
n=int(input())
print((1000-n%1000)%1000)
Buggy python submission (verdict: Runtime Error):
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in [0]*D]
a=sorted(c)
for i in a:
    print(c.index(a))

Fixed submission:
import random
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in [0]*D]
for i in range(D):
    print(random.randint(1,26))
Buggy python submission (verdict: Runtime Error):
n=int(input())
k=[]
def a(i):
    if i==0:
        return 26
    else:
        return i
while n>26:
    k+=[chr(96+a(n%26))]
    if n%26==0:
        n=n//26-1
    else:
        n//=26
k+=[chr(96+a(n))]
print(z+1,"".join(k[::-1]))

Fixed submission:
n=int(input())
k=[]
def a(i):
    if i==0:
        return 26
    else:
        return i
while n>26:
    k+=[chr(96+a(n%26))]
    if n%26==0:
        n=n//26-1
    else:
        n//=26
k+=[chr(96+a(n))]
print("".join(k[::-1]))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=1
a=map(int,input().split())
for i in a:
    s*=i
if s>10**18:
    s=-1
print(s)

Fixed submission:
n=int(input())
s=1
a=list(map(int,input().split()))
if 0 in a:
    print(0)
else:
    for i in a:
        s*=i
        if s>10**18:
            s=-1
            break
    print(s)
Buggy python submission (verdict: Runtime Error):
s=list(input())
if s[0]=="?":
    if s[1]=="D":
        s[0]="P"
    else:
        s[0]="D"
for i in range(-1,len(s)-2):
    if s[i+1]!="?":
        continue
    if i+2<len(s) and s[i+2]=="D":
        s[i+1]="P"
    else:
        s[i+1]="D"
print("".join(s))

Fixed submission:
s=list(input())
for i in range(len(s)):
    if s[i]=="?":
        s[i]="D"
print("".join(s))

Buggy python submission (verdict: Runtime Error):
s=list(input())
if s[0]=="?":
    if s[1]=="D":
        s[0]="P"
    else:
        s[0]="D"
for i in range(len(s)-1):
    if s[i+1]!="?":
        continue
    if i+2<len(s) and s[i+2]=="D":
        s[i+1]="P"
    else:
        s[i+1]="D"
print("".join(s))

Fixed submission:
s=list(input())
for i in range(len(s)):
    if s[i]=="?":
        s[i]="D"
print("".join(s))
Buggy python submission (verdict: Runtime Error):
]
print("ABC")if s=="R" else print("ARC")

Fixed submission:
s=input()[1]
print("ABC")if s=="R" else print("ARC")