Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(zz) for zz in input().split()]
A = [int(zz) for zz in input().split()]

A.sort(reverse=True)
p = sum(A)
flag = 0
for i in range(N-1):
    if K >= p - sum(A[:i+1]):
        p//=(i+1)
        flag=1
        break

if flag == 0:
    p //= N

while p > 0:
    z = 0
    for i in range(N):
        z += A[i] % p
    if z % p == 0:
        B = [i % p for i in A]
        B.sort(reverse=True)
        q = z//p
        j = 0
        for i in range(q):
            j += p-B[i]
        if K >= j:
            print(p)
            exit()
    p -= 1

print(p)


Fixed submission:
N, K = [int(zz) for zz in input().split()]
A = [int(zz) for zz in input().split()]

A.sort(reverse=True)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

P = make_divisors(sum(A))
P.sort(reverse=True)

for p in P:
    z = 0
    for i in range(N):
        z += A[i] % p
    if z % p == 0:
        B = [i % p for i in A]
        B.sort(reverse=True)
        q = z//p
        j = 0
        for i in range(q):
            j += p-B[i]
        if K >= j:
            print(p)
            exit()
            
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N,K = [int(zz) for zz in input().split()]
A = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = [int(zz)-1 for zz in input().split()]
    A[a].append(b)
    A[b].append(a)

dq = deque([0])
ans = K
check = [True]*N
check[0] = False
while dq:
    p = dq.popleft()
    if p == 0:
        cand = K-1
    else:
        cand = K-2
    for i in A[p]:
        if check[i]:
            check[i] = False
            ans *= cand
            cand -= 1
            dq.append(i)

print(ans%(10**9+7))


Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline
MOD = 10**9+7

N,K = [int(zz) for zz in input().split()]
A = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = [int(zz)-1 for zz in input().split()]
    A[a].append(b)
    A[b].append(a)

dq = deque([0])
ans = K
check = [True]*N
check[0] = False
while dq:
    p = dq.popleft()
    if p == 0:
        cand = K-1
    else:
        cand = K-2
    for i in A[p]:
        if check[i]:
            check[i] = False
            ans = (ans*cand)%MOD
            cand -= 1
            dq.append(i)

print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque
import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

N,K = [int(zz) for zz in input().split()]
A = [[] for _ in range(N)]
B = [0]*N

for _ in range(N-1):
    a,b = [int(zz)-1 for zz in input().split()]
    A[a].append(b)
    A[b].append(a)
    B[a] += 1
    B[b] += 1

dq = deque([0])
check = [True]*N
check[0] = False
ans = K
tmp = 1
while dq:
    p = dq.pop()
    count = 0
    btmp = 0
    for i in A[p]:
        if check[i]:
            check[i] = False
            count += 1
            dq.append(i)
        else:
            btmp += 1

    if K-tmp-btmp > 0:
        ans *= permutations_count(K-tmp-btmp,count)
print(ans%(10**9+7))


Fixed submission:
from collections import deque
import sys
input = sys.stdin.readline
MOD = 10**9+7

N,K = [int(zz) for zz in input().split()]
A = [[] for _ in range(N)]
for _ in range(N-1):
    a,b = [int(zz)-1 for zz in input().split()]
    A[a].append(b)
    A[b].append(a)

dq = deque([0])
ans = K
check = [True]*N
check[0] = False
while dq:
    p = dq.popleft()
    if p == 0:
        cand = K-1
    else:
        cand = K-2
    for i in A[p]:
        if check[i]:
            check[i] = False
            ans = (ans*cand)%MOD
            cand -= 1
            dq.append(i)

print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd

def lcm(a,b):
    return a*b//gcd(a,b)

A,B,C,D = [int(zz) for zz in input().split()]

bc = B//C
ac = (A-1)//C
bd = B//D
ad = (A-1)//D
bcd = B//lcm(C,D)
acd = (A-1)//lcm(C,D)

print(B-A-bc+ac-bd+ad+bcd-acd+1)


Fixed submission:
A,B,C,D = [int(i) for i in input().split()]

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)

E = lcm(C,D)

p = B-A+1

ac = p//C
if A%C+p%C >= C+1:
    ac += 1

ad = p//D
if A%D+p%D >= D+1:
    ad += 1

ae = p//E
if A%E+p%E >= E+1:
    ae += 1

print(p-(ac+ad-ae))
Buggy python submission (verdict: Runtime Error):
from collections import deque

N = int(input())
A = [int(i) for i in input().split()]
p = deque()
m = deque()

A.sort(reverse=True)
for i in A:
    if i > 0:
        p.append(i)
    else:
        m.append(i)

ans = []
for _ in range(N-2):
    if p and m:
        if len(p) < len(m):
            tt = p.popleft()
            zz = m.pop()
            p.appendleft(tt-zz)
            ans.append([tt,zz])
        else:
            tt = m.pop()
            zz = p.popleft()
            m.append(tt-zz)
            ans.append([tt,zz])
    elif p:
        tt = p.pop()
        zz = p.popleft()
        m.append(tt-zz)
        ans.append([tt,zz])

    else:
        tt = m.popleft()
        zz = m.pop()
        p.append(tt-zz)
        ans.append([tt,zz])

if p and m:
    tt = p.pop()
    zz = m.pop()
    ans.append([tt,zz])
    print(tt-zz)
else:
    tt = p.popleft()
    zz = p.pop()
    ans.append([tt,zz])
    print(tt-zz)

for i in range(N-1):
    tt,zz = ans[i]
    print(tt,zz)


Fixed submission:
from collections import deque

N = int(input())
A = [int(i) for i in input().split()]
p = deque()
m = deque()

A.sort(reverse=True)
for i in A:
    if i > 0:
        p.append(i)
    else:
        m.append(i)

ans = []
for _ in range(N-2):
    if p and m:
        if len(p) < len(m):
            tt = p.popleft()
            zz = m.pop()
            p.appendleft(tt-zz)
            ans.append([tt,zz])
        else:
            tt = m.pop()
            zz = p.popleft()
            m.append(tt-zz)
            ans.append([tt,zz])
    elif p:
        tt = p.pop()
        zz = p.popleft()
        m.append(tt-zz)
        ans.append([tt,zz])

    else:
        tt = m.popleft()
        zz = m.pop()
        p.append(tt-zz)
        ans.append([tt,zz])

if p and m:
    tt = p.pop()
    zz = m.pop()
    ans.append([tt,zz])
    print(tt-zz)

elif p:
    tt = p.popleft()
    zz = p.pop()
    ans.append([tt,zz])
    print(tt-zz)

else:
    tt = m.popleft()
    zz = m.pop()
    ans.append([tt,zz])
    print(tt-zz)

for i in range(N-1):
    tt,zz = ans[i]
    print(tt,zz)
Buggy python submission (verdict: Runtime Error):
import math

N,M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)]

m = 10**9+7

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

A.append(N+1)
p = A[0]
ans = memo[p]
for i in range(1,M+1):
    print(ans)
    if p+1 == A[i]:
        print(0)
        exit()
    else:
        ans *= memo[A[i]-p-1]
        ans %= m
    p = A[i]

print(ans)


Fixed submission:
N,M = [int(i) for i in input().split()]
A = [int(input()) for _ in range(M)]

m = 10**9+7

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

memo[0] = 0

A.append(N+1)
p = A[0]
ans = memo[p]
for i in range(1,M+1):
    ans *= memo[A[i]-p-1]
    p = A[i]

print(ans%m)
Buggy python submission (verdict: Runtime Error):
	S = list(input())
N = len(S)

ans = 0
flag = 0
ABCflag = 0

i = 0
while i < N-2:

    if S[i]+S[i+1]+S[i+2] == 'ABC':
        ans += 1
        if flag:
            ans += flag
        if ABCflag:
            ans += ABCflag
            ABCflag = 0
        i += 2
        ABCflag += 1

    elif S[i] == 'A':
        flag += 1

    else:
        flag = 0
        if S[i]+S[i+1] == 'BC':
            if ABCflag:
                ans += ABCflag
                ABCflag = 0
            i += 1
        else:
            ABCflag = 0
    i += 1

print(ans)


Fixed submission:
S = list(input())
N = len(S)

ans = 0
flag = 0
ABCflag = 0

i = 0
while i < N-2:

    if S[i]+S[i+1]+S[i+2] == 'ABC':
        if flag:
            ans += flag
        ans += 1
        S[i+2] = 'A'
        i += 1

    elif S[i] == 'A':
        flag += 1

    else:
        flag = 0

    i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = [int(i) for i in input().split()]
ans = [0]*N
for _ in range(M):
    L,R = [int(i)-1 for i in input().split()]
    for j in range(L,R+1):
        ans[j] += 1

count = 0
for i in ans:
    if i == M:
        count += 1

print(count)


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

N,M = [int(i) for i in input().split()]
L_max = 0
R_min = 10**9
for _ in range(M):
    L,R = [int(i) for i in input().split()]
    L_max = max(L_max,L)
    R_min = min(R_min,R)

if R_min-L_max+1 > 0:
    print(R_min-L_max+1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
S = list(input())

p = S[0]+S[1]
q = S[2]+S[3]

p_flag = 0
q_flag = 0

if int(q) = 0 and int(p) == 0:
    print('NA')
elif int(p) == 0:
    print('YYMM')
elif int(q) == 0:
    print('MMYY')
else:
    if int(p) > 12:
        p_flag = 1
    if int(q) > 12:
        q_flag = 1

    if p_flag and q_flag:
        print('NA')
    elif p_flag:
        print('YYMM')
    elif q_flag:
        print('MMYY')
    else:
        print('AMBIGUOUS')


Fixed submission:
S = list(input())

p = S[0]+S[1]
q = S[2]+S[3]

p_flag = 0
q_flag = 0

if int(p) == 0 and int(q) == 0:
    print('NA')
elif int(p) == 0:
    if int(q) < 13:
        print('YYMM')
    else:
        print('NA')
elif int(q) == 0:
    if int(p) < 13:
        print('MMYY')
    else:
        print('NA')
else:
    if int(p) > 12:
        p_flag = 1
    if int(q) > 12:
        q_flag = 1

    if p_flag and q_flag:
        print('NA')
    elif p_flag:
        print('YYMM')
    elif q_flag:
        print('MMYY')
    else:
        print('AMBIGUOUS')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [int(i) for i in input().split()]

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

if N == 2:
    print(max(l))
    exit()

p = l.pop(0)
ans = 1
for j in range(1,N+1):
    element = gcd(l[0], l[1])
    for i in range(2,N-1):
        element = gcd(element,l[i])
    ans = max(ans, element)
    l.append(p)
    p = l.pop(0)
print(ans)


Fixed submission:
N = int(input())
l = [int(i) for i in input().split()]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.extend([i,int(n/i)])
    return divisors

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

p = make_divisors(l[0])
p.extend(make_divisors(l[1]))

p.sort(reverse=True)
for i in p:
    ans = 1
    flag = 0
    for j in l:
        if j%i != 0:
            if flag == 1:
                ans = 0
                break
            flag = 1
    if ans:
        print(i)
        exit()

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [int(i) for i in input().split()]

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

if N == 2:
    print(max(l))
    exit()

p = l.pop(0)
ans = []
for j in range(1,N+1):
    element = gcd(l[0], l[1])
    for i in range(2,N-1):
        element = gcd(element,l[i])
    ans.append(element)
    l.append(p)
    p = l.pop(0)
print(max(ans))


Fixed submission:
N = int(input())
l = [int(i) for i in input().split()]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.extend([i,int(n/i)])
    return divisors

def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

p = make_divisors(l[0])
p.extend(make_divisors(l[1]))

p.sort(reverse=True)
for i in p:
    ans = 1
    flag = 0
    for j in l:
        if j%i != 0:
            if flag == 1:
                ans = 0
                break
            flag = 1
    if ans:
        print(i)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools


X, Y, Z, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

AB = [a + b for (a, b) in list(itertools.product(A, B))]
AB.sort(reverse=True)
ans = [ab + c for (ab, c) in list(itertools.product(AB[:min(3000, X*Y*Z)], C))]
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Fixed submission:
from itertools import product

X,Y,Z,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

BC = [i+j for i,j in list(product(B,C))]
BC.sort(reverse=True)

ans = [i+j for i,j in list(product(BC[:min(3000, X*Y*Z)], A))]
ans.sort(reverse=True)

[print(ans[i]) for i in range(K)]

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

X,Y,Z,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

BC = [i+j for i,j in list(product(B,C))]
BC.sort(reverse=True)

ans = [i+j for i,j in list(product(BC[:min(3000, X*Y*Z)], A))]
ans.sort(reverse=True)

[print(ans[i]) for i in range(K)]


Fixed submission:
from itertools import product

X,Y,Z,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

BC = [i+j for i,j in list(product(B,C))]
BC.sort(reverse=True)

ans = [i+j for i,j in list(product(BC[:min(3000, X*Y*Z)], A))]
ans.sort(reverse=True)

[print(ans[i]) for i in range(K)]

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

X,Y,Z,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

BC = [i+j for i,j in product(B,C)]
BC.sort(reverse=True)

ans = [i+j for i,j in product(BC[:min(3000, X*Y*Z)], A)]
ans.sort(reverse=True)

[print(ans[i]) for i in range(K)]


Fixed submission:
from itertools import product

X,Y,Z,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

BC = [i+j for i,j in list(product(B,C))]
BC.sort(reverse=True)

ans = [i+j for i,j in list(product(BC[:min(3000, X*Y*Z)], A))]
ans.sort(reverse=True)

[print(ans[i]) for i in range(K)]
Buggy python submission (verdict: Runtime Error):
N,Q = [int(i) for i in input().split()]
S = list(input())


q = [input().split() for _ in range(Q)]

li = []
for a,b in q:
    flag = 0
    for i in range(a,b):
        if S[i] == 'A':
            flag = 1
        if S[i] == 'C' and flag:
            li.append(i)

[print(i) for i in li]


Fixed submission:
import itertools
N,Q = [int(i) for i in input().split()]
S = list(input())

li = [0]*N
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        li[i+1] = 1
ans = list(itertools.accumulate(li))
k = []
for j in range(Q):
    a,b = [int(i) for i in input().split()]
    k.append(ans[b-1]-ans[a-1])

[print(i) for i in k]

Buggy python submission (verdict: Runtime Error):
import sys.stdin.readline
input = readline

N,Q = [int(i) for i in input().split()]
S = input()

ans = []
for _ in range(Q):
    a,b = [int(i) for i in input().split()]
    ans.append(S[a-1:b].count('AC'))

[print(i) for i in ans]


Fixed submission:
import itertools
N,Q = [int(i) for i in input().split()]
S = list(input())

li = [0]*N
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        li[i+1] = 1
ans = list(itertools.accumulate(li))
k = []
for j in range(Q):
    a,b = [int(i) for i in input().split()]
    k.append(ans[b-1]-ans[a-1])

[print(i) for i in k]

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

N,Q = [int(i) for i in input().split()]
S = input()

ans = []
for _ in range(Q):
    a,b = [int(i) for i in input().split()]
    ans.append(S[a-1:b].count('AC'))

[print(i) for i in ans]


Fixed submission:
import itertools
N,Q = [int(i) for i in input().split()]
S = list(input())

li = [0]*N
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        li[i+1] = 1
ans = list(itertools.accumulate(li))
k = []
for j in range(Q):
    a,b = [int(i) for i in input().split()]
    k.append(ans[b-1]-ans[a-1])

[print(i) for i in k]

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = [int(i) for i in input().split()]
S = input()

ans = []
for _ in range(Q):
    a,b = [int(i) for i in input().split()]
    ans.append(S[a-1:b].count('AC'))

for i in ans:
    print(i)


Fixed submission:
import itertools
N,Q = [int(i) for i in input().split()]
S = list(input())

li = [0]*N
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        li[i+1] = 1
ans = list(itertools.accumulate(li))
k = []
for j in range(Q):
    a,b = [int(i) for i in input().split()]
    k.append(ans[b-1]-ans[a-1])

[print(i) for i in k]
Buggy python submission (verdict: Runtime Error):
from statistics import mode
n = int(input())
a = list(input())
b = list(input())
c = list(input())
ans = 0
for i in range(n):
    k = [a[i], b[i], c[i]]
    if len(set(k)) != 3:
        flag = mode(k)
        ans += 3-k.count(flag)
    else:
        ans += 2

print(ans)


Fixed submission:
n = int(input())
a = list(input())
b = list(input())
c = list(input())
ans = 0
for i in range(n):
    k = [a[i], b[i], c[i]]
    ans += len(set(k))-1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

dp = [0]*N
dp[1] = abs(H[1]-H[0])

for i in range(2,N):
    tmp = 10**9
    for j in range(1,min(i,K)+1):
        tmp = min(tmp,abs(H[i]-H[i-j])+dp[i-j])
    dp[i] = tmp

print(dp[-1])


Fixed submission:
N,K = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]

INF = 10**20
dp = [0]*N
dp[0] = 0

for k in range(1,N):
    tmp = []
    for i in range(min(k,K)):
        tmp.append(dp[k-i-1]+abs(H[k]-H[k-i-1]))
    dp[k] = min(tmp)
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,x = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

if x < min(A):
    print(0)
    exit()

A.sort()
ans = 0
i = 0
while x > 0 and ans < N:
    if x >= A[i]:
        x -= A[i]
        ans += 1
        i += 1

if x > 0:
    ans -= 1

print(ans)


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

li.sort()
ans = 0

for i in range(n):
    x = x-li[i]
    if x < 0:
        ans = i
        break
    ans = i+1

if x > 0:
    ans -=1

print(ans)
Buggy python submission (verdict: Runtime Error):
N,X = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]

P = [0]*N
P[0] = abs(min(L) - X)
for i in range(1,N):
    P[i] = abs(L[i]-L[i-1])

def gcd( x, y ):
    while y != 0:
        x, y = y, x%y
    return x

ans = gcd(P[0],P[1])

for i in range(2,N):
    ans = gcd(ans,P[i])

print(ans)


Fixed submission:
N,X = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]

if N == 1:
    print(abs(L[0]-X))
else:
    P = [0]*N
    P[0] = abs(min(L) - X)
    for i in range(1,N):
        P[i] = abs(L[i]-L[i-1])

    def gcd( x, y ):
        while y != 0:
            x, y = y, x%y
        return x

    ans = gcd(P[0],P[1])

    for i in range(2,N):
        ans = gcd(ans,P[i])

    print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())

l = [[]for _ in range(a)]
m = [[]for _ in range(b)]

for i in range(a):
    l[i] = list(input())
    for j in range(b):
        m[j].append(l[i][j])

p = []
for i in range(a):
    if l[i].count('.') == b:
        p.append(i)

q = []
for i in range(b):
    if m[i].count('.') == a:
        q.append(i)

count=0
for i in p:
    l.pop(i-count)
    count+=1

count=0
for i in q:
    for j in range(len(l)):
        l[j].pop(i-count)
        count+=1

for i in range(len(l)):
    for j in l[i]:
        print(j,end='')
    print()


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

p = ['.']*W
while p in L:
    L.remove(p)
    H -= 1

L2 = [[0]*H for _ in range(W)]
for h in range(H):
    for w in range(W):
        L2[w][h] = L[h][w]


q = ['.']*H
while q in L2:
    L2.remove(q)
    W -= 1

ans = [[0]*W for _ in range(H)]
for h in range(H):
    for w in range(W):
        print(L2[w][h], end="")
    print()
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())

if K == 1:
    print(S[0])
    exit()
else:
    for i in range(K):
        if S[i] != '1':
            print(S{i})
            exit()
print(1)


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

p = 0
for i in s:
    if p == k-1:
        print(i)
        exit()
    if i != '1':
        print(i)
        exit()
    p += 1
print(i)
Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
count=0

for i in range(n-1):
    if li[i] == li[i+1]:
        li[i+1] = li[i]*li[i+2]+1
        count += 1

print(count)


Fixed submission:
n = int(input())
li = list(map(int,input().split()))
count=0

for i in range(n-1):
    if li[i] == li[i+1]:
        li[i+1] = 0
        count += 1

print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int,input().split()))

m = []
for i in range(n):
    m.append(l[i]-i)

b = set(m)
max = 0
index = 0
for i in b:
    if max < m.count(i):
        max = m.count(i)
        index = i

ans = 0
for i in range(n):
    ans += abs(l[i]-index-i)

print(ans)


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

m = []
for i in range(n):
    m.append(l[i]-i-1)

m.sort()
index = n//2

b = m[index]

ans = 0
for i in range(n):
    ans += abs(l[i]-b-i-1)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

N = int(input())
A = [int(i) for i in input().split()]

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if not factor:
        return [n]
    else:
        factor.append(n)
        return factor

ans = 0
for i in A:
    ans += trial_division(i).count(2)

print(ans)


Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
for i in A:
    while True:
        if i%2 == 0:
            ans += 1
            i /= 2
        else:
            break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

B = [0] + list(accumulate(A))

ans = 0
for i in set(B):
    p = Counter(B)[i]
    ans += p*(p-1)//2

print(ans)


Fixed submission:
from itertools import accumulate
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

B = [0] + list(accumulate(A))
C = Counter(B)

ans = 0
for i in set(B):
    p = C[i]
    ans += p*(p-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

ans = 0

for i in range(N):
    for j in range(i,N+1):
        if i != j:
            if sum(A[i:j]) == 0:
                ans += 1

print(ans)


Fixed submission:
from itertools import accumulate
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

B = [0] + list(accumulate(A))
C = Counter(B)

ans = 0
for i in set(B):
    p = C[i]
    ans += p*(p-1)//2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = [int(i) for i in input().split()]

m_r = N//2
m_l = m_r-1

A = sorted(X)

for i in range(N):
    if A.index(X[i]) >= m_r:
        print(A[m_l])
    else:
        print(A[m_r])


Fixed submission:
N = int(input())
X = [int(i) for i in input().split()]

A = sorted(X)

m_r = A[N//2]
m_l = A[N//2-1]

for i in range(N):
    if X[i] >= m_r:
        print(m_l)
    else:
        print(m_r)