Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n,m=list(map(int,input().split()))

if n+1 < 2*m:
    print(0)
else:
    a = [int(input()) for _ in range(m)]

    pre2 = 0
    pre1 = 0
    cur = 1
    a_id = 0

    for i in range(n):
        pre2 = pre1
        pre1 = cur 
        cur = pre1 + pre2
        if i+1 == a[a_id]:
            a_id += 1 if a_id < m-1 else 0
            cur = 0
        if cur == 0 and pre1 == 0:
            break
    print(cur%1000000007)

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

if n+1 < 2*m:
    print(0)
else:
    a = [int(input()) for _ in range(m)]

    pre2 = 0
    pre1 = 0
    cur = 1
    a_id = 0

    for i in range(n):
        pre2 = pre1
        pre1 = cur 
        cur = pre1 + pre2
        if a_id < m:
            if i+1 == a[a_id]:
                a_id += 1 if a_id < m-1 else 0
                cur = 0
        if cur == 0 and pre1 == 0:
            break
    print(cur%1000000007)

Buggy python submission (verdict: Runtime Error):
n,m=list(map(int,input().split()))
a = [int(input()) for _ in range(m)]

pre2 = 0
pre1 = 0
cur = 1
a_id = 0

for i in range(n):
    pre2 = pre1
    pre1 = cur 
    cur = pre1 + pre2
    if i+1 == a[a_id]:
        a_id += 1 if a_id < m-1 else 0
        cur = 0
    if cur == 0 and pre1 == 0:
        break
print(cur%1000000007)

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

if n+1 < 2*m:
    print(0)
else:
    a = [int(input()) for _ in range(m)]

    pre2 = 0
    pre1 = 0
    cur = 1
    a_id = 0

    for i in range(n):
        pre2 = pre1
        pre1 = cur 
        cur = pre1 + pre2
        if a_id < m:
            if i+1 == a[a_id]:
                a_id += 1 if a_id < m-1 else 0
                cur = 0
        if cur == 0 and pre1 == 0:
            break
    print(cur%1000000007)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=list(map(int,input().split()))
a = [int(input()) for _ in range(m)]

pre2 = 0
pre1 = 0
cur = 1

for i in range(n):
    pre2 = pre1
    pre1 = cur 
    cur = pre1 + pre2
    if i+1 in a:
        cur = 0
    if cur == 0 and pre1 == 0:
        break
print(cur%1000000007)

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

if n+1 < 2*m:
    print(0)
else:
    a = [int(input()) for _ in range(m)]

    pre2 = 0
    pre1 = 0
    cur = 1
    a_id = 0

    for i in range(n):
        pre2 = pre1
        pre1 = cur 
        cur = pre1 + pre2
        if a_id < m:
            if i+1 == a[a_id]:
                a_id += 1 if a_id < m-1 else 0
                cur = 0
        if cur == 0 and pre1 == 0:
            break
    print(cur%1000000007)
Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
v=[0]+list(map(int,input().split()))+[0]

ans=0

getl_sum=0
for lc in range(min(51,k+1)):
    getl_sum += v[lc]
    getr_sum =0
    for rc in range(min(51-lc,k-lc+1)):
        getr_sum += v[-rc-1]
        get = v[:lc] + v[-rc-1:]
        get.sort()
        get_sum = getl_sum + getr_sum
        ans = max(ans,get_sum)
        for bc in range(min(lc+rc,k-lc-rc)):
            get_sum-=get[bc]
            ans = max(ans,get_sum)
print(ans)

Fixed submission:
n,k=map(int,input().split())
v=[0]+list(map(int,input().split()))+[0]

ans=0

getl_sum=0
for lc in range(min(n,k)+1):
    getl_sum += v[lc]
    getr_sum =0
    for rc in range(min(n,k)-lc+1):
        getr_sum += v[-rc-1]
        get = v[:lc] + v[-rc-1:]
        get.sort()
        get_sum = getl_sum + getr_sum
        ans = max(ans,get_sum)
        for bc in range(min(lc+rc,k-lc-rc)):
            get_sum-=get[bc]
            ans = max(ans,get_sum)
print(ans)
Buggy python submission (verdict: Runtime Error):
M,K = map(int,input().split())

num = 2**(M+1)

if K >= num//2 or (M==1 and K==1):
    print(-1)
else:
    ans = [0]*num
    for i in range(2**M):
        if i==K: continue
        ans[i-(i>K)] = i
        ans[num-2-i+(i>K)] = i
    ans[num//2-1] = K
    ans[-1] = K
    
print(*ans)

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

num = 2**(M+1)

if K >= num//2 or (M==1 and K==1):
    ans = [-1]
elif M==1 and K==0:
    ans = [0,0,1,1]
else:
    ans = [0]*num
    for i in range(2**M):
        if i==K: continue
        ans[i-(i>K)] = i
        ans[num-2-i+(i>K)] = i
    ans[num//2-1] = K
    ans[-1] = K
    
print(*ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))
c=list(map(int,input().split()))
s = 0
for i in range(n):
    s += max(0,v[i]-c[i])
print(s)

Fixed submission:
a,b,t=map(int,input().split())
print((t//a)*b)
Buggy python submission (verdict: Runtime Error):
def count(n,x):
    if x<=n:
        return 0
    elif x>=2**(n+2)-2-n:
        return 2**(n+1)-1
    elif 2**(n+2)-3 > 2*x:
        return count(n-1,x-1)
    else:
        return 2**n + count(n-1,x-2**(n+1)+1)

n,x=map(int,input().split())
print(count(n,x))

Fixed submission:
def count(n,x):
    if x<=n:
        return 0
    elif x>=2**(n+2)-3-n:
        return 2**(n+1)-1
    elif 2**(n+2)-3 > 2*x:
        return count(n-1,x-1)
    else:
        return 2**n + count(n-1,x-2**(n+1)+1)

n,x=map(int,input().split())
print(count(n,x))

Buggy python submission (verdict: Runtime Error):
def count(n,x):
    print(n,x)
    if x<=n:
        return 0
    elif x>=2**(n+2)-2-n:
        return 2**(n+1)-1
    elif 2**(n+2)-3 > 2*x:
        return count(n-1,x-1)
    else:
        return 2**n + count(n-1,x-2**(n+1)+1)

n,x=map(int,input().split())
print(count(n,x))

Fixed submission:
def count(n,x):
    if x<=n:
        return 0
    elif x>=2**(n+2)-3-n:
        return 2**(n+1)-1
    elif 2**(n+2)-3 > 2*x:
        return count(n-1,x-1)
    else:
        return 2**n + count(n-1,x-2**(n+1)+1)

n,x=map(int,input().split())
print(count(n,x))

Buggy python submission (verdict: Runtime Error):
def count(n,x):
    if x<=n:
        return 0
    elif 2**(n+2)-3 > 2*x:
        return count(n-1,x-1)
    else:
        return 2**n + count(n-1,x-2**(n+1)+1)

n,x=map(int,input().split())
print(count(n,x))

Fixed submission:
def count(n,x):
    if x<=n:
        return 0
    elif x>=2**(n+2)-3-n:
        return 2**(n+1)-1
    elif 2**(n+2)-3 > 2*x:
        return count(n-1,x-1)
    else:
        return 2**n + count(n-1,x-2**(n+1)+1)

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

cs={}
for i,c in enumerate(s):
    cs[c] = cs.get(c,[])+[i]

ct={}
for i,c in enumerate(t):
    ct[c] = ct.get(c,[])+[i]

print('Yes' if sorted(list(ct.values()),key=lambda x:x[0])==sorted(list(cs.values()),key=lambda x:x[0]) else 'No')

Fixed submission:
import collections

s=input()
t=input()

cs = collections.Counter(s)
ct = collections.Counter(t)

print('Yes' if sorted(list(ct.values()))==sorted(list(cs.values())) else 'No')

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
t=input()

cs={}
for i,c in enumerate(s):
    cs[c] = cs.get(c,[])+[i]

ct={}
for i,c in enumerate(t):
    ct[c] = ct.get(c,[])+[i]

print('Yes' if sorted(list(ct.values()))==sorted(list(cs.values())) else 'No')

Fixed submission:
import collections

s=input()
t=input()

cs = collections.Counter(s)
ct = collections.Counter(t)

print('Yes' if sorted(list(ct.values()))==sorted(list(cs.values())) else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 10**9+7

s=input()
Anum = 0
ABnum = 0
ABCnum = 0
q = 0
for c in s:
    if c == 'A':
        Anum = (Anum+3**q)%MOD
    elif c == 'B':
        ABnum = (ABnum+Anum)%MOD
    elif c == 'C':
        ABCnum = (ABCnum+ABnum)%MOD
    else:
        Anum,ABnum,ABCnum = 3*Anum+3**q,3*ABnum+Anum,3*ABCnum+ABnum
        Anum,ABnum,ABCnum = Anum%MOD,ABnum%MOD,ABCnum%MOD
        q += 1
print(ABCnum)


Fixed submission:
MOD = 10**9+7

s=input()
Anum = 0
ABnum = 0
ABCnum = 0
q = 0
for c in s:
    if c == 'A':
        Anum = (Anum+pow(3,q,MOD))%MOD
    elif c == 'B':
        ABnum = (ABnum+Anum)%MOD
    elif c == 'C':
        ABCnum = (ABCnum+ABnum)%MOD
    else:
        Anum,ABnum,ABCnum = 3*Anum+pow(3,q,MOD),3*ABnum+Anum,3*ABCnum+ABnum
        Anum,ABnum,ABCnum = Anum%MOD,ABnum%MOD,ABCnum%MOD
        q += 1
print(ABCnum)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect

n=int(input())
a=list(map(int,input().split()))

a2=[]

for i in range(n):
    temp = a[i]-(i+1)
    index = bisect(a2,temp)
    a2.insert(index,temp)

ans = sum( abs(x - a2[n//2]) for x in a2)
print(ans)

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

a2 = [ x-i for i,x in enumerate(a)]
a2.sort()

ans = sum( abs(x - a2[n//2]) for x in a2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = tuple(map(int,input().split()))
x_sort = sorted(x,reverse=True)
for i in range(n):
    print(x_sort[n//2] if x_sort.index(x[i]) < n//2 else x_sort[n//2-1])

Fixed submission:
n = int(input())
x = tuple(map(int,input().split()))
x_sort = sorted(x,reverse=True)
x_median = x_sort[n//2-1]
x_median2 = x_sort[n//2]
for i in range(n):
    print(x_median2 if x[i] > x_median2 else x_median)
Buggy python submission (verdict: Runtime Error):
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
from itertools import permutations

n,m,r = map(int,input().split())
rr = np.array(list(map(int,input().split()))) - 1

L = np.zeros((m,m),int)
for _ in range(m):
    a,b,c = map(int,input().split())
    L[a-1,b-1] = c

shortest = floyd_warshall(L, directed = False)

ans = float('inf')

for route in permutations(rr,len(rr)):
    ans = min(ans, shortest[route[:-1],route[1:]].sum())
print(int(ans))

Fixed submission:
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
from itertools import permutations

n,m,r = map(int,input().split())
rr = np.array(list(map(int,input().split()))) - 1

L = np.zeros((n,n),int)
for _ in range(m):
    a,b,c = map(int,input().split())
    L[a-1,b-1] = c

shortest = floyd_warshall(L, directed = False)

ans = float('inf')

for route in permutations(rr,len(rr)):
    ans = min(ans, shortest[route[:-1],route[1:]].sum())
print(int(ans))
Buggy python submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra
import numpy as np

n = int(input())
L = np.zeros((n,n),int)
for _ in range(n-1):
    a,b,c = map(int,input().split())
    L[a-1,b-1] = c

q,k = map(int,input().split())

dist = dijkstra(L,directed = False, indices= k-1).astype(int)

for _ in range(q):
    x,y = map(int,input().split())
    print(dist[x-1] + dist[y-1])

Fixed submission:
from collections import deque

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b,c = map(int,input().split())
    edge[a-1].append((b-1,c))
    edge[b-1].append((a-1,c))

q,k = map(int,input().split())

dist = [float('inf')] * n
visited = [0] * n

dist[k-1] = 0
visited[k-1] = 1
vq = deque([k-1])

while vq:
    
    vs = vq.popleft()
    
    for ve,vc in edge[vs]:
        if visited[ve] == 1: continue
        
        dist[ve] = dist[vs] + vc
        visited[ve] = 1
        vq.append(ve)


for _ in range(q):
    x,y = map(int,input().split())
    print(dist[x-1] + dist[y-1])
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(v,d,dist):
    dist[v] = d
    for ve in edge[v]:
        if dist[ve] is None:
            dist = dfs(ve, d+1, dist)
    return dist
    
    
f_dist = dfs(0,0,[None]*n)
s_dist = dfs(n-1,0,[None]*n)

fget = sum(1 for f,s in zip(f_dist,s_dist) if f<=s)
print("Fennec" if fget*2>n else "Snuke")

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(v,d,dist):
    dist[v] = d
    for ve in edge[v]:
        if dist[ve] is None:
            dist = dfs(ve, d+1, dist)
    return dist
    
    
f_dist = dfs(0,0,[None]*n)
s_dist = dfs(n-1,0,[None]*n)

fget = sum(1 for f,s in zip(f_dist,s_dist) if f<=s)
print("Fennec" if fget*2>n else "Snuke")

Buggy python submission (verdict: Runtime Error):
n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(v,d,dist):
    dist[v] = d
    for ve in edge[v]:
        if dist[ve] is None:
            dist = dfs(ve, d+1, dist)
    return dist
    
    
f_dist = dfs(0,0,[None]*n)
s_dist = dfs(n-1,0,[None]*n)

fget = sum(1 for f,s in zip(f_dist,s_dist) if f<=s)
print("Fennec" if fget*2>n else "Snuke")

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(v,d,dist):
    dist[v] = d
    for ve in edge[v]:
        if dist[ve] is None:
            dist = dfs(ve, d+1, dist)
    return dist
    
    
f_dist = dfs(0,0,[None]*n)
s_dist = dfs(n-1,0,[None]*n)

fget = sum(1 for f,s in zip(f_dist,s_dist) if f<=s)
print("Fennec" if fget*2>n else "Snuke")

Buggy python submission (verdict: Runtime Error):
def dfs(v,d,dist,edge):
    dist[v] = d
    for ve in edge[v]:
        if dist[ve] is None:
            dist = dfs(ve, d+1, dist, edge)
    return dist

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

    
f_dist = dfs(0,0,[None]*n,edge)
s_dist = dfs(n-1,0,[None]*n,edge)

fget = sum(1 for f,s in zip(f_dist,s_dist) if f<=s)
print("Fennec" if fget*2>n else "Snuke")

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n = int(input())
edge = [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

def dfs(v,d,dist):
    dist[v] = d
    for ve in edge[v]:
        if dist[ve] is None:
            dist = dfs(ve, d+1, dist)
    return dist
    
    
f_dist = dfs(0,0,[None]*n)
s_dist = dfs(n-1,0,[None]*n)

fget = sum(1 for f,s in zip(f_dist,s_dist) if f<=s)
print("Fennec" if fget*2>n else "Snuke")
Buggy python submission (verdict: Time Limit Exceeded):
n,W = map(int,input().split())

dp = [[[0]*(3*n+1) for _ in range(n)] for _ in range(n)]

w1,v1 = map(int,input().split())
for i in range(3*n+1):
    dp[0][0][i] = v1

for i in range(1,n):
    w,v = map(int,input().split())
    w -= w1
    for j in range(n):
        for k in range(3*n+1):
            if j>0 and k>=w:
                dp[i][j][k] = max(dp[i-1][j][k], dp[i-1][j-1][k-w] + v)
            elif k>=w:
                dp[i][0][k] = max(dp[i-1][0][k], v)
            else:
                dp[i][j][k] = dp[i-1][j][k]

ans = 0
for i in range(n):
    for j in range(3*n+1):
        if w1*(i+1) + j>W: continue
        ans = max(ans,dp[-1][i][j])

print(ans)

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

dp = [[[0]*(3*n+1) for _ in range(n)] for _ in range(n)]

w1,v1 = map(int,input().split())
for i in range(3*n+1):
    dp[0][0][i] = v1

for i in range(1,n):
    w,v = map(int,input().split())
    w -= w1
    for j in range(min(i+1,n)):
        for k in range(3*n+1):
            if j>0 and k>=w:
                dp[i][j][k] = max(dp[i-1][j][k], dp[i-1][j-1][k-w] + v)
            elif k>=w:
                dp[i][0][k] = max(dp[i-1][0][k], v)
            else:
                dp[i][j][k] = dp[i-1][j][k]

ans = 0
for i in range(n):
    for j in range(3*n+1):
        if w1*(i+1) + j>W: continue
        ans = max(ans,dp[-1][i][j])

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,ma,mb = map(int,input().split())

INF = 10**4
dp = [[[INF] * (n*10+1) for _ in range(n*10+1)] for _ in range(n+1)]
dp[0][0][0] = 0

for i in range(n):
    a,b,c = map(int,input().split())
    for ai in range(n*10):
        for bi in range(n*10):
            if ai>=a and bi>=b:
                tmp = dp[i][ai-a][bi-b] + c
            else:
                tmp = INF
            dp[i+1][ai][bi] = min(dp[i][ai][bi], tmp)

ans = min(dp[n][ma*i][mb*i] for i in range(1,n*10//max(ma,mb)+1) )
if ans == INF: ans = -1
    
print(ans)

Fixed submission:
n,ma,mb = map(int,input().split())

INF = 10**4
dp = [[[INF] * (n*10+1) for _ in range(n*10+1)] for _ in range(n+1)]
dp[0][0][0] = 0

for i in range(n):
    a,b,c = map(int,input().split())
    for ai in range(i*10+11):
        for bi in range(i*10+11):
            if ai>=a and bi>=b:
                tmp = dp[i][ai-a][bi-b] + c
            else:
                tmp = INF
            dp[i+1][ai][bi] = min(dp[i][ai][bi], tmp)

ans = min(dp[n][ma*i][mb*i] for i in range(1,n*10//max(ma,mb)+1) )
if ans == INF: ans = -1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().rstrip().split(" "))
P = list(map(int,input().rstrip().split(" ")))
C = list(map(int,input().rstrip().split(" ")))
check = [False for _ in range(N)]
ans = -(10 ** 15)
for i in range(N):
    kans = 0
    score = [0]
    nex = P[i] -1
    while True:
        score.append(score[-1] + C[nex])
        nex = P[nex] - 1
        if nex == P[i] -1:
            break;
    if score[-1] > 0:
        kans = score[-1] * (K // (len(score) -1)) + max(score[1:K % (len(score) -1) + 1])
    else:
        kans = max(score[1:min(len(score) - 1,K) + 1])
    ans = max(ans,kans)
print(ans)

Fixed submission:
N,K = map(int,input().rstrip().split(" "))
P = list(map(int,input().rstrip().split(" ")))
C = list(map(int,input().rstrip().split(" ")))

ans = -(10 ** 15)
for i in range(N):
    kans = 0
    score = [0]
    nex = P[i] -1
    while True:
        score.append(score[-1] + C[nex])
        nex = P[nex] - 1
        if nex == P[i] -1:
            break;

    if score[-1] > 0:
        if score[1:(K % (len(score) -1)) + 1] != []:
            kans = score[-1] * (K // (len(score) -1)) + max(score[1:(K % (len(score) -1)) + 1])
        else:
            kans = score[-1] * ((K // (len(score) -1)) - 1) + max(score)
    else:
        if score[1:min(len(score) - 1,K) + 1] != []:
            kans = max(score[1:min(len(score) - 1,K) + 1])
        else:
            kans = -(10 ** 15)
    ans = max(ans,kans)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().rstrip().split(" ")))
bit = [0 for i in range(32)]
for i in range(32):
    for i2 in A:
        if (i2 >> i) & 1:
            bit[i] += 1
ans = [0 for i in range(len(A))]
for i in range(32):
    for i2 in range(len(A)):
        if bit[i] % 2 == 0:
            if (A[i2] >> i) & 1:
                ans[i2] += 2 ** i
        else:
            if not (A[i2] >> i) & 1:
                ans[i2] += 2 ** i
print(" ".join(map(str,ans)))

Fixed submission:
N = int(input())
A = list(map(int,input().rstrip().split(" ")))
bit = [0 for i in range(32)]
for i in range(32):
    for i2 in A:
        if (i2 >> i) & 1:
            bit[i] += 1
ans = [0 for i in range(len(A))]
for i in range(32):
    for i2 in range(len(A)):
        if bit[i] % 2 == 0:
            if (A[i2] >> i) & 1:
                ans[i2] += 2 ** i
        else:
            if not (A[i2] >> i) & 1:
                ans[i2] += 2 ** i
print(" ".join(map(str,ans)))
Buggy python submission (verdict: Runtime Error):
N = int(input())
nokori = N
kaburi = set()
ans = 0
A = list(map(int,input().rstrip().split(" ")))
A2 = set()
rem = set()
for i in A:
    if i in A2:
        kaburi.add(i)
    else:
        A2.add(i)
for i in kaburi:
    A2.remove(i)
for i in kaburi:
    k = i
    for i2 in A2:
        if i2 % k == 0:
            rem.add(i2)
    for i2 in rem:
        A2.remove(rem)
    rem.clear()
while len(A2) != 0:
    i = min(A2)
    ans += 1
    for i2 in A2:
        if i2 % i == 0:
            rem.add(i2)
    for i2 in rem:
        A2.remove(i2)
    rem.clear()
print(ans)

Fixed submission:
N = int(input())
ans = 0
A = list(map(int,input().rstrip().split(" ")))
A.sort()
A2 = [True for i in range(A[-1] + 1)]
for i in range(len(A)):
    k = A[i] * 2
    if A2[A[i]]:
        if i != 0 and A[i-1] == A[i]:
            A2[A[i]] = False
        while(k < len(A2)):
            A2[k] = False
            k += A[i]
for i in A:
    if A2[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
nokori = N
kaburi = set()
ans = 0
A = list(map(int,input().rstrip().split(" ")))
A2 = set()
for i in A:
    if i in A2:
        kaburi.add(i)
    else:
        A2.add(i)
for i in kaburi:
    A2.remove(i)
for i in kaburi:
    k = i
    for i2 in A2:
        if i2 % K == 0:
            A2.remove(i2)
while len(A2) != 0:
    i = min(A2)
    ans += 1
    k = i
    for i2 in A2:
        if i2 % K == 0:
            A2.remove(i2)
print(ans)

Fixed submission:
N = int(input())
ans = 0
A = list(map(int,input().rstrip().split(" ")))
A.sort()
A2 = [True for i in range(A[-1] + 1)]
for i in range(len(A)):
    k = A[i] * 2
    if A2[A[i]]:
        if i != 0 and A[i-1] == A[i]:
            A2[A[i]] = False
        while(k < len(A2)):
            A2[k] = False
            k += A[i]
for i in A:
    if A2[i]:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
nokori = N
kaburi = set()
ans = 0
A = list(map(int,input().rstrip().split(" ")))
A2 = set()
for i in A:
    if i in A2:
        kaburi.add(i)
    else:
        A2.add(i)
for i in kaburi:
    A2.remove(i)
for i in kaburi:
    k = i * 2
    while k < 1000000:
        A2.discard(k)
        k += i
while len(A2) != 0:
    i = min(A2)
    ans += 1
    k = i
    while k < 1000000:
        A2.discard(k)
        k += i
print(ans)

Fixed submission:
N = int(input())
ans = 0
A = list(map(int,input().rstrip().split(" ")))
A.sort()
A2 = [True for i in range(A[-1] + 1)]
for i in range(len(A)):
    k = A[i] * 2
    if A2[A[i]]:
        if i != 0 and A[i-1] == A[i]:
            A2[A[i]] = False
        while(k < len(A2)):
            A2[k] = False
            k += A[i]
for i in A:
    if A2[i]:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
A,V = map(int,input().rstrip().split(" "))
B,W = map(int,input().rstrip().split(" "))
T = int(input())
if(V <= W):
    print("NO")
else:
    if(abs(A - B) <= (V - W) * T):
        print("YES")
    else:
        Print("NO")

Fixed submission:
A,V = map(int,input().rstrip().split(" "))
B,W = map(int,input().rstrip().split(" "))
T = int(input())
if(abs(A - B) <= (V - W) * T):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
N =int(input())
A = list(map(int,input().rstrip().split(" ")))
Aq = []
DP = [0 for i in range(2 * 10 ** 5)]
DPP = []
ans = 0
for i in range(N):
    if i >= A[i]:
        ans += DP[i - A[i]]
    if A[i] <= N:
        DP[A[i] + i] += 1
    
print(ans)

Fixed submission:
N =int(input())
A = list(map(int,input().rstrip().split(" ")))
Aq = []
DP = [0 for i in range(5 * 10 ** 5)]
DPP = []
ans = 0
for i in range(N):
    if i >= A[i]:
        ans += DP[i - A[i]]
    if A[i] <= N:
        DP[A[i] + i] += 1
    
print(ans)

Buggy python submission (verdict: Runtime Error):
N =int(input())
A = list(map(int,input().rstrip().split(" ")))
Aq = []
DP = [0 for i in range(10 ** 5)]
DPP = []
ans = 0
for i in range(N):
    if i >= A[i]:
        ans += DP[i - A[i]] 
    DP[A[i] + i] += 1
    
print(ans)

Fixed submission:
N =int(input())
A = list(map(int,input().rstrip().split(" ")))
Aq = []
DP = [0 for i in range(5 * 10 ** 5)]
DPP = []
ans = 0
for i in range(N):
    if i >= A[i]:
        ans += DP[i - A[i]]
    if A[i] <= N:
        DP[A[i] + i] += 1
    
print(ans)