Harryxun/stf_run huggingface dataset:
x = y = S//3 + 1
z = S - x - y
if z < y:
    x = z
    z = y
while 0 <= x <= y and 0 <= y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
    if z < y:
        x = z
        z = y
print(ans)

### FIXED CODE ###

K,S = map(int,input().split())
x = y = S//3
z = S - x - y
if z < y:
    x = z
    z = y
ans = 0
while 0 <= x <= y and 0<= y <=K and z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y -= 1
    x = y
    z = S - x - y
    if z < y:
        x = z
        z = y
x = y = S//3 + 1
z = S - x - y
if z < y:
    x = z
    z = y
while 0 <= x <= y and 0 <= y <= K and y <= z <= K:
    while 0 <= x and z <= K:
        if x == y == z:
            ans += 1
        elif x == y or y == z:
            ans += 3
        else:
            ans += 6
        x -= 1
        z += 1
    y += 1
    x = y
    z = S - x - y
    if z < y:
        x = z
        z = y
print(ans)
a, b, c = input().split()

if a < b and b < c:
  print 'No'

if a < c and c < b:
  print 'Yes'

if b < c and c < a:
  print 'Yes'

if b < a and a < c:
  print('No')
  
if c < a and a < b:
  print('Yes')
  
if c < b and b < a:
  print('No')

### FIXED CODE ###

a, b, c = input().split()
if (int(a) < int(c) and int(c) < int(b)) or (int(b) < int(c) and int(c) < int(a)):
  print('Yes')
else:
  print('No')
n,a = map(int,input().split())
print(n**2-a)

### FIXED CODE ###

n = int(input())
a = int(input())
print(n*n-a)
A,c,B=input().split()

if c == "+":
  print(A+B)
else:
  print(A-B)

### FIXED CODE ###

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

z = 1	
for a in x:
  z *= a
  if z >= 10**18:
    break
    print(-1)
  
if z<10**18
  print(z)

### FIXED CODE ###

import sys
N = int(input())
x = list(map(int,input().split()))
 
z = 1
if 0 in x:
  print(0)
  sys.exit()
  
for a in x:
  z = a*z
  if z > 10**18:
    print(-1)
    sys.exit()
  
print(z)
# coding: utf-8
N = int(input())
A = int(input())

c = N%A

if c > A:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

# coding: utf-8
N = int(input())
A = int(input())

c = N%500

if c > A:
    print("No")
else:
    print("Yes")
inpt = input.split(',')
print inpt[0]+' '+inpt[1]+' '+inpt[2]

### FIXED CODE ###

inpt = input().split(',')
print(inpt[0]+' '+inpt[1]+' '+inpt[2])
a,b,c=input()
print("Yes" if a==c else No)

### FIXED CODE ###

a,b,c=input()
print("Yes" if a==c else "No")
import math
menu = []
for i in range(0, 5):
        menu.append(int(input()))
df = max([10 - i % 10 for i in menu if i%10!=0 ])
sum = 0
for i in menu:
        sum += ((i + 9) // 10) * 10
print(sum-10+df)

### FIXED CODE ###

import math
menu = []
for i in range(0, 5):
        menu.append(int(input()))
df = max([10 - i % 10 for i in menu if i % 10 != 0 ],default=0)
sum = 0
for i in menu:
        sum += ((i + 9) // 10) * 10
if(df == 0):
        print(sum)
else:
        print(sum-df)
def main():
    N = int(input())
    X = int(input(), 2)

    def popcount(num):
        return bin(num).count("1")
    
    popc_X = popcount(X)
    puls1 = X % (popc_X + 1)
    minu1 = X % (popc_X - 1)
    dic = {0: minu1, 1: puls1}
    tow = [1]
    for i in range(1,N):
        tow.append(2*tow[i-1])
    pop_table = {i: [popcount(i), 0, 0] for i in range(1, 1+N)}
    def f(x, factor, i):
        temp = dic[factor]
        if factor:
            temp += tow[i] % (popc_X + 1)
        else:
            temp -= tow[i] % (popc_X - 1) 
        count = 1
        visited = []
        
        while temp > 0:
            if pop_table[temp][1] == 0:
                pop_table[temp][1] = count
            else:
                if pop_table[temp][2]:
                    count += pop_table[temp][1]
                    break

            if pop_table[temp][2] == 0:
                visited.append(temp)
            temp %= pop_table[temp][0]
            count += 1

        for v in visited:
            pop_table[v][1] = count - pop_table[v][1]
            pop_table[v][2] = 1
        return count
    

    # ans = [0]*N
    for i in range(N-1, -1, -1):
        xi = X ^ (1 << i)
        # print(xi, "xi")
        if X & (1<<i):
            factor = 0
        else:
            factor = 1
        print(f(xi, factor, i))
    # for a in ans:
    #     print(a)

main()

### FIXED CODE ###

N=int(input())
X=input()
num_X = int(X, base=2)
pop_x = X.count("1")
if pop_x <= 1:
    mod0 = pop_x + 1
    res0 = num_X % mod0
else:
    mod1 = pop_x - 1
    mod0 = pop_x + 1
    res1 = num_X % (mod1)
    res0 = num_X % (mod0)

# pops = [0]*(N+20)
for i in range(N):
    tmp = 0
    if X[i] == "0":
        # +
        tmp = (res0 + pow(2, N-i-1, mod0))%mod0
    else:
        if pop_x == 1:
            print(0)
            continue
        tmp = (res1 - pow(2, N-i-1, mod1))%mod1
    
    if tmp == 0:
        print(1)
        continue
    cnt = 1
    while tmp != 0:
        pop = bin(tmp).count("1")
        tmp %= pop
        cnt += 1
    print(cnt)
N = int(input())
X = int(input(), 2)

f = {}


def calcF(i, count):
    if i == 0:
        return count
    if i in f:
        return count + f[i]
    icount = bin(i).count("1")
    if icount == 0:
        return count + 1
    r = i % icount
    if r != 0:
        return calcF(r, count + 1)
    else:
        return count + 1


for i in range(1, 2 ** N):
    f[i] = calcF(i, 0)

for i in range(1, N + 1):
    a = X ^ 2 ** ((N - 1) - (i - 1))
    if a == 0:
        print(0)
    else:
        print(f[a])


### FIXED CODE ###

L, R, d = map(int, input().split())
count = 0
for i in range(L, R + 1):
    if i % d == 0:
        count += 1
print(count)
a=int(input())
l=list(map(int,input().split()))
l1=[0]
l1.extend(l)
l2=[]
l1=sorted(l1)
for i in range(a-1):
    if l1[i]<l1[i+1]:
        print(l.count(l[i+1]))
    else:
        print("0")


### FIXED CODE ###

from collections import Counter
a=int(input())
l=list(map(int,input().split()))
d=Counter(l)
# print(d)
for i in range(1,a+1):
    if i in d:
        print(d[i])
    else:
        print("0")
a,b,c=map(input().split())
if a==b==c:
  print(-1)
elif a%2==1 or b%2==1 or c%2==1:
  print(0)
else:
  ans=0
  while a%2==0 and b%2==0 and c%2==0:
    ans+=1
    a1=(b+c)//2
    b1=(c+a)//2
    c1=(a+b)//2
    a=a1
    b=b1
    c=c1
  print(ans)

### FIXED CODE ###

a,b,c=map(int,input().split())
if a%2==1 or b%2==1 or c%2==1:
  print(0)
elif a==b==c:
  print(-1)
else:
  ans=0
  while a%2==0 and b%2==0 and c%2==0:
    ans+=1
    a1=(b+c)//2
    b1=(c+a)//2
    c1=(a+b)//2
    a=a1
    b=b1
    c=c1
  print(ans)
s = input()
k = int(input())
sumtmp = 0

for i in s:
  sumlen += int(i)**(5 * (10)**15)
  if sumtmp >= k:
    print(i)

### FIXED CODE ###

s = list(input())
k = int(input())

if s[0] == '1' and len(s) == 1:
  print(1)
  exit()
elif s[0] != '1':
  print(s[0])
  exit()

if k > 100:
  for i in s:
    if i != '1':
      print(i)
      exit()
  print(1)
  
else:
  for i in s[:k]:
    if i != '1':
      print(i)
      exit()
  print(1)
  exit()
n, m = map(int, input().split())

edges = [[] for _ in range(n+1)]
for _ in range(m):
    x, y = map(int, input().split())
    edges[x].append(y)

dp = [-1 for _ in range(n+1)]

def longest_path(u):
    if dp[u] != -1:
        return dp[u]
    d = 0
    for v in edges[u]:
        d = max(d, 1+longest_path(v))
    dp[u] = d
    return d

for u in range(1, n+1):
    longest_path(u)

print(max(dp))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

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

edges = [[] for _ in range(n+1)]
for _ in range(m):
    x, y = map(int, input().split())
    edges[x].append(y)

dp = [-1 for _ in range(n+1)]

def longest_path(u):
    if dp[u] != -1:
        return dp[u]
    d = 0
    for v in edges[u]:
        d = max(d, 1+longest_path(v))
    dp[u] = d
    return d

for u in range(1, n+1):
    longest_path(u)

print(max(dp))
s = input()

ans = ""
for i in range(len(s)):
  if (i == 3) ans += "8"
  else ans += s[i]
 

print (ans)

### FIXED CODE ###

s = input()

ans = ""
for i in range(len(s)):
  if (i == 3):
    ans += "8"
  else:
    ans += s[i]
 

print (ans)
import math

# D - Maximum Average Sets
# 問題URL:http://abc057.contest.atcoder.jp/tasks/abc057_d

# N:商品の数　A個以上B個以下の範囲で選ぶ
N, A, B = map(int, input().split())
# C：最大価値組み合わせ総数
C = 0

# 商品価値をリストに入れる
V = [int(value) for value in input().split()]
# 商品価値が高い順に並び替え
V.sort(reverse=True)

# 商品価値が高いものから出来るだけ少なく（＝A個）選ぶのが最も平均価値が高くなる
S = V[0:A+1]
ave = sum(S) / A
print(S)
print(ave)

Vs = V.count(min(S)) # A個選んだ中で最も低い価値を持つ商品は、もともとの商品リストの中にいくつあるか
Ss = S.count(min(S)) # A個選んだ時中で最も低い価値を持つ商品はいくつあるか

if min(S) == max(S): # もしもA個選んだ中の商品価値が全て同じだったら
    i = A
    while i <= B and V[-i] == min(S):
        C = C + math.factorial(Vs) // ( math.factorial(Vs - i) * math.factorial(i))
        i += 1
    

else: # 商品価値が均一でなかったのなら
    # nCk = n! /( (n-k)! * k! )に基づきCを計算
    C = math.factorial(Vs) // (math.factorial(Vs - Ss) * math.factorial(Ss) )

print(C)

### FIXED CODE ###

# 元ソースコード：http://abc057.contest.atcoder.jp/submissions/1183710
# 初心者の実験用です

import math
N,A,B = map(int,input().split())
V = list(map(int,input().split()))
V.sort()
S = V[-A:]
avgmax = sum(S) / A
print(avgmax)
 
Vs = V.count(min(S))
Ss = S.count(min(S))
if min(S) != max(S):
	C = math.factorial(Vs) // (math.factorial(Vs -Ss) * math.factorial(Ss))
	print(C)
else:
	i = A
	C = 0
	while i <= B and V[-i] == min(S):
		c = math.factorial(Vs) // (math.factorial(Vs -i) * math.factorial(i))
		C = C + c
		i = i + 1
	print(C)
import math
from functools import reduce

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

for i in range(n):
    b = a[:i]+a[i+1:]
    ans = max(reduce(math.gcd, b), ans)

print(ans)

### FIXED CODE ###

import fractions

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

l_gcd = [0]
for i in range(n):
    l_gcd.append(fractions.gcd(l_gcd[-1], a[i]))
# print(l_gcd)

r_gcd = [0]
for i in range(n):
    r_gcd.append(fractions.gcd(r_gcd[-1], a[-(i+1)]))
r_gcd.reverse()
# print(r_gcd)

for i in range(n):
    ans = max(ans, fractions.gcd(l_gcd[i], r_gcd[i+1]))
print(ans)
def neighbor_sum(N, A):
    A_1 = [] 
    A_2 = []
    i = 0
    j = N-1
    change = True
    while i < j:
        if change == True:
            A_1.append(A[i])
            A_2.append(A[j])
            i += 1
            j -= 1
            change = False
        else:
            A_1.append(A[j])
            A_2.append(A[i])
            i += 1
            j -= 1
            change = True
        if N % 2 == 1:
            if change == True:
                A_1.append(A[N//2])
            else:
                A_2.append(A[N//2])
        return A_1[::-1] + A_2[:]

if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()
    diff = neighbor_sum(N, A)
    diff_sum = [abs(diff[i+1] - diff[i]) for i in range(N-1)]
    print(sum(diff_sum))



### FIXED CODE ###

def create_sum(N):
    list_align = [2 for _ in range(N)]
    for i in range(N):
        if i % 2 == 0:
            list_align[i] *= -1
    list_align[0] //= 2
    list_align[N-1] //= 2
    list_align.sort()
    return list_align

def solve(N, Array):
    sum1 = 0
    sum2 = 0
    arr = create_sum(N)
    for i in range(N):
        sum1 += arr[i] * Array[i]
        sum2 += arr[i] * Array[N-1-i]
    print(max(abs(sum1), abs(sum2)))
    
if __name__ == "__main__":
    N = int(input())
    A = [int(input()) for _ in range(N)]
    A.sort()
    solve(N, A)
from datetime import datetime,timedelta

a=[int(input()) for _ in range(4)]

t1=datetime(2000,1,1,a[0],a[1],0)
t2=datetime(2000,1,1,a[2],a[3],0)

delta=t2-t1
total_seconds=delta.seconds

ans=(total_seconds-a[4]*60)/60
print(ans)


### FIXED CODE ###

from datetime import datetime,timedelta

a=input().split()
a=[int(_) for _ in a]

t1=datetime(2000,1,1,a[0],a[1],0)
t2=datetime(2000,1,1,a[2],a[3],0)

delta=t2-t1
total_seconds=delta.seconds

ans=(total_seconds-a[4]*60)/60
print(int(ans))
n = list(map(int, input().rstrip().split(" ")))
ans = 0
coor = []
for a in n[0]:
  coor.append(list(map(int, input().rstrip().split(" "))))
  
def dis(a,b):
  ans = 0
  for i in range(a):
    ans += (a[i] - b[i])**2
  return ans**0.5
  
for a in range(len(coor)):
  for b in range(0,a):
    if coor[a]!=coor[b]:
      if dis(coor[a], coor[b]).is_integer():
        ans += 1
print(ans)

### FIXED CODE ###

n = list(map(int, input().rstrip().split(" ")))
ans = 0
coor = []
for a in range(n[0]):
  coor.append(list(map(int, input().rstrip().split(" "))))
  
def dis(a,b):
  ans = 0
  for i in range(len(a)):
    ans += (a[i] - b[i])**2
  return ans**0.5
  
for a in range(len(coor)):
  for b in range(0,a):
    if coor[a]!=coor[b]:
      if dis(coor[a], coor[b]).is_integer():
        ans += 1
print(ans)
# encoding: "utf-8"

from collections import defaultdict

# class Stdin:
#     @staticmethod
#     def read_line(converter=str):
#         return [converter(x) for x in input().split()]
    
#     @staticmethod
#     def read_lines(n, converter=str):
#         result = list()
#         for _ in range(n):
#             result.append(Stdin.read_line(converter))
#         return result
    
#     @staticmethod
#     def convert(data, converter):
#         assert(len(data) == len(converter))
#         return tuple(map(lambda x, f: f(x), data, converter))

#     @staticmethod
#     def convert_lines(datas, n, converter):
#         return [converter(data, n, converter) for data in datas]


def first_count_and_pop(xs):
    cnt = 0
    fst = xs[0]
    # cnt = xs.count(fst)
    for x in xs:
        if x != fst:
            break
        cnt += 1
    return (cnt, i)    
    

def main():
    _ = input()
    # xs = Stdin.read_line(converter=int)
    xs = [int(x) for x in input().split()]
    xs.sort()
    ys = defaultdict(int)
    i = 0
    j = len(xs)
    while i < j:
        key = xs[0]
        cnt, i = first_count_and_pop(xs[i:])
        ys[key] += cnt
        ys[key-1] += cnt
        ys[key+1] += cnt

    print(max(ys.values()))

# def main_():
#     input()
#     xs = Stdin.read_line(converter=int)
#     xs.sort()
#     counts = list()
#     for i in range(100000):
#         if not xs:
#             counts.extend([0] * (100000 - len(counts)))
#             break     
#         elif i == xs[0]:
#             cnt, xs = first_count_and_pop(xs)
#             counts.append(cnt)
#         else:
#             counts.append(0)
#     m = 0
#     for i in range(0, 100000):
#         if i == 0:
#             temp = counts[i] + counts[i+1]
#         elif i == 100000 - 1:
#             temp = counts[i-1] + counts[i]
#         else:
#             temp = counts[i-1] + counts[i] + counts[i+1]
#         if m < temp:
#             m = temp
#     print(m)

if __name__ == "__main__":
    main()

### FIXED CODE ###

input()
a_list = [int(s) for s in input().split()]

count = [0]*100002

for a in a_list:
    count[a] += 1
    count[a+1] += 1
    count[a+2] += 1
    
print(max(count))
N=int(input())
AC=0
WA=0
TLE=0
RE=0
 
for k in range(N):
  K=input()
  if K=="AC":
    AC=AC+1
  elif K=="WA":
    WA=WA+1
  elif K=="TLE":
    TLE=TLE+1
  else:
    RE=RE+1
 
print("AC x " + AC)
print("WA x " + RE)
print("TLE x " + TLE)
print("RE x " + RE)

### FIXED CODE ###

N=int(input())
AC=0
WA=0
TLE=0
RE=0
 
for k in range(N):
  K=input()
  if K=="AC":
    AC=AC+1
  if K=="WA":
    WA=WA+1
  if K=="TLE":
    TLE=TLE+1
  if K=="RE":
    RE=RE+1
 
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))
num=int(input())

for i in range(num):
	a,b,c=input().split(" ")
	if(a==b==c):
		print("YES")
	else:	
		print("NO"

### FIXED CODE ###

num=int(input())

for i in range(num):
	a=list(map(int,input().split(" ")))
	a.sort()
	if(a[0]**2+a[1]**2==a[2]**2):
		print("YES")
	else:	
		print("NO")
from functools import reduce
from math import gcd

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

c=max(A)+1
D=[0]*c
div=[0]*c
P=[]

for i in range(2,c):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>=c  or j>D[i] :
           break
        D[i*j]=j
g=c
f=0
for i in A:
    if i==1:
        continue
    temp=i
    if temp==D[temp]:
        if div[D[temp]]==1:
            f=1
            break
        div[D[temp]]+=1
        continue
    while temp!=D[temp]:
        if div[D[temp]]==1:
            f=1
            break
        div[D[temp]]+=1
        temp=temp//D[temp]
    if f==1:
        break

if f==0:
    print('pairwise coprime')

elif reduce(gcd, A) == 1:
    print('setwise coprime')
    hoge

else:
    print('not coprime')

### FIXED CODE ###

from functools import reduce
from math import gcd

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

c=max(A)+1
D=[0]*c
div=[0]*c
P=[]

for i in range(2,c):
    if D[i]==0:
        P.append(i)
        D[i]=i
    for j in P:
        if i*j>=c  or j>D[i] :
           break
        D[i*j]=j
f=0
for i in A:
    if i==1:
        continue
    temp=i
    while temp!=1:
        if div[D[temp]]==1:
            f=1
            break
        div[D[temp]]+=1
        temp2=D[temp]
        while temp%temp2==0 and temp>=temp2:
            temp=temp//temp2
    if f==1:
        break
        


if max(div)<=1 and f==0:
    print('pairwise coprime')

elif reduce(gcd, A) == 1:
    print('setwise coprime')

else:
    print('not coprime')
S = int(input())

h = intS // 3600

m = S % 3600 // 60

s = S % 3600 % 60

print(str(h) + ':' + str(m) + ':' + str(s))

### FIXED CODE ###

S = int(input())

h = S // 3600

m = S % 3600 // 60

s = S % 3600 % 60

print(str(h) + ':' + str(m) + ':' + str(s))
numbers = input().split()
x = input().split()
y = input().split()
z = input().split()

k = int(numbers[3])

x.sort(reverse=True)
if len(x) > k:
    del x[k::]
y.sort(reverse=True)
if len(y) > k:
    del y[k::]
z.sort(reverse=True)
if len(z) > k:
    del z[k::]

answer = []

for i in x:
    for j in y:
        price = int(i)+int(j)
        answer.append(price)
answer[k::]

for m, mn in enumerate(z):
    price = answer[m] + mn
    answer.append(price)

answer.sort(reverse=True)
del answer[int(numbers[3])::]

for l in answer:
    print(l)


### FIXED CODE ###

numbers = input().split()
x = input().split()
y = input().split()
z = input().split()

k = int(numbers[3])

answer = []
for i in x:
    for j in y:
        price = int(i)+int(j)
        answer.append(price)
answer.sort(reverse=True)
del answer[k::]
f_ans = []
for m in answer:
    for n in z:
        price = m + int(n)
        f_ans.append(price)

f_ans.sort(reverse=True)
del f_ans[k::]

for l in f_ans:
    print(l)
K,S=map(int,input().split())
ans=0
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z=S:
        ans+=1
print(ans)

### FIXED CODE ###

r,g=map(int,input().split())
X=0
for i in range(r+1):
  for j in range(r+1):
    k=g-i-j
    if k>=0 and k<=r:
      X+=1
print(X)
a=int(input())
b=list(map(int,input().split()))
c=b.sorted()
d=0
for i in range(a):
  b[i]!=b[i]
  d+=1
if d<=2:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
c=sorted(b)
d=0
for i in range(a):
  if b[i]!=c[i]:
    d+=1
if d<=2:
  print('YES')
else:
  print('NO')
x, a, b = map(int,input().split())

if |x - b| > |x - a|:
  print("A")
  
else:
  print("B")
  


### FIXED CODE ###

x, a, b = map(int,input().split())

if abs(x - b) > abs(x - a):
  print("A")
  
else:
  print("B")
from fractions import gcd

INF = 2 << 30
V = 1002
G = [[] for _ in xrange(V)]
visited = [False]*V

def add_edge(fro, to, cap):
    G[fro].append([to,cap,len(G[to])])
    G[to].append([fro,0,len(G[fro])-1])

def dfs(v,t,f):
    if v == t:
        return f
    visited[v] = True
    for i,(to,cap,rev) in enumerate((G[v])):
        if visited[to] or cap == 0:
            continue        
        d = dfs(to,t,min(f,cap))
        if d > 0:
            G[v][i][1] -= d
            G[to][rev][1] += d
            return d
    return 0

def max_flow(s,t):
    flow = 0
    while True:
        for i in xrange(V):
            visited[i] = False
        f = dfs(s,t,INF)
        if f == 0:
            return flow
        flow += f

while True:
    m,n = map(int,raw_input().split())
    if (m,n) == (0,0):
        break
    V = m+n+2
    G = [[] for _ in xrange(V)]
    visited = [True] * V
    data = []
    while len(data) < n+m:
        data += map(int,raw_input().split())
    blue = data[:m]
    red = data[m:]
    for i in xrange(m):
        add_edge(V-2,i,1)
    for i in xrange(m,m+n):
        add_edge(i,V-1,1)
    for i,b in enumerate(blue):
        for j,r in enumerate(red,m):
            if gcd(b,r) != 1:
                add_edge(i,j,1)
    print max_flow(V-2,V-1)

### FIXED CODE ###

from fractions import gcd

V = 1001
G = []
visited = []
match = []

def add_edge(u,v):
    G[u].append(v)
    G[v].append(u)

def dfs(v):
    visited[v] = True
    for u in G[v]:
        w = match[u]
        if w < 0 or not visited[w] and dfs(w):
            match[v] = u
            match[u] = v
            return True

def bipartite_matching():
    global match,visited
    res = 0
    match = [-1]*V
    for v in xrange(V):
        if match[v] < 0:
            visited = [False]*V
            if dfs(v):
                res += 1
    return res

while True:
    m,n = map(int,raw_input().split())
    V = m+n
    if V == 0:
        break
    G = [[] for _ in xrange(V)]
    data = []
    while len(data) < V:
        data += map(int,raw_input().split())
    for i,b in enumerate(data[:m]):
        for j,r in enumerate(data[m:],m):
            if gcd(b,r) != 1:
                add_edge(i,j)
    print bipartite_matching()
n=int(input())
a=sorted(list(map(int,input().split())) for _ in range(n))
print(sum(a[-1])

### FIXED CODE ###

n=int(input())
a=sorted(list(map(int,input().split())) for _ in range(n))
print(sum(a[-1]))
import statistics

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

a = round(statistics.mean(x))
sums = 0
for i in x:
    sums += (i - a) ** 2
print(sums)


### FIXED CODE ###

import statistics

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

a = round(statistics.mean(x))
sums = 0
for i in x:
    sums += (i - a) ** 2
print(sums)
a = int(input())
s = input()
  if a <= 3200:
    print(s)
else:
    print("red")

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print("red")
n, k = map(int, input().split())
a = list(map(int, input().split())
ans = 0
dic = {}
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
dic = sorted(dic.items(), key=lambda x: x[1])
while len(dic) > k:
    ans += dic[0][1]    
    del dic[0]
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
dic = {}
for i in a:
    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1
dic = sorted(dic.items(), key=lambda x: x[1])
#while len(dic) > k:
#    ans += dic[0][1]    
#    del dic[0]
for i in range(len(dic)-k):
    ans += dic[i][1]
print(ans)