Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9 + 7


def ketadp3(a, b):
    L = len(str(a))

    # dp = [[[0 for i in range(b)] for j in range(2)] for k in range(L + 1)]
    dp = [[[0 for i in range(2)] for j in range(b)] for k in range(L + 1)]
    dp[0][0][0] = 1
    for i in range(L):
        D = int(str(a)[i])
        for k in range(b):
            for j in range(2):
                for d in range(10 if j else D+1):
                    dp[i + 1][((k + d) % b)][j or (d < D)] += dp[i][k][j]
                    dp[i + 1][((k + d) % b)][j or (d < D)] %= MOD

    return (dp[L][0][0] + dp[L][0][1] - 1) % MOD


def main():
    # a, b = map(int, input().split())
    # print(ketadp(b)-ketadp(a-1))
    n = int(input())
    d = int(input())
    print(ketadp3(n, d))


if __name__ == '__main__':
    main()


Fixed submission:
MOD = 10**9 + 7
def ketadp3(a, b):
    L = len(a)

    dp = [[[0 for i in range(2)] for j in range(b)] for k in range(L + 1)]
    dp[0][0][0] = 1
    for i in range(L):
        D = int(a[i])
        for k in range(b):
            for j in range(2):
                for d in range(10 if j else D+1):
                    dp[i + 1][(k + d) % b][j or (d < D)] += dp[i][k][j]
                    dp[i + 1][(k + d) % b][j or (d < D)] %= MOD

    print((dp[L][0][0] + dp[L][0][1] - 1) % MOD)


def main():
    n = input()
    d = int(input())
    ketadp3(n, d)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9 + 7


def ketadp3(a, b):
    L = len(str(a))

    dp = [[[0]*b for j in range(2)] for k in range(L + 1)]
    dp[0][0][0] = 1
    for i in range(L):
        D = int(str(a)[i]) 
        for j in range(2):
            for k in range(b):
                for d in range(10 if j else D+1):
                    dp[i + 1][j or (d < D)][((k + d) % b)] += dp[i][j][k]
                    dp[i + 1][j or (d < D)][((k + d) % b)] %= MOD

    return (dp[L][0][0] + dp[L][1][0] - 1) % MOD


def main():
    n = int(input())
    d = int(input())
    print(ketadp3(n, d))


if __name__ == '__main__':
    main()


Fixed submission:
MOD = 10**9 + 7
def ketadp3(a, b):
    L = len(a)

    dp = [[[0 for i in range(2)] for j in range(b)] for k in range(L + 1)]
    dp[0][0][0] = 1
    for i in range(L):
        D = int(a[i])
        for k in range(b):
            for j in range(2):
                for d in range(10 if j else D+1):
                    dp[i + 1][(k + d) % b][j or (d < D)] += dp[i][k][j]
                    dp[i + 1][(k + d) % b][j or (d < D)] %= MOD

    print((dp[L][0][0] + dp[L][0][1] - 1) % MOD)


def main():
    n = input()
    d = int(input())
    ketadp3(n, d)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))

a = [0] * 100000
for i in v:
    a[i] += 1

A = sorted(a)
if A[-2] == 0:
    print(int(n/2))
else:
    print(len(v) - A[-1] - A[-2])

Fixed submission:
n = int(input())
v = list(map(int,input().split()))

a = [ v[i] for i in range(0,n,2)]
b = [ v[i] for i in range(1,n,2)]
A = [0] * 100010
B = [0] * 100010

for i in range(int(n/2)):
    A[a[i]] += 1
    B[b[i]] += 1

if A.index(max(A)) == B.index(max(B)):
    BB = sorted(B)
    cc1 = len(b) - BB[-2] + len(a) - max(A)
    AA = sorted(A)
    cc2 = len(a) - AA[-2] + len(b) - max(B)
    if cc1 > cc2:
        print(cc2)
    else:
        print(cc1)
else:
    print(n - max(A) - max(B))
Buggy python submission (verdict: Runtime Error):
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))

ans = 0
for i in range(N):
    ans = math.gcd(ans,abs(x[i]-X))
print(ans)


Fixed submission:
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
 
ans = 0
for i in range(N):
    ans = fractions.gcd(ans,abs(x[i]-X))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,X = map(int,input().split())
x = list(map(int,input().split()))

for i in range(N):
    x[i] = abs(x[i] - X)
    if x[i] == 0:
        x[i] = 10000000000
m = min(x)

flg = True
for i in range(m,0,-1):
    for j in range(N):
        if x[j] % i != 0:
            flg = False
            break

    if flg == True:
        print(i)
        exit()
    else:
        flg = True


Fixed submission:
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
 
ans = 0
for i in range(N):
    ans = fractions.gcd(ans,abs(x[i]-X))
print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print(a*b -(a+b-1))


Fixed submission:
a,b = map(int,input().split())
print(a*b -(a+b-1))
Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())
LR = [ list(map(int,input().split())) for i in range(M)]
pq = [ list(map(int,input().split())) for i in range(Q)]

lr = [ [0]*(N+1) for i in range(N+1)]
for i in range(M):
    l,r = LR[i][0],LR[i][1]
    lr[l][r] += 1

for i in range(Q):
    ans = 0
    p,q = pq[i][0],pq[i][1]
    for i in range(p,q+1):
        for j in range(p,q+1):
            ans += lr[i][j]
    print(ans)



Fixed submission:
N,M,Q = map(int,input().split())
LR = [ list(map(int,input().split())) for i in range(M)]
pq = [ list(map(int,input().split())) for i in range(Q)]

lr = [ [0]*(N+1) for i in range(N+1)]
for i in range(M):
    l,r = LR[i][0],LR[i][1]
    lr[l][r] += 1

for i in range(N):
    for j in range(N):
        lr[i][j+1] += lr[i][j]

for i in range(Q):
    ans = 0
    p,q = pq[i][0],pq[i][1]
    for i in range(p,q+1):
        ans += (lr[i][q] - lr[i][p-1])
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M,Q = map(int,input().split())

L,R =[],[]
for i in range(M):
    l,r = map(int,input().split())
    L.append(l)
    R.append(r)

p,q = [],[]
for i in range(Q):
    pp,qq = map(int,input().split())
    p.append(pp)
    q.append(qq)

cnt = 0
for i in range(Q):
    x = p[i]
    y = q[i]
    for j in range(M):
        l = L[j]
        r = R[j]
        if x <= l and y >= r:
            cnt += 1
    print(cnt)
    cnt = 0


Fixed submission:
N,M,Q = map(int,input().split())
LR = [ list(map(int,input().split())) for i in range(M)]
pq = [ list(map(int,input().split())) for i in range(Q)]

lr = [ [0]*(N+1) for i in range(N+1)]
for i in range(M):
    l,r = LR[i][0],LR[i][1]
    lr[l][r] += 1

for i in range(N):
    for j in range(N):
        lr[i][j+1] += lr[i][j]

for i in range(Q):
    ans = 0
    p,q = pq[i][0],pq[i][1]
    for i in range(p,q+1):
        ans += (lr[i][q] - lr[i][p-1])
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int,input().split()))

cnt = 0
while True:
    flg = False
    for i in range(N):
        if a[i] % 2 == 0:
            a[i] /= 2
            break
        elif i == N - 1:
            print(cnt)
            flg = True
    if flg == True:
        break

    cnt += 1


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

cnt = 0
for i in range(N):
    while True:
        if a[i] % 2 != 0:
            break
        else:
            cnt+=1
            a[i] = a[i] / 2
print(cnt)

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

cnt = 0
while True:
    g =-1
    for i in range(N):
        if a[i] % 2 == 0:
            g = i
            break
        elif i == N - 1:
            print(cnt)

    if g == -1:
        break

    for i in range(N):
        if g == i:
            a[i] /= 2
    cnt += 1


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

cnt = 0
for i in range(N):
    while True:
        if a[i] % 2 != 0:
            break
        else:
            cnt+=1
            a[i] = a[i] / 2
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
S = input()

m = float("inf")
for i in range(N):
    cnt = 0
    for j in range(N):
        if i == j:
            continue
        elif i > j:
            if S[j] =='W':
                cnt += 1
        elif i < j:
            if S[j] == 'E':
                cnt += 1
    if m > cnt:
        m = cnt

print(m)


Fixed submission:
import math
N = int(input())
S = input()

w = [0]*N
e = [0]*N
if S[0] == 'W':
    w[0] += 1
if S[N-1] == 'E':
    e[N-1] += 1
for i in range(1,N):
    w[i] = w[i-1]
    e[N-i-1] = e[N-i]
    if S[i] == 'W':
        w[i] += 1
    if S[N-i-1] == 'E':
        e[N-i-1] += 1

m = float("inf")
for i in range(N):
    cnt = w[i] + e[i] - 1
    if cnt < m:
        m = cnt
print(m)
Buggy python submission (verdict: Runtime Error):
s = input()
K = int(input())

L = []
L.append(s)

for i in range(len(s),0,-1):
    for j in range(len(s)):
        if i + j >= len(s):
            break
        L.append(s[j:i+j])
    L = sorted(set(L))
#    if len(L) >= K:
print(L[K-1])


Fixed submission:
s = input()
K = int(input())

L = []
for i in range(len(s)):
    for j in range(1,K+1):
        L.append(s[i:i+j])
print(sorted(set(L))[K-1])
Buggy python submission (verdict: Runtime Error):
a,b,c = map(int,input().split())

if A > X:
  print("NO")
elif A+B < X:
  print("NO")
else:
  print("YES")

Fixed submission:
A,B,X = map(int,input().split())

if A > X:
  print("NO")
elif A+B < X:
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
print(min(a,b) + min(c,d))

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min(a,b) + min(c,d))
Buggy python submission (verdict: Runtime Error):
N = int(input())
Sdic = {}
L = ["M","A","R","C","H"]
for i in L:
    Sdic[i] = []

tN = N
for i in range(N):
    s = input()
    if s[0] in L:
        Sdic[s[0]].append(s)
    else:
        tN -= 1


zen = tN*(tN-1)*(tN-2) / 6

one = 0
for i in ["M","A","R","C","H"]:
    c = len(Sdic[i])
    if c >= 3:
        one += c * (c-1) * (c-2)  / 6


lis = []
for i in range(N):
    for j in range(N):
        if i < j:
            lis.append(len(Sdic[L[i]]) + len(Sdic[L[j]]))

two = 0
for c in lis:
    if c >= 3:
        two += c * (c-1) * (c-2)  / 6

print(int(zen - one - two))


Fixed submission:
N = int(input())
d = {}
for i in range(N):
    s = input()[0]
    if s not in d.keys():
        d[s] = 0
    d[s] += 1
march = ["M","A","R","C","H"]
lis = []
for a in d.keys():
    if a in march:
        lis.append(a)
import itertools
ans = 0
for l in list(itertools.combinations(lis,3)):
    ans += d[l[0]]*d[l[1]]*d[l[2]]
print(ans)
Buggy python submission (verdict: Runtime Error):
def main():
    n = input()
    if len(n) == 1:
        print(n)
    else:
        ans = (len(n) - 1) * 9
        t = 0
        for i in range(len(n)):
            t += int(n[i])
        ans = max(ans, t)
        k = int(n)
        for i in range(len(n)-1):
            nn = str(k)
            m = int(nn[len(n) - i - 1:]) + 1
            #print(m)
            k -= m
            t = 0
            for j in range(len(str(k))):
                t += int(str(k)[j])
            ans = max(ans, t)
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
def main():
    n = input()
    if len(n) == 1:
        print(n)
        exit()
    else:
        ans = (len(n) - 1) * 9
        t = 0
        for i in range(len(n)):
            t += int(n[i])
        ans = max(ans, t)
        k = int(n)
        for i in range(len(n)-1):
            nn = str(k)
            m = int(nn[len(n) - i - 1:]) + 1
            k -= m
            t = 0
            for j in range(len(str(k))):
                t += int(str(k)[j])
            ans = max(ans, t)
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
x = int(input())
a = int(input())
b = int(input())
X -= a
k = X//b
print(X - b*k)

Fixed submission:
X = int(input())
a = int(input())
b = int(input())
X -= a
k = X//b
print(X - b*k)
Buggy python submission (verdict: Runtime Error):
S = input()

ans = 0
if len(S) % 2 == 0:
    ans = len(S)//2
    c = ans
    t = S[ans]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
else:
    ans = len(S)//2
    c = ans+1
    t = S[ans+1]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
print(ans)


Fixed submission:
S = input()

ans = 0
if len(S) % 2 == 0:
    ans = len(S)//2
    c = ans
    t = S[ans]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break
else:
    ans = len(S)//2+1
    c = ans
    t = S[ans-1]
    for i in range(len(S)//2-1,-1,-1):
        if S[i] == S[c] and S[i] == t:
            ans += 1
            c += 1
        else:
            break

    ans = max(len(S)//2,ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())

s = 0
sN = str(N)
for i in range(len(sN)):
  s += sN[i]

if N % s == 0:
  print("Yes")
else:
  print("No")

Fixed submission:
N = int(input())

s = 0
sN = str(N)
for i in range(len(sN)):
  s += int(sN[i])

if N % s == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

def sol(n):
  if n == 0:
    return 2
  elif n == 1:
    return 1
  else:
    return sol(n-1) + sol(n-2)

print(sol(N))
  

Fixed submission:
N = int(input())

dp = [0] * (N+10)
dp[0] = 2
dp[1] = 1

for i in range(2,N+1):
  dp[i] = dp[i-1] + dp[i-2]

print(dp[N])
Buggy python submission (verdict: Runtime Error):
X,Y = input().split()
if x == y:
  print("=")
elif x > y:
  print(">")
elif x < y:
  print("<")

Fixed submission:
x,y = input().split()
if x == y:
  print("=")
elif x > y:
  print(">")
elif x < y:
  print("<")
Buggy python submission (verdict: Runtime Error):
cnt = 0
def dfs(g , start,N):
    global cnt
    visited = [False for i in range(N)]
    stack =[]
    stack.append(start)

    while stack:
        v = stack.pop()
        visited[v] = True


        for i in range(N):
            if g[v][i] == 1 and visited[i] ==False:
                stack.append(i)

    for i in range(N):
        if visited[i] == False:
            cnt += 1
            break


N,M = map(int,input().split())
g = [ [0 for i in range(N)] for j in range(N)]
a,b = [0] * N,[0] * N

for i in range(M):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

for i in range(M):

    g[a[i]][b[i]] -= 1
    g[b[i]][a[i]] -= 1

    dfs(g,0,N)

    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

print(cnt)


Fixed submission:

cnt = 0
def dfs(g , start,N):
    global cnt
    visited = [False for i in range(N)]
    stack =[]
    stack.append(start)

    while stack:
        v = stack.pop()
        visited[v] = True

        for i in range(N):
            if g[v][i] == 1 and visited[i] ==False:
                stack.append(i)

    for i in range(N):
        if visited[i] == False:
            cnt += 1
            break


N,M = map(int,input().split())
g = [ [0 for i in range(N)] for j in range(N)]
a,b = [0] * M,[0] * M

for i in range(M):
    a[i],b[i] = map(int,input().split())
    a[i] -= 1
    b[i] -= 1
    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

for i in range(M):

    g[a[i]][b[i]] -= 1
    g[b[i]][a[i]] -= 1

    dfs(g,0,N)

    g[a[i]][b[i]] += 1
    g[b[i]][a[i]] += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
N = int(input())
p = list(map(int,input().split()))

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

k = 0
for i in range(1,N):
    i += k
    if i == p[i-1] and i+1 == p[i]:
        ans -= 1
        k += 1
print(ans)


Fixed submission:
N = int(input())
p = list(map(int,input().split()))

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

k = 0
for i in range(1,N):
    i += k
    if i >= N:
        break
    if i == p[i-1] and i+1 == p[i]:
        ans -= 1
        k += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
p = list(map(int,input().split()))
ppp = [0]*N
for i in range(N):
    if i == p[i] - 1:
        ppp[i] = 1
cnt = 0
while True:
    if 1 not in ppp:
        print(cnt)
        exit()
    a = ppp.index(1)
    if a == len(ppp) - 1:
        ppp[a] = 0
    elif ppp[a+1] == 1:
        ppp[a],ppp[a+1] = 0,0
    else:
        ppp[a] = 0
    cnt += 1

Fixed submission:
N = int(input())
p = list(map(int,input().split()))

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

k = 0
for i in range(1,N):
    i += k
    if i >= N:
        break
    if i == p[i-1] and i+1 == p[i]:
        ans -= 1
        k += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S1 = input()
S2 = input()

i = 1
if S1[0] == S2[0]:
    ans = 3
    state = 0
else:
    i+= 1
    ans = 6
    state = 1
mod  = 10**9 + 7
while N > i:
    if S1[i] != S2[i] and state == 0:
        ans *= 2
        i+=2
        state = 1
    elif S1[i] != S2[i] and state == 1:
        ans *= 3
        i+=2
    elif S1[i] == S2[i] and state == 0:
        ans *= 2
        i+= 1
    elif S1[i] == S2[i] and state == 1:
        ans *= 1
        i+=1
        state = 0

    ans %= mod
print(ans)
~


Fixed submission:
N = int(input())
S1 = input()
S2 = input()

i = 1
if S1[0] == S2[0]:
    ans = 3
    state = 0
else:
    i+= 1
    ans = 6
    state = 1
mod  = 10**9 + 7
while N > i:
    if S1[i] != S2[i] and state == 0:
        ans *= 2
        i+=2
        state = 1
    elif S1[i] != S2[i] and state == 1:
        ans *= 3
        i+=2
    elif S1[i] == S2[i] and state == 0:
        ans *= 2
        i+= 1
    elif S1[i] == S2[i] and state == 1:
        ans *= 1
        i+=1
        state = 0

    ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
onelist,nlist = [],[]
for i in range(M):
    aa,bb = map(int,input().split())
    if aa == 1:
        onelist.append(bb)
    if bb == N:
        nlist.append(aa)

for b in onelist:
    if b in nlist:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")


Fixed submission:
N,M = map(int,input().split())
onelist,nlist = [],[]
for i in range(M):
    aa,bb = map(int,input().split())
    if aa == 1:
        onelist.append(bb)
    if bb == N:
        nlist.append(aa)


if len(set(onelist) & set(nlist)) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
Buggy python submission (verdict: Runtime Error):
def main():
    k = int(input())
    a = min(k, 50)
    b = k % a
    ans = [i + k//a for i in range(a)]
    for i in range(b):
        ans.sort()
        for j in range(1, a):
            ans[j] -= 1
        ans[0] += a

    print(a)
    print(*ans)


if __name__ == '__main__':
    main()

Fixed submission:
from datetime import date
from math import factorial
import functools
from heapq import*
from collections import deque
import collections
import math
from collections import defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
inf = float("inf")


def main():
    k = int(input())
    if k == 0:
        print(3)
        print("2 2 2")
        exit()
    elif k == 1:
        print(3)
        print("1 0 3")
        exit()
    a = min(k, 50)
    b = k % a
    ans = [i + k//a for i in range(a)]
    for i in range(b):
        ans.sort()
        for j in range(1, a):
            ans[j] -= 1
        ans[0] += a

    print(a)
    print(*ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []

for aa in a:
    b.append(aa)
    b = b[::-1]

print(' '.join(map(str,b)))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []

x,y = [],[]
for i in range(1,n+1):
    if i % 2 == 0:
        x.append(a[i-1])
    else:
        y.append(a[i-1])
if n % 2 == 0:
    print(" ".join(map(str,x[::-1])), " ".join(map(str,y)))
else:
    print(" ".join(map(str,y[::-1])), " ".join(map(str,x)))
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())

if abs(M-N) > 1:
    print(0)
    exit()

L = 0
if N == M:
    cnt = 1
    for i in range(1,N+1):
        cnt *= i
    ccnt = cnt
else:
    mi = min([N,M])
    ma = max([N,M])
    cnt = 1
    for i in range(1,mi+1):
        cnt *= i

    ccnt = cnt * ma


nn = N%2
mm = M%2
if (nn == 0 and mm == 0) or (nn == 1 and mm == 1):
    print((cnt * ccnt * 2) % 1000000007)
else:
    print((cnt * ccnt) % 1000000007)


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

if abs(M-N) > 1:
    print(0)
    exit()

L = 0
if N == M:
    cnt = 1
    for i in range(1,N+1):
        cnt *= i
        cnt %= 1000000007
    ccnt = cnt
else:
    mi = min([N,M])
    ma = max([N,M])
    cnt = 1
    for i in range(1,mi+1):
        cnt *= i
        cnt %= 1000000007

    ccnt = cnt * ma


nn = N%2
mm = M%2
if (nn == 0 and mm == 0) or (nn == 1 and mm == 1):
    print((cnt * ccnt * 2) % 1000000007)
else:
    print((cnt * ccnt) % 1000000007)
Buggy python submission (verdict: Runtime Error):
N = int(input())
a = list(map(int,input().split()))

baclet = [False] * 9
baclet[8] = 0

for val in a:
    if val < 400:
        baclet[0] = True
    elif val >= 400 and val < 800: 
        baclet[1] = True
    elif val >= 800 and val < 1200: 
        baclet[2] = True
    elif val >= 1200 and val < 1600: 
        baclet[3] = True
    elif val >= 1600 and val < 2000: 
        baclet[4] = True
    elif val >= 2000 and val < 2400: 
        baclet[5] = True
    elif val >= 2400 and val < 2800: 
        baclet[6] = True
    elif val >= 2800 and val < 3200: 
        baclet[7] = True
    elif val >= 3200: 
        baclet[8] += 1

if baclet[:-1].count(True) > 0:
    print(baclet[:-1].count(True),end=" ")
elif backet[8] > 0:
    print(1,end=" ")

if baclet[8] >= 8:
    print(8)
elif 8 - baclet[:-1].count(True) <= baclet[8]:
    print(8)
else:
    print(baclet[:-1].count(True) + baclet[8])


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

baclet = [False] * 9
baclet[8] = 0

for val in a:
    if val < 400:
        baclet[0] = True
    elif val >= 400 and val < 800: 
        baclet[1] = True
    elif val >= 800 and val < 1200: 
        baclet[2] = True
    elif val >= 1200 and val < 1600: 
        baclet[3] = True
    elif val >= 1600 and val < 2000: 
        baclet[4] = True
    elif val >= 2000 and val < 2400: 
        baclet[5] = True
    elif val >= 2400 and val < 2800: 
        baclet[6] = True
    elif val >= 2800 and val < 3200: 
        baclet[7] = True
    elif val >= 3200: 
        baclet[8] += 1

if baclet[:-1].count(True) > 0:
    print(baclet[:-1].count(True),end=" ")
elif baclet[8] > 0:
    print(1,end=" ")

print(baclet[:-1].count(True) + baclet[8])
Buggy python submission (verdict: Runtime Error):
def BellmanFord(edges,num_v,source):
  dist=[float("inf") for i in range(num_v)]
  dist[source]=0
  
  for i in range(num_v):
    for edge in edges:
      if edge[0] != float("inf") and dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        if i==num_v-1: return -1
  
  return dist

N,M = map(int,input().split())
edges = []
edges2 = []
for i in range(M):
    a,b,c = map(int,input().split())
    edges.append([a-1,b-1,-c])
    edges2.append([a-1,b-1,c])

d  = BellmanFord(edges,N,0)
d2  = BellmanFord(edges2,N,0)
if d==-1:
    print("inf")
    exit()

for i in range(N):
    if d[i] == float("inf"):
        print("inf")
        exit()

print(max(-d[N-1],d2[N-1]))



Fixed submission:
def BellmanFord(edges,num_v,source):
  dist=[float("inf") for i in range(num_v)]
  dist[source]=0
  
  for i in range(num_v):
    for edge in edges:
      if edge[0] != float("inf") and dist[edge[1]] > dist[edge[0]] + edge[2]:
        dist[edge[1]] = dist[edge[0]] + edge[2]
        if i==num_v-1 and edge[1] == N - 1:
            return -1
  
  return dist

N,M = map(int,input().split())
edges = []
for i in range(M):
    a,b,c = map(int,input().split())
    edges.append([a-1,b-1,-c])

d  = BellmanFord(edges,N,0)
if d==-1:
    print("inf")
    exit()

print(-d[N-1])