Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#かいせつ

import itertools

n,m,q = map(int,input().split())

lr = [[0 for i in range(n)] for j in range(n)]
for _ in range(m):
    l,r = map(int,input().split())
    lr[l-1][r-1] += 1

acc_lr = []
for l in lr:
    acc_lr.append([0] + list(itertools.accumulate(l)))

for _ in range(q):
    l,r = map(int,input().split())
    ans = 0
    for ls in acc_lr[l-1:r]:
        ans += ls[r] - ls[l-1]
        #print(ls,r,l-1)
    print(ans)


Fixed submission:
import itertools

n,m,q = map(int,input().split())

lr = [[0 for i in range(n)] for j in range(n)]
for _ in range(m):
    l,r = map(int,input().split())
    lr[l-1][r-1] += 1

acc_lr = []
for l in lr:
    acc_lr.append([0] + list(itertools.accumulate(l)))

for _ in range(q):
    l,r = map(int,input().split())
    ans = 0
    for ls in acc_lr[l-1:r]:
        ans += ls[r] - ls[l-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = map(int,input().split())

train = [[0 for i in range(n+1)] for j in range(n+1)]

for _ in range(m):
    l,r = map(int,input().split())
    for i in range(n+1):
        for j in range(n+1):
            if i<=l and j>=r:
                train[i][j] += 1

for _ in range(q):
    p,q = map(int,input().split())
    print(train[p][q])


Fixed submission:
import itertools

n,m,q = map(int,input().split())

lr = [[0 for i in range(n)] for j in range(n)]
for _ in range(m):
    l,r = map(int,input().split())
    lr[l-1][r-1] += 1

acc_lr = []
for l in lr:
    acc_lr.append([0] + list(itertools.accumulate(l)))

for _ in range(q):
    l,r = map(int,input().split())
    ans = 0
    for ls in acc_lr[l-1:r]:
        ans += ls[r] - ls[l-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,q = map(int,input().split())

train = []

for _ in range(m):
    l,r = map(int,input().split())
    train.append([l,r])

for _ in range(q):
    p,q = map(int,input().split())
    ans = 0
    for l,r in train:
        if p<=l and q>=r:
            ans += 1
    print(ans)


Fixed submission:
import itertools

n,m,q = map(int,input().split())

lr = [[0 for i in range(n)] for j in range(n)]
for _ in range(m):
    l,r = map(int,input().split())
    lr[l-1][r-1] += 1

acc_lr = []
for l in lr:
    acc_lr.append([0] + list(itertools.accumulate(l)))

for _ in range(q):
    l,r = map(int,input().split())
    ans = 0
    for ls in acc_lr[l-1:r]:
        ans += ls[r] - ls[l-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
s_a=[0]
for i in a:
	s_a.append((s_a[-1]+i)%m)
res = 0
for i in range(m):
	c = s_a.count(i)
	res += c*(c-1)//2
print(res)

Fixed submission:
from collections import defaultdict as dd
n,m = map(int,input().split())
a = list(map(int,input().split()))
a_s = [0]
for i in range(n):
    a_s.append((a_s[-1]+a[i])%m)
d = dd(int)
for i in a_s:
    d[i] += 1
res = 0
for k in d.values():
    if k>=2:
        res += k*(k-1)//2
print(int(res))
Buggy python submission (verdict: Runtime Error):
r=input()
if r<1200:
  print("ABC")
elif r<2800:
  print("ARC")
else:
  print("AGC")

Fixed submission:
r=int(input())
if r<1200:
  print("ABC")
elif r<2800:
  print("ARC")
else:
  print("AGC")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
mid = b[n//2]
sum = 0
for i in range(n):
    sum+=abs(a[i]-(mid+(i+1)))
print(sum)


Fixed submission:
N = int(input())
if N%2==0:
    print(N)
else:
    print(N*2)

Buggy python submission (verdict: Runtime Error):
N=input();print(N*(N%2+1))

Fixed submission:
N = int(input())
if N%2==0:
    print(N)
else:
    print(N*2)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
l = len(a)
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
if l%2==1:
    mid = b[l//2+1]
    sum = 0
    for i in range(n):
        sum += abs(a[i] - mid - (i+1))
else:
    mid = (b[l//2] + b[l//2+1]) / 2
    sum1 = 0
    sum2 = 0
    for i in range(n):
        sum1 += abs(a[i] - math.floor(mid) - (i+1))
        sum2 += abs(a[i] - math.ceil(mid) - (i+1))
    sum = min(sum1, sum2)
print(sum)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
l = len(a)
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
mid = b[l//2]
sum = 0
for i in range(n):
    sum+=abs(a[i]-(mid+(i+1)))
print(sum)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
l = len(a)
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
if l%2==1:
    mid = b[l//2+1]
else:
    mid = (b[l//2] + b[l//2+1]) // 2
sum = 0
for i in range(n):
    sum += abs(a[i] - mid - (i+1))
print(sum)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
l = len(a)
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
mid = b[l//2]
sum = 0
for i in range(n):
    sum+=abs(a[i]-(mid+(i+1)))
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
l = len(a)
a = [a[i]-(i+1) for i in range(l)]
a_min = min(a)
a_max = max(a)

res = float('inf')
for i in range(min(a),max(a)+1):
    sum = 0
    for j in a:
        sum += abs(j - i)
    res = min(res, sum)
print(res)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
l = len(a)
b = [a[i]-(i+1) for i in range(n)]
b = sorted(b)
mid = b[l//2]
sum = 0
for i in range(n):
    sum+=abs(a[i]-(mid+(i+1)))
print(sum)
Buggy python submission (verdict: Runtime Error):
res = []
for digit in range(1,16):
    if digit<=3:
        for i in range(2,11):
            res.append(10**(digit-1)*i-1)
    elif 4<=digit<=12:
        for i in range(11,(digit-2)*10):
            res.append(i*10**(digit-2)-1)
        for i in range(digit-2,11):
            res.append(i*10**(digit-1)-1)
    else:
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
for i in range(int(input())):
    print(res[i])


Fixed submission:
res = []
for digit in range(1,16):
    if digit<=3:
        for i in range(2,11):
            res.append(10**(digit-1)*i-1)
    elif 4<=digit<=12:
        for i in range(11,(digit-2)*10):
            res.append(i*10**(digit-2)-1)
        for i in range(digit-2,11):
            res.append(i*10**(digit-1)-1)
    elif digit==15:
        for i in range(101,110):
            res.append(i*10**(digit-3)-1)
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
    else:
        for i in range(11,101):
            res.append(i*10**(digit-2)-1)
for i in range(int(input())):
    print(res[i])
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A>8 or B>8:
	print(':(')
else:
	print('Yay!')

Fixed submission:
A,B=list(map(int,input().split()))
if A>8 or B>8:
	print(':(')
else:
	print('Yay!')
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = int(input())
r = set()

# i: 文字数
for i in range(1,len(s)+1):
    # j: 始点
    for j in range(len(s)-i+1):
        sub = s[j:j+i]
        r.add(sub)

print(sorted(r)[t-1])

Fixed submission:
s = input()
k = int(input())
alphabets = sorted(set(list(s)))

# 答えとなるsubstringは必ずK文字以下
res = set()
# 頭文字(alphabetsの添字)
prefix = 0
while len(res)<k:
    # 頭文字のみの場合
    res.add(alphabets[prefix])
    for i in range(len(s)):
        #print(i,res)
        if s[i]==alphabets[prefix]:
            # 2文字以上の部分文字列をresに追加
            length = 2
            while length<=k:
                if i+length>len(s):
                    break
                res.add(s[i:i+length])
                length += 1
    prefix += 1

print(sorted(res)[k-1])
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
A=[]

for i in range(W):
    S='.'+input()+'.'
    A.append(S)
K='.'
A.insert(0,K*(H+2))
A.append(K*(H+2))
for i in range(1,H):
    for j in range(1,W):
        if A[i][j]=='#':
            if A[i+1][j]=='.' and A[i-1][j]=='.' and A[i][j+1]=='.' and A[i][j-1]=='.':
                print('No')
                exit(0)

print('Yes')


Fixed submission:
h,w = map(int,input().split())
s = [input() for _ in range(h)]

def countSharp(x,y):
    res = 0
    if x!=0:
        res += s[x-1][y]=='#'
    if y!=0:
        res += s[x][y-1]=='#'
    if x!=h-1:
        res += s[x+1][y]=='#'
    if y!=w-1:
        res += s[x][y+1]=='#'
    return res

flag = [[False for _ in range(w)] for oijqd in range(h)]
for i,l in enumerate(s):
    for j,c in enumerate(l):
        if c=='.':
            flag[i][j] = True

for i in range(h):
    for j in range(w):
        if s[i][j]=='#' and countSharp(i,j)>0:
            flag[i][j] = True
            if i!=0:
                flag[i-1][j] = True
            if j!=0:
                flag[i][j-1] = True
            if i!=h-1:
                flag[i+1][j] = True
            if j!=w-1:
                flag[i][j+1] = True

res = True
for l in flag:
    if False in l:
        res = False
        break

print('Yes' if res else 'No')

Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
A=[]

for i in range(W):
    S='.'+input()+'.'
    A.append(S)
K='.'
A.insert(0,K*(H+2))
A.append(K*(H+2))
for j in range(1,H+1):
    for i in range(1,W+1):
        if A[i][j]=='#':
            if A[i+1][j]=='.' and A[i-1][j]=='.' and A[i][j+1]=='.' and A[i][j-1]=='.':
                print('No')
                exit(0)

print('Yes')


Fixed submission:
h,w = map(int,input().split())
s = [input() for _ in range(h)]

def countSharp(x,y):
    res = 0
    if x!=0:
        res += s[x-1][y]=='#'
    if y!=0:
        res += s[x][y-1]=='#'
    if x!=h-1:
        res += s[x+1][y]=='#'
    if y!=w-1:
        res += s[x][y+1]=='#'
    return res

flag = [[False for _ in range(w)] for oijqd in range(h)]
for i,l in enumerate(s):
    for j,c in enumerate(l):
        if c=='.':
            flag[i][j] = True

for i in range(h):
    for j in range(w):
        if s[i][j]=='#' and countSharp(i,j)>0:
            flag[i][j] = True
            if i!=0:
                flag[i-1][j] = True
            if j!=0:
                flag[i][j-1] = True
            if i!=h-1:
                flag[i+1][j] = True
            if j!=w-1:
                flag[i][j+1] = True

res = True
for l in flag:
    if False in l:
        res = False
        break

print('Yes' if res else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int,input().split()))
s_x = sorted(x)
med_1 = s_x[n//2-1]
med_2 = s_x[n//2]

for i in x:
    if s_x.index(i)<n//2:
        print(med_2)
    else:
        print(med_1)


Fixed submission:
n = int(input())
x = list(map(int,input().split()))
s_x = sorted(x)
med_1 = s_x[n//2-1]
med_2 = s_x[n//2]

for i in x:
    if i<med_2:
        print(med_2)
    else:
        print(med_1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
for i in range(n):
    arr = a[:i+1]+a[i+2:]
    print(sum([abs(arr[i]-arr[i+1]) for i in range(n)]))

Fixed submission:
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
b = sum([abs(a[i]-a[i+1]) for i in range(n+1)])

for i in range(n):
    t = b
    if not (a[i]<=a[i+1]<=a[i+2] or a[i]>=a[i+1]>=a[i+2]):
        t -= abs(a[i]-a[i+1])
        t -= abs(a[i+1]-a[i+2])
        t += abs(a[i]-a[i+2])
    print(t)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
csf = [list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
    res = 0
    for t in range(i,n-1):
        c,s,f = csf[t]
        if res<=s:
            res = s + c
        else:
            while res>s:
                s += f
            res = s + c
        #print(i,res)
    print(res)

Fixed submission:
import math

n = int(input())
csf = [list(map(int,input().split())) for _ in range(n-1)]

for i in range(n):
    res = 0
    for t in range(i,n-1):
        c,s,f = csf[t]
        if res<=s:
            res = s + c
        else:
            s += f*math.ceil((res-s)/f)
            res = s + c
        #print(i,res)
    print(res)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
res = []
for i,(a,b) in enumerate(zip(s,s[1:])):
    if a != b:
        res.append(max(i+1,n-1-i))
print(min(res))


Fixed submission:
s = input()
n = len(s)
if s[0]*n==s:
    print(n)
    exit()
res = []
for i,(a,b) in enumerate(zip(s,s[1:])):
    if a != b:
        res.append(max(i+1,n-1-i))
print(min(res))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = set(a)
r = []
for i in s:
	r.append(a.count(i))
r = sorted(r)
dif = len(s) - k
print(sum(r[0:max(0,dif)]))

Fixed submission:
import itertools
n,k = map(int,input().split())
a = sorted(list(map(int,input().split())))
c = []
g = itertools.groupby(a)
for m,v in g:
    c.append(len(list(v)))
c = sorted(c)
print(sum(c[:-k]))
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())

# 0-indexed
visited = [False]*n
aa = []
bb = []
edge = []
for i in range(7):
    edge.append([False]*7)
"""
edge = [[False]*7]*7
"""

for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    aa.append(a)
    bb.append(b)
    edge[a][b] = True
    edge[b][a] = True
    """
    for l in edge:
        print(l)
    print('')
    """

def dfs(vertex):
    visited[vertex] = True
    for i in range(n):
        if edge[vertex][i] and not visited[i]:
            #print(i, end=' ')
            dfs(i)

res = 0
for i in range(m):
    visited = [False]*n
    edge[aa[i]][bb[i]] = False
    edge[bb[i]][aa[i]] = False
    dfs(0)
    if not visited==[True]*n:
        res += 1
    #print(visited)
    edge[aa[i]][bb[i]] = True
    edge[bb[i]][aa[i]] = True

print(res)


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

# 0-indexed
visited = [False]*n
aa = []
bb = []
edge = []
for i in range(51):
    edge.append([False]*51)
"""
edge = [[False]*7]*7
"""

for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    aa.append(a)
    bb.append(b)
    edge[a][b] = True
    edge[b][a] = True
    """
    for l in edge:
        print(l)
    print('')
    """

def dfs(vertex):
    visited[vertex] = True
    for i in range(n):
        if edge[vertex][i] and not visited[i]:
            #print(i, end=' ')
            dfs(i)

res = 0
for i in range(m):
    visited = [False]*n
    edge[aa[i]][bb[i]] = False
    edge[bb[i]][aa[i]] = False
    dfs(0)
    if not visited==[True]*n:
        res += 1
    #print(visited)
    edge[aa[i]][bb[i]] = True
    edge[bb[i]][aa[i]] = True

print(res)
Buggy python submission (verdict: Runtime Error):
from math import gcd
n,k = map(int,input().split())
a = list(map(int,input().split()))
G = a[0]
for i in a:
    G = gcd(G,i)
if k<=max(a) and k%G==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
from fractions import gcd
n,k = map(int,input().split())
a = list(map(int,input().split()))
G = a[0]
for i in a:
    G = gcd(G,i)
if k<=max(a) and k%G==0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
route=[]
cur=0
while 1:
    if cur in route:
        print(-1)
        break
    if cur==1:
        print(len(route))
        break
    route.append(cur)
    cur = a[cur]-1


Fixed submission:
n=int(input())
a=[int(input())-1 for i in range(n)]
cur=0
i=0
while 1:
    if cur==1:
        print(i)
        break
    if i>=n:
        print(-1)
        break
    i+=1
    cur=a[cur]

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input()) for i in range(n)]
route=[]
cur=0
while 1:
    if cur in route:
        print(-1)
        break
    if cur==1:
        print(len(route))
        break
    route.append(cur)
    cur = a[cur]-1


Fixed submission:
n=int(input())
a=[int(input())-1 for i in range(n)]
cur=0
i=0
while 1:
    if cur==1:
        print(i)
        break
    if i>=n:
        print(-1)
        break
    i+=1
    cur=a[cur]
Buggy python submission (verdict: Runtime Error):
a=input()
b=input()
c=input()
if a[-1]==b[0] and b[-1]==c[0]:
  print('YES')
else:
  print('NO')

Fixed submission:
a,b,c=input().split()
print('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[i*30000+1 for i in range(n)]
b=[30000**2-i for i in a]
p=list(map(int,input().split()))
for i in range(n):
  a[p[i]-1]+=i
  b[p[i]-1]+=i
print(*a)
print(*b)


Fixed submission:
h,w=map(int,input().split())
r=0
for _ in range(h):r+=input().count('#')
print('Possible'if r==h+w-1else'Impossible')

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[i*40000 for i in range(n)]
b=[40000**2-i for i in a]
p=list(map(int,input().split()))
for i in range(n):
  a[p[i]]+=i
  b[p[i]]+=i
print(*a)
print(*b)


Fixed submission:
h,w=map(int,input().split())
r=0
for _ in range(h):r+=input().count('#')
print('Possible'if r==h+w-1else'Impossible')
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[i*40000 for i in range(n)]
b=[i*40000 for i in range(n-1,-1,-1)]
p=list(map(int,input().split()))
for i in range(n):
  a[p[i]]+=i
  b[p[i]]+=i
print(*a)
print(*b)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
A = [45678 * i for i in range(1, N + 1)]
B = A[::-1]
for i, p in enumerate(P):
    A[p - 1] += i
    B[p - 1] += i
print(*A)
print(*B)
Buggy python submission (verdict: Time Limit Exceeded):
n,x = map(int,input().split())
if x in (1, 2 * n - 1):
    print('No')
    exit()
res = list(range(1, 2 * n))
while res[n - 1] != x:
    res = res[1:] + [res[0]]
print('Yes')
print(*res, sep = '\n')


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

# 仮説
if x in (1,2*n-1):
    print('No')
    exit()

res = [i for i in range(1,2*n)]

flag = False
if x > n:
    x = 2 * n - x
    flag = True

res = res[x-n:] + res[:x-n]

if flag:
    for i in range(2*n-1):
        res[i] = 2 * n - res[i]

print('Yes')
print(*res, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
t,a = 0,0
for i in range(n):
    tt,aa = map(int,input().split())
    p,q = tt,aa
    while p<t or q<a:
        p += tt
        q += aa
    t,a = p,q
print(t+a)


Fixed submission:
n = int(input())
a,b = 1,1
for i in range(n):
    T,A = map(int,input().split())
    N = max((T+a-1)//T,(A+b-1)//A)
    a,b = N*T,N*A
print(a+b)
Buggy python submission (verdict: Runtime Error):
input();*a,=map(int,input().split());print(sum(a[a[i]-1]==i+1for i in range(len(a)))>>1)

Fixed submission:
s=input()
print(s[:4]+' '+s[4:])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
res = 0
for i in range(n-1):
    for j in range(i+1,n):
        if a[i]==j+1 and a[j]==i+1:
            res += 1
print(res)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
res = 0
for i in range(n):
    if a[i]>i+1 and a[a[i]-1]==i+1:
        res += 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c = map(int,input().split())
res = 10**100
#a
for i in range(1,a):
    j = a - i
    r = abs(i - j) * b * c
    res = min(res, r)
#b
for i in range(1,b):
    j = b - i
    r = abs(i - j) * a * c
    res = min(res, r)
#c
for i in range(1,c):
    j = c - i
    r = abs(i - j) * b * a
    res = min(res, r)
print(res)


Fixed submission:
l=list(map(int,input().split()))
if not l[0]%2&l[1]%2&l[2]%2:
    print(0)
else:
    l=sorted(l)
    print(l[0]*l[1])
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split());d=input().split()
while 1:
    for c in str(n):
        if c in d:break
    else:
        print(n)
        exit()
    n += 1

Fixed submission:
A=input()
print(['NO','YES'][(A.count('5')==2)*(A.count('7')==1)])

Buggy python submission (verdict: Runtime Error):
l = sort(list(map(int,input().split())))
if l==[5,5,7]:
    print('YES')
else:
    print('NO')

Fixed submission:
A=input()
print(['NO','YES'][(A.count('5')==2)*(A.count('7')==1)])
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
import math
for i in range(1,n+1):
    a=math.floor(math.sqrt(i/6))+1
    t=0
    for x in range(1,a):
        b=math.floor(math.sqrt((i-x**2)/3))+1
        for y in range(x,b):
            c=math.floor(math.sqrt(i-x**2-y**2-x*y))+1
            for z in range(y,c):
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    if x==y and y==z:
                        t+=1
                    elif x!=y and y!=z and z!=x:
                        t+=6
                    else:
                        t+=3
    print(t)

Fixed submission:
n=int(input())
import math
for i in range(1,n+1):
    t=0
    for x in range(1,101):
        if (x**2)*6>i:
            break
        for y in range(x,101):
            if x**2+3*(y**2)+2*x*y>i:
                break
            B=(x+y)
            C=x**2+y**2+x*y-i
            r=(B**2-4*C)**0.5
            z1=(-B+r)/2
            z2=(-B-r)/2
            if z1.is_integer() and z1>0:
                if x==y and y==z1:
                    t+=1
                elif x!=y and y!=z1 and z1!=x:
                    t+=6
                else:
                    t+=3
            if z2.is_integer() and z2>0:
                if x==y and y==z2:
                    t+=1
                elif x!=y and y!=z2 and z2!=x:
                    t+=6
                else:
                    t+=3
    print(t)

Buggy python submission (verdict: Runtime Error):
n=int(input())
import math
a=math.floor(math.sqrt(n/6))+1
for i in range(1,n+1):
    t=0
    for x in range(1,a):
        b=math.floor(math.sqrt((i-x**2)/3))+1
        for y in range(x,b):
            c=math.floor(math.sqrt(i-x**2-y**2-x*y))+1
            for z in range(y,c):
                if x**2+y**2+z**2+x*y+y*z+z*x==i:
                    if x==y and y==z:
                        t+=1
                    elif x!=y and y!=z and z!=x:
                        t+=6
                    else:
                        t+=3
    print(t)

Fixed submission:
n=int(input())
import math
for i in range(1,n+1):
    t=0
    for x in range(1,101):
        if (x**2)*6>i:
            break
        for y in range(x,101):
            if x**2+3*(y**2)+2*x*y>i:
                break
            B=(x+y)
            C=x**2+y**2+x*y-i
            r=(B**2-4*C)**0.5
            z1=(-B+r)/2
            z2=(-B-r)/2
            if z1.is_integer() and z1>0:
                if x==y and y==z1:
                    t+=1
                elif x!=y and y!=z1 and z1!=x:
                    t+=6
                else:
                    t+=3
            if z2.is_integer() and z2>0:
                if x==y and y==z2:
                    t+=1
                elif x!=y and y!=z2 and z2!=x:
                    t+=6
                else:
                    t+=3
    print(t)
Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
t=0
for i in range(n+1):
    for j in range(m+1):
        if sum(a[0:i])+sum(b[0:j])<=k and t<=i+j:
            t=i+j
print(t)

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

a,b=[0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])


ans,j=0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans =max(ans,i+j)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=0
for i in range(1,n+1):
    t=0
    for j in range(1,int((i+1)**(1/2))+1):
        if i%j==0:
            t+=1
    t=t*2
    if i==(int((i+1)**(1/2)))**2:
        t+=-1
    s+=i*t
print(s)

Fixed submission:
n=int(input())
s=0
a=[1]
for i in range(n-1):
    a.append(a[i]+(i+2))
for i in range(1,n+1):
    s+=i*a[(n//i)-1]
print(s)