Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
S = list(input())

answer = [0] * len(S)
b_list = []
for idx, moji in enumerate(S):
    if moji == "a" and sum(answer) < A + B:
        answer[idx] = 1
        print("Yes")
        continue
    elif moji == "b":
        b_list.append(1)
        if sum(answer) < A + B and sum(b_list) <= B:
            answer[idx] = 1
            print("Yes")
            continue
    print("No")


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

answer = 0
b_list = 0
for idx, moji in enumerate(S):
    if moji == "a" and answer < A + B:
        answer += 1
        print("Yes")
        continue
    elif moji == "b":
        b_list += 1
        if answer < A + B and b_list <= B:
            answer += 1
            print("Yes")
            continue
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
S = list(input())

answer = [0] * len(S)
b_list = []
for idx, moji in enumerate(S):
    if moji == "a" and sum(answer) < A + B:
        answer[idx] = 1
    elif moji == "b":
        b_list.append(1)
        if sum(answer) < A + B and sum(b_list) <= B:
            answer[idx] = 1
    elif moji == "c":
        pass
    else:
        pass
for result in answer:
    if result == 1:
        print("Yes")
    elif result == 0:
        print("No")


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

answer = 0
b_list = 0
for idx, moji in enumerate(S):
    if moji == "a" and answer < A + B:
        answer += 1
        print("Yes")
        continue
    elif moji == "b":
        b_list += 1
        if answer < A + B and b_list <= B:
            answer += 1
            print("Yes")
            continue
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

A = list(map(int,input().split(" ")))

ans = 1
for x in A:
    ans *= x

if ans <= 10**18:
    print(ans)
else:
    print("-1")


Fixed submission:
N = int(input())

A = list(map(int,input().split(" ")))
flag = 0
ans = 1

if 0 in A:
    flag = 2
    print(0)

if flag != 2:
    for x in A:
        ans *= x
        #print(ans)
        if ans > 10**18:
            flag = 1
            break

if flag == 0:
    print(ans)
elif flag == 1:
    print("-1")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N= map(int,input().split())
floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  
    for x in range(0,N+1):

        floor_num.append(int(A*x/B)-A*int(x/B))


print(max(floor_num))



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


floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  

        floor_num.append(int(A*N/B))


print(max(floor_num))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N= map(int,input().split())


floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  
    for x in range(0,N+1):

        floor_num.append(int(A*x/B)-A*int(x/B))

    if N >=B:
        floor_num.append(int(A*(B-1)/B))

print(max(floor_num))


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


floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  

        floor_num.append(int(A*N/B))


print(max(floor_num))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N= map(int,input().split())


floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  
    for x in range(0,N+1):

        floor_num.append(int(A*x/B)-A*int(x/B))

    if N >=B:
        floor_num.append(int(A*(B-1)/B))

print(max(floor_num))


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


floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  

        floor_num.append(int(A*N/B))


print(max(floor_num))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N= map(int,input().split())


floor_num=[]
   
for x in range(0,N+1):

    floor_num.append(int(A*x/B)-A*int(x/B))

if N >=B:
    floor_num.append(int(A*(B-1)/B))

print(max(floor_num))


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


floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  

        floor_num.append(int(A*N/B))


print(max(floor_num))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N= map(int,input().split())


floor_num=[]
for x in range(N+1):
    if x>=B:
        break
    floor_num.append(int(A*x/B)-A*int(x/B))

print(max(floor_num))

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


floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  

        floor_num.append(int(A*N/B))


print(max(floor_num))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N= map(int,input().split())


floor_num=[]
for x in range(N+1):
    floor_num.append(int(A*x/B)-A*int(x/B))

print(max(floor_num))

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


floor_num=[]

if N >=B:
    floor_num.append(int(A*(B-1)/B))
else:  

        floor_num.append(int(A*N/B))


print(max(floor_num))
Buggy python submission (verdict: Runtime Error):
S = input()

count = 0

for i in range(len(S)):
    for j in range(i + 3,len(S)):
       
        x = int(S[i:j+1])
        

        if x % 2019 == 0:
            count += 1

print(count)

Fixed submission:
S, W = map(int, input().split())

if S>W:
    print("safe")
else:
    print("unsafe")
Buggy python submission (verdict: Runtime Error):
import decimal

L=int(input())

#decimal.getcontext().prec = 6
x = decimal.Decimal(L / 3)

V=decimal.Decimal(x*x*x)

print("{:.24f}".format(V))

Fixed submission:
import math

#入力
N, M = map(int, input().split())


#combination 関数
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

#main
if N <=1 and M <= 1:
  print(0)

elif N <= 1 and M>=2:
  print(combinations_count(M,2))

elif M <=1 and N>=2:
  print(combinations_count(N,2))
  
elif N >=2 and M >=2:
  print(combinations_count(N,2)+combinations_count(M,2))
Buggy python submission (verdict: Time Limit Exceeded):
def MergeSort(num_list):
  n = len(num_list)
  
  if len(num_list) == 1:
    return num_list
  
  #1. 整列されていないリストを２つのサブリストに分割する
  mid = int(round(n/2))
  
  left = num_list[:mid]
  right = num_list[mid:]
  

  
  #2. 分割したリスト（サブリスト）を整列する。サブリストもマージソートを使って整列させる。（再帰関数）
  l = MergeSort(left)
  r = MergeSort(right)
  
  #3. 2つのサブリストをマージして１つの整列済みリストにする
  return Merge(l,r)
  
# 整列済みリストA、Bを使って、整列済みリストCを作成する
def Merge(A,B):
  C = []
#   print("A",A)
#   print("B",B)
  
  # 1. AとBの先頭の数字を比較し、小さい方をCに追加し追加した値はリストから削除する
  # 2. 手順1をどちらか一方のリストが空になるまで繰り返す。
  while (len(A) > 0) and (len(B) > 0):
    if A[0] < B[0]:
      C.append(A[0])
      del A[0]
    else:
      C.append(B[0])
      del B[0]
  
  # 3. 残った要素をCの末尾に追加する
  if len(A) > 0:
    C.extend(A)
  else:
    C.extend(B)
 
#   print("C",C)
  return C

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

list = MergeSort(array)

ans = 0
if n % 2 == 0:
  for i in range(n//2):
    ans += 2* list[-i-1]
  ans -= list[-1]
else:
  for i in range((n-1)//2):
   ans += 2*list[-i-1]
  ans += list[-(n-1)//2-1]
  ans -= list[-1]
print(ans)




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

list.sort(reverse=True)

ans = 0
if n % 2 == 0:
  for i in range(n//2):
    ans += 2* list[i]
  ans -= list[0]
else:
  for i in range((n-1)//2):
    ans += 2*list[i]
  ans += list[(n-1)//2]
  ans -= list[0]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def MergeSort(num_list):
  n = len(num_list)
  
  if len(num_list) == 1:
    return num_list
  
  #1. 整列されていないリストを２つのサブリストに分割する
  mid = int(round(n/2))
  
  left = num_list[:mid]
  right = num_list[mid:]
  

  
  #2. 分割したリスト（サブリスト）を整列する。サブリストもマージソートを使って整列させる。（再帰関数）
  l = MergeSort(left)
  r = MergeSort(right)
  
  #3. 2つのサブリストをマージして１つの整列済みリストにする
  return Merge(l,r)
  
# 整列済みリストA、Bを使って、整列済みリストCを作成する
def Merge(A,B):
  C = []
#   print("A",A)
#   print("B",B)
  
  # 1. AとBの先頭の数字を比較し、小さい方をCに追加し追加した値はリストから削除する
  # 2. 手順1をどちらか一方のリストが空になるまで繰り返す。
  while (len(A) > 0) and (len(B) > 0):
    if A[0] < B[0]:
      C.append(A[0])
      del A[0]
    else:
      C.append(B[0])
      del B[0]
  
  # 3. 残った要素をCの末尾に追加する
  if len(A) > 0:
    C.extend(A)
  else:
    C.extend(B)
 
#   print("C",C)
  return C

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

list = MergeSort(array)

ans = 0
if n % 2 == 0:
  for i in range(n//2):
    ans += 2* list[-i-1]
  ans -= list[-1]
else:
  for i in range((n-1)//2):
   ans += 2*list[-i-1]
  ans += list[-(n-1)//2-1]
  ans -= list[-1]
print(ans)




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

list.sort(reverse=True)

ans = 0
if n % 2 == 0:
  for i in range(n//2):
    ans += 2* list[i]
  ans -= list[0]
else:
  for i in range((n-1)//2):
    ans += 2*list[i]
  ans += list[(n-1)//2]
  ans -= list[0]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

dp = [0]*(10**6)
count = [0]*(10**6)
for i in a:
  count[i-1] += 1
  for j in range(i*2, 10**6+1, i):
    dp[j-1] = 1
    
ans = 0
for i in a:
  if count[i-1] == 1 and dp[i-1] == 0:
    ans +=1
    
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
 
dp = [0]*(10**6)
count = [0]*(10**6)

for i in a:
  count[i-1] += 1
 
b = list(set(a))
for i in b:
  for j in range(i*2, 10**6+1, i):
    dp[j-1] = 1
    
ans = 0
for i in a:
  if count[i-1] == 1 and dp[i-1] == 0:
    ans +=1
    
print(ans)

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

dp = [0]*(10**6)
count = [0]*(10**6)
for i in a:
  count[i-1] += 1
  m = 2
  while i*m <= 10**6:
    dp[i*m-1] = 1
    m += 1
ans = 0
for i in a:
  if count[i-1] == 1 and dp[i-1] == 0:
    ans +=1
    
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
 
dp = [0]*(10**6)
count = [0]*(10**6)

for i in a:
  count[i-1] += 1
 
b = list(set(a))
for i in b:
  for j in range(i*2, 10**6+1, i):
    dp[j-1] = 1
    
ans = 0
for i in a:
  if count[i-1] == 1 and dp[i-1] == 0:
    ans +=1
    
print(ans)

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

dp = [0]*(10**6)

for i in a:
  m = 2
  while i*m <= 10**6:
    dp[i*m-1] = 1
    m += 1
ans = 0
for i in a:
  if a.count(i) == 1 and dp[i-1] == 0:
    ans +=1
    
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
 
dp = [0]*(10**6)
count = [0]*(10**6)

for i in a:
  count[i-1] += 1
 
b = list(set(a))
for i in b:
  for j in range(i*2, 10**6+1, i):
    dp[j-1] = 1
    
ans = 0
for i in a:
  if count[i-1] == 1 and dp[i-1] == 0:
    ans +=1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
 
a_0, b_0 = input().split()
a = int(a_0)


small = str(a*int(b_0[-2:]))



ans = a*int(b_0[0:-3]) +int(small[:-2])
print(ans)

Fixed submission:
import math
 
a_0, b_0 = input().split()
a = int(a_0)

small = str(a*int(b_0[-2:]))


if len(small) >= 3:
  ans = a*int(b_0[0:-3]) +int(small[:-2])
else:
  ans = a*int(b_0[0:-3])
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = list(map(int,input().split()))
timestamp = [0]*n
position = 1
period = 0
start=0
for i in range(n):
  if timestamp[position-1] != 0:
    start = timestamp[position-1]
    period = i-timestamp[position-1]
    break
  timestamp[position-1] =i
  position = a[position-1]
print(period,start)


if k <=start:
  position = 1
  for i in range(k-1):
    position = a[position-1]
  print(position)
  
else:
  cycle = (k-start)%period
  for i in range(cycle):
    position = a[position-1]
  print(position) 
  

Fixed submission:
n, k = map(int, input().split())
a = list(map(int,input().split()))
timestamp = [0]*n
position = 1
period = 0
start=0
for i in range(n*2):
  if timestamp[position-1] != 0:
    start = timestamp[position-1]
    period = i-timestamp[position-1]
    break
  timestamp[position-1] =i
  position = a[position-1]
  

if k <=start:
  position = 1
  for i in range(k):
    position = a[position-1]
  print(position)
  
else:
  cycle = (k-start)%period
  for i in range(cycle):
    position = a[position-1]
  print(position)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[0 for i in range(N)] for j in range (N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)
  
ans = 0
for k in range(N):
  flag =1
  for l in B[k]:
    if O[k] <= O[l]:
      flag = 0
      break
    else:
      continue
  if  flag ==1:
    ans += 1
print(ans)
      

Fixed submission:
a = input()
if (a[1] == 'B'):
  print('ARC')
else:
  print('ABC')

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
O =  [0]*N
B = [[0 for i in range(N)] for j in range (N)]
a = list(map(int, input().split()))
for i in range(N):
  O[i] = a[i]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1][o_2-1] = 1
  B[o_2-1][o_1-1] = 1
 
ans = 0
for k in range(N):
  flag =1
  for l in range(N):
    if B[k][l] == 1 and O[k] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)
      

Fixed submission:
a = input()
if (a[1] == 'B'):
  print('ARC')
else:
  print('ABC')
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[0 for i in range(N)] for j in range (N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1][o_2-1] = 1
  B[o_2-1][o_1-1] = 1
  
ans = 0
for k in range(N):
  flag =1
  for l in range(N):
    if B[k][l] == 1 and O[k] <= O[l]:
      flag = 0
      break
    else:
      continue
  if  flag ==1:
    ans += 1
print(ans)
      

Fixed submission:
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[] for i in range(N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)

ans = 0
for node in range(N):
  flag =1
  for l in B[node]:
    if O[node] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
O =  [0]*N
B = [[0 for i in range(N)] for j in range (N)]
a = list(map(int, input().split()))
for i in range(N):
  O[i] = a[i]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1][o_2-1] = 1
  B[o_2-1][o_1-1] = 1
 
ans = 0
for k in range(N):
  flag =1
  for l in range(N):
    if B[k][l] == 1 and O[k] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)
      

Fixed submission:
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[] for i in range(N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)

ans = 0
for node in range(N):
  flag =1
  for l in B[node]:
    if O[node] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
O =  [0]*N
B = [[0 for i in range(N)] for j in range (N)]
a = list(map(int, input().split()))
for i in range(N):
  O[i] = a[i]

for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1][o_2-1] = 1
  B[o_2-1][o_1-1] = 1

ans = 0
for k in range(N):
  flag =1
  for l in range(N):
    if B[k][l] == 1 and O[k] <= O[l]:
      flag = 0
      break
    else:
      continue
  if  flag ==1:
    ans += 1
print(ans)
      

Fixed submission:
N, M = map(int, input().split())
O = list(map(int, input().split()))
B = [[] for i in range(N)]
 
for j in range(M):
  o_1, o_2 = map(int, input().split())
  B[o_1-1].append(o_2-1)
  B[o_2-1].append(o_1-1)

ans = 0
for node in range(N):
  flag =1
  for l in B[node]:
    if O[node] <= O[l]:
      flag = 0
  if  flag ==1:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
 
a = list(map(int, input().split()))
A = a[0]
B = a[1]
N = a[2]
 
if N%B !=0:
  x_1 = (N//B)*B-1
  if x_1 == -1:
    x_1 = N
  x_2 = N
elif N == 1 or B ==1:
  x_1 =N
  x_2 =N

else:
  x_1 = N-1
  x_2 = N-1
ans_1 = math.floor(A*x_1/B)-A*math.floor(x_1/B)
ans_2 = math.floor(A*x_2/B)-A*math.floor(x_2/B)
if ans_1 >= ans_2:
  print(ans_1)
else:
  print(ans_2)

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

if a[1]//k != a[0]//k:
  print('OK')
elif a[0]%k == 0:
  print('OK')
else:
  print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
a = input()
n = len(a)
s = int(a)

m = 0
for i in range(n):
  for j in range(n-i):
    if int(a[i:i+j+1])%2019 == 0:
      m = m+1
print(m)
    

Fixed submission:
m = 2019
s = 0
i = 1
l=[0]*m

for c in reversed(input()):
    s = (s + int(c)* i)%m
    l[s] +=1
    i = (i*10)%m
    
print(l[0] + sum(v*(v-1)//2 for v in l))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
  print(a.count(i+1))

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

for i in range(n-1):
  c[a[i]-1] += 1

for j in range(n):
  print(c[j])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

for i in range(q):
  order = list(input().split())
  if order[0] == '1':
    s = s[::-1]
  elif order[1] == '1':
    s = order[2] + s
  elif order[1] == '2':
    s = s + order[2]
print(s)

Fixed submission:
s = input()
q = int(input())
 
head = []
tail = []
flip = 0
 
for i in range(q):
    query = input().split()
    if query[0] == "1":
        flip ^=1
    else:
        f = int(query[1]) - 1
        c = query[2]
        if (f ^ flip) == 0:
            head.append(c)
        else:
            tail.append(c)
 
if flip:
    head, tail = tail, head
    s = s[::-1]
 
head = "".join(head)
tail = "".join(tail)
 
print(head[::-1] + s + tail)
Buggy python submission (verdict: Runtime Error):
s, t = input().split()
a, b = map(int, input().split())
u =input()

if s == u:
  print(a-1, b)
else:
  prtin(a, b-1)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u =input()
 
if s == u:
  print(a-1, b)
else:
  print(a, b-1)
Buggy python submission (verdict: Runtime Error):
a = input()
b = input()
print(int(6-a-b))

Fixed submission:
a = int(input())
b = int(input())
print(6-a-b)
Buggy python submission (verdict: Runtime Error):
a = list(map(int, input().split()))
if sum(a) >= 22:
  print('bust')
else:
  printt('win')

Fixed submission:
a = list(map(int, input().split()))
if sum(a) >= 22:
  print('bust')
else:
  print('win')
Buggy python submission (verdict: Runtime Error):
f = inout()
r = input()

cnt = 0
for i in range(3):
  if f[i] == r[i]:
    cnt += 1
print(cnt)

Fixed submission:
f = input()
r = input()
 
cnt = 0
for i in range(3):
  if f[i] == r[i]:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i ==0:
      divisors.append(i)
  return divisors

def digit(n):
  for i in range(10):
    if n>=10**i and n<10**(i+1):
      return i+1
      break

list = make_divisors(n)

ans = 12

for i in list:
  if max(digit(i), digit(n/i)) < ans:
    ans = max(digit(i), digit(n/i))

print(ans)

Fixed submission:
n = int(input())

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i ==0:
      divisors.append(i)
  return divisors

def digit(n):
  for i in range(15):
    if n>=10**i and n<10**(i+1):
      return i+1
      break

list = make_divisors(n)

ans = 2345

for i in list:
  if max(digit(i), digit(n/i)) < ans:
    ans = max(digit(i), digit(n/i))

print(ans)

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

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i ==0:
      divisors.append(i)
      if i != n//i:
        divisors.append(n//i)
  return divisors

def digit(n):
  for i in range(10):
    if n>=10**i and n<10**(i+1):
      return i+1
      break

list = make_divisors(n)

ans = 12

for i in list:
  if max(digit(i), digit(n/i)) < ans:
    ans = max(digit(i), digit(n/i))

print(ans)
  
  

Fixed submission:
n = int(input())

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i ==0:
      divisors.append(i)
  return divisors

def digit(n):
  for i in range(15):
    if n>=10**i and n<10**(i+1):
      return i+1
      break

list = make_divisors(n)

ans = 2345

for i in list:
  if max(digit(i), digit(n/i)) < ans:
    ans = max(digit(i), digit(n/i))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=sorted([int(i) for i in input().split()])
m={}
for i in range(n):
    x=m.get(a[i],0)
    m[a[i]]=x+1
q=int(input())
b=[]
c=[]
for i in range(q):
    b,c=[int(i) for i in input().split()]
    x=m.get(b,0)
    y=m.get(c,0)
    m[b]=0
    m[c]=x+y
    print(sum(map(lambda x: x*m[x],m.keys())))


Fixed submission:
n=int(input())
m={}
s=0
for i in input().split():
    i=int(i)
    x=m.get(i,0)
    m[i]=x+1
    s+=i
q=int(input())
for i in range(q):
    b,c=[int(i) for i in input().split()]
    x=m.get(b,0)
    y=m.get(c,0)
    m[b]=0
    m[c]=x+y
    s=s-(b*x)+(c*x)
    print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n=input()
a=[int(i) for i in input().split()]
r=1
for i in a:
    r*=i
if 10**18 < r:
    print(-1)
else:
    print(r)


Fixed submission:
n=input()
a=[int(i) for i in input().split()]
t=10**18
r=1
if 0 in a:
    print(0)
else:
    for i in a:
        r*=i
        if t < r:
            print(-1)
            break
    else:
        print(r)
Buggy python submission (verdict: Runtime Error):
l=[0] * (n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        #print(i,j)
        index=min(abs(y-j)+abs(x-i)+1,j-i)-1
        #print(index+1)
        l[index]=l[index]+1
for i in range(len(l)):
    print(l[i])


Fixed submission:
n,x,y=[int(i) for i in input().split()]
l=[0 for i in range(n-1)]
for i in range(1,n):
    for j in range(i+1,n+1):
        #print(i,j)
        index=min(abs(y-j)+abs(x-i)+1,j-i)-1
        #print(index+1)
        l[index]=l[index]+1
for i in range(len(l)):
    print(l[i])