Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

def main():
    n, k = map(int, input().split())
    ans = [0 for i in range(n+1)]
    for x in sys.stdin.readlines():
        a, b = map(int, x.split())
        ans[a] += b

    cnt = 0
    for i in range(n+1):
        cnt += ans[i]
        if cnt >= k:
            print(ans[i])

if __name__ == "__main__":
    main()

Fixed submission:
# https://atcoder.jp/contests/abc061/tasks/abc061_c
import sys

def main():
    n, k = map(int, input().split())
    ans = [0 for _ in range(10**5+1)]
    for x in sys.stdin.readlines():
        a, b = map(int, x.split())
        ans[a] += b

    cnt = 0
    for i in range(10**5+1):
        cnt += ans[i]
        if cnt >= k:
            print(i)
            exit()

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    n, k = map(int, input().split())
    ans = [0 for i in range(n+1)]
    for x in sys.stdin.readlines():
        a, b = map(int, x.split())
        ans[a] += b

    cnt = 0
    for i in range(n+1):
        cnt += ans[i]
        if cnt >= k:
            print(ans[i])

if __name__ == "__main__":
    main()

Fixed submission:
# https://atcoder.jp/contests/abc061/tasks/abc061_c
import sys

def main():
    n, k = map(int, input().split())
    ans = [0 for _ in range(10**5+1)]
    for x in sys.stdin.readlines():
        a, b = map(int, x.split())
        ans[a] += b

    cnt = 0
    for i in range(10**5+1):
        cnt += ans[i]
        if cnt >= k:
            print(i)
            exit()

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys

def main():
    n, k = map(int, input().split())
    cnt = 0
    for x in sys.stdin.readlines:
        a, b = map(int, x.split())
        if cnt + b < k:
            cnt += b
        else:
            print(a)
            exit()

if __name__ == "__main__":
    main()

Fixed submission:
# https://atcoder.jp/contests/abc061/tasks/abc061_c
import sys

def main():
    n, k = map(int, input().split())
    ans = [0 for _ in range(10**5+1)]
    for x in sys.stdin.readlines():
        a, b = map(int, x.split())
        ans[a] += b

    cnt = 0
    for i in range(10**5+1):
        cnt += ans[i]
        if cnt >= k:
            print(i)
            exit()

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import math
a, b, c = map(int, input().split())
if math.gcd(a,b) == c:
  print("YES")
else:
  print("NO")

Fixed submission:
a, b, c = map(int, input().split())
print("YES" if any((a*i%b) == c for i in range(1,b+1)) else "NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = len(str(n))
for i in range(1, int(n**(1/2))+1):
  if n%i == 0:
    ans = min(ans, max(len(str(i)), len(str(n//i))))
print(ans)

Fixed submission:
a, b = map(int, input().split())
print((a + b) % 24)
Buggy python submission (verdict: Runtime Error):
a, b = input()
if a == b :
  print("H")
else:
  print("D")

Fixed submission:
a, b = input().split()
if a == b :
  print("H")
else:
  print("D")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 1
for i in range(1,n+1):
  ans *= i
print(ans % (10 **9 + 7))

Fixed submission:
n = int(input())
ans = 1
for i in range(1,n+1):
  ans *= i
  ans %= (10**9 + 7)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    x = int(input())
    s = 0
    f = 0
    ans = 0
    while ans < x:
        s += 1
        ans += 6
        if ans >= x:
            print(s+f)
            exit()
        f += 1
        ans += 5
        if ans >= x:
            print(s+f)
            exit()

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    x = int(input())
    ans = x//11
    chk = x%11
    if chk == 0:
        print(2*ans)
    elif chk <=6:
        print(2*ans+1)
    else:
        print(2*ans+2)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    x = int(input())
    s = 0
    f = 0
    while ans < x:
        s += 1
        tmp = 6*s + 5*f
        if tmp >= x:
            print(s+f)
            exit()
        f += 1
        tmp += 5
        if tmp >= x:
            print(s+f)
            exit()

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    x = int(input())
    ans = x//11
    chk = x%11
    if chk == 0:
        print(2*ans)
    elif chk <=6:
        print(2*ans+1)
    else:
        print(2*ans+2)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
  k, s = map(int, input().split())
  cnt = 0
  for i in range(k+1):
    for j in range(k+1):
      if 0 <= s - i - j <= k:
        cnt += 1
  print(cnt)

if __name__ == "__main__":
    main()

Fixed submission:
s = input().split(",")
print(*s)

Buggy python submission (verdict: Runtime Error):
k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
  if i < s:
    for j in range(k+1):
      if i + j :
        for l in range(k+1):
          if i + j + l == s:
            cnt += 1
print(cnt)

Fixed submission:
s = input().split(",")
print(*s)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
  if i <= s:
    for j in range(k+1):
      if i + j <= s:
        for l in range(k+1):
          if i + j + l == s:
            cnt += 1
print(cnt)

Fixed submission:
def main():
  k, s = map(int, input().split())
  cnt = 0
  for i in range(k+1):
    for j in range(k+1):
      if 0 <= s - i - j <= k:
        cnt += 1
  print(cnt)

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
  if i < s:
    for j in range(k+1):
      if i + j < s:
        for l in range(k+1):
          if i + j + l == s:
            cnt += 1
      elif i + j <= s:
        cnt += 1
  elif i == s:
    cnt += 1
print(cnt)

Fixed submission:
def main():
  k, s = map(int, input().split())
  cnt = 0
  for i in range(k+1):
    for j in range(k+1):
      if 0 <= s - i - j <= k:
        cnt += 1
  print(cnt)

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
  if i <= s:
    for j in range(k+1):
      if i + j <= s:
        for l in range(k+1):
          if i + j + l == s:
            cnt += 1
print(cnt)

Fixed submission:
def main():
  k, s = map(int, input().split())
  cnt = 0
  for i in range(k+1):
    for j in range(k+1):
      if 0 <= s - i - j <= k:
        cnt += 1
  print(cnt)

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i + j + l == s:
        cnt += 1
print(cnt)

Fixed submission:
def main():
  k, s = map(int, input().split())
  cnt = 0
  for i in range(k+1):
    for j in range(k+1):
      if 0 <= s - i - j <= k:
        cnt += 1
  print(cnt)

if __name__ == "__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
cnt = 0
for i in range(k+1):
  for j in range(k+1):
    if s < i + j:
      break
    for l in range(k+1):
      if i + j + l == s:
        cnt += 1
print(cnt)

Fixed submission:
def main():
  k, s = map(int, input().split())
  cnt = 0
  for i in range(k+1):
    for j in range(k+1):
      if 0 <= s - i - j <= k:
        cnt += 1
  print(cnt)

if __name__ == "__main__":
  main()
Buggy python submission (verdict: Runtime Error):
def main():
    x, y = map(int, input().split())
    print(min(max(y-x, x-y+2), abs(x+y)+1)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    x, y = map(int, input().split())
    print(min(abs(x+y), abs(~x+y))+1)
if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def main():
    x, y = map(int, input().split())
    print(min(max(x+y, y-x+2), abs(x+y)+1)
if __name__ == '__main__':
    main()

Fixed submission:
def main():
    x, y = map(int, input().split())
    print(min(abs(x+y), abs(~x+y))+1)
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
m = 10**9+7
n = int(input())
a = list(map(int, input().split()))
check = 0
for i in set(a):
  if n%2 == 1:
    if i == 0 and a.count(i) == 1:
      pass
    elif i%2 == 0 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()
  else:
    if i%2 == 1 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()

print(2**(n//2)%m)

Fixed submission:
m = 10**9+7
n = int(input())
a = list(map(int, input().split()))
check = True
if n%2 == 0:
    if 0 in a or len(set(a)) != n//2:
      check = False
else:
    if len([0 for i in a if i==0]) != 1 or len(set(a)) != n//2+1:
      check = False
      
if check:
  print(2**(n//2)%m)
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
m = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
check = 0
for i in set(a):
  if n%2 == 1:
    if i == 0 and a.count(i) == 1:
      pass
    elif i%2 == 0 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()
  else:
    if i%2 == 1 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()

print(2**(n//2)%m)

Fixed submission:
m = 10**9+7
n = int(input())
a = list(map(int, input().split()))
check = True
if n%2 == 0:
    if 0 in a or len(set(a)) != n//2:
      check = False
else:
    if len([0 for i in a if i==0]) != 1 or len(set(a)) != n//2+1:
      check = False
      
if check:
  print(2**(n//2)%m)
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
check = 0
for i in set(a):
  if n%2 == 1:
    if i == 0 and a.count(i) == 1:
      pass
    elif i%2 == 0 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()
  else:
    if i%2 == 1 and a.count(i) == 2:
      pass
    else:
      print(0)
      exit()

print(2**(n//2))

Fixed submission:
m = 10**9+7
n = int(input())
a = list(map(int, input().split()))
check = True
if n%2 == 0:
    if 0 in a or len(set(a)) != n//2:
      check = False
else:
    if len([0 for i in a if i==0]) != 1 or len(set(a)) != n//2+1:
      check = False
      
if check:
  print(2**(n//2)%m)
else:
  print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = []
cnt = 0
for i in range(1, int(n**0.7)+3):
    if n > cnt:
        ans.append(i)
        cnt += i
    else:
        if cnt - n in ans:
            ans.remove(cnt - n)
            break
for i in ans:
    print(i)

Fixed submission:
n = int(input())
ans = []
cnt = 0
for i in range(1, int(n**0.7)+3):
    if n > cnt:
        ans.append(i)
        cnt += i
    else:
        if cnt - n in ans:
            ans.remove(cnt - n)
        break
for i in ans:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    x = input()
    tmp = x.replace("ST", "")
    for i in range(10**6):
        if x == tmp:
            break
        x = tmp
        tmp = tmp.replace("ST", "")
    print(len(x))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    x = input()
    s, t = 0, 0
    for i in x:
        if i == "S":
            s += 1
        else:
            if s:
                s -= 1
            else:
                t += 1
    print(s + t)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    x = input()
    tmp = x.replace("ST", "")
    for i in range(10**6):
        if x == tmp:
            break
        x = tmp
        tmp = tmp.replace("ST", "")
    print(len(x))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    x = input()
    s, t = 0, 0
    for i in x:
        if i == "S":
            s += 1
        else:
            if s:
                s -= 1
            else:
                t += 1
    print(s + t)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    x = input()
    tmp = x.replace("ST", "")
    while x != tmp:
        x = tmp
        tmp = tmp.replace("ST", "")
    print(len(x))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    x = input()
    s, t = 0, 0
    for i in x:
        if i == "S":
            s += 1
        else:
            if s:
                s -= 1
            else:
                t += 1
    print(s + t)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    x = input()
    tmp = x.replace("ST", "")
    while x != tmp:
        x = tmp
        tmp = tmp.replace("ST", "")
    print(len(x))

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    x = input()
    s, t = 0, 0
    for i in x:
        if i == "S":
            s += 1
        else:
            if s:
                s -= 1
            else:
                t += 1
    print(s + t)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n, k, x, y = (input() for i in range(4))
print(min(n, k) * x + max(0, n - k) * y)

Fixed submission:
n, k, x, y = (int(input()) for i in range(4))
print(min(n, k) * x + max(0, n - k) * y)
Buggy python submission (verdict: Runtime Error):
w = input()
print("Yes" if all[s.count(i)%2 == 0 for i in set(s)] else "No")

Fixed submission:
w = input()
print("Yes" if all([w.count(i)%2 == 0 for i in set(w)]) else "No")
Buggy python submission (verdict: Time Limit Exceeded):
a, b = map(int, input().split())
ans = 1
for i in range(a, b+1):
  ans *= i
if ans < 0:
  print("Negative")
elif ans > 0:
  print("Positive")
else:
  print("Zero")

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

if a<=0 and 0<=b:
  print("Zero")  
elif a < 0 and min(b-a,-a)%2 == 0:
  print("Negative")
else:
  print("Positive")
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

ans=0
for i in range(1,N):
  for j in range(1,N):
    if i*j<N:
      ans+=1
    else:
      break
print(ans)

Fixed submission:
N=int(input())

ans=0
for i in range(1,N):
  for j in range(1,N):
    if i*j<N:
      ans+=1
    else:
      break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
A=list(map(int,input().split()))

ans=[0]*(N-K)

tmp=1
before_score=0
for i in range(0,N):
  tmp*=A[i]
  if i>=K-1:
    if i>=K:
      print('Yes' if before_score<tmp else 'No')
      
    before_score=tmp
    tmp//=A[i-K+1]


    

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


tmp=1
before_score=0
for i in range(K,N):
  if i>=K-1:
    if i>=K:
      print('Yes' if A[i-K]<A[i] else 'No')
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
list.sort(A)

l=[]
n=A.pop()
n2=A.pop()
sum=n
comfort={n2:[[n,n2],[n2,n]]}

while A:
  max=sorted(comfort.keys())[-1]
  if comfort.get(max)==None:print(0)
  n=comfort[max].pop()
  if comfort[max]==[]:del comfort[max]
  sum+=max
  n2=A.pop()
  if comfort.get(min(n[0],n2))==None:comfort[min(n[0],n2)]=[]
  if comfort.get(min(n[1],n2))==None:comfort[min(n[1],n2)]=[]
  comfort[min(n[0],n2)].append([n[0],n2])
  comfort[min(n[1],n2)].append([n[1],n2])
print(sum)

Fixed submission:
input()
A=list(map(int,input().split()))
A.sort(reverse=True)
B=[]
ans=0
for i in A:
  if len(B)>=1:
    ans+=B[len(B)//2]
  B.append(i)
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
list.sort(A)

l=[]
n=A.pop()
n2=A.pop()
sum=n
comfort={n2:[[n,n2],[n2,n]]}

while A:
  max=sorted(comfort.keys())[-1]
  n=comfort[max].pop()
  sum+=max
  n2=A.pop()
  if comfort.get(min(n[0],n2))==None:comfort[min(n[0],n2)]=[]
  if comfort.get(min(n[1],n2))==None:comfort[min(n[1],n2)]=[]
  comfort[min(n[0],n2)].append([n[0],n2])
  comfort[min(n[1],n2)].append([n[1],n2])
print(sum)

Fixed submission:
input()
A=list(map(int,input().split()))
A.sort(reverse=True)
B=[]
ans=0
for i in A:
  if len(B)>=1:
    ans+=B[len(B)//2]
  B.append(i)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
d=deque(A)


l=[]
if K%2==0 or (K%2==1 and A[0]>0):
  for i in range(K//2):
    if d[0]*d[1]>=d[-1]*d[-2] and d[2]>0:
      l.append(d.popleft())
      l.append(d.popleft())
    else:
      l.append(d.pop())
      l.append(d.pop())
  if K%2==1:
    l.append(d[0])
else:
  for i in range(K):
    l.append(d.popleft())
      
ans=1
for i in l:
  ans*=i
print(ans%(10**9+7))

Fixed submission:
from collections import deque
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
d=deque(A)
import time
l=[]
if K%2==0 or (K%2==1 and A[0]>=0):
  for i in range(K//2):
    if d[0]*d[1]>d[-1]*d[-2] and (i==K//2-1 or (len(d)>2 and  d[2]>0)):
      l.append(d.popleft())
      l.append(d.popleft())
    else:
      l.append(d.pop())
      l.append(d.pop())
  if K%2==1:
    l.append(d[0])
else:
  for i in range(K):
    l.append(d.popleft())
      
ans=1
for i in l:
  ans*=i
  ans%=10**9+7
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
lastday=[-1]*26
def last(d):
  sum=0
  for i in range(26):
    sum+=c[i]*(d-lastday[i])
  return sum

def myFunc(i,Score,depth,lastday):
  tmp_score=Score
  tmp_max_choice=0
  tmp_score-=last(i)
  tmp_max_score=tmp_score
  tmp_deep_score=tmp_score
  
  for k,j in enumerate(s[i]):
    if depth==0 or i==D-1:      
      if tmp_max_score<tmp_score+j+c[k]*(i-lastday[k]):
        tmp_max_choice=k
        tmp_max_score=tmp_score+j+c[k]*(i-lastday[k])
    else:
      l=lastday.copy()
      l[k]=i
      score,choice=myFunc(i+1,tmp_score+j+c[k]*(i-lastday[k]),depth-1,l)
      if tmp_deep_score<score:
        tmp_max_choice=k
        tmp_max_score=tmp_score+j+c[k]*(i-lastday[k])
        tmp_deep_score=score

  return tmp_max_score,tmp_max_choice

D=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(D):
  s.append(list(map(int,input().split())))
Score=0
for i in range(D):
  score,choice=myFunc(i,Score,2,lastday)
  Score=score
  lastday[choice]=i
  print(choice+1)


Fixed submission:
for i in range(365):
  print(i%26+1)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N=int(input())
A=list(map(int,input().split()))
Adic={}
for i in A:
  if Adic.get(i)==None:
    Adic[i]=1
  else:
    Adic[i]+=1
Q=int(input())
ope=[]

for i in range(Q):
  ope.append(list(map(int,input().split())))

A=np.array(A)

for b,c in ope:
  if Adic.get(b)!=None:
    if Adic.get(c)==None:Adic[c]=0
    Adic[c]+=Adic.pop(b)
  sum=0
  for key,value in Adic.items():
    sum+=key*value
  print(sum)

Fixed submission:
import numpy as np

N=int(input())
A=list(map(int,input().split()))
Adic={}
for i in A:
  if Adic.get(i)==None:
    Adic[i]=1
  else:
    Adic[i]+=1
Q=int(input())
ope=[]

for i in range(Q):
  ope.append(list(map(int,input().split())))

A=np.array(A)

sum=0
for key,value in Adic.items():
  sum+=key*value
for b,c in ope:
  if Adic.get(b)!=None:
    if Adic.get(c)==None:Adic[c]=0
    sum=sum-b*Adic[b]+c*Adic[b]
    Adic[c]+=Adic.pop(b)
    print(sum)
  else:
    print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
ope=[]
for i in range(Q):
  ope.append(list(map(int,input().split())))
ope=np.array(ope)
A=np.array(A)

for b,c in ope:
  A[A==b]=c
  print(np.sum(A))


Fixed submission:
import numpy as np

N=int(input())
A=list(map(int,input().split()))
Adic={}
for i in A:
  if Adic.get(i)==None:
    Adic[i]=1
  else:
    Adic[i]+=1
Q=int(input())
ope=[]

for i in range(Q):
  ope.append(list(map(int,input().split())))

A=np.array(A)

sum=0
for key,value in Adic.items():
  sum+=key*value
for b,c in ope:
  if Adic.get(b)!=None:
    if Adic.get(c)==None:Adic[c]=0
    sum=sum-b*Adic[b]+c*Adic[b]
    Adic[c]+=Adic.pop(b)
    print(sum)
  else:
    print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
ope=[]
for i in range(Q):
  ope.append(list(map(int,input().split())))

A=np.array(A)
for b,c in ope:
  A[A==b]=c
  print(sum(A))


Fixed submission:
import numpy as np

N=int(input())
A=list(map(int,input().split()))
Adic={}
for i in A:
  if Adic.get(i)==None:
    Adic[i]=1
  else:
    Adic[i]+=1
Q=int(input())
ope=[]

for i in range(Q):
  ope.append(list(map(int,input().split())))

A=np.array(A)

sum=0
for key,value in Adic.items():
  sum+=key*value
for b,c in ope:
  if Adic.get(b)!=None:
    if Adic.get(c)==None:Adic[c]=0
    sum=sum-b*Adic[b]+c*Adic[b]
    Adic[c]+=Adic.pop(b)
    print(sum)
  else:
    print(sum)
Buggy python submission (verdict: Runtime Error):
import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  for x in ans:
  if x not in p:
    print(x)
    exit()
  ans+=[-1,1]
    


Fixed submission:
import numpy as np
X,N=map(int,input().split())
p=np.array(list(map(int,input().split())))
ans=np.array([X,X])
while True:
  if ans[0] not in p:
    print(ans[0])
    exit()
  if ans[1] not in p:
    print(ans[1])
    exit()
  ans+=[-1,1]
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))

A.sort()

dp=[False]*(10**6)
ans=0
for idx,i in enumerate(A):
  if dp[i]:continue
  tmp=i
  ans+=1
  while tmp<10**6:
    dp[tmp]=True
    tmp+=i
  if idx!=len(A)-1 and A[idx+1]==i:
    ans-=1
print(ans)

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

A.sort()

dp=[False]*(10**6*2)
ans=0
for idx,i in enumerate(A):
  if dp[i]:continue
  tmp=i
  ans+=1
  while tmp<10**6*2-1:
    dp[tmp]=True
    tmp+=i
  if idx!=len(A)-1 and A[idx+1]==i:
    ans-=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
A.sort()

dp=[False]*(10**6)
ans=0
for i in A:
  if dp[i]:continue
  tmp=i
  ans+=1
  while tmp>10**6:
    dp[tmp]=True
    tmp+=i
print(ans)

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

A.sort()

dp=[False]*(10**6*2)
ans=0
for idx,i in enumerate(A):
  if dp[i]:continue
  tmp=i
  ans+=1
  while tmp<10**6*2-1:
    dp[tmp]=True
    tmp+=i
  if idx!=len(A)-1 and A[idx+1]==i:
    ans-=1
print(ans)

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

sum=0
while A:
  if len(A)==1 or A[0]!=A[1]:
    sum+=1
  B=A.copy()
  for j in range(len(A)):
    if A[j]%A[0]==0:
      B.remove(A[j])
  A=B
print(sum)    
  

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

A.sort()

dp=[False]*(10**6*2)
ans=0
for idx,i in enumerate(A):
  if dp[i]:continue
  tmp=i
  ans+=1
  while tmp<10**6*2-1:
    dp[tmp]=True
    tmp+=i
  if idx!=len(A)-1 and A[idx+1]==i:
    ans-=1
print(ans)