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

import sys

sys.setrecursionlimit(10 ** 9)

n, q = map(int, input().split())
root = [[] for _ in range(n)]
ans = [0 for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    root[a - 1].append(b - 1)
    root[b - 1].append(a - 1)
for _ in range(q):
    p, x = map(int, input().split())
    ans[p - 1] += x
    
def dfs(pos, before):
    for next_pos in root[pos]:
        if next_pos == before:
            continue
        ans[next_pos] += ans[pos]
        dfs(next_pos, pos)

dfs(0, -1)

for i in range(n):
    print(ans[i], end=" ")

### FIXED CODE ###

from sys import setrecursionlimit, stdin

setrecursionlimit(10 ** 9)

def input():
    return stdin.readline()

n, q = map(int, input().split())
root = [[] for _ in range(n)]
ans = [0 for _ in range(n)]
for _ in range(n - 1):
    a, b = map(int, input().split())
    root[a - 1].append(b - 1)
    root[b - 1].append(a - 1)
for _ in range(q):
    p, x = map(int, input().split())
    ans[p - 1] += x
    
def dfs(pos, before):
    for next_pos in root[pos]:
        if next_pos == before:
            continue
        ans[next_pos] += ans[pos]
        dfs(next_pos, pos)

dfs(0, -1)

for i in range(n):
    print(ans[i], end=" ")
### BUGGY CODE ###

from bisect import bisect
N = int(input())
B = []
BW = []; BB = []
MB = {}; MW = {}
for i in range(2*N):
    c, a = input().split()
    a = int(a)
    c = "BW".index(c)
    B.append((c, a))
    if c:
        MW[a-1] = i
    else:
        MB[a-1] = i

P = [[0]*(N+1) for i in range(N+1)]
Q = [[0]*(N+1) for i in range(N+1)]

for p in range(N):
    cnt = MW[p] - sum(MW[p0] < MW[p] for p0 in range(p))

    P[p][0] = cnt
    for q in range(N):
        if MB[q] < MW[p]:
            cnt -= 1
        P[p][q+1] = cnt

for q in range(N):
    cnt = MB[q] - sum(MB[q0] < MB[q] for q0 in range(q))

    Q[q][0] = cnt
    for p in range(N):
        if MW[p] < MB[q]:
            cnt -= 1
        Q[q][p+1] = cnt

from heapq import heappush, heappop
dist = [[10**9]*(N+1) for i in range(N+1)]
dist[0][0] = 0
que = [(0, 0, 0)]
while que:
    cost, i, j = heappop(que)
    if dist[i][j] < cost:
        continue
    if i == j == N:
        print(cost)
        break
    if i < N and cost + P[i][j] < dist[i+1][j]:
        dist[i+1][j] = d = cost + P[i][j]
        heappush(que, (d, i+1, j))
    if j < N and cost + Q[j][i] < dist[i][j+1]:
        dist[i][j+1] = d = cost + Q[j][i]
        heappush(que, (d, i, j+1))

### FIXED CODE ###

from bisect import bisect
N = int(input())
B = []
BW = []; BB = []
MB = {}; MW = {}
for i in range(2*N):
    c, a = input().split()
    a = int(a)
    c = "BW".index(c)
    B.append((c, a))
    if c:
        MW[a-1] = i
    else:
        MB[a-1] = i

P = [[0]*(N+1) for i in range(N+1)]
Q = [[0]*(N+1) for i in range(N+1)]

for p in range(N):
    cnt = MW[p] - sum(MW[p0] < MW[p] for p0 in range(p))

    P[p][0] = cnt
    for q in range(N):
        if MB[q] < MW[p]:
            cnt -= 1
        P[p][q+1] = cnt

for q in range(N):
    cnt = MB[q] - sum(MB[q0] < MB[q] for q0 in range(q))

    Q[q][0] = cnt
    for p in range(N):
        if MW[p] < MB[q]:
            cnt -= 1
        Q[q][p+1] = cnt

dist = [[10**9]*(N+1) for i in range(N+1)]
dist[0][0] = 0
que = [(0, 0, 0)]
for i in range(N):
    dist[i+1][0] = dist[i][0] + P[i][0]
for i in range(N):
    dist[0][i+1] = dist[0][i] + Q[i][0]
for i in range(N):
    for j in range(N):
        dist[i+1][j+1] = min(dist[i][j+1] + P[i][j+1], dist[i+1][j] + Q[j][i+1])
print(dist[N][N])
### BUGGY CODE ###

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

# N人の持ち点arrayの初期値を作成する
points = [K]*N

for i in range(Q):
    win = int(input())
    points  = list(map(lambda x: x-1, points))
    points[win-1] += 1

for p in points:
    if p > 0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

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

# N人の持ち点arrayの初期値を作成する
points = [K-Q]*N

for i in range(Q):
    win = int(input()) -1
    points[win] += 1

for p in points:
    if p > 0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

import queue
def main():
    n,m,k=map(int,input().split())
    root={}
    ng={}
    friend=[[0 for i in range(n)]for i in range(n)]
    for i in range(n):
        root[i]=[]
        ng[i]=[0]*n
        ng[i][i]=1
    for i in range(m):
        a,b=map(int,input().split())
        root[a-1].append(b-1)
        root[b-1].append(a-1)
        friend[a-1][b-1]=1
        friend[b-1][a-1]=1
    for i in range(k):
        a,b=map(int,input().split())
        ng[a-1][b-1]=1
        ng[b-1][a-1]=1
    
    Vstd=[]
    checkVst=[0]*n
    num=[0]*n
    ToVst=queue.Queue()
    for i in range(n):
        Vstd=[]
        if checkVst[i]==1:
            continue
        now=i
        Vstd.append(now)
        checkVst[now]=1
        for kouho in root[now]:
            if checkVst[kouho]!=1:
                ToVst.put(kouho)
                checkVst[kouho]=1
        while ToVst.empty()==False:
            now=ToVst.get()
            Vstd.append(now)
            checkVst[now]=1
            for kouho in root[now]:
                if checkVst[kouho]==1:
                    continue
                ToVst.put(kouho)
                checkVst[kouho]=1

        l=len(Vstd)
        for x in Vstd:
            num[x]=l
            for y in Vstd:
                if ng[x][y]==1 or friend[x][y]==1:
                    num[x]-=1
    print(*num)
    #print(" ".join(map(str,num)))
   

if __name__=="__main__":
    main()
    

### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n,m,k=map(int,input().split())
uf=UnionFind(n)
block={}
for i in range(n):
    block[i]=[i]
for i in range(m):
    a,b=map(int,input().split())
    uf.union(a-1,b-1)
    block[a-1].append(b-1)
    block[b-1].append(a-1)
    
for i in range(k):
    a,b=map(int,input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)
ans=[]
#print(block)
for i in range(n):
    res=uf.size(i)
 #   print(res)
    for value in block[i]:
        if uf.same(value,i):
            res-=1
    ans.append(res)
print(*ans)
### BUGGY CODE ###

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

ans = 0
P = 10**9+7
bit = [0 for i in range(70)]

# 各bit独立に1が何個あるか数える
for i in range(N):
    S = bin(A[i])
    for j in range(1,len(S)-1):
        if S[-1*j] == '1':
            bit[j-1] += 1

# 各bitの1の個数と0の個数の積が、XOR和が1になる数字の個数と一致
for i in range(70):
    if bit[i] != 0 and bit[i] != N:
        ans += (2**i)*bit[i]*(N-bit[i])
        ans %= P

print(ans)


### FIXED CODE ###

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

ans = 0
P = 10**9+7
bit = [0 for i in range(70)]

# 各bit独立に1が何個あるか数える
for i in range(N):
    S = bin(A[i])
    for j in range(1,len(S)-1):
        if S[-1*j] == '1':
            bit[j-1] += 1

# 各bitの1の個数と0の個数の積が、XOR和が1になる数字の個数と一致
for i in range(70):
    ans += (2**i)*bit[i]*(N-bit[i])
    ans %= P

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

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

x_max = int(P**(1/N)) + 1
ans = 1
for i in range(x_max):
  x = x_max - i
  if(P%x**N == 0):
    ans = x
    break
print(ans)

### FIXED CODE ###

N,P = map(int,input().split())
X = P
Factoring = []

if(N == 1):
 ans = X
 print(ans)
else:
 #素因数分解
 p = 2
 ans = 1

 while(p*p <= P):
  count = 0
  while(X%p == 0):
    X = X//p
    count += 1
  if(count != 0):
   Factoring.append([p,count])
   ans = ans*(p**(count//N))
  p += 1
  
 if(len(Factoring) == 0):
  ans = 1
 print(ans)
### BUGGY CODE ###

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

ans = [max(a[i+1:]) - a[i] for i in range(n-1)]
r = max(ans)
print(ans.count(r))


### FIXED CODE ###

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

ans = []
min_a = a[0]
for i in range(1, n):
    min_a = min(min_a, a[i-1])
    ans.append(a[i] - min_a)
r = max(ans)
print(ans.count(r))
### BUGGY CODE ###

# B

inputs = input().split(' ')

d = inputs[0:2]
takahashi = {'Name': 'Takahashi', 'Hp': int(d[0]), 'Power': int(d[1])}
d = inputs[2:4]
aoki = {'Name': 'Aoki', 'Hp': int(d[0]), 'Power': int(d[1])}

players = [aoki, takahashi]
N =len(players)
while True:
    for i in range(N):
        players[i-1]['Hp'] -= players[i]['Power']
        if players[i-1]['Hp'] <= 0:
            if players[i]['Name'] == 'Takahashi':
                print('Yes')
            else:
                print('No')

### FIXED CODE ###

# B

inputs = input().split(' ')

d = inputs[0:2]
takahashi = {'Name': 'Takahashi', 'Hp': int(d[0]), 'Power': int(d[1])}
d = inputs[2:4]
aoki = {'Name': 'Aoki', 'Hp': int(d[0]), 'Power': int(d[1])}

players = [takahashi, aoki]

def compute(players):
    N =len(players)
    while True:
        for i in range(N):
            players[i-1]['Hp'] -= players[i]['Power']
            if players[i-1]['Hp'] <= 0:
                if players[i]['Name'] == 'Takahashi':
                    print('Yes')
                else:
                    print('No')
                return 

compute(players)
### BUGGY CODE ###

s = input()
Q = int(input())
flag = True  # flagがTrueのとき、偶数回数の反転が行われている
cnt = 0
query = [list(map(str, input().split())) for _ in range(Q)]
for i in range(Q):
    a = query[i]
    # tmp.append(query)
    if len(a) == 1:  # 1のqueryのとき
        cnt += 1
        if flag:
            flag = False
        else:
            flag = True
    else:
        f, c = a[1], a[2]
        if f == "1":  # 先頭に追加するもの
            if flag:
                s = c + s  # 偶数回の反転なら素直に先頭に追加する
            else:
                s += c  # 奇数会の反転なら後ろに追加する
        else:  # 末尾に追加する
            if flag:
                s += c
            else:
                s = c + s

if cnt % 2 == 1 and cnt != 0:
    s = s[::-1]
print(s)


### FIXED CODE ###

s = input()
Q = int(input())
flag = True  # flagがTrueのとき、偶数回数の反転が行われている
cnt = 0
query = [list(map(str, input().split())) for _ in range(Q)]
before = []  # 先頭に追加する時
after = []  # 末尾に追加する時
for i in range(Q):
    a = query[i]
    if len(a) == 1:  # 1のqueryのとき
        cnt += 1
        if flag:
            flag = False
        else:
            flag = True
    else:
        f, c = a[1], a[2]
        if f == "1":  # 先頭に追加するもの
            if flag:
                # s = c + s  # 偶数回の反転なら素直に先頭に追加する
                before.append(c)
            else:
                # s += c  # 奇数会の反転なら後ろに追加する
                after.append(c)
        else:  # 末尾に追加する
            if flag:
                # s += c  # 末尾に追加
                after.append(c)
            else:
                # s = c + s  # 先頭に追加
                before.append(c)
before.reverse()
# print(before)
# print(s)
# print(after)
s = "".join(before) + s + "".join(after)
if cnt % 2 == 1 and cnt != 0:
    s = s[::-1]
print(s)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
#from collections import deque
N=int(input())
A=[int(input())-1 for i in range(N-1)]
A=[0]+A
table=[[] for i in range(N)]
for i in range(1,N):
    table[A[i]].append(i)
#print(table)

num=[-1]*N
def dfs(s):
    if num[s]!=-1:
        return num[s]
    child=len(table[s])
    if child==0:
        num[s]=0
        return 0
    L=[]
    n=0
    for y in table[s]:
        x=dfs(y)
        L.append(x)
    L.sort()
    for l in L:
        n=max(n+1,l+1)
    num[s]=n
    return n

dfs(0)
#print(num)
print(num[0])



### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
#from collections import deque
N=int(input())
A=[int(input())-1 for i in range(N-1)]
A=[0]+A
table=[[] for i in range(N)]
for i in range(1,N):
    table[A[i]].append(i)
#print(table)

num=[-1]*N
def dfs(s):
    if num[s]!=-1:
        return num[s]
    child=len(table[s])
    if child==0:
        num[s]=0
        return 0
    L=[]
    n=0
    for y in table[s]:
        x=dfs(y)
        L.append(x)
    L.sort()
    for l in L:
        n=max(n+1,l+1)
    num[s]=n
    return n

dfs(0)
#print(num)
print(num[0])
### BUGGY CODE ###

def gacha():
    N=int(input())
    string=[]
    result_list=[]
    for i in range(0,N):
        s=input()
        string.append(s)
    for i in string:
        if i not in result_list:
            result_list.append(i)
    print(len(result_list))

if __name__=="__main__":
    gacha()

### FIXED CODE ###

def gacha():
    N=int(input())
    string=[]
    for i in range(0,N):
        s=input()
        string.append(s)
    result=list(set(string))
    print(len(result))

if __name__=="__main__":
    gacha()
### BUGGY CODE ###

a = input()
inputList = input().split()


index = 0
sum = 0
for i in inputList:
  if index == len(inputList) - 1:
    break
  for j in inputList[index+1:]:
    sum += (int(i) ^ int(j))
  index += 1

print(sum % (10 **9 + 7))


### FIXED CODE ###

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

mod = 10**9 + 7
total = 0
for i in range(60):
  cnt = sum([1 for a in A if (a>>i & 1)])
  total += cnt * (n-cnt) * (1 << i)
  total %= mod
print(total)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n=int(input())
h=list(map(int,input().split()))
l=h
s=[]

for i in range(n-1):
        if l[i]-1==l[i+1]:
                l[i]=l[i]-1
                s.append(l[i])
        elif l[i]==l[i+1] and l[i]==max(h):
                l[i]=l[i]-1
                s.append(l[i])
        elif l[i]-1>l[i+1]:
                break
        elif l[i]-1<l[i+1]:
                s.append(l[i])
                continue

s.append(h[n-1])
s.sort()
if len(s)==n:
        if l==s:
                print('Yes')
        else:
                print('No')

else:
        print('No')




### FIXED CODE ###

import sys
input = sys.stdin.readline

n=int(input())
h=list(map(int,input().split()))
l=h
s=[]
t=max(h)

for i in range(n-1):
        if l[i]-1==l[i+1]:
                l[i]=l[i]-1
                s.append(l[i])
        elif l[i]==l[i+1] and l[i]==t:
                l[i]=l[i]-1
                s.append(l[i])
        elif l[i]-1>l[i+1]:
                break
        elif l[i]-1<l[i+1]:
                s.append(l[i])
                continue

s.append(h[n-1])
s.sort()
if len(s)==n:
        if l==s:
                print('Yes')
        else:
                print('No')

else:
        print('No')
### BUGGY CODE ###

import sys
import math

def add_ball(idx):
    add_list = []
    for j in range(1, int(math.sqrt(idx))+1):
        if idx%j == 0:
            add_list.append(j)
            if j != idx//j:
                add_list.append(idx//j)
    for k in add_list:
        b_list[k] += 1

if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * (n+1)
    ans_list = []
    for a, i in zip(reversed(a_list), range(n, 0, -1)):
        if a != b_list[i]%2:
            ans_list.append(i)
            add_ball(i)
    cnt = len(ans_list)
    ans_list.sort()
    print(cnt)
    if cnt > 0:
        print(' '.join(map(str, ans_list)))


### FIXED CODE ###

import sys
import math

def add_ball(idx):
    add_list = []
    for j in range(1, int(math.sqrt(idx))+1):
        if idx%j == 0:
            add_list.append(j)
            if j != idx//j:
                add_list.append(idx//j)
    for k in add_list:
        b_list[k] += 1

if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * (n+1)
    cnt = 0
    ans_list = []
    for a, i in zip(reversed(a_list), range(n, 0, -1)):
        if a != b_list[i]%2:
            cnt += 1
            ans_list.append(i)
            add_ball(i)
    ans_list.sort()
    print(cnt)
    if cnt > 0:
        print(' '.join(map(str, ans_list)))
### BUGGY CODE ###

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

cnt=0

for i in range(n):
    if i == 0:
        cnt += 1
    else:
      if min(p[:i+1]) == p[i]:
          cnt += 1
      else:
        continue

print(cnt)

### FIXED CODE ###

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

min=p[0]
cnt=0

for i in range(n):
    if min >= p[i]:
        cnt+=1
        min=p[i]
    else:
        continue
print(cnt)
### BUGGY CODE ###

N,K=map(int,input().split())
H=list(map(int,input().split()))
dp=[float('inf')]*N
dp[0]=0

for i in range(1,N):
    for k in range(1,K+1):
        if i-k<0:
            break
        dp[i]=min(dp[i],dp[i-k]+abs(H[i]-H[i-k]))

print(dp[N-1])

### FIXED CODE ###

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

dp=[float('inf')]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])

for n in range(2,N):
    if n-K>0:
        dp[n]=min([(dp[i]+abs(H[n]-H[i]))for i in range(n-K,n)])
    else:
        dp[n]=min([dp[i]+abs(H[n]-H[i])for i in range(0,n)])

print(dp[N-1])
### BUGGY CODE ###

import heapq
def SME(start,end):
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        if None not in ANS[a[1]:a[1]+L] : continue
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[:i+1])
    while i < N :
        if None not in ANS[i:i+50] :
            i += 50
            continue
        ANS[i] = min(Whole[i+1-L:i+1])
        i+=1
    return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.9997
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

def run():
  N = int(input())
  abc_li = [[int(i) for i in input().split()] for n in range(N)]
  dp = [0] * N
  dp[0] = [(abc_li[0][k], k) for k in range(3)]
  for n in range(1, N):
    len_dp = len(dp[n-1])
    dp[n] = [(0, 0) for _ in range(len_dp)]
    for k in range(len_dp):
      value, pre_abc = dp[n-1][k] 
      for abc, abc_value in enumerate(abc_li[n]):
        if pre_abc == abc: continue
        if dp[n][k][0] == (value + abc_value):
          dp[n].append((value + abc_value, abc))
          continue
        dp[n][k] = max([dp[n][k], (value + abc_value, abc)],
                      key=lambda x:x[0])
    dp[n] = list(set(dp[n]))
  print(max(dp[-1])[0])
  
if __name__ == '__main__':
  run()

### FIXED CODE ###

def run():
  N = int(input())
  abc_li = [[int(i) for i in input().split()] for n in range(N)]
  dp = [[0]*3 for n in range(N)]
  dp[0] = abc_li[0]
  for n in range(1, N):
    for next_abc in range(3):
      for pre_abc in range(3):
        if pre_abc == next_abc: continue
        dp[n][next_abc] = max(dp[n][next_abc], dp[n-1][pre_abc]+abc_li[n][next_abc])
  print(max(dp[N-1]))
  
if __name__ == '__main__':
  run()
### BUGGY CODE ###

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

ans = n
for i in range(1,n):
    if a[i-1] <= 2*sum(a[i:]):
        pass
    else:
        print(i)
        exit()

print(n)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
sum_a = sum(a)

ans = n
for i in range(1,n):
    sum_a -= a[i-1]
    if a[i-1] <= 2*sum_a:
        pass
    else:
        print(i)
        exit()

print(n)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
s = input()
n = len(s)
ok = 0
while ok == 0:
    ok = 1
    i = 0
    while i < len(s) - 1:
        str = s[i] + s[i+1]
        if str == "01" or str == "10":
            s = s[:i] + s[i+2:]
            ok = 0
        i += 1
print(n - len(s))

### FIXED CODE ###

import sys
input = sys.stdin.readline
s = input()
n = len(s)
ok = 0
while ok == 0:
    ok = 1
    i = 0
    while i < len(s) - 1:
        str = s[i] + s[i+1]
        j = 0
        while str == "01" or str == "10":
            s = s[:i-j] + s[i+2-j:]
            ok = 0
            j += 1
            if i > j + 1:
                str = s[i-j] + s[i-j+1]
            else:
                break
        i += 1
print(n - len(s))
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
for i in range(1,N+1):
    print(A.index(i)+1,end=" ")

### FIXED CODE ###

N=int(input())
A={i:a for (i, a) in enumerate(list(map(int, input().split())),1)}
B=sorted(A.items(), key=lambda A:A[1])
for i in range(N):
    print(B[i][0],end=" ")