Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):

s = input()

q = int(input())


for i in range(q):
    li = input().split()
    if li[0] == "2":
        if li[1] =="1":
            s = li[2] + s

        else:
            s = s + li[2]

    else:
        s = s[::-1]

print(s)


Fixed submission:

s = input()

q = int(input())
x = []
y = []

flag = 0

for i in range(q):
    li = list(input().split())
    if flag%2 == 0:
        if li[0] == "2":
            if li[1] =="1":
                x.append(li[2])
            else:
                y.append(li[2])
        else:
            flag += 1

    else:
        if li[0] == "2":
            if li[1] =="1":
                y.append(li[2])
            else:
                x.append(li[2])
        else:
            flag += 1

if flag%2 == 0:
    x = x[::-1]
    print("".join(x)+s+"".join(y))

else:
    s = s[::-1]
    y = y[::-1]
    print("".join(y)+s+"".join(x))

Buggy python submission (verdict: Time Limit Exceeded):

s = input()

q = int(input())


for i in range(q):
    li = input().split()
    if li[0] == "2":
        if li[1] =="1":
            s = li[2] + s

        elif li[1] == "2":
            s = s + li[2]

    elif li[0] == "1":
        s = s[::-1]

print(s)


Fixed submission:

s = input()

q = int(input())
x = []
y = []

flag = 0

for i in range(q):
    li = list(input().split())
    if flag%2 == 0:
        if li[0] == "2":
            if li[1] =="1":
                x.append(li[2])
            else:
                y.append(li[2])
        else:
            flag += 1

    else:
        if li[0] == "2":
            if li[1] =="1":
                y.append(li[2])
            else:
                x.append(li[2])
        else:
            flag += 1

if flag%2 == 0:
    x = x[::-1]
    print("".join(x)+s+"".join(y))

else:
    s = s[::-1]
    y = y[::-1]
    print("".join(y)+s+"".join(x))

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

q = int(input())

for i in range(q):
    li = list(map(str, input().split()))
    if li[0] == "2":
        if li[1] =="1":
            s = li[2] + s

        elif li[1] == "2":
            s = s + li[2]

    elif li[0] == "1":
        s = s[::-1]

print(s)





Fixed submission:

s = input()

q = int(input())
x = []
y = []

flag = 0

for i in range(q):
    li = list(input().split())
    if flag%2 == 0:
        if li[0] == "2":
            if li[1] =="1":
                x.append(li[2])
            else:
                y.append(li[2])
        else:
            flag += 1

    else:
        if li[0] == "2":
            if li[1] =="1":
                y.append(li[2])
            else:
                x.append(li[2])
        else:
            flag += 1

if flag%2 == 0:
    x = x[::-1]
    print("".join(x)+s+"".join(y))

else:
    s = s[::-1]
    y = y[::-1]
    print("".join(y)+s+"".join(x))
Buggy python submission (verdict: Runtime Error):
s=input()

if 12<int(s[:2]):
    if 12>=int(s[2:])>=1:
        print("YYMM")
    else:
        print("NA")
else:
    if 12>=int(s[2:])>=1:
        print("AMBIGUOUS")
    elif 12<s[2:]:
        print("MMYY")
      


    


Fixed submission:
s=input()

if 12<int(s[:2]) or 0==int(s[:2]):
    if 12>=int(s[2:])>=1:
        print("YYMM")
    else:
        print("NA")
elif 1<=int(s[:2])<=12:
    if 12>=int(s[2:])>=1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())

v=list(map(int,input().split()))
c=list(map(int,input().split()))

x=0
for i in range(2**n):
    cost=0
    value=0
    for j in range(n):
        if i>>j&1:
            cost+=c[j]
            value+=v[j]
    else:
        if value-cost>x:
            x=value-cost
            


print(x)
         

Fixed submission:
n=int(input())

v=list(map(int,input().split()))
c=list(map(int,input().split()))

ans=0
for i in range(n):
    if v[i]-c[i]>=1:
        ans+=v[i]-c[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
li=[]
for i in range(5):
    li.append(int(input()))

min=9

for i in range(5):
    if min> li[i]%10 >0:
        min=li[i]%10
        min_f=i

cnt=0

for i in range(5):
    if i==min_f:
        continue
    if li[i]%10==0:
        cnt+=li[i]
    else:
        cnt+=li[i]+10-li[i]%10
print(cnt+li[min_f])

Fixed submission:
li=[]
for i in range(5):
    li.append(int(input()))

min=9

min_f=0

for i in range(5):
    if min> li[i]%10 >0:
        min=li[i]%10
        min_f=i

cnt=0

for i in range(5):
    if i==min_f:
        continue
    if li[i]%10==0:
        cnt+=li[i]
    else:
        cnt+=li[i]+10-li[i]%10
print(cnt+li[min_f])
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=[]

cnt=0
k=0
flag=0
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())

for j in range(n-m+1):
    k=0
    for i in range(n-m+1):
        if b[k]==a[i][j:j+m]:
            k+=1
            if k==m:
                print("Yes")
                flag+=1

if flag==0:
    print("No")



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

cnt=0
k=0
flag=0
for i in range(n):
    a.append(input())
for i in range(m):
    b.append(input())

for j in range(n-m+1):
    k=0
    for i in range(n-m+1):
        if b[k]==a[i][j:j+m]:
            k+=1
            if k==m:
                print("Yes")
                flag+=1
                break
    else:
        continue
    break


if flag==0:
    print("No")
Buggy python submission (verdict: Runtime Error):
x=int(input())

if x>0:
    if x%11>5:
        ans=(x//11)*2+2


    elif 1<=x%11<=5:
        ans=(x//11)*2+1
else:
    ans==(x//11)*2

print(ans)

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

Buggy python submission (verdict: Runtime Error):
x=int(input())

if x>0:
    if x%11>5:
        ans=(x//11)*2+2


    elif 1<=x%11<=5:
        ans=(x//11)*2+1
else:
    ans==(x//11)*2

print(ans)

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

Buggy python submission (verdict: Runtime Error):
x=int(input())

if x>0:
    if x%11>5:
        ans=(x//11)*2+2


    elif 1<=x%11<=5:
        ans=(x//11)*2+1

print(ans)

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

Buggy python submission (verdict: Runtime Error):
x=int(input())


if x>0:
    if x%11>5:
        ans=(x//11)*2+2

    elif 1<=x%11<=5:
        ans=(x//11)*2+1

print(ans)

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

Buggy python submission (verdict: Runtime Error):
x=int(input())


if x>0:
    if x%11>=6:
        ans=(x//11)*2+2

    elif 1<=x%11<=5:
        ans=(x//11)*2+1


print(ans)

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

Buggy python submission (verdict: Runtime Error):
x=int(input())


if x>0:
    if x%11>=7:
        ans=(x//11)*2+2

    elif 1<=x%11<=6:
        ans=(x//11)*2+1


print(ans)

Fixed submission:
x = int(input())
 
ans = (x//11)*2
remainder = x%11
if remainder == 0:
    print(ans)
elif 1 <= remainder <= 6:
    print(ans+1)
else:
    print(ans+2)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
flag=0

if n%2==0:
    b=list(range(1,n,2))
    for i in range(n//2):
        if a.count(b[i])!=2:
            print("0")
            flag+=1
            break
if n%2==1:
    c=list(range(0,n,2))
    for i in range(n//2):
        if i==0:
            if a.count(c[i])!=1:
                print("0")
                flag+=1
                break

        else:
            if a.count(c[i])!=2:
                print("0")
                flag+=1
                break
        
if flag==0:
    print(2**(n//2)%(10**9+7))

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
flag=0
A=a.sort()
num=[]

if n%2==0:
    for i in range(1,n,2):
        num.append(i)
        num.append(i)

if n%2==1:
    num=[0]
    for i in range(2,n,2):
        num.append(i)
        num.append(i)

if num==a:
    print(2**(n//2)%(10**9+7))

else:
    print("0")
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d=input().split()
x=int(x)
k=int(k)
d=int(d)
i=1
while i*d<=abs(x):
  i+=1
if k<=i-1:
  print(abs(x)-d*k)
else:
  if (k-(i-1))%2==0:
    print(abs(x)-d*(i-1))
  else:
    print(abs(abs(x)-d*(i)))

Fixed submission:
x,k,d=input().split()
x=abs(int(x))
k=int(k)
d=int(d)
a=x//d
b=x-a*d
c=(x-b)/d
i=int(c)
if k<=i:
  print(abs(x)-d*k)
else:
  if (k-(i))%2==0:
    print(abs(x)-d*(i))
  else:
    print(abs(abs(x)-d*(i+1)))

Buggy python submission (verdict: Time Limit Exceeded):
x,k,d=input().split()
x=int(x)
k=int(k)
d=int(d)
for i in range(k):
  if x>0:
    x=x-d
  else:
    x=x+d
print(abs(x))

Fixed submission:
x,k,d=input().split()
x=abs(int(x))
k=int(k)
d=int(d)
a=x//d
b=x-a*d
c=(x-b)/d
i=int(c)
if k<=i:
  print(abs(x)-d*k)
else:
  if (k-(i))%2==0:
    print(abs(x)-d*(i))
  else:
    print(abs(abs(x)-d*(i+1)))
Buggy python submission (verdict: Runtime Error):
N,D=input().split()
n=int(N)
d=int(D)
count=0
for i in range(n):
  X,Y=input().split()
  x=int(X)
  y=int(Y)
  distance=x*x+y*y
  if distance<=d*d:
    count+=1
print(count)

Fixed submission:
x=int(input())
if x>=30:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
li=[]
red=0
white=0
count=0
li=list(input())
for i in li:
  if i == 'R':
    red+=1
  else:
    white+=1
while True:
  for i in range(red):
    checkw=-1
    if li[i]=='W':
      checkw=i
      break
  for i in range(white):
    checkr=-1
    if li[i+red]=='R':
      checkr=i
      break
  if checkw!=-1 and checkr!=-1:
    li[checkw]='R'
    li[red+checkr]='W'
    count+=1
  elif checkw!=-1:
    li[checkw]='R'
    count+=1
  elif checkr!=-1:
    li[red+checkr]='W'
    count+=1
  else:
    break
print(count)
    
  

Fixed submission:
n=int(input())
li=[]
red=0
white=0
count=0
li=list(input())
for i in li:
  if i == 'R':
    red+=1
  else:
    white+=1

checkw=0
for i in range(red):
  if li[i]=='W':
    checkw+=1

checkr=0
for i in range(white):
  if li[i+red]=='R':
    checkr+=1
sa=checkw-checkr
if sa==0:
  print(checkr)
elif sa>0:
  print(checkr+sa)
else:
  print(checkw+sa)
Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
count=0
for x in range(k+1):
    for y in range(x+1):
        for z in range(y+1):
            if x+y+z==s:
                if x==y==z:
                    count+=1
                elif x==y or y==z or z==x:
                    count+=3
                else:
                    count+=6
print(count)







Fixed submission:
k,s=map(int,input().split())
count=0
for x in range(k+1):
    for y in range(x+1):
        if x+y>s:
            continue
        else:
            z=s-x-y
            if z>x or z>y:
              continue
            if x==y==z:
                count+=1
            elif x==y or y==z or z==x:
                count+=3
            else:
                count+=6
print(count)

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

Fixed submission:
k,s=map(int,input().split())
count=0
for x in range(k+1):
    for y in range(x+1):
        if x+y>s:
            continue
        else:
            z=s-x-y
            if z>x or z>y:
              continue
            if x==y==z:
                count+=1
            elif x==y or y==z or z==x:
                count+=3
            else:
                count+=6
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())

for j in range(N):
    B = A[0:j]
    C = A[j+1:N]
    D = B+C
    print(max(D))

Fixed submission:
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())

mx = max(A)
mxidx = A.index(mx)

for i in range(N):
    if i == mxidx:
        B = A[0:i] + A[i+1:N]
        print(max(B))
    else:
        print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N = input().split()
A = list(map(int, input().split()))
ans = 0

for i,j in itertools.combinations(A, 2):
        ans += i * j
    
print(ans % 1000000007)

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

for n, i in enumerate(reversed(A[1:]), 1):
    s += i
    ans += A[N-n-1] * s
    
print(ans % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, C = map(int, input().split())
K = int(input())

while K > 0:
    if A > B:
        B *= 2
        K -= 1
    else:
        if B > C:
            C *= 2
            K -= 1

if A < B and B < C:
    print("Yes")
else:
    print("No")

Fixed submission:
A, B, C = map(int, input().split())
K = int(input())
n = 0

while A >= B:
    B *= 2
    n += 1

while B >= C:
    C *= 2
    n += 1

if n <= K:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
ans = 0

for i in range(n+1):
    if a[i] > k:
        break
    for j in range(m+1):
        if a[i] + b[j] <= k:
            ans = max(ans, i+j)
        
print(ans)

Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans = 0

for i in range(n + 1):
    if a[i] > k:
        break
    while  a[i] + b[m] > k:
        m -= 1
    ans = max(ans, i + m)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
ans = 0

for i in range(n+1):
    for j in range(m+1):
        if a[i] + b[j] <= k:
            ans = max(ans, i+j)
        
print(ans)
            

Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans = 0

for i in range(n + 1):
    if a[i] > k:
        break
    while  a[i] + b[m] > k:
        m -= 1
    ans = max(ans, i + m)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])
ans = 0

for i in range(n+1):
    for j in range(m+1):
        if a[i] + b[j] <= k:
            ans = max(ans, i+j)
        
print(ans)
            

Fixed submission:
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]
for i in range(n):
    a.append(a[i] + A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans = 0

for i in range(n + 1):
    if a[i] > k:
        break
    while  a[i] + b[m] > k:
        m -= 1
    ans = max(ans, i + m)

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

ans = 0    
for i in range(1, N+1):
    for j in range(i, N+1, i):
        ans += j

print(ans)

Fixed submission:
n = int(input())

table = [0] * (n + 1)
    
for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        table[j] += j


print(sum(table))

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

table = [0] * (n + 1)
    
for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        table[j] += j


print(sum(table))

Fixed submission:
n = int(input())

table = [0] * (n + 1)
    
for i in range(1, n + 1):
    for j in range(i, n + 1, i):
        table[j] += j


print(sum(table))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

d = defaultdict(int)

N = input()
A = list(map(int, input().split())) 
for i in A:
    d[i] += 1

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    d[C] += d[B]
    d[B] = 0
    ans = 0
    for i,j in d.items():
        ans += i*j
    print(ans)

Fixed submission:
from collections import defaultdict
 
d = defaultdict(int)
 
N = input()
A = list(map(int, input().split())) 
for i in A:
    d[i] += 1

ans = sum(A)
 
Q = int(input())

for _ in range(Q):
    B, C = map(int, input().split())
    ans = ans - B*d[B] + C*d[B]
    print(ans)
    d[C] += d[B]
    d[B] = 0

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

d = defaultdict(int)

N = input()
A = list(map(int, input().split())) 
for i in A:
    d[i] += 1

Q = int(input())
for _ in range(Q):
    B, C = map(int, input().split())
    d[C] += d[B]
    d[B] = 0
    ans = 0
    for i,j in d.items():
        ans += i*j
    print(ans)

Fixed submission:
from collections import defaultdict
 
d = defaultdict(int)
 
N = input()
A = list(map(int, input().split())) 
for i in A:
    d[i] += 1

ans = sum(A)
 
Q = int(input())

for _ in range(Q):
    B, C = map(int, input().split())
    ans = ans - B*d[B] + C*d[B]
    print(ans)
    d[C] += d[B]
    d[B] = 0

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

A = list(input().split())

Q = int(input())

for _ in range(Q):
    B, C = input().split()
    A = [s.replace(B, C) for s in A]
    print(sum([int(i) for i in A]))

Fixed submission:
from collections import defaultdict
 
d = defaultdict(int)
 
N = input()
A = list(map(int, input().split())) 
for i in A:
    d[i] += 1

ans = sum(A)
 
Q = int(input())

for _ in range(Q):
    B, C = map(int, input().split())
    ans = ans - B*d[B] + C*d[B]
    print(ans)
    d[C] += d[B]
    d[B] = 0

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

A = list(input().split())

Q = int(input())

for _ in range(Q):
    B, C = input().split()
    A = [s.replace(B, C) for s in A]
    print(sum([int(i) for i in A]))

Fixed submission:
from collections import defaultdict
 
d = defaultdict(int)
 
N = input()
A = list(map(int, input().split())) 
for i in A:
    d[i] += 1

ans = sum(A)
 
Q = int(input())

for _ in range(Q):
    B, C = map(int, input().split())
    ans = ans - B*d[B] + C*d[B]
    print(ans)
    d[C] += d[B]
    d[B] = 0
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
 
xor = 0
for i in A:
    A ^= i
 
for j in range(N):
    print(A^a[i], end=' ')


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
xor = 0
for i in A:
    xor ^= i
 
for j in range(N):
    print(xor^A[j], end=' ')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted(list(map(int, input().split()))) + [0]
 
memo = ['Y'] * (10**6+1)
count = 0
 
for i in range(N):
    if memo[A[i]] == 'N':
        continue
    for j in range(A[i], max(A)+1, A[i]):
        memo[j] = 'N'
    if A[i] == A[i+1]:
        continue
    
    count += 1
 
print(count)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
max = A[-1]
memo = ['Yes'] * (10**6+1)
ans = 0
 
for i, A_i in enumerate(A):
    if memo[A_i] == 'No':
        continue
    for j in range(A_i, max+1, A_i):
        memo[j] = 'No'
    if i != N-1 and A_i == A[i+1]:
        continue
    ans += 1
 
print(ans)

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

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

if N == 1:
    print(1)
    sys.exit()
max = A[-1]
memo = ['Yes'] * (10**6+1)
ans = 0
 
for i, A_i in enumerate(A):
    if memo[A_i] == 'No':
        continue
    for j in range(A_i, max+1, A_i):
        memo[j] = 'No'
    if A_i == A[i+1]:
        continue
    ans += 1
 
print(ans)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
max = A[-1]
memo = ['Yes'] * (10**6+1)
ans = 0
 
for i, A_i in enumerate(A):
    if memo[A_i] == 'No':
        continue
    for j in range(A_i, max+1, A_i):
        memo[j] = 'No'
    if i != N-1 and A_i == A[i+1]:
        continue
    ans += 1
 
print(ans)

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

N = int(input())

A = list(map(int, input().split()))
A = [x for x in set(A) if A.count(x) == 1]
if len(A) <= 1:
    print(len(A))
    sys.exit()

A = np.array(sorted(A))
B = np.array([A[0]])
 
for i in range(len(A)-1):
    if np.all(A[i+1] % B != 0):
        B = np.append(B, A[i+1])
print(len(B))

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
max = A[-1]
memo = ['Yes'] * (10**6+1)
ans = 0
 
for i, A_i in enumerate(A):
    if memo[A_i] == 'No':
        continue
    for j in range(A_i, max+1, A_i):
        memo[j] = 'No'
    if i != N-1 and A_i == A[i+1]:
        continue
    ans += 1
 
print(ans)

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

N = int(input())

if N == 1:
    print(1)
    sys.exit()
    
A = sorted(set(map(int, input().split())))

if len(A) == 1:
    print(0)
    sys.exit()
    
max = A[-1]
memo = ['Y'] * (10**6+1)
ans = 0
 
for i, A_i in enumerate(A):
    if memo[A_i] == 'N':
        continue
    for j in range(A_i, max+1, A_i):
        memo[j] = 'N'
    if i != N-1 and A_i == A[i+1]:
        continue
    ans += 1
    
print(ans)

Fixed submission:
N = int(input())
A = sorted(list(map(int, input().split())))
max = A[-1]
memo = ['Yes'] * (10**6+1)
ans = 0
 
for i, A_i in enumerate(A):
    if memo[A_i] == 'No':
        continue
    for j in range(A_i, max+1, A_i):
        memo[j] = 'No'
    if i != N-1 and A_i == A[i+1]:
        continue
    ans += 1
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
A = list(map(int, input().split()))
ans = 1

for i in A:
    ans *=i
    
if ans > 10**18:
    print(-1)
else:
    print(ans)


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

for i in A:
    if i == 0: 
        ans = 0
        break
    elif ans > 10**18:
        break
    else:
        ans *=i

if ans > 10**18:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
T = input()
ans = 0

if T[0] == "?":
    if T[1] == "P":
        ans = "D"
    else:
        ans = "P"
else:
    ans = T[0]

for i in range(len(T)-1):
    if T[i+1] == "?":
        if ans[i]  == "P":
            ans += "D"
        else:
            if T[i+2] == "P":
                ans += "D"
            else:
                ans += "P"
    else:
        ans += T[i+1]
        
print(ans)

Fixed submission:
T = input()
ans = 0

if T[0] == "?":
    if len(T) == 1:
        ans = "D"
    elif T[1] == "D":
        ans = "P"
    else:
        ans = "D"
else:
    ans = T[0]

for i in range(len(T)-2):
    if T[i+1] == "?":
        if ans[i]  == "P":
            ans += "D"
        else:
            if T[i+2] == "P":
                ans += "D"
            else:
                ans += "P"
    else:
        ans += T[i+1]

if len(T) > 1:
    if T[-1] == "?":
        ans += "D"
    else:
        ans += T[-1]
            
print(ans)