Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(10**9):
    a.sort(reverse=True)
    cnt = 0
    for j in range(N):
        if a[j]%2 == 0 and cnt == 0:
            a[j] //= 2
            cnt = 1
        else:
            a[j] *= 3
    if cnt == 0:
        print(ans)
        exit()
    else:
        ans +=1

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(N):
    while a[i] % 2 == 0:
        a[i] //= 2
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = [2, 1]
for i in range(n-1):
    L = l[i] + l[i+1]
    l.append(L)
print(L)

Fixed submission:
n = int(input())
l = [2, 1]
for i in range(n-1):
    L = l[i] + l[i+1]
    l.append(L)
print(l[n])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10 ** 9)
n,m = map(int, input().split())
ab = []
c = [set() for i in range(n)]

for i in range(m):
  a = list(map(int, input().split()))
  a.sort()
  x,y = a[0]-1,a[1]-1
  c[x].add(y)
  c[y].add(x)

def dfs(s):
  if vis[s] == False:
    ary.append(s)
    vis[s] = True
    for j in c[s]:
      dfs(j)



vis = [False for i in range(n)]

ans= []

for i in range(n):
  ary = []
  dfs(i)
  if len(ary) == 0:
    continue
  ans.append(len(ary))

print (len(ans)-1)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)
n,m = map(int, input().split())
ab = []
c = [set() for i in range(n)]

for i in range(m):
  a = list(map(int, input().split()))
  a.sort()
  x,y = a[0]-1,a[1]-1
  c[x].add(y)
  c[y].add(x)

def dfs(s):
  if vis[s] == False:
    ary.append(s)
    vis[s] = True
    for j in c[s]:
      dfs(j)

vis = [False for i in range(n)]

ans= []

for i in range(n):
  ary = []
  dfs(i)
  if len(ary) == 0:
    continue
  ans.append(len(ary))

print (len(ans)-1)
Buggy python submission (verdict: Runtime Error):
n,x,m = map(int, input().split())

chk = [0 for i in range(m)]
a = x
s = x
c = 1
ary = [x]
flg = False
while True:
  if c == n:
    break
  x = (x**2)%m
  s += x
  c += 1
  if chk[x]:
    flg = True
    break
  ary.append(x)
  chk[x] = c
if flg == False:
  print (s)
  exit()
cyc = ary[chk[x]:]
l1 = len(cyc)
ss = ary[:chk[x]]
l2 = len(ss)
tot = sum(ss) + sum(cyc)*((n-l2)//l1) + sum(cyc[:(n-l2)%l1])
print (tot)

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

chk = [0 for i in range(m)]
a = x
s = x
c = 0
ary = [x]
flg = False
while True:
  if c == n:
    break
  x = (x**2)%m
  s += x
  c += 1
  if chk[x]:
    flg = True
    break
  ary.append(x)
  chk[x] = c
if flg == False:
  print (sum(ary[:-1]))
  exit()
cyc = ary[chk[x]:]
l1 = len(cyc)
ss = ary[:chk[x]]
l2 = len(ss)
tot = sum(ss) + sum(cyc)*((n-l2)//l1) + sum(cyc[:((n-l2)%l1)])
print (tot)
Buggy python submission (verdict: Runtime Error):
from collections import deque
h, w = map(int ,input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1

s = []
for i in range(h):
  t = input()
  s.append(t)

dx = [1,0,-1,0]
dy = [0,1,0,-1]

queue = deque([[ch,cw]])
visited = [[False for i in range(w)] for j in range(h)]
magic = [[-1 for i in range(w)] for j in range(h)]
visited[ch][cw] = True
magic[ch][cw] = 0
while queue:
  l,m = queue.popleft()
  for k in range(4):
    x = l + dx[k]
    y = m + dy[k]
    if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] or s[x][y] == "#":
      continue
    #visited[x][y] = visited[l][m] + 1
    visited[x][y] = True
    magic[x][y] = magic[l][m]
    queue.append([x,y])
  if len(queue) == 0:
    for i in range(-2,3):
      for j in range(-2,3):
        if (i== 1 and j == 0)or(i==-1 and j == 0)or(i==0 and j == 1)or(i==0 and j==-1)or(i==0 and j==0):
          continue
        x = l + i
        y = m + j
        if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] or s[x][y] == "#":
          continue
        visited[x][y] = True
        magic[x][y] = magic[l][m] + 1
        queue.append([x,y])
        cnt += 1
print (magic[dh][dw])

Fixed submission:
from collections import deque
h, w = map(int ,input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch -= 1
cw -= 1
dh -= 1
dw -= 1

s = []
for i in range(h):
  t = input()
  s.append(t)

dx = [1,0,-1,0]
dy = [0,1,0,-1]

queue = deque([[ch,cw]])
visited = [[1000000 for i in range(w)] for j in range(h)]
visited[ch][cw] = 0
while queue:
  l,m = queue.popleft()
  d = visited[l][m]
  for k in range(4):
    x = l + dx[k]
    y = m + dy[k]
    if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] <= d or s[x][y] == "#":
      continue
    visited[x][y] = d
    queue.appendleft([x,y])
  for i in range(-2,3):
    for j in range(-2,3):
      if (i== 1 and j == 0)or(i==-1 and j == 0)or(i==0 and j == 1)or(i==0 and j==-1)or(i==0 and j==0):
        continue
      x = l + i
      y = m + j
      if x < 0 or y < 0 or x >= h or y >= w or visited[x][y] <= d+1 or s[x][y] == "#":
        continue
      visited[x][y] = d + 1
      queue.append([x,y])
  #print (queue)
if visited[dh][dw] == 1000000:
  print (-1)
else:
  print (visited[dh][dw])
Buggy python submission (verdict: Runtime Error):
x,k,d = map(int, input().split())
mx = x + d*k
mn = x - d*k
 
if (x <= 0 and mx > 0) or (x >= 0 and mn < 0):
  if k%2 == 0:
    if x < 0:
      b = min(abs(abs(x)%(2*d)),abs(abs(x)%(2*d)-2*d))
    else:
      b = min(abs(x%(2*d)),abs(x%(2*d)-2*d))
    b = min(abs(b),abs(mx),abs(mn))
  else:
    if x > 0:
      b = min(abs(abs(x-d)%(2*d)),abs(abs(x-d)%(2*d)-2*d))
    else:
      b = min(abs(abs(x+d)%(2*d)),abs(abs(x+d)%(2*d)-2*d))
  ans = min(abs(b),abs(mx),abs(mn))
else:
  ans = min(abs(mx),abs(mn))
print (ans)

Fixed submission:
s = input()

if s == 'RSR':
  print (1)
else:
  print (s.count('R'))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int, input().split()))

def check(x):
  c = 0
  for i in range(n):
    c += a[i]//x
  if c <= k:
    return True
  else:
    return False

mx = max(a)
mn = 0
ans = [mx]
while mn <= mx:
  m = (mx+mn)//2
  if check(m):
    mx = m - 1
    ans.append(m)
  else:
    mn = m + 1
print (min(ans))


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

def check(x):
  c = 0
  for i in range(n):
    c += a[i]//x
    if a[i]%x == 0:
      c -= 1
  if c <= k:
    return True
  else:
    return False

mx = max(a)
mn = 0
ans = [mx]
while mn <= mx:
  m = (mx+mn)//2
  if m == 0:
    if check(1):
      ans.append(1)
    break
  if check(m):
    mx = m - 1
    ans.append(m)
  else:
    mn = m + 1
print (min(ans))

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

def check(x):
  c = 0
  for i in range(n):
    c += a[i]//x
  if c <= k:
    return True
  else:
    return False

mx = max(a)
mn = 0
ans = [mx+mn//2]
while mn <= mx:
  m = (mx+mn)//2
  if check(m):
    mx = m - 1
    ans.append(m)
  else:
    mn = m + 1
print (min(ans))


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

def check(x):
  c = 0
  for i in range(n):
    c += a[i]//x
    if a[i]%x == 0:
      c -= 1
  if c <= k:
    return True
  else:
    return False

mx = max(a)
mn = 0
ans = [mx]
while mn <= mx:
  m = (mx+mn)//2
  if m == 0:
    if check(1):
      ans.append(1)
    break
  if check(m):
    mx = m - 1
    ans.append(m)
  else:
    mn = m + 1
print (min(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

s = a[:k]

for i in range(n-k):
  b = s[0]
  if a[k+i] > b:
    print ('Yes')
  else:
    print ('No')
  s.append(a[k+i])
  s.pop(0)

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

s = a[:k]

for i in range(n-k):
  b = s[0]
  if a[k+i] > b:
    print ('Yes')
  else:
    print ('No')
  s.append(a[k+i])
  s.pop(0)
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()))
aa = a.copy()
bb = b.copy()
sa = sum(a)
sb = sum(b)
c = [10**10 for i in range(n+m+1)]
c[n+m] = sa + sb
x = sa + sb
c[0] = 0
for i in range(1,n+m):
  if len(a) == 0:
    x -= b[-1]
    b.pop(-1)
    c[n+m-i] = x
    continue
  if len(b) == 0:
    x -= a[-1]
    a.pop(-1)
    c[n+m-i] = x
    continue
  if a[-1] > b[-1]:
    x -= a[-1]
    a.pop(-1)
  else:
    x -= b[-1]
    b.pop(-1)
  c[n+m-i] = x

s = 0
d = [0 for i in range(n+m+1)]
for i in range(n+m+1):
  if i == 0:
    continue
  if len(aa) == 0:
    s += bb[0]
    bb.pop(0)
    d[i] = s
    continue
  if len(bb) == 0:
    x += aa[0]
    aa.pop(0)
    d[i] = s
    continue
  if aa[0] > bb[0]:
    s += bb[0]
    bb.pop(0)
  else:
    s += aa[0]
    aa.pop(0)
  d[i] = s
  e = min(c[i],d[i])
  if e > k:
    print (i-1)
    exit()
if e <= k:
  print (n+m)
else:
  print (0)


Fixed submission:
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sa = [0 for i in range(n+1)]
sb = [0 for i in range(m+1)]

c = 0

for i in range(n):
  c += a[i]
  sa[i+1] = c
c = 0
for i in range(m):
  c += b[i]
  sb[i+1] = c
ans = 0
# if k >= sum(a)+sum(b):
#   print (n+m)
#   exit()
for i in range(n+1):
  x = k - sa[i]
  if x < 0:
    continue
  y = bisect.bisect_right(sb,x)
  y += i
  ans = max(ans, y-1)
print (ans)

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()))
aa = a.copy()
bb = b.copy()
sa = sum(a)
sb = sum(b)
ans = 10**7
c = [10**10 for i in range(n+m+1)]
c[n+m] = sa + sb
x = sa + sb
c[0] = 0
for i in range(1,n+m):
  if len(a) == 0:
    x -= b[-1]
    b.pop(-1)
    c[n+m-i] = x
    continue
  if len(b) == 0:
    x -= a[-1]
    a.pop(-1)
    c[n+m-i] = x
    continue
  if a[-1] > b[-1]:
    x -= a[-1]
    a.pop(-1)
  else:
    x -= b[-1]
    b.pop(-1)
  c[n+m-i] = x

s = 0
d = [0 for i in range(n+m)]
for i in range(n+m):
  if len(aa) == 0:
    s += bb[0]
    bb.pop(0)
    d[i] = s
    continue
  if len(bb) == 0:
    x += aa[0]
    aa.pop(0)
    d[i] = s
    continue
  if aa[0] > bb[0]:
    s += bb[0]
    bb.pop(0)
  else:
    s += aa[0]
    aa.pop(0)
  d[i] = s
d = [0] + d

for i in range(n+m+1):
  e = min(c[i],d[i])
  if e > k:
    print (i-1)
    exit()
if e <= k:
  print (n+m)
else:
  print (0)


Fixed submission:
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

sa = [0 for i in range(n+1)]
sb = [0 for i in range(m+1)]

c = 0

for i in range(n):
  c += a[i]
  sa[i+1] = c
c = 0
for i in range(m):
  c += b[i]
  sb[i+1] = c
ans = 0
# if k >= sum(a)+sum(b):
#   print (n+m)
#   exit()
for i in range(n+1):
  x = k - sa[i]
  if x < 0:
    continue
  y = bisect.bisect_right(sb,x)
  y += i
  ans = max(ans, y-1)
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
s = input()
mod = 10**9+7
n = len(s)
fact =[1]*(k+n)
factinv = [1]*(k+n)
inv = [0,1]
 
 
for i in range(2,k+n):
    fact[i] = (fact[i-1] * i) % mod
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv[i] = (factinv[i-1] * inv[i]) % mod

def nCr(n,r):
  r = min(r,n-r)
  return (fact[n] * factinv[r] * factinv[n-r])%mod
ans = 0
for i in range(k+1):
  a = pow(25, i, mod)
  a *= nCr(i+n-1, n-1)
  a *= pow(26,k-i, mod)
  ans += a
  ans %= mod
print (ans)

Fixed submission:
k = int(input())
s = input()
mod = 10**9+7
n = len(s)
fact =[1]*(k+n)
factinv = [1]*(k+n)
inv = [0,1]
 
 
for i in range(2,k+n):
    fact[i] = (fact[i-1] * i) % mod
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv[i] = (factinv[i-1] * inv[i]) % mod

def nCr(n,r):
  r = min(r,n-r)
  return (fact[n] * factinv[r] * factinv[n-r])%mod
ans = 0
for i in range(k+1):
  a = pow(25, i, mod)
  a *= nCr(i+n-1, n-1)
  a *= pow(26,k-i, mod)
  ans += a
  ans %= mod
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
s = input()
mod = 10**9+7
n = len(s)
def nCr(N, R, mod):
	R = min(R, N-R)
	numer = denom = 1
	for i in range(1, R+1):
		numer = numer * (N+1-i) % mod
		denom = denom * i % mod
	return numer * pow(denom, mod-2, mod) % mod


ans = 0
for i in range(k+1):
  a = pow(25, i, mod)
  a *= nCr(i+n-1, n-1, mod)
  a *= pow(26,k-i, mod)
  ans += a
  ans %= mod
print (ans)

Fixed submission:
k = int(input())
s = input()
mod = 10**9+7
n = len(s)
fact =[1]*(k+n)
factinv = [1]*(k+n)
inv = [0,1]
 
 
for i in range(2,k+n):
    fact[i] = (fact[i-1] * i) % mod
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv[i] = (factinv[i-1] * inv[i]) % mod

def nCr(n,r):
  r = min(r,n-r)
  return (fact[n] * factinv[r] * factinv[n-r])%mod
ans = 0
for i in range(k+1):
  a = pow(25, i, mod)
  a *= nCr(i+n-1, n-1)
  a *= pow(26,k-i, mod)
  ans += a
  ans %= mod
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
s = input()
mod = 10**9+7
n = len(s)
def nCr(N, R, mod):
	R = min(R, N-R)
	numer = denom = 1
	for i in range(1, R+1):
		numer = numer * (N+1-i) % mod
		denom = denom * i % mod
	return numer * pow(denom, mod-2, mod) % mod


ans = 0
for i in range(k+1):
  a = pow(25, i, mod)
  a *= nCr(i+n-1, n-1, mod)
  a *= pow(26,k-i, mod)
  ans += a
  ans %= mod
print (ans)

Fixed submission:
k = int(input())
s = input()
mod = 10**9+7
n = len(s)
fact =[1]*(k+n)
factinv = [1]*(k+n)
inv = [0,1]
 
 
for i in range(2,k+n):
    fact[i] = (fact[i-1] * i) % mod
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv[i] = (factinv[i-1] * inv[i]) % mod

def nCr(n,r):
  r = min(r,n-r)
  return (fact[n] * factinv[r] * factinv[n-r])%mod
ans = 0
for i in range(k+1):
  a = pow(25, i, mod)
  a *= nCr(i+n-1, n-1)
  a *= pow(26,k-i, mod)
  ans += a
  ans %= mod
print (ans)
Buggy python submission (verdict: Runtime Error):
import math
a, b, h, m = map(int, input().split())
x = 360*(h/12)+30*(m/60)
y = 360*(m/60)
d = math.cos(math.radians(abs(x-y)))
z = a**2 + b**2 -2*a*b*d
print (math.sqrt(z))


Fixed submission:
k = int(input())
s = input()
if len(s) <= k:
	print (s)
else:
	print (s[:k] + "...")
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
ary = []
a = []
b = []
ary = [0 for i in range(n)]
chk = [False for i in range(n)]
d = {}
for i in range(m):
	aa, bb = map(int, input().split())
	if aa not in d:
		d[aa] = []
	d[aa].append(bb)
	if bb not in d:
		d[bb] = []
	d[bb].append(aa)

flg = True
e = set()
e.add(1)
#print (d)

chk[0] = True
f = set()
cnt = 0
while True:
	flg = False
	for i in e:
		for j in d[i]:
			if chk[j-1]:
				continue
			if ary[j-1] == 0:
				flg = True
				ary[j-1] = i
				chk[j-1] = True
				cnt += 1
				f.add(j)
	e = f.copy()
	if flg == False:
		break
if cnt < n-1:
	print ("No")
else:
	print ("Yes")
	for i in ary[1:]:
		print(i)


Fixed submission:
from collections import deque
n, m = map(int, input().split())
ary = []
a = []
b = []
ary = [0 for i in range(n)]
chk = [False for i in range(n)]
d = {}
for i in range(m):
	aa, bb = map(int, input().split())
	if aa not in d:
		d[aa] = []
	d[aa].append(bb)
	if bb not in d:
		d[bb] = []
	d[bb].append(aa)

visited = [-1 for i in range(n)]
visited[0] = 0
queue = deque([1])
while queue:
	c = queue.popleft()
	for i in d[c]:
		if visited[i-1] != -1:
			continue
		visited[i-1] = c
		queue.append(i)
for i in visited:
	if i == -1:
		print ("No")
		exit()
print ("Yes")
for i in visited[1:]:
	print (i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

dicplus = {}
dicmins = {}
for i in range(n):
	b = a[i] + i
	c = a[i] - i
	if b not in dicplus:
		dicplus[b] = 1
	else:
		dicplus[b] += 1
	if c not in dicmins:
		dicmins[c] = 1
	else:
		dicmins[c] += 1

ans = 0
for i in dicplus:
	for j in dicmins:
		if i + j == 0:
			ans += dicplus[i] * dicmins[j]
print (ans)

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

dicplus = {}
dicmins = {}
for i in range(n):
	b = i + a[i]
	c = i - a[i]
	if b not in dicplus:
		dicplus[b] = 1
	else:
		dicplus[b] += 1
	if c not in dicmins:
		dicmins[c] = 1
	else:
		dicmins[c] += 1

ans = 0
for i in dicplus:
	if i in dicmins:
		ans += dicplus[i] * dicmins[i]
print (ans)

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

cnt = 0
for i,j in itertools.combinations(b,2):
	if abs(i[0]-j[0]) == i[1] + j[1]:
		cnt += 1
print (cnt)

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

dicplus = {}
dicmins = {}
for i in range(n):
	b = i + a[i]
	c = i - a[i]
	if b not in dicplus:
		dicplus[b] = 1
	else:
		dicplus[b] += 1
	if c not in dicmins:
		dicmins[c] = 1
	else:
		dicmins[c] += 1

ans = 0
for i in dicplus:
	if i in dicmins:
		ans += dicplus[i] * dicmins[i]
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

c = [0 for i in range(2019)]
c[0] = 1
mod = 2019
d = 1
x = 0
for i,j in enumerate(s[::-1]):
	x = (x + int(j)*pow(10,i))%mod
	c[x] += 1

ans = 0
for i in range(2019):
	ans += (c[i]*(c[i]-1))//2
print (ans)


Fixed submission:
s = input()

c = [0 for i in range(2019)]
c[0] = 1
mod = 2019
d = 1
x = 0
for i,j in enumerate(s[::-1]):
	x = (x + int(j)*pow(10,i,mod))%mod
	c[x] += 1

ans = 0
for i in range(2019):
	ans += (c[i]*(c[i]-1))//2
print (ans)

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

c = [0 for i in range(2019)]
c[0] = 1
mod = 2019
d = 1
t = 0
x = 0
for i,j in enumerate(s[::-1]):
	x = (x + int(j)*pow(10,i))%mod
	c[x] += 1

ans = 0
for i in range(2019):
	ans += (c[i]*(c[i]-1))//2
print (ans)


Fixed submission:
s = input()

c = [0 for i in range(2019)]
c[0] = 1
mod = 2019
d = 1
x = 0
for i,j in enumerate(s[::-1]):
	x = (x + int(j)*pow(10,i,mod))%mod
	c[x] += 1

ans = 0
for i in range(2019):
	ans += (c[i]*(c[i]-1))//2
print (ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
s = input()

a = [i for i in range(len(s))]
c = 0
for v in itertools.combinations(a,2):
	x,y = v[0],v[1]
	if y-x < 4:
		continue
	#print (s[x:y+1],x,y)
	if int(s[x:y+1]) %2019 == 0:
		c += 1
print (c)



Fixed submission:
s = input()

c = [0 for i in range(2019)]
c[0] = 1
mod = 2019
d = 1
x = 0
for i,j in enumerate(s[::-1]):
	x = (x + int(j)*pow(10,i,mod))%mod
	c[x] += 1

ans = 0
for i in range(2019):
	ans += (c[i]*(c[i]-1))//2
print (ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
import math
from fractions import gcd
s = 0
for i in range(1,n+1):
	for j in range(1,n+1):
		for k in range(1,n+1):
			s += math.gcd(math.gcd(i,j),k)
print (s)

Fixed submission:
n = int(input())
import math
from fractions import gcd
s = 0
for i in range(1,n+1):
	for j in range(1,n+1):
		for k in range(1,n+1):
			s += math.gcd(math.gcd(i,j),k)
print (s)
Buggy python submission (verdict: Runtime Error):

n, m = map(int, input().split())
import math
def comb(n, r):
	return math.factorial(s) // (math.factorial(s - r) * math.factorial(s))
print (comb(n,2) + comb(m,2))

Fixed submission:
s = input()
n = len(s)
if s != s[::-1]:
	print ("No")
	exit()
if s[:n//2] != s[:n//2][::-1]:
	print ("No")
	exit()
if s[(n+3)//2-1:] != s[(n+3)//2-1:][::-1]:
	print ("No")
	exit()
print ("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())

if n == 1:
  w = ['a']
elif n == 2:
  w = ['aa','ab']
elif n == 3:
  w = ['aaa','aab','aba','abb','abc']
for s in w:
  print (s)

Fixed submission:
n = int(input())
v = 'abcdefghijk'

w = []
def dfs(s,t):
  if len(s) == n:
    w.append(s)
    return
  u = len(set(s))
  for i in range(u+1):
    dfs(s+v[i],u+1)

dfs('a',1)

for i in w:
  print (i)

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

if n == 1:
  w = ['a']
elif n == 2:
  w = ['aa','ab']
elif n == 3:
  w = ['aaa','aab','aba','abb']
for s in w:
  print (s)

Fixed submission:
n = int(input())
v = 'abcdefghijk'

w = []
def dfs(s,t):
  if len(s) == n:
    w.append(s)
    return
  u = len(set(s))
  for i in range(u+1):
    dfs(s+v[i],u+1)

dfs('a',1)

for i in w:
  print (i)
Buggy python submission (verdict: Runtime Error):
s = input()
if s == "hi" or s == "hihi" or s == "hihihi" or s == "hihihihi" or s == "hihihihihi"
	print ("Yes")
else:
	print ("No")

Fixed submission:
s = input()
if s == "hi" or s == "hihi" or s == "hihihi" or s == "hihihihi" or s == "hihihihihi":
	print ("Yes")
else:
	print ("No")
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ary = []
a = []
b = []
d = []
for i in range(m):
	s,c = map(int, input().split())
	if s == 1:
		a.append(c)
	elif s == 2:
		b.append(c)
	else:
		d.append(c)
if m == 0:
	print (-1)
	exit()
if n == 1:
	print (min(d))
	exit()
ans = 1000
if len(a) == 0:
	a.append(0)
if len(b) == 0:
	b.append(0)
if len(d) == 0:
	d.append(0)
for i in a:
	for j in b:
		for k in d:
			wk = str(i) + str(j) + str(k)
			if len(str(int(wk))) != n:
				continue
			else:
				ans = min(ans, int(wk))
if ans >= 1000:
	print (-1)
else:
	print (ans)

Fixed submission:
n, m = map(int, input().split())
a = []
for i in range(m):
	s,c = map(int, input().split())
	a.append([s,c])

for i in range(10**(n-1)-1,10**n):
	if len(str(i)) != n:
		continue
	if all(str(i)[s-1] == str(c) for s,c in a):
		print (i)
		exit()
print (-1)