qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N, M = map(int, input().split())
a, b, c, d = [0] * N, [0] * N, [0] * M, [0] * M
for i in range(N):
	a[i], b[i] = map(int, input().split())
for i in range(M):
	c[i], d[i] = map(int, input().split())

for j in range(N):
	for k in range(M - 1, -1, -1):
		ans = "nan"
		diff = float("inf")
		if abs(a[j] - c[k]) + abs(b[j] - d[k]) < diff:
			diff = abs(a[j] - c[k]) + abs(b[j] - d[k])
			ans = k
	print(k + 1)


Fixed code:
N, M = map(int, input().split())
a, b, c, d = [0] * N, [0] * N, [0] * M, [0] * M
for i in range(N):
	a[i], b[i] = map(int, input().split())
for i in range(M):
	c[i], d[i] = map(int, input().split())

for j in range(N):
	ans = "nan"
	diff = float("inf")
	for k in range(M):
		if abs(a[j] - c[k]) + abs(b[j] - d[k]) < diff:
			diff = abs(a[j] - c[k]) + abs(b[j] - d[k])
			ans = k
	print(ans + 1)
Buggy code:
n,m=map(int,input().split())
l1=[]
l2=[]
for i in range(n):
  l1.append(list(map(int,input().split())))
for i in range(m):
  l2.append(list(map(int,input().split())))
for i in range(n):
  l=abs(l1[i][0]-l2[0][0])+abs(l1[i][1]-l2[0][1])
  for j in range(1,m):
    if l>abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1]):
      l=abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1])
    else:
      pass
  print(l)
  

Fixed code:
n,m=map(int,input().split())
l1=[]
l2=[]
for i in range(n):
  l1.append(list(map(int,input().split())))
for i in range(m):
  l2.append(list(map(int,input().split())))
for i in range(n):
  l=abs(l1[i][0]-l2[0][0])+abs(l1[i][1]-l2[0][1])
  n=0
  for j in range(1,m):
    if l>abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1]):
      l=abs(l1[i][0]-l2[j][0])+abs(l1[i][1]-l2[j][1])
      n=j
    else:
      pass
  print(n+1)
Buggy code:
N, M = [int(i) for i in input().split().strip()]
A = [[int(i) for i in input().split().strip()] for j in range(N)]
C = [[int(i) for i in input().split().strip()] for j in range(M)]

ls1 = []
for i in range(N):
    ls2 = []
    for j in range(M):
        ls2.append(abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1]))
    a = min(ls2)
    ls1.append(ls2.index(a))
for i in ls1:
    print(i)

Fixed code:
N, M = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(N)]
C = [[int(i) for i in input().split()] for j in range(M)]

ls1 = []
for i in range(N):
    ls2 = []
    for j in range(M):
        ls2.append(abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1]))
    a = min(ls2)
    ls1.append(ls2.index(a))
for i in ls1:
    print(i+1)
Buggy code:
n,m=map(int,input().split())
s=[]
p=[]
md=[[None,float('INF')] for i in range(n)]
for i in range(n):
    t1,t2=map(int,input().split())
    s.append([t1,t2])
for i in range(m):
    t1,t2=map(int,input().split())
    p.append([t1,t2])
for i in range(n):
    for j in range(m):
        if md[i][1]>abs(s[i][0]-p[j][0])+abs(s[i][1]-p[j][1]):
            md[i][0]=j+1
for i in range(n):
    print(md[i][0])

Fixed code:
n,m=map(int,input().split())
s=[]
p=[]
md=[[None,float('INF')] for i in range(n)]
for i in range(n):
    t1,t2=map(int,input().split())
    s.append([t1,t2])
for i in range(m):
    t1,t2=map(int,input().split())
    p.append([t1,t2])
for i in range(n):
    for j in range(m):
        if md[i][1]>abs(s[i][0]-p[j][0])+abs(s[i][1]-p[j][1]):
            md[i][0]=j+1
            md[i][1]=abs(s[i][0]-p[j][0])+abs(s[i][1]-p[j][1])
for i in range(n):
    print(md[i][0])
Buggy code:
N, M = map(int,input().split())

list_a = []
list_b = []
count = 0
ans = [10**8 for i in range(N)]

for i in range(N):
    a = [int(i) for i in input().split()]
    list_a.append(a)
    
for i in range(M):
    b = [int(i) for i in input().split()]
    list_b.append(b)
    
for i in range(N):
    ans_x = 10**8
    for j in range(M):
        x = abs(list_a[i][0]-list_b[j][0])
        y = abs(list_a[i][1]-list_b[j][1])
        xxx = x + y
        if xxx < ans_x:
            ans_x = xxx
            count = j+1
            ans[i] = min(count, ans[i])
    print(ans[i])


    

Fixed code:
N, M = map(int,input().split())

list_a = []
list_b = []
count = 0

for i in range(N):
    a = [int(i) for i in input().split()]
    list_a.append(a)
    
for i in range(M):
    b = [int(i) for i in input().split()]
    list_b.append(b)
    
for i in range(N):
    ans_x = 10**18
    for j in range(M):
        x = abs(list_a[i][0]-list_b[j][0])
        y = abs(list_a[i][1]-list_b[j][1])
        xxx = x + y
        if xxx < ans_x:
            ans_x = xxx
            count = j+1
    print(count)
Buggy code:
N,M = map(int,input().split())
ab = []
for i in range(N):
    a,b = map(int,input().split())
    ab.append((a,b))
cd = []
for i in range(N):
    a,b = map(int,input().split())
    cd.append((a,b))
ans = []
for i in range(N):
    aaa = 1000000000
    for j in range(M):
        man = abs(ab[i][0] - cd[j][0]) - abs(ab[i][1] - cd[j][1])
        if(man < aaa):
            aaa = man
            cnt = j + 1
    ans.append(cnt)
for i in ans:
    print(i)

Fixed code:
N,M = map(int,input().split())
ab = []
for i in range(N):
    a,b = map(int,input().split())
    ab.append((a,b))
cd = []
for i in range(M):
    c,d = map(int,input().split())
    cd.append((c,d))
ans = []
for i in range(len(ab)):
    aaa = 1000000000
    for j in range(len(cd)):
        man = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if(man < aaa):
            aaa = man
            cnt = j + 1
    ans.append(cnt)
for i in ans:
    print(i)
Buggy code:
n,m=map(int, input().split())
s=[list(map(int, input().split())) for _ in range(n)]
c=[list(map(int, input().split())) for _ in range(m)]
for a,b in s:
  k=[]
  for c,d in c:
    k.append(abs(a-c)+abs(b-d))
  print(k.index(min(k))+1)

Fixed code:
n,m=map(int, input().split())
s=[list(map(int, input().split())) for _ in range(n)]
o=[list(map(int, input().split())) for _ in range(m)]
for a,b in s:
  k=[]
  for c,d in o:
    k.append(abs(a-c)+abs(b-d))
  print(k.index(min(k))+1)
Buggy code:

import math
N=int(input())

def func(A,B):
  if A > B:
    return len(str(A))
  else:
    return len(str(B))


ans=[]
N2=int(math.sqrt(N))
for A in range(1,N2+1):
  if N%A==0:
    B=N/A
    ans.append(func(A,B))

print(min(ans))

Fixed code:

import math
N=int(input())

def func(A,B):
  if A > B:
    return len(str(A))
  else:
    return len(str(B))


ans=[]
N2=math.floor(math.sqrt(N))
for A in range(1,N2+1):
  if N%A==0:
    B=int(N/A)
    ans.append(func(A,B))

print(min(ans))
Buggy code:
N = int(input())
r_N = int(N ** (1 / 2))

li = []
for n in range(1,r_N + 1):
  if N % n == 0:
    a = N // n
    l = max(len(str(a)),len(str(n))))
  	li.append(l)
    
print(min(li))

Fixed code:
N = int(input())
r_N = int(N ** (1 / 2))
 
li = []
for n in range(1,r_N + 1):
  if N % n == 0:
    a = N // n
    l = max(len(str(a)),len(str(n)))
    li.append(l)
    
print(min(li))
Buggy code:
import math
n = int(input())
k = int(math.sqrt(n))
for i in range(1,k+2):
  if n%i == 0:
    a = n//i
    break
s = len(str(a))
print(s)

Fixed code:
import math
n = int(input())
k = int(math.sqrt(n))
for i in range(k+2,0,-1):
  if n%i == 0:
    a = n//i
    break
s = len(str(a))
print(s)
Buggy code:
n = int(input())
pf={}
for i in range(2,int(n**0.5) + 1):
    if n % i == 0:
      pf[i] = pf.get(i,0) + 1
a = max(pf)
b = int(n/a)
ans = max(len(str(a)), len(str(b)))
print(ans)

Fixed code:
n = int(input())
pf={}
for i in range(1,int(n**0.5) + 1):
    if n % i == 0:
      pf[i] = pf.get(i,0) + 1
a = max(pf)
b = int(n/a)
ans = max(len(str(a)), len(str(b)))
print(ans)
Buggy code:
import math

N = int(input())
answer = []
b = 0
for a in range(1,round(sqrt(N))+1):
  if N%a == 0:
    b = N//a
    answer.append(max(len(str(a)), len(str(b))))
print(min(answer))


Fixed code:
import math

N = int(input())
answer = []
b = 0
for a in range(1,round(math.sqrt(N))+1):
  if N%a == 0:
    b = N//a
    answer.append(max(len(str(a)), len(str(b))))
print(min(answer))
Buggy code:
N = int(input())
x = int(n**.5)
while n%x:
  x-=1

print(len(str(n//x)))

Fixed code:
N = int(input())
x = int(N**.5)
while N%x:
  x-=1

print(len(str(N//x)))
Buggy code:
n = int(input())
l = []
for i in range(1, int(math.sqrt(n)//1)):
    if n % i == 0:
        l.append(int(n / i))
print(len(str(l[-1])))

Fixed code:
import math
n = int(input())
l = []
for i in range(1, int(math.sqrt(n)//1)+1):
    if n % i == 0:
        l.append(int(n / i))
print(len(str(l[-1])))
Buggy code:
F=lambda*m:max(len(str(x))for x in m)
N=int(input())
print(min(F(x,N//x)for x in range(1,int(N**.5)+1)if N%x))

Fixed code:
F=lambda*m:max(len(str(x))for x in m)
N=int(input())
print(min(F(x,N//x)for x in range(1,int(N**.5)+1)if N%x==0))
Buggy code:
import math
N = int(input())
ans = float("inf")
for i in range(2, math.ceil(math.sqrt(N)+1)):
  if N % i == 0 and ans > (N // i):
    ans = N // i
print(len(str(ans)))

Fixed code:
import math
N = int(input())
ans = float("inf")
for i in range(1, math.ceil(math.sqrt(N)+1)):
  if N % i == 0 and ans > len(str(N // i)):
    ans = len(str(N // i))
print(ans)
Buggy code:
n = int(input())

min_len = len(str(n))
for i in range(2,int(n**(1/2))+1):
    if n%i==0:
        l = max(len(str(i)), len(str(n/i)))
        min_len = min(min_len, l)

print(min_len)

Fixed code:
n = int(input())

min_len = len(str(n))
for i in range(2,int(n**(1/2))+1):
    if n%i==0:
        l = max(len(str(i)), len(str(n//i)))
        min_len = min(min_len, l)


print(min_len)
Buggy code:
n = int(input())
import math
ans = float('Inf')
sq = int(math.sqrt(n)) + 1
for i in range(1, sq):
    #print(i, n // i)
    if n % i != 0:
        continue
    print(i, n // i)
    ans = min(ans, max(len(str(i)), len(str(n // i))))
print(ans)

Fixed code:
n = int(input())
import math
ans = float('Inf')
sq = int(math.sqrt(n)) + 1
for i in range(1, sq):
    #print(i, n // i)
    if n % i != 0:
        continue
    #print(i, n // i)
    ans = min(ans, max(len(str(i)), len(str(n // i))))
print(ans)
Buggy code:
import math

if __name__ == '__main__':
    N = int(input())
    root_N_int = math.floor(math.sqrt(N))
    for A in range(root_N_int, 0, -1):
        if N % A == 0:
            B = int(N / A)
            print(B)
            break
    digit = len(str(B))
    print(digit)

Fixed code:
import math

if __name__ == '__main__':
    N = int(input())
    root_N_int = math.floor(math.sqrt(N))
    for A in range(root_N_int, 0, -1):
        if N % A == 0:
            B = int(N / A)
            break
    digit = len(str(B))
    print(digit)
Buggy code:
N = int(input())

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

    # divisors.sort()
    return divisors

X = make_divisors(N)
ans = 10

for i in X:
    ans = min(ans, max(len(str(i[0])), len(str(i[1]))))

print(ans)

for i in X:
    ans = min(ans, max(len(str(i[0])), len(str(i[1]))))

print(ans)


Fixed code:
N = int(input())

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

    # divisors.sort()
    return divisors

X = make_divisors(N)
ans = 10

for i in X:
    ans = min(ans, max(len(str(i[0])), len(str(i[1]))))

print(ans)
Buggy code:
import math

N = int(input())

anss = []
for n in range(1,math.ceil(N**0.5)):
	if N % n == 0:
		anss.append(max(len(str(n)),len(str(N//n))))
else:
	anss.append(1)
		
print(min(anss))

Fixed code:
import math

N = int(input())

anss = []
for n in range(1,math.ceil(N**0.5)+1):
	if N % n == 0:
		anss.append(max(len(str(n)),len(str(N//n))))

if len(anss) == 0:
	anss.append(1)
		
print(min(anss))
Buggy code:
import math
def f(a, b):
    al = len(str(a))
    bl = len(str(b))
    if al > bl:
        return al
    return bl
N = int(input())
result = len(str(N))
for a in range(1, N):
    if (N % a) != 0:
        continue
    if a*a >= N:
        break
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)


Fixed code:
def f(a, b):
    al = len(str(int(a)))
    bl = len(str(int(b)))
    if al > bl:
        return al
    return bl
N = int(input())
result = len(str(N))
for a in range(1, N):
    if a*a > N:
        break
    if (N % a) != 0:
        continue
    b = N / a
    r = f(a, b)
    if r < result:
        result = r
print (result)
Buggy code:
N = int(input())

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if i > N/i:
                break
            if num % i == 0:
                divisor_list.append(i)

        return divisor_list

A = make_divisor_list(N)

B = []
ans = 0

for a in A:
    b = int(N/a)
    c = max(a,b)
    ans = max(ans,len(str(c)))

print(ans)

Fixed code:
N = int(input())

def make_divisor_list(num):
    if num < 1:
        return []
    elif num == 1:
        return [1]
    else:
        divisor_list = []
        divisor_list.append(1)
        for i in range(2, num // 2 + 1):
            if i > N/i:
                break
            if num % i == 0:
                divisor_list.append(i)

        return divisor_list

A = make_divisor_list(N)

B = []
ans = float("inf")

for a in A:
    b = int(N/a)
    c = max(a,b)
    ans = min(ans,len(str(c)))

print(ans)
Buggy code:
N = int(input())
ret = float("inf")
for A in range(1,N//2):
  if N % A == 0:
    ret = min(ret,max(len(str(A)),len(str(N//A))))
print(ret)
              

Fixed code:
N = int(input())
ret = float("inf")
for A in range(1,100000):
  if N % A == 0:
    ret = min(ret,max(len(str(A)),len(str(N//A))))
print(ret)
Buggy code:
from math import sqrt
N = int(input())

max_v = int(sqrt(N))
for num in range(max_v,1,(-1)):
	if N % num == 0:
		div = num
		break

print(max(len(str(div)),len(str(N//max_v))))

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

div = 1
max_v = int(sqrt(N))
for num in range(max_v,1,(-1)):
	if N % num == 0:
		div = num
		break

#print(div)
print(max(len(str(div)),len(str(N//div))))
Buggy code:
n = int(input())
ans = float('inf')
temp = 0
for i in range(1,n+1):
    if n%i == 0:
        temp = max(len(str(i)), len(str(n//i)))
        ans = min(temp, ans)
print(ans)

Fixed code:
n = int(input())
ans = float('inf')
temp = 0
for i in range(1,int(n**(1/2))+1):
    if n%i == 0:
        temp = max(i, n//i)
        ans = min(temp, ans)
print(len(str(ans)))
Buggy code:
n = int(input())
ans = float('inf')
temp = 0
for i in range(1,n/2+1):
    if n%i == 0:
        temp = max(len(str(i)), len(str(n//i)))
        ans = min(temp, ans)
print(ans)

Fixed code:
n = int(input())
ans = float('inf')
temp = 0
for i in range(int(n**(1/2)), 0, -1):
    if n%i == 0:
        temp = max(i, n//i)
        ans = min(temp, ans)
print(len(str(ans)))
Buggy code:
n = int(input())

root_n = n**0.5
if (root_n != int(root_n)):
    root_n = int(root_n)+1
else:
    root_n = int(root_n)    

for i in range(root_n, 0, -1):
    if(n%i == 0):
        ans = int(n/i)
        print(i, ans)
        print(max([len(str(i)), len(str(ans))]))
        break

Fixed code:
n = int(input())

root_n = n**0.5
if (root_n != int(root_n)):
    root_n = int(root_n)+1
else:
    root_n = int(root_n)    

for i in range(root_n, 0, -1):
    if(n%i == 0):
        ans = int(n/i)
        print(max([len(str(i)), len(str(ans))]))
        break
Buggy code:
N = int(input())

def divisor(N):
    '''
    create divisor_list < sqrt(N) from natural number
    '''
    divisor_list = []
    
    for num in range(1, math.ceil(math.sqrt(N)) + 1):
        if N % num == 0:
            divisor_list.append(num)
    
    return divisor_list
    
def F(A, B):
    return max(len(str(A)), len(str(B)))
  
def minimumF(N):
    factoring_list = divisor(N)
    
    candidate_list = []
    
    for A in factoring_list:
        B = N // A
        candidate_list.append(F(A, B))
        
    return min(candidate_list)
  
print(minimumF(N))

Fixed code:
import math

N = int(input())
 
def divisor(N):
    '''
    create divisor_list < sqrt(N) from natural number
    '''
    divisor_list = []
    
    for num in range(1, math.ceil(math.sqrt(N)) + 1):
        if N % num == 0:
            divisor_list.append(num)
    
    return divisor_list
    
def F(A, B):
    return max(len(str(A)), len(str(B)))
  
def minimumF(N):
    factoring_list = divisor(N)
    
    candidate_list = []
    
    for A in factoring_list:
        B = N // A
        candidate_list.append(F(A, B))
        
    return min(candidate_list)
  
print(minimumF(N))
Buggy code:
def f(a, b):
    return max(len(str(a)), len(str(b)))

n = int(input())

ans = 11
for a in range(1, int(n ** 0.5) + 1):
    b = n / a
    if f(a, b) < ans and n % a == 0:
        ans = f(a, b)

print(ans)

Fixed code:
def f(a, b):
    return max(len(str(a)), len(str(b)))

n = int(input())

ans = 11
for a in range(1, int(n ** 0.5) + 1):
    b = n // a 
    if n % a == 0 and f(a, b) < ans:
        ans = f(a, b)

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

Fixed code:
n=int(input())
ans=10000000000000000
for i in range(1,int(n**0.5+1)):
    if n%i==0:ans=min(ans,len(str(n//i)))
print(ans)
Buggy code:
n = int(input())

def f(a, b):
    x = max(a, b)
    return len(str(x))

results = []

for i in range(1, n + 1):
    if n % i == 0:
        a = i
        b = n / i
    result = f(a, b)
    results.append(result)

print(min(results))

Fixed code:
n = int(input())

def f(a, b):
    x = int(max(a, b))
    return len(str(x))

results = []

for i in range(1, int(n ** (1/2)) + 1):
    if n % i == 0:
        a = i
        b = n / i
    result = f(a, b)
    results.append(result)

print(min(results))
Buggy code:
from math import sqrt, ceil

def check(n):
    minf = len(str(n))
    square = ceil(sqrt(n)) # 10^5
    print(square)
    for a in range(1, square+1):
        b, r = divmod(n, a)
        if r == 0:
            f = max(len(str(a)), len(str(b)))
            minf = min(f, minf)
    return minf

#print(check(10**10))
N = int(input())
print(check(N))


Fixed code:
from math import sqrt, ceil

def check(n):
    minf = len(str(n))
    square = ceil(sqrt(n)) # 10^5
    for a in range(1, square+1):
        b, r = divmod(n, a)
        if r == 0:
            f = max(len(str(a)), len(str(b)))
            minf = min(f, minf)
    return minf

#print(check(10**10))
N = int(input())
print(check(N))
Buggy code:
n = int(input())
a = 0
t = 0
for i in range(1, n+1):
    a = n / i
    if(n % i == 0):
        t = i
    if(a <= i):
        break

b = max(int(n / t), t)
ans = 0
while(b > 1):
    ans += 1
    b /= 10
print(ans)



Fixed code:
n = int(input())
a = 0
t = 0
for i in range(1, n+1):
    a = n / i
    if(n % i == 0):
        t = i
    if(a <= i):
        break

b = max(int(n / t), t)
ans = 0
while(b >= 1):
    ans += 1
    b /= 10
print(ans)
Buggy code:
# -*- coding: utf-8 -*-
import math

if __name__ == '__main__':
    N = int(input())
    val = N
    li = []
    for i in range(1, math.ceil(math.sqrt(N))+1):
        if N % i == 0:
            a = len(str(int(i)))
            b = len(str(int(N/i)))
            print(a, b)
            c = max(a, b)

            if c < val:
                val = c

    print(val)


Fixed code:
# -*- coding: utf-8 -*-
import math

if __name__ == '__main__':
    N = int(input())
    val = len(str(N))
    li = []
    for i in range(1, math.ceil(math.sqrt(N))+1):
        if N % i == 0:
            a = len(str(int(i)))
            b = len(str(int(N/i)))
            c = max(a, b)

            if c < val:
                val = c

    print(val)
Buggy code:
import math

def F(A,B):
    if A > B:
        return len(str(A))
    else:
        return len(str(B))
            

N = int(input())
min = F(1,N)
rt = int(math.sqrt(N))
for i in range(2,rt):
    if N % i != 0:
        continue
    f = F(i,int(N/i))
    if f < min:
        min = f
        break
print(min)

Fixed code:
import math

def F(A,B):
    if A > B:
        return len(str(A))
    else:
        return len(str(B))
            

N = int(input())
min = F(1,N)
rt = int(math.sqrt(N))
for i in range(2,rt+1):
    if N % i != 0:
        continue
    f = F(i,int(N/i))
    if f < min:
        min = f
print(min)
Buggy code:
N = int(input())

F = len(str(N))
for A in range(1, int(N**0.5)+1):
    if N%A != 0:
        continue
    B = N // A
    F = min(F, max([len(str(x)) for x in [A,B]]))
    print(F,A,B)

print(F)

Fixed code:
N = int(input())

F = len(str(N))
for A in range(1, int(N**0.5)+1):
    if N%A != 0:
        continue
    B = N // A
    F = min(F, max([len(str(x)) for x in [A,B]]))

print(F)
Buggy code:
import math

N = int(input())

def f(a,b):
    if len(str(a)) < len(str(b)):
        return len(str(b))
    else:
        return len(str(a))

ans = 100000000000
for i in range(1,math.sqrt(N)+1):
    if N % i == 0:
        ans = min(ans,f(i,N//i))
print(ans)
        
        

Fixed code:
import math

N = int(input())

def f(a,b):
    if len(str(a)) < len(str(b)):
        return len(str(b))
    else:
        return len(str(a))

ans = 100000000000
for i in range(1,int(math.sqrt(N)+1)):
    if N % i == 0:
        ans = min(ans,f(i,N//i))
print(ans)
Buggy code:
f = lambda x, y: len(str(max(x, y)))

if __name__ == '__main__':
    n = int(input())
    a = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            a.append((i, n // i))
            if i != n // i:
                a.append((n//i, n // (n // i)))
    k = [f(e[0], e[1]) for e in a]
    print(max(set(k)))

Fixed code:

f = lambda x, y: len(str(max(x, y)))

if __name__ == '__main__':
    n = int(input())
    a = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            a.append((i, n // i))
            if i != n // i:
                a.append((n//i, n // (n // i)))
    k = [f(e[0], e[1]) for e in a]
    print(min(set(k)))
Buggy code:
import math
def keta(n):
    r = 1
    _n = n
    while _n != 0 :
        _n = _n // 10
        if _n > 0:
            r +=1
    return r
n = int(input())
r = keta(n)
for a in range(1, int(math.sqrt(n))):
    b = n / a
    if n % a == 0:
        print(b)
        r = min(r, max(keta(a), keta(b)))
    else:
        continue
print(r)

Fixed code:
import math
def keta(n):
    r = 1
    _n = n
    while _n != 0 :
        _n = _n // 10
        if _n > 0:
            r +=1
    return r
n = int(input())
r = keta(n)
for a in range(1, int(math.sqrt(n))+1):
    b = n / a
    if n % a == 0:
        r = min(r, max(keta(a), keta(b)))
print(r)
Buggy code:
N = int(input())
ans = float("inf")
a = 1
b = 1

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

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

Fixed code:
N = int(input())
ans = float("inf")
a = 1
b = 1

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

for i in range(1, int(N**0.5)+1):
    a = i
    b = N//i
    if N%i==0:
        ans = min(ans, F(a,b))
print(ans)
Buggy code:
import numpy as np

N = int(input())

ans = 1e+99
for a in range(1,N+1):
  if N % a == 0:
    b = N // a
  else:
    continue
  d_a = 1 + int(np.log10(a))
  d_b = 1 + int(np.log10(b))
  F = max(d_a, d_b)
  if F < ans:
    ans = F
print(ans)

Fixed code:
import numpy as np
import math 

N = int(input())

ans = 1e+99
for a in range(1,math.floor(np.sqrt(N))+1):
  if N % a == 0:
    b = N // a
  else:
    continue
  d_a = 1 + int(np.log10(a))
  d_b = 1 + int(np.log10(b))
  F = max(d_a, d_b)
  if F < ans:
    ans = F
print(ans)
Buggy code:
from math import sqrt
N = int(input())
ans = [1]
for i in range(1, int(sqrt(N))):
    if i * (N // i) == N:
        ans.append(max(len(str(i)), len(str(N // i))))
        
print(min(ans))

Fixed code:
from math import sqrt
N = int(input())
ans = []
for i in range(1, int(sqrt(N)) + 1):
    if i * (N // i) == N:
        ans.append(max(len(str(i)), len(str(N // i))))
print(min(ans))
Buggy code:
import math
N=int( input())
for r in range (int(math.sqrt(N)),N):
  if N%r==0:
    count=1
    for i in range (0,9):
      r=r/10
      if r<1:
        print(count)
        break
      count+=1
    break

Fixed code:
import math
N=int( input())
for r in range (int(math.sqrt(N)),0,-1):
  if N%r==0:
    count=1
    l=N/r
    for i in range (0,10):
      l=l/10
      if l<1:
        print(count)
        break
      count+=1
    break