Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
# n = II()
# dp = [INF] * n
# h = LI()
# dp[0], dp[1] = 0, abs(h[1] - h[0])
# for i in range(2, n):
    # dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i])
    # dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i])
# P(dp[n-1])


a = IS()
b = IS()
c = IS()
d = IS()
e = IS()
ryo = [a, b, c, d, e]
ryo = sorted(ryo, key=lambda x:x[-1])[::-1]
least = '9'
for i in ryo:
    if int(least) >= int(i[-1]) and int(i[-1]) != 0:
        least = i[-1]
for i in range(len(ryo)):
    if ryo[i][-1] == least:
        number = ryo.pop(i)
        break
for i in range(len(ryo)):
    for j in range(0,140,10):
        if int(ryo[i]) <= j:
            ryo[i] = j
            break
print(sum(ryo) +int(number))


Fixed submission:
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
# n = II()
# dp = [INF] * n
# h = LI()
# dp[0], dp[1] = 0, abs(h[1] - h[0])
# for i in range(2, n):
    # dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i])
    # dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i])
# P(dp[n-1])


a = IS()
b = IS()
c = IS()
d = IS()
e = IS()
ryo = [a, b, c, d, e]
ryo = sorted(ryo, key=lambda x:x[-1])[::-1]
least = '10'
for i in ryo:
    if int(least) >= int(i[-1]) and int(i[-1]) != 0:
        least = i[-1]
if least == '10':
    least = '0'
for i in range(len(ryo)):
    if ryo[i][-1] == least:
        number = ryo.pop(i)
        break
for i in range(len(ryo)):
    for j in range(0,140,10):
        if int(ryo[i]) <= j:
            ryo[i] = j
            break
print(sum(ryo) +int(number))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
for index in lr:
    str = s[index[0]-1:index[1]]
    print(str.count('AC'))


Fixed submission:
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
a = [0] * 100010
count = 0 
for i in range(1,len(s)):
    if s[i] == 'C' and s[i-1] == 'A':
        count += 1
    a[i] = count
# print(a)
for index in lr:
    # print(index)
    print(a[index[1]-1] - a[index[0]-1])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


# 間に合わない
a, b = MI()
binlen = len(bin(b)) - 2
ans = [0] * binlen
for i in range(a, b + 1):
    for j in range(binlen):
        ans[j] += i // (2 ** j)
num = ''
for i in ans:
    num = str(i & 1) + num
print(int(num, 2))


Fixed submission:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


def f(n):
    if n == 0:
        return n
    elif n & 1:  # nが奇数
        return ((n // 2) & 1) ^ (n - 1) ^ n
    else:
        return ((n // 2) & 1) ^ n


a, b = MI()
print(f(a - 1) ^ f(b))
Buggy python submission (verdict: Runtime Error):
n, m=map(int, input().split())
list = [list(map(int, input().split())) for _ in range(m)]
node = [i for i in range(0, n+1)]
ans = [0] * (m+1)
# print(node)
# print(ans)

def root(x):
    # print('ROOT!!')
    if node[x] == x:
        return x
    else:
        node[x] == root(node[x])
        return node[x]


def same(x, y):
    # print('SAME!!')
    return bool(root(x) == root(y))


def unite(x, y):
    # print('UNITE!!')
    x = root(x)
    y = root(y)
    if x == y:
        return
    node[x] = y
    # print('NODE')
    # print(node)


def find(x):
    # print('FIND!!!')
    # print(root(x))
    # print(node.count(root(x)))
    # print('NODE')
    # print(node)
    return node.count(root(x))


ans[0] = n*(n-1)//2


for i, element in enumerate(list[::-1]):
    # print('i,element')
    # if i == 0:
    #    continue
    # print(i, element)
    if same(element[0], element[1]):
        ans[i+1] = ans[i]
    else:
        ans[i+1] = ans[i]-find(element[0])*find(element[1])
        unite(element[0], element[1])
    # print('node')
    # print(node)
    # print('ans')
    # print(ans)
    # print('===============')

# print(ans)
# print(ans[:m:][::-1])
for i in ans[:m:][::-1]:
    print(i)


Fixed submission:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
def same(x, y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:
        return x
    else:
        node[x] = root(node[x])
        return node[x]
def unite(x, y):
    x, y = root(x), root(y)
    if x == y:
        return  # 結合不要
    if size[x] < size[y]:
        x, y = y, x
    node[y] = x
    size[x] += size[y]
def return_size(x):
    return size[root(x)]
    

n, m = MI()
ans = [0] * (m + 1)
bridge = [LI() for _ in range(m)]
# union-find
node = [i for i in range(n)]
size = [1 for i in range(n)]
# 辺を追加していない状態
ans[0] = (n * (n - 1)) // 2
i = 0 
for a, b in bridge[::-1]:
    if same(a - 1, b - 1):  # 辺を追加する以前のもともと連結であった
        ans[i + 1] = ans[i]
    else:
        ans[i + 1] = ans[i] - return_size(a - 1) * return_size(b - 1)
    unite(a - 1, b - 1)
    i += 1
for i in ans[:m][::-1]:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
cities = ([list(map(int, input().split())) for _ in range(m)])
for city in cities:
    pref = str(city[0]).zfill(6)
    same_pref = sorted([i[1] for i in cities if i[0] == city[0]])
    rank = str(same_pref.index(city[1]) + 1).zfill(6)
    print(pref + rank)


Fixed submission:
n, m = map(int, input().split())
# i は 通し番号
cities = sorted(([list(map(int, input().split())) + [i] for i in range(m)]))
pref = cities[0]
counter = 1
for city in cities:
    if pref != city[0]:
        counter = 1
    pref = city[0]
    rank = counter
    number = str(pref).zfill(6) + str(rank).zfill(6)
    city.append(number)
    counter += 1
for i in sorted(cities, key=lambda x: x[2]):
    print(i[3])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
import fractions
from functools import reduce
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


N = II()
a = LI()
# aのすべての数の最小公倍数-1をaの各要素で割った剰余の和
print(sum([(LCM_LIST(a) - 1) % i for i in a]))


Fixed submission:
import time
import sys
import math
import fractions
from functools import reduce
from collections import Counter
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


N = II()
a = LI()
# aのすべての数の最小公倍数-1をaの各要素で割った剰余の和
lcm = LCM_LIST(a)
print(sum([(lcm - 1) % i for i in a]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
change_direction = [0] * n
count = 0 
for i in range(len(s)):
    change_direction[i] = s[:i].count('W') + s[i+1:].count('E')
print(min(change_direction))


Fixed submission:
n = int(input())
s = input()
count = s.count('E')
m = count
for i in s:
    if i == 'E':
        m -= 1
    else:
        m += 1
    count = min(count, m)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
change_direction = []
for i in range(len(s)):
    count = 0
    for j in range(len(s)):
        if j < i and s[j] == 'W':
            count += 1
            continue
        if i < j and s[j] == 'E':
            count += 1
            continue
    change_direction.append(count)
print(min(change_direction))


Fixed submission:
n = int(input())
s = input()
count = s.count('E')
m = count
for i in s:
    if i == 'E':
        m -= 1
    else:
        m += 1
    count = min(count, m)
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
set_a = set(a)
ans=0
while len(set_a) > k:
    i = -1
    c = Counter(a).most_common()[i]  # (出現回数の最も少ない数字,出現回数)
    num = c[0]
    ans += c[1]
    set_a.remove(num)
    for _ in range(c[1]):
        a.remove(num)  # リストの操作回数...
    i-=1
print(ans)


Fixed submission:
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
set_a = set(a)
ans = 0
i = -1
c = Counter(a).most_common() # (出現回数の最も少ない数字,出現回数)
while len(set_a) > k:
    set_a.remove(c[i][0])
    ans += c[i][1]
    i-=1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans = [1] * len(a)
index=0
for i in range(n):
    ans[index] = a.count(a[i]-1)+a.count(a[i])+a.count(a[i]+1)
    index+=1
print(max(ans))



Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
collection = Counter(a)
# print(collection)
ans = [0] * 100010
for i in collection:
    ans[i] = collection[i-1]+collection[i]+collection[i+1]
print(max(ans))

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans = [1] * len(set(a))
index=0
for i in range(n):
    ans[index] = a.count(a[i]-1)+a.count(a[i])+a.count(a[i]+1)
    index+=1
print(max(ans))

Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
collection = Counter(a)
# print(collection)
ans = [0] * 100010
for i in collection:
    ans[i] = collection[i-1]+collection[i]+collection[i+1]
print(max(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=1
for i in range(n):
    tmp = a.count(a[i]-1)+a.count(a[i])+a.count(a[i]+1)
    if ans < tmp:
        ans = tmp
print(ans)




Fixed submission:
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
collection = Counter(a)
# print(collection)
ans = [0] * 100010
for i in collection:
    ans[i] = collection[i-1]+collection[i]+collection[i+1]
print(max(ans))
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())


H, W = MI()
N = II()
a = LI()
color = deque()
ans = [[0] * W for _ in range(H)]
# visited = [[0] * W for _ in range(H)]
x_diff = [-1, 0, 1, 0]
y_diff = [0, 1, 0, -1]

for i, num in enumerate(a):
    for j in range(num):
        color.append(i + 1)

# coordinate_q = deque()
# coordinate_q.append([0, 0])
# visited[0][0] = 1
# ans[0][0] = color.popleft()

"""
while len(coordinate_q) != 0:
    y_tmp, x_tmp = coordinate_q.popleft()
    for i in range(4):
        y, x = y_tmp + y_diff[i], x_tmp + x_diff[i]
        if 0 <= y <= H-1 and 0 <= x <= W-1 and visited[y][x] == 0:
            ans[y][x] = color.popleft()
            visited[y][x] = 1
            coordinate_q.append([y, x])
"""

"""
for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            ans[i][j] = color.popleft()
        else:
            ans[i][-(j+1)] = color.popleft()
"""

def tansaku(y, x):
    if visited[y][x] == 1:
        return
    visited[y][x] = 1
    ans[y][x] = color.popleft()
    for i in range(4):
        ny = y + y_diff[i]
        nx = x + x_diff[i]
        if 0 <= ny <= H-1 and 0 <= nx <= W-1:
            tansaku(ny, nx)

visited = [[0] * W for _ in range(H)]
tansaku(0, 0)

for i in range(H):
    for j in range(W):
        print(ans[i][j], end=' ')
    print('')


Fixed submission:
from collections import deque
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())


H, W = MI()
N = II()
a = LI()
color = deque()
ans = [[0] * W for _ in range(H)]
# visited = [[0] * W for _ in range(H)]
# x_diff = [-1, 0, 1, 0]
# y_diff = [0, 1, 0, -1]

for i, num in enumerate(a):
    for j in range(num):
        color.append(i + 1)

# coordinate_q = deque()
# coordinate_q.append([0, 0])
# visited[0][0] = 1
# ans[0][0] = color.popleft()

"""
while len(coordinate_q) != 0:
    y_tmp, x_tmp = coordinate_q.popleft()
    for i in range(4):
        y, x = y_tmp + y_diff[i], x_tmp + x_diff[i]
        if 0 <= y <= H-1 and 0 <= x <= W-1 and visited[y][x] == 0:
            ans[y][x] = color.popleft()
            visited[y][x] = 1
            coordinate_q.append([y, x])
"""

for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            ans[i][j] = color.popleft()
        else:
            ans[i][-(j+1)] = color.popleft()

for i in range(H):
    for j in range(W):
        print(ans[i][j], end=' ')
    print('')
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import pprint
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v,depth):
    # ノードに訪れた
    visited[v] = 1
    if depth == 2:
        return
    for a, b in sides:
        if v == a-1:
            depth += 1
            dfs(b-1, depth)
            depth -= 1

n, m = MI()
sides = [LI() for _ in range(m)]
visited = [0] * n
dfs(0,0)
print('POSSIBLE') if visited[n-1] == 1 else print('IMPOSSIBLE')


Fixed submission:
from collections import Counter
from functools import reduce
# import statistics
import bisect
import copy
import fractions
import math
import pprint
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers):
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
def unite(x, y):
    # それぞれのノードの根を求める
    x = root(x)
    y = root(y)
    if x == y:
        return
    # node[x]の根をyに変更する
    node[x] = y
def same(x,y): return bool(root(x) == root(y))
def root(x):
    if node[x] == x:  # xが根の場合
        return x
    else:
        node[x] = root(node[x])  # 経路圧縮
        return node[x]
def dfs(v,depth):
    # ノードに訪れた
    visited[v] = 1
    if depth == 2:
        return
    for a, b in sides:
        if v == a-1:
            depth += 1
            dfs(b-1, depth)
            depth -= 1

n, m = MI()
sides = [LI() for _ in range(m)]
islands = [[0] * 2 for _ in range(n)]

for a, b in sides:
    if a-1 == 0:
        islands[b-1][0] = 1
    if b-1 == n-1:
        islands[a-1][1] = 1

for a, b in islands:
    if a == b == 1:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
l = [ i for i in range(1,n+1) if i*i <= n]
for a in l[::-1]:
    if n % a == 0:
        print(max(len(str(a)),len(str(n//a))))
        break


Fixed submission:
import math
n=int(input())
k = math.floor(math.sqrt(n))
for a in range(k+1,0,-1):
    if n % a == 0:
        print(max(len(str(a)),len(str(n//a))))
        break

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans = len(str(n))
l = [ i for i in range(1,n+1) if i*i <= n]
for a in l[::-1]:
    if n % a == 0:
        print( max(len(str(a)),len(str(int(n / a)))))
        break

Fixed submission:
import math
n=int(input())
k = math.floor(math.sqrt(n))
for a in range(k+1,0,-1):
    if n % a == 0:
        print(max(len(str(a)),len(str(n//a))))
        break

Buggy python submission (verdict: Runtime Error):
n=int(input())
ans = len(str(n))
l = [ i for i in range(1,n+1) if i*i < n]
for a in l:
    if n % a == 0 and ans > max(len(str(a)),len(str(int(n / a))))
        ans = max(len(str(a)),len(str(int(n / a))))
print(ans)

Fixed submission:
import math
n=int(input())
k = math.floor(math.sqrt(n))
for a in range(k+1,0,-1):
    if n % a == 0:
        print(max(len(str(a)),len(str(n//a))))
        break

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
ans = len(str(n))
for a in range(1,int(math.sqrt(n)+1)):
    if n % a == 0 and ans > max(len(str(a)),len(str(int(n / a))))
        ans = max(len(str(a)),len(str(int(n / a))))
print(ans)

Fixed submission:
import math
n=int(input())
k = math.floor(math.sqrt(n))
for a in range(k+1,0,-1):
    if n % a == 0:
        print(max(len(str(a)),len(str(n//a))))
        break

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
ans = len(str(n))
# print(int(math.sqrt(n)))
for a in range(1,int(math.sqrt(n)+1)):
    # print(a,n/a,n % a)
    if n % a == 0 and ans > max(len(str(a)),len(str(int(n / a))))
        ans = max(len(str(a)),len(str(int(n / a))))
print(ans)

Fixed submission:
import math
n=int(input())
k = math.floor(math.sqrt(n))
for a in range(k+1,0,-1):
    if n % a == 0:
        print(max(len(str(a)),len(str(n//a))))
        break
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
power = 1
for i in range(1, n+1):
    power *= i
print(power % 1000000007)


Fixed submission:
n = int(input())
power = 1
for i in range(1, n+1):
    power = (i * power) % 1000000007
print(power)
Buggy python submission (verdict: Runtime Error):
import time
import math
def sieve(n):
    prime = []
    limit = math.sqrt(n)
    data = [i for i in range(2, n+1)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


n = int(input())
prime = sieve(n)
ans = 1
for sosu in prime:
    cnt = 0
    for i in range(2, n+1):
        num = i
        while num % sosu == 0:
            num //= sosu 
            cnt += 1
    ans *= (cnt + 1)
print(ans % (10**9 + 7))


Fixed submission:
import time
import math
def sieve(n):
    prime = []
    limit = math.sqrt(n)
    data = [i for i in range(2, n+1)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


n = int(input())
if n == 1:
    print(1)
    exit()
prime = sieve(n)
ans = 1
for sosu in prime:
    cnt = 0
    for i in range(2, n+1):
        num = i
        while num % sosu == 0:
            num //= sosu 
            cnt += 1
    ans *= (cnt + 1)
print(ans % (10**9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
cnt=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z == s:
                cnt+=1
print(cnt)


Fixed submission:
k,s=map(int,input().split())
cnt=0
for x in range(k+1):
    for y in range(k+1):
        if 0 <= s-x-y <=k:
            cnt+=1
print(cnt)