Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
def main():
	# a,b,k = map(int,input().split())
	# n,k = map(int,input().split())
	s = list(str(input()))
	# a = list(map(int,input().split()))
	# rsp = list(str(input()))
	# l = [list(map(int, input().split())) for _ in range(n-1)]
	# s = list(s)
	avoid = 0
	ans = 0
	ans_rec = []
	for i in range(len(s)):
		if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
			# print("when i = {} is true".format(i))
			ans += 1
		else:
			ans_rec.append(ans)
			ans = 0
			
	print(max(ans_rec))

 
if __name__ == '__main__':
	main()

Fixed submission:
def main():
	# a,b,k = map(int,input().split())
	# n,k = map(int,input().split())
	s = list(str(input()))
	# a = list(map(int,input().split()))
	# rsp = list(str(input()))
	# l = [list(map(int, input().split())) for _ in range(n-1)]
	# s = list(s)
	avoid = 0
	ans = 0
	ans_rec = []
	for i in range(len(s)):
		if s[i] == "A" or s[i] == "T" or s[i] == "G" or s[i] == "C":
			# print("when i = {} is true".format(i))
			ans += 1
		else:
			ans_rec.append(ans)
			ans = 0
	ans_rec.append(ans)
			
	print(max(ans_rec))

 
if __name__ == '__main__':
	main()
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)

N, K = map(int, input().split())
*A, = map(int, input().split())

def g(X, t):
    if X<=t:
        return 0
    return 1+g(t, t)+g(X-t, t)

def f(t):
    c = 0
    for i in A:
        c += i//t if i!=t else 0
    return c<=K

left, right = -1, 10**10
while right-left>1:
    m = (right+left)//2
    if f(m):
        right = m
    else:
        left = m

print(right)


Fixed submission:
N, K = map(int, input().split())
*A, = map(int, input().split())

def f(t):
    if t!=0:
        c = 0
        for i in A:
            c += i//t if i!=t else 0
        return c<=K
    else:
        return all(i<=t for i in A)

left, right = -1, 10**10
while right-left>1:
    m = (right+left)//2
    if f(m):
        right = m
    else:
        left = m

print(right)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(1000000)

N, K = map(int, input().split())
*A, = map(int, input().split())

def g(X, t):
    if X<=t:
        return 0
    return 1+g(t, t)+g(X-t, t)

def f(t):
    c = 0
    for i in A:
        c += g(i, t)
    return c<=K

left, right = -1, 10**10
while right-left>1:
    m = (right+left)//2
    if f(m):
        right = m
    else:
        left = m

print(right)


Fixed submission:
N, K = map(int, input().split())
*A, = map(int, input().split())

def f(t):
    if t!=0:
        c = 0
        for i in A:
            c += i//t if i!=t else 0
        return c<=K
    else:
        return all(i<=t for i in A)

left, right = -1, 10**10
while right-left>1:
    m = (right+left)//2
    if f(m):
        right = m
    else:
        left = m

print(right)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
f = lambda x,y,z:x**2+y**2+z**2+x*y+y*z+z*x

for n in range(1, N+1):
    ans = 0
    for x in range(1, int(n**0.5)+1):
        if f(x,0,0)>n:
            break
        for y in range(1, int(n**0.5)+1):
            if f(x,y,0)>n:
                break
            for z in range(1, int(n**0.5)+1):
                if f(x,y,z)>n:
                    break
                elif f(x,y,z)==n:
                    ans += 1
    print(ans)

Fixed submission:
def solve():
    N = int(input())
    f = lambda x,y,z:x*x+y*y+z*z+x*y+y*z+z*x
    MAX = 10000

    ans = [0]*(MAX+1)
    for x in range(1, 101):
        if f(x,0,0)>MAX:
            break
        for y in range(1, 101):
            if f(x,y,0)>MAX:
                break
            for z in range(1, 101):
                if f(x,y,z)>MAX:
                    break
                ans[f(x,y,z)]+=1
    for i in range(1, N+1):
        print(ans[i])

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for n in range(1, N+1):
    ans = 0
    for x in range(1, int(n**0.5)+1):
        for y in range(1, int(n**0.5)+1):
            v = x**2+y**2+1+x*y+y*1+1*x
            if v>n:
                break
            for z in range(1, int(n**0.5)+1):
                v = x**2+y**2+z**2+x*y+y*z+z*x
                if v>n:
                    break
                elif v==n:
                    ans += 1
    print(ans)

Fixed submission:
def solve():
    N = int(input())
    f = lambda x,y,z:x*x+y*y+z*z+x*y+y*z+z*x
    MAX = 10000

    ans = [0]*(MAX+1)
    for x in range(1, 101):
        if f(x,0,0)>MAX:
            break
        for y in range(1, 101):
            if f(x,y,0)>MAX:
                break
            for z in range(1, 101):
                if f(x,y,z)>MAX:
                    break
                ans[f(x,y,z)]+=1
    for i in range(1, N+1):
        print(ans[i])

if __name__ == "__main__":
    solve()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for n in range(1, N+1):
    ans = 0
    for x in range(1, int(n**0.5)+1):
        for y in range(1, int(n**0.5)+1):
            for z in range(1, int(n**0.5)+1):
                v = x**2+y**2+z**2+x*y+y*z+z*x
                if v>n:
                    continue
                elif v==n:
                    ans += 1
    print(ans)

Fixed submission:
def solve():
    N = int(input())
    f = lambda x,y,z:x*x+y*y+z*z+x*y+y*z+z*x
    MAX = 10000

    ans = [0]*(MAX+1)
    for x in range(1, 101):
        if f(x,0,0)>MAX:
            break
        for y in range(1, 101):
            if f(x,y,0)>MAX:
                break
            for z in range(1, 101):
                if f(x,y,z)>MAX:
                    break
                ans[f(x,y,z)]+=1
    for i in range(1, N+1):
        print(ans[i])

if __name__ == "__main__":
    solve()
Buggy python submission (verdict: Runtime Error):
N = int(input())
X = input()

def f(n, first):
    cnt = 1
    n %= first
    while n!=0:
        pc = bin(n).count("1")
        n = n%pc
        cnt += 1
    return cnt

v = 0
for i, j in enumerate(X[::-1]):
    if j=="1":
        v += 2**i
cnt = X.count("1")

for i in range(N):
    p = N-i-1
    buf = 0
    c2 = 0
    if X[i]=="0":
        buf = v+2**p
        c2 = cnt+1
    else:
        buf = v-2**p
        c2 = cnt-1
    print(f(buf, c2))

Fixed submission:
def f(n):
    cnt = 0
    while n:
        buf = n
        pc = 0
        while buf:
            pc += buf%2
            buf //= 2
        n = n%pc
        cnt += 1
    return cnt

N = int(input())
X = input()

v1, v2 = 0, 0
cnt = X.count("1")
for i, j in enumerate(X[::-1]):
    if j=="1":
        v1 += pow(2, i, cnt+1)
        v1 %= (cnt+1)

        if cnt>1:
            v2 += pow(2, i, cnt-1)
            v2 %= (cnt-1)

for i in range(N):
    p = N-i-1
    buf = 0
    c2 = 0
    if X[i]=="0":
        c2 = cnt+1
        buf = (v1+pow(2, p, c2))%c2
        print(f(buf)+1)
    else:
        c2 = cnt-1
        if c2>0:
            buf = (v2-pow(2, p, c2))%c2
            print(f(buf)+1)
        else:
            print(0)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter


class Osa_k:
    def __init__(self, maximum):
        self.table = [-1] * (maximum+1)
        for i in range(2, maximum+1):
            if self.table[i] == -1:
                self.table[i] = i
                for k in range(i*i, maximum+1, i):
                    if self.table[k] == -1:
                        self.table[k] = i

    def factorize(self, n):
        res = Counter()
        b = n
        while self.table[b] != -1:
            res[self.table[b]] += 1
            b //= self.table[b]
        return res


def solve():
    N = int(input())
    ins = Osa_k(N)
    ans = 0

    for i in range(1, N+1):
        cnt = i
        for j in ins.factorize(i).values():
            cnt *= (j+1)
        ans += cnt

    print(ans)


solve()


Fixed submission:
def solve():
    N = int(input())
    cnt = [1]*(N+1)

    for i in range(2, N+1):
        j = 1
        while i*j<=N:
            cnt[i*j] += 1
            j += 1

    ans = 0
    for i in range(1, N+1):
        ans += i*cnt[i]
    print(ans)

solve()
Buggy python submission (verdict: Time Limit Exceeded):
def solve():
    K = int(input())
    S = input()
    N = len(S)

    MOD = 10**9+7
    n = N+K
    fac = [1]*(n+1)
    rev = [1]*(n+1)
    
    for i in range(1,n+1):
        fac[i] = i*fac[i-1]%MOD
        rev[i] = pow(fac[i], MOD-2, MOD)
    
    comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD

    ans = 0
    for i in range(K+1):
        ans += pow(26, K-i, MOD) * pow(25, i, MOD) * comb(N+i-1, i)
        ans %= MOD
    print(ans)


solve()


Fixed submission:
MOD = 10**9+7
K = int(input())
S = input()
N = len(S)

n = N+K
fac = [1]*(n+1)
rev = [1]*(n+1)
 
for i in range(1,n+1):
  fac[i] = i*fac[i-1]%MOD
  rev[i] = pow(fac[i], MOD-2, MOD)
 
comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD

ans = 0
for i in range(K+1):
    ans += pow(26, K-i, MOD) * pow(25, i, MOD) * comb(N+i-1, i)
    ans %= MOD
print(ans)

Buggy python submission (verdict: Runtime Error):
def solve():
    K = int(input())
    S = input()
    N = len(S)

    MOD = 10**9+7
    n = N+K
    fac = [1]*(n+1)
    rev = [1]*(n+1)
    
    for i in range(1,n+1):
    fac[i] = i*fac[i-1]%MOD
    rev[i] = pow(fac[i], MOD-2, MOD)
    
    comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD

    ans = 0
    for i in range(K+1):
        ans += pow(26, K-i, MOD) * pow(25, i, MOD) * comb(N+i-1, i)
        ans %= MOD
    print(ans)


solve()


Fixed submission:
MOD = 10**9+7
K = int(input())
S = input()
N = len(S)

n = N+K
fac = [1]*(n+1)
rev = [1]*(n+1)
 
for i in range(1,n+1):
  fac[i] = i*fac[i-1]%MOD
  rev[i] = pow(fac[i], MOD-2, MOD)
 
comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD

ans = 0
for i in range(K+1):
    ans += pow(26, K-i, MOD) * pow(25, i, MOD) * comb(N+i-1, i)
    ans %= MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
S = input()
N = len(S)

MOD = 10**9+7
n = N+K
fac = [1]*(n+1)
rev = [1]*(n+1)
 
for i in range(1,n+1):
  fac[i] = i*fac[i-1]%MOD
  rev[i] = pow(fac[i], MOD-2, MOD)
 
comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD

ans = 0
for i in range(K+1):
    ans += pow(26, K-i, MOD) * pow(25, i, MOD) * comb(N+i-1, i)
    ans %= MOD
print(ans)


Fixed submission:
MOD = 10**9+7
K = int(input())
S = input()
N = len(S)

n = N+K
fac = [1]*(n+1)
rev = [1]*(n+1)
 
for i in range(1,n+1):
  fac[i] = i*fac[i-1]%MOD
  rev[i] = pow(fac[i], MOD-2, MOD)
 
comb = lambda a,b:(fac[a]*rev[a-b]*rev[b])%MOD

ans = 0
for i in range(K+1):
    ans += pow(26, K-i, MOD) * pow(25, i, MOD) * comb(N+i-1, i)
    ans %= MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
*A, = map(int, input().split())

b = [i for i in A]
for _ in range(K):
    buf = [0]*(N+1)
    for i, j in enumerate(b):
        buf[max(i-j, 0)] += 1
        buf[min(i+j+1, N)] -= 1
    for i in range(1, N+1):
        buf[i] += buf[i-1]
    b = [buf[i] for i in range(N)]

print(*b)

Fixed submission:
N, K = map(int, input().split())
*A, = map(int, input().split())

b = [i for i in A]
for c in range(K):
    buf = [0]*(N+1)
    for i, j in enumerate(b):
        buf[max(i-j, 0)] += 1
        buf[min(i+j+1, N)] -= 1
    for i in range(1, N+1):
        buf[i] += buf[i-1]
    b = [buf[i] for i in range(N)]
    if all([i==N for i in b]):
        break

print(*b)
Buggy python submission (verdict: Runtime Error):
from math import cos, radians, sqrt

A, B, H, M = map(int, input().split())
rad = radians(abs(360/(720/(60*H+M))-6*M))
ans = sqrt((A**2)+(B**2)-2*A*B*cos(rad))
print(ans)


Fixed submission:
from math import cos, radians, sqrt

A, B, H, M = map(int, input().split())
rad = 0 if H==0 and M==0 else radians(abs(360/(720/(60*H+M))-6*M))
ans = sqrt((A**2)+(B**2)-2*A*B*cos(rad))
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
from collections import defaultdict

N = int(input())
d = {}
MOD = 10**9+7

for _ in range(N):
    A, B = map(int, input().split())
    g = gcd(A, B)
    A//=g
    B//=g
    if (A, B) in d:
        d[(A, B)] += 1
    else:
        d[(A, B)] = 1

b = 1
used = defaultdict(int)

for (i, j), v in d.items():
    if used[(i, j)]:continue
    buf = 0
    if (-j, i) in d or (j, -i) in d:
        if (-j, i) in d:
            used[(-j, i)] = 1
            buf += pow(2, d[(-j, i)], MOD)+pow(2, v, MOD)-1
        if (j, -i) in d:
            used[(j, -i)] = 1
            buf += pow(2, d[(j, -i)], MOD)+pow(2, v, MOD)-1
        b *= buf
    else:
        b *= pow(2, v, MOD)
    b %= MOD
b -= 1
b %= MOD
print(b)

Fixed submission:
from math import gcd
from collections import defaultdict

N = int(input())
d = {}
MOD = 10**9+7
zall = 0

for _ in range(N):
    A, B = map(int, input().split())

    if A==0 and B==0:
        zall += 1
    else:
        if A and B:
            if A<0 and B<0:
                A *= -1
                B *= -1
            elif A<0 and B>0:
                A *= -1
                B *= -1

            g = gcd(A, B)
            A //= g
            B //= g
        elif A==0:
            B = 1
        elif B==0:
            A = 1
        
        if (A, B) in d:
            d[(A, B)] += 1
        else:
            d[(A, B)] = 1

ans = 1
used = defaultdict(int)

for (i, j), v in d.items():
    if used[(i, j)]:continue
    used[(i, j)] = 1
    buf = 0

    if j>0:
        if (j, -i) in d:
            used[(j, -i)] = 1
            buf = d[(j, -i)]
        else:
            buf = 0
    else:
        if (-j, i) in d:
            used[(-j, i)] = 1
            buf = d[(-j, i)]
        else:
            buf = 0

    ans *= (pow(2, buf, MOD)+pow(2, v, MOD)-1)
    ans %= MOD

print((ans+zall-1)%MOD)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
*A, = map(int, input().split())
dp = [[0]*N for _ in range(60)]

for i in range(N):
    dp[0][i] = A[i] - 1

for k in range(1, 60):
    for n in range(N):
        dp[k][n] = dp[k - 1][dp[k - 1][n]]

res = []
for i in range(60):
    if (K>>i)&1:
        res.append(i)
    
pos = 0
for i in res:
    pos = dp[i][pos]
print(pos + 1)

Fixed submission:
N, K = map(int, input().split())
*A, = map(int, input().split())
dist = [-1]*(N+1)

d = {i:[] for i in range(1, N+1)}
for i, j in enumerate(A, start=1):
    d[i].append(j)

dist[1] = 0
q = [1]
cycle = 0
ls = 0
while q:
    a = q.pop()
    for b in d[a]:
        if dist[b]==-1:
            dist[b] = dist[a] + 1
            q.append(b)
        elif dist[b]==0 or dist[b]:
            cycle = dist[a] + 1 - dist[b]
            ls = b
            break

b = (K-dist[ls])%cycle if K>dist[ls] else K
c = dist[ls]+b if K>dist[ls] else K
for i, j in enumerate(dist):
    if j==c:
        print(i)
        break
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
ans = 0
for x in range(int(N**0.5), N+1):
    ans  = max(ans, (A*x)//B-A*(x//B))
print(ans)

Fixed submission:
A, B, N = map(int, input().split())
ans = 0
x = min(B-1, N)
print((A*x)//B-A*(x//B))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
S = input()[::-1]
N = len(S)
l = [0]*N
for i in range(N):
    l[i] = (l[i-1]+int(S[i])*(10**i))%2019
c = Counter(l)
c[0] += 1
ans = 0
for i in c.values():
    ans += i*(i-1)//2
print(ans)

Fixed submission:
from collections import Counter
S = input()[::-1]
N = len(S)
l = [0]*N
for i in range(N):
    l[i] = (l[i-1]+int(S[i])*pow(10,i,2019))%2019
c = Counter(l)
c[0] += 1
ans = 0
for i in c.values():
    ans += i*(i-1)//2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from heapq import heappop, heappush
import sys
input = sys.stdin.readline


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

d = defaultdict(list)
e = defaultdict(int)

for _ in range(M):
    U, V, A, B = map(int, input().split())
    d[U].append((A, B, V))
    d[V].append((A, B, U))

for i in range(1, N+1):
    C, D = map(int, input().split())
    e[i] = (C, D)

dist = defaultdict(lambda :10**30)
ans = defaultdict(lambda :10**30)

source = (1, S)
dist[source] = 0
q = [(0, source)]

while q:
    cost, (s, nokori) = heappop(q)
    ns = (s, nokori)

    u, v = e[s]
    if dist[ns] < cost:
        continue

    n_nokori = nokori
    n_cost = 0
    while n_nokori < 2500:
        n_nokori += u
        n_cost += v
        nt = (s, n_nokori)
        
        if dist[nt] > dist[ns]+n_cost:
            dist[nt] = dist[ns]+n_cost
            heappush(q, (dist[nt], nt))

    for a, b, t in d[s]:
        n_nokori = nokori - a
        n_cost = b
        
        nt = (t, n_nokori)

        if n_nokori < 0:
            continue
        if dist[nt] > dist[ns]+n_cost:
            dist[nt] = dist[ns]+n_cost
            heappush(q, (dist[nt], nt))

for (s, _), v in dist.items():
    ans[s] = min(ans[s], v)

for i in range(2, N+1):
    print(ans[i])

Fixed submission:
from collections import defaultdict
from heapq import heappop, heappush
import sys
input = sys.stdin.readline


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

d = defaultdict(list)
e = defaultdict(int)

for _ in range(M):
    U, V, A, B = map(int, input().split())
    d[U].append((A, B, V))
    d[V].append((A, B, U))

for i in range(1, N+1):
    C, D = map(int, input().split())
    e[i] = (C, D)

dist = defaultdict(lambda :10**30)
ans = defaultdict(lambda :10**30)

source = (1, S)
dist[source] = 0
q = [(0, source)]

while q:
    cost, (s, nokori) = heappop(q)
    ns = (s, nokori)

    u, v = e[s]
    if dist[ns] < cost:
        continue

    if nokori > 2500:
        nokori = 2500
    else:
        n_nokori = nokori + u
        n_cost = v
        if n_nokori > 2500:
            n_nokori = 2500
        nt = (s, n_nokori)
        
        if dist[nt] > dist[ns]+n_cost:
            dist[nt] = dist[ns]+n_cost
            heappush(q, (dist[nt], nt))
    
    for a, b, t in d[s]:
        n_nokori = nokori - a
        n_cost = b
        
        nt = (t, n_nokori)

        if n_nokori < 0:
            continue
        if dist[nt] > dist[ns]+n_cost:
            dist[nt] = dist[ns]+n_cost
            heappush(q, (dist[nt], nt))

for (s, _), v in dist.items():
    ans[s] = min(ans[s], v)

for i in range(2, N+1):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

N = int(input())
*A, = map(int, input().split())
INF = 10**20
dp = [[defaultdict(lambda :-INF) for _ in range(N+1)] for _ in range(2)]
dp[0][0][0] = 0

for i in range(1, N+1):
    for j in range(i+1):
        dp[1][i][j] = max(dp[1][i][j], dp[0][i-1][j-1]+A[i-1])
        dp[0][i][j] = max(dp[1][i-1][j], dp[0][i-1][j])

ans = max(dp[1][N][N//2], dp[0][N][N//2])
print(ans)


Fixed submission:
from collections import defaultdict

N = int(input())
*A, = map(int, input().split())
INF = 10**20
dp = [[defaultdict(lambda :-INF) for _ in range(N+1)] for _ in range(2)]
dp[0][0][0] = 0

for i in range(1, N+1):
    for j in range(i//2-1, i//2+2):
        dp[1][i][j] = max(dp[1][i][j], dp[0][i-1][j-1]+A[i-1])
        dp[0][i][j] = max(dp[1][i-1][j], dp[0][i-1][j])

ans = max(dp[1][N][N//2], dp[0][N][N//2])
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = set()

def check(N, k):
    if k<2:
        return False
    N //= k
    while N:
        if (N-1)%k==0:
            return True
        if N%k:
            return False
        N //= k

for k in range(1, int(N**0.5)+1):
    if (N-1)%k==0:
        ans.add(k)
        ans.add((N-1)//k)
    if N%k==0:
        if check(N, k):
            ans.add(k1)
        if check(N, N//k):
            ans.add(k2)

ans.remove(1)
print(len(ans))

Fixed submission:
N = int(input())
ans = set()

def check(N, k):
    if k<2:
        return False
    N //= k
    while N:
        if (N-1)%k==0:
            return True
        if N%k:
            return False
        N //= k
    return False


for k in range(1, int(N**0.5)+1):
    if (N-1)%k==0:
        k1, k2 = k, (N-1)//k
        ans.add(k1)
        ans.add(k2)
    if N%k==0:
        k1, k2 = k, N//k
        if check(N, k1):
            ans.add(k1)
        if check(N, k2):
            ans.add(k2)

ans.remove(1)
print(len(ans))
Buggy python submission (verdict: Runtime Error):
N, R = map(int, input().split())
print(R+100*(10-K) if N<10 else R)

Fixed submission:
N, R = map(int, input().split())
print(R+100*(10-N) if N<10 else R)

Buggy python submission (verdict: Runtime Error):
N, R = map(int, input().split())
if N<10:
  print(R+100*(10-K))
else:
  print(R)

Fixed submission:
N, R = map(int, input().split())
print(R+100*(10-N) if N<10 else R)
Buggy python submission (verdict: Runtime Error):
s = input()[::-1]
size = len(s)
s += "9"

ans = 0
bef = 0

for i in range(size):
    v1 = int(s[i])
    v2 = int(s[i+1])
    if v1+bef>=6 or (v1+bef>=5 and v2>=5):
        ans += 10-(v1+bef)
        bef = 1
    else:
        ans += (v1+bef)
        bef = 0

ans += (v+bef)//10
print(ans)

Fixed submission:
s = input()[::-1]
size = len(s)
s += "4"

ans = 0
bef = 0

for i in range(size):
    v1 = int(s[i])
    v2 = int(s[i+1])
    if v1+bef>=6 or (v1+bef>=5 and v2>=5):
        ans += 10-(v1+bef)
        bef = 1
    else:
        ans += (v1+bef)
        bef = 0

ans += bef
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
*l = map(int, input().split())
print("YES" if len(l)==len(set(l)) else "NO")

Fixed submission:
N = int(input())
*l, = map(int, input().split())
print("YES" if len(l)==len(set(l)) else "NO")
Buggy python submission (verdict: Runtime Error):
def f(x):
    if x==1:return 1
    return 2*f(x//2)+1

H = int(input())
print(H(n))

Fixed submission:
def f(x):
    if x==1:return 1
    return 2*f(x//2)+1

H = int(input())
print(f(H))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

def gcd(x, y):
    if (y==0):return x
    else:return gcd(y, x%y)

N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7
lcm = reduce(lambda a,b: a*b//gcd(a,b), A)

print(sum(map(lambda x: lcm//x, A))%mod)

Fixed submission:
from functools import reduce

def gcd(x, y):
    if (y==0):return x
    else:return gcd(y, x%y)

N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7
lcm = reduce(lambda a,b: a*b//gcd(a,b), A)

print(sum(map(lambda x: lcm//x, A))%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce

N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7

lcm = reduce(lambda a,b: a*b//gcd(a,b), A)
print(sum(map(lambda x: lcm//x, A))%mod)

Fixed submission:
from functools import reduce

def gcd(x, y):
    if (y==0):return x
    else:return gcd(y, x%y)

N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7
lcm = reduce(lambda a,b: a*b//gcd(a,b), A)

print(sum(map(lambda x: lcm//x, A))%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce

N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7

lcm = reduce(lambda a,b: a*b//gcd(a,b), A)
ans = 0

for n in map(lambda x: lcm//x, A):
    ans += n
    ans %= mod

print(ans)

Fixed submission:
from functools import reduce

def gcd(x, y):
    if (y==0):return x
    else:return gcd(y, x%y)

N = int(input())
*A, = map(int, input().split())
mod = 10**9 + 7
lcm = reduce(lambda a,b: a*b//gcd(a,b), A)

print(sum(map(lambda x: lcm//x, A))%mod)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
*x, = map(int, input().split())
MOD = 10**9+7

l1 = [1]*N
for i in range(1, N):
    l1[i] = (l1[i-1]*i)%MOD

va, vb = 0, 1
ans = 0

for i in range(N-1):
    d = x[i+1]-x[i]
    va = (i+1)*va+vb
    vb = (i+1)*vb
    ans += (d*va*pow(vb, MOD-2, MOD)*l1[N-1])
    ans %= MOD


print(ans)


Fixed submission:
from fractions import gcd


N = int(input())
*x, = map(int, input().split())
MOD = 10**9+7

m = 1
for i in range(1, N):
    m *= i
    m %= MOD

va, vb = 0, 1
ans = 0

for i in range(N-1):
    d = x[i+1]-x[i]
    va = ((i+1)*va+vb)%MOD
    vb = ((i+1)*vb)%MOD
    ans += (d*va*pow(vb, MOD-2, MOD)*m)
    ans %= MOD

print(ans)