Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class UF:
    def __init__(self, N):
        self.state = [-1] * N
        self.rank = [0] * N
        self.num_group = N
    
    def get_parent(self, a):
        p = self.state[a]
        if p < 0:
            return a
        
        q = self.get_parent(p)
        self.state[a] = q
        return q

    def make_pair(self, a, b):
        pa = self.get_parent(a)
        pb = self.get_parent(b)
        if pa == pb:
            return

        if self.rank[pa] > self.rank[pb]:
            pa, pb = pb, pa
            a, b = b, a
        elif self.rank[pa] == self.rank[pb]:
            self.rank[pb] += 1

        self.state[pb] += self.state[pa]
        self.state[pa] = pb
        self.state[a] = pb
        self.num_group -= 1
    
    def is_pair(self, a, b):
        return self.get_parent(a) == self.get_parent(b)

    def get_size(self, a):
        return -self.state[self.get_parent(a)]

N, M = read_values()
A = read_list()
uf = UF(N)
for _ in range(M):
    i, j = read_index()
    uf.make_pair(A[i] - 1, A[j] - 1)

res = 0
for i, a in enumerate(A):
    if uf.is_pair(i, A[i] - 1)

print(res)

Fixed submission:
def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class UF:
    def __init__(self, N):
        self.state = [-1] * N
        self.rank = [0] * N
        self.num_group = N
    
    def get_parent(self, a):
        p = self.state[a]
        if p < 0:
            return a
        
        q = self.get_parent(p)
        self.state[a] = q
        return q

    def make_pair(self, a, b):
        pa = self.get_parent(a)
        pb = self.get_parent(b)
        if pa == pb:
            return

        if self.rank[pa] > self.rank[pb]:
            pa, pb = pb, pa
            a, b = b, a
        elif self.rank[pa] == self.rank[pb]:
            self.rank[pb] += 1

        self.state[pb] += self.state[pa]
        self.state[pa] = pb
        self.state[a] = pb
        self.num_group -= 1
    
    def is_pair(self, a, b):
        return self.get_parent(a) == self.get_parent(b)

    def get_size(self, a):
        return -self.state[self.get_parent(a)]


N, M = read_values()
A = read_list()
uf = UF(N)
for _ in range(M):
    i, j = read_index()
    uf.make_pair(A[i] - 1, A[j] - 1)

res = 0
for i, a in enumerate(A):
    if uf.is_pair(i, A[i] - 1):
        res += 1

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

sums = [[None for j in range(N-i)] for i in range(N)]

for i in range(N):
    for j in range(N-i):
        if j == 0:
            sums[i][j] = A[i]
        else:
            sums[i][j] = sums[i][j-1] + A[j+i]

count = 0
for line in sums:
    count += line.count(0)
    
print(count)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
sums_dic = {}
a = sum(A)
sums_dic[a] = 1

for n in range(1,N):
    a -= A[n-1]
    sums_dic[a] = sums_dic.setdefault(a, 0) + 1 

count = 0
for key, value in sums_dic.items():
    if key == 0:
        count += value
    
    if value >= 2:
        count += value * (value - 1) // 2
    
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, C = list(map(int, input().split()))
X = np.zeros(N + 2, dtype = int)
V = np.zeros(N + 1, dtype = int)
sumVClockwiwse = np.zeros(N + 1, dtype = int)
#sumVAntiClockwiwse = np.zeros(N + 1, dtype = int)
X[N+1] = C

for n in range(1, N + 1):
    X[n], V[n] = list(map(int, input().split()))
    sumVClockwiwse[n] = sumVClockwiwse[n-1] + V[n]

sumVAntiClockwiwse = sumVClockwiwse[N] - sumVClockwiwse[::-1]

max = 0
for nA in range(N + 1):
    for nB in range(N - nA + 1):
        value = sumVClockwiwse[nA] + sumVAntiClockwiwse[nB]
        if max >= value:
            continue

        cost = min(X[nA] * 2 + (C - X[N - nB + 1]), X[nA] + (C - X[N - nB + 1]) * 2)
        value -= cost 
        if max >= value:
            continue
        # print(nA, nB, ":", cost)
        
        max = value


print(max)

Fixed submission:
import sys
from collections import deque
from functools import lru_cache
import bisect
import copy
import heapq
import itertools
import math
import random
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, C = read_values()
    D = read_lists(N)
    A = [0] * (N + 1)
    A2 = [0] * (N + 1)
    V = 0
    res = 0
    for i, (X, v) in enumerate(D):
        V += v
        A[i + 1] = max(A[i], V - X)
        A2[i + 1] = max(A2[i], V - 2 * X)
        res = max(res, A[i + 1], A2[i + 1])

    V = 0
    for b in range(N - 1, -1, -1):
        x, v = D[b]
        X = C - x
        V += v
        res = max(res, V - 2 * X + A[b], V - X + A2[b])

    print(res)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = list(map(int, input().split()))
if K >= (B - A + 1) / 2 :
    l = [n for n in range(A, B+1)]
else:
    l1 = {n for n in range(A, A + K)}
    l2 = {n for n in range(B - K + 1, B + 1)}
    l = sorted(list((l1 | l2) & {n for n in range(A, B+1)}))
for s in l:
    print(s)

Fixed submission:
A, B, K = list(map(int, input().split()))
if K >= (B - A + 1) / 2 :
    for n in range(A, B+1):
        print(n)
else:
    for n in range(A, A + K):
        print(n)
    for n in range(B - K + 1, B + 1):
        print(n)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = list(map(int, input().split()))
l1 = {n for n in range(A, A + K)}
l2 = {n for n in range(B - K + 1, B + 1)}
l = sorted(list((l1 | l2) & {n for n in range(A, B+1)}))
for s in l:
    print(s)

Fixed submission:
A, B, K = list(map(int, input().split()))
if K >= (B - A + 1) / 2 :
    for n in range(A, B+1):
        print(n)
else:
    for n in range(A, A + K):
        print(n)
    for n in range(B - K + 1, B + 1):
        print(n)
Buggy python submission (verdict: Time Limit Exceeded):
H, W, D = map(int, input().split())
position = {}

for h in range(H):
    L = list(map(int, input().split()))
    for w in range(W):
        position[L[w] - 1] = (h, w)

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    if L == R:
        print(0)
        continue
    
    res = 0
    for i in range(L-1, R - 1, D):
        A = position[i + D]
        B = position[i]
        res += abs(A[0] - B[0]) + abs(A[1] - B[1])
        
    print(res)


Fixed submission:
H, W, D = map(int, input().split())
position = {}

for h in range(H):
    L = list(map(int, input().split()))
    for w in range(W):
        position[L[w] - 1] = (h, w)

cost = [0] * (H * W)
for r in range(D):
    for j in range(r + D, H *W, D):
        A = position[j]
        B = position[j - D]
        cost[j] = cost[j - D] + abs(A[0] - B[0]) + abs(A[1] - B[1])

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    print(cost[R - 1] - cost[L - 1])
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import heapq
import sys
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())

    left = 0
    right = N - 1
    D = {}
    for _ in range(21):
        if left not in D:
            print(left)
            sys.stdout.flush()
            res = input()
            if res == "Vacant":
                return

            D[left] = 0 if res == "Male" else 1

        if right not in D:
            print(right)
            sys.stdout.flush()
            res = input()
            if res == "Vacant":
                return

            D[right] = 0 if res == "Male" else 1

        LD = D[left]
        RD = D[right]

        m = (left + right) // 2

        if m not in D:
            print(m)
            sys.stdout.flush()
            res = input()
            if res == "Vacant":
                return

            D[m] = 0 if res == "Male" else 1

        MD = D[m]

        if (m % 2 == left % 2 and MD == LD) or (m % 2 != left % 2 and MD != LD):
            left = m
        else:
            right = m


if __name__ == "__main__":
    main()


Fixed submission:
import bisect
import heapq
import sys
import queue


input = sys.stdin.readline
sys.setrecursionlimit(100000)


class V:
    def __init__(self, f):
        self.f = f
        self.v = None

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n)

    def get(self):
        return self.v


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    N = int(input())

    left = 0
    right = N - 1
    D = {}
    c = 0
    for _ in range(21):
        if left not in D:
            print(left)
            sys.stdout.flush()
            res = input()
            c += 1
            if res == "Vacant" or c >= 20:
                return

            D[left] = res

        LD = D[left]
        m = (left + right) // 2

        if m not in D:
            print(m)
            sys.stdout.flush()
            res = input()
            c += 1
            if res == "Vacant" and c >= 20:
                return

            D[m] = res

        MD = D[m]

        if (m % 2 == left % 2 and MD == LD) or (m % 2 != left % 2 and MD != LD):
            left = m if left != m else m + 1
        else:
            right = m


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!
import numpy as np

N, H = list(map(int, input().split()))
S = np.array([list(map(int, input().split())) for n in range(N)])
A = [[n, a] for n, a in enumerate(S[:, 0]) if max(S[:,0]) == a]
B = [n for n, b in enumerate(S[:, 1]) if b > A[0][1]]
sumB = sum(S[b,1] for b in B)
res = H - sumB

#print(S)
#print(A)
#print(B)
#print(sumB)
#print(res)

if res > 0:
    print((res-1)//A[0][1] + 1 + len(B))
else:
    L = sorted(S[B, 1])
    L.reverse()
    #print(L)
    p, q = 0, (len(L) - 1)
    while p != q:
        r = (p + q)//2
        #print(p, q, r)
        #print(L[:r + 1])
        if sum(L[:r + 1]) < H:
            p = r + 1
        else:
            q = r

    print(p + 1)
    
    #print(len(B))

Fixed submission:
def main():
    N, H = map(int, input().split())

    A = [-1] * N
    B = [-1] * N
    for n in range(N):
        a, b = map(int, input().split())
        A[n] = a
        B[n] = b
    
    B.sort(reverse=True)
    max_A = max(A)
    
    count = 0
    for b in B:
        if max_A < b:
            H -= b
            count += 1
            if H <= 0:
                return count
        else:
            break
    return (H - 1) // max_A + 1 + count

print(main())
Buggy python submission (verdict: Runtime Error):
import math
X, Y = map(int, input().split())
r = 0
while X < Y:
  Y //= X
  r += 1
print(int(math.log2(r)) + 1)

Fixed submission:
import math
X, Y = map(int, input().split())
r = 0
R = Y // X
while R >= 2:
  R //= 2
  r += 1
print(r + 1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

Bcon = [0] * N
res = 0
p = 0
for n in range(N):
    while p <= N - 1 and B[n] > A[p]:
        p += 1
    Bcon[n] = p

p = 0
for n in range(N):
    while p <= N - 1 and C[n] > B[p]:
        p += 1
    res += sum(Bcon[:p])
    
print(res)

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

Bcon = [0] * (N + 1)
res = 0
p = 0
for n in range(N):
    while p <= N - 1 and B[n] > A[p]:
        p += 1
    Bcon[n + 1] = p + Bcon[n]
    
p = 0
for n in range(N):
    while p <= N - 1 and C[n] > B[p]:
        p += 1
    res += Bcon[p]
    
print(res)

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

Bcon = [sum([1 for i in A if i < B[j]]) for j in range(N)]
Ccon = [sum([Bcon[n] for n, i in enumerate(B) if i < C[j]]) for j in range(N)]

print(sum(Ccon))

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

Bcon = [0] * (N + 1)
res = 0
p = 0
for n in range(N):
    while p <= N - 1 and B[n] > A[p]:
        p += 1
    Bcon[n + 1] = p + Bcon[n]
    
p = 0
for n in range(N):
    while p <= N - 1 and C[n] > B[p]:
        p += 1
    res += Bcon[p]
    
print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
res = 0
for _ in range(N)
    r, l = map(int, input().split())
    res += l - r + 1
print(res)


Fixed submission:
N = int(input())
res = 0
for _ in range(N):
    r, l = map(int, input().split())
    res += l - r + 1
print(res)

Buggy python submission (verdict: Runtime Error):
N = int(input())
res = 0
for _ in range(N)
	r, l = map(int, input().split())
  	res += l - r + 1
print(res)

Fixed submission:
N = int(input())
res = 0
for _ in range(N):
    r, l = map(int, input().split())
    res += l - r + 1
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, M, _ = map(int, input().split())
R = list(map(int, input().split()))
E = [[10 ** 8 for _ in range(N)] for __ in range(N)]
for _ in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    E[A][B] = C
    E[B][A] = C

for v in range(N):
    for d in range(N):
        for w in range(N):
            E[v][w] = min(E[v][w], E[v][d] + E[d][w])

res = 10 ** 8
for case in itertools.permutations(range(len(R))):
    tmp = 0
    p = None
    for v in case:
        v -= 1
        if p is None:
            p = v
            continue
        tmp += E[p][v]
        p = v
    res = min(res, tmp)

print(res)

Fixed submission:
import itertools

N, M, r = map(int, input().split())
R = list(map(int, input().split()))
E = [[10 ** 20 if i != j else 0 for i in range(N)] for j in range(N)]
for _ in range(M):
    A, B, C = map(int, input().split())
    A -= 1
    B -= 1
    E[A][B] = C
    E[B][A] = C

for d in range(N):
    for v in range(N):
        for w in range(N):
            E[v][w] = min(E[v][w], E[w][v], E[v][d] + E[d][w])
            E[w][v] = E[v][w]

res = 10 ** 20
for case in itertools.permutations(R):
    tmp = 0
    c = list(case)
    for i in range(r - 1):
        tmp += E[c[i] - 1][c[i + 1] - 1]
    res = min(res, tmp)

print(res)
Buggy python submission (verdict: Runtime Error):
def l(a, b):
  if a > b:
    a, b = b, a
  return l(a, b % a) if b % a else a

def g(a, b):
  return a * b // l(a, b)

N = int(input())
res = 1
for n in range(N):
  res = g(res, int(input())

print(res)

Fixed submission:
def l(a, b):
  if a > b:
    a, b = b, a
  return l(a, b % a) if b % a else a

def g(a, b):
  return a * b // l(a, b)

N = int(input())
res = 1
for n in range(N):
  res = g(res, int(input()))

print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import queue

N = int(input())
E = {n: set() for n in range(N)}

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    E[a].add((b, c))
    E[b].add((a, c))

Q, K = map(int, input().split())
K -= 1
dist = [-1] * N
already = set()
que = queue.Queue()
que.put((K, 0))
while not que.empty():
    now, d = que.get()
    already.add(now)
    dist[now] = d
    out = E[now]
    for n, c in out:
        if n in already:
            continue
        que.put((n, d + c))

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(dist[x] + dist[y])


Fixed submission:
import queue

N = int(input())
E = {n: set() for n in range(N)}

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    E[a].add((b, c))
    E[b].add((a, c))

Q, K = map(int, input().split())
K -= 1
dist = [-1] * N
already = set()
que = queue.Queue()
que.put((K, 0))
while not que.empty():
    now, d = que.get()
    already.add(now)
    dist[now] = d
    out = E[now]
    for n, c in out:
        if n in already:
            continue
        que.put((n, d + c))

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(dist[x] + dist[y])

Buggy python submission (verdict: Time Limit Exceeded):
import queue

N = int(input())
E = {n: set() for n in range(N)}
C = {}

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    E[a].add(b)
    E[b].add(a)
    C[(min(a, b), max(a, b))] = c 

Q, K = map(int, input().split())
K -= 1
dist = [-1] * N
already = set()
que = queue.Queue()
que.put((K, 0))
while not que.empty():
    now, c = que.get()
    already.add(now)
    dist[now] = c
    out = E[now]
    for n in out:
        if n in already:
            continue
        que.put((n, c + C[min(now, n), max(now, n)]))

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(dist[x] + dist[y])


Fixed submission:
import queue

N = int(input())
E = {n: set() for n in range(N)}

for _ in range(N - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    E[a].add((b, c))
    E[b].add((a, c))

Q, K = map(int, input().split())
K -= 1
dist = [-1] * N
already = set()
que = queue.Queue()
que.put((K, 0))
while not que.empty():
    now, d = que.get()
    already.add(now)
    dist[now] = d
    out = E[now]
    for n, c in out:
        if n in already:
            continue
        que.put((n, d + c))

for _ in range(Q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(dist[x] + dist[y])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
mod = 10 ** 9 + 7
K = max(N, M)
kaijo = [1] * (K + 1) 

for i in range(K):
    kaijo[i + 1] = ((i + 1) * kaijo[i]) % mod
    
if abs(N - M) > 1:
    print(0)
    
else:
    res = 1
    res *= kaijo[N] * kaijo[M]
    if N == M:
        res *= 2
    
print(res % mod)

Fixed submission:
N, M = map(int, input().split())
mod = 10 ** 9 + 7
K = max(N, M)
kaijo = [1] * (K + 1) 

for i in range(K):
    kaijo[i + 1] = ((i + 1) * kaijo[i]) % mod
    
if abs(N - M) > 1:
    print(0)
    
else:
    res = 1
    res *= kaijo[N] * kaijo[M]
    if N == M:
        res *= 2
    
    print(res % mod)
Buggy python submission (verdict: Runtime Error):
H, W = list(map(int,input().split()))


blank = ["#" for i in range(W + 2)]
print("".join(blank))
for line in range(H):
    print("#" + input() + "#")
print("".join(blank))


Fixed submission:
lis = [[1,3,5,7,8,10,12],[4,6,9,11],[2]]
x, y = list(map(int,input().split()))

for i in lis:
    if x in i:
        if y in i:
            print("Yes")
        else:
            print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))

S1 , S2 = {}, {}
for i in range(N):
    S1[a[i]] = S1.get(a[i], 0) + 1

for i in range(2 * N, 3* N):
    S2[a[i]] = S2.get(a[i], 0) + 1

i = N
j = 2 * N - 1

minS1 = min(S1)
maxS2 = max(S2)

while i <= j:
    delS1 = a[i] - minS1
    delS2 = maxS2 - a[j]

    if delS1 >= 0 and delS1 >= delS2:
        #print("chang S1")
        val = S1.pop(minS1)
        if val >= 2:
            S1[minS1] = val - 1
        S1[a[i]] = S1.get(a[i], 0) + 1
        minS1 = min(S1)
        i += 1

    elif delS2 >= 0:
        val = S2.pop(maxS2)
        if val >= 2:
            S2[minS2] = val - 1
        S2[a[j]] = S2.get(a[j], 0) + 1
        maxS2 = max(S2)
        j -= 1

    else:
        i += 1

sumS1, sumS2 = 0, 0
for i in S1.items():
    sumS1 += i[0] * i[1]
for j in S2.items():
    sumS2 += j[0] * j[1]

print(sumS1 - sumS2)



Fixed submission:
from heapq import *

N = int(input())
a = list(map(int,input().split()))

sumS1 = [0 for i in range(N + 1)]
S1 = a[0:N]
heapify(S1)
sumS1[0] = sum(S1)

for k in range(1, N + 1):
    if S1[0] < a[N + k - 1]:
        sumS1[k] = sumS1[k - 1] +a[N + k - 1] - S1[0]
        heapreplace(S1, a[N + k - 1])
    else:
        sumS1[k] = sumS1[k - 1]

sumS2 = [0 for i in range(N + 1)]
S2 =  [-1 * i for i in a[2 * N:3 * N]]
heapify(S2)
sumS2[N] = sum(S2)

for k in range(1, N + 1):
    if S2[0] < -1 * a[2 * N - k]:
        sumS2[N - k] = sumS2[N - k + 1] - a[2 * N - k] - S2[0]
        heapreplace(S2, -1 * a[2 * N - k])
    else:
        sumS2[N - k] = sumS2[N - k + 1]


res = [float("-inf")] * (N + 1)
for i in range(N + 1):
    res[i] = sumS1[i] + sumS2[i]

res.sort()
print(res[N])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


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


if __name__ == "__main__":
    main()


Fixed submission:
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


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


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


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


if __name__ == "__main__":
    main()


Fixed submission:
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


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


if __name__ == "__main__":
    main()