qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import numpy as np

N = int(input())
ans = len(str(N))
for i in range(2, int(np.sqrt(N)) + 2):
    if not N % i:
        a = max(len(str(i)), len(str(int(N / i))))
        ans = min(ans, a)
print(a)

Fixed code:
import numpy as np
 
N = int(input())
ans = len(str(N))
for i in range(2, int(np.sqrt(N)) + 2):
    if not N % i:
        a = max(len(str(i)), len(str(int(N / i))))
        ans = min(ans, a)
print(ans)
Buggy code:
import math
n=int(input())
a=int(math.sqrt(n))
ans=len(str(n))
for i in range(1,a+1):
  if n%i==0:
    cand=len(str(max(i,n/i)))
    if ans>cand:
      ans=cand
print(ans)

Fixed code:
import math
n=int(input())
a=int(math.sqrt(n))
ans=len(str(n))
for i in range(1,a+1):
  if n%i==0:
    cand=len(str(max(i,int(n/i))))
    if ans>cand:
      ans=cand
print(ans)
Buggy code:
N = int(input())

for i in range(int(N**0.5)+1, 1, -1):
    if N % i == 0:
        break
print(len(str(N//i)))


Fixed code:
N = int(input())

for i in range(int(N**0.5), 0, -1):
    if N % i == 0:
        break
print(len(str(N//i)))
Buggy code:
from math import sqrt
from itertools import product
import sys

n = int(input())
p = []
def factorization(arg):
    while arg % 2 == 0:
        p.append(2)
        arg /= 2
    for i in range(3, int(sqrt(arg)) + 1, 2):
        while arg % i == 0:
            p.append(i)
            arg /= i
    if arg > 1:
        p.append(arg)
if n == 1:
    print(1)
else:
    factorization(n)
    min = sys.maxsize
    for bit in range(2 ** len(p)):
        a = 1
        b = 1
        for i in range(len(p)):
            if ((bit >> i) & 1):
                a *= p[i]
            else:
                b *= p[i]
        if min > len(str(a)) if len(str(a)) >= len(str(b)) else len(str(b)):
            min = len(str(a)) if len(str(a)) >= len(str(b)) else len(str(b))
    print(min)

Fixed code:
from math import sqrt
from itertools import product
import sys

n = int(input())
p = []
def factorization(arg):
    while arg % 2 == 0:
        p.append(2)
        arg //= 2
    for i in range(3, int(sqrt(arg)) + 1, 2):
        while arg % i == 0:
            p.append(i)
            arg //= i
    if arg > 1:
        p.append(arg)
if n == 1:
    print(1)
else:
    factorization(n)
    min = sys.maxsize
    for bit in range(2 ** len(p)):
        a = 1
        b = 1
        for i in range(len(p)):
            if ((bit >> i) & 1):
                a *= p[i]
            else:
                b *= p[i]
        if min > a and a >= b:
            min = a
        elif min > b and b > a:
            min = b
    print(len(str(min)))
Buggy code:
from math import sqrt
from itertools import product
import sys

n = int(input())
p = []
def factorization(arg):
    while arg % 2 == 0:
        p.append(2)
        arg /= 2
    for i in range(3, int(sqrt(arg)) + 1, 2):
        while arg % i == 0:
            p.append(i)
            arg /= i
    if arg > 1:
        p.append(arg)
if n == 1:
    print(1)
else:
    factorization(n)
    min = sys.maxsize
    for bit in list(product([False, True], repeat=len(p))):
        a = 1
        b = 1
        for i in range(len(p)):
            if bit[i]:
                a *= p[i]
            else:
                b *= p[i]
        if min > len(str(a)) if len(str(a)) >= len(str(b)) else len(str(b)):
            min = len(str(a)) if len(str(a)) >= len(str(b)) else len(str(b))
    print(min)

Fixed code:
from math import sqrt
from itertools import product
import sys

n = int(input())
p = []
def factorization(arg):
    while arg % 2 == 0:
        p.append(2)
        arg //= 2
    for i in range(3, int(sqrt(arg)) + 1, 2):
        while arg % i == 0:
            p.append(i)
            arg //= i
    if arg > 1:
        p.append(arg)
if n == 1:
    print(1)
else:
    factorization(n)
    min = sys.maxsize
    for bit in range(2 ** len(p)):
        a = 1
        b = 1
        for i in range(len(p)):
            if ((bit >> i) & 1):
                a *= p[i]
            else:
                b *= p[i]
        if min > len(str(a)) if len(str(a)) >= len(str(b)) else len(str(b)):
            min = len(str(a)) if len(str(a)) >= len(str(b)) else len(str(b))
    print(min)
Buggy code:
N = int(input().strip())

def F(a, b):
    return max(len(str(a)), len(str(b)))

f = N
for i in range(1, N):
    if i * i >= N:
        break
    if N % i == 0:
        _f = F(i, N // i)
        f = min(f, _f)



Fixed code:
N = int(input().strip())

def F(a, b):
    return max(len(str(a)), len(str(b)))

f = N
for i in range(1, N):
    if i * i > N:
        break
    if N % i == 0:
        _f = F(i, N // i)
        f = min(f, _f)

print(f)
Buggy code:
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)

    #divisors.sort()
    return divisors

N = int(input())
list =  make_divisors(N)
ans = 10**9
for i in range(0,len(list),2):
  tmp1 = len(str(list[i]))
  tmp2 = len(str(list[i+1]))
  ans = min(ans,max(tmp1,tmp2))
print(ans)


Fixed code:
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)

    #divisors.sort()
    return divisors

N = int(input())
list =  make_divisors(N)
ans = 10**9
if len(list)%2==1:
    list.append(list[-1])
for i in range(0,len(list),2):
    tmp1 = len(str(list[i]))
    tmp2 = len(str(list[i+1]))
    ans = min(ans,max(tmp1,tmp2))
print(ans)
Buggy code:
import math
N=int(input())
ans=10**5
for i in range(1, int(math.sqrt(N))+1):
    if int(N/i) != N/i:
        continue
    else:
        j = int(N/i)
        ans = min(ans, len(str(i)), len(str(j)))
print(ans)

Fixed code:
import math
N=int(input())
ans=10**5
for i in range(1, int(math.sqrt(N))+1):
    if int(N/i) != N/i:
        continue
    else:
        j = int(N/i)
        ans = min(ans, max(len(str(i)), len(str(j))))
print(ans)
Buggy code:
from math import sqrt
from math import log10
n=int(input())

i=1
ans=13
j=0

while i<=sqrt(n):
    if n%i==0:
        j=n//i
        ans=int(min(ans,max(log10(i)+1,log10(j)+1)))
        print(i,j)
    i+=1
if j==0:
    ans=int(max(log10(i)+1,log10(j)+1))
print(ans)
    



Fixed code:
from math import sqrt
from math import log10
n=int(input())

i=1
ans=13
j=0

while i<=sqrt(n):
    if n%i==0:
        j=n//i
        ans=int(min(ans,max(log10(i)+1,log10(j)+1)))
    i+=1
if j==0:
    ans=int(max(log10(i)+1,log10(j)+1))
print(ans)
Buggy code:
n=int(input())
x=int(n**0.5)
for i in range(x):
    if n%(x-i)==0:
        print(len(str(x-i)))
        break

Fixed code:
n=int(input())
x=int(n**0.5)
for i in range(x):
    if n%(x-i)==0:
        print(len(str(n//(x-i))))
        break
Buggy code:
import math
N = int(input())
for i in range(1,int(math.sqrt(N))+1):
    if N % i == 0:
        ans = math.log10(N // i) // 1 + 1
print(ans)

Fixed code:
import math
N = int(input())
for i in range(1,int(math.sqrt(N))+1):
    if N % i == 0:
        ans = math.log10(N // i) // 1 + 1
print(int(ans))
Buggy code:
N = int(input())
l = []
for a in range(1, N+1):
  if N % a == 0:
    b = N // a
    s = max(len(str(a)), len(str(b)))
    l.append(int(s))
print(min(l))


Fixed code:
N = int(input())
l = []
for a in range(1, 10**5+1):
  if N % a == 0:
    b = N // a
    s = max(len(str(a)), len(str(b)))
    l.append(int(s))
print(min(l))
Buggy code:
import sys
import math
N = int(input())
for n in range(int(math.sqrt(N)),1,-1):
  if N%n==0:
    print(max(int(math.log10(n)), int(math.log10(N//n)))+1)
    sys.exit()
    


Fixed code:
import sys
import math
N = int(input())
for n in range(int(math.sqrt(N))+1,0,-1):
  if N%n==0:
    print(max(int(math.log10(n)), int(math.log10(N//n)))+1)
    sys.exit()
Buggy code:
n=int(input())
import math
for i in range (math.sqrt(n),0,-1):
  if n%i==0:
    print(max(len(str(i)),len(str(n//i))))
    quit()

Fixed code:
n=int(input())
import math
for i in range (int(math.sqrt(n)),0,-1):
  if n%i==0:
    print(max(len(str(i)),len(str(n//i))))
    quit()
Buggy code:
def fdigit(a,b):
    if len(str(a)) > len(str(b)):
        return len(str(a))
    else:
        return len(str(b))

N = int(input())
result = 10000000000
goal = int((N**0.5)//1)

for i in range(1, goal):
    if N%i ==0:
        if result > fdigit(i, N//i):
            result = fdigit(i, N//i)
            print(i, N/i,fdigit(i, N//i))

print(result)

Fixed code:
def fdigit(a,b):
    if len(str(a)) > len(str(b)):
        return len(str(a))
    else:
        return len(str(b))

N = int(input())
result = 10000000000
goal = int((N**0.5)//1)

for i in range(1, goal+1):
    if N%i ==0:
        #print(i)
        if result > fdigit(i, N//i):
            result = fdigit(i, N//i)
            #print(i, N/i,fdigit(i, N//i))

print(result)
Buggy code:
import math

P=[]
n=int(input())
N=int(math.sqrt(n))

for i in range(1,n+1):
  if n%i==0:
    p=max(len(str(i)),len(str(int(n/i))))
    P.append(p)
    
print(min(P))

Fixed code:
import math

P=[]
n=int(input())
N=int(math.sqrt(n))

for i in range(1,N+2):
  if n%i==0:
    p=max(len(str(i)),len(str(int(n/i))))
    P.append(p)
    
print(min(P))
Buggy code:


def findBiggerDigits(n):
    digits = 0
    while n > 0:
        digits += 1
        n //= 10
    return digits 

def main()->None:
    n = int(input())
    sqrt_n = int(n ** (1/2))
    print(sqrt_n)
    range_a = range(1, sqrt_n+1)

    min_value = 1000000
    for a in range_a:
        if n % a != 0: continue
        b = n / a
        a_digits = findBiggerDigits(a)
        b_digits = findBiggerDigits(b)
        max_dig = max(a_digits, b_digits)
        if max_dig < min_value:
            min_value = max_dig

    print(min_value)


if __name__ == "__main__":
    main()

Fixed code:


def findBiggerDigits(n):
    digits = 0
    while n > 0:
        digits += 1
        n //= 10
    return digits 

def main()->None:
    n = int(input())
    sqrt_n = int(n ** (1/2))
    range_a = range(1, sqrt_n+1)

    min_value = 1000000
    for a in range_a:
        if n % a != 0: continue
        b = n / a
        a_digits = findBiggerDigits(a)
        b_digits = findBiggerDigits(b)
        max_dig = max(a_digits, b_digits)
        if max_dig < min_value:
            min_value = max_dig

    print(min_value)


if __name__ == "__main__":
    main()
Buggy code:
n = int(input())
mx = 1
for i in range(2,n**(1/2)+1):
  if n%i == 0:
    mx = i
print(len(str(n//mx)))
    
    

Fixed code:
n = int(input())
mx = 1
for i in range(2,int(n**(1/2))+1):
  if n%i == 0:
    mx = i
print(len(str(n//mx)))
Buggy code:
import math
N = int(input())
sqrtN = math.floor(math.sqrt(N))
for i in range(sqrtN, 1, -1):
    if N % i == 0:
        print(len(str(N//i)))
        break


Fixed code:
import math
N = int(input())
sqrtN = math.floor(math.sqrt(N))
for i in range(sqrtN, 0, -1):
    if N % i == 0:
        print(len(str(N//i)))
        break
Buggy code:
n = int(input())
root = int(n**0.5)
for i in range(root):
  if n & (root-i) == 0:
    print(len(str( n // (root-i) )))
    break

Fixed code:
n = int(input())
root = int(n**0.5)
for i in range(root):
  if n % (root-i) == 0:
    print(len(str( n // (root-i) )))
    break
Buggy code:
from math import sqrt
n = int(input())
x = n
i = 2
while i <= sqrt(n):
    if n % i == 0:
        x = n / i
    i += 1
print(len(str(x)))


Fixed code:
from math import sqrt
n = int(input())
x = n
i = 2
while i <= sqrt(n):
    if n % i == 0:
        x = n / i
    i += 1
print(len(str(int(x))))
Buggy code:
N = int(input())
M = 0
for i in range(2, int(N ** (1/2)) + 1):
   if N % i == 0:
      if M < i:
         M = i

if M == 0:
   ndm = len(list(str(N)))
else:
   ndm = len(list(str(M)))

print(ndm)

Fixed code:
N = int(input())

M = 1

for i in range(1, int(N ** (1/2)) + 1):
   if N % i == 0:
      if M < i:
         M = i

M = N // M

ndm = len(list(str(M)))

print(ndm)
Buggy code:
import math
N=int(input())
ans=len(str(N))
for a in range(2,math.sqrt(N**0.5)+1):
    if N%a==0:
        b=N//a
        ans=min(ans,len(str(b)))
print(ans)

Fixed code:
N=int(input())
ans=len(str(N))
for a in range(2,int(N**0.5)+1):
    if N%a==0:
        b=N//a
        ans=min(ans,len(str(b)))
print(ans)
Buggy code:
from math import sqrt

N = int(input())
ans = len(str(N))
for i in range(1, int(sqrt(N))+1):
    if N % i == 0:
        B = N//i
    else:
        B = 0
    ans = min(ans, max(len(str(i)), len(str(B))))
print(ans)


Fixed code:
from math import sqrt

N = int(input())
ans = len(str(N))
for i in range(1, int(sqrt(N))+1):
    if N % i == 0:
        B = N//i
        ans = min(ans, max(len(str(i)), len(str(B))))
print(ans)
Buggy code:
N = int(input())
ans = N
for i in range(1, N):
    if N*i > N:
        break
    d = 0
    if N % i == 0:
        d = max(len(str(i)), len(str(N//i)))
        ans = min(ans, d)
print(ans)

Fixed code:
N = int(input())
ans = N
for i in range(1, N):
    if i**2 > N:
        break
    d = 0
    if N % i == 0:
        d = max(len(str(i)), len(str(N//i)))
        ans = min(ans, d)
print(ans)
Buggy code:
def f(a, b):
    str_a = str(a)
    len_a = len(str_a)
    str_b = str(b)
    len_b = len(str_b)

    return len_a if len_a > len_b else len_b

N = int(input())

min = 10**10
for i in range(1, N//2 + 1):
    a = i
    if N % a == 0:
        b = int(N / a)
    else:
        continue

    if len(str(a)) > len(str(N)) // 2 + 1:
        break

    ret = f(a, b)
    if min > ret:
        print(a, b, min, ret)
        min = ret

print(min)


Fixed code:
def f(a, b):
    str_a = str(a)
    len_a = len(str_a)
    str_b = str(b)
    len_b = len(str_b)

    return len_a if len_a > len_b else len_b

N = int(input())

min = 10**10
max_iter = 10 ** (len(str(N))//2 + 1)

for i in range(1, max_iter):
    a = i
    if N % a == 0:
        b = int(N / a)
    else:
        continue

    ret = f(a, b)
    if min > ret:
        min = ret
        if min <= len(str(N))//2:
            break

print(min)
Buggy code:
import math

N = int(input())

min_length = -1
for i in range(int(math.sqrt(N))):
    for j in range(i + 1):
        A = j + 1
        if N % A == 0:
            B = int(N / A)
            len_a = len(str(A))
            len_b = len(str(B))
            length = len_a if len_a >= len_b else len_b
            if min_length == -1 or length < min_length:
                print("len:{}, A:{}, B:{}".format(length, A, B))
                min_length = length
print(min_length)

Fixed code:
import math

N = int(input())

min_length = -1
for A in range(1, int(math.sqrt(N)) + 1, 1):
    if N % A == 0:
        B = int(N / A)
        len_a = len(str(A))
        len_b = len(str(B))
        length = len_a if len_a >= len_b else len_b
        if min_length == -1 or length < min_length:
            # print("len:{}, A:{}, B:{}".format(length, A, B))
            min_length = length
print(min_length)
Buggy code:
import math
n = int(input())
def f(n):
  g = float('inf')
  for i in [j for j in range(1,math.ceil(n**0.5))+1 if n%j == 0]:
    if g > len(str(max(i,n//i))):
      g = len(str(max(i,n//i)))
    if g == float('inf'):
        g = 1
  return g
print(f(n))

Fixed code:
import math
n = int(input())
def f(n):
  g = float('inf')
  for i in [j for j in range(1,math.ceil(n**0.5)+1) if n%j == 0]:
    if g > len(str(max(i,n//i))):
      g = len(str(max(i,n//i)))
    if g == float('inf'):
        g = 1
  return g
print(f(n))
Buggy code:
import sys
import math
input = sys.stdin.readline

N = int(input())
a = int(math.sqrt(N))

A = 0
B = 0
for i in reversed(range(1, a + 1)):
  if not N % i:
    A = i
    B = N // A
    break

print(max(len(str(A)), len(str(B)))

Fixed code:
import sys
import math
input = sys.stdin.readline
 
N = int(input())
a = int(math.sqrt(N))
 
A = 0
B = 0
for i in reversed(range(1, a + 1)):
  if not N % i:
    A = i
    B = N // A
    break
 
print(max(len(str(A)), len(str(B))))
Buggy code:
N = int(input())
import math
n = math.floor(N**0.5)
for i in range(n):
    x = n - i
    if n % x == 0:
        break
print(len(str(x)))

Fixed code:
N = int(input())
import math
n = math.floor(N**0.5)
for i in range(n):
    x = n - i
    if N % x == 0:
        y = N//x
        break
print(len(str(y)))
Buggy code:
import math

N = int(input())
M = int(N**0.5//1)
S = list()
for i in range(M+1):
    if i > 0 :
       if N%i == 0:
           S.append(i)
a =  S[-1]
b = N//a
print(len(str(a))+len(str(b)))


Fixed code:
import math

N = int(input())
M = int(N**0.5//1)
S = list()
for i in range(M+1):
    if i > 0 :
       if N%i == 0:
           S.append(i)
a =  S[-1]
b = N//a
print(max(len(str(a)),len(str(b))))
Buggy code:
import math
N = int(input())
ans = 10
for A in range(1, int(math.sqrt(N))):
  if N % A == 0:
    B = N//A
    F = max(len(str(A)), len(str(B)))
    ans = F if ans > F
print(ans)

Fixed code:
import math
N = int(input())
ans = 10
for A in range(1, int(math.sqrt(N))+1):
  if N % A == 0:
    B = N//A
    F = max(len(str(A)), len(str(B)))
    if ans > F:
      ans = F 
print(ans)
Buggy code:
n = int(input())
ans = 99
for i in range(int(n**0.5),0,-1):
  if n%i==0:
    ans = min([ans,len(str(n//i))+len(str(i))])
print(ans)

Fixed code:
n = int(input())
ans = 11
for i in range(int(n**0.5),0,-1):
  if n%i==0:
    ans = min([ans,len(str(n//i))])
print(ans)
Buggy code:
import math
n = int(input())

a = 1
b = 1

'''
def get_prime(num):
    primes = {}
    origin_num = num
    primes[1] = 1

    tmp = int(math.sqrt(num) + 1)

    for i in range(2, tmp):
        while num % i == 0:
            num //= i

            if not (i in primes.keys()):
                primes[i] = 0
            primes[i] += 1

    if num != 1:
        primes[num] = 1

    if num == origin_num:
        primes[num] = 1

    return primes


prime_dic = get_prime(n)
prime_sorted = sorted(prime_dic.items(), key=lambda x: x[0], reverse=True)

for k, v in prime_sorted:
    for i in range(v):
        if a <= b:
            a *= k
        else:
            b *= k
'''


tmp = int(math.sqrt(n) + 1)

for i in range(1, tmp):
    if n % i == 0:
        a = i

b = int(n / a)

f = max(len(str(a)), len(str(b)))

print(f, a, b)



Fixed code:
import math
n = int(input())

a = 1
b = 1

'''
def get_prime(num):
    primes = {}
    origin_num = num
    primes[1] = 1

    tmp = int(math.sqrt(num) + 1)

    for i in range(2, tmp):
        while num % i == 0:
            num //= i

            if not (i in primes.keys()):
                primes[i] = 0
            primes[i] += 1

    if num != 1:
        primes[num] = 1

    if num == origin_num:
        primes[num] = 1

    return primes


prime_dic = get_prime(n)
prime_sorted = sorted(prime_dic.items(), key=lambda x: x[0], reverse=True)

for k, v in prime_sorted:
    for i in range(v):
        if a <= b:
            a *= k
        else:
            b *= k
'''


tmp = int(math.sqrt(n) + 1)

for i in range(1, tmp):
    if n % i == 0:
        a = i

b = int(n / a)

f = max(len(str(a)), len(str(b)))

print(f)
Buggy code:
import math

N = int(input())

def get_divisor_list(N):
    divisor_list = []

    for i in range(1, int(math.sqrt(N)) + 1):
        if N % i == 0:
            divisor_list.append([i, N //i])

    return divisor_list

divisor_list_max = [max(x) for x in get_divisor_list(N)]


print(len(str(divisor_list_max)))

Fixed code:
import math

N = int(input())

def get_divisor_list(N):
    divisor_list = []

    for i in range(1, int(math.sqrt(N)) + 1):
        if N % i == 0:
            divisor_list.append([i, N //i])

    return divisor_list

divisor_list_max_min = min([max(x) for x in get_divisor_list(N)])



print(len(str(divisor_list_max_min)))
Buggy code:
n = int(input())
a = 1
b = n
for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
        a = i
        b //= i

c = max(a, b)
print(len(str(c)))    

Fixed code:
n = int(input())
a = 1
b = n
for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
        a = i
        b = n // i
      

c = max(a, b)
print(len(str(c)))
Buggy code:
n=int(input())
li=[]

for i in range(1,10**5):
  if n%i==0:
    a=i
    b=n//a
    f=max(len(str(a)),len(str(b)))
    li.append(f)
print(li)

Fixed code:
n=int(input())
li=[]

for i in range(1,10**5):
  if n%i==0:
    a=i
    b=n//a
    f=max(len(str(a)),len(str(b)))
    li.append(f)
print(min(li))
Buggy code:
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)

    divisors.sort()
    return divisors

N = int(input())
answer = 0
len_div = len(make_divisors(N))
if len_div % 2 == 0:
    A_len = len(str(make_divisors(N)[len_div // 2 - 2]))
    B_len = len(str(make_divisors(N)[len_div // 2 - 1]))
    if A_len <= B_len:
        answer = B_len
    else:
        answer = A_len
else:
    answer = len(str(make_divisors(N)[len_div // 2]))
print(answer)



Fixed code:
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)

    divisors.sort()
    return divisors

N = int(input())
answer = 0
len_div = len(make_divisors(N))
# print(make_divisors(N))
# print(make_divisors(N))
# print(make_divisors(N))
# print(len(make_divisors(N)))
# print(make_divisors(N)[len_div // 2])

if len_div % 2 == 0:
    A_len = len(str(make_divisors(N)[len_div // 2 - 1]))
    B_len = len(str(make_divisors(N)[len_div // 2]))
    if A_len <= B_len:
        answer = B_len
    else:
        answer = A_len
else:
    answer = len(str(make_divisors(N)[len_div // 2]))
    # print(make_divisors(N)[len_div // 2])
print(answer)
Buggy code:
n=int(input())
ans=10
for i in range(1,10**5+1):
  if n%i==0:
    ans=min(ans,len(str(n//i)))
print(ans)

Fixed code:
n=int(input())
ans=10
for i in range(1,10**5+1):
  if n%i==0 and n//i>=i:
    ans=min(ans,len(str(n//i)))
print(ans)
Buggy code:
N = int(input())

ans = 10**18

for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        b = N//i
        print(b, i)
        ans = min(ans, max( len(str(i)),  len(str(b))))
print(ans)

Fixed code:
N = int(input())

ans = 10**18

for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        b = N//i
        ans = min(ans, max( len(str(i)),  len(str(b))))
print(ans)
Buggy code:
import math as m
N = int(input())
F_ab = 0
for i in range(1, int(sqrt(N))+1):
    if N%i != 0:
        continue
    if i == 1:
        F_ab = len(str(N//i))
    else:
        F_ab = min(F_ab, max(len(str(i)), len(str(N//i))))

print(F_ab)

Fixed code:
import math as m
N = int(input())
F_ab = 0
for i in range(1, int(m.sqrt(N))+1):
    if N%i != 0:
        continue
    if i == 1:
        F_ab = len(str(N//i))
    else:
        F_ab = min(F_ab, max(len(str(i)), len(str(N//i))))

print(F_ab)
Buggy code:
import sys
def main():
    n = int(input())

    mi = sys.maxsize
    for x in range(1, n + 1):
        if n % x == 0:
            mi = min(mi, max(len(str(x)), len(str(int(n / x)))))
    print(mi)


if __name__ == "__main__":
    main()

Fixed code:
import sys
def main():
    n = int(input())

    mi = sys.maxsize
    for x in range(1, n + 1):
        if x > int(n / x):
            break
        if n % x == 0:
            mi = min(mi, max(len(str(x)), len(str(int(n / x)))))
    print(mi)


if __name__ == "__main__":
    main()
Buggy code:
import math

N = int(input())
n = int(math.sqrt(N))
if N / n == n:
    print(int(math.log10(n) + 1))
else:
    while N % n != 0:
        n -= 1
    print(int(math.log10(n) + 1))


Fixed code:
import math

N = int(input())
n = int(math.sqrt(N)) + 1
if N / n == n:
    print(int(math.log10(n) + 1))
else:
    while N % n != 0:
        n -= 1
    print(int(math.log10(N/n) + 1))
Buggy code:
import math
N = int(input())
min_digits = 12
for a in range(1, round(math.sqrt(N))+1):
    if N%a !=0:
        continue
    b = N//a
    print(a, b)
    digits = max(len(str(a)), len(str(b)))
    if digits < min_digits:
        min_digits = digits
print(min_digits)

Fixed code:
import math
N = int(input())
min_digits = 12
for a in range(1, round(math.sqrt(N))+1):
    if N%a !=0:
        continue
    b = N//a
    digits = max(len(str(a)), len(str(b)))
    if digits < min_digits:
        min_digits = digits
print(min_digits)