Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))

ans = 0
flag = True
while flag:
  flag = False
  for i in range(n-1, -1, -1):
    if not flag and a[i]%2 == 0:
      flag = True
      ans += 1
      a[i] //= 2
    else: a[i] *= 3
print(ans)

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

ans = 0
for i in a:
  while i%2==0:
    i//=2
    ans+= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int, input().split())))

ans = 0
t = 1
while t != 0:
  t = 0
  for i in range(n-1, -1 ,-1):
    if t == 0 and a[i]%2 == 0 and a[i] != 2:
      a[i] //= 2
      t += 1
      ans += 1
    else: a[i] *= 3
print(ans)

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

ans = 0
for i in a:
  while i%2==0:
    i//=2
    ans+= 1
print(ans)

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

ans = 0
while True:
  if all(i%2==1 for i in a): break
  ans += 1
  t = 0
  for i in range(n):
    if a[i]%2 == 1: a[i] *= 3
    else:
      if t == 0 and a[i] != 2:
        a[i] //= 2
        t += 1
      else: a[i] *= 3

print(ans)

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

ans = 0
for i in a:
  while i%2==0:
    i//=2
    ans+= 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int, input().split()))

m = (n-1)//2
l = sorted(x)
for i in x:
  if l.index(i) > m: print(l[m])
  else: print(l[m+1])

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

m = (n-1)//2
l = sorted(x)
for i in x:
  if i > l[m]: print(l[m])
  else: print(l[m+1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))+[0]

for i in range(n):
  ans = 0
  t = 0
  for j in range(n+1):
    if i == j: continue
    ans += abs(t - a[j])
    t = a[j]
  print(ans)

Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

nums = [0]*(n+1)
for i in range(1, n+2): nums[i-1] = abs(a[i] - a[i-1])

ans = sum(nums)
for i in range(1,n+1):
  print(ans - nums[i-1]-nums[i]+abs(a[i+1]-a[i-1]))

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

for i in range(n):
  ans = 0
  t = 0
  for j in range(n):
    if i == j: continue
    ans += abs(t - a[j])
    t = a[j]
  ans += abs(t)
  print(ans)

Fixed submission:
n = int(input())
a = [0] + list(map(int, input().split())) + [0]

nums = [0]*(n+1)
for i in range(1, n+2): nums[i-1] = abs(a[i] - a[i-1])

ans = sum(nums)
for i in range(1,n+1):
  print(ans - nums[i-1]-nums[i]+abs(a[i+1]-a[i-1]))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
n = int(input())

march = ("M","A","R","C","H")
d = []
for _ in range(n):
  pre = input()[0]
  if pre in march: d.append(pre)

if len(d) < 3:
  print(0)
  exit()

ans = 0
for i in combinations(d,3):
  if len(set(i)) == 3:
    ans += 1
print(ans)

Fixed submission:
n = int(input())

march = ("M","A","R","C","H")
prefix = []
d = {}
for _ in range(n):
  pre = input()[0]
  if pre in march:
    if pre not in prefix:
      prefix.append(pre)
      d[pre] = 1
    else:
      d[pre] += 1
      
t = len(prefix)
if t < 3:
  print(0)
  exit()

ans = 0
for i in range(t-2):
  for j in range(i+1, t-1):
    for k in range(j+1,t):
      ans += d[prefix[i]]*d[prefix[j]]*d[prefix[k]]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
c = [tuple(map(int, input().split())) for _ in range(3)]

maxNum = max(max(c))
for i in product(range(maxNum+1),repeat=3):
  if max(i) > maxNum: continue
  for x in range(maxNum+1):
    row1 = (i[0]+x,i[1]+x,i[2]+x)
    if row1 == c[0]:
      for y in range(maxNum+1):
        row2 = (i[0]+y,i[1]+y,i[2]+y)
        if row2 == c[1]:
          for z in range(maxNum+1):
            row3 = (i[0]+z,i[1]+z,i[2]+z)
            if row3 == c[2]:
              print("Yes")
              exit()
print("No")

Fixed submission:
c = [list(map(int, input().split())) for _ in range(3)]

# 斜め同士を足し合わせ比較をする
if c[0][0] + c[1][1] == c[0][1] + c[1][0]:
  if c[0][1] + c[1][2] == c[0][2] + c[1][1]:
    if c[1][0] + c[2][1] == c[1][1] + c[2][0]:
      if c[1][1] + c[2][2] == c[1][2] + c[2][1]:
        print("Yes")
        exit()
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())

n = 10**5+1
nums = [True]*n
nums[1] = False
for i in range(4, n, 2): nums[i] = False
for i in range(3, int(n**0.5)+1, 2):
  if nums[i]:
    for j in range(i+i, n, i): nums[j] = False

for _ in range(q):
  ans = 0
  l,r = map(int, input().split())
  for i in range(l, r+1,2):
    if nums[i] and nums[(i+1)//2]: ans += 1
  print(ans)

Fixed submission:
q = int(input())

n = 10**5+1
flag = [True]*n
flag[1] = False
for i in range(4, n, 2): flag[i] = False
for i in range(3, int(n**0.5)+1, 2):
  if flag[i]:
    for j in range(i+i, n, i): flag[j] = False

nums = [0]*n
for i in range(1,n):
  if i%2 == 1:
    if flag[i] and flag[(i+1)//2]: nums[i] = nums[i-1]+1
    else: nums[i] = nums[i-1]
  else: nums[i] = nums[i-1]

for _ in range(q):
  l,r = map(int, input().split())
  print(nums[r]-nums[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
q = int(input())

n = 10**5+1
nums = [True]*n
nums[1] = False
for i in range(4, n, 2): nums[i] = False
for i in range(3, int(n**0.5)+1, 2):
  if nums[i]:
    for j in range(i+i, n, i): nums[j] = False

for _ in range(q):
  ans = 0
  l,r = map(int, input().split())
  for i in range(l, r+1):
    if i%2 == 1:
      if nums[i] and nums[(i+1)//2]: ans += 1
  print(ans)

Fixed submission:
q = int(input())

n = 10**5+1
flag = [True]*n
flag[1] = False
for i in range(4, n, 2): flag[i] = False
for i in range(3, int(n**0.5)+1, 2):
  if flag[i]:
    for j in range(i+i, n, i): flag[j] = False

nums = [0]*n
for i in range(1,n):
  if i%2 == 1:
    if flag[i] and flag[(i+1)//2]: nums[i] = nums[i-1]+1
    else: nums[i] = nums[i-1]
  else: nums[i] = nums[i-1]

for _ in range(q):
  l,r = map(int, input().split())
  print(nums[r]-nums[l-1])
Buggy python submission (verdict: Runtime Error):
h,w = map(int, input().split())
s = [list(input()) for _ in range(h)]

ans = [[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#": ans[i][j] = "#"
      for i2 in range(i-1, i+2):
        if i2 < 0 or h-1 < i2: continue
        for j2 in range(j-1, j+2):
          if (j2 < 0 or w-1 < j2): continue
          elif ans[i2][j2] == "#": continue
          ans[i2][j2] += 1
for i in ans:
  print("".join(map(str,i)))

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

ans = [[0]*w for _ in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      ans[i][j] = "#"
      for i2 in range(i-1, i+2):
        if i2 < 0 or h-1 < i2: continue
        for j2 in range(j-1, j+2):
          if (j2 < 0 or w-1 < j2): continue
          elif ans[i2][j2] == "#": continue
          ans[i2][j2] += 1
for i in ans:
  print("".join(map(str,i)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

nums = [0]*(max(a)+1)
for i in a: nums[i] += 1

if n == 1:
  print(1)
  exit()
elif n == 2:
  if abs(a[0]-a[1]) <= 2: print(2)
  else: print(1)
  exit()
    
ans = 0
for i in range(1,n-1):
  if ans < nums[i-1] + nums[i] + nums[i+1]:
    ans = nums[i-1] + nums[i] + nums[i+1]

print(ans)

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

nums = [0]*(max(a)+1)
for i in a: nums[i] += 1

if len(nums) <= 2:
  print(sum(nums))
  exit()
  
ans = 0
for i in range(1,max(a)):
  if ans < nums[i-1] + nums[i] + nums[i+1]:
    ans = nums[i-1] + nums[i] + nums[i+1]

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
ans = [0]*2
t = 0
for i in sorted(count.items(), reverse=True):
  if i[1] >= 4:
    if t == 0:
      ans[0],ans[1] = i[0],i[0]
      t = 2
    elif t == 1:
      ans[t] = i[0]
      t += 1
  if i[1] >= 2:
    ans[t] = i[0]
    t += 1
  if t == 2: break
print(ans[0]*ans[1])

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

count = Counter(a)
t = 4
s = []
for i in sorted(count.items(), key=lambda x: x[0], reverse=True):
  if i[1] >= 4 and t == 4:
    print(i[0]**2)
    exit()
  if i[1] >= 2 and t != 0:
    t -= 2
    s.append(i[0])
  elif t == 0: break
    
if len(s) != 0: print(s[0]*s[1])
else: print(0)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

count = Counter(a)
t = 4
s = []
for i in sorted(count.items(), key=lambda x: x[0], reverse=True):
  if i[1] >= 4 and t == 4:
    print(i**2)
    exit()
  if i[1] >= 2 and t != 0:
    t -= 2
    s.append(i[0])
  elif t == 0: break
    
if len(s) != 0: print(s[0]*s[1])
else: print(0)

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

count = Counter(a)
t = 4
s = []
for i in sorted(count.items(), key=lambda x: x[0], reverse=True):
  if i[1] >= 4 and t == 4:
    print(i[0]**2)
    exit()
  if i[1] >= 2 and t != 0:
    t -= 2
    s.append(i[0])
  elif t == 0: break
    
if len(s) != 0: print(s[0]*s[1])
else: print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = []
t = 0
for i in a:
  if t == 0: ans.append(i)
  else: ans.insert(0,i)
  t = 1 - t

if t == 0: print(*ans)
else: print(*ans[::-1])

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

d = deque()
t = 0
for i in a:
  if t == 0: d.append(i)
  elif t == 1: d.appendleft(i)
  t = 1 - t
  
if t == 0: print(*d)
else: print(*list(reversed(d)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [int(input()) for _ in range(n)]

sumNum = sum(s)
if sumNum % 10 != 0:
  print(sumNum)
  exit()

t = 0
for i in s:
  if (sumNum - i)%10 != 0:
    t = max(t, sum-i)
print(t)

Fixed submission:
n = int(input())
s = [int(input()) for _ in range(n)]

sumNum = sum(s)
if sumNum % 10 != 0:
  print(sumNum)
  exit()

t = 0
for i in s:
  if (sumNum - i)%10 != 0:
    t = max(t, sumNum-i)
print(t)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())

ans = 0
for i in range(n, 0, -1):
  if m >= 2*i:
    ans += i
    m -= 2*i
    break

if m >= 4:
  ans += m // 4
  
print(ans)

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

ans = 0
if n*2 <= m:
  ans += n
  m -= n*2
else:
  ans += m//2
  m %= 2

if m >= 4:
  ans += m // 4
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [0]*n
y = [0]*n
for i in range(n-1, -1, -1):
  a,b = map(int, input().split())
  x[i] = a
  y[i] = b

ans = 0
for i in range(n):
  while (x[i]+ans) % y[i] != 0:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
x = [0]*n
y = [0]*n
for i in range(n-1, -1, -1):
  a,b = map(int, input().split())
  x[i] = a
  y[i] = b

ans = 0
for i in range(n):
  if (x[i]+ans) % y[i] != 0:
    ans += y[i]-(x[i]+ans)%y[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = [0]*n
y = [0]*n
for i in range(n-1, -1, -1):
  a,b = map(int, input().split())
  x[i] = a
  y[i] = b

ans = 0
for i in range(n):
  while (x[i]+ans) % y[i] != 0:
    ans += 1
print(ans)

Fixed submission:
n = int(input())
x = [0]*n
y = [0]*n
for i in range(n-1, -1, -1):
  a,b = map(int, input().split())
  x[i] = a
  y[i] = b

ans = 0
for i in range(n):
  if (x[i]+ans) % y[i] != 0:
    ans += y[i]-(x[i]+ans)%y[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(list(map(int, input().split())))

if n%2 == 0:
  for i in range(0,n-2,2):
    if a[i] != a[i+1] or a[i] == a[i+2]:
      print(0)
      exit()
  if a[-2] != a[-1]:
    print(0)
    exit()
else:
  if a[0] != 0 or a[1] == 0:
    print(0)
    exit()
  for i in range(1,n-2,2):
    if a[i] != a[i+1] or a[i] == a[i+2]:
      print(0)
      exit()
  if a[-2] != a[-1]:
    print(0)
    exit()

mod = 10**9+7
if n%2 == 0: print(2**(n//2)%mod)
else: print(2**((n-1)//2)%mod)

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

if n%2 == 0: # 人数が偶数の場合に不整合があるか確認
  for i in range(0,n,2):
    if a[i] != i+1 or a[i+1] != i+1:
      print(0)
      exit()
else: # 人数が奇数の場合に不整合があるか確認
  if a[0] != 0: # 差分が0存在していることを確認
    print(0)
    exit()
  else:
    for i in range(1,n,2):
      if a[i] != i + 1 or a[i+1] != i + 1:
        print(0)
        exit()
        
ans = 1        
for i in range(n//2):
  ans = ans*2%(10**9+7)
print(ans)
Buggy python submission (verdict: Runtime Error):

n,m = map(int, raw_input())

def g(u,parent):
    if parent[u]!= u:
        parent[u] = g(parent[u], parent)
    return parent[u]
parent = {u:u for u in range(1, n+1)}
for _ in range(m):
    u,v = map(int, raw_input().split())
    pu,pv = g(u,parent), g(v,parent)
    if pu!= pv:
        parent[pu] = pv

ans = 0
for u in parent:
    if g(u,parent) == u:
        ans+=1
print ans -1

Fixed submission:

n,m = map(int, raw_input().split())

def g(u,parent):
    if parent[u]!= u:
        parent[u] = g(parent[u], parent)
    return parent[u]
parent = {u:u for u in range(1, n+1)}
for _ in range(m):
    u,v = map(int, raw_input().split())
    pu,pv = g(u,parent), g(v,parent)
    if pu!= pv:
        parent[pu] = pv

ans = 0
for u in parent:
    if g(u,parent) == u:
        ans+=1
print ans -1
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,raw_input().split())
jis = [map(int, raw_input().split()) for _ in range(k)]
jis.sort()
dp = [0 for _ in range(n)]
dp[0] = 1
mod = 998244353
for i in range(1,n):
	flag = True
	for u,v in jis:
		if flag is False: break
		for w in range(u,v+1):
			if i-w>=0:
				dp[i] += dp[i - w]
				dp[i] %= mod
			else:
				flag = False
				break
print dp[n-1]

Fixed submission:
n,k = map(int,raw_input().split())
jis = [map(int, raw_input().split()) for _ in range(k)]
jis.sort()

dp = [0 for _ in xrange(n)]
dp[0] = 1
pre = [0 for _ in xrange(n)]
pre[0] = 1
mod = 998244353
for i in range(1,n):
	flag = True
	for u,v in jis:
		uu,vv = i - v, i - u
		
		if vv >= 0:
			dp[i] += pre[vv] - (pre[uu - 1] if uu - 1 >= 0 else 0)
			dp[i] %= mod
	pre[i] += dp[i] + pre[i-1]
	pre[i] %= mod

print dp[n-1]

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,raw_input().split())
jis = [map(int, raw_input().split()) for _ in range(k)]
dp = [0 for _ in range(n)]
dp[0] = 1
mod = 998244353
for i in range(1,n):
	for u,v in jis:
		for w in range(u,v+1):
			if i-w>=0:
				dp[i] += dp[i - w]
				dp[i] %= mod
print dp[n-1]

Fixed submission:
n,k = map(int,raw_input().split())
jis = [map(int, raw_input().split()) for _ in range(k)]
jis.sort()

dp = [0 for _ in xrange(n)]
dp[0] = 1
pre = [0 for _ in xrange(n)]
pre[0] = 1
mod = 998244353
for i in range(1,n):
	flag = True
	for u,v in jis:
		uu,vv = i - v, i - u
		
		if vv >= 0:
			dp[i] += pre[vv] - (pre[uu - 1] if uu - 1 >= 0 else 0)
			dp[i] %= mod
	pre[i] += dp[i] + pre[i-1]
	pre[i] %= mod

print dp[n-1]
Buggy python submission (verdict: Runtime Error):

s = raw_input()
count = 0
a = 0
for j in range(len(s))
	if s[j] == 'R':
		count +=1
	else:
		count = 0
	a = max(count, a)
print 

Fixed submission:
s = raw_input()
count = 0
a = 0
for j in range(len(s)):
	if s[j] == 'R':
		count +=1
	else:
		count = 0
	a = max(count, a)
print a
Buggy python submission (verdict: Runtime Error):
x,k,d = map(int, raw_input().split())
def f(x,k,d):
	if k == 0:
		return abs(x)

	if abs(x) <= d:
		if k % 2 == 0:
			if k == 0:
				return x
			else:
				return min(f(x+d,k-1,d), f(x-d,k-1,d))	
		else:
			return min(abs(x+d), abs(x-d))
	else:
		if x > d:
			if x/d <= k:
				return f(x - (x/d) * d, k - x/d, d)
			elif x / d > k:
				#get as close to zero as u can
				return f(x - k*d, 0, d)
		elif x < -d:
			return f(-x, k, d)

print f(x,k,d)

Fixed submission:
x,k,d = map(int, raw_input().split())
def f(x,k,d):
	if k == 0:
		return abs(x)

	if abs(x) <= d:
		if k % 2 == 0:
			if k <= 2:
				return abs(x)
			else:
				return min(abs(x),abs(x-2*d), abs(x+2*d) )#f(x+d,k-1,d), f(x-d,k-1,d))	
		else:
			return min(abs(x+d), abs(x-d))
	else:
		if x > d:
			if x/d <= k:
				return f(x - (x/d) * d, k - x/d, d)
			elif x / d > k:
				#get as close to zero as u can
				return f(x - k*d, 0, d)
		elif x < -d:
			return f(-x, k, d)

print f(x,k,d)
Buggy python submission (verdict: Time Limit Exceeded):


ais = [raw_input() for _ in range(int(raw_input()))]
ais.sort(key = len)
import collections
cc = collections.Counter()

def f(w):
	res = set()
	for i in range(len(w)):
		#keep i th
		res.add(w[i])
		for j in range(i+1,len(w)):
			res.add(w[i] + w[j:])
	
	return res

ans = 0
for w in ais:
	for g in f(w):
		ans += cc[g]
	cc[w] +=1
print ans

Fixed submission:

class TN(object):
	def __init__(self):
		self.h = {}
		self.count = 0
		self.need = collections.Counter()


ais = [raw_input() for _ in range(int(raw_input()))]
ais.sort(key = len)
import collections
cc = collections.Counter()

ans = 0
root = TN()
for w in ais:
	
	###COUNT
	cur =  root
	for j in range(len(w)-1, -1, -1):
		for k in cur.need:
			if k in w[:j+1]:
				ans += cur.need[k]
		if w[j] in cur.h:
			cur = cur.h[w[j]]
		else:
			break
	###UPDATE
	cur = root
	for j in range(len(w) - 1, 0, -1):
		if w[j] not in cur.h:
			cur.h[w[j]] = TN()
		cur = cur.h[w[j]]
	cur.need[w[0]] += 1

print ans
Buggy python submission (verdict: Runtime Error):
"""According to a fortune-teller, a white stone placed to the immediate left of a red stone 
WR leads to nok
"""
n = int(raw_input())
s = list(raw_input())
import collections


def f(s):
	cc = collections.Counter(s)
	if cc['R'] == 0 or cc['W'] == 0:
		return 0
	i = 0
	j = len(s) - 1
	while(s[i] == 'R'): i +=1
	while(s[j] == 'W'): j +=1
	
	c = 0
	while(i < j):
		if s[i] == 'W' and s[j] == 'R':
			s[i],s[j] = s[j],s[i]
			i += 1
			j -= 1
			c += 1
		while(i < j and s[i] == 'R'): i+=1
		while(i < j and s[j] == 'W'): j-=1
	return min(c, cc['R'], cc['W'])

print f(s)

Fixed submission:
"""According to a fortune-teller, a white stone placed to the immediate left of a red stone 
WR leads to nok
"""
n = int(raw_input())
s = list(raw_input())
import collections


def f(s):
	cc = collections.Counter(s)
	if cc['R'] == 0 or cc['W'] == 0:
		return 0
	i = 0
	j = len(s) - 1
	#while(i < len(s) and s[i] == 'R'): i +=1
	#while(j>=0 and s[j] == 'W'): j -=1
	
	c = 0
	while(i < j):
		if s[i] == 'W' and s[j] == 'R':
			s[i],s[j] = s[j],s[i]
			i += 1
			j -= 1
			c += 1
		while(i < j and s[i] == 'R'): i+=1
		while(i < j and s[j] == 'W'): j-=1
	return min(c, cc['R'], cc['W'])

print f(s)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n,k = map(int , raw_input().split())

q = collections.deque([])
cumul = 1
prev = 0
for ai in map(int, raw_input().split()):
	cumul *= ai
	q.append(ai)
	if len(q) == k + 1:
		cumul /= q.popleft()


	if len(q) == k:
		if prev != 0:
			print 'Yes' if cumul > prev else 'No'
		prev = cumul

Fixed submission:
n,k = map(int , raw_input().split())
ais = map(int, raw_input().split())
for ii in range(k, n):
	print 'Yes' if ais[ii] > ais[ii - k] else 'No'
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(raw_input())
h = collections.Counter()
for x in range(1,n+1):
	for y in range(1,n+1):
		for z in range(1,n+1):
			q = x ** 2 + y ** 2 + z ** 2
			q += x*y + y*z + z * x
			if q > n:
				break
			h[q] +=1 
for i in range(1,n+1):
	print h[i]

Fixed submission:
import collections
n = int(raw_input())
h = collections.Counter()
for x in range(1,n+1):
	if x ** 2 > n:
		break
	for y in range(1,n+1):
		if x ** 2 + y ** 2 + x * y > n:
			break
		for z in range(1,n+1):
			q = x ** 2 + y ** 2 + z ** 2
			q += x*y + y*z + z * x
			if q > n:
				break
			h[q] +=1 
for i in range(1,n+1):
	print h[i]
Buggy python submission (verdict: Runtime Error):
import collections
n = raw_input()
cc = collections.Counter([raw_input() for _ in range(n)])

for u in ['AC', 'WA', 'TLE', 'RE']:
	print '{}x{}'.format(u, cc[u])

Fixed submission:
import collections
n = int(raw_input())
cc = collections.Counter([raw_input() for _ in range(n)])

for u in ['AC', 'WA', 'TLE', 'RE']:
	print '{} x {}'.format(u, cc[u])
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int, raw_input().split(' '))
ais = map(int,raw_input().split(' '))
bis = map(int,raw_input().split(' '))

mem = {}
def f(i,j,k,ais,bis):
	if (i,j,k) in mem:
		return mem[(i,j,k)]
	m = 0
	if i < len(ais) and ais[i] <= k:
		m = max(m , 1+ f(i + 1,j, k - ais[i],ais,bis ))
	if j < len(bis) and bis[j] <= k:
		m = max(m , 1+ f(i,j+1, k - bis[i],ais,bis ))
	mem[(i,j,k)] = m
	return m

print f(0,0, k, ais, bis)


Fixed submission:
import collections
n,m,k = map(int, raw_input().split(' '))
ais = map(int,raw_input().split(' '))
bis = map(int,raw_input().split(' '))
cumul = 0
pais = [0]
for ai in ais:
	cumul +=ai
	pais.append(cumul)

cumul = 0
pbis = [0]
for ai in bis:
	cumul +=ai
	pbis.append(cumul)
	


q = 0
for j,bi in enumerate(pbis):

	if k >= bi:
		j
		qq = k - bi
		lo,hi = 0, len(pais)-1
		while(lo < hi):
			med = (lo + hi + 1) >> 1
			if pais[med] <= qq:
				lo = med
			else:
				hi = med -1
		
		ans = j + lo
		q = max(ans, q)
print q
Buggy python submission (verdict: Runtime Error):

s = raw_input()
print 'a' if a.lower() == a else 'A'

Fixed submission:
a = raw_input()
print 'a' if a.lower() == a else 'A'
Buggy python submission (verdict: Runtime Error):
n,k = map(int ,raw_input().split(' '))
prices = map(int, raw_input().split(' ')
print sum(prices[:k])

Fixed submission:
n,k = map(int ,raw_input().split(' '))
prices = map(int, raw_input().split(' '))
prices.sort()
print sum(prices[:k])
Buggy python submission (verdict: Runtime Error):
x,y = map(int, raw_input().split(' '))


"""
a + b = x
2a + 4b = y

a = x-b
2x- 2b + 4b = y

a = x-b
2b = y  - 2x
"""
def f(x,y):
  
	if (y - 2*x) < 0 or (y - 2*x) %2 != 0:
      return False
  	b = y - 2*x
    a = x - b
    if a < 0:
      return False
    return True
  
print 'Yes' if f(x,y) else 'No'

Fixed submission:
x,y = map(int, raw_input().split(' '))


"""
a + b = x
2a + 4b = y

a = x-b
2x- 2b + 4b = y

a = x-b
2b = y  - 2x
"""
def f(x,y):
  	
	if (y - 2*x) < 0: return False
	b = (y - 2*x)/2
	a = x - b

	b = (y - 2*x)/2
	a = x - b
	
	if a < 0: return False


	return a+b == x and 2*a + 4*b ==y
  
print 'Yes' if f(x,y) else 'No'