Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from numpy import log
def f(k):
  c=0
  while k % 2 == 0:
    k //= 2
    c+=1
    if c==2:
      break
  return c
def g(k):
  return f(int(k))
n=int(input())
a=list(map(g,input().split()))
a.sort()
ct0=a.count(0)
ct1=a.count(1)
ct2-a.count(2)
if ct0 > ct2:
  print("No")
else:
  print("Yes")

Fixed submission:
from numpy import log
def f(k):
  c=0
  while k % 2 == 0:
    k //= 2
    c+=1
    if c==2:
      break
  return c
def g(k):
  return f(int(k))
n=int(input())
a=list(map(g,input().split()))
ct0=a.count(0)
ct1=a.count(1)
ct2=a.count(2)
if ct0 <= ct2 or (ct0 == ct2 + 1 and ct1==0):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
li = [0]*9
for i in a:
  if i < 400:
    li[0]+=1
  elif i < 800:
    li[1]+=1
  elif i < 1200:
    li[2]+=1
  elif i < 1600:
    li[3]+=1
  elif i < 2000:
    li[4]+=1
  elif i < 2400:
    li[5]+=1
  elif i<2800:
    li[6]+=1
  elif i<3200:
    li[7]+=1
  else:
    li[8]+=1
li_ = [i for i in li[:-1] if i>0]
num = len(li_)
if num==0:
  print(1,n)
else:
  print(num, num + li[-1])


Fixed submission:
r,g,b=map(int,input().split())
n=100*r+10*g+b
if n%4==0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
from math import gcd
a,b,c=map(int,input().split())
d=gcd(a,b)
if c%d==0:
  print("YES")
else:
  print("NO")

Fixed submission:
from fractions import gcd
a,b,c=map(int,input().split())
d=gcd(a,b)
if c%d==0:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
a,b=map(int,input())
print((a+b)%24)

Fixed submission:
a,b=map(int,input().split())
print((a+b)%24)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
from math import sqrt
m=int(sqrt(n))
for i in range(m,n+1):
  if n%i==0:
    print(len(str(i)))
    exit()

Fixed submission:
from numpy import sqrt
n=int(input())
r=int(sqrt(n))
for i in range(r):
  if n % (r-i) == 0:
    m = n // (r-i)
    print(len(str(m)))
    exit()
Buggy python submission (verdict: Runtime Error):
k,s=map(int,input().split())
from math import factorial
def c(n,k):
  return factorial(n)//factorial(n-k)//factorial(k)
if s<k:
  print(c(s+2,2))
elif 3*k < s:
  print(0)
else:
  # k<=s<=3k の場合
  くっそ～わかんねぇ～

Fixed submission:
k,s=map(int,input().split())
from math import factorial
def c(n,r):
  return factorial(n)//factorial(n-r)//factorial(r)
ans=0
for x in range(k+1):
  for y in range(k+1):
    if 0<=s-x-y<=k:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i+j+l==s:
        ans += 1
        break
print(ans)


Fixed submission:
k,s=map(int,input().split())
from math import factorial
def c(n,r):
  return factorial(n)//factorial(n-r)//factorial(r)
ans=0
for x in range(k+1):
  for y in range(k+1):
    if 0<=s-x-y<=k:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i+j+l==s:
        ans += 1
print(ans)

Fixed submission:
k,s=map(int,input().split())
from math import factorial
def c(n,r):
  return factorial(n)//factorial(n-r)//factorial(r)
ans=0
for x in range(k+1):
  for y in range(k+1):
    if 0<=s-x-y<=k:
      ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i+j+l==s:
        ans += 1
print(ans)

Fixed submission:
k,s=map(int,input().split())
from math import factorial
def c(n,r):
  return factorial(n)//factorial(n-r)//factorial(r)
ans=0
for x in range(k+1):
  for y in range(k+1):
    if 0<=s-x-y<=k:
      ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
while len(s)>0:
  #初めがdreamの場合
  if s[:5]=="dream" and (len(s)==5 or s[5]=="d" or d[5:8]=="era"):
    s=s[5:]
  elif s[:7]=="dreamer" and (len(s)==7 or s[7]=="d" or s[7]=="e"):
    #初めがdreamerの場合
    s=s[7:]
  elif s[:5]=="erase" and (len(s)==5 or s[5]=="d" or s[5]=="e"):
    #初めがeraseの場合
    s=s[5:]
  elif s[:6]=="eraser" and (len(s)==6 or s[6]=="d" or s[6]=="e"):
    s=s[6:]
  else:
    print("NO")
    exit()
print("YES")

Fixed submission:
s=input()
while len(s)>0:
  #初めがdreamの場合
  if s[:5]=="dream" and (len(s)==5 or s[5]=="d" or s[5:8]=="era"):
    s=s[5:]
  elif s[:7]=="dreamer" and (len(s)==7 or s[7]=="d" or s[7]=="e"):
    #初めがdreamerの場合
    s=s[7:]
  elif s[:5]=="erase" and (len(s)==5 or s[5]=="d" or s[5]=="e"):
    #初めがeraseの場合
    s=s[5:]
  elif s[:6]=="eraser" and (len(s)==6 or s[6]=="d" or s[6]=="e"):
    s=s[6:]
  else:
    print("NO")
    exit()
print("YES")
Buggy python submission (verdict: Runtime Error):
h,w=map(int,input().split())
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(h):
  s=list(map(str,input().split()))
  for j in range(w):
    if s[i]=="snuke":
      print(alphabet[j]+str(i+1))

Fixed submission:
h,w=map(int,input().split())
alphabet = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
for i in range(h):
  s=list(map(str,input().split()))
  for j in range(w):
    if s[j]=="snuke":
      print(alphabet[j]+str(i+1))
Buggy python submission (verdict: Runtime Error):
w,h,n=map(int,input().split())
xya=[list(map(int,input().split())) for i in range(n)]
xya1=[i[0] for i in xya if i[2]==1]
xya2=[i[0] for i in xya if i[2]==2]
xya3=[i[1] for i in xya if i[2]==3]
xya4=[i[1] for i in xya if i[2]==4]
left=max(xya1)
right=min(xya2)
lower=max(xya3)
upper=min(xya4)
if left>=right or lower>=upper:
  print(0)
else:
  print((right-left)*(upper-lower))

Fixed submission:
w,h,n=map(int,input().split())
xya=[list(map(int,input().split())) for i in range(n)]
xya1=[i[0] for i in xya if i[2]==1]+[0]
xya2=[i[0] for i in xya if i[2]==2]+[w]
xya3=[i[1] for i in xya if i[2]==3]+[0]
xya4=[i[1] for i in xya if i[2]==4]+[h]
left=max(xya1)
right=min(xya2)
lower=max(xya3)
upper=min(xya4)
if left>=right or lower>=upper:
  print(0)
else:
  print((right-left)*(upper-lower))

Buggy python submission (verdict: Runtime Error):
w,h,n=map(int,input().split())
xya=[list(map(int,input().split())) for i in range(n)]
xya1=[i[0] for i in xya if i[2]==1]
xya2=[i[0] for i in xya if i[2]==2]
xya3=[i[1] for i in xya if i[2]==3]
xya4=[i[1] for i in xya if i[2]==4]
left=max(xya1)
right=min(xya2)
lower=max(xyz3)
upper=min(xyz4)
if left>=right or lower>=upper:
  print(0)
else:
  print((right-left)*(upper-lower))

Fixed submission:
w,h,n=map(int,input().split())
xya=[list(map(int,input().split())) for i in range(n)]
xya1=[i[0] for i in xya if i[2]==1]+[0]
xya2=[i[0] for i in xya if i[2]==2]+[w]
xya3=[i[1] for i in xya if i[2]==3]+[0]
xya4=[i[1] for i in xya if i[2]==4]+[h]
left=max(xya1)
right=min(xya2)
lower=max(xya3)
upper=min(xya4)
if left>=right or lower>=upper:
  print(0)
else:
  print((right-left)*(upper-lower))
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
aa=sort([a,b,c])
if aa == [5,5,7]:
  print("YES")
else:
  print("NO")

Fixed submission:
a,b,c=map(int,input().split())
aa=sorted([a,b,c])
if aa == [5,5,7]:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n = input()
rem = 0
for d in n:
  rem += int(d)
if d % 9 == 0:
  print ("Yes")
else:
  print ("No")

Fixed submission:
n = input()
rem = 0
for d in n:
  rem += int(d)
if rem % 9 == 0:
  print ("Yes")
else:
  print ("No")
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    a = ri()
    print (a + a*a + a*a*a)





mode = 's'

if mode == 's':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Fixed submission:
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    a = ri()
    print (a + a*a + a*a*a)





mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    n, k = rl()
    A = rl()
    # leaps = [A]
    # leap_size = 2
    # while leap_size <= k:
        # new_leap = []
        # for i in range(n):
    curr = 1
    seen = {1:0}

    for i in range(1, k + 1):
        curr = A[curr - 1]
        if i == k:
            print (curr)
            return
        elif curr in seen:
            break
        seen[curr] = i

    cycle_len = i - seen[curr]
    # print (cycle_len)

    while 1:
        if i % cycle_len == k % cycle_len:
            print (curr)
            return
        i += 1
        curr = A[curr - 1]






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Fixed submission:
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def solve():
    n, m, k = rl()
    mod = 998244353
    ans = 0
    C = 1
    for d in range(k + 1):
        # print (d)
        ans += m * pow(m - 1, n - 1 - d, mod) * C
        ans %= mod
        C = (C * (n - 1 - d) * modinv(d + 1, mod)) % mod
    print (ans)





mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()
Buggy python submission (verdict: Runtime Error):
s = input()
if s[2] == s[3] and s[4] == s[5]:
  return "Yes"
else:
  return "No"

Fixed submission:
s = input()
if s[2] == s[3] and s[4] == s[5]:
  print ("Yes")
else:
  print ("No")
Buggy python submission (verdict: Runtime Error):
N,X,T = map(int, input().split())
a = N/X
if N%X != 0:
  a += 1
return a * T


Fixed submission:
N,X,T = map(int, input().split())
a = int(N/X)
if N%X != 0:
  a += 1
print(int(a * T))
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3
input()
l = 10**18
a = 1
for i in map(int, input()):
    a *= i
    if a > l:
        a = -1
        break
print(a)

Fixed submission:
#! /usr/bin/env python3
input()
l = 10**18
a = 1
*b, = map(int, input().split())
if 0 in b:
    a = 0
else:
    for i in b:
        a *= i
        if a > l:
            a = -1
            break
print(a)
Buggy python submission (verdict: Runtime Error):
a,*_,e,k=map(int,input(input().split()));print([':(','Yey!'][e-a<=k])

Fixed submission:
a,*_,e,k=[int(input())for x in' '*6];print([':(','Yay!'][e-a<=k])
Buggy python submission (verdict: Runtime Error):
t=0
for i in sorted(map(int,[*open(0)]),key=lambda x:-x%10-(x%10<1)):t+=i+(10-t)%10
print(t)

Fixed submission:
t=0
for i in sorted([int(input())for i in' '*5],key=lambda x:-x%10-(x%10<1)):t+=i+(10-t%10)%10
print(t)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
for i in range(1, 101):
  if a%i + b%i < 1:
	c -= 1
    if c < 1:
      print(i)
	  break 
  

Fixed submission:
#! /usr/bin/env python3
a, b, c = map(int, input().split())
t = []
for i in range(1, 101):
    if a%i + b%i < 1: t += [i]
print(t[-c])
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input())
print([b+a,b-a][b%a>0])

Fixed submission:
a, b = map(int, input().split())
print([b+a,b-a][b%a>0])
Buggy python submission (verdict: Runtime Error):
i=input;print'Hello World'*(i()-1)or i()+i()

Fixed submission:
*a,=map(int,open(0).read().split())
print(a[1]+a[2]if a[0]>1else'Hello World')

Buggy python submission (verdict: Runtime Error):
i=input;i(eval(i()+'+'+i())if'1'<i()else'Hello World')

Fixed submission:
*a,=map(int,open(0).read().split())
print(a[1]+a[2]if a[0]>1else'Hello World')

Buggy python submission (verdict: Runtime Error):
a=map(int,open(0).read().split())
print('Hello World'if a[0]<2else a[1]+a[2])

Fixed submission:
*a,=map(int,open(0).read().split())
print(a[1]+a[2]if a[0]>1else'Hello World')
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3

A = int(input())
B = int(input())

if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')

Fixed submission:
#! /usr/bin/env python3

A, B = map(int, input().split())

if A <= 8 and B <= 8:
    print('Yay!')
else:
    print(':(')
Buggy python submission (verdict: Runtime Error):
A=int(input());B=int(input());print(max(A+B,A-B,A+B))

Fixed submission:
A,B=map(int,input().split());print(max(A+B,A-B,A*B))
Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python3

N = int(input())
ans = 0
for b in range(1, 999):
    for p in range(2, 999):
        if b ** p <= N : ans = max(ans, b ** p)
print(ans)

Fixed submission:
#! /usr/bin/env python3

N = int(input())
ans = 0
for b in range(1, 100):
    for p in range(2, 100):
        if b ** p <= N : ans = max(ans, b ** p)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, X = map(int, input().split())
L = [int(x) for x in range(N)]
print(N + ((X - sum(L))) // min(L))

Fixed submission:
N, X = map(int, input().split())
L = [int(input()) for x in range(N)]
print(N + ((X - sum(L))) // min(L))
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3

alp = 'abcdefghijklmnopqrstuvwxyz'
S = input()
if S == alp[::-1]:
    print(-1)
else:
    if len(S) == len(alp):
        p = ''
        for i, j in zip(alp, S):
            if i != j : break
            p += i
        S = p

    for i in set(S) : alp = alp.replace(i, '')
    print(S+alp[0])

Fixed submission:
#! /usr/bin/env python3

alp = 'abcdefghijklmnopqrstuvwxyz'
S = input()
if S == alp[::-1]:
    print(-1)
else:
    if len(S) == len(alp):
        l = list(S)
        s = []
        for i in range(1, len(S))[::-1]:
            s += [l[i]]
            r = sorted(x for x in s if x > l[i-1])
            if r:
                l = l[:i-1] + [r[0]]
                break
        print(''.join(l))
    else:
        for i in S : alp = alp.replace(i, '')
        print(S+alp[0])
Buggy python submission (verdict: Runtime Error):
*a,=open(0);n,a=map(int,a);print(sum(a[0::2])-sum(a[1::2]))

Fixed submission:
input();a=sorted(map(int,input().split()))[::-1];print(sum(a[::2])-sum(a[1::2]))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input.split())
print(max(0, a-b))

Fixed submission:
a, b = map(int, input().split())
print(max(0, a-b))
Buggy python submission (verdict: Runtime Error):
input()
d = {}
for i in map(int, input().split()):
    if i in d:
        d[i] = 1
    else:
        d[i] += 1
print(sorted(d.values())[-1])
  
  

Fixed submission:
input()
d = {}
for i in map(int, input().split()):
    for j in (-1, 0, 1):
        a = i + j
        if a in d:
            d[a] += 1
        else:
            d[a] = 1
print(sorted(d.values())[-1])
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3

def f(diu, n):
    r = []
    try:
        while n != 1:
            r = [diu[n][0]] + r
            n = diu[n][1]
    except:
        pass
    return r

memo = {}
def d(p, a, b, k):
    if k in memo : return memo[k]
    c = 0
    for i, j in zip(a, b):
        if i == j:
            c += 1
        else:
            break
    memo[k] = sum(p[x][2] for x in a[c:]) + sum(p[x][2] for x in b[c:])
    return memo[k]

def main():
    N = int(input())
    P = [tuple(map(int, input().split())) for x in range(N-1)]
    diu = {max(v[0], v[1]) : (i, min(v[0], v[1]))  for i, v in enumerate(P)}
    Q, K = map(int, input().split())
    k = f(diu, K)
    for i in range(Q):
        x, y = map(int, input().split())
        print(d(P, f(diu, x), k, (K, x)) + d(P, f(diu, y), k, (K, y)))

if __name__ == '__main__':
    main()

Fixed submission:
#! /usr/bin/env python3


def gcd(a, b):
    if a < b : return gcd(b, a)
    while b != 0:
        t = a % b
        a = b
        b = t
    return a

N = int(input())
T = sorted(set([int(input()) for x in range(N)]))
a = T[-1]
for i in T[:-1]:
    a = (a * i) // gcd(a, i)

print(a)

Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3
import math

N = int(input())
T = sorted(set([int(input()) for x in range(N)]))
a = 1
for i in T[:-1] : a *= i
print((a * T[-1]) // math.gcd(a, T[-1]))


Fixed submission:
#! /usr/bin/env python3


def gcd(a, b):
    if a < b : return gcd(b, a)
    while b != 0:
        t = a % b
        a = b
        b = t
    return a

N = int(input())
T = sorted(set([int(input()) for x in range(N)]))
a = T[-1]
for i in T[:-1]:
    a = (a * i) // gcd(a, i)

print(a)

Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3
import math

N = int(input())
T = sorted(set([int(input()) for x in range(N)]))
s = set()
for i in T : s = s.union(set(primefactor(i)))
a = 1
for i in T[:-1] : a *= i

print((a * T[-1]) // math.gcd(a, T[-1]))

Fixed submission:
#! /usr/bin/env python3


def gcd(a, b):
    if a < b : return gcd(b, a)
    while b != 0:
        t = a % b
        a = b
        b = t
    return a

N = int(input())
T = sorted(set([int(input()) for x in range(N)]))
a = T[-1]
for i in T[:-1]:
    a = (a * i) // gcd(a, i)

print(a)
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3
import itertools
N, A, B = map(int, input().split())
t = B - A + 1
if B <= A or N < 2:
    if A == B:
        print(1)
    else:
        print(0)
else:
    s = set()
    print(len({sum(i) for i in itertools.product(range(t), repeat = N - 2)}))

Fixed submission:
#! /usr/bin/env python3
import itertools
N, A, B = map(int, input().split())
if B <= A or N < 2:
    if A == B:
        print(1)
    else:
        print(0)
else:
    print((B - A) * (N - 2) + 1)

Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python3
import itertools
N, A, B = map(int, input().split())
t = B - A + 1
s = set()
if B <= A or N < 3:
    if A == B:
        print(1)
    else:
        print(0)
else:
    print(len({sum(i) for i in itertools.product(range(t), repeat = N - 2)}))

Fixed submission:
#! /usr/bin/env python3
import itertools
N, A, B = map(int, input().split())
if B <= A or N < 2:
    if A == B:
        print(1)
    else:
        print(0)
else:
    print((B - A) * (N - 2) + 1)
Buggy python submission (verdict: Runtime Error):
print(sum(sorted(map(int,input().split()))[::-1][1:2*int(input()):2]))

Fixed submission:
N = int(input())
print(sum(sorted(map(int, input().split()))[::-1][1:2*N:2]))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
def f(a, b):
    return max(len(str(a)), len(str(b)))
def p(n):
    l = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            l += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : l += [n]
    return l

def main():
    N = int(input())
    l = p(N)
    if len(l) < 2:
        print(f(N, 1))
    else:
        w = len(l)
        ans = len(str(N))
        for i in itertools.product([0, 1], repeat=w):
            a = b = 1
            for j in range(w):
                if i[j] == 0:
                    a *= l[j]
                else:
                    b *= l[j]
            ans = min(ans, f(a, b))
        print(ans)
if __name__ == '__main__':
    main()


Fixed submission:
import itertools
def f(a, b):
    return max(len(str(a)), len(str(b)))
def p(n):
    l = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            l += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : l += [n]
    return l

def main():
    N = int(input())
    l = p(N)
    if len(l) < 2:
        print(f(N, 1))
    else:
        w = len(l)
        ans = len(str(N))
        for i in itertools.product([0, 1], repeat=w):
            a = b = 1
            for j in range(w):
                if i[j] == 0:
                    a *= l[j]
                else:
                    b *= l[j]
            ans = min(ans, f(a, b))
        print(ans)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
def f(a, b):
    return max(len(str(a)), len(str(b)))
def p(n):
    l = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            l += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : l += [n]
    return l

N = int(input())
l = p(N)
if len(l) < 2:
    print(f(N, 1))
else:
    w = len(l)
    ans = len(str(N))
    for i in itertools.product([0, 1], repeat=w):
        a = b = 1
        for j in range(w):
            if i[j] == 0:
                a *= l[j]
            else:
                b *= l[j]
        ans = min(ans, f(a, b))
    print(ans)

Fixed submission:
import itertools
def f(a, b):
    return max(len(str(a)), len(str(b)))
def p(n):
    l = []
    a, b = 0, 2
    while b * b <= n:
        if n % b == 0:
            n //= b
            l += [b]
        else:
            b += 1 + a
            a = 1
    if n > 1 : l += [n]
    return l

def main():
    N = int(input())
    l = p(N)
    if len(l) < 2:
        print(f(N, 1))
    else:
        w = len(l)
        ans = len(str(N))
        for i in itertools.product([0, 1], repeat=w):
            a = b = 1
            for j in range(w):
                if i[j] == 0:
                    a *= l[j]
                else:
                    b *= l[j]
            ans = min(ans, f(a, b))
        print(ans)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
D = {}
for i in A:
    if i in D:
        D[i] += 1
    else:
        D[i] = 1
cnt = 0
for k in D.keys():
    if D[k] % 2:
        D[k] = 1
    else:
        D[k] = 2
        cnt += 1
print(len({*A}) - (cnt % 2))

Fixed submission:
N = int(input())

if N < 11:
    d, m = divmod(N, 6)
    print(d + (m>0))
else:
    d, m = divmod(N, 11)
    a = (1 if m else 0) if m < 7 else 2
    print(d * 2 + a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
cnt = 0
L = [list(map(int, input().split())) for x in range(N)]
for a, b in L[::-1]:
    a += cnt
    if a < b && a != 0 : cnt += b - a
    if a > b: 
        if a % b:
            cnt += b - a % b
        else:
            cnt += a % b
print(cnt)

Fixed submission:
N = int(input())
cnt = 0
L = [list(map(int, input().split())) for x in range(N)]
for a, b in L[::-1]:
    a += cnt
    if a < b and a != 0 : cnt += b - a
    if a > b: 
        if a % b:
            cnt += b - a % b
        else:
            cnt += a % b
print(cnt)
Buggy python submission (verdict: Runtime Error):
import itertools
K, S = map(int, input().split())
s = set([x for x in itertools.combinations_with_replacement(range(K+1), 3) if sum(x) == S]) 
print(len(s) * 3 - (S % 3 == 0) * 2)

Fixed submission:
print(*input().split(','))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
K, S = map(int, input().split())
cnt = 0
for i in itertools.product(range(K+1), repeat=3):
    cnt += sum(i) == S
print(cnt)

Fixed submission:
K, S = list(map(int, input().split()))
K += 1
cnt = 0
for i in range(K):
    if i+K*2<=S : continue
    if i>S : continue
    for j in range(min(K, S-i+1)):
        if i+j+K<=S : continue
        if i+j>S : break
        cnt += 1
print(cnt)