Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02719 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

N,K = [int(x) for x in stdin.readline().rstrip().split()]
ans1 = N % K
ans2 = (ans1 - K) * -1
# print(ans1,ans2)
print(min(ans1,ans2))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

K = int(stdin.readline().rstrip())
a = list(range(1,10))
b = []
attack = 100000
while attack > 0:
    go = a.pop(0)
    ue = go*10
    shimo = go%10
    b.append(go)
    if shimo == 0:
        a.append(ue)
        a.append(ue+1)
    elif shimo == 9:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
    else:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
        a.append(ue+shimo+1)
    attack -= 1

print(b[K-1])
Problem p02741 (python)

Fixed submission:
from sys import stdin
# stdin = open("sample.txt")

a = int(stdin.readline().rstrip())

b = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(b[a-1])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter

# stdin = open("sample.txt")

h, w = [int(x) for x in stdin.readline().rstrip().split()]

if h == 1 or w == 1:
    print(1)
else:
    if h*w % 2 == 0:
        print(h*w // 2)
    else:
        print((h*w + 1) // 2)

Buggy submission (verdict: Runtime Error):
stdin = open("sample.txt")

a = int(stdin.readline().rstrip())

b = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(b[a-1])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter

stdin = open("sample.txt")

a = int(stdin.readline().rstrip())

b = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(b[a-1])
Problem p02742 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter

# stdin = open("sample.txt")

h, w = [int(x) for x in stdin.readline().rstrip().split()]

if h == 1 or w == 1:
    print(1)
else:
    if h*w % 2 == 0:
        print(h*w // 2)
    else:
        print((h*w + 1) // 2)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter

stdin = open("sample.txt")

h, w = [int(x) for x in stdin.readline().rstrip().split()]

if h == 1 or w == 1:
    print(0)
else:
    if h*w % 2 == 0:
        print(h*w // 2)
    else:
        print((h*w + 1) // 2)
Problem p03998 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from sys import stdin

A = stdin.readline().rstrip()
B = stdin.readline().rstrip()
C = stdin.readline().rstrip()
turn = "a"

for i in range(300):
    if turn == "a":
        if A != "":
            turn = A[0]
            A = A[1:]
        else:
            print("A")
            exit()
    elif turn == "b":
        if B != "":
            turn = B[0]
            B = B[1:]
        else:
            print("B")
            exit()
    elif turn == "c":
        if C != "":
            turn = C[0]
            C = C[1:]
        else:
            print("C")
            exit()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin
stdin = open("sample.txt")

A = stdin.readline().rstrip()
B = stdin.readline().rstrip()
C = stdin.readline().rstrip()
turn = "a"

for i in range(300):
    if turn == "a":
        if A != "":
            turn = A[0]
            A = A[1:]
        else:
            print("A")
            exit()
    elif turn == "b":
        if B != "":
            turn = B[0]
            B = B[1:]
        else:
            print("B")
            exit()
    elif turn == "c":
        if C != "":
            turn = C[0]
            C = C[1:]
        else:
            print("C")
            exit()
Problem p02780 (python)

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


def cal_expect(value):
    return ((value*(value+1))/2)*(1/value)

expect_value = [0]*N
expect_value[0] = cal_expect(p[0])

for i in range(1,K):
    expect_value[i] += expect_value[i-1] + cal_expect(p[i])

for i in range(K,N):
    expect_value[i] = expect_value[i-1] + cal_expect(p[i]) - cal_expect(p[i - K])

print(max(expect_value))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
p = list(map(int,input().split()))

expect_value = [0]*N

for i in range(N):
    expect_value[i] = ((p[i] * (p[i]+1))/2) * (1/p[i])

ans = [0] * (N - K + 1))
for i in range(N - K + 1):
    ans[i] = sum(expect_value[i:i+K])
print(max(ans)
Problem p02811 (python)

Fixed submission:
K, X = map(int,input().split())
if 500 * K >= X:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
cnt = 0
ans = 0
for i in range(N):
    if S[i] == "A":
        if cnt == 0:
            cnt += 1
        else:
            cnt = 1
    if S[i] == "B":
        if cnt == 1:
            cnt += 1
        else:
            cnt = 0
    if S[i] == "C":
        if cnt == 2:
            ans += 1
            cnt = 0
        else:
            cnt = 0

print(ans)
Problem p02995 (python)

Fixed submission:
import fractions

a,b,c,d = map(int,input().split())

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

gcd_cd = lcm(c,d)

a_c_numbers = a//c
if a % c == 0:
    a_c_numbers -= 1
a_d_numbers = a//d
if a % d == 0:
    a_d_numbers -= 1

a_numbers = a_c_numbers + a_d_numbers

b_c_numbers = b//c
b_d_numbers = b//d
b_numbers = b_c_numbers + b_d_numbers

if a % gcd_cd == 0:
    gcd_cd_numbers = b//gcd_cd - a//gcd_cd + 1
else:
    gcd_cd_numbers = b//gcd_cd - a//gcd_cd

# print(a_c_numbers,a_d_numbers)
# print(b_c_numbers,b_d_numbers)
# print(gcd_cd_numbers)
# print(b_numbers - a_numbers - gcd_cd_numbers)
ans = b - a + 1 - (b_numbers - a_numbers - gcd_cd_numbers)

if ans > 0:
    print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())

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

gcd_cd = lcm(c,d)

a_c_numbers = a//c
if a % c == 0:
    a_c_numbers -= 1
a_d_numbers = a//d
if a % d == 0:
    a_d_numbers -= 1

a_numbers = a_c_numbers + a_d_numbers

b_c_numbers = b//c
b_d_numbers = b//d
b_numbers = b_c_numbers + b_d_numbers

gcd_cd_numbers = b//gcd_cd - a//gcd_cd

# print(a_c_numbers,a_d_numbers)
# print(b_c_numbers,b_d_numbers)
# print(gcd_cd_numbers)
# print(b_numbers - a_numbers - gcd_cd_numbers)
ans = b - a + 1 - (b_numbers - a_numbers - gcd_cd_numbers)

if ans > 0:
    print(ans)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
import math

a,b,c,d = map(int,input().split())

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

gcd_cd = lcm(c,d)

a_c_numbers = a//c
if a % c == 0:
    a_c_numbers -= 1
a_d_numbers = a//d
if a % d == 0:
    a_d_numbers -= 1

a_numbers = a_c_numbers + a_d_numbers

b_c_numbers = b//c
b_d_numbers = b//d
b_numbers = b_c_numbers + b_d_numbers

gcd_cd_numbers = b//gcd_cd - a//gcd_cd

# print(a_c_numbers,a_d_numbers)
# print(b_c_numbers,b_d_numbers)
# print(gcd_cd_numbers)
# print(b_numbers - a_numbers - gcd_cd_numbers)
print(b - a + 1 - (b_numbers - a_numbers - gcd_cd_numbers))
Problem p03001 (python)

Fixed submission:
W,H,x,y = map(int,input().split())

if x * 2 == W and y * 2 == H:
    print(W*H/2, 1)
else:
    print(W*H/2, 0)

Buggy submission (verdict: Runtime Error):
W,H,x,y = map(int,input().split())

if W/x == 2 and H/y == 2:
    print(W*H/2, 1)
else:
    print(W*H/2, 0)

Buggy submission (verdict: Runtime Error):
W,H,x,y = map(int,input().split())

if W/x == 2 and Y/2 == 2:
    print(W*H/2, 1)
else:
    print(W*H/2, 0)
Problem p03150 (python)

Fixed submission:
S = input()

for i in range(8):
    if S[0:i] + S[i+(len(S)-7):len(S)] == "keyence":
        print("YES")
        exit()
print("NO")

Buggy submission (verdict: Runtime Error):
S = input()

ans_str = "keyence"

if S[0:7] == ans_str:
    print("YES")
    exit()

if S[len(S)-7:len(S)] == ans_str:
    print("YES")
    exit()

count_check_str = 0
count_insert = 0
count_ans_str = 0
for i in range(len(S)):
    if S[i] == ans_str[count_ans_str]:
        count_check_str += 1
        count_ans_str += 1
        if count_insert == 1:
            count_insert = 2
    else:
        if count_insert == 2:
            print("NO")
            exit()
        count_insert = 1

if count_check_str < 6:
    print("NO")
    exit()
print("YES")
Problem p03244 (python)

Fixed submission:
n = int(input())
v = list(map(int,input().split()))
dic_odd = {}
dic_even = {}

for i in range(0,n,2):
    if v[i] in dic_odd:
        dic_odd[v[i]] += 1
    else:
        dic_odd[v[i]] = 1

for i in range(1,n,2):
    if v[i] in dic_even:
        dic_even[v[i]] += 1
    else:
        dic_even[v[i]] = 1

odd_sorted = sorted(dic_odd.items(), key=lambda x:x[1])
even_sorted = sorted(dic_even.items(), key=lambda x:x[1])

if odd_sorted[len(odd_sorted)-1][0] == even_sorted[len(even_sorted)-1][0]:
    if len(odd_sorted) == 1 and len(even_sorted) == 1:
        print(n//2)
    elif len(odd_sorted) == 1:
        print(n//2-even_sorted[len(even_sorted)-2][1])
    elif len(even_sorted) == 1:
        print(n//2-odd_sorted[len(odd_sorted)-2][1])
    else:
        if odd_sorted[len(odd_sorted)-1][1] < even_sorted[len(even_sorted)-1][1]:
            print(n - (odd_sorted[len(odd_sorted)-2][1] + even_sorted[len(even_sorted)-1][1]))
        elif  odd_sorted[len(odd_sorted)-1][1] > even_sorted[len(even_sorted)-1][1]:
            print(n - (odd_sorted[len(odd_sorted)-1][1] + even_sorted[len(even_sorted)-2][1]))
        else:
            if odd_sorted[len(odd_sorted)-2][1] < even_sorted[len(even_sorted)-2][1]:
                print(n - (odd_sorted[len(odd_sorted)-1][1] + even_sorted[len(even_sorted)-2][1]))
            else:
                print(n - (odd_sorted[len(odd_sorted)-2][1] + even_sorted[len(even_sorted)-1][1]))
else:
    print(n-(odd_sorted[len(odd_sorted)-1][1]+even_sorted[len(even_sorted)-1][1]))

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))
dic_odd = {}
dic_even = {}

#奇数桁の中で一番多く存在する数字の数
for i in range(0,n,2):
    if v[i] in dic_odd:
        dic_odd[v[i]] += 1
    else:
        dic_odd[v[i]] = 1

#偶数桁の中で一番多く存在する数字の数
for i in range(1,n,2):
    if v[i] in dic_even:
        dic_even[v[i]] += 1
    else:
        dic_even[v[i]] = 1

odd_sorted = sorted(dic_odd.items(), key=lambda x:x[1])
even_sorted = sorted(dic_even.items(), key=lambda x:x[1])

if odd_sorted[len(odd_sorted)-1][0] == even_sorted[len(even_sorted)-1][0]:
    if len(odd_sorted) == 1 and len(even_sorted) == 1:
        print(n//2)
    elif len(odd_sorted) == 1:
        print(n//2-even_sorted[len(even_sorted)-2][1])
    elif len(even_sorted) == 1:
        print(n//2-odd_sorted[len(odd_sorted)-2][1])
    else:
        if odd_sorted[len(odd_sorted)-1][1] < even_sorted[len(even_sorted)-1][1]:
            print(n - (odd_sorted[len(odd_sorted)-1][2] + even_sorted[len(even_sorted)-1][1]))
        else:
            print(n - (odd_sorted[len(odd_sorted)-1][1] + even_sorted[len(even_sorted)-1][2]))
else:
    print(n-(odd_sorted[len(odd_sorted)-1][1]+even_sorted[len(even_sorted)-1][1]))
Problem p03246 (python)

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

v1 = [0] * (10**5)
v2 = [0] * (10**5)
v1_max_1 = 0
v1_max_2 = 0
v2_max_1 = 0
v2_max_2 = 0

for i in range(0,n,2):
	v1[v[i]-1] += 1

for i in range(1,n,2):
	v2[v[i]-1] += 1

v1_max_index = v1.index(max(v1))
v2_max_index = v2.index(max(v2))

v1.sort(reverse=True)
v2.sort(reverse=True)
v1_max_1 = v1[0]
v2_max_1 = v2[0]
v1_max_2 = v1[1]
v2_max_2 = v2[1]

ans = n - ( v1_max_1 + v2_max_1 )

if ans == 0:
	if v[0] == v[1]:
		print(n//2)
		exit()

if v1_max_index == v2_max_index:
	print(min( n - ( v1_max_2 + v2_max_1 ),n  - ( v1_max_1 + v2_max_2 ) ))
else:
	print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = list(map(int,input().split()))

v1 = [0] * (10**5)
v2 = [0] * (10**5)

for i in range(0,n,2):
	v1[v[i]] += 1

for i in range(1,n,2):
	v2[v[i]] += 1

ans = n - ( max(v1) + max(v2) )
if ans == 0:
	if v[0] == v[1]:
		print(n//2)
		exit()

print(ans)
Problem p03574 (python)

Fixed submission:
H, W = map(int,input().split())
S = []
for _ in range(H):
    S.append(input())

ans = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            ans[i][j] = "#"
            if j-1 >= 0 and ans[i][j-1] != "#":
                ans[i][j-1] += 1
            if j-1 >= 0 and i-1 >= 0 and ans[i-1][j-1] != "#":
                ans[i-1][j-1] += 1
            if j-1 >= 0 and i+1 <= H-1 and ans[i+1][j-1] != "#":
                ans[i+1][j-1] += 1

            if i-1 >= 0 and ans[i-1][j] != "#":
                ans[i-1][j] += 1
            if i+1 <= H-1 and ans[i+1][j] != "#":
                ans[i+1][j] += 1
            
            if j+1 <= W-1 and ans[i][j+1] != "#":
                ans[i][j+1] += 1
            if j+1 <= W-1 and i-1 >= 0 and ans[i-1][j+1] != "#":
                ans[i-1][j+1] += 1
            if j+1 <= W-1 and i+1 <= H-1 and ans[i+1][j+1] != "#":
                ans[i+1][j+1] += 1                        

for i in range(H):
    print(''.join(map(str,ans[i])))

Buggy submission (verdict: Runtime Error):
H, W = map(int,input().split())
S = []
for _ in range(H):
    S.append(input())

ans = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            ans[i][j] = "#"
            if j-1 >= 0 and ans[i][j-1] != "#":
                ans[i][j-1] += 1
            if j-1 >= 0 and i-1 >= 0 and ans[i-1][j-1] != "#":
                ans[i-1][j-1] += 1
            if j-1 >= 0 and i+1 <= H-1 and ans[i+1][j-1] != "#":
                ans[i+1][j-1] += 1

            if i-1 >= 0 and ans[i-1][j] != "#":
                ans[i-1][j] += 1
            if i+1 <= H-1 and ans[i+1][j] != "#":
                ans[i+1][j] += 1
            
            if j+1 <= W-1 and ans[i][j+1] != "#":
                ans[i][j+1] += 1
            if j+1 <= W-1 and i-1 >= 0 and ans[i-1][j+1] != "#":
                ans[i-1][j+1] += 1
            if j+1 <= W-1 and i+1 <= H-1 and ans[i+1][j+1] != "#":
                ans[i+1][j+1] += 1                        

for i in range(H):
    print(''.join(ans[i]))
Problem p03607 (python)

Fixed submission:
N = int(input())

A = []
for _ in range(N):
    A.append(int(input()))

if N == 1:
    print(1)
    exit()

A.sort()

current_number = A[0]
current_count = 1
ans = 0

for i in range(1,N-1):
    if current_number == A[i]:
        current_count += 1
    else:
        current_number = A[i]
        if current_count % 2 != 0:
            ans += 1
        current_count = 1

if current_number == A[N-1]:
    current_count += 1
    if current_count % 2 != 0:
            ans += 1
else:
    if current_count % 2 != 0:
            ans += 1
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

ans = [0] * max(A)
count = 0
for i in range(N):
    if ans[A[i]-1] == 0:
        ans[A[i]-1] = 1
        count += 1
    else:
        ans[A[i]-1] = 0
        count -= 1

print(count)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
for _ in range(N):
    A.append(int(input()))

ans = [0] * (10**9)
for i in range(N):
    if ans[i] == 0:
        ans[i] = 1
    if ans[i] == 1:
        ans[i] = 0

print(sum(ans[i]))
Problem p03665 (python)

Fixed submission:
import math

N,P = map(int,input().split())
A = list(map(int,input().split()))
pascal_triangle = []

memo = [[0 for _ in range(51)] for _ in range(51)]

def c(n,k):
  if memo[n][k] != 0:
      return memo[n][k]
  if(k<=0 or n<=k):
      memo[n][k] = 1
      return 1
  else:
      ans = c(n-1, k-1) + c(n-1, k)
      memo[n][k] = ans
      return ans

for i in range(51):
  pascal_triangle.append([c(i,j) for j in range(i+1)])

Numbers_1 = 0
for i in range(N):
    Numbers_1 += A[i] % 2

Select_0_count = sum(pascal_triangle[N - Numbers_1])

ans = 0

for i in range(Numbers_1+1):
    if i % 2 == P:
        ans += pascal_triangle[Numbers_1][i] * Select_0_count

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N,P = map(int,input().split())
A = list(map(int,input().split()))
pascal_triangle = []

memo = [[0 for _ in range(50)] for _ in range(50)]

def c(n,k):
  if memo[n][k] != 0:
      return memo[n][k]
  if(k<=0 or n<=k):
      memo[n][k] = 1
      return 1
  else:
      ans = c(n-1, k-1) + c(n-1, k)
      memo[n][k] = ans
      return ans

for i in range(50):
  pascal_triangle.append([c(i,j) for j in range(i+1)])

Numbers_1 = 0
for i in range(N):
    Numbers_1 += A[i] % 2

Select_0_count = sum(pascal_triangle[N - Numbers_1])

ans = 0

for i in range(Numbers_1+1):
    if i % 2 == P:
        ans += pascal_triangle[Numbers_1][i] * Select_0_count

print(ans)
Problem p03861 (python)

Fixed submission:
import math
a, b, x = map(int,input().split())
print(b//x - (a-1)//x)

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int,input().split())
def fnc(n,x):
    if n == -1:
        return 0
    return n//x
print(fnc(b,x) - func((a-1),x))

Buggy submission (verdict: Runtime Error):
import math
a, b, x = map(int,input().split())
if a % x != 0:
    print(b//x - a//x + 2)
else
    print(b//x - a/x + 1)
Problem p02719 (python)

Fixed submission:
n,k = map(int,input().split())
if abs(k-n)>n:
  print(n)
elif k==1 or k==n or n==0:
  print(0)
elif n<k:
  print(k%n)
else:
  n = k+ n%k
  n1 = n%k
  while n1<n:
    n=n1
    n1 = abs(k-n1)
  print(n)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
if abs(k-n)>n:
  print(n)
elif k==1:
  print(0)
else:
  print(n%abs(k-n))
Problem p02802 (python)

Fixed submission:
n,m = map(int,input().split())
cor = set()
pens = {}
for i in range(m):
  p,s = input().split()
  if s=="AC":
    cor.add(p)
  else:
    if not p in cor:
      if p in pens:
        pens[p] += 1
      else:
        pens[p] = 1
pen = 0
for x in cor:
  if x in pens:  
    pen += pens[x]
print(str(len(cor))+" "+str(pen))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
cor = set()
pens = {}
for i in range(m):
  p,s = input().split()
  if s=="AC":
    cor.add(p)
  else:
    if not p in cor:
      if p in pens:
        pens[p] += 1
      else:
        pens[p] = 1
pen = 0
for x in cor:
  if x in pens:  
    pen += pens(x)
print(str(len(cor))+" "+str(pen))
Problem p03161 (python)

Fixed submission:
import sys
import math
input = sys.stdin.readline

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

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

ans=[0]*N

ans[N-2]=abs(arr[-2]-arr[-1])

for i in range(N-3,-1,-1):
	minn=100000000000000
	for j in range(min(K,N-i-1)):
		minn = min(minn,abs(arr[i]-arr[i+j+1])+ans[i+j+1])
	ans[i]=minn

print(ans[0])

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

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

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

ans=[0]*N

ans[N-2]=abs(arr[-2]-arr[-1])

for i in range(N-3,-1,-1):
	minn=math.inf
	for j in range(min(K,N-i-1)):
		minn = min(minn,abs(arr[i]-arr[i+j+1])+ans[i+j+1])
	ans[i]=minn

print(ans[0])

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

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

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

ans=[0]*N

ans[N-2]=abs(arr[-2]-arr[-1])

for i in range(N-3,-1,-1):
	minn=math.inf
	for j in range(min(K,N-i-1)):
		minn = min(minn,abs(arr[i]-arr[i+j+1])+ans[i+j+1])
	ans[i]=minn

print(ans[0])
Problem p02642 (python)

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

a = sorted(a)

dp  = [0] * (a[-1]+1)

for ai in a:
    if dp[ai]:
        dp[ai] += 1
        continue

    i = 1
    while True:
        if ai*i >= len(dp):
            break
        dp[ai*i] += 1
        i += 1

ans = 0
for ai in a:
    if dp[ai] == 1:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

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

a = sorted(a)
ads = [0]*(2*10**5)

ans = 0
dups = []
for ai in a:
    ds = make_divisors(ai)
    ok = True
    if ads[ai]:
        if ai not in dups:
            dups.append(ai)
        continue
    for d in ds:
        if ads[d]:
            ok = False
            break
    if ok:
        ads[ai] = 1
        ans += 1

print(ans - len(dups))

Buggy submission (verdict: Runtime Error):
import sympy as sp

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

a = sorted(a)
ads = [0]*(2*10**5)

ans = 0
dups = []
for ai in a:
    ds = sp.divisors(ai)
    ok = True
    if ads[ai]:
        if ai not in dups:
            dups.append(ai)
        continue
    for d in ds:
        if ads[d]:
            ok = False
            break
    if ok:
        ads[ai] = 1
        ans += 1

print(ans - len(dups))
Problem p02727 (python)

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = sorted(p)[a-x:]
q = sorted(q)[b-y:]
r = sorted(r, reverse=True)

pi = 0
qi = 0
ri = 0
while True:
    if ri > c-1: break
    if pi <= x-1 and qi <= y-1:
        if p[pi] < q[qi]:
            if p[pi] < r[ri]:
                p[pi] = r[ri]
                pi += 1
                ri += 1
            else:
                break
        else:
            if q[qi] < r[ri]:
                q[qi] = r[ri]
                qi += 1
                ri += 1
            else:
                break
    elif pi <= x-1:
        if p[pi] < r[ri]:
            p[pi] = r[ri]
            pi += 1
            ri += 1
        else:
            break
    elif qi <= y-1:
        if q[qi] < r[ri]:
            q[qi] = r[ri]
            qi += 1
            ri += 1
        else:
            break
    else:
        break

print(sum(p)+sum(q))

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = sorted(p)[a-x:]
q = sorted(q)[b-y:]
r = sorted(r, reverse=True)

pi = 0
qi = 0
ri = 0
while True:
    if ri > c-1: break
    if pi <= a-1 and qi <= b-1:
        if p[pi] < q[qi]:
            if p[pi] < r[ri]:
                p[pi] = r[ri]
                pi += 1
                ri += 1
            else:
                break
        else:
            if q[qi] < r[ri]:
                q[qi] = r[ri]
                qi += 1
                ri += 1
            else:
                break
    elif pi <= a-1:
        if p[pi] < r[ri]:
            p[pi] = r[ri]
            pi += 1
            ri += 1
        else:
            break
    elif qi <= b-1:
        if q[qi] < r[ri]:
            q[qi] = r[ri]
            qi += 1
            ri += 1
        else:
            break
    else:
        break

print(sum(p)+sum(q))

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = sorted(p)[a-x:]
q = sorted(q)[b-y:]
r = sorted(r, reverse=True)

pi = 0
qi = 0
ri = 0
while True:
    if ri > c-1: break
    if p[pi] < q[qi]:
        if p[pi] < r[ri]:
            p[pi] = r[ri]
            pi += 1
            ri += 1
        else:
            break
    else:
        if q[qi] < r[ri]:
            q[qi] = r[ri]
            qi += 1
            ri += 1
        else:
            break

print(sum(p)+sum(q))