Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]", b: "List[int]"):
    conn = [[] for _ in range(N)]
    for i in range(N - 1):
        conn[a[i] - 1].append(b[i] - 1)
        conn[b[i] - 1].append(a[i] - 1)
    def find_path(idx, target, conn, visited):
        visited[idx] = True
        if idx == target:
            return [target]
        for nex in conn[idx]:
            if not visited[nex]:
                path = find_path(nex, target, conn, visited)
                if path is not None:
                    return [idx] + path
        return None

    visited = [False] * N
    path_to_n = find_path(0, N - 1, conn, visited)
    #print(path_to_n)

    colors = [None] * N
    for i, node in enumerate(path_to_n):
        if i < (len(path_to_n) + 1) / 2:
            colors[node] = True
        else:
            colors[node] = False

    def dfs(idx, conn, colors):
        colors[idx] = True
        for nex in conn[idx]:
            if colors[nex] is None:
                dfs(nex, conn, colors)
        return

    cnt = 0
    dfs(0, conn, colors)
    #print(colors)
    for c in colors:
        if c:
            cnt += 1
    if cnt > (N - cnt):
        ret = 'Fennec'
    else:
        ret = 'Snuke'
    print(ret)
    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()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, a: "List[int]", b: "List[int]"):
    conn = [[] for _ in range(N)]
    for i in range(N - 1):
        conn[a[i] - 1].append(b[i] - 1)
        conn[b[i] - 1].append(a[i] - 1)

    def dfs(idx, cur, conn, dis):
        dis[idx] = cur
        for nex in conn[idx]:
            if dis[nex] is None:
                dfs(nex, cur + 1, conn, dis)
        return None

    f_dis = [None] * N
    f_dis[0] = 0
    dfs(0, 0, conn, f_dis)

    s_dis = [None] * N
    s_dis[N - 1] = 0
    dfs(N - 1, 0, conn, s_dis)

    cnt = 0
    for i in range(N):
        if f_dis[i] <= s_dis[i]:
            cnt += 1

    if cnt > (N - cnt):
        ret = 'Fennec'
    else:
        ret = 'Snuke'
    print(ret)
    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()] * (N-1)  # type: "List[int]" 
    b = [int()] * (N-1)  # type: "List[int]" 
    for i in range(N-1):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, a, b)

if __name__ == '__main__':
    main()
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

int main() {
  int N;
  cin >> N;
  priority_queue<double, vector<double>,  greater<double>> q;
  int v;
  for (int i = 0; i < N; i++) {
    cin >> v;
    q.push((double)v);
  }
  while (q.size() > 1) {
    double v1 = q.top();
    q.pop();
    double v2 = q.top();
    q.pop();
    q.push((v1+v2)/2);
  }
  cout << setprecision(10) << q.top() << endl;
  return 0;
}


### FIXED CODE ###

import heapq

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

heapq.heapify(q)

while (len(q) > 1):
    v1 = heapq.heappop(q)
    v2 = heapq.heappop(q)
    heapq.heappush(q, (v1+v2)/2.0)

print(heapq.heappop(q))
n, x, y = map(int, input().split())
X = min(x,y)
Y = max(x,y)
x =X
y = Y
sum = x +y +1
dist = x+1
for i in range(2,dist):
	sum += dist//i
dist = n+1-y
for j in range(2,dist):
	sum += dist//j
dist = y+1-x
sum+= dist
for k in range(2,dist):
  sum += dist//k
sum+= y-n+2

### FIXED CODE ###

txt = input()
if( txt[2] == txt[3] and txt[4] == txt[5]):
  print('Yes')
else:
  print('No')
import math
s = list(map(int, input().split()))
n=s[0]
ans=math.inf
for a in range(1,int(math.sqrt(n))):
    b=n/a
    if b.is_integer():
        b=int(b)
        if max(len(str(a)),len(str(b)))<ans:
            ans = max(len(str(a)), len(str(b)))
print(ans)

### FIXED CODE ###

import numpy
s = list(map(int, input().split()))
n=s[0]
ans=11
for a in range(1,int(numpy.sqrt(n))+1):
    b=n/a
    if b.is_integer():
        b=int(b)
        if max(len(str(a)),len(str(b)))<ans:
            ans = max(len(str(a)), len(str(b)))
print(ans)
a = input()
s = input()
if input(a) >= 3200:
    print(s)
else:
    print('red')

### FIXED CODE ###

a = input()
s = input()
if int(a) >= 3200:
    print(s)
else:
    print('red')
N, M= map(int, input().split())
B=[]
for i in range(N):
    B.append([None]*2)
    l=input().split()
    B[i][0]=int(l[1])
    B[i][1]=int(l[0])
B.sort(reverse=True)
h=[0]*(M+1)
a=0
d=M+1
for i in range(N):
    for j in range(B[i][1],d):
        if h[j]==0:
            h[j]=1
            a+=B[i][0]
            break
    else:
        d=B[i][1]
print(a)

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
N,M=map(int,input().split())
l=[[] for i in range(10**5)]
for i in range(N):
    a,b=map(int,input().split())
    l[a-1].append(b)
h=[]
import heapq
a=0
for i in range(M):
    for j in l[i]:
        heapq.heappush(h,-j)
    if h:
        a-=heapq.heappop(h)
print(a)
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

X, Y = MAP()

print(X+Y//2)import sys, re


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

X, Y = MAP()

print(X+Y//2)
n = int(input())
l = list(map(int,input().split()))
sa = []
for i in range(n-1):
    sa.append(l[i+1]-l[i])

mod = 10**9+7
ans = 0
count = 0
kai = 1
for i in range(n-1):
    kai *= (i+1)
    
for i in range(n-1):
    count += 1/(i+1)
    
    
    ans += sa[i]*count
    ans %= mod
    

print(int(kai*ans%mod))


### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
sa = []
for i in range(n-1):
    sa.append(l[i+1]-l[i])

mod = 10**9+7
ans = 0
count = 0
kai = 1
for i in range(1,n):
    kai *= i
    kai %= mod
    
for i in range(n-1):
    count += pow((i+1),mod-2,mod)
    
    ans += sa[i]*count
    ans %= mod


print(int(kai*ans%mod))
n,m = map(int, input().split())
sc= [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]

ans = 10001
for l in range((10**(n-1))+1,10**n):
    ln = str(l)
    #ln = l

    tmp = 0
    for j in range(m):
        if int(ln[int(s[j])-1]) == int(c[j]):
            tmp += 1
            # print(tmp)
            if tmp == m:
                ans = int(ln)
                print(ans)
                break

        else:
            # print(tmp)
            break
    if ans != 10001:
        break

if ans == 10001:
    print(-1)


### FIXED CODE ###

# n,m = map(int, input().split())
# sc = [map(int, input().split()) for _ in range(m)]
# s, c = [list(i) for i in zip(*sc)]
#
#
#
# for i in range(10**n):
#     ans = str(i)
#     if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
#         print(ans)
#         exit()
#
#
# print(-1)

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

s, c = [], []
for _ in range(m):
    s_, c_ = map(int, input().split())
    s.append(s_)
    c.append(c_)

for i in range(10 ** n):
    ans = str(i)
    if len(ans) == n and all([ans[s[j] - 1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()

print(-1)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N, X = list(map(int, input().split()))
sum_ = X
prev = X
next = N - X
i = 0
while True:
    num = prev // next
    if i == 0:
        sum_ += 2 * num * next
    elif i % 2 == 1:
        sum_ += 2 * num * next - next
    else:
        sum_ += 2 * num * next - next
    mod_ = prev % next
    if mod_ == 0:
        break
    sum_ += next
    prev = next
    next = mod_
    i += 1
print(sum_)

### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
Ls = list(map(int, input().split()))
sorted_ = sorted(Ls)
list_ = []
for i, x in enumerate(sorted_):
    if i % 2 == 0:
        list_.append(x)
sum_ = sum(list_)
print(sum_)
import sys
sys.setrecursionlimit(1000000)
n,m,k=map(int,input().split())
class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.size = [1 for i in range(N)]
 
    def merge(self, a, b):
        if self.issame(a,b):
            return
        pa = self.root(a)
        pb = self.root(b)
        self.parent[pa] = pb
        self.size[pb] += self.size[pa]
    
    def root(self, x):
        p = self.parent[x]
        if p == x:
            return x
        else:
            r = self.root(p)
            self.parent[x] = r
            return r
    def issame(self, x, y):
        return self.root(x) == self.root(y)
    def getsize(self, x):
        return self.size[self.root(x)]
uf=UnionFind(n)
ans=[0]*n
for i in range(m):
    a,b=map(int,input().split())
    uf.merge(a-1,b-1)
    ans[a-1]-=1;ans[b-1]-=1
for i in range(k):
    c,d=map(int,input().split())
    if uf.issame(c-1,d-1):
        ans[c-1]-=1;ans[d-1]-=1
for i in range(n):
    ans[i]=uf.getsize(i)+ans[i]-1
print(*ans)


### FIXED CODE ###

n=int(input())
print((n+1)//2)
A = int(input())
B = int(input())
C = int(input())
 
if (A+B+C>=22):
  print("bust")

else:
  print("win")
 

### FIXED CODE ###

A, B, C = map(int, input().split())
 
if (A+B+C>=22):
  print("bust")

else:
  print("win")
import queue

def Dijkstra(vertex,edges,start):
	weight = [0 if i==start else float("inf") for i in range(vertex)]
	Q = queue.PriorityQueue()
	Q.put((weight[start],start))

	while(not Q.Empty()):
		cur = Q.get()
		if weight[cur[1]] < cur[0]:
			continue
		for j in range(len(edges[cur[1]])):
			if weight[edges[cur[1]][j][1]] > weight[cur[1]] + edges[cur[1]][j][2]:
				weight[edges[cur[1]][j][1]] = weight[cur[1]] + edges[cur[1]][j][2]
				Q.put((weight[edges[cur[1]][j][1]],edges[cur[1]][j][1]))
	return weight

V,E,r = map(int,input().split())
edges = [[] for i in range(V)]
for i in range(E):
	data = list(map(int,input().split()))
	edges[data[0]].append(data)
edges.sort()
w = Dijkstra(V,edges,r)
for i in range(len(w)):
	print(w[i])


### FIXED CODE ###

import queue

def Dijkstra(vertex,edges,start):
	weight = [0 if i==start else float("inf") for i in range(vertex)]
	Q = queue.PriorityQueue()
	Q.put((weight[start],start))

	while(not Q.empty()):
		cur = Q.get()
		if weight[cur[1]] < cur[0]:
			continue
		for j in range(len(edges[cur[1]])):
			if weight[edges[cur[1]][j][1]] > weight[cur[1]] + edges[cur[1]][j][2]:
				weight[edges[cur[1]][j][1]] = weight[cur[1]] + edges[cur[1]][j][2]
				Q.put((weight[edges[cur[1]][j][1]],edges[cur[1]][j][1]))
	return weight

V,E,r = map(int,input().split())
edges = [[] for i in range(V)]
for i in range(E):
	data = list(map(int,input().split()))
	edges[data[0]].append(data)
for j in range(V):
	edges[j].sort()
w = Dijkstra(V,edges,r)
for i in range(len(w)):
	if w[i]==float("inf"):
		print('INF')
	else:
		print(w[i])
import math
A, B, C, D = map(int, input().split())
U = B - A + 1


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


def sten(st, en, x):
    st = math.ceil(st/x)*x
    en = math.floor(en/x)*x
    if en >= st:
        n = (en - st) / x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
MofD = sten(A, B, D)
MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)

### FIXED CODE ###


A, B, C, D = map(int, input().split())
U = B - A + 1

MofD = 0
MofCD = 0

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

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


def sten(st, en, x):
    if x == 1:
        return en - st + 1
    st = st // x if st % x == 0 else st // x + 1
    en = en // x
    st *= x
    en *= x
    if en >= st:
        n = (en - st) // x + 1
    else:
        n = 0
    return n


MofC = sten(A, B, C)
if C != D:
    MofD = sten(A, B, D)
    MofCD = sten(A, B, lcm(C, D))

print(U-MofC-MofD+MofCD)
n, k = input().split()
s = input()
num = 3
if (num - int(k)) == 0:
    sn = s[0] + s[1] + s[int(k)-1].lower()
    print(sn)
if (num - int(k)) == 1:
    sn = s[0] + s[int(k)-1].lower() + s[2]
    print(sn)
if (num - int(k)) == 2:
    sn = s[int(k)-1].lower() + s[1] + s[2]
    print(sn)


### FIXED CODE ###

n, k = input().split()
s = input()
sn = s[int(k)-1].lower()
num1 = int(k) - 1
num2 = int(k)
print(s[:num1] + sn + s[num2:])
def _input():
    lines = open("tmp_in").readlines()
    for ss in lines:
        yield ss.rstrip()
input = _input().__next__



from collections import defaultdict
n, m, k = list(map(int, input().split()))
ns = defaultdict(set)
bs = defaultdict(set)
for i in range(m):
    a,b = list(map(int, input().split()))
    ns[a-1].add(b-1)
    ns[b-1].add(a-1)
for i in range(k):
    c,d = list(map(int, input().split()))
    bs[c-1].add(d-1)
    bs[d-1].add(c-1)
    
s = [0]
start = 0
parent = [None] * n
starts = defaultdict(int)
starts[0] = 0
done = [0] * n
doneCount = 0
while doneCount<n:
    u = s.pop()
    done[u] = 1
    doneCount += 1
    parent[u] = start
    starts[start] += 1
    for v in ns[u]:
        if not done[v]:
            s.append(v)
    if not s:
        start = 0
        while done[start]:
            start += 1
        parent[start] = start
        s.append(start)
ans = [None] * n
for u in range(n):
    val = starts[parent[u]] - 1 - len(ns[u])
    for v in bs[u]:
        if parent[v]==parent[u]:
            val -= 1
    ans[u] = val
print(" ".join(map(str, ans)))

### FIXED CODE ###



from collections import defaultdict
n, m, k = list(map(int, input().split()))
ns = defaultdict(set)
bs = defaultdict(set)
for i in range(m):
    a,b = list(map(int, input().split()))
    ns[a-1].add(b-1)
    ns[b-1].add(a-1)
for i in range(k):
    c,d = list(map(int, input().split()))
    bs[c-1].add(d-1)
    bs[d-1].add(c-1)
    
s = [0]
start = 0
parent = [None] * n
starts = defaultdict(int)
starts[0] = 0
notdone = set(list(range(n)))
notdone.remove(start)
while notdone or s:
    u = s.pop()
    parent[u] = start
    starts[start] += 1
    for v in ns[u]:
        if v in notdone:
            s.append(v)
            notdone.remove(v)
    if not s and notdone:
        start = notdone.pop()
        parent[start] = start
        s.append(start)
ans = [None] * n
for u in range(n):
    val = starts[parent[u]] - 1 - len(ns[u])
    for v in bs[u]:
        if parent[v]==parent[u]:
            val -= 1
    ans[u] = val
print(" ".join(map(str, ans)))
N = int(input())
M = int(input())

print(N*(N-1)/2 + M*(M-1)/2)

### FIXED CODE ###

import sys
N, M = map(int, sys.stdin.readline().split())

print(N*(N-1)//2 + M*(M-1)//2)
from functools import reduce
from math import gcd
a,b = map(int,input().split())
li = list(map(int,input().split()))
li = [abs(x-b) for x in li]
print(reduce(gcd,li))

### FIXED CODE ###

n, x = map(int,input().split())
li = list(input().split())
li = [abs(int(a)-x) for a in li]

def gcd(a,b):
    while a%b!=0:
        a,b = b,a%b
    return b
    
if n == 1:
    print(abs(li[0]))
    
elif n == 2:
    print(gcd(li[0],li[1]))
    
elif n >= 3:

    c = gcd(li[0],li[1])
    #print(c)
    for i in range(2,len(li)-1):
        c = gcd(c,li[i])
    print(c)
A,B,K = map(int,input().split())
T=[]
for i in range(1,101):
    if A%i==0 and B%i==0:
        T.append(i)
T=sorted(T,reverse=True)
print(T[K-1])

### FIXED CODE ###

A,B,C = map(int,input().split())
if B//A < C:
    print(B//A)
else:
    print(C)
import copy

####入力
H,W = map(int,input().split())

#gridの定義
grid = []
for i in range(H):
  S = input()
  grid.append( [S[i] for i in range(W) ])
####入力終了


#l_blackの設定
l_black = []
for i in range(H):
  for j in range(W):
    if grid[i][j] == "#":
      l_black.append( [i,j] ) # [行,列]


#探索
cnt = 0

while len(l_black) > 0:

  l_change = []

  #vは黒マスリスト #新たに黒マスになる白マスの座標をl_changeに詰めていく
  for v in l_black:
    #iはvの上下左右のマスの座標[行,列]
    for i in [ [v[0]+1,v[1]] , [v[0],v[1]+1] , [v[0]-1,v[1]] ,[v[0],v[1]-1] ]:
      #場外アウトの場合はスルー
      if (i[0]<0 or i[1] <0 or i[1]>=H or i[0] >= W ):
        continue
      #移動先がもう黒マスの場合スルー
      if grid[i[1]][i[0]] == "#":
        continue
      #移動先が白マスならばそこの座標をl_changeに追加
      if grid[i[1]][i[0]] == ".":
        l_change.append( i )
  
  #l_changeの中の白マスを黒にする
  for i in l_change:
    grid[i[0]][i[1]] = "#" 
  print(grid)
  #l_blackの中を新たに黒鱒になったやつの座標だけにする
  l_black = copy.deepcopy( l_change )
  if len(l_black) > 0:
    cnt = cnt + 1
print(cnt)  

### FIXED CODE ###

import copy
from collections import deque

####入力
H,W = map(int,input().split())

#gridの定義
grid = []
for i in range(H):
  S = input()
  grid.append( [S[i] for i in range(W) ])
####入力終了

#distの設定
dist = [[0 for i in range(W)] for j in range(H)]

#l_blackの設定
l_black = deque([])
for i in range(H):
  for j in range(W):
    if grid[i][j] == "#":
      l_black.append( [i,j] ) # [行,列]

#探索
max_d = 0

while len(l_black) > 0:
  #vは黒マスの座標 
  while len(l_black) > 0:
    v = l_black.popleft()
    #iはvの上下左右のマスの座標[行,列]
    for i in [ [v[0]+1,v[1]] , [v[0],v[1]+1] , [v[0]-1,v[1]] ,[v[0],v[1]-1] ]:
      #場外アウトの場合はスルー
      if (i[1]<0 or i[0] <0 or i[0]>=H or i[1] >= W ):
        continue
      #移動先がもう黒マスの場合スルー
      if grid[i[0]][i[1]] == "#":
        continue
      #移動先が白マスならばそこの座標を黒マスにして距離を記録する
      if grid[i[0]][i[1]] == ".":
        #黒マスにする
        grid[i[0]][i[1]] = "#"
        #新たに黒鱒となった座標をl_blackに追加
        l_black.append(i)
        #距離の記録
        dist[i[0]][i[1]] = dist[v[0]][v[1]] + 1
        max_d = max(max_d,dist[i[0]][i[1]])
print(max_d)
s = raw_input()
l =[]
while True:
	x = raw_input()
	if x == 'END_OF_TEXT':
		break
	l.append(x.lower.split())
print l.count(s)

### FIXED CODE ###

s = raw_input()
l =[]
while True:
	x = raw_input()
	if x == 'END_OF_TEXT':
		break
	l += x.lower().split()
print l.count(s)
N = int(input())
a = list(map(int, input().split()))

count = 0

for x in range(N):
    if x != N - 1:
        if a[x] == a[x + 1]:
            if x + 1 < N:
                if a[x + 2] == 10000:
                    a[x + 1] = 9999
                    count += 1
                else:
                    a[x + 1] = 10000
                    count += 1
            else:
                a[x + 1] = 10000
                count += 1
print(count)


### FIXED CODE ###

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

count = 0

for x in range(N):
    if x != N - 1:
        if a[x] == a[x + 1]:
            if x < N - 2:
                if a[x + 2] == 10000:
                    a[x + 1] = 9999
                    count += 1
                else:
                    a[x + 1] = 10000
                    count += 1
            else:
                a[x + 1] = 10000
                count += 1
print(count)
N = int(input())

ac, wa, tle, re = 0, 0, 0, 0

for i in range(N):
  S = int(input())
  if S=='AC':
    ac+=1
  elif S=='WA':
    wa+=1
  elif S=='TLE':
    tle+=1
  elif S=='RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)

### FIXED CODE ###

N = int(input())

ac, wa, tle, re = 0, 0, 0, 0

for i in range(N):
  S = input()
  if S=='AC':
    ac+=1
  elif S=='WA':
    wa+=1
  elif S=='TLE':
    tle+=1
  elif S=='RE':
    re+=1

print('AC x %d'%ac)
print('WA x %d'%wa)
print('TLE x %d'%tle)
print('RE x %d'%re)
n = int(input())
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))

b_sum = sum(b)

c_sum = 0
for i in range(n-1):
    if a[i] != n:
        if a[i] + 1 == a[i+1]:
            c_sum += c[ai-1]

print(b_sum + c_sum)

### FIXED CODE ###

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

b_sum = sum(b)

c_sum = 0
for i in range(n-1):
    if a[i] != n:
        if a[i] + 1 == a[i+1]:
            c_sum += c[a[i]-1]

print(b_sum + c_sum)
N = int(input())
A = list(map(int,input().split()))
ans = 0
A_set = list(set(A))
if len(A_set)==2 and (A.count(A_set[0])==1 or A.count(A_set[1])==1):
  print(max(A))
elif len(A_set)==1:
  print(max(A))
else:
  for i in sorted(range(1,max(A)+1),reverse=True):
    tmp = [A[j]%int(i) for j in range(N)]
    tmp_set = list(set(tmp))
    if len(tmp_set)==2:
      if tmp.count(tmp_set[0])==1 or tmp.count(tmp_set[1])==1:
        ans = i
        break
  print(ans)

### FIXED CODE ###

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

def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)

ans = 0
L = [0]*(N+1)
for i in range(N):
  L[i+1] = gcd(L[i],A[i])

R = [0]*(N+1)
for i in range(N-1,-1,-1):
  R[i] = gcd(R[i+1],A[i])
  
for i in range(N):
  M = gcd(L[i],R[i+1])
  if ans < M:
    ans = M
    
print(ans)
n=int(input())
l=list(map(int,input().split()))
a=abs(l[0])
m=0
d=0
z=0
for i in range(n):
  if l[i]<0:
    d+=1
  elif l[i]=0:
    z+=1
if d%2==0 or (d+z)%2==0:
  for i in range(n):
    s+=abs(l[i])
  print(s)
else:
  for i in range(1,n):
    if a>=abs(l[i]):
      a=abs(l[i])
      m=i
  s=0
  for i in range(m):
    s+=abs(l[i])
  s+=-abs(l[m])
  for i in range(m+1,n):
    s+=abs(l[i])
  print(s)
    


### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
a=abs(l[0])
m=0
d=0
z=0
s=0
for i in range(n):
  if l[i]<0:
    d+=1
  elif l[i]==0:
    z+=1
if d%2==0 or (d+z)%2==0:
  for i in range(n):
    s+=abs(l[i])
  print(s)
else:
  for i in range(1,n):
    if a>=abs(l[i]):
      a=abs(l[i])
      m=i
  s=0
  for i in range(m):
    s+=abs(l[i])
  s+=-abs(l[m])
  for i in range(m+1,n):
    s+=abs(l[i])
  print(s)
N = int(input())
a = list(map(int,input().split()))
 
res = "No"
a_set = list(set(a))
 
a_set = [i for i in a_set if i != 0]
 
if len(a_set) == 3:
    if a_set[0] ^ a_set[1] == a_set[2]:
        if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
            res = "Yes"
if len(a_set) == 0:
    if a_set[0] == 0:
        res = "Yes"
print(res)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
 
res = "No"
a_set = list(set(a))
 

 
if len(a_set) == 3:
    if a_set[0] ^ a_set[1] == a_set[2]:
        if a.count(a_set[0]) == a.count(a_set[1]) and a.count(a_set[0]) == a.count(a_set[2]):
            res = "Yes"
if len(a_set) == 1:
    if a_set[0] == 0:
        res = "Yes"
if len(a_set) == 2:
    if 0 in a_set:
        if N%3 == 0 and a.count(0) == N/3:
            res = "Yes"
print(res)