Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N, M = map(int, input().split())

prime = defaultdict(int)
m = M
for i in range(2, M + 1):
    while m % i == 0 and m > 1:
        prime[i] += 1
        m //= i

MOD = 10 ** 9 + 7

def comb(n, k):
    a = 1
    for i in range(1, k + 1):
        a *= n - i + 1
        a %= MOD
        
        a *= pow(i, MOD - 2, MOD)
        a %= MOD
        
    return a

ans = 1
for _, t in prime.items():
    ans *= comb(N - 1 + t, t)
    ans %= MOD
    
print(ans)



Fixed submission:
from collections import defaultdict

N, M = map(int, input().split())

prime = defaultdict(int)
m = M
for i in range(2, 10 ** 5):
    while m % i == 0 and m > 1:
        prime[i] += 1
        m //= i

if m > 1:
    prime[10 ** 9] = 1
MOD = 10 ** 9 + 7

def comb(n, k):
    a = 1
    for i in range(1, k + 1):
        a *= n - i + 1
        a %= MOD
        
        a *= pow(i, MOD - 2, MOD)
        a %= MOD
        
    return a

ans = 1
for _, t in prime.items():
    ans *= comb(N - 1 + t, t)
    ans %= MOD
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N, *X = map(int, open(0).read().split())
X.sort()
y = []
for i in range(N):
  y.append(X[i + 1] - X[i])

ans = y[0]
for v in y[1:]:
  ans = gcd(ans, v)
print(ans)

Fixed submission:
from fractions import gcd
N, *X = map(int, open(0).read().split())
X.sort()
y = [X[i + 1] - X[i] for i in range(N)]

ans = y[0]
for v in y[1:]:
  ans = gcd(ans, v)
print(ans)
Buggy python submission (verdict: Runtime Error):

H, W = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(H)]
ans = []


def dfs(u, v):
    for i, j in [(0, 1), (0, -1), (1, 0), (-1, 0)]:
        if 0 <= u + i < H and 0 <= v + j < W and X[u + i][v + j] > 0:
            ans.append((u + 1, v + 1, u + i + 1, v + j + 1))
            X[u + i][v + j] += X[u][v]
            X[u][v] = 0
            dfs(u + i, v + j)


for u in range(H):
    for v in range(W):
        if X[u][v] > 0:
            dfs(u, v)

for t in ans:
    print(*t)


Fixed submission:
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

ans = []
idx_list = [(i, j) if i % 2 == 0 else (i, W - j - 1) 
            for i in range(H) for j in range(W)]
        
for i, (x, y) in enumerate(idx_list[:-1]):
    if A[x][y] % 2 == 1:
        A[idx_list[i + 1][0]][idx_list[i + 1][1]] += 1
        ans.append([x, y, idx_list[i + 1][0], idx_list[i + 1][1]])
        
print(len(ans))
for v in ans:
    print(*[c + 1 for c in v])
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N, K = map(int, input().split())
x = list(product(range(1, N + 1), repeat=3))
ans = 0
for q in x:
    w = [q[0] + q[1], q[0] + q[2], q[1] + q[2]]
    if all(list(map(lambda x: x % K == 0, w))):
        ans += 1
print(ans)

Fixed submission:
N, K = map(int, input().split())
if K % 2 == 1:
    print(sum(1 for n in range(1, N + 1) if n % K == 0) ** 3)
else:
    print(sum(1 for n in range(1, N + 1) if n % K == 0) ** 3 + sum(1 for n in range(1, N + 1) if n % K == K // 2) ** 3)
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
print(S[:K].replace('1', '')[0] or '1')

Fixed submission:
S = input()
K = int(input())
while S[0] == '1' and len(S) > 1 and K > 1:
    S = S[1:]
    K -= 1
print(S[0])

Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[0] == '1' and len(S) > 1:
    while S[0] == '1':
        S = S[1:]
print(S[0])

Fixed submission:
S = input()
K = int(input())
while S[0] == '1' and len(S) > 1 and K > 1:
    S = S[1:]
    K -= 1
print(S[0])
Buggy python submission (verdict: Runtime Error):
D, G = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(D)]

def func(i, t):
    if i == 0 or i > D:
        return 10 ** 9
    
    # Solve all problems, or part of them
    k = min(t // (100 * i), X[i][0])
    s = 100 * i * k
    
    # If all problems are solved, add bonus
    if k == X[i][0]:
        s += X[i][1]
        
    # If score < objective, go next step
    if s < t:
        k += func(i - 1, t - s)
        
    # Select minimum number of solved problems
    # k: solve i-th line
    # func(i-1,t): pass i-th line
    return min(k, func(i - 1, t))

# Solve backward
print(func(D, G))

Fixed submission:
D, G = map(int, input().split())
X = [0] + [list(map(int, input().split())) for _ in range(D)]

def func(i, t):
    if i == 0 or i > D:
        return 10 ** 9
    
    # Solve all problems, or part of them
    k = min(t // (100 * i), X[i][0])
    s = 100 * i * k
    
    # If all problems are solved, add bonus
    if k == X[i][0]:
        s += X[i][1]
        
    # If score < objective, go next step
    if s < t:
        k += func(i - 1, t - s)
        
    # Select minimum number of solved problems
    # k: solve i-th line
    # func(i-1,t): pass i-th line
    return min(k, func(i - 1, t))

# Solve backward
print(func(D, G))
Buggy python submission (verdict: Runtime Error):
ans = []
for l in range(len(s)):
    for r in range(l + 1, K + 1):
        ans.append(s[l:r])
        
print(sorted(set(ans))[K - 1])

Fixed submission:
s = input()
K = int(input())
ans = [s[l:l + r + 1] for l in range(len(s)) for r in range(K)]
print(sorted(set(ans))[K - 1])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
K = int(input())
ans = []
for l in range(len(s)):
    for r in range(l + 1, len(s) + 1):
        ans.append(s[l:r])
        
ans = list(set(ans))
ans.sort()
print(ans[K - 1])

Fixed submission:
s = input()
K = int(input())
ans = [s[l:l + r + 1] for l in range(len(s)) for r in range(K)]
print(sorted(set(ans))[K - 1])
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
s = ['.' + input() +'.' for _ in range(H)]
s = ['.'] * (W + 2) s + ['.'] * (W + 2)
flag = True
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if (s[h][w] == '#' and s[h - 1][w] == '.' and s[h + 1][w] == '.'
               and s[h][w - 1] == '.' and s[h][w + 1] == '.'):
            flag = False
                
print('Yes' if flag else 'No')


Fixed submission:
H, W = map(int, input().split())
s = ['.' + input() +'.' for _ in range(H)]
s = ['.' * (W + 2)] + s + ['.' * (W + 2)]
flag = True
for h in range(1, H + 1):
    for w in range(1, W + 1):
        if (s[h][w] == '#' and (not '#' in [s[h - 1][w], s[h + 1][w], s[h][w - 1], s[h][w + 1]])):
            flag = False
                
print('Yes' if flag else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
N, *A = map(int, open(0).read().split())
A = [0] + A + [0]
diff = [abs(A[i + 1] - A[i]) for i in range(N + 1)]
diff_i = [abs(A[i + 2] - A[i]) for i in range(N)]
for i in range(N):
  print(sum(diff) + diff_i[i] -  (diff[i] + diff[i + 1]))

Fixed submission:
N, *A = map(int, open(0).read().split())
A = [0] + A + [0]
diff = [abs(A[i + 1] - A[i]) for i in range(N + 1)]
diff_i = [abs(A[i + 2] - A[i]) for i in range(N)]
a = sum(diff)
for i in range(N):
  print(a + diff_i[i] -  (diff[i] + diff[i + 1]))

Buggy python submission (verdict: Time Limit Exceeded):
N, *A = map(int, open(0).read().split())
A = [0] + A + [0]
diff = [abs(A[i + 1] - A[i]) for i in range(N + 1)]
for i in range(N):
  print(sum(diff) + abs(A[i + 2] - A[i + 0]) -  (diff[i] + diff[i + 1]))

Fixed submission:
N, *A = map(int, open(0).read().split())
A = [0] + A + [0]
diff = [abs(A[i + 1] - A[i]) for i in range(N + 1)]
diff_i = [abs(A[i + 2] - A[i]) for i in range(N)]
a = sum(diff)
for i in range(N):
  print(a + diff_i[i] -  (diff[i] + diff[i + 1]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
x = sorted([list(map(int, input().split())) for _ in range(N)], reverse=True)
y = sorted([list(map(int, input().split())) for _ in range(N)], reverse=True)

i = 0
j = 0
cnt = 0
while j < N:
    if x[i][0] < y[j][0] and x[i][1] < y[j][1]:
        cnt += 1
        i += 1
        j += 1
        continue
    else:
	    i += 1
    if i >= N:
      i = 0
      j += 1
print(cnt)

Fixed submission:
N = int(input())
x = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: -x[1])
y = sorted([list(map(int, input().split())) for _ in range(N)])

cnt = 0
for c, d in y:
  for a, b in x:
    if a < c and b < d:
      x.remove([a, b])
      cnt += 1
      break

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))

c = Counter(A).most_common()
c.sort(key=lambda x: x[1])
ans = 0
while len(c) > K:
    ans += c.pop(0)[1]
print(ans)

Fixed submission:
from collections import Counter
N, K = map(int, input().split())
A = list(map(int, input().split()))

c = Counter(A).most_common()
c.sort(key=lambda x: -x[1])
ans = 0
while len(c) > K:
    ans += c.pop()[1]
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
ans = ''
if a + b + c + d == 7:
    ans = '{}+{}+{}+{}=7'
elif a - b + c + d == 7:
    ans = '{}-{}+{}+{}=7'
elif a + b - c + d == 7:
    ans = '{}+{}-{}+{}=7'
elif a + b + c - d == 7:
    ans = '{}+{}+{}-{}=7'
elif a - b - c + d == 7:
    ans = '{}-{}-{}+{}=7'
elif a + b - c - d == 7:
    ans = '{}+{}-{}-{}=7'
elif a - b + c - d == 7:
    ans = '{}-{}+{}-{}=7'
elif a - b - c - d == 7:
    ans = '{}-{}-{}-{}=7'
    
print(ans.format(a, b, c, d))

Fixed submission:
a, b, c, d = map(int, input())
ans = ''
if a + b + c + d == 7:
    ans = '{}+{}+{}+{}=7'
elif a - b + c + d == 7:
    ans = '{}-{}+{}+{}=7'
elif a + b - c + d == 7:
    ans = '{}+{}-{}+{}=7'
elif a + b + c - d == 7:
    ans = '{}+{}+{}-{}=7'
elif a - b - c + d == 7:
    ans = '{}-{}-{}+{}=7'
elif a + b - c - d == 7:
    ans = '{}+{}-{}-{}=7'
elif a - b + c - d == 7:
    ans = '{}-{}+{}-{}=7'
elif a - b - c - d == 7:
    ans = '{}-{}-{}-{}=7'
    
print(ans.format(a, b, c, d))
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

cnt = [0] * N
for i in range(N):
    cnt[i] = N - bisect_right(C, B[i])
    
res = 0
for i in range(N):
    idx = bisect_right(B, A[i])
    if idx < N:
        res += sum(cnt[idx:])
print(res)


Fixed submission:
from bisect import bisect_left, bisect_right
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()
print(sum(bisect_left(A, i) * (N - bisect_right(C, i)) for i in B))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

x = sorted(v for v, _ in X)
y = sorted(v for _, v in X)
ans = 10 ** 20
for x1 in x:
    for x2 in x:
        for y1 in y:
            for y2 in y:
                num = 0
                for i in range(N):
                    if x1 <= X[i][0] <= x2 and y1 <= X[i][1] <= y2:
                        num += 1
                if num >= K:
                    ans = min(ans, abs(x1 - x2) * abs(y1 - y2))
                    
print(ans)


Fixed submission:
N, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

x = sorted(v for v, _ in X)
y = sorted(v for _, v in X)
ans = 10 ** 20
for i in range(N - 1):
    for j in range(i + 1, N):
        for k in range(N - 1):
            for l in range(k + 1, N):
                x1 = x[i]
                x2 = x[j]
                y1 = y[k]
                y2 = y[l]
                num = 0
                for n in range(N):
                    if x1 <= X[n][0] <= x2 and y1 <= X[n][1] <= y2:
                        num += 1
                if num >= K:
                    ans = min(ans, (x2 - x1) * (y2 - y1))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

N, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

ans = 10 ** 20
for t in combinations(range(N), K):
    x = []
    y = []
    for i in t:
        x.append(X[i][0])
        y.append(X[i][1])
    ans = min(ans, (max(x) - min(x)) * (max(y) - min(y)))

print(ans)


Fixed submission:
N, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

x = sorted(v for v, _ in X)
y = sorted(v for _, v in X)
ans = 10 ** 20
for i in range(N - 1):
    for j in range(i + 1, N):
        for k in range(N - 1):
            for l in range(k + 1, N):
                x1 = x[i]
                x2 = x[j]
                y1 = y[k]
                y2 = y[l]
                num = 0
                for n in range(N):
                    if x1 <= X[n][0] <= x2 and y1 <= X[n][1] <= y2:
                        num += 1
                if num >= K:
                    ans = min(ans, (x2 - x1) * (y2 - y1))

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N, *a = map(int, open(0).read().split())
c = [y for _, y in sorted(Counter(a).most_common())]
print(max(sum(c[i:i + 3]) for i in range(len(c) - 2)))

Fixed submission:
N, *a = map(int, open(0).read().split())
cnt = [0] * (10 ** 5 + 2)

for v in a:
    cnt[v] += 1
    cnt[v + 1] += 1
    cnt[v + 2] += 1
    
print(max(cnt))
Buggy python submission (verdict: Runtime Error):
N, *X = map(int, open(0).read().split())

ans = 0
for i in range(N - 1):
    if X[i] == i + 1:
        X[i], X[j] = X[j], X[i]
        ans += 1

print(ans)


Fixed submission:
N, *X = map(int, open(0).read().split())

ans = 0
for i in range(N):
    if X[i] == i + 1:
        if i < N - 1:
            X[i], X[i + 1] = X[i + 1], X[i]
        else:
            X[i - 1], X[i] = X[i], X[i - 1]
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
N = 5
x = list(range(5))
for i in range(min(N - 1, K)):
    for j in range(N):
        if j == i:
            x[j] += N
        else:
            x[j] -= 1
            
print(N)
print(*x)

Fixed submission:
K = int(input())

N = 50
x = [v + K // N for v in range(N)]
for i in range(K % N):
    for j in range(N):
        if j == i:
            x[j] += N
        else:
            x[j] -= 1
            
print(N)
print(*x)
Buggy python submission (verdict: Time Limit Exceeded):
N, *a = map(int, open(0).read().split())
print(min(abs(sum(a[:i]) - sum(a[i:])) for i in range(1, N)))

Fixed submission:
from itertools import accumulate
N, *a = map(int, open(0).read().split())
x = list(accumulate(a[:-1]))
y = list(accumulate(a[:0:-1]))[::-1]
print(min(abs(i - j) for i, j in zip(x, y)))
Buggy python submission (verdict: Time Limit Exceeded):
N, *a = map(int, open(0).read().split())
b = []
for i, v in enumerate(a):
    if i % 2 == 0:
        b.append(v)
    else:
        b.insert(0, v)
        
if N % 2 == 0:
    print(*b)
else:
    print(*b[::-1])

Fixed submission:
N, *a = map(int, open(0).read().split())
b = a[1::2][::-1] + a[::2]
if N % 2 == 0:
    print(*b)
else:
    print(*b[::-1])
Buggy python submission (verdict: Runtime Error):
N, *X = map(int, open(0).read().split())

MAX = 10 ** 5
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k:
        return 0
    return fac[n] * finv[n - k] * finv[k]

# Find indices of duplicated values
indices = [-1] * (N + 1)
for i in range(N + 1):
    if indices[X[i]] < 0:
        indices[X[i]] = i
    else:
        l = indices[X[i]]
        r = i
        break

for k in range(1, N + 2):
    print((comb(N + 1, k) - comb(l + N - r, k - 1)) % MOD)



Fixed submission:
N, *X = map(int, open(0).read().split())

MAX = 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k:
        return 0
    return fac[n] * finv[n - k] * finv[k]

# Find indices of duplicated values
indices = [-1] * (N + 1)
for i in range(N + 1):
    if indices[X[i]] < 0:
        indices[X[i]] = i
    else:
        l = indices[X[i]]
        r = i
        break

for k in range(1, N + 2):
    print((comb(N + 1, k) - comb(l + N - r, k - 1)) % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappop, heappush
N = int(input())
a = list(map(int, input().split()))

pq1 = []
for x in a[:N]:
    heappush(pq1, x)

pq2 = sorted(a[N:])

ans = sum(pq1) - sum(pq2[:N])
for k in range(N, 2 * N):
    heappush(pq1, a[k])
    heappop(pq1)    
    pq2.remove(a[k])
    
    ans = max(ans, sum(pq1) - sum(pq2[:N]))
    
print(ans)


Fixed submission:
from heapq import heappop, heappush, heapify
N = int(input())
a = list(map(int, input().split()))

pq1 = a[:N]
pq2 = [-x for x in a[2 * N:]]

heapify(pq1)
heapify(pq2)

s1 = sum(pq1)
s2 = sum(pq2)

ans1 = [s1]
ans2 = [s2]

for k in range(N, 2 * N):
    heappush(pq1, a[k])
    x = heappop(pq1)
    s1 += a[k] - x
    ans1.append(s1)
    
    heappush(pq2, -a[3 * N - k - 1])
    x = heappop(pq2)
    s2 += -a[3 * N - k - 1] - x
    ans2.append(s2)
    
print(max(ans1[i] + ans2[-i - 1] for i in range(len(ans1))))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

def bellman_ford():
    d = [None] * (N + 1)
    visited = [False] * (N + 1)
    d[1] = 0
    visited[1] = True
    updated = True
    cnt = 0
    
    while updated and (cnt < N):
        updated = False
        cnt += 1
        for u, v, c in edges:
            if (not visited[v]) or (visited[v] and visited[u] and d[v] < d[u] + c):
                d[v] = d[u] + c
                visited[v] = True
                updated = True
                
    return d, cnt

d, cnt = bellman_ford()
print(d[-1] if cnt < N else 'inf')



Fixed submission:
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]

for i in range(M):
    edges[i][2] *= -1

INF = 10 ** 20
d = [INF] * (N + 1)

def bellman_ford():    
    d[1] = 0
    for _ in range(N):
        for u, v, c in edges:
            if (d[u] != INF) and (d[v] > d[u] + c):
                d[v] = d[u] + c

negative = [False] * (N + 1)

def bellman_ford_neg():
    for _ in range(N):
        for u, v, c in edges:
            if (d[u] != INF) and (d[v] > d[u] + c):
                d[v] = d[u] + c
                negative[v] = True
                
            if negative[u]:
                negative[v] = True

bellman_ford()
bellman_ford_neg()

if negative[-1]:
    print('inf')
else:
    print(-d[-1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

ctr = Counter(sum(X, []))
if all(v % 2 == 0 for v in ctr.values()):
    print("YES")
else:
    print("NO")


Fixed submission:
from collections import Counter

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

ctr = Counter()
for a, b in X:
    ctr[a] += 1
    ctr[b] += 1

if all(v % 2 == 0 for v in ctr.values()):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
from math import gcd

A, B, C = map(int, open(0).read().split())

if C % gcd(A, B) == 0:
    print("YES")
else:
    print("NO")


Fixed submission:
from fractions import gcd

A, B, C = map(int, open(0).read().split())

if C % gcd(A, B) == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N, W = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
    for j in range(W + 1):
        if j < X[i][0]:
            dp[i + 1][j] = dp[i][j]
        else:
            dp[i + 1][j] = max(dp[i][j], dp[i][j - X[i][0]] + X[i][1])

print(dp[-1][-1])


Fixed submission:
N, W = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

w0 = X[0][0]
ctr = [[] for _ in range(4)]
for w, v in X:
    ctr[w - w0].append(v)

for n in range(4):
    values = sorted(ctr[n], reverse=True)
    s = [0] * (len(values) + 1)
    for i in range(len(values)):
        s[i + 1] = s[i] + values[i]
    ctr[n] = s

ans = 0
for i in range(len(ctr[0])):
    for j in range(len(ctr[1])):
        for k in range(len(ctr[2])):
            for l in range(len(ctr[3])):
                tmp = ctr[0][i] + ctr[1][j] + ctr[2][k] + ctr[3][l]
                w = w0 * i + (w0 + 1) * j + (w0 + 2) * k + (w0 + 3) * l
                if w <= W:
                    ans = max(ans, tmp)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
v = round(N ** 0.5)
while N % v != 0:
    v += 1
print(len(str(v)))

Fixed submission:
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 python submission (verdict: Runtime Error):
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))

Fixed submission:
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 python submission (verdict: Runtime Error):
from math import sqrt
N = int(input())
ans = []
for i in range(1, int(sqrt(N))):
    if i * (N // i) == N:
        ans.append(max(len(str(i)), len(str(N // i))))
        
print(max(min(ans), 1))

Fixed submission:
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 python submission (verdict: Runtime Error):
from math import sqrt

N = int(input())
ans = []
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 submission:
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 python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
from collections import defaultdict

N, T, *A = map(int, open(0).read().split())

inf = 10 ** 9 + 7
dp = [inf] * (N + 1)
ctr = defaultdict(int)
for i in range(N):
    idx = bisect_left(dp, A[i])
    if idx == 0:
        dp = [inf] * (N + 1)
    dp[idx] = A[i]
    ctr[A[i] - dp[0]] += 1

print(min(T, ctr[max(ctr)]))


Fixed submission:
from bisect import bisect_left
from collections import defaultdict

N, T, *A = map(int, open(0).read().split())

inf = 10 ** 9 + 7
dp = [inf] * (N + 1)
ctr = defaultdict(int)
for i in range(N):
    idx = bisect_left(dp, A[i])
    dp[idx] = A[i]
    if idx != 0:
        ctr[A[i] - dp[0]] += 1

print(ctr[max(ctr)])