Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
input()
A = list(map(int,input().split(' ')))
num = 1
for i in A:
    num *= i
print(-1 if num>1000000000000000000 else num)

Fixed submission:
N = input()
A = list(map(int,input().split(' ')))
if 0 in A:
    print(0)
    exit()
x = 1
for a in A:
    x *= a
    if x > 1000000000000000000:
        print(-1)
        exit()
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
input()
A = list(map(int,input().split(' ')))
x = A[0]
for a in A[1::]:
    x=x*a
    A.pop(0) 
if x > 1000000000000000000:
    print(-1)
else:
    print(x)

Fixed submission:
N = input()
A = list(map(int,input().split(' ')))
if 0 in A:
    print(0)
    exit()
x = 1
for a in A:
    x *= a
    if x > 1000000000000000000:
        print(-1)
        exit()
print(x)

Buggy python submission (verdict: Time Limit Exceeded):
input()
A = list(map(int,input().split(' ')))
if 0 in A:
    print(0)
else:
    x=A[0]
    for a in A[1::]:
        x=x*a
    if x > 1000000000000000000:
        print(-1)
    else:
        print(x)

Fixed submission:
N = input()
A = list(map(int,input().split(' ')))
if 0 in A:
    print(0)
    exit()
x = 1
for a in A:
    x *= a
    if x > 1000000000000000000:
        print(-1)
        exit()
print(x)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)
_ = input()
h = list(map(int, input().split()))
inf = float('inf')
dp = [inf] * len(h)

def rec_opt(i):
    if dp[i] < inf:
        return dp[i]
    if i == 0:
        return 0
    elif i ==1:
        return abs(h[0] - h[1])
    else:
        ans = min(inf, rec_opt(i-1) + abs(h[i] - h[i-1]))
        if i > 1:
            ans = min(ans, rec_opt(i-2) + abs(h[i] - h[i-2]))
        dp[i] = ans
    return dp[i]
print(rec_opt(len(h)-1))

Fixed submission:
_ = int(input())
h = list(map(int, input().split()))

opt = [0] * len(h)
opt[1] = abs(h[0]-h[1])

for i in range(2,len(h)):
    A = opt[i-1] + abs(h[i-1] - h[i])
    B = opt[i-2] + abs(h[i-2] - h[i])
    opt[i] = min(A, B)

print(opt[len(h)-1])

Buggy python submission (verdict: Runtime Error):
_ = int(input())
h = list(map(int, input().split()))
inf = float('inf')
dp = [inf] * len(h)

def rec_opt(i):
    if dp[i] < inf:
        return dp[i]
    if i == 0:
        return 0
    elif i ==1:
        return abs(h[0] - h[1])
    else:
        ans = min(inf, rec_opt(i-1) + abs(h[i] - h[i-1]))
        if i > 1:
            ans = min(ans, rec_opt(i-2) + abs(h[i] - h[i-2]))
        dp[i] = ans
    return dp[i]
print(rec_opt(len(h)-1))

Fixed submission:
_ = int(input())
h = list(map(int, input().split()))

opt = [0] * len(h)
opt[1] = abs(h[0]-h[1])

for i in range(2,len(h)):
    A = opt[i-1] + abs(h[i-1] - h[i])
    B = opt[i-2] + abs(h[i-2] - h[i])
    opt[i] = min(A, B)

print(opt[len(h)-1])
Buggy python submission (verdict: Time Limit Exceeded):
_, k = map(int, input().split())
h = list(map(int, input().split()))

opt = [0] * len(h)
for i in range(1,len(h)):
    opt[i] = min([opt[i-j] + abs(h[i-j] - h[i]) for j in range(1,min(i,k)+1)])
print(opt[-1])

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

opt = [0]
for i in range(1,n):
    opt += [min([opt[-j] + abs(h[i-j] - h[i]) for j in range(1,min(i,k)+1)])]
print(opt[-1])

Buggy python submission (verdict: Time Limit Exceeded):
_, k = map(int, input().split())
h = list(map(int, input().split()))

opt = [0] * len(h)
opt[1] = abs(h[0]-h[1])

for i in range(2,len(h)):
    opt[i] = min([opt[i-j] + abs(h[i-j] - h[i]) for j in range(1,k+1) if i-j >= 0])
print(opt[len(h)-1])

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

opt = [0]
for i in range(1,n):
    opt += [min([opt[-j] + abs(h[i-j] - h[i]) for j in range(1,min(i,k)+1)])]
print(opt[-1])

Buggy python submission (verdict: Time Limit Exceeded):
_, k = map(int, input().split())
h = list(map(int, input().split()))

opt = [0] * len(h)
opt[1] = abs(h[0]-h[1])

for i in range(2,len(h)):
    res = float('inf')
    for j in range(1,k+1):
        if (i-j) >= 0:
            res = min(res, opt[i-j] + abs(h[i-j] - h[i]))
    opt[i] = res

print(opt[len(h)-1])

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

opt = [0]
for i in range(1,n):
    opt += [min([opt[-j] + abs(h[i-j] - h[i]) for j in range(1,min(i,k)+1)])]
print(opt[-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
dp = [0] * (W + 1)

for _ in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        tmp = dp[j-w] + v
        if tmp > dp[j]:
            dp[j] = tmp
print(dp[-1])

Fixed submission:
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
dp = [0] * (W + 1)
def dp_opt(n, w):
    for _ in range(N):
        w, v = map(int, input().split())
        for j in range(W, w-1, -1):
            tmp = dp[j-w] + v
            if tmp > dp[j]:
                dp[j] = tmp
    print(dp[-1])
dp_opt(N,W)

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
dp = [0] * (W + 1)

for i in range(N):
    w, v = map(int, input().split())
    for j in range(W, w-1, -1):
        tmp = dp[j-w] + v
        if tmp > dp[j]:
            dp[j] = tmp
print(dp[-1])

Fixed submission:
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
dp = [0] * (W + 1)
def dp_opt(n, w):
    for _ in range(N):
        w, v = map(int, input().split())
        for j in range(W, w-1, -1):
            tmp = dp[j-w] + v
            if tmp > dp[j]:
                dp[j] = tmp
    print(dp[-1])
dp_opt(N,W)
Buggy python submission (verdict: Runtime Error):
#include <stdio.h>

int main()
{
    int N, a, b, c;
    long Y, yn;

    scanf("%d", &N);
    scanf("%ld", &Y);

    Y = Y / 1000;
    yn = Y - N;

    for (c = 0; c <= N; c++) {
        b = (yn - 9 * c) / 4;
        if ((yn - 9 * c) % 4 == 0) {
            a = N - b - c;
            if ((a >= 0) && (yn == 4 * b + 9 * c)) {
                printf("%d %d %d", a, b, c);
                return 0;
            }
        }
    }
    printf("%d %d %d", -1, -1, -1);
    return 0;
}

Fixed submission:
N, Y = map(int, input().split())
Y = Y//1000
for a in range(N+1):
    for b in range(N+1-a):
        if Y == a*10 + b*5 + (N - a - b):
            print(a,b,N-a-b)
            exit(0)
else:
    print(-1,-1,-1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

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

ans = i = j = 0

import bisect

for b in B:
    if b in A:
        b -= 1
    i = len(A[:bisect.bisect_left(A,b)])
    if b in C:
        b += 1
    j = len(C[bisect.bisect_left(C,b):])

    ans += i * j

print(ans)

Fixed submission:
N = int(input())

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

ans = i = j = 0

import bisect

for b in B:
    i = bisect.bisect_left(A,b)
    j = N - bisect.bisect_right(C,b)
    ans += i * j
print(ans)

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

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

ans = i = j = 0

def binary_search(l, p, low):
    if low:
        if len(l) == 1:
            if l[0] < p:
                return 1
            else:
                return 0
        elif l[len(l)//2] < p:
            return len(l[:len(l)//2:]) + binary_search(l[len(l)//2::], p, low)
        else:
            return binary_search(l[:len(l)//2:], p, low) + binary_search(l[len(l)//2::], p, low)
    else:
        if len(l) == 1:
            if l[0] > p:
                return 1
            else:
                return 0
        elif l[len(l)//2] > p:
            return len(l[len(l)//2::]) + binary_search(l[:len(l)//2:], p, low)
        else:
            return binary_search(l[:len(l)//2:], p, low) + binary_search(l[len(l)//2::], p, low)

for b in B:
    i = binary_search(A,b,True)
    j = binary_search(C,b,False)
    ans += i * j

print(ans)

Fixed submission:
N = int(input())

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

ans = i = j = 0

import bisect

for b in B:
    i = bisect.bisect_left(A,b)
    j = N - bisect.bisect_right(C,b)
    ans += i * j
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for a in A:
    for b in B:
        if a >= b:
            continue
        for c in C:
            if b >= c:
                continue
            else:
                ans += 1
print(ans)

Fixed submission:
N = int(input())

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

ans = i = j = 0

import bisect

for b in B:
    i = bisect.bisect_left(A,b)
    j = N - bisect.bisect_right(C,b)
    ans += i * j
print(ans)
Buggy python submission (verdict: Runtime Error):

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

def lcm(x,y):
    return x*y//gcd(x,y)

def f(tmp):
    tmp.sort(reverse=True)
    result=[]
    for i in tmp[1:]:
        if tmp[0]%i == 0:
            tmp.remove(i)
    for i in range(1,len(tmp)):
        result.append(lcm(tmp[0],tmp[i]))
    else:
        if result:
            return result
        else:
            return tmp
if __name__ == "__main__":
    n=int(input())
    t=[]
    for _ in range(n):
        t.append(int(input()))
    t.sort(reverse=True)
    tmp=[]
    for i in range(1,n):
        tmp.append(lcm(t[0],t[i]))
    while len(tmp) > 1:
        tmp=f(tmp)
    if tmp[0] >1000000000000000000:
        print(1000000000000000000)
    else:
        print(tmp[0])


Fixed submission:

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

def lcm(x,y):
    return x*y//gcd(x,y)

def f(tmp):
    tmp.sort(reverse=True)
    result=[]
    for i in tmp[1:]:
        if tmp[0]%i == 0:
            tmp.remove(i)
    for i in range(1,len(tmp)):
        result.append(lcm(tmp[0],tmp[i]))
    else:
        if result:
            return result
        else:
            return tmp
if __name__ == "__main__":
    n=int(input())
    t=[]
    for _ in range(n):
        t.append(int(input()))
    t.sort(reverse=True)
    if len(t)<2:
        print(t[0])
        exit(0)
    tmp=[]
    for i in range(1,n):
        tmp.append(lcm(t[0],t[i]))
    while len(tmp) > 1:
        tmp=f(tmp)
    if tmp[0] >1000000000000000000:
        print(1000000000000000000)
    else:
        print(tmp[0])
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=10**100
x=sum(a)
b=0
for i in a[:-1]:
   b+=i
   x-=i
   ans=min(ans,abs(x-b))
print(ans)

Fixed submission:
a,b=map(int,input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print('Possible')
else:
    print('Impossible')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
cnt = n//2
ans=abs(sum(a[:cnt]) - sum(a[cnt:]))
for i in range(1,cnt):
    if ans > abs(sum(a[:cnt+i]) - sum(a[cnt+i:])):
        ans = abs(sum(a[:cnt+i]) - sum(a[cnt+i:]))
for i in range(1,cnt):
    if ans > abs(sum(a[:cnt-i]) - sum(a[cnt-i:])):
        ans = abs(sum(a[:cnt-i]) - sum(a[cnt-i:]))
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=10**100
x=sum(a)
b=0
for i in a[:-1]:
   b+=i
   x-=i
   ans=min(ans,abs(x-b))
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
cnt = n//2
print(a[:cnt],a[cnt:])
ans=abs(sum(a[:cnt]) - sum(a[cnt:]))

for i in range(1,cnt):
    
    print(a[:cnt+i],a[cnt+i:])
    if ans > abs(sum(a[:cnt+i]) - sum(a[cnt+i:])):
        ans = abs(sum(a[:cnt+i]) - sum(a[cnt+i:]))
for i in range(1,cnt):
    print(a[:cnt-i],a[cnt-i:])
    if ans > abs(sum(a[:cnt-i]) - sum(a[cnt-i:])):
        ans = abs(sum(a[:cnt-i]) - sum(a[cnt-i:]))

print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=10**100
x=sum(a)
b=0
for i in a[:-1]:
   b+=i
   x-=i
   ans=min(ans,abs(x-b))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(input().split())
ans=[]
for i in range(n):
    ans.append(a[i])
    ans.reverse()
print(' '.join(ans))

Fixed submission:
n=int(input())
a=list(input().split())
if n > 3:
    ans=''
    ans += ' '.join(a[::-2])
    if n%2==0:
        ans += ' ' + ' '.join(a[0::2])
    else:
        ans += ' ' + ' '.join(a[1::2])
    print(ans)
else:
    ans=[]
    for i in range(n):
        ans.append(a[i])
        ans.reverse()
    print(' '.join(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a = [int(input()) for _ in range(n)]
a.sort()
for i in range(n):
    if sum(a)%10 == 0:
        if a[i]%10 == 0:
            continue
        else:
            a[i]=0
    else:
        print(sum(a))
        exit(0)
print(0)

Fixed submission:
ans = sum(map(int,input().split()))
print('error' if ans >=10 else ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a = [int(input()) for _ in range(n)]
ans=0
a.sort()
for i in range(n+1):
    if sum(a)%10 == 0:
        if a[i]%10 == 0:
            continue
        else:
            a[i]=0
    else:
        print(sum(a))
        exit(0)
print(0)

Fixed submission:
n=int(input())
a = [int(input()) for _ in range(n)]
ans=0
a.sort()
for i in range(n):
    if sum(a)%10 == 0:
        if a[i]%10 == 0:
            pass
        else:
            a[i]=0
    else:
        print(sum(a))
        exit(0)
print(0)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input().split())
if x in gp1 and y in gp1:
    print('Yes')
elif x in gp2 and y in gp2 :
    print('Yes')
elif x==y==2:
    print('Yes')
else:
    print('No')

Fixed submission:
gp1=[1,3,5,7,8,10,12]
gp2=[4,6,9,11]

x,y=map(int,input().split())
if x in gp1 and y in gp1:
    print('Yes')
elif x in gp2 and y in gp2 :
    print('Yes')
elif x==y==2:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())

for i in range(1,n+1):
    t *= i
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(t))
ans = 1
for _, v in c.items():
    ans *= (v + 1)
print(ans%(10**9+7))

Fixed submission:
import collections
n = int(input())
t = 1
for i in range(1,n+1):
    t *= i
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(t))
ans = 1
for _, v in c.items():
    ans *= (v + 1)
print(ans%(10**9+7))
Buggy python submission (verdict: Time Limit Exceeded):
n,a = map(int,input().split())
x = list(map(int,input().split()))
cnt = 0
for i in range(1 << n):
    ans=[]
    for j in range(n):
        if (i >> j) & 1:
            ans.append(x[j])
    if ans and sum(ans)/len(ans) == a:
        cnt+=1
print(cnt)

Fixed submission:
N,A = map(int,input().split())
X = list(map(int,input().split()))
Y = [x-A for x in X]
dp = {0:1}

for y in Y:
  tmp = list(dp.items())
  for k,v in tmp:
    dp[k+y]=dp.get(k+y,0)+v

print(dp[0]-1)
Buggy python submission (verdict: Runtime Error):
def main():
    k = int(input)

    for _ in range(k):
        print("ACL",end='')
    print()

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    k = int(input())

    for _ in range(k):
        print("ACL",end='')
    print()

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
class SegmentTree():

    def __init__(self,N):
        # N: 処理する区間の長さ
        self.N0 = 2**(N-1).bit_length()
        self.INF = 2**31-1
        self.data = [self.INF]*(2*self.N0)
    # a_k の値を x に更新
    def update(self, k, x):
        k += self.N0-1
        self.data[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.data[k] = min(self.data[2*k+1], self.data[2*k+2])
    # 区間[l, r)の最小値
    def query(self, l, r):
        L = l + self.N0; R = r + self.N0
        s = self.INF
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])

            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

def main():
    n,k = tuple([int(t)for t in input().split()])
    size = 3*10**5
    lst = SegmentTree(size+1)
    for _ in range(n):
        a = int(input())
        l,r = max(a-k,0),min(a+k+1,size+1)
        m = min(lst.query(l,r),0)
        lst.update(a,m-1)

    print(-lst.query(0,3*10**5))

if __name__ == "__main__":
    main()

Fixed submission:
class SegmentTree():

    def __init__(self,N):
        # N: 処理する区間の長さ
        self.N0 = 2**(N-1).bit_length()
        self.INF = 2**31-1
        self.data = [self.INF]*(2*self.N0)
    # a_k の値を x に更新
    def update(self, k, x):
        k += self.N0-1
        self.data[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.data[k] = min(self.data[2*k+1], self.data[2*k+2])
    # 区間[l, r)の最小値
    def query(self, l, r):
        L = l + self.N0; R = r + self.N0
        s = self.INF
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])

            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s

def main():
    n,k = tuple([int(t)for t in input().split()])
    size = 3*10**5
    lst = SegmentTree(size+1)
    for _ in range(n):
        a = int(input())
        l,r = max(a-k,0),min(a+k+1,size+1)
        m = min(lst.query(l,r),0)
        lst.update(a,m-1)

    print(-lst.query(0,3*10**5))

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
    n = input()
    

    if n%9==0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    

    if n%9==0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    ans = [0]*(n+1)
    for p in range(1,n+1):
        for i in range(1,int(p**0.5+1)):
            for j in range(1,int(p**0.5+1)):
                t = (i+j)**2-4*(i**2+j**2+i*j-p)
                if t<0:
                    continue
                k = (t**0.5-i-j)/2
                if k.is_integer() and k>0:
                    ans[p] +=1

    for a in ans[1:]:
        print(a)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    ans = [0]*(n+1)
    for i in range(1,int(n**0.5+1)):
        for j in range(1,int(n**0.5+1)):
            for k in range(1,int(n**0.5+1)):
                t = i**2+j**2+k**2+i*j+j*k+k*i
                if t<=n:
                    ans[t] += 1
    for a in ans[1:]:
        print(a)
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    ans = [0]*(n+1)
    for p in range(1,n+1):
        for i in range(1,p):
            for j in range(1,p):
                if (i+j)**2-4*(i**2+j**2+i*j-p)<0:
                    continue
                k = (((i+j)**2-4*(i**2+j**2+i*j-p))**0.5-i-j)/2
                if k.is_integer() and k>0:
                    ans[p] +=1

    for a in ans[1:]:
        print(a)
if __name__ == "__main__":
    main()

Fixed submission:
def main():
    n = int(input())
    ans = [0]*(n+1)
    for i in range(1,int(n**0.5+1)):
        for j in range(1,int(n**0.5+1)):
            for k in range(1,int(n**0.5+1)):
                t = i**2+j**2+k**2+i*j+j*k+k*i
                if t<=n:
                    ans[t] += 1
    for a in ans[1:]:
        print(a)
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter 

def main():
    n = int(input())

    checker = [False] * (10**6+1)

    a = list([int(t)for t in input().split()])
    c = Counter(a)

    for a_i in a:
        for i in range(a_i*2,10**6+1,a_i):
            checker[i] = True

    ans = 0
    for a_i in a:
        if not checker[a_i] and c[a_i]==1:
            ans += 1

    print(ans)
            
if __name__ == "__main__":
    main()


Fixed submission:
from collections import Counter 

def main():
    n = int(input())
    a = list([int(t)for t in input().split()])
    c = Counter(a)
    checker = [False]*(10**6+1)
    times = [False]*(10**6+1)

    for a_i in a:
        checker[a_i] = True
    ans = 0
    for i in range(1,10**6+1):
        if times[i]:
            continue
        if not checker[i]:
            continue
        if checker[i] and c[i]==1:
            ans+=1
        for j in range(i,10**6+1,i):
            times[j] = True
        
    print(ans)
            
if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter 

def main():
    n = int(input())

    checker = [False] * (10**6+1)

    a = list([int(t)for t in input().split()])
    c = Counter(a)

    for a_i in a:
        for i in range(a_i*2,10**6+1,a_i):
            checker[i] = True

    ans = 0
    for a_i in a:
        if not checker[a_i] and c[a_i]==1:
            ans += 1

    print(ans)
            
if __name__ == "__main__":
    main()


Fixed submission:
from collections import Counter 

def main():
    n = int(input())
    a = list([int(t)for t in input().split()])
    c = Counter(a)
    checker = [False]*(10**6+1)
    times = [False]*(10**6+1)

    for a_i in a:
        checker[a_i] = True
    ans = 0
    for i in range(1,10**6+1):
        if times[i]:
            continue
        if not checker[i]:
            continue
        if checker[i] and c[i]==1:
            ans+=1
        for j in range(i,10**6+1,i):
            times[j] = True
        
    print(ans)
            
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
def main():
    n,k = tuple([int(t)for t in input().split()])

    a = tuple([int(t)for t in input().split()])

    for _ in range(min(41,k)):
        b = [0]*(n+1)
        for i in range(n):
            l = max(0,i-a[i])
            r = min(n,i+a[i]+1)
            b[l] += 1
            b[r] -= 1
        a = list(itertools.accumulate(b))[:n]

    print(*a)



if __name__ == "__main__":
    main()

Fixed submission:
import itertools
def main():
    n,k = tuple([int(t)for t in input().split()])

    a = tuple([int(t)for t in input().split()])

    for _ in range(min(41,k)):
        b = [0]*(n+1)
        for i in range(n):
            l = max(0,i-a[i])
            r = min(n,i+a[i]+1)
            b[l] += 1
            b[r] -= 1
        a = list(itertools.accumulate(b))[:n]

    print(*a)



if __name__ == "__main__":
    main()