Harryxun/stf_run huggingface dataset:
# coding: utf-8
import sys
from bisect import bisect_left, bisect_right, insort
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [0] + lr()  # 1-indexed
graph = [[] for _ in range(N+1)]  # 1-indexed
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

answer = [0] * (N+1)  # 1-indexed
INF = 10 ** 6
parent = [0] * (N+1)

def dfs(n, arr):
    """arrはLISのリスト、answerのリストを更新してから子にarrを渡す"""
    i = bisect_left(arr, INF)
    answer[n] = i
    for c in graph[n]:
        if c == parent[n]:
            continue
        parent[c] = n
        new = arr[:]
        i = bisect_left(new, A[c])
        new[i] = A[c]
        dfs(c, new)

B = [INF] * N
B[0] = 0
dfs(1, B)
for a in answer[1:]:
    print(a)


### FIXED CODE ###

# coding: utf-8
import sys
from bisect import bisect_left, bisect_right, insort
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [0] + lr()  # 1-indexed
graph = [[] for _ in range(N+1)]  # 1-indexed
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

answer = [0] * (N+1)  # 1-indexed
INF = 10 ** 10
parent = [-1] * (N+1)

def dfs(n):
    """arrはLISのリスト、answerのリストを更新してから子にarrを渡す"""
    i = bisect_left(dp, INF)
    answer[n] = i
    for c in graph[n]:
        if c == parent[n]:
            continue
        parent[c] = n
        i = bisect_left(dp, A[c])
        old = dp[i]
        dp[i] = A[c]
        dfs(c)
        dp[i] = old

dp = [INF] * (N+1)
dp[0] = A[1]
dfs(1)
for a in answer[1:]:
    print(a)
N = int(input())
alphabet = [chr(ord('a') + i) for i in range(26)]
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}

ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    N = N // 26

print(''.join(list(reversed(ans))))


### FIXED CODE ###

import string

N = int(input())
alphabet = list(string.ascii_lowercase)
num2alphabet = {i + 1: a for i, a in enumerate(alphabet)}
num2alphabet[0] = "z"
ans = ""

while N > 0:
    num = N % 26
    ans += num2alphabet[num]
    if N <= 26:
        break

    if num == 0:
        N -= 1

    N = N // 26

print(''.join(list(reversed(ans))))
print(x*x*x)


### FIXED CODE ###

x = int(input())

print(x*x*x)
import numpy as np

N, M = map(int, input().split())
A = np.array([int(input()) for _ in range(M)])
q = 1000000007

cost = np.zeros(N + 1, dtype=np.int64)
cost[0] = 1
cost[1] = 1
cost[A] = 0
cost[2] = cost[0] + cost[1]

for i in range(1, N + 1):
    cost[A] = 0
    cost[i] = (cost[i - 1] + cost[i - 2]) % q

print(cost[-1])


### FIXED CODE ###

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
q = 1000000007

if N == 1:
    if M == 0:
        print(1)
    elif M == 1:
        print(0)
else:
    cost = [0 for _ in range(N + 1)]
    cost[0] = 1

    cnt = 0
    A.append([0])
    for i in range(1, N + 1):
        if i == A[cnt]:
            cost[i] = 0
            cnt += 1
        else:
            cost[i] = (cost[i - 1] + cost[i - 2]) % q

    print(cost[-1])
a,b,c,d=int(input().split())
if a==b or b==c or c==d:
  print("Bad")
else:
  print("Yes")


### FIXED CODE ###

s=list(input())
if s[0]==s[1] or s[1]==s[2] or s[2]==s[3]:
  print("Bad")
else:
  print("Good")
#

import sys
from math import gcd
input=sys.stdin.readline

def main():
    K=int(input())
    if K%2==0:
        print(-1)
        exit()
    if K==5:
        print(-1)
    s=set()
    r=7%K
    rsum=r
    s.add(r)
    for i in range(10**6):
        if rsum==0:
            print(i+1)
            exit()
        r=(r*10)%K
        if r in s:Q
            break
        s.add(r)
        rsum=(rsum+r)%K
    print((i+1)*K/gcd(rsum,K))
    
    
    
if __name__=="__main__":
    main()


### FIXED CODE ###

#

import sys
input=sys.stdin.readline

def main():
    K=int(input())
    rsum=0
    r=7
    for i in range(10**6+1):
        rsum=(rsum+r)%K
        r=(r*10)%K
        if rsum==0:
            print(i+1)
            exit()
    print(-1)
    
    
    
if __name__=="__main__":
    main()
a=int(input())
b=1
for i in range(1,a+1):
  b=b*i
if b<1000000000:
  print(b)
else:
  print(((b/10000000000)*(10000000000))%1000000007)

### FIXED CODE ###

a=int(input())
b=1
for i in range(1,a+1):
  b=b*i
  if b>1000000007:
    b=b%1000000007
if b<1000000000:
  print(b)
else:
  print(b%1000000007)
from statistics import mode
n = int(input())
vlist = list(map(int, input().split()))


a = vlist[::2]
b = vlist[1::2]

freq_a = mode(a)
freq_b = mode(b)


x = len(a) - freq_a
y = len(b) - freq_b


if len(set(vlist)) == 1:
    print(min(len(a), len(b)))
else:
    print(x+y)


### FIXED CODE ###

from collections import Counter

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

# most_commonを使うためにリストをCounterオブジェクトに渡す
Counter_evens = Counter(vlist[::2])
Counter_odds = Counter(vlist[1::2])


# even_indexes
top2_even = Counter_evens.most_common(2)  # [(一番多い要素,その出現回数),(2番目に多い要素,その出現回数)]

E_most_common = top2_even[0][0]
Emnum = top2_even[0][1]

if len(top2_even) == 2:
    E_2nd_common = top2_even[1][0]
    E2num = top2_even[1][1]
else:
    E_2nd_common = 'foo'
    E2num = 0

# odd_indexes
top2_odd = Counter_odds.most_common(2)

O_most_common = top2_odd[0][0]
Omnum = top2_odd[0][1]

if len(top2_odd) == 2:
    O_2nd_common = top2_odd[1][0]
    O2num = top2_odd[1][1]
else:
    O_2nd_common = 'foo'
    O2num = 0


if E_most_common == O_most_common:  # most commonどうしが衝突してしまっている。
    # もし偶数番目・奇数番目をどちらもmost commonに書き換えると、3つ目の条件「数列は1種類の数ではだめ」が満たされない。
    # なので奇数番目・偶数番目のどちらかは2番目に多いやつに書き換える必要がある

    # 偶数番目をmost commonに、oddsを2nd commonにそろえる場合に書き換えないといけない要素の数
    x = len(vlist[::2]) - Emnum + len(vlist[1::2]) - O2num
    # 逆の場合
    y = len(vlist[::2]) - E2num + len(vlist[1::2]) - Omnum

    print(min(x, y))
else:
    # most common は衝突していない、つまり異なる数。よって3つ目の条件「数列は1種類の数ではだめ」は満たされている。
    # 両方とも most commonに書き換えてOK
    print(len(vlist[::2]) - Emnum + len(vlist[1::2]) - Omnum)
import numpy as np

# N = 3
# M = 7
# x_list = sorted([-10, -3, 0, 9, -100, 2, 17])

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


def rl_dist(x_point):

    p_num = len(x_point)
    d_list = []
    d_dict = {}
    for num, (a, b) in enumerate(zip(x_point, x_point[1:])):
        d = (b-a)
        if x_point[num] not in d_dict.keys():
            d_dict[x_point[num]] = [d]
            if num==0:
                d_dict[x_point[num]] = np.mean(d_dict[x_point[num]])
        else:
            d_dict[x_point[num]].append(d)
            
            if len(d_dict[x_point[num]])==2:
                d_dict[x_point[num]] = np.mean(d_dict[x_point[num]])
                
            
        if x_point[num+1] not in d_dict.keys():
            d_dict[x_point[num+1]] = [d]
            
            if num+1==p_num-1:
                d_dict[x_point[num+1]] = np.mean(d_dict[x_point[num+1]])
                
    return d_dict
            
    
rl_dict = rl_dist(x_list)
        
first_set = list(set([p[0] for p in sorted(rl_dict.items(), key=lambda x: x[1])[-1*N:] ]))
# print("First Set", first_set)

if len(first_set)==0:
    print(0)
else:

    rem = list(set(x_list) - set(first_set))
#     print("First Remain", rem)
    
    cost = 0
    
    current_point = first_set
    
    while len(rem)>0:
        d_list = []
        best = 10**5
        best_list = []
        
        for fp in current_point:
            for new in rem:
                if fp==new:
                    continue
                    
                d = abs(fp-new)
                if d<best:
                    best = d
                    best_list = [fp, new]
        
#         print("Next", best, best_list)
        cost += best
        
        bef_point = best_list[0]
        new_point = best_list[1]
        rem = set(rem) - set([new_point])
        
        idx = current_point.index(bef_point)
        current_point[idx] = new_point
        
    print(cost)

### FIXED CODE ###

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

if N>=M:
    print(0)
else: 
    dist = [b-a for a, b  in zip(X, X[1:])]
    dist.sort()
    print(sum(dist[:M-N]))
# coding: utf-8
# Your code here!
N,Q = map(int,input().split())
S = input()
p = set()
for n,i in enumerate(S[:-1]):
    if i == "A" and S[n+1]=="C":
        p.add(n)
#print(p)
for i in range(Q):
    a,b = map(int,input().split())
    #tmp = {}
    # tmp = {i for i in range(a-1,b-1)}
    # print(tmp)
    # print(len(tmp&p))
    count=0
    for j in p:
        #print("j",j)
        if a <= j+1 and j+1 < b:
            count+=1
        elif j > b:
            break
    print(count)

### FIXED CODE ###


a = input()
if a == "A":
    print("T")
elif a == "T":
    print("A")
elif a == "G":
    print("C")
else:
    print("G")
x = map(input(int,list(x))
if 0 != x[0]:
    print sum(map(int,list(x)))

### FIXED CODE ###

while True:
    x = map(int,list(raw_input()))
    if 0 != x[0]:
        print sum(x)
    else:
        break
n,a,b=map(int, input().split())
k=n//(a+b)*a+min(a,n%(a+b))
  
print(k)

### FIXED CODE ###

n,a,b=map(int, input().split())
k=n//(a+b)*a+min(a,n%(a+b))
  
print(k)
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
A.sort()
BC.sort(key=lambda x: -x[1])
i = 0
for B, C in BC:
    for _ in range(B):
        if C >= A[i]:
            A[i] = C
            i += 1
            if i == N - 1:
                break
    if i == N - 1:
        break
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
A.sort()
BC.sort(key=lambda x: - x[1])
tmp = []
for B, C in BC:
    tmp += [C] * B
    if len(tmp) >= N:
        break
if len(tmp) < N:
    n = len(tmp)
else:
    n = N
for i in range(n):
    if A[i] < tmp[i]:
        A[i] = tmp[i]
    else:
        break
print(sum(A))
import sys

N = int(sys.stdin.readline())

stones = []
for _ in range(N):
    stones.append(int(sys.stdin.readline()))

left = [-1] * N
dp = [0] * (N+1)
dp[0] = 1
for i in range(1, N+1):
    dp[i] = dp[i-1]
    # 同じ色が前回出現した位置
    if left[stones[i-1]] != -1 and left[stones[i-1]] != i - 1:
        dp[i] += dp[left[stones[i-1]]]
    
    left[stones[i-1]] = i

print(dp[-1])

### FIXED CODE ###

import sys

mod = 10**9 + 7
N = int(sys.stdin.readline())

stones = []
for _ in range(N):
    stones.append(int(sys.stdin.readline()))

left = [-1 for _ in range(2*10**5+1)]
dp = [0 for _ in range(N+5)]
dp[0] = 1
for i in range(N):
    dp[i+1] = dp[i]
    # 同じ色が前回出現した位置
    c = stones[i]
    if 0 <= left[c] < i - 1:
        dp[i+1] += dp[left[c] + 1]
    
    dp[i+1] %= mod
    left[c] = i

print(dp[N])
n = input()
x = list(map(int,input().split()))
ans = sys.maxsize

# i = min(x)
# while i <= max(x):
for i in range(min(x),max(x)+1,1):
    tmp = sum(map(lambda p: (p-i)**2,x))
    if ans > tmp:
        ans = tmp
    # i += 1
print(ans)

### FIXED CODE ###

import sys

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

# i = min(x)
# while i <= max(x):
for i in range(min(x),max(x)+1,1):
    tmp = sum(map(lambda p: (p-i)**2,x))
    if ans > tmp:
        ans = tmp
    # i += 1
print(ans)
def run(n):
    '''
    '''
    _base_array = string.ascii_lowercase
    results = []
    while n > 0:
        results.append(_base_array[n%26 - 1])
        if n%26 == 0:
            n = n//26 - 1
            continue
        n = n//26

    print(''.join(results[::-1]))



if __name__ == '__main__':
    n = int(input())
    run(n)

### FIXED CODE ###

import string

def run(n):
    '''
    '''
    _base_array = string.ascii_lowercase
    results = []
    while n > 0:
        results.append(_base_array[n%26 - 1])
        if n%26 == 0:
            n = n//26 - 1
            continue
        n = n//26

    print(''.join(results[::-1]))



if __name__ == '__main__':
    n = int(input())
    run(n)
#解説の方針にしたがった
import fractions

N = int(input())
X = list(map(int, input().split()))
   
M = 1  
L = [0 for i in range(10)] #L(0)=0
R = [0 for i in range(10)]  #R(N+1) = 0

for i in range(N):
  L[i] = (fractions.gcd(L[i-1],X[i]))

for i in reversed(range(N)):
  #print(i)
  R[i] = (fractions.gcd(R[i+1],X[i]))
    
ans = 1

#print(L)
#print(R)
for i in range(N):
  ans = max(ans, fractions.gcd(L[i-1],R[i+1]))

print(ans)

### FIXED CODE ###

#解説の方針にしたがった
import fractions

N = int(input())
X = list(map(int, input().split()))
   
M = 1  
L = [0 for i in range(100004)] #L(0)=0
R = [0 for i in range(100004)]  #R(N+1) = 0

for i in range(N):
  L[i] = (fractions.gcd(L[i-1],X[i]))

for i in reversed(range(N)):
  #print(i)
  R[i] = (fractions.gcd(R[i+1],X[i]))
    
ans = 1

#print(L)
#print(R)
for i in range(N):
  ans = max(ans, fractions.gcd(L[i-1],R[i+1]))

print(ans)
a, b = input().split()
ab = int(a+b)
print("Yes" if ab**(1/2))%1==0 else "No")

### FIXED CODE ###

a, b = input().split()
ab = int(a+b)

print("Yes" if ab**(1/2)%1==0 else "No")
H, W, M = map(int, input().split())

hs = [0] * H
ws = [0] * W
checked = set()

for i in range(M):
    r,c = map(int, input().split())
    r -= 1
    c -= 1

    hs[r] += 1
    ws[c] += 1
    checked.add((r, c))

mh, mw = 0, 0
for i in range(H):
    mh = max(mh, hs[i])
    mw = max(mw, ws[i])

max_h_list = []
max_w_list = []
    
for i in range(H):
    if hs[i] == mh: max_h_list.append(i)    
for j in range(W):
    if ws[i] == mw: max_w_list.append(i)

ans = mh + mw

for i in max_h_list:
    for j in max_w_list:
        if (i,j) not in checked:
            print(ans)
            exit()
print(ans-1)            

### FIXED CODE ###

H, W, M = map(int, input().split())

hs = [0] * H
ws = [0] * W
checked = set()

for i in range(M):
    r,c = map(int, input().split())
    r -= 1
    c -= 1

    hs[r] += 1
    ws[c] += 1
    checked.add((r, c))

mh, mw = 0, 0
for i in range(H):
    mh = max(mh, hs[i])
for j in range(W):
    mw = max(mw, ws[j])

max_h_list = []
max_w_list = []
    
for i in range(H):
    if hs[i] == mh: max_h_list.append(i)    
for j in range(W):
    if ws[j] == mw: max_w_list.append(j)

ans = mh + mw

for i in max_h_list:
    for j in max_w_list:
        if (i,j) not in checked:
            print(ans)
            exit()
print(ans-1)
S = input()
if ((S[0] == S[1]) and (S[0] !==S[2]) and (S[2] == S[3]))or
	((S[0] != S[1]) and (S[0] ==S[2]) and (S[1] == S[3]))or
	((S[0] != S[1]) and (S[1] == S[2]) and (S[0] == S[3])):
  print("Yes")
else:
  print("No")
  


### FIXED CODE ###

S = input()
if ((S[0] == S[1]) and (S[0] !=S[2]) and (S[2] == S[3]))or((S[0] != S[1]) and (S[0] ==S[2]) and (S[1] == S[3]))or((S[0] != S[1]) and (S[1] == S[2]) and (S[0] == S[3])):
  print("Yes")
else:
  print("No")
while 1:
  a, b, c, d, e, f = map(int, raw_input().split())
  g = b / e
  x = (c - g * f) / (a - g)
  y = (c - a * x) / b
  print str(x) + " " + str(y)

### FIXED CODE ###

while 1:
    try:
        a, b, c, d, e, f = map(float, raw_input().split())
        x = (c * e - b * f) / (a * e - b * d)
        y = (f * a - c * d) / (a * e - d * b)
        if x == -0.000:
            x = 0.000
        if y == -0.000:
            y = 0.000
        print str('%.3f' % x) + " " + str('%.3f' % y)
    except:
        break
n = int(input())
list = input().split()
print(list(set(list)))

### FIXED CODE ###

n = input()
n = int(n)
s = set([])

for i in range(1, n+1):
    a = input()
    a = int(a)
    s.add(a)

print(len(s))
cards = int(input())
i = 0
cardlist = []
while(i < cards):
    cardlist.append(list(map(str,input().split())))
    i += 1
SP = [False] * 13
HR = [False] * 13
CL = [False] * 13
DY = [False] * 13

for i in cardlist:
    num = int(i[1])
    if  (i[0] == "S"):
        SP[num] = True
    elif(i[0] == "H"):
        HR[num] = True
    elif(i[0] == "C"):
        CL[num] = True
    elif(i[0] == "D"):
        DY[num] = True

c = 0
for i in SP:
    c += 1
    if i == False:
        print("S %d" %c)
c = 0
for i in HR:
    c += 1
    if i == False:
        print("H %d" %c)
c = 0
for i in CL:
    if i == False:
        print("C %d" %c)
c = 0
for i in DY:
    if i == False:
        print("D %d" %c)
print()


### FIXED CODE ###

cards = int(input())
i = 0
cardlist = []
while(i < cards):
    cardlist.append(list(map(str,input().split())))
    i += 1
SP = [False] * 13
HR = [False] * 13
CL = [False] * 13
DY = [False] * 13

for i in cardlist:
    num = int(i[1])-1
    if  (i[0] == "S"):
        SP[num] = True
    elif(i[0] == "H"):
        HR[num] = True
    elif(i[0] == "C"):
        CL[num] = True
    elif(i[0] == "D"):
        DY[num] = True

c = 0
for i in SP:
    c += 1
    if i == False:
        print("S %d" %c)
c = 0
for i in HR:
    c += 1
    if i == False:
        print("H %d" %c)
c = 0
for i in CL:
    c += 1
    if i == False:
        print("C %d" %c)
c = 0
for i in DY:
    c += 1
    if i == False:
        print("D %d" %c)
if (input() == '3') or (input() == '5') or (input() == '7'):
  print("YES")
else:
  print("NO")

### FIXED CODE ###

n = input()
if (n == '3') or (n == '5') or (n == '7'):
    print("YES")
else:
    print("NO")
import math
a,b,x = map(int,input().split())

if x >= a*a*b/2:
    y = (-1)*b + 2*x/(a**2)
    if b != y:
        d = math.atan(a / (b-y))
    else:
        print(0)
        #exit()
else:
    y = 2*x/(a*b)
    d = math.atan(y/b)
print(90 - math.degrees(d))

### FIXED CODE ###

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

if x >= a*a*b/2:
    y = (-1)*b + 2*x/(a**2)
    if b != y:
        d = math.atan(a / (b-y))
    else:
        print(0)
        exit()
else:
    y = 2*x/(a*b)
    d = math.atan(y/b)
print(90 - math.degrees(d))
from collections import defaultdict as dd
H, W = map(int, input().split())
S = [input() for _ in range(H)]

i = 0
color = []
edge = dd(lambda: dd(int))
for h in range(H):
  for w in range(W):
    color.append(S[h][w])
    if w != 0:
      j = i-1
      if S[h][w-1] != S[h][w]:
        edge[i][j] = 1
        edge[j][i] = 1
    if h != 0:
      j = i-W
      if S[h-1][w] != S[h][w]:
        edge[i][j] = 1
        edge[j][i] = 1
    i += 1

visited = [False] * i
def dfs(k):
  black = 1 if color[k] == '#' else 0
  white = 1 if color[k] == '.' else 0
  visited[k] = True
  for dst in edge[k]:
    if not visited[dst]:
      b, w = dfs(dst)
      black += b
      white += w
  return black, white

ans = 0
for k in range(i):
  black, white = dfs(k)
  ans += black * white
print(ans)

### FIXED CODE ###

from collections import defaultdict as dd
H, W = map(int, input().split())
S = [input() for _ in range(H)]

i = 0
color = []
edge = dd(lambda: dd(int))
for h in range(H):
  for w in range(W):
    color.append(S[h][w])
    if w != 0:
      j = i-1
      if S[h][w-1] != S[h][w]:
        edge[i][j] = 1
        edge[j][i] = 1
    if h != 0:
      j = i-W
      if S[h-1][w] != S[h][w]:
        edge[i][j] = 1
        edge[j][i] = 1
    i += 1

visited = [False] * i
ans = 0
for k in range(i):
  if not visited[k]:
    count = { '#': 0, '.': 0 }
    queue = set([k])
    while queue:
      j = queue.pop()
      count[color[j]] += 1
      visited[j] = True
      for dst in edge[j]:
        if not visited[dst]:
          queue.add(dst)
    ans += count['#'] * count['.']
print(ans)
H, W = map(int, input().split())
field = [list(input()) for _ in range(H)]

goal_set = set()

def dfs(x, y, cnt):
    if field[x][y] == "#":
        cnt += 1
    if x == W-1 and y == H-1:
        goal_set.add(cnt)
    for nx, ny in ((1,0),(0,1)):
        nx += x
        ny += y
        if nx >= W or ny >= H:
            continue
        dfs(nx, ny, cnt)

dfs(0,0,0)
print(min(goal_set))



### FIXED CODE ###

H, W = map(int, input().split())
#field = [list(input()) for _ in range(H)]
field =[["."] * (W+1)]
for _ in range(H):
    tmp = ["."]
    tmp.extend(list(input()))
    field.append(tmp)

dp = [[10**9] * (W+1) for _ in range(H+1)]
dp[1][0] = 0
dp[0][1] = 0
for h in range(1,H+1):
    for w in range(1,W+1):
        if field[h][w] == ".":
            dp[h][w] = min(dp[h-1][w], dp[h][w-1])
        else:
            u = dp[h-1][w] if field[h-1][w] == "#" else dp[h-1][w] + 1
            l = dp[h][w-1] if field[h][w-1] == "#" else dp[h][w-1] + 1
            dp[h][w] = min(u,l)

print(dp[-1][-1])
N = int(input())
arr = map(int, input().split(' '))
ans = [0 for x in range(N)]
for i in reversed(range(N)):
  n = i + 1
  if n > N/2.0:
    ans[i] == arr[i]:
  else:
    s = 0
  	for k in reversed(range(1, N // n)):
    	index = n*k - 1
        s += arr[index]
    if s % 2 == arr[i]:
      ans[i] = 0
    else:
      ans[i] = 1
    	
ans_arr = []
for i in ans:
  if ans == 1:
    ans_arr.append(i)

print(sum(ans))
print(' '.join(ans_arr))


### FIXED CODE ###

def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    for i in range(n // 2, 0, -1):  # second half: no multiples
        A[i] = sum(A[i::i]) % 2
    ans = [i for i, j in enumerate(A) if j]
    print(len(ans))  # all cells: [1] -> len() (much faster than sum())
    print(*ans)


if __name__ == "__main__":
    main()
s=input()
t=input()
index=0
count=0
for i in range (len(s)):
    if s[i]==t[0]:
       index=i+1
       break
if index == 0:
    for j in range(len(t)):
        if t[j]!=s[j]:
            count+=1
    
else:
    
    for j in range (1,len(t)):
        if t[j]!= s[index]:
            count+=1
        index+=1
print(count)


### FIXED CODE ###


s=input()
t=input()
ans=10000
lt=len(t)
ls=(len(s))
start,last=0,lt
while last<=ls:
    count=0
    j=0
    for i in range (start,last):
        if s[i]!=t[j]:
            count+=1
        j+=1
    ans=min(ans,count)
    start+=1
    last+=1


print(ans)
if __name__ == '__main__':
  b = input()
  if b = 'A':
    print ('T')
  elif b = 'T':
	print ('A')
  elif b = 'G':
	print ('C')
  else:
    print ('G')

### FIXED CODE ###

if __name__ == '__main__':
  b = input()
  if b == 'A':
    print('T')
  elif b == 'T':
    print('A')
  elif b == 'G':
    print('C')
  elif b == 'C':
    print('G')
S=input()
ans=0
for i in range(len(S)):
  if S[i]=="-":
    ans-=1:
  else:
    ans+=1
print(ans)

### FIXED CODE ###

S=input()
ans=0
for i in range(len(S)):
  if S[i]=="-":
    ans-=1
  else:
    ans+=1
print(ans)
#!/usr/bin/env python3
import sys
from collections import Counter


def solve(N: int, a: "List[int]"):

    c = Counter(a)
    kitai = [[[0]*(c[1]+c[2]+c[3]+1) for _ in range(c[2]+c[3]+1)]
             for _ in range(c[3]+1)]
    for k in range(c[3]+1):
        for j in range(c[2]+c[3]+1):
            for i in range(c[1]+c[2]+c[3]+1):
                tot = i+j+k
                if tot == 0:
                    continue
                kitai[k][j][i] = N + kitai[k][j][i-1]*i + kitai[k][j-1][i+1]*j \
                    + kitai[k-1][j+1][i]*k
                kitai[k][j][i] /= tot
    print(kitai[c[3]][c[2]][c[1]])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):

    c = [0]*4
    for A in a:
        c[A] += 1

    J = min(c[2]+c[3]+1, N+1)
    I = min(c[1]+c[2]+c[3]+1, N+1)
    kitai = [[[0]*(I+1) for _ in range(J+1)]
             for _ in range(c[3]+1)]
    for k in range(c[3]+1):
        for j in range(J):
            for i in range(I):
                tot = i+j+k
                if tot == 0 or tot > N:
                    continue
                res = N + kitai[k][j][i-1]*i + \
                    kitai[k][j-1][i+1]*j + kitai[k-1][j+1][i]*k
                kitai[k][j][i] = res/tot
    print(kitai[c[3]][c[2]][c[1]])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()