Harryxun/stf_run huggingface dataset:
import sys
N, M = map(int, input().split())
D = list(zip(list(map(int, input().split())), list(range(N))))
G = [[] for _ in range(N)]
for i in range(N):
    u, v = map(int, input().split())
    G[u-1].append((v-1, i))
    G[v-1].append((u-1, i))
E = [e for e in D]
D.sort()
V = [-1]*N
j = 0
used = [False]*N
ans = [10**9]*M
BW = ['']*N
while j<N:
    d, v = D[j]
    for nv, i in G[v]:
        nd, k = E[nv]
        if used[nv]:
            ans[i] = d-nd
            used[v] = True
            j+=1
            BW[v] = BW[nv]
            break
        if nd == d:
            used[v] = used[nv] = True
            ans[i] = d
            BW[nv] = 'B'
            BW[v] = 'W'
            j+=2
            break
    if not used[v]:
        print(-1)
        sys.exit()
print(*BW, sep = '')
print(*ans, sep = '\n')

        

            



### FIXED CODE ###

import sys
N, M = map(int, input().split())
D = list(map(int, input().split()))
DI = list(zip(D, list(range(N))))
G = [[] for _ in range(N)]
for i in range(M):
    u, v = map(int, input().split())
    G[u-1].append((v-1, i))
    G[v-1].append((u-1, i))
DI.sort()
V = [-1]*N
j = 0
used = [False]*N
ans = [10**9]*M
BW = ['']*N
for j in range(N):
    d, v = DI[j]
    if used[v]:
        continue
    for nv, i in G[v]:
        if d == D[nv]:
            if BW[nv] == '':
                BW[nv] = 'B'
                BW[v] = 'W'
                ans[i] = d
                used[v] = True
                used[nv] = True
            elif BW[nv] == 'W':
                BW[v] = 'B'
                ans[i] = d
                used[v] = True
            else:
                BW[v] = 'W'
                ans[i] = d
                used[v] = True
            break
        elif used[nv]:
            if BW[nv] == 'B':
                BW[v] = 'B'
                ans[i] = d-D[nv]
                used[v] = True
            else:
                BW[v] = 'W'
                ans[i] = d-D[nv]
                used[v] = True
            break
    if not used[v]:
        print(-1)
        sys.exit()
print(*BW, sep = '')
print(*ans, sep = '\n')
k = int(input())
s = raw_input()

if k >= len(s):
    print(s)
else:
    print(s[0:k]+"...")


### FIXED CODE ###

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

if k >= len(s):
    print(s)
else:
    print(s[0:k]+"...")
N,K = map(int,input().split())
x = [int(i) for i in input().split()]
ans = 0

if  0 in x:
    K-=1
    N-=1
    x.pop(x.index(0))

if K > 0:
    ansp,ansm,anso,border = 1e8,1e8,1e8,0
    while border < N and x[border] < 0:
        border += 1
    
    if N - border >= K: ansp = x[border+K-1]
    if border >= K: ansm = -x[border-K]
    
    if border!=0 and border!=N:
        xp,xm = x[border:],x[:border][::-1]
        if len(xp) >= K and len(xm) >= K:
            ind = [[K-i, i] for i in range(K)] 
        elif len(xp) < len(xm):
            ind = [[len(xp)-i, K-len(xp)+i] for i in range(len(xp))]
        else:
            ind = [[K-len(xm)+i, len(xm)-i] for i in range(len(xm))]

        for i in ind:
            if xp[i[0]-1] > -xm[i[1]-1]:    temp = xp[i[0]-1] - 2*xm[i[1]-1]
            else:   temp = 2*xp[i[0]-1] - xm[i[1]-1]
            
            if anso > temp: anso = temp
    
    ans = min(ansp,ansm,anso)

print(ans)
        

### FIXED CODE ###

N,K = map(int,input().split())
x = [int(i) for i in input().split()]
ans = 1e10

for i in range(N-K+1):
    l,r = x[i],x[i+K-1]
    if l < 0 and r <= 0: temp = -l
    elif l >= 0 and r > 0:   temp = r
    else:
        if -l < r:    temp = 2*(-l) + r
        else:    temp = -l + 2*r  
    
    if ans > temp:  ans = temp

print(ans)
N,M=map(int,input().split())
ab=[[0]*8]*8
a=[0]*M
b=[0]*M

reached=[0]*M

for i in range(M):
  a[i],b[i]=map(int,input().split())
  ab[a[i]-1][b[i]-1]=1
  ab[b[i]-1][a[i]-1]=1
    
def rootCount(pos,N,reached):
  count=0
  prev=0
  finish=1
  for i in range(N):
    if reached[i] == 0:
      finish=0
  if finish==1:
    return 1
    
  
  for i in range(N):
    if ab[pos][i]==0:
      continue
    if reached[i]==1:
      continue
    reached[i]=1
    count+=rootCount(i,N,reached)
    reached[i]=0
  return(count)

reached[0]=1
count=rootCount(0,N,reached)
print(count)


### FIXED CODE ###

from itertools import permutations
N,M=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(M)]
g=[[False]*N for i in range(N)]
for a,b in ab:
  g[a-1][b-1]=True
  g[b-1][a-1]=True
nodes=[i for i in range(1,N)]
ans=0
for route in permutations(nodes):
  if g[0][route[0]]== False:
    continue
  for i in range(N-1):
    if i == N-2:
      ans+=1
      
      break
    elif g[route[i]][route[i+1]]:
      continue
    else:
      break
print(ans)
n = int(input())
x, y = [], []
for i in range(n)
  x_, y_ = map(int, input().split())
  x.append(x_)
  y.append(y_)
for i in range(n-2)
  if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
    print("Yes")
    break
else:
  print("No")

### FIXED CODE ###

n = int(input())
x, y = [], []
for i in range(n):
  x_, y_ = map(int, input().split())
  x.append(x_)
  y.append(y_)
for i in range(n-2):
  if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
    print("Yes")
    break
else:
  print("No")
import sys

def solve(n, lst_a):
    a=1
    b=1    
    for i in as1:
        if a <i:
            a=i
        elif b>i:
            b=i
    return a-b

def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    n = int(line1)
    line2 = sys.stdin.readline().rstrip()
    lst_a = [int(s) for s in line2.split(' ')]
    return (n, lst_a)

def main():
    n, lst_ab = readQuestion()
    answer = solve(n, lst_ab)
    print(answer)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

def solve(n, lst_a):
    a=lst_a[0]
    b=lst_a[0]
    [0]
    for i in lst_a:
        if a <i:
            a=i
        elif b>i:
            b=i
    return a-b

def readQuestion():
    line1 = sys.stdin.readline().rstrip()
    n = int(line1)
    line2 = sys.stdin.readline().rstrip()
    lst_a = [int(s) for s in line2.split(' ')]
    return (n, lst_a)

def main():
    n, lst_ab = readQuestion()
    answer = solve(n, lst_ab)
    print(answer)
    
if __name__ == '__main__':
    main()
n = int(input())
a = [int(_) for _ in input().split()]

if n % 2 == 0:
    print(*a[n-1::-2], *a[::2])
else:
    print(*a[n-1::-2], *a[1::2])

### FIXED CODE ###

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

if n%2==0:
    s = a[n-1::-2] + a[::2]
else:
    s = a[n-1::-2] + a[1::2]

print(*s)
import math
MOD =1000000007


def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
        # print(K,x)
        x%=MOD
    return K * x


n = int(input())

a_b_d = {}
# b_a_d = {}

a_zero_cnt = 0
b_zero_cnt = 0
ab_zero_cnt = 0

for i in range(n):
    a, b = map(int, input().split()) 
    if a==0 and b!=0:
        a_zero_cnt += 1
    elif  a!=0 and b==0:
        b_zero_cnt += 1
    elif a == 0 and b == 0:
        ab_zero_cnt += 1
    else:
        gcd_ab = math.gcd(a,b)
        a = a//gcd_ab
        b = b//gcd_ab
        if a > 0 and b < 0:
            a *= -1
            b *= -1
        elif a < 0 and b < 0:
            a *= -1
            b *=-1
        a_b_d.setdefault((a,b),0)
        a_b_d[(a,b)] += 1


done_list = set()
pair_cnt = []
uniq_cnt = 0
for k,v in a_b_d.items():
    comp_pair1 = (-k[1], k[0])
    comp_pair2 = (k[1], -k[0])
    if k in done_list:
        continue
    if comp_pair1 in a_b_d:
        # print(k, comp_pair)
        done_list.add(comp_pair1)
        pair_cnt.append((v,a_b_d[comp_pair1]))
    elif comp_pair2 in a_b_d:
        # print(k, comp_pair)
        done_list.add(comp_pair2)
        pair_cnt.append((v,a_b_d[comp_pair2]))
    else:
        uniq_cnt += 1


ans = pow_k(2,uniq_cnt) % MOD
for pair in pair_cnt:
    ans *= (pow_k(2,pair[0]) + pow_k(2,pair[1]) -1 )
    ans%=MOD

zero_m = max(pow_k(2,a_zero_cnt) + pow_k(2,b_zero_cnt) -1, 1)
# print(ans)
ans *= zero_m
# ans *= (zero_cnt+1)
ans -= 1
print(ans%MOD)

### FIXED CODE ###

from collections import deque

def bfs(g_list, visited):
    q = deque([1])
    visited[1] = 0
    while q:
        curr_room = q.popleft()
        for next_room in g_list[curr_room]:
            if visited[next_room] >= 0:
                continue
            visited[next_room] = curr_room
            q.append(next_room)


def main():
    n, m = map(int, input().split()) 
    g_list = [ [] for _ in range(n+1)]
    visited = [-1] * (n+1)
    visited[0] = 0
    # print(g_list)
    for i in range(m):
        a, b = map(int, input().split()) 
        g_list[a].append(b)
        g_list[b].append(a)
    bfs(g_list,visited)
    # print(visited)
    ans = visited[2:]
    if -1 in ans:
        print('No')
    else:
        print('Yes')
        for a in ans:
            print(a)

if __name__ == "__main__":
    main()
n,k = map(int,input().split())
x = []
y = []
xx = []
yy = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
ans = 10 ** 40
x.sort()
y.sort()
for i in range(n):
    for j in range(i+1,n):
        for l in range(n):
            for h in range(l+1,n):
                lx = x[i]
                rx = x[j]
                uy = y[h]
                dy = y[l]
                cnt = 0
                for ii in range(n):
                    if lx <= xx[ii] <= rx and dy <= yy[ii] <= uy:
                        cnt += 1
                if cnt >= k:
                    if (rx-lx) * (uy-dy) != 0:
                        ans = min(ans,(rx-lx)*(uy-dy))
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
x = []
y = []
xx = []
yy = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
    xx.append(a)
    yy.append(b)
ans = 10 ** 40
x.sort()
y.sort()
for i in range(n):
    for j in range(i+1,n):
        for l in range(n):
            for h in range(l+1,n):
                lx = x[i]
                rx = x[j]
                uy = y[h]
                dy = y[l]
                cnt = 0
                for ii in range(n):
                    if lx <= xx[ii] <= rx and dy <= yy[ii] <= uy:
                        cnt += 1
                if cnt >= k:
                    if (rx-lx) * (uy-dy) != 0:
                        ans = min(ans,(rx-lx)*(uy-dy))
print(ans)
L.R=map(int,input().split())
ans=float('inf')
for i in range(L,R+1):
  for j in range(L,R+1):
    s=(i*j)%2019
    if s==0:
      print(0)
      exit()
    else:
      ans=min(s,ans)
      
print(ans)
    

### FIXED CODE ###

L,R=map(int,input().split())
ans=float('inf')
for i in range(L,R):
  for j in range(L+1,R+1):
    s=(i*j)%2019
    
    if s==0:
      print(0)
      exit()
    else:
      ans=min(s,ans)
      
print(ans)
while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
        if h == 0 or h == H - 1 or w == 0 or w == W - 1:
            print('#', end='')
        else:
             print('.', end='')

        print()

    print()

### FIXED CODE ###

while True:
    H, W = [int(i) for i in input().split()]
    if H == W == 0:
        break

    for h in range(H):
        for w in range(W):
            print('#', end='')

        print()

    print()
from collections import defaultdict
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
d = defaultdict(int)
for i in range(n):
    x1, y1 = xy[i]
    for j in range(i+1, n):
        x2, y2 = xy[j]
        d["%d:%d" % (x2-x1, y2-y1)] += 1

print(n-max(d.values()))


### FIXED CODE ###

N=int(input())
point=[]
merge=0
for num in range(0,N):
    x,y=map(int,input().split())
    point.append([x,y])
p=0
q=0
point.sort()
ans=0
for i in range(0,N-1):
    for j in range(i+1,N):
        p=point[j][0]-point[i][0]
        q=point[j][1]-point[i][1]
        merge=0
        for k in range(0,N):
            if([point[k][0]+p,point[k][1]+q] in point):
                merge+=1
        ans=max(ans,merge)
print(N-ans)
# -*- coding: utf-8 -*-


N = int(input())
S = input()

count = 0

for i, s in enumerate(S):
    if s != 'A':
        continue
    else:
        if S[i+1] == 'B' and S[i+2] == 'C':
            count += 1

print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-


N = int(input())
S = input()

count = 0

for i, s in enumerate(S[:-2]):
    if s != 'A':
        continue
    else:
        if N >= i + 2 and S[i+1] == 'B' and S[i+2] == 'C':
            count += 1

print(count)
upp = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
low = "abcdefghijklmnopqrstuvwxyz"

while 1:
	a,type = raw_input().split()
	if type == "X": break
	ans = ""
	if type == "U":
		if "_" in a:
			words = a.split("_")
			for word in words:
				ans += upp[low.index(word[0])] + word[1:]
		else:
			ans = upp[low.index(a[0])] + a[1:]
	elif type == "L":
		if "_" in a:
			words = a.split("_")
			ans += words[0]
			for word in words[1:]:
				ans += upp[low.index(word[0])] + word[1:]
		else:
			ans = low[upp.index(a[0])] + a[1:]
	else:
		words = []
		sp = 0
		for i in range(1,len(a)):
			if a[i] in upp:
				words.append(a[sp:i].lower())
				sp = i
		words.append(a[sp:].lower())
		ans = "_".join(words)
	print ans

### FIXED CODE ###

while 1:
	a,type = raw_input().split()
	if type == "X": break
	ans = ""
	if type == "U":
		for word in a.split("_"):
			ans += word[0].upper() + word[1:]
	elif type == "L":
		for word in a.split("_"):
			ans += word[0].upper() + word[1:]
		ans = ans[0].lower() + ans[1:]
	else:
		if "_" not in a:
			words = []
			sp = 0
			for i in range(1,len(a)):
				if a[i].isupper() :
					words.append(a[sp:i].lower())
					sp = i
			words.append(a[sp:].lower())
			ans = "_".join(words)
		else:
			ans = a
	print ans
N,K = input().split()
N = int(N)
K = int(K)

h = input().split()

count = 0

for i in range(n):
    if h[i] >= K:
        count += 1
    else:
        pass

print(count)




### FIXED CODE ###

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

count = 0

for i in a:
    if i>= k:
        count += 1
print(count)
from collections import deque

def bfs(start):
    queue = deque([start])
    visited = []

    while queue:
        label = queue.pop()

       visited.append(label)

        for v in d[label]:
            if tekazu[v] == float("inf"):
                tekazu[v] = tekazu[label] + 1
                queue.appendleft(v)

    return

n = int(input())
d = [[] for _ in range(n)]

for _ in range(n - 1):
    a, b = map(int, input().split())
    d[a - 1].append(b - 1)
    d[b - 1].append(a - 1)

tekazu = [float("inf") for _ in range(n)]
tekazu[0] = 0
bfs(0)
tekazu_Fennec = tekazu

tekazu = [float("inf") for _ in range(n)]
tekazu[-1] = 0
bfs(n - 1)
tekazu_Snuke = tekazu

Fennec = 0
Snuke = 0

for i in range(n):
    if tekazu_Fennec[i] <= tekazu_Snuke[i]:
        Fennec += 1
    else:
        Snuke += 1

if Fennec > Snuke:
    print("Fennec")
else:
    print("Snuke")

### FIXED CODE ###

from collections import deque

def bfs(start):
    queue = deque([start])
    visited = []

    while queue:
        label = queue.pop()

        #if label not in visited:
        visited.append(label)

        for v in d[label]:
            if tekazu[v] == float("inf"):
                tekazu[v] = tekazu[label] + 1
                queue.appendleft(v)

    return

n = int(input())
d = [[] for _ in range(n)]

for _ in range(n - 1):
    a, b = map(int, input().split())
    d[a - 1].append(b - 1)
    d[b - 1].append(a - 1)

tekazu = [float("inf") for _ in range(n)] # nは頂点数
tekazu[0] = 0
bfs(0)
tekazu_Fennec = tekazu

tekazu = [float("inf") for _ in range(n)] # nは頂点数
tekazu[-1] = 0
bfs(n - 1)
tekazu_Snuke = tekazu

Fennec = 0
Snuke = 0

for i in range(n):
    if tekazu_Fennec[i] <= tekazu_Snuke[i]:
        Fennec += 1
    else:
        Snuke += 1

#print(tekazu_Fennec, tekazu_Snuke)

if Fennec > Snuke:
    print("Fennec")
else:
    print("Snuke")
i = input().split()
h = int(i[0])
w = int(i[1])

if h == 1 || w == 1:
    print(1)

if (h * w % 2 == 0):
    print(h * w // 2)
else:
    print(h * w // 2 + 1)

### FIXED CODE ###

i = input().split()
h = int(i[0])
w = int(i[1])

if h == 1 or w == 1:
    print(1)
else:
    if (h * w % 2 == 0):
        print(h * w // 2)
    else:
        print(h * w // 2 + 1)
n = int(input())
a = list(map(int, input().split()))
x = [0] * n
x[0] += a[0]
for i in range(1, n, 2):
  x[0] += - a[i] + a[i+1]

for i in range(1, n):
  x[i] = -x[i-1] + 2*a[i-1]
  
o = " ".join(x)
print(o)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
x = [0] * n
x[0] += a[0]
for i in range(1, n, 2):
  x[0] += - a[i] + a[i+1]

for i in range(1, n):
  x[i] = -x[i-1] + 2*a[i-1]
  
o = " ".join(map(str, x))
print(o)
N = int(input())
ans = 0
bool1 = False

a0 = int(input())

for i in range(N-1):
    a1 = int(input())
    if i == 0 and a0 != 0:
        bool1 = True
        break
    if a1 - a0 > 1:
        bool1 = True
        break
    elif a1 - a0 == 1:
        a0 = a1
        continue
    else:
        ans += a0
        a0 = a1
       
if bool1 == True:
    print(-1)
else:
    print(ans + a1)

### FIXED CODE ###

N = int(input())
ans = 0
bool1 = False

a0 = int(input())
if N == 1:
    if a0 != 0:
        print(-1)
    else:
        print(0)

else:
    for i in range(N-1):
        a1 = int(input())
        if i == 0 and a0 != 0:
            bool1 = True
            break
        if a1 - a0 > 1:
            bool1 = True
            break
        elif a1 - a0 == 1:
            a0 = a1
            continue
        else:
            ans += a0
            a0 = a1

    if bool1 == True:
        print(-1)
    else:
        print(ans + a1)
x = input().split(" ")
a = int(x[0])
b = int(x[1])
c = int(x[2])
count = 0
for i in range(a,b+1):
    if c % i == 0:
        count += 1
Print(count)


### FIXED CODE ###

x=input().split(" ")
a=int(x[0])
b=int(x[1])
c=int(x[2])
count=0
for i in range(a,b+1):
  if c%i==0:
   count+=1
print(count)
import sys

sys.setrecursionlimit(5000)
line_size, row_size = map(int, input().split())
mapmap = []#地図初期化

for i in range(line_size):
    mapmap.append(list(input()))

#探索関数
def Dfs(px, py):
    global mapmap
    #自分のいるところを変換→globalにして更新
    mapmap[py][py] = '.'

    #自分の動けるところ定義
    move_x = [1, -1, 0, 0]
    move_y = [0, 0, 1, -1]
    for i in range(len(move_x)):#動ける範囲で探索
        nx = px + move_x[i]
        ny = py + move_y[i]
        if 0 <= nx and line_size > nx and 0 <= ny and row_size > ny:
            if mapmap[nx][ny] == '#':#もし黒塗りなら
                Dfs(nx, ny)#自分のいるところから突き進むむからfirst in last out
            else:
                return

#開始条件探索
def Start_check(px, py):
    global mapmap
    start_flg = False
    move_x = [1, -1, 0, 0]
    move_y = [0, 0, 1, -1]
    for i in range(len(move_x)):#動ける範囲で探索
        nx = px + move_x[i]
        ny = py + move_y[i]
        if 0 <= nx and line_size > nx and 0 <= ny and row_size > ny:
            if mapmap[nx][ny] == '#':#もし黒塗りなら
                start_flg = True
    
    if start_flg == False:
        print('No')
        sys.exit()

    print(start_flg)

#Main
count = 0#探索回数（塗り絵した回数）
for i in range(line_size):
    for j in range(row_size):
        if mapmap[i][j] == '#':
            Start_check(i, j)
            Dfs(i, j)
            count += 1

#何もしなかった場合
if count == 0:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

import sys

line_size, row_size = map(int, input().split())
mapmap = []#地図初期化

for i in range(line_size):
    mapmap.append(list(input()))

#探索
def Start_check(mapmap, px, py):
    start_flg = False
    move_x = [1, -1, 0, 0]
    move_y = [0, 0, 1, -1]
    for i in range(4):#動ける範囲で探索
        nx = px + move_x[i]
        ny = py + move_y[i]
        if 0 <= nx and nx < line_size and 0 <= ny and ny < row_size:
            if mapmap[nx][ny] == '#':#もし黒塗りなら
                start_flg = True
    
    if start_flg == False:
        print('No')
        sys.exit()

#Main
count = 0#探索回数（塗り絵した回数）
for i in range(line_size):
    for j in range(row_size):
        if mapmap[i][j] == '#':
            Start_check(mapmap, i, j)
            count += 1

#何もしなかった場合
print('Yes')
N = int(input())
s = list(input())
t = list(input())
cnt = 0
if s==t:
    ans = N
else:
    for i in range(N):
        if s[i:]==t[:-i]:
            ans = N*2 - (N-i)
print(ans)

### FIXED CODE ###

N = int(input())
s = list(input())
t = list(input())
cnt = 0
if s==t:
    ans = N
    cnt = 1
elif N==1:
    ans = N*2
    cnt = 1
else:
    for i in range(N):
        if s[i:]==t[:-i]:
            cnt = 1
            ans = N*2 - (N-i)
print(ans) if cnt==1 else print(N*2)
a,b,c =map(input().split())
print(a[0].isupper(),b[0].isupper(),c[0].isupper(),sep="")

### FIXED CODE ###

a,b,c =input().split()
print(a[0].upper(),b[0].upper(),c[0].upper(),sep="")
#N=input()
#N,M=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

total=sum(B)

for j in range(N):
  if j+1!=N:
    if A[j]+1==A[j+1]:
      total+=C[A[j-1]]
      
print(total)

### FIXED CODE ###

#N=input()
#N,M=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

total=sum(B)

for j in range(N):
  if j+1!=N:
    if A[j]+1==A[j+1]:
      total+=C[A[j]-1]
      
print(total)
from sys import stdin
n=int(stdin.readline())
l=map(int,stdin.readline().split())
ans=0
for i in l:
  ans^=i
if ans:
  stdout.write("No")
else:
  stdout.write("Yes")

### FIXED CODE ###

n=input()
l=map(int,raw_input().split())
ans=0
for i in xrange (n):
  ans^=l[i]
if ans:
  print "No"
else:
  print "Yes"
x,n = map(int, input().split())

if n == 0:
    print(x)
    exit()

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

allList=[]

for i in range(1,101):
    allList.append(i)
    
diff = set(allList) ^ set(p)

diff = list(diff)
diff.append(x)
diff = sorted(diff)

# print(diff)

ind = diff.index(x)
# print(ind)

a = diff[ind-1]
b = diff[ind+1]

ax = abs(a-x)
bx = abs(b-x)

# print(ax,bx)

if ax==bx:
    if a < b:
        print(a)
    else:
        print(b)

if ax > bx:
    print(b)
    exit()

### FIXED CODE ###

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

if n == 0:
    print(x)
    exit()

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

allList=[]

for i in range(-201,301):
    allList.append(i)

diff = set(allList) ^ set(p)



diff = list(diff)
diff.append(x)
diff = sorted(diff)

# print(diff)

ind = diff.index(x)
# print(ind)

# if x == 100:
    

a = diff[ind-1]
b = diff[ind+1]
# print(a,b)

ax = abs(x-a)
bx = abs(x-b)

# print(ax,bx)

if ax==bx:
    if a < b:
        print(a)
        exit()
    else:
        print(b)
        exit()

if ax > bx:
    print(b)
else:
    print(a)
n=int(input())
a=list(map(int,input().split()))
a.sort()

while len(a)>=2:
  for i in range(1,len(a)):
    a[i]=a[i]%a[0]
  if 0 in a:
    a.remove(0)
  a.sort()
    

print(a[0])

### FIXED CODE ###

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

while len(a)>=2:
  for i in range(1,len(a)):
    a[i]=a[i]%a[0]
  if 0 in a:
    for j in range(a.count(0)):
      a.remove(0)
  a.sort()
    

print(a[0])
import numpy as np
#import random
from numba import jit

@jit
def main():
    #N = 100000
    #A = random.choices(range(1, N), k=N)
    N = int(input())
    A = np.array(list(map(int, input().split())), dtype=np.uintc)
    MAX = 10**5
    X = np.zeros(MAX, dtype=np.uintc)
    Y = np.array(range(MAX), dtype=np.uintc)
    
    for i in range(len(A)): X[A[i]] += 1
    
    Q = int(input())
    #Q = MAX
    OUT = np.zeros(Q, dtype=np.uintc)
    for i in range(Q):
        [b, c] = list(map(int, input().split()))
        #b, c = random.choice(range(1, N)), random.choice(range(1, N))
        X[c] += X[b]
        X[b] = 0
        OUT[i] = int(np.sum(X*Y))
    return OUT

OUT = main()
print("\n".join(map(str, list(OUT))))



### FIXED CODE ###

import array

N = int(input())
A = array.array('L', list(map(int, input().split())))
MAX = 10**5+1
X = array.array('L', [0]) * MAX
Y = array.array('L', range(MAX))

for i in range(len(A)): X[A[i]] += 1
    
Q = int(input())
cur = sum(array.array('L', (X[i]*Y[i] for i in range(len(X)))))

for i in range(Q):
    [b, c] = list(map(int, input().split()))
    cur = cur - X[b]*b + X[b]*c
    print(cur)
    X[c] += X[b]
    X[b] = 0