Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a=sorted(a)
f=sorted(f,reverse=True)


def is_lessthanK(X):
  ans=0
  for i in range(n):
    ans+=max(0,a[i]-X//f[i])
    if ans > k:
      return False
  return True


ng=-1
ok=10**13
while ok-ng>1:
  mid=(ok+ng)//2
  if is_lessthanK(mid):
    ok=mid
  else:
    ng=mid
print(ok)



### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
f=list(map(int,input().split()))
a=sorted(a)
f=sorted(f,reverse=True)


def is_lessthanK(X):
  ans=0
  for A,F in zip(a,f):
    if A*F>X:
      ans+=A-X//F
    if ans > k:
      return False
  return True


ng=-1
ok=a[-1]*f[0]
while ok-ng>1:
  mid=(ok+ng)//2
  if is_lessthanK(mid):
    ok=mid
  else:
    ng=mid
print(ok)
### BUGGY CODE ###

import sys
input=sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
for x in range(N):
    y=x+1
    z=len([n for n in A if n==y])
    print(z)
    



### FIXED CODE ###

import sys
input=sys.stdin.readline
import collections

N=int(input())
A=list(map(int,input().split()))
c=collections.Counter(A)
for x in range(N):
    y=x+1
    
    print(c[y])
### BUGGY CODE ###

N,K=map(int,input().split())
while (N-K)>=0:
    N=N-K

if N>=abs(N-K):
    print(int(abs(N-K)))
else:
    print(int(N))

### FIXED CODE ###

N,K=map(int,input().split())
t=N%K
print(min(t,K-t))
### BUGGY CODE ###

N=int(input())
Sister=[int(input()) for i in range(N)]
Paper=[i for i in Sister if Sister.count(i)%2==1]
print(len(Paper))

### FIXED CODE ###

N=int(input())
Sister={}
Paper=0
for i in range(N):
  index=int(input())
  if index not in Sister:
    Sister[index]=1
  else:
    Sister[index]+=1
for i in Sister:
  if Sister[i]%2==1:
    Paper+=1
print(Paper)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

def main():
    N, M = LI()
    A = LI()
    BC = []
    for _ in range(M):
        BC.append(LI())
    A.sort()
    for B, C in BC:
        for i in range(B):
            if C <= A[i]:
                break
            A[i] = C
        A.sort()
    ans = sum(A)
    return ans

print(main())

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict
from operator import itemgetter

def main():
    N, M = LI()
    A = LI()
    BC = []
    for _ in range(M):
        BC.append(LI())
    for a in A:
        BC.append([1, a])
    BC.sort(reverse=True, key=itemgetter(1))
    cnt = 0
    ans = 0
    for B, C in BC:
        if cnt + B >= len(A):
            ans += C * (len(A) - cnt)
            break
        ans += C * B
        cnt += B
    return ans

print(main())
### BUGGY CODE ###

S = input()
Q = int(input())
L = [list(input().split()) for i in range(Q)]

ans = S
hanten = 0
for l in L:
    if len(l) == 1:
        hanten += 1
    elif (l[1] == '1' and hanten % 2 == 0) or (l[1] == '2' and hanten % 2 == 1):
        ans = l[2] + ans
    else:
        ans = ans + l[2]
if hanten % 2 == 1:
    ans = ''.join(list(reversed(ans)))
print(ans)

### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())
L = [list(input().split()) for i in range(Q)]

hanten = 0
t = deque([S])

for l in L:
    if len(l) == 1:
        hanten += 1
    elif (l[1] == '1' and hanten % 2 == 0) or (l[1] == '2' and hanten % 2 == 1):
        t.appendleft(l[2])
    else:
        t.append(l[2])

ans = ''.join(t)
if hanten % 2 == 1:
    ans = ''.join(list(reversed(ans)))
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
Nj = N
while True:
    Ni = Nj
    Nj = abs(Ni - K)
    if Ni > N:
        print(N)
        break
    elif Nj > Ni:
        print(Ni)
        break
    elif K == 1 or Nj == K:
        print(0)
        break
    else:
        continue


### FIXED CODE ###

n, k = map(int, input().split())
if n % k == 0:
    print(0)
else:
    l = [n]
    p = n // k
    c = n - (p * k)
    half = k // 2
    while c > half:
        c = abs(c - k)
    l.append(c)
    print(min(l))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n = int(input())

Li = []
for i in range(n):
    s = input()
    if s in Li:
        pass
    else:
        Li.append(s)

print(len(Li))


### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())

Li = [input() for _ in range(n)]
Li.sort()
s= Li[0]
c =1
for l in Li[1:]:
    if l == s:
        pass
    else:
        c+=1
        s = l
print(c)
### BUGGY CODE ###

n = int(input())
s = str(input())
 
R = []
G = []
B = []
for i in range(n):
  if s[i] == "R":
    R.append(i+1)
  elif s[i] == "G":
    G.append(i+1)
  else:
    B.append(i+1)
 
  
ans = 0
 
for i in range(len(R)):
  for j in range(len(G)):
    temp = 0
    if 2*R[i] - G[j] in B:
      temp += 1
    if 2*G[j] - R[i] in B:
      temp += 1
    if (R[i]+G[j])/2 in B:
      temp += 1
    ans += len(B)- temp
 
print(ans)

### FIXED CODE ###

n = int(input())
s = str(input())

R = []
G = []
B = []
for i in range(n):
  if s[i] == "R":
    R.append(i+1)
  elif s[i] == "G":
    G.append(i+1)
  else:
    B.append(i+1)

  
ans = 0

for i in range(len(R)):
  for j in range(len(G)):
    temp = 0
    if 2*R[i] - G[j] >0 and 2*R[i] - G[j] <= n:
      if s[2*R[i] - G[j] -1] == "B":
        temp += 1
    if 2*G[j] - R[i] >0 and 2*G[j] - R[i] <= n:
      if s[2*G[j] - R[i]-1] == "B":
        temp += 1
    if (R[i]+G[j])%2 == 0:
      if s[(R[i]+G[j])//2-1] == "B":
        temp += 1
    ans += len(B)- temp

print(ans)
### BUGGY CODE ###

from collections import defaultdict
import bisect
N, M = map(int, input().split())
P = [[int(i) for i in input().split()] for _ in range(M)]
D = defaultdict(list)

for p, y in sorted(P):
  D[p] += [y]
  
for p, y in P:
  z = D[p].index(y)
  print ("%06d%06d"%(p, z+1))


### FIXED CODE ###

from collections import defaultdict
import bisect
N, M = map(int, input().split())
P = [[int(i) for i in input().split()] for _ in range(M)]
D = defaultdict(list)

for p, y in sorted(P):
  D[p] += [y]
  
for p, y in P:
  z = bisect.bisect(D[p], y)
  print ("%06d%06d"%(p, z))
### BUGGY CODE ###

from collections import Counter
from itertools import groupby


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def ilen(ll):
    return sum(1 for _ in ll)


def solve():
    H, W, M = read_ints()
    hw = []
    for _ in range(M):
        hw.append(read_ints())
    hw.sort()

    max_ws = {}
    max_count_ws = 0
    for h, ws in groupby(hw, key=lambda pair: pair[0]):
        ws = list(ws)
        max_count_ws = max(max_count_ws, len(ws))
        max_ws[h] = [w for _, w in ws]
    max_ws = {k: max_ws[k] for k in max_ws if len(max_ws[k]) == max_count_ws}

    hw.sort(key=lambda pair: pair[1])
    max_hs = {}
    max_count_hs = 0
    for w, hs in groupby(hw, key=lambda pair: pair[1]):
        hs = list(hs)
        max_count_hs = max(max_count_hs, len(hs))
        max_hs[w] = [h for h, _ in hs]
    max_hs = {k: max_hs[k] for k in max_hs if len(max_hs[k]) == max_count_hs}

    counter = Counter()
    for v in max_hs.values():
        counter += Counter(v)
    for k in max_ws.keys():
        if counter[k] != len(max_hs):
            return max_count_ws+max_count_hs
    return max_count_ws+max_count_hs-1


if __name__ == '__main__':
    print(solve())


### FIXED CODE ###

from collections import Counter
from itertools import groupby


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def ilen(ll):
    return sum(1 for _ in ll)


def solve():
    H, W, M = read_ints()
    hw = []
    for _ in range(M):
        hw.append(tuple(read_ints()))
    hw.sort()

    rows = set()
    max_count_row = 0
    for h, ws in groupby(hw, key=lambda pair: pair[0]):
        count = ilen(ws)
        if count == max_count_row:
            rows.add(h)
        elif count > max_count_row:
            rows = set([h])
            max_count_row = count

    hw.sort(key=lambda pair: pair[1])
    cols = set()
    max_count_col = 0
    for w, hs in groupby(hw, key=lambda pair: pair[1]):
        count = ilen(hs)
        if count == max_count_col:
            cols.add(w)
        elif count > max_count_col:
            cols = set([w])
            max_count_col = count

    hw = set(hw)
    for h in rows:
        for w in cols:
            if (h, w) not in hw:
                return max_count_row+max_count_col
    return max_count_row+max_count_col-1


if __name__ == '__main__':
    print(solve())
### BUGGY CODE ###

from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    S = input()[:-1]

    res = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            for k in range(j+1, N):
                if S[i] != S[j] and S[j] != S[k] and S[k] != S[i] and j-i != k-j:
                    res += 1
    
    print(res)


if __name__ == '__main__':
    main()

### FIXED CODE ###

from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    S = input()[:-1]

    A = [[] for _ in range(3)]
    for i in range(N):
        if S[i:i+1] == "R":
            A[0].append(i)
        if S[i:i+1] == "G":
            A[1].append(i)
        if S[i:i+1] == "B":
            A[2].append(i)

    res = 0
    for P in itertools.permutations(range(3)):
        a = P[0]
        b = P[1]
        c = P[2]
        for i in A[a]:
            x = bisect.bisect_left(A[b], i)
            for j in A[b][x:]:
                res += len(A[c]) - bisect.bisect_left(A[c], j)
    
    for l in range(1, math.ceil(N/2)):
        n = 0
        while n+l*2 < N:
            if S[n] != S[n+l] and S[n+l] != S[n+l*2] and S[n+l*2] != S[n]:
                res -= 1
            n += 1
    
    print(res)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

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

dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]].append(i)
    else:
        dic[a[i]] = [i]

zero = [-1 for i in range(n)]
for key, value in dic.items():
    num = len(value)
    for i in range(num-1):
        zero[value[i]] = value[i+1] - value[i] + 1
    zero[value[-1]] = n - value[-1] + value[0] + 1

lst = [zero]
while lst[-1][0] <+ n*k - 1:
    before = lst[-1]
    after = []
    for i in range(n):
        after.append(before[i] + before[(before[i]+i)%n])
    lst.append(after)
lst.pop()

i = 0
while lst != []:
    lsti = lst.pop()
    while True:
        if i + lsti[i%n] <= n*k - 1:
            i = i + lsti[i%n]
        else:
            break

i = i % n
nokori = a[i:]
lst = []
dic = {}
ko = 0
for i in range(len(nokori)):
    if nokori[i] not in dic:
        lst.append(nokori[i])
        dic[nokori[i]] = ko
        ko += 1
    else:
        lst = lst[:dic[nokori[i]]]
        dic = {}
        for j in range(len(lst)):
            dic[lst[j]] = j
        ko = len(lst)
print(*lst)

### FIXED CODE ###

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

dic = {}
for i in range(n):
    if a[i] in dic:
        dic[a[i]].append(i)
    else:
        dic[a[i]] = [i]

zero = [-1 for i in range(n)]
for key, value in dic.items():
    num = len(value)
    for i in range(num-1):
        zero[value[i]] = value[i+1] - value[i] + 1
    zero[value[-1]] = n - value[-1] + value[0] + 1

lst = [zero]
while lst[-1][0] <+ n*k - 1:
    before = lst[-1]
    after = []
    for i in range(n):
        after.append(before[i] + before[(before[i]+i)%n])
    lst.append(after)
lst.pop()

i = 0
while lst != []:
    lsti = lst.pop()
    while True:
        if i + lsti[i%n] <= n*k - 1:
            i = i + lsti[i%n]
        else:
            break

i = i % n
nokori = a[i:]
lst = []
dic = {}
ko = 0
for i in range(len(nokori)):
    if nokori[i] not in dic:
        lst.append(nokori[i])
        dic[nokori[i]] = ko
        ko += 1
    else:
        lst = lst[:dic[nokori[i]]]
        dic = {}
        for j in range(len(lst)):
            dic[lst[j]] = j
        ko = len(lst)
print(*lst)
### BUGGY CODE ###

lis =[]
abc =[]
count = 0

N = int(input())
for _ in range(N):
    lis.append(input()) 

for i in lis:
    if i in abc:
        pass
    else:
        abc.append(i)
        count += 1

print(count)
    

### FIXED CODE ###

n = int(input())

ans = len(set(input() for i in range(n)))

print(ans)
### BUGGY CODE ###

N,M,K = map(int, input().split())
field = [[0]*M for i in range(N)]
def reverse(x):
    if x == 0:
        return 1
    else:
        return 0
now = 0
for i in range(N+1):
    if N - 2 * i ==0:
        for j in range(M):
            field[i][j] = reverse(field[i][j])
            now = sum(map(sum,field))
    elif (K - now) % (N - 2 * i) == 0 and (K - now) / (N - 2 * i) <= M and  (K - now) / (N - 2 * i) >= 0:
        print("Yes")
        exit(0)
    elif i == N:
        print("No")
        exit(0)
    else:
        for j in range(M):
            field[i][j] = reverse(field[i][j])
            now = sum(map(sum,field))


### FIXED CODE ###

N,M,K = map(int, input().split())
field = [[0]*M for i in range(N)]
def reverse(x):
    if x == 0:
        return 1
    else:
        return 0
now = 0
for i in range(N+1):
    if N - 2 * i ==0:
        for j in range(M):
           now += M
    elif (K - now) % (N - 2 * i) == 0 and (K - now) / (N - 2 * i) <= M and  (K - now) / (N - 2 * i) >= 0:
        print("Yes")
        exit(0)
    elif i == N:
        print("No")
        exit(0)
    else:
        now += M
### BUGGY CODE ###

import fractions
from functools import reduce
N = int(input())
l = list(map(int,input().split()))


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

if len(l) == 2:
    memo = max(l)
else:
    memo = 1
    for i in range(N):
        g = gcd(*(l[:i]+l[i+1:]))
        if g > memo:
            memo = g

print(memo)





### FIXED CODE ###

import fractions

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

L = [0]
R = [0]

gl = 0
gr = 0
for i in range(N):
    gl = fractions.gcd(gl,l[i])
    L.append(gl)
    gr = fractions.gcd(gr,l[N-1-i])
    R.append(gr)

M = []
for i in range(N+1):
    M.append(fractions.gcd(L[i-1],R[N-i]))

print(max(M))
### BUGGY CODE ###

from collections import deque
import numpy as np

H,W = [int(i) for i in input().split()]
l = [list(input()) for _ in range(H)]
check = [[False]*W for _ in range(H)]
ans = [[0]*W for _ in range(H)]
q = deque()

for i in range(H):
    for j in range(W):
        if l[i][j] == '#':
            q.append([i,j])

while q:
    i,j = q.popleft()
    for next_i, next_j in [[i+1,j], [i-1,j], [i,j+1], [i,j-1]]:
        if 0 <= next_i < H and 0 <= next_j < W:
            if not check[next_i][next_j] and l[next_i][next_j] == '.':
                check[next_i][next_j] = True
                ans[next_i][next_j] = ans[i][j] + 1
                q.append([next_i,next_j])

a = 0
for i in range(H):
    for j in range(W):
        a = max(ans[i][j], a)
print(a)


### FIXED CODE ###

from collections import deque

H,W = [int(i) for i in input().split()]
l = [list(input()) for _ in range(H)]
ans = [[-1]*W for _ in range(H)]
q = deque()

for i in range(H):
    for j in range(W):
        if l[i][j] == '#':
            q.append([i,j])
            ans[i][j] = 0

t = 0
while q:
    i,j = q.popleft()
    for next_i, next_j in [[i+1,j], [i-1,j], [i,j+1], [i,j-1]]:
        if 0 <= next_i < H and 0 <= next_j < W:
            if ans[next_i][next_j] == -1 and l[next_i][next_j] == '.':
                ans[next_i][next_j] = ans[i][j] + 1
                t = max(t, ans[next_i][next_j])
                q.append([next_i,next_j])

print(t)
### BUGGY CODE ###

h,w = map(int,input().split())
a = [input() for i in range(h)]

cnt = [[-1]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            cnt[i][j] = 0

ans = 0
f = True
while f:
    f = False
    for i in range(h):
        for j in range(w):
            if cnt[i][j] != ans:
                if cnt[i][j]==-1 or cnt[i][j]>ans:
                    f = True
                continue
            for k,l in [[-1,0],[1,0],[0,-1],[0,1]]:
                if 0<=i+k<h and 0<=j+l<w and cnt[i+k][j+l]==-1:
                    cnt[i+k][j+l] = ans+1
    if f:ans += 1
print(ans)



### FIXED CODE ###

h,w = map(int,input().split())
a = [input() for i in range(h)]

from collections import deque
q = deque()
reach = [[False]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j]=='#':
            q.append([i,j,0])
            reach[i][j] = True

ans = 0
while q:
    i,j,cnt = q.popleft()
    ans = max(ans,cnt)
    for k,l in [[1,0],[-1,0],[0,1],[0,-1]]:
        if 0<=i+k<h and 0<=j+l<w:
            if not reach[i+k][j+l]:
                q.append([i+k,j+l,cnt+1])
                reach[i+k][j+l] = True

print(ans)
### BUGGY CODE ###

R,G,B,N=map(int,input().split())
r,g,b,count=0,0,0,0
while(B*b<=N):
	g=0
	while(G*g<=N-B*b):
		r=(-G*g-B*b+N)/R
		if r==int(r): count+=1
		g+=1
	b+=1
print(count)

### FIXED CODE ###

R,G,B,N=map(int,input().split())
r,g,b,count=0,0,0,0
for b in range(N+1):
	for g in range(N+1):
		r=-G*g-B*b+N
		if r<0:break
		if (r%R==0): count+=1
print(count)
### BUGGY CODE ###

n = int(input())
list_int = list(map(int, input().split()))
FLAG = True
ans = 1
for i in list_int:
  ans *= i
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

n = int(input())
list_int = list(map(int, input().split()))
if 0 in list_int:
  print(0)
else:
  ans = 1
  for i in list_int:
    ans *= i
    if ans > 10**18:
      print(-1)
      break
    else:
      continue
  if ans <= 10**18:
    print(ans)
### BUGGY CODE ###

import sys
from collections import deque
n, m = [int(i) for i in sys.stdin.readline().split()]
dis_dict = dict()
parent = [i for i in range(n)]

def find_root(a):
    ls = []
    while parent[a] != a:
        ls.append(a)
        a = parent[a]
    for l in ls:
        parent[l] = a
    return a

def is_same(a, b):
    root_a = find_root(a)
    root_b = find_root(b)
    return root_b == root_a

def unite(a, b):
    root_a = find_root(a)
    root_b = find_root(b)
    if root_a != root_b:
        parent[root_b] = root_a

graph = {j:[] for j in range(n)}
for i in range(m):
    l, r, d = [int(i) for i in sys.stdin.readline().split()]
    l -= 1
    r -= 1
    unite(l, r)
    graph[l].append((r, d))
    graph[r].append((l, -d))

yet = list(range(n))
x_ls = [None for i in range(n)]
x_ls[0] = 0
que = deque([0])
flg = True
while len(que) > 0:
    cur = que.popleft()
    if cur in yet:
        yet.remove(cur)
    cur_pos = x_ls[cur]
    for _next, dis in graph[cur]:
        if x_ls[_next] is None:
            x_ls[_next] = cur_pos + dis
            que.append(_next)
        else:
            if x_ls[_next] != cur_pos + dis:
                flg = False
                break
    if not flg:
        break
    if len(que) == 0 and len(yet) > 0:
        que.append(yet[0])
        x_ls[yet[0]] = 0
        yet.pop(0)
if flg:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

n, m = [int(i) for i in sys.stdin.readline().split()]
parent = [i for i in range(n)]

graph = {j:[] for j in range(n)}
for i in range(m):
    l, r, d = [int(i) for i in sys.stdin.readline().split()]
    l -= 1
    r -= 1
    graph[l].append((r, d))
    graph[r].append((l, -d))

already = set()
x_ls = [None for i in range(n)]
x_ls[0] = 0
stack = list(range(n))[::-1]
flg = True
while len(stack) > 0:
    cur = stack.pop(-1)
    if cur in already:
        continue
    if x_ls[cur] is None:
        cur_pos = 0
    else:
        cur_pos = x_ls[cur]
    already.add(cur)
    for _next, dis in graph[cur]:
        if x_ls[_next] is None:
            x_ls[_next] = cur_pos + dis
            stack.append(_next)
        else:
            if x_ls[_next] != cur_pos + dis:
                flg = False
                break
    if not flg:
        break
if flg:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

a, b, x = (int(x) for x in input().split())

n = 0
for i in range(a, b+1):
  if (i%x) == 0:
    n += 1

print(n)

### FIXED CODE ###

a, b, x = (int(x) for x in input().split())
 
f1 = (a - 1) // x
f2 = b // x
print(f2 - f1)
### BUGGY CODE ###

N = int(input())

s = []
for _ in range(N):
  s.append(''.join(sorted(str(input()))))   

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
      if s[i] == s[j]:
        cnt += 1

print(cnt)

### FIXED CODE ###

import math
from collections import Counter

N = int(input())

s = []
for _ in range(N):
  s.append(''.join(sorted(str(input()))))
  
c = Counter(s) 

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

cnt = 0  
for i in c.values():
  if i >= 2:
    cnt += combinations_count(i, 2)

print(cnt)
### BUGGY CODE ###

from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def d(n):
    divisors = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i * i != n:
                divisors.append(n // i)

    return divisors


def main():
    N = int(input())
    # A = [
    #     int(input())
    #     for _ in range(N)
    # ]
    A = [int(a) for a in input().split()]

    res_c = 0
    res1 = []
    bucket = [0] * (N + 1)

    i = N
    for Ai in reversed(A):
        i -= 1
        k = i + 1
        if k * 2 > N:
            if Ai == 1:
                res_c += 1
                res1.append(k)
                for j in range(2, int(k ** 0.5) + 1):
                    if k % j == 0:
                        bucket[j] += 1
                        if j * j != k:
                            bucket[k // j] += 1
            continue
        if k == 1:
            if res_c % 2 != Ai:
                res_c += 1
                res1.append(k)
            break

        if bucket[k] % 2 != Ai:
            res_c += 1
            res1.append(k)
            for j in range(2, int(k ** 0.5) + 1):
                if k % j == 0:
                    bucket[j] += 1
                    if j * j != k:
                        bucket[k // j] += 1
    print(res_c)
    print(*res1)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


def d(n):
    divisors = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i * i != n:
                divisors.append(n // i)

    return divisors


def main():
    N = int(input())
    # A = [
    #     int(input())
    #     for _ in range(N)
    # ]
    A = [int(a) for a in input().split()]

    res1 = []
    bucket = [0] * (N + 1)

    i = N
    for Ai in reversed(A):
        i -= 1
        k = i + 1
        if k * 2 > N:
            if Ai == 1:
                res1.append(k)
                bucket[k] = 1

            continue
        if k == 1:
            if len(res1) % 2 != Ai:
                res1.append(k)
            break

        s = 0
        j = 0
        while True:
            j+=1
            if j * k > N:
                break
            s += bucket[j * k]

        if s % 2 != Ai:
            res1.append(k)
            bucket[k] = 1
    print(len(res1))
    print(*res1)


if __name__ == '__main__':
    main()