TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
x,n=map(int,input().split())
r=[i-x for i in map(int,input())]
i=1
while True:
  if not -i in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
  else:
    i+=1

x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
i=1
while True:
  if not -i in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
  else:
    i+=1


x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
for i in range(100):
  if not -i in r:
    print(x-i)
  elif not i in r:
    print(x+i)


x,n=map(int,input().split())
r=[i-x for i in map(int,input())]
for i in range(100):
  if not -i in r:
    print(x-i)
  elif not i in r:
    print(x+i)

x,n=map(int,input().split())
r=[i-x for i in map(int,input())]
for i in range(100):
  if not -(i+1) in r:
    print(x-i-1)
    break
  elif not i+1 in r:
    print(x+i+1)
    break

x,n=map(int,input().split())
r=[i-x for i in map(int,input())]
for i in range(100):
  if not -(i+1) in r:
    print(x-i)
  elif not (i+1) in r:
    print(x+i)


x,n=map(int,input().split())
r=[i-x for i in map(int,input().split())]
for i in range(n+1):
  if not -(i) in r:
    print(x-i)
    break
  elif not i in r:
    print(x+i)
    break


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
import numpy as np
X,N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
  min_val = 0
  max_val = 101
  not_p = [i for i in range(min_val,max_val+1,1)]
  
  for i in range(N):
    not_p.remove(p[i])
  print(not_p)

  min_val = 999
  out_num = 101
  for i in range(len(not_p)):
    if abs(X-not_p[i]) < min_val:
      min_val = abs(X-not_p[i])
      out_num = not_p[i]
  print(out_num)
else:
  out_num = 0


import numpy as np
X,N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
  min_val = 0
  max_val = 101
  not_p = [i for i in range(min_val,max_val+1,1)]
  print(not_p)
  for i in range(N):
    not_p.remove(p[i])

  min_val = 999
  out_num = 101
  for i in range(len(not_p)):
    if abs(X-not_p[i]) < min_val:
      min_val = abs(X-not_p[i])
      out_num = not_p[i]
else:
  out_num = 0
print(out_num)


import numpy as np
X,N = map(int, input().split())
if N != 0:
  p = list(map(int, input().split()))
  min_val = 0
  max_val = 101
  not_p = [i for i in range(min_val,max_val+1,1)]
  
  for i in range(N):
    not_p.remove(p[i])
  print(not_p)

  min_val = 999
  out_num = 101
  for i in range(len(not_p)):
    if abs(X-not_p[i]) < min_val:
      min_val = abs(X-not_p[i])
      out_num = not_p[i]
  print(out_num)
else:
  print(0)


import numpy as np
X,N = map(int, input().split())


if N == 0:
  print(X)
else:
  ans_v = 102
  ans_idx = 0
  candidate = list(np.arange(0,102))
  p = list(map(int, input().split()))
  for i in range(N):
    candidate.remove(p[i])
  for i in range(len(candidate)):
    if ans_v > abs(X-candidate[i]):
      ans_v = abs(X-candidate[i])
      ans_idx = i
  print(candidate[ans_idx])


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
x,n,*a=map(int,open(0).read().split())
b=[1]*101
for i in a:
    b[i]=0
c=1000 
ans=n
for i in range(102):
    if b[i] and c>abs(x-i):
        c=abs(x-i)
        ans=i
print(ans)

x,n,*a=map(int,open(0).read().split())
b=[1]*103
for i in a:
    b[i]=0
c=1000 
ans=n
for i in range(102):
    if b[i] and c>abs(x-i):
        c=abs(x-i)
        ans=i
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
c=[]
d=0
e=[]

a,b=map(int,input().split())
c=int(input().split())
if c!=null:
 for i in range(c):
  d=a-c
  e.append(abs(d))
print(min(e)) 

x,n=map(int,input().split())
s=list(map(int,input().split()))

dist=0
for i in range(0,100):
 if abs(x-i)>=0:
  for j in s:
    if s[j]==i:
    else:
      print(i)

s=[]
x,n=map(int,input().split())
s=list(map(int,input().split()))
slist=sorted(s)

if n==0:
  print(x)
  exit()
for i in range(0,100):
  for j in range(n+1):
    if slist[j]==x-i:
        flag=1
    if slist[j]==x+i:
        flag=2
            
  if flag==2:
    flag=0
  elif flag==1:
    print(x+i)
    exit()
  elif flag==0:
    print(x-i)
    exit()

s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
  
s=list(map(int,input().split()))
slist=sorted(s)
  
for i in range(0,1000):
  for j in range(n):
    if slist[j]==x-i:
        flaga=1
    if slist[j]==x+i:
        flagb=1
            
  if flaga=1 and flagb=1:
    flaga=0
    flagb=0
  elif flagb==0:
    print(x-i)
    exit()
  elif flaga==0:
    print(x+i)
    exit()

s=[]
x,n=map(int,input().split())
if n==0:
  print(x)
  exit()
  
s=list(map(int,input().split()))
slist=sorted(s)
out=0
for i in range(0,1000):
  out=0
  for j in range(n):
    if slist[j]==x-i:
      out=1
  if out !=1:
   print(x-i)
   exit()
  out=0
  for k in range(n):
    if slist[k]==x+i:
      out=1
  if out !=1:
    print(x+i)
    exit()

Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
a = list(map(int,input().split()))
b = list(map(int,input().split()))
b.sort()

P = a[1] - 1 

list = list(map(lambda x: x+1, list(range(b[P]))))

if a[1] == 0:
  print(a[0])
  exit()

for i in range(a[1]):
  list.remove(b[i])

num = 0

result = []

for i in range(a[1]):
  x = a[0] - b[num]
  result.append(abs(x))
  num += 1

print(min(result))

X,N = map(int,input().split())

if N == 0:
  print(X)
  exit()
else:
  P = list(map(int,input().split()))

  for i in range(100):
    if (X-i) not in P:
      print(X-i)
      break
    elif (X+i) not in P:
      print(X+i)
      break

Verdicts: Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
print(101)

print(0)

import sys
x,n = map(int,input().split())
    
p,f = x-1,x+1
bans = set(map(int,input().split()))

if n == 0 or x not in bans:
    print(x)
    sys.exit()

while True:
    if p not in bans:
        print(p)
        break 
    p -= 1
    
    if f not in bans:
        print(f)
        break 
    f += 1

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
X,N = map(int,input().split())
p = list(map(int,input().split()))
for i in range(101):
    if X - i not in p:
        print(x - i)
        exit()
    elif X + i not in p:
        print(x + i)
        exit()

X,N = map(int,input().split())
p = list(map(int,input().split()))
for i in range(101):
    if X - i not in p:
        print(X - i)
        exit()
    elif X + i not in p:
        print(X + i)
        exit()

Verdicts: Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
m, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(m)
    exit()
else:
    pp = list(range(0, max(p)+1))
    ppp = list(filter(lambda x: x not in p, pp))
    print(ppp)
    pppp = list(map(lambda x: abs(x-m), ppp))
    print(ppp[pppp.index(min(pppp))])


m, n = map(int, input().split())
p = list(map(int, input().split()))

for d in range(m+1):
    for i in [-1,1]:
        a = m + i*d
        if p.count(a==0):
            print(a)
            exit()

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

while True:
    if m-a not in p:
        print(m-a)
        break
    elif m+a not in p:
        print(m+a)
        break
    a+=1

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
from bisect import bisect
from bisect import insort

X,N=list(map(int,input().split()))
if N != 0:
	p=list(map(int,input().split()))

	not_list=[]
	for i in range(1,101):
		if i not in p:
			not_list.append(i)

		a=bisect(not_list,X)
		insort(not_list,X)

		ans1=not_list[a]-not_list[a-1]
		ans2=not_list[a+1]-not_list[a]

		if ans1 < ans2:
			print(not_list[a-1])
		elif ans1 == ans2:
			print(not_list[a-1])
		else:
			print(not_list[a+1])
            
else:
	print(X)

from bisect import bisect
from bisect import insort

X,N=list(map(int,input().split()))
if N != 0:
	p=list(map(int,input().split()))

	not_list=[]
	for i in range(1,101):
		if i not in p:
			not_list.append(i)

		a=bisect(not_list,X)
		insort(not_list,X)

		ans1=not_list[a]-not_list[a-1]
		ans2=not_list[a+1]-not_list[a]

		if ans1 < ans2:
			print(not_list[a-1])
		elif ans1 == ans2:
			print(not_list[a-1])
		else:
			print(not_list[a+1])
            
else:
	print(X)

X, N = map(int, input().split())
p = list(map(int, input().split()))

p = set(p)
for i in range(200):
    if X - i not in p:
        print(X - i)
        break
    if X + i not in p:
        print(X + i)
        break

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
x,y=map(int,input().split())
a=list(map(int,input().split()))
a=set(a)
for i in range(101):
  
  if x-i not in a:
        print(x-i)
        exit()
    elif x+i not in a:
        print(x+i)
        exit()

x,y=map(int,input().split())
a=list(map(int,input().split()))
a=set(a)
for i in range(101):
  
  if x-i not in a:
        print(x-i)
        exit()
  elif x+i not in a:
      print(x+i)
      exit()


Verdicts: Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))
c=0
if n==0:
  print(x)
  sys.exit()
for i in range(x,-200,-1):
  
  if not i in p:
    print(i)
    sys.exit()
  if not (x+c) in p:
    print(x+c)
    sys.exit()
　c+=1

import sys
x,n=map(int,input().split())
p=list(map(int,input().split()))
c=0
if n==0:
  print(x)
  sys.exit()
for i in range(x,-200,-1):
  
  if not i in p:
    print(i)
    sys.exit()
  if not (x+c) in p:
    print(x+c)
    sys.exit()
  c+=1


Verdicts: Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
X,N = map(int, input().split())
if(N == 0):
  print(X)
  exit()
else:
  p_list = list(map(int, input().split()))

i = X
ans_small = X
ans_big = X

while(True):
  i = i + 1
  #print("1",i)
  if((i in p_list)==True):
    pass
  else:
    ans_big = i
    break
    
i = X
while(True):
  i = i - 1
  #print("2",i)
  if((i in p_list)==True):
    pass
  else:
    ans_small = i
    break

print(ans_big,ans_small)
if(abs(X-ans_small)>abs(X-ans_big)):
  print(ans_big)
else:
  print(ans_small)

X,N = map(int, input().split())
if(N == 0):
  print(X)
  exit()
else:
  p_list = list(map(int, input().split()))

i = X
ans_big = X

while(True):
  #print("1",i)
  if((i in p_list)==True):
    pass
  else:
    ans_big = i
    break
  i = i + 1
    
i = X
ans_small = X
while(True):
  #print("2",i)
  if((i in p_list)==True):
    pass
  else:
    ans_small = i
    break
  i = i - 1

#print(ans_big,ans_small)
if(abs(X-ans_small)>abs(X-ans_big)):
  print(ans_big)
else:
  print(ans_small)

Verdicts: Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
    print(X)
    
else:
    for i in range(100):
        if (X-(i+1)) and (X+i+1) and X in p:
            continue
    
        elif (X-i-1) not in p:
            print(X-i-1)
            break
    
        elif (X+i+1) not in p:
            print(X+i+1)
            break

X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
    print(X)


for i in range(100):
    if (X-i+1) in p:
        print(X-i+1)
        break
    elif (X+i+1) in p:
        print(X+i+1)
        break
        

X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
    print(X)
    break
    
else:
    for i in range(100):
    if (X-(i+1)) and (X+i+1) in p:
        continue
    
    elif (X-i-1) not in p:
        print(X-i-1)
        break
    
    elif (X+i+1) not in p:
        print(X+i+1)
        break


X, N = map(int, input().split())
p = list(map(int, input().split()))

if N == 0:
    print(X)

elif X not in p:
    print(X)
    
else:
    for i in range(110):
        if (X-(i+1)) in p and (X+i+1) in p:
            continue
    
        else:
            if(X-(i+1)) not in p:
                print(X-(i+1))
                break
    
            elif (X+i+1) not in p:
                print(X+i+1)
                break

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
    exit()

p.sort()
print(p)
for i in range(n):
    if p[i] == x:
        index = i
        break

right = x + 1
for i in p[index + 1:]:
    print(i)
    if i != right:
        print('aaaa')
        print(right)
        break
    right += 1

left = x - 1
for i in reversed(p[:index]):
    print(i)
    if i != left:
        print('bbbb')
        print(left)
        break
    left -= 1

if x - left <= right - x:
    print(left)
else:
    print(right)

x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    print(x)
    exit()

p.sort()

if x not in p:
    print(x)
    exit()
    
for i in range(len(p)):
    #print(p[i])
    if p[i] == x:
        index = i
        break

right = x + 1
for i in p[index + 1:]:
    if i != right:
        break
    right += 1

left = x - 1
for i in reversed(p[:index]):
    if i != left:
        break
    left -= 1

if x - left <= right - x:
    print(left)
else:
    print(right)

Verdicts: Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
X,N = list(map(int,input().split()))
p = list(map(int,input().split()))

def f(p):
  global X
  return p - X

p2 = list(map(f,p))

p3 = list(map(abs,p2))

OK = 2
j = 0
print(p2,p3)

if min(p3) ==0:
  while(OK==2):
    j+=1
    
    OK = p3.count(min(p3)+j)

  print(X-p2[p3.index(min(p3)+j)])
      
else:
  print(X)

X,N = list(map(int,input().split()))
if N != 0:
  p = list(map(int,input().split()))
else:
  p = [X+1]
def f(p):
  global X
  return p - X

p2 = list(map(f,p))

p3 = list(map(abs,p2))

OK = 2
j = 0


if min(p3) ==0:
  while(OK==2):
    j+=1
    OK = p3.count(min(p3)+j)
  if OK == 1:
    print(X-p2[p3.index(min(p3)+j)])
  else:
    print(X-j)
else:
  print(X)

Verdicts: Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
x,n = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))

import bisect
p.sort()
i = bisect.bisect_left(p,x)
print(p)
for h in range(1, p[-1]-p[0]+2):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()    


x,n = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))
p = [-1] + p + [101]
import bisect
p.sort()
i = bisect.bisect_left(p,x)

x,n = list(map(int,input().split()))
if n == 0:
  print(x)
  exit()

p = list(map(int,input().split()))
p = [-1] + p + [102]
import bisect
p.sort()
i = bisect.bisect_left(p,x)
if p[i] != x:
    print(x)
    exit()

for h in range(102):
  if p[i-h] != x-h:
    print(x-h)
    exit()
  elif p[i+h] != x+h:
    print(x+h)
    exit()    


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
X, N = map(int, input().split())
if N == 0:
  exit()
p = list(map(int, input().split()))

max_num = max(p)
lst = []
for i in range(max_num+2):
  if i not in p:
    lst.append(i)
tmp = float("inf")
print(lst)
for j in lst:
  if tmp > abs(X-j):
    tmp = abs(X-j)
    ans = j
print(ans)

X, N = map(int, input().split())
if N == 0:
  print(X)
  exit()
p = list(map(int, input().split()))

max_num = max(p)
lst = []
for i in range(max_num+2):
  if i not in p:
    lst.append(i)
tmp = float("inf")
for j in lst:
  if tmp > abs(X-j):
    tmp = abs(X-j)
    ans = j
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
def main():
  X, N = map(int, input().split())
  if N == 0:
    return X
  
  P = list(map(int, input().split()))
  
  if X < min(P) or X > max(P):
    return X
  
  delta = []
  for n in range(min(P), max(P) + 1):
    if n in P:
      delta.append(float('inf'))
    else:
      delta.append(abs(X - n))
  print(list(range(min(P), max(P) + 1)))
  
  print(delta)
  
  minD = min(delta)
  for i, d in enumerate(delta):
    if d == minD:
      return min(P) + i
  

print(main())

def main():
  X, N = map(int, input().split())
  if N == 0:
    return X
  
  P = list(map(int, input().split()))
  
  delta = []
  for n in range(-1, 102):
    if n in P:
      delta.append(float('inf'))
    else:
      delta.append(abs(X - n))
      
  minD = min(delta)
  for i, d in enumerate(delta):
    if d == minD:
      return i + 1


print(main())

def main():
  X, N = map(int, input().split())
  if N == 0:
    return X
  
  P = list(map(int, input().split()))
  
  delta = []
  for n in range(-1, 102):
    if n in P:
      delta.append(float('inf'))
    else:
      delta.append(abs(X - n))
      
  minD = min(delta)
  for i, d in enumerate(delta):
    if d == minD:
      return i - 1


print(main())

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
import sys


def main():
    x, n = map(int, input().split())
    P = list(map(int, input().split()))

    if not (x in P):
        print(x)
        sys.exit()

    for i in range(101):
        x1 = max(0, x - (i + 1))
        x2 = min(101, x + (i + 1))

        print(x1, x2)
        if x1 == 0:
            print(0)
            sys.exit()
            
        if not (x1 in P):
            print(x1)
            sys.exit()

        if x2 == 101:
            print(101)
            sys.exit()
            
        if not (x2 in P):
            print(x2)
            sys.exit()


if __name__ == '__main__':
    main()


import sys


def main():
    x, n = map(int, input().split())
    P = list(map(int, input().split()))

    if not (x in P):
        print(x)
        sys.exit()

    for i in range(n):
        x1 = max(0, x - (i + 1))
        x2 = min(101, x + (i + 1))

        print(x1, x2)
        if x1 == 0:
            print(0)
            sys.exit()
            
        if not (x1 in P):
            print(x1)
            sys.exit()

        if x2 == 101:
            print(101)
            sys.exit()
            
        if not (x2 in P):
            print(x2)
            sys.exit()


if __name__ == '__main__':
    main()


import sys


def main():
    x, n = map(int, input().split())
    P = list(map(int, input().split()))

    if not (x in P):
        print(x)
        sys.exit()

    for i in range(101):
        x1 = max(0, x - (i + 1))
        x2 = min(101, x + (i + 1))

        if x1 == 0:
            print(0)
            sys.exit()
            
        if not (x1 in P):
            print(x1)
            sys.exit()

        if x2 == 101:
            print(101)
            sys.exit()
            
        if not (x2 in P):
            print(x2)
            sys.exit()


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
# -*- coding: utf-8 -*-
num, i = map(int, input().split())
if(i != 0):
  s = set(map(int, input().split()))
else:
  s = set()
m = set(range(101))
o = list(m-s)
o2 = list(map(lambda x: abs(x - num), o))
print(o2.index(min(o2)))

# -*- coding: utf-8 -*-
num, i = map(int, input().split())
if(i != 0):
  s = set(map(int, input().split()))
else:
  s = set()
m = set(range(102))
o = list(m-s)
o2 = list(map(lambda x: abs(x - num), o))
print(o[o2.index(min(o2))])

Verdicts: Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
x,n = list(map(int,input().split()))
p= list(map(int,input().split()))
 
for i in range(x+1):
 for s in [-1,+1]:
   a=x+s*i
   if a not in p:
     print(a)

x,n = list(map(int,input().split()))
p= list(map(int,input().split()))

for i in range(x+1):
 for s in [-1,+1]:
   a=X+s*d
   if a not in p:
     print(a)




x,n = list(map(int,input().split()))
p= list(map(int,input().split()))
 
for i in range(x+1):
 for s in [-1,+1]:
   a=x+s*d
   if a not in p:
     print(a)

x,n = list(map(int,input().split()))
p= list(map(int,input().split()))
 
for i in range(x+1):
 for s in [-1,+1]:
   a=x+s*i
   if a not in p:
     print(a)
     exit(0)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
X,N = map(int,input().split())
P = list(map(int,input().split()))

num = sorted([[abs(X - i),i] for i in range(-100,101) if i not in P],key = lambda x: x[0])

print(num)

X,N = map(int,input().split())
P = list(map(int,input().split()))
num = sorted([[abs(X - i),i] for i in range(-200,200) if i not in P],key = lambda x: x[0])

inf = 10 ** 3
inf2 = 10 ** 3 * -1

for i in range(X,inf):
  if i in P:
    continue
  plus = abs(X - i)
  break

for j in range(X,inf * -1,-1):
  if j in P:
    continue
  minus = abs(X - j)
  break

if plus < minus:
  print(i)

else:
  print(j)

Verdicts: Wrong Answer

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
X, N= map(int,input().split())
P = map(int, input().split())

P_sub_abs = [abs(i - X) for i in P]
if(P_sub_abs.count(0) == 0):
    print(X)
    exit()
for i in range(1, 100):
    if(P_sub_abs.count(i) == 1):
        list = [X - i, X + i]
        list.remove(P[P_sub_abs.index(i)])
        print(list[0])
        exit()
    elif(P_sub_abs.count(i) == 0):
        print(X - i)
        exit()


X, N= [int(x) for x in input().split()]
P = [int(x) for x in input().split()]

P_sub_abs = [abs(i - X) for i in P]
if(P_sub_abs.count(0) == 0):
    print(X)
    exit()
for i in range(1, 100):
    if(P_sub_abs.count(i) == 1):
        list = [X - i, X + i]
        list.remove(P[P_sub_abs.index(i)])
        print(list[0])
        exit()
    elif(P_sub_abs.count(i) == 0):
        print(X - i)
        exit()


Verdicts: Runtime Error

Accepted
Problem: Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.  Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Submission attempts (in order):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  p.sort()
  p1 = {i for i in range(p[-1])}
  p = set(p)
  p2 = p1 - p
  p2 = list(p2)
  absv = x
  for i in range(len(p2)):
    if absv > abs(x - p2[i]):
      absv = abs(x - p2[i])
  print(x - absv)

x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  absv = x
  value = x
  for i in range(-1, 102):
    if i in p:
      pass
    else:
      if absv > abs(x - i):
        absv = abs(x - i)
        value = x - i
  print(x - value)
    

Verdicts: Wrong Answer

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
n=int(input())
b=list(map(int,input().split()))
ans=0
w=max(b)
a=[0]*w
for i in b:
  x=i
  while x<w:
    a[x]=1
    x+=i
for i in b:
  if a[i]==0:
    ans+=1

a=int(input())
b=list(map(int,input().split()))
ans=0
for i in b:
  if len([j for j in b if not i%j==0])==a:
    break
  else:
    ans+=1
print(ans)

n=int(input())
b=list(map(int,input().split()))
ans=0
w=max(b)
a=[0]*(w+1)
for i in b:
  x=i
  while x<=w:
    a[x]+=1
    x+=i
for i in b:
  if a[i]==1:
    ans+=1
print(ans)

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
N = int(input())
As = list(map(int, input().split()))

bool_array = []


for i in range(len(As)):
    tmp = [True if i!=j else False for j in range(len(As))]
    bool_array.append(tmp)

count = 0
for i, A in enumerate(As):
    is_exist = True
    for j, tf in enumerate(bool_array[i]):
        if i!=j and not tf:
            is_exist = False
            break
        elif i!=j:
            current_tf = A%As[j]
            current_tf = [current_tf==0][0]
            if current_tf and A!=As[j]:
                is_exist = False
                bool_array[i][j] = False
                #bool_array[j][i] = False
                break
    if not is_exist:
        count+=1
print(count)


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

max_num = max(As)
tfs = [0 for _ in range(max_num+1)]

for A in As:
    if tfs[A] != 0:
        tfs[A] = 2
        continue
    for j in range(A, max_num+1, A):
        tfs[j]+=1

result = 0
for A in As:
    if tfs[A] == 1:
        result+=1
print(result)


Verdicts: Wrong Answer

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

import collections
N = int(input())
A = list(map(int, input().split()))
cA = collections.Counter(A)

LIM = 10 ** 6 + 10
# LIM = 25

A.sort()
dp = [1] * LIM

for i in set(A):
    s = i * 2
    while s <= LIM:
        dp[s] = 0
        s += i

ans = 0
# print(dp)
for a in A:
    # print("{} {}".format(dp[a], cA[a]))
    if dp[a] and cA[a] == 1:
        # print(a)
        ans += 1
print(ans)

import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

import collections
N = int(input())
A = list(map(int, input().split()))
cA = collections.Counter(A)

LIM = 10 ** 6 + 1
# LIM = 25

A.sort()
dp = [1] * LIM

for i in set(A):
    s = i * 2
    while s <= LIM:
        dp[s] = 0
        s += i

ans = 0
# print(dp)
for a in A:
    # print("{} {}".format(dp[a], cA[a]))
    if dp[a] and cA[a] == 1:
        print(a)
        ans += 1
print(ans)

import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

import collections
N = int(input())
A = list(map(int, input().split()))
cA = collections.Counter(A)

LIM = 10 ** 6 + 1
# LIM = 25

A.sort()
dp = [1] * LIM

for i in set(A):
    s = i * 2
    while s <= LIM:
        dp[s] = 0
        s += i

ans = 0
# print(dp)
for a in A:
    # print("{} {}".format(dp[a], cA[a]))
    if dp[a] and cA[a] == 1:
        print(a)
        ans += 1
print(ans)

import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

import collections
N = int(input())
A = list(map(int, input().split()))
cA = collections.Counter(A)

LIM = 10 ** 6 + 1
# LIM = 25

A.sort()
dp = [1] * LIM

for i in set(A):
    s = i * 2
    while s < LIM:
        dp[s] = 0
        s += i

ans = 0
# print(dp)
for a in A:
    # print("{} {}".format(dp[a], cA[a]))
    if dp[a] and cA[a] == 1:
        # print(a)
        ans += 1
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
N=int(input())
A=list(map(int,input().split()))
A.sort()
ma=A[-1]
dp=[1]*(ma+1)
ans=0

for i in range(len(A)-1):
  p=A[i]
  if dp[i]==1:
    for q in range(ma//p+1):
      dp[p*q]=0
    if dp[i]!=dp[i+1]:
      ans+=1
if dp[ma]==1:
  ans+=1
print(ans)


N=int(input())
A=list(map(int,input().split()))
A.sort()
ma=A[-1]
dp=[1]*(ma+1)
ans=0

for i in range(N-1):
  p=dp[i]
  if dp[i]==1:
    for q in range(ma//p+1):
      dp[p*q]=0
    if dp[i]!=dp[i+1]:
      ans+=1
if dp[ma]==1:
  ans+=1
print(ans)

N = int(input())
A = list(map(int, input().split()))
A.sort()                  
Amax = A[-1]
dp = [1]*(Amax+1)         
ans = 0
for i in range(len(A)-1):
  p = A[i]
  if dp[p] == 1:          
    for q in range(Amax//p+1):
      dp[p*q] = 0         
    if A[i] != A[i+1]: 
      ans += 1            
if dp[Amax] == 1:         
  ans += 1
print(ans)


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
n=int(input())
A=list(map(int,input().split()))

A.sort()
B=[1]*n

from math import sqrt
def eratosu():
  # if not isinstance(n,int):
  
  # if n<2:
  
  primec = 0
  
  data = A  #2,3,4,...,n
  while len(data)>0:
    p = data[0]
    
    
    if len(data)>0:
        if data[1]==p:
            primec-=1
    primec+=1 
    data = [e  for e in data if e % p != 0]
  return primec 


#     if i>0:
#         if A[i]==A[i-1]: B[i]=0 ; B[i-1]=0 ; continue
    # if B[i]==1:
    #     for j in range(i+1,n):
    #         if A[j]%A[i]==0:
    #             B[j]=0
print(eratosu())




n=int(input())
A=sorted(list(map(int,input().split())))
B=[0]*(1+A[-1])
for i in A:
    B[i]+=1
    if B[i]==1:
        for j in range(2*i,A[-1]+1,i):
            B[j]+=1
    else:
        continue
ans=0
for i in A:
  if B[i]==1: ans+=1

print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
N =input()
A = list(map(int, input().split()))
N=int(N)
s=0
A2 = [-1] 
LS =[-1]
for i in range(0,N):
  k=1
  P =A[i]
  if P in A2:
    pass
  else:
    while P*k<=10^6:
      LS.append(P)
      k+=1
    A2.append(P)
for j in range(0,N):
  if A[j] in A2:
    pass
  else:
    if LS.count(A[j]) ==1:
      s+=1
      
print(s)
    

N =input()
A = list(map(int, input().split()))
N=int(N)
s=0
A1 =A
A2 = [-1]
B = [-1]
LS =[]
for i in range(0,N):
  k=1
  P =A1[i]
  if P in A2:
    if P in B:
      pass
    else:
      B.append(P)
  else:
    while P*k<=2*10^5:
      LS.append(P)
      k+=1
    A2.append(P)
for j in range(0,N):
  if A[j] in B:
    pass
  else:
    if LS.count(A[j]) ==1:
      s+=1
      
print(s)
    

sucl =[]
for i in range(0,int(N)):
  T=True
  for j in range(0,int(N)):
    if T== False:
      break
    if A[i]<A[j]:
      break
    if A[i] % A[j]==0:
      if i==j:
        pass
      else:
        T=False
        
  if T==True:
    sucl.append(i)
print(len(sucl))
    

N=input()
A = list(map(int, input().split()))
T=True
sucl =[]
for i in range(0,int(N)):
  T=True
  for j in range(0,int(N)):
    if T== False:
      break
    if A[i]<A[j]:
      break
    if A[i] % A[j]==0:
      if i==j:
        pass
      else:
        T=False
        
  if T==True:
    sucl.append(i)
print(len(sucl))
    

N =input()
A = list(map(int, input().split()))
N=int(N)
s=0
A2 = [-1] 
LS =[-1]
for i in range(0,N):
  k=1
  P =A[i]
  if P in A2:
    pass
  else:
    while P*k<=10^6:
      LS.append(P*k)
      k+=1
    A2.append(P)
for j in range(0,N):
  if A[j] in A2:
    pass
  else:
    if LS.count(A[j]) ==1:
      s+=1
      
print(s)
    


N = input()
A = list(map(int, input().split()))
N = int(N)
MA = max(A)
s=0
LS = [0 for i in range(0,MA)]
for i in range(0,N):
  k=1
  while A[i]*k<=MA:
    LS[A[i]*k-1] +=1
    k +=1
for j in range(0,N):
  if LS[A[j]-1]==1:
    s+=1
print(s)

Verdicts: Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
n = int(input())
a_lst = list(map(int, input().split()))
index_lst = [0]*(a_max + 1)

for ai in a_lst:
    for multi in range(ai, a_max+1, ai):
        index_lst[multi] += 1

ans = 0
for ai in a_lst:
    if index_lst[ai] == 1:
        ans += 1
print(ans)

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

a_max = max(a_lst)
index_lst = [0]*(a_max + 1)

for ai in a_lst:
    for multi in range(ai, a_max+1, ai):
        index_lst[multi] += 1

ans = 0
for ai in a_lst:
    if index_lst[ai] == 1:
        ans += 1
print(ans)

Verdicts: Runtime Error

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
  
def main():
  m = int(input())
  a = LI()
  ans = 0
  n = max(a)
  num = [True]*(n+1)
  num[0] = False
  a.sort()
  for i in range(m):
    if (i != m-1 and a[i]==a[i+1]) or (i != 0 and a[i]== a[i-1]): num[a[i]] = False
    for j in range(a[i]*2, n+1, a[i]):
      num[j] = False
  print(num)
  for aa in a:
    if num[aa]:
      ans += 1
  print(ans)

if __name__ == '__main__':
  main()

def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
  
def main():
  m = int(input())
  a = LI()
  ans = 0
  if a.count(1) == 1:
    print(1)
    exit()
  n = max(a)
  num = [True]*(n+1)
  num[0] = num[1] = False
  a.sort()
  for i in range(m):
    if (i != m-1 and a[i]==a[i+1]) or (i != 0 and a[i]== a[i-1]): num[a[i]] = False
    for j in range(a[i]*2, n+1, a[i]):
      num[j] = False
  for aa in a:
    if num[aa]:
      ans += 1
  print(ans)

if __name__ == '__main__':
  main()

Verdicts: Wrong Answer

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N = int(input())
    A = read_list()
    A.sort()

    F = [True] * (A[-1] + 1)
    for i in range(N - 1):
        if A[i] == A[i + 1]:
            F[A[i]] = False

    res = 0
    for a in A:
        if not F[a]:
            continue
        
        res += 1
        for b in range(a, len(F), a):
            print(a, b)
            F[b] = False

    print(res)


if __name__ == "__main__":
    main()



import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N = int(input())
    A = read_list()
    A.sort()

    F = [True] * (A[-1] + 1)
    for i in range(N - 1):
        if A[i] == A[i + 1]:
            F[A[i]] = False

    res = 0
    for a in A:
        if F[a]:
            res += 1
        for b in range(a, len(F), a):
            F[b] = False

    print(res)


if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
import math
N = int(input())
A = list(map(int, input().split()))

As = sorted(A)

dellist = []

i = 0
MAX = int(math.sqrt(As[N-1]))+2
while(i < len(As)):
    if As[i] < MAX:
        break
#     print('i:{}'.format(i))
#     print('As:{}'.format(As))
    
    j = i+1
    poplist = []
    while(j < len(As)):

#         print('As[i]:{}'.format(As[i]))
#         print('As[j]:{}'.format(As[j]))
        if As[j]%As[i] == 0: 
            
            poplist.append(j)
            
            
            if As[i]  == As[j]:
                dellist.append(A[i])
                
        j += 1
        
    
    
    # https://gammasoft.jp/blog/remove-multiple-elements-from-python-list/
    for k in sorted(poplist, reverse=True):
        As.pop(k)
    
    
    i += 1



dellist = list(set(dellist))
    
for i in dellist:
    As.remove(i)

# print(As)
print(len(As))


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

D = [0]*(10**6+1)
for i in A:
    
    D[i] += 1

U = []
for i in range(10**6+1):
    
    if D[i] == 1:
        U.append(i)

A = list(set(A))

T = [0]*(max(A)+1)
for i in A:
    
    for j in range(2*i, 10**6+1, i):
        T[j] = 1


ans = 0
for i in U:
    if T[i] == 0:
        ans += 1

print(ans)

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

As = sorted(A)

dellist = []

i = 0
MAX = int(math.sqrt(As[N-1]))+2
while(i < len(As) or As[i] < MAX):
#     print('i:{}'.format(i))
#     print('As:{}'.format(As))
    
    j = i+1
    poplist = []
    while(j < len(As)):

#         print('As[i]:{}'.format(As[i]))
#         print('As[j]:{}'.format(As[j]))
        if As[j]%As[i] == 0: 
            
            poplist.append(j)
            
            
            if As[i]  == As[j]:
                dellist.append(A[i])
                
        j += 1
        
    
    
    # https://gammasoft.jp/blog/remove-multiple-elements-from-python-list/
    for k in sorted(poplist, reverse=True):
        As.pop(k)
    
    
    i += 1



dellist = list(set(dellist))
    
for i in dellist:
    As.remove(i)

# print(As)
print(len(As))


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


rm = 0
for i in A:
    if A.count(i) != 1:
        rm += 1


T = [0]*(10**6+1)
for i in A:
    j = 1
    while(i*j <= 10**6):
        T[i*j] += 1
        j += 1

ans = -len(rmlst)
for i in A:
    if T[i] == 1:
        ans += 1

print(ans)

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

D = [0]*(10**6+1)
for i in A:
    
    D[i] += 1

U = []
for i in range(10**6+1):
    
    if D[i] == 1:
        U.append(i)

A = list(set(A))

T = [0]*(10**6+1)
for i in A:
    
    for j in range(2*i, 10**6+1, i):
        T[j] = 1


ans = 0
for i in U:
    if T[i] == 0:
        ans += 1

print(ans)

Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Given is a number sequence A of length N.  Find the number of integers i \left(1 \leq i \leq N\right) with the following property:    * For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Submission attempts (in order):
# -*- coding: utf-8 -*-

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

new_num_list = list(set(num_list))
new_num_list.sort()

if len(new_num_list) = 1:
  ans = 0
else:
  ans = 1

count = 0

for index_1, num_1 in enumerate(num_list):
  for index_2, num_2 in enumerate(num_list):
    if index_1 > index_2:
      if num_1 % num_2 != 0:
        count += 1
  
  if count == index_1:
    ans += 1

  count = 0

print(ans)

import collections
 
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=set()
cnt=collections.Counter(arr)
 
for i in range(n):
 if arr[i] in s:
   continue
 if cnt[arr[i]]>=2:
   s.add(arr[i])
 for j in range(2,10**6//arr[i]+1):
   s.add(arr[i]*j)
ans=0
for i in range(n):
 if arr[i] in s:
   continue
 ans+=1
 
print(ans)

Verdicts: Runtime Error

Accepted