Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
edges = {}
for _ in range(m):
  a, b = map(int, input().split())
  if a-1 in edges:
    edges[a-1].append(b-1)
  else:
    edges[a-1] = [b-1]
  if b-1 in edges:
    edges[b-1].append(a-1)
  else:
    edges[b-1] = [a-1]

end1, end2 = a-1, b-1

visited = [False for _ in range(n)]
visited[end1] = True
visited[end2] = True

seti = set([end1, end2])
path = [end1, end2]
while True:
  reme = None
  for _a in edges[end1]:
    if _a not in seti:
      reme = _a
      break
  if reme is not None:
    end1 = _a
    seti.add(_a)
    path = [_a] + path
  else:
    for _a in edges[end2]:
      if _a not in seti:
        reme = _a
        break
    if reme is not None:
      end2 = _a
      seti.add(_a)
      path += [_a]
  if reme is None:
    break

print(len(path))
print(*map(lambda x: x+1, path))


Fixed submission:
n, m = map(int, input().split())
edges = {}
for _ in range(m):
  a, b = map(int, input().split())
  if a-1 in edges:
    edges[a-1].append(b-1)
  else:
    edges[a-1] = [b-1]
  if b-1 in edges:
    edges[b-1].append(a-1)
  else:
    edges[b-1] = [a-1]

end1, end2 = a-1, b-1

visited = [False for _ in range(n)]
visited[end1] = True
visited[end2] = True

seti = set([end1, end2])
path = [end1, end2]
while True:
  reme = None
  for _a in edges[end1]:
    if _a not in seti:
      reme = _a
      break
  if reme is not None:
    end1 = _a
    seti.add(_a)
    path = [_a] + path
  else:
    for _a in edges[end2]:
      if _a not in seti:
        reme = _a
        break
    if reme is not None:
      end2 = _a
      seti.add(_a)
      path += [_a]
  if reme is None:
    break

print(len(path))
print(*map(lambda x: x+1, path))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)

col = [0 for _ in range(n)]
def bfs(bs, d, c):
  if d < 0:
    return
  nset = set()
  for b in bs:
    nset = nset.union(g[b])
    col[b] = c
  return bfs(nset, d-1, c)
  
q = int(input())
for _ in range(q):
  v, d, c = map(int, input().split())
  col[v-1] = c
  bfs(set(g[v-1]), d-1, c)
for c in col:
  print(c)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))


def main():
    n, m = map(int, input().split())
    ab = [tuple(map(int, input().split())) for _ in range(m)]
    edges = [[] for _ in range(n)]
    for a, b in ab:
        edges[a - 1].append(b - 1)
        edges[b - 1].append(a - 1)
    
    q = int(input())
    ans = [0 for _ in range(n)]
    dd = [-1 for _ in range(n)]
    vdc = [tuple(map(int, input().split())) for _ in range(q)]
    for v, d, c in vdc[::-1]:
        if dd[v - 1] >= d:
            #  v - 1 から距離 d の部分は塗りつぶされているため無視
            continue
        
        node = []
        node.append(v - 1)
        while d >= 0 and len(node) > 0:
            next_node = []
            while len(node) > 0:
                u = node.pop()
                if dd[u] >= d:
                    continue
                dd[u] = d
                if ans[u] == 0:
                    ans[u] = c
                for v in edges[u]:
                    if dd[v] < d - 1:
                        next_node.append(v)
            node = next_node
            d -= 1
    
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input().strip())
A = list(map(int, input().strip().split()))


if N % 2 == 1:
  if A.count(0) != 1:
    print(0)
  else:
    if not all([A.count(i) == 2 for i in range(2, N, 2)]):
      print(0)
    else:
      print(2 ** ((N - 1) // 2) % (10**9 + 7))
else:
  if not all([A.count(i) == 2 for i in range(1, N, 2)]):
    print(0)
  else:
    print(2 ** ((N // 2) % (10**9 + 7)))


Fixed submission:
N = int(input().strip())
A = list(sorted(map(int, input().strip().split())))

if N % 2 == 0:
  for i in range(0, N, 2):
    if A[i] != A[i+1]:
      print(0)
      break
  else:
    print(2**(N // 2) % 1000000007)
else:
  if A[0] != 0:
    print(0)
  else:
    for i in range(1, N, 2):
      if A[i] != A[i+1]:
        print(0)
        break
    else:
      print(2**((N-1)//2) % 1000000007)

Buggy python submission (verdict: Runtime Error):
N = int(input().strip())
A = map(int, input().strip().split())


if N % 2 == 1:
  if A.count(0) != 1:
    print(0)
  else:
    if not all([A.count(i) == 2 for i in range(2, N, 2)]):
      print(0)
    else:
      print(2 ** ((N - 1) // 2) % (10**9 + 7))
else:
  if not all([A.count(i) == 2 for i in range(1, N, 2)]):
    print(0)
  else:
    print(2 ** ((N // 2) % (10**9 + 7)))

Fixed submission:
N = int(input().strip())
A = list(sorted(map(int, input().strip().split())))

if N % 2 == 0:
  for i in range(0, N, 2):
    if A[i] != A[i+1]:
      print(0)
      break
  else:
    print(2**(N // 2) % 1000000007)
else:
  if A[0] != 0:
    print(0)
  else:
    for i in range(1, N, 2):
      if A[i] != A[i+1]:
        print(0)
        break
    else:
      print(2**((N-1)//2) % 1000000007)
Buggy python submission (verdict: Runtime Error):
S = input().strip()

while True:
  if S.endswith('dream'):
    S = S[:-5]
  elif S.endswith('dreamer'):
    S = S[:-7]
  elif S.endswith('erase'):
    S = S[:-5]
  elif S.endswith('eraser'):
    S = S[:-6]
  else break

if S:
  print("NO")
else:
  print('YES')

Fixed submission:
S = input().strip()

while True:
  if S.endswith('dream'):
    S = S[:-5]
  elif S.endswith('dreamer'):
    S = S[:-7]
  elif S.endswith('erase'):
    S = S[:-5]
  elif S.endswith('eraser'):
    S = S[:-6]
  else:
    break

if S:
  print("NO")
else:
  print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

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

people = []
lang = [[] for _ in range(m)]

for i in range(n):
  kl = list(map(int, input().split()))
  k = kl[0]
  people.append(kl[1:])
  for l in kl[1:]:
    lang[l-1].append(i)

visited = [False for _ in range(n)]

def dfs(i):
  if visited[i]:
    return
  else:
    visited[i] = True
    for l in people[i]:
      for nexp in lang[l-1]:
        dfs(nexp)

dfs(0)

if all(visited):
  print('YES')
else:
  print('NO')


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

def dfs(v):
    used[v] = True
    for _v in adjl[v]:
        if not used[_v]:
            dfs(_v)

n, m = map(int, input().split())
adjl = [[] for v in range(n + m)]
for i in range(n):
    kl = list(map(int, input().split()))
    k = kl[0]
    llist = kl[1:]
    for l in llist:
        adjl[i].append(l + n - 1)
        adjl[l + n - 1].append(i)

used = [False] * (n + m)
dfs(0)

if all(used[:n]):
  print('YES')
else:
  print('NO')

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

people = []
lang = [[] for _ in range(m)]

for i in range(n):
  kl = list(map(int, input().split()))
  k = kl[0]
  people.append(kl[1:])
  for l in kl[1:]:
    lang[l-1].append(i)

visited = [False for _ in range(n)]

def dfs(i):
  if visited[i]:
    return
  else:
    visited[i] = True
    for l in people[i]:
      for nexp in lang[l-1]:
        dfs(nexp)

dfs(0)

if all(visited):
  print('YES')
else:
  print('NO')


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

def dfs(v):
    used[v] = True
    for _v in adjl[v]:
        if not used[_v]:
            dfs(_v)

n, m = map(int, input().split())
adjl = [[] for v in range(n + m)]
for i in range(n):
    kl = list(map(int, input().split()))
    k = kl[0]
    llist = kl[1:]
    for l in llist:
        adjl[i].append(l + n - 1)
        adjl[l + n - 1].append(i)

used = [False] * (n + m)
dfs(0)

if all(used[:n]):
  print('YES')
else:
  print('NO')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
t, a = 1, 1

for _ in range(N):
  _t, _a = map(int, input().strip().split())
  if _t > _a:
    i = t // _t
  else:
    i = a // _a
  while True:
    if _t*i>=t and _a*i>=a:
      break
    else:
      i += 1
  t = _t*i
  a = _a*i
print(t+a)
    

Fixed submission:
N = int(input())
t, a = 1, 1

for _ in range(N):
  _t, _a = map(int, input().split())
  n = max(-(-t // _t), -(-a // _a))
  t, a = n*_t, n*_a
print(t + a)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
S = input()
passed = []

for i in range(N):
  if S[i] == 'c':
    print('No')
  elif S[i] == 'a':
    if len(passed) <= A+B:
      print('Yes')
      passed.append('a')
    else: print('No')
  else:
    if len(passed) <= A+B and passed.count('b') <= B:
      print('Yes')
      passed.append('b')
    else: print('No')

Fixed submission:
s = input()
chs = list(s)
str = 'CODEFESTIVAL2016'
count = 0
for i, ch in enumerate(chs):
  if ch != str[i]:
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
S = input()
passed = []

for i in range(N):
  if S[i] == 'c':
    print('No')
  elif S[i] == 'a':
    if len(passed) < A+B:
      print('Yes')
      passed.append('a')
    else: print('No')
  else:
    if len(passed) < A+B and passed.count('b') < B:
      print('Yes')
      passed.append('b')
    else: print('No')

Fixed submission:
n, a, b = map(int, input().split())
s = input().strip()

sumy = 0
sumf = 0
for _s in s:
  if _s == 'c':
    print('No')
  elif _s == 'a':
    if sumy < a + b:
      print('Yes')
      sumy += 1
    else:
      print('No')
  else:
    if sumy < a + b and sumf < b:
      print('Yes')
      sumy += 1
      sumf += 1
    else:
      print('No')
Buggy python submission (verdict: Runtime Error):
import heapq

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

ad = {}
for i, a in enumerate(alist):
  ad[a] = i

h = []
right = [n-1] * n

for i in range(n):
  while h and -h[0] > alist[i]:
    v = -heapq.heappop(h)
    right[ad[v]] = i - 1
  heapq.heappush(h, -alist[i])
  print(right, h)

h = []
left = [0] * n

for i in reversed(range(n)):
  while h and -h[0] > alist[i]:
    v = -heapq.heappop(h)
    left[ad[v]] = i + 1
  heapq.heappush(h, -alist[i])
  print(left, h)

ans = 0
for i in range(n):
  ans += alist[i] * (i - left[i] + 1) * (right[i] - i + 1)
  print(ans)

print(ans)


Fixed submission:
import heapq

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

ad = {}
for i, a in enumerate(alist):
  ad[a] = i

h = []
right = [n-1] * n

for i in range(n):
  while h and -h[0] > alist[i]:
    v = -heapq.heappop(h)
    right[ad[v]] = i - 1
  heapq.heappush(h, -alist[i])

h = []
left = [0] * n

for i in reversed(range(n)):
  while h and -h[0] > alist[i]:
    v = -heapq.heappop(h)
    left[ad[v]] = i + 1
  heapq.heappush(h, -alist[i])

ans = 0
for i in range(n):
  ans += alist[i] * (i - left[i] + 1) * (right[i] - i + 1)

print(ans)
Buggy python submission (verdict: Runtime Error):
R,G,B=map(int,input().split())
K=int(input())
#print(R,G,B,K)

for i in range(K):
  #print(R,G,B,K)
  if(B<=G):
    B*=2
    continue
  if(G<=R):
    G*=2
    continue
#print(R,G,B,K)
if(R<G and G<B):
  print('Yes')
else:
  print('No')

Fixed submission:
x=int(input())
if(400<=x and x<=599):
	print(8)
if(600<=x and x<=799):
	print(7)
if(800<=x and x<=999):
	print(6)
if(1000<=x and x<=1199):
	print(5)
if(1200<=x and x<=1399):
	print(4)
if(1400<=x and x<=1599):
	print(3)
if(1600<=x and x<=1799):
	print(2)
if(1800<=x and x<=1999):
	print(1)
Buggy python submission (verdict: Runtime Error):
a=input()
print(a%1000)

Fixed submission:
a=int(input())
if(a%1000==0):
  print(a%1000)
else:
  print(1000-a%1000)
Buggy python submission (verdict: Runtime Error):
a=input().split()
pl1=int(a[0])
pl0=int(a[1])
pl_1=int(a[2])
draw=int(a[3])
#print(pl1,pl0,pl_1,draw)
if(pl1>=draw):
  print(draw)
elif(pl1+pl0>=draw):
  print(pl1)
else:
  all_card=pl1+pl0+pl_1
  #print(all_card)
  draw_pl_1=all_card-draw
  #print(draw_pl_1)
  print(pl1-draw_pl_1)

Fixed submission:
a=input()
b=input()
if(a == b[:-1]):
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
a=input().split()
pl1=int(a[0])
pl0=int(a[1])
pl_1=int(a[2])
draw=int(a[3])

if(pl1+pl0>draw):
  print(pl1)
else:
  all_card=pl1+pl0+pl_1
  print(all_card)
  draw_pl_1=all_card-draw
  print(draw_pl_1)
  print(pl1-draw_pl_1)

Fixed submission:
a=input()
b=input()
if(a == b[:-1]):
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
ans=1
mod=10**9+7

if (x+y)%3==0 and x<=2*y and y<=2*x:
    a=(x+y)/3
    b=(2*x-y)/3
    a=int(a)
    b=int(b)
    f=[1]
    
    for i in range(1,a+1):
        f.append(f[-1]*i%mod)
    #print(f)
    ans=f[a]//f[b]//f[a-b]  #aCbが答
    if ans>mod:
        ans=ans%mod
else:
    ans=0
print(int(ans))

Fixed submission:
print(int(input())**2)
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x,y):
    return x*y//math.gcd(x,y)

def ABC(x,y,z):
    return z-(z//x+z//y-z//lcm(x,y))

a,b,c,d=map(int,input().split())
print(ABC(c,d,b)-ABC(c,d,a-1))

Fixed submission:
import fractions
def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

def ABC(x,y,z):
    return z-(z//x+z//y-z//lcm(x,y))

a,b,c,d=map(int,input().split())
print(ABC(c,d,b)-ABC(c,d,a-1))
Buggy python submission (verdict: Runtime Error):
# 

a,b,x=map(int,input().split())

c=b-a
d=int(c/1e15)
e=int(c-d*1e15)
#print(d,e,c)
if a%x==0 and b%x==0:
    print(d+1)
else:
    print(d)


Fixed submission:
# 

s=input()
t=s.split(" ")
print("A"+t[1][0]+"C")

Buggy python submission (verdict: Runtime Error):
# 

a,b,x=map(int,input().split())

c=b-a
d=int(c/1e15)
e=int(c-d*1e15)
#print(d,e,c)
if a%x==0 and b%x==0:
    print(d+1)
else:
    print(d)


Fixed submission:
# 

s=input()
t=s.split(" ")
print("A"+t[1][0]+"C")
Buggy python submission (verdict: Runtime Error):
x,y = map(int,input().split())
z = 2*x + y/2
if (z - floor(z) == 0):
  print("Yes")
else:
  print("No")

Fixed submission:
from math import floor
x,y = map(int,input().split())
for i in range(0,x+1):
    if (2*(i) + 4*(x-i) == y):
        print("Yes")
        exit(0);
print("No")
Buggy python submission (verdict: Runtime Error):
from math import ceil
a,b,c,d = map(int, input().split())
x = (a+d-1)/d
y = (b+c-1)/b
if (x>=y):
  print("Yes")
  else:
    print("No")

Fixed submission:
from math import ceil
a,b,c,d = map(int, input().split())
x = ceil(a/d)
y = ceil(c/b)
if (x>=y):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input())
pn = n
while(abs(n-k)<n):
  pn = n
  n = abs(n-k)
print(pn)

Fixed submission:
n,k = map(int,input().split())
ans = n%k
if (abs(ans-k) < ans):
	ans = abs(ans-k)
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input())
if (a<=8 and b<=8):
  print("Yay!")
else:
  print(":(")

Fixed submission:
a,b = map(int,input().split())
if (a<=8 and b<=8):
  print("Yay!")
else:
  print(":(")
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
ans=0
for i in range(3):
  if(S[i]==T[i])ans+=1
print(ans)

Fixed submission:
S=input()
T=input()
ans=0
for i in range(3):
  if S[i]==T[i]:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a=input()
print("Good") if a[0]!=a[1]&a[1]!=a[2]&a[2]!=a[3] else print("Bad")

Fixed submission:
a=input()
if a[0]==a[1] or a[1]==a[2] or a[2]==a[3]:
  print("Bad")
else:
  print("Good")

Buggy python submission (verdict: Runtime Error):
s=input()
for i in range(1,4):
  if s[i]==s[i-1]:
    print("Bad")
    return
print("Good")

Fixed submission:
a=input()
if a[0]==a[1] or a[1]==a[2] or a[2]==a[3]:
  print("Bad")
else:
  print("Good")
Buggy python submission (verdict: Runtime Error):
s=input()
for i in range(3):
  if s[i]=='1':
    s[i]='9'
  else:
    s[i]='1'
print(s)

Fixed submission:
print(input().replace('1','a').replace('9','1').replace('a','9'))
Buggy python submission (verdict: Runtime Error):
n=int(input())
print('ABC') if n<1200 elif n<2800 print('ARC') else print('AGC')

Fixed submission:
n=int(input())
print('ABC') if n<1200 else print('ARC') if n<2800 else print('AGC')

Buggy python submission (verdict: Runtime Error):
n=int(input())
print('ABC') if n<1200 else if n<2800 print('ARC') else print('AGC')

Fixed submission:
n=int(input())
print('ABC') if n<1200 else print('ARC') if n<2800 else print('AGC')
Buggy python submission (verdict: Runtime Error):
N,M=input().split(' ')
N=int(N)
M=int(M)

x_arr=[]
y_arr=[]
z_arr=[]
for i in range(N):
	x,y,z=input().split(' ')
	x=int(x)
	y=int(y)
	z=int(z)
	x_arr.append(x)
	y_arr.append(y)
	z_arr.append(z)

ans_x=0
ans_y=0
ans_z=0
for i in range(M):
	kari_arr=[]
	for j in range(N-i):
		ans_x1=ans_x+x_arr[j]
		ans_y1=ans_y+y_arr[j]
		ans_z1=ans_z+z_arr[j]
		kari_arr.append(abs(ans_x1)+abs(ans_y1)+abs(ans_z1))
	print(kari_arr)
	index=kari_arr.index(max(kari_arr))
	ans_x=ans_x+x_arr[index]
	ans_y=ans_y+y_arr[index]
	ans_z=ans_z+z_arr[index]
	del x_arr[index]
	del y_arr[index]
	del z_arr[index]
	ans=abs(ans_x)+abs(ans_y)+abs(ans_z)
print(ans)


Fixed submission:
import numpy as np

N,M=input().split(' ')
N=int(N)
M=int(M)

x_arr=[]
y_arr=[]
z_arr=[]
for i in range(N):
	x,y,z=input().split(' ')
	x=int(x)
	y=int(y)
	z=int(z)
	x_arr.append(x)
	y_arr.append(y)
	z_arr.append(z)

x_arr=np.array(x_arr)
y_arr=np.array(y_arr)
z_arr=np.array(z_arr)

xyz1=x_arr+y_arr+z_arr
xyz1=np.sort(xyz1)[::-1]
xyz1_sum=np.sum(xyz1[:M:])

xyz2=x_arr+y_arr-z_arr
xyz2=np.sort(xyz2)[::-1]
xyz2_sum=np.sum(xyz2[:M:])

xyz3=x_arr-y_arr-z_arr
xyz3=np.sort(xyz3)[::-1]
xyz3_sum=np.sum(xyz3[:M:])

xyz4=x_arr-y_arr+z_arr
xyz4=np.sort(xyz4)[::-1]
xyz4_sum=np.sum(xyz4[:M:])

xyz5=-x_arr-y_arr+z_arr
xyz5=np.sort(xyz5)[::-1]
xyz5_sum=np.sum(xyz5[:M:])

xyz6=-x_arr+y_arr+z_arr
xyz6=np.sort(xyz6)[::-1]
xyz6_sum=np.sum(xyz6[:M:])

xyz7=-x_arr+y_arr-z_arr
xyz7=np.sort(xyz7)[::-1]
xyz7_sum=np.sum(xyz7[:M:])

xyz8=-x_arr-y_arr-z_arr
xyz8=np.sort(xyz8)[::-1]
xyz8_sum=np.sum(xyz8[:M:])

a=[xyz1_sum,xyz2_sum,xyz3_sum,xyz4_sum,xyz5_sum,xyz6_sum,xyz7_sum,xyz8_sum]
print(max(a))
Buggy python submission (verdict: Runtime Error):
N=int(input())

def num_6(A):
	i=0
	while True:
		if 6**i>A:
			return i-1
		i=i+1

def num_9(A):
	i=0
	while True:
		if 9**i>A:
			return i-1
		i=i+1

num_arr=[]
for i in range(N-1):
	num_6_max=num_6(i+1)
	num_9_max=num_9(N-(i+1))
	a6_num=[]
	a9_num=[]
	A=i+1
	B=N-(i+1)
	for j in range(num_6_max+1):
		a6_num.append(A//(6**(num_6_max-j)))
		A=A-(6**(num_6_max-j))*a6_num[j]
	for j in range(num_9_max+1):
		a9_num.append(B//(9**(num_9_max-j)))
		B=B-(9**(num_9_max-j))*a9_num[j]
	num_arr.append(sum(a6_num)+sum(a9_num))
print(min(num_arr))


Fixed submission:
N=int(input())

def num_6(A):
	i=0
	while True:
		if 6**i>A:
			return i-1
		i=i+1

def num_9(A):
	i=0
	while True:
		if 9**i>A:
			return i-1
		i=i+1

num_arr=[]
for i in range(N+1):
	num_6_max=num_6(i)
	num_9_max=num_9(N-i)
	a6_num=[]
	a9_num=[]
	A=i
	B=N-(i)
	for j in range(num_6_max+1):
		a6_num.append(A//(6**(num_6_max-j)))
		A=A-(6**(num_6_max-j))*a6_num[j]
	for j in range(num_9_max+1):
		a9_num.append(B//(9**(num_9_max-j)))
		B=B-(9**(num_9_max-j))*a9_num[j]
	num_arr.append(sum(a6_num)+sum(a9_num))
print(min(num_arr))

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

def num_6(A):
	i=0
	while True:
		if 6**i>A:
			return i-1
		i=i+1

def num_9(A):
	i=0
	while True:
		if 9**i>A:
			return i-1
		i=i+1

num_arr=[]
for i in range(N-1):
	num_6_max=num_6(i+1)
	num_9_max=num_9(N-(i+1))
	a6_num=[]
	a9_num=[]
	A=i+1
	B=N-(i+1)
	for j in range(num_6_max+1):
		a6_num.append(A//(6**(num_6_max-j)))
		A=A-(6**(num_6_max-j))*a6_num[j]
	for j in range(num_9_max+1):
		a9_num.append(B//(9**(num_9_max-j)))
		B=B-(9**(num_9_max-j))*a9_num[j]
	num_arr.append(sum(a6_num)+sum(a9_num))
print(min(num_arr))


Fixed submission:
N=int(input())

def num_6(A):
	i=0
	while True:
		if 6**i>A:
			return i-1
		i=i+1

def num_9(A):
	i=0
	while True:
		if 9**i>A:
			return i-1
		i=i+1

num_arr=[]
for i in range(N+1):
	num_6_max=num_6(i)
	num_9_max=num_9(N-i)
	a6_num=[]
	a9_num=[]
	A=i
	B=N-(i)
	for j in range(num_6_max+1):
		a6_num.append(A//(6**(num_6_max-j)))
		A=A-(6**(num_6_max-j))*a6_num[j]
	for j in range(num_9_max+1):
		a9_num.append(B//(9**(num_9_max-j)))
		B=B-(9**(num_9_max-j))*a9_num[j]
	num_arr.append(sum(a6_num)+sum(a9_num))
print(min(num_arr))
Buggy python submission (verdict: Runtime Error):
print(int(input())**2-int(input())

Fixed submission:
print(int(input())**2-int(input()))
Buggy python submission (verdict: Runtime Error):
x,a,b=map(int,input().split())
print(min(abs(x-a),abs(x-b))

Fixed submission:
x,a,b=map(int,input().split())
print("A") if abs(x-a)<abs(x-b) else print('B')
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
if (a%3==0) || (b%3==0) || ((a+b)%3==0):
  print("Possible")
else:
  print("Impossible")

Fixed submission:
a,b=map(int,input().split())
if (a%3==0) or (b%3==0) or ((a+b)%3==0):
  print("Possible")
else:
  print("Impossible")
Buggy python submission (verdict: Runtime Error):
a=list(map(int,input()))
a.sort()
print("Yes") if max(a[2]==a[1]+a[0]) else print("No")

Fixed submission:
a=list(map(int,input().split()))
a.sort()
print("Yes") if a[0]+a[1]==a[2] else print("No")

Buggy python submission (verdict: Runtime Error):
a=list(map(int,input())).sort()
print("Yes") if max(a[2]==a[1]+a[0]) else print("No")

Fixed submission:
a=list(map(int,input().split()))
a.sort()
print("Yes") if a[0]+a[1]==a[2] else print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

res=0

for i in range(1,n):
    for j in range(1,n):
        if i*j < n:
            res+=1
        else:
            break

print(res)

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

res=0

for i in range(1,ceil(n/2)):
    for j in range(i+1,n):
        if i*j < n:
            res+=1
        else:
            break

if int(n**0.5) == n**0.5:
    print(res*2 + int(n**0.5) - 1)
else:
    print(res*2 + int(n**0.5))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
c,d = map(int,input().split())
m31 = [1,3,5,7,8,10,12]
m30 = [4,6,9,11]

if a in m31 and b == 31:
    print(1)
elif a in m30 and b == 30:
    print(1)
elif a == 2 and b == 28:
    print(1)
else:
    print(0) 

Fixed submission:
a,b = map(int,input().split())
c,d = map(int,input().split())
m31 = [1,3,5,7,8,10,12]
m30 = [4,6,9,11]

if a in m31 and b == 31:
    print(1)
elif a in m30 and b == 30:
    print(1)
elif a == 2 and b == 28:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
    a = int(input())

    X = int(a/1.08 + 0.9)

    if int(X*1.08) == a: 
        print(X)
    else:
        print(":(")

Fixed submission:
import math
a = int(input())

X = math.ceil(a/1.08)

if math.floor(X*1.08) == a: 
    print(X)
else:
    print(":(")
Buggy python submission (verdict: Runtime Error):
n=int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
a=0
for i in range(n):
  if x[i]==y[i]:
    a+=1
  	if a==3:
      break
  else:
    a=0
    
if a>=3:
  print("Yes")
else:
  print("No")

Fixed submission:
n=int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
a=0
for i in range(n):
  if x[i]==y[i]:
    a+=1
    if a==3:
      break
  else:
    a=0
    
if a>=3:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=0
for a in range(1,n):
  for b in range(1,n):
    if a*b<n:
      x+=1
    elif a*b>=n:
      break
print(x)

 

Fixed submission:
n=int(input())
x=0
for a in range(1,n):
  for b in range(1,n):
    if a*b<n:
      x+=1
    elif a*b>=n:
      break
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
x=0
for a in range(1,n):
  for b in range(1,n):
    if a*b<n:
      x+=1
    else:
      break
print(x)


Fixed submission:
n=int(input())
x=0
for a in range(1,n):
  for b in range(1,n):
    if a*b<n:
      x+=1
    elif a*b>=n:
      break
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=0
for i in range(1,n):
  for j in range(1,n):
    if i%j==0:
      a+=1
print(a)

Fixed submission:
n=int(input())
x=0
for a in range(1,n):
  for b in range(1,n):
    if a*b<n:
      x+=1
    elif a*b>=n:
      break
print(x)