Harryxun/stf_run huggingface dataset:
x,n = map(int, input().split())

if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    d = []
    c=0
    for e in p:
        d.append(abs(e-x))
    d1 = d[0]
    for i in range(len(d)):
        if d[i] < d1:
            d1 = d[i]
            z = p[i]
    for j in range(1,100):
        for g in p:
            if z+j != g:
                c +=1
                w1 = z+j
        if c == n:
            break
        c = 0
    c=0
    for j2 in range(1,100):
        for g2 in p:
            if z-j2 != g2:
                c +=1
                w2 = z-j2
        if c == n:
            break
        c = 0

    if w2 < 0:
        print(w1)
    elif abs(w1-x) < abs(w2-x):
        print(w1)
    else:
        print(w2)

### FIXED CODE ###

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

if n == 0:
    print(x)
elif n ==100:
    if x >50:
        print(101)
    else:
        print(0)
else:
    p = list(map(int, input().split()))
    d = []
    c=0
    for e in p:
        d.append(abs(e-x))
    d1 = d[0]
    z=p[0]
    for i in range(len(d)):
        if d[i] < d1:
            d1 = d[i]
            z = p[i]
    for j in range(1,100):
        for g in p:
            if z+j != g:
                c +=1
                w1 = z+j
        if c == n:
            break
        c = 0
    c=0
    for j2 in range(1,100):
        for g2 in p:
            if z-j2 != g2:
                c +=1
                w2 = z-j2
        if c == n:
            break
        c = 0
    if w2 < 0:
        print(w1)
    elif abs(w1-x) < abs(w2-x):
        print(w1)
    else:
        print(w2)
def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+100)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, Mod
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True
    try:
        if  a[x-2] != 1:
            res += solve(x-2) 
            zeroflg = False
    except:
        pass
    try:
        if a[x-1] != 1:
            res += solve(x-1)
            zeroflg = False
    except:
        pass

    if zeroflg:
        return 0
    dp[x] = res% Mod
    return res


dp = [-1]*(N+100)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

def acinput():
    return list(map(int, input().split(" ")))


N, M = acinput()
a = [0]*(N+1)
for i in range(M):
    a[int(input())] = 1


Mod = 1000000007


def solve(x):
    global dp, Mod
    if dp[x] >= 0:
        return dp[x]

    if x < 0:
        return 0

    res = 0
    zeroflg = True

    if  a[x-2] != 1:
        res += solve(x-2) 
        zeroflg = False

    if a[x-1] != 1:
        res += solve(x-1)
        zeroflg = False

    if zeroflg:
        return 0
    dp[x] = res% Mod
    return res


dp = [-1]*(N+1)
dp[0] = 1
dp[1] = 1

print(solve(N) % Mod)


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

    # divisors.sort()
    return divisors

N = int(input())

n = make_divisors(N)

cnt = 999999999999999
for i in range(0,len(n),2):
    t = n[i]-1 + n[i+1]-1
    if cnt > t:
        cnt = t
print(cnt)



### FIXED CODE ###

def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    #table = list(set(table))
    table = list(table)
    table.sort()
    return table

N = int(input())

#for N in range(1000000000000):
n = []
n = divisor(N)
#print(n)

cnt = 999999999999999
for i in range(0,len(n)//2,1):
    t = int(n[i])-1 + int(n[len(n)-i-1])-1
    if cnt > t:
        cnt = t
print(cnt)
N, M = map(int, input().split())

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

X.sort()

buff = []

for i in range(M-1):
    buff.append(abs(X[i+1]-X[i]))


buff.sort()
buff = buff[::-1]

for i in range(min(N-1, len(buff))):
    # print(buff.pop(0))

print(sum(buff))

### FIXED CODE ###

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

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

X.sort()

buff = []

for i in range(M-1):
    buff.append(abs(X[i+1]-X[i]))


buff.sort()
buff = buff[::-1]

for i in range(min(N-1, len(buff))):
    buff.pop(0)

print(sum(buff))
N, M = map(int, input().split())
list=[]
s={}
for i in range(N):
    list.append(input().split())
    a = set(list[1:])
    s = s & a
    list=[]
print(len(s)) 

### FIXED CODE ###

N, M = map(int, input().split())
list=[]
s=set(range(1, M+1))
for i in range(N):
    K, *A = map(int, input().split())
    s &= set(A)
print(len(s))
s=input()
list_s=list(s)
element='B'
l1=['0','1','B']
for i in range(0,len(list_s)-i):
	if(list_s[i] == element):
		index_element=list_s[i-1]
		if(index_element):
			list_s.remove(index_element)
			list_s.remove(element)
			print(list_s)
		else:
		    list_s.append("s")
		    list_s.remove("s")

	else:
		list_s.append("s")
		list_s.remove("s")
		print(list_s)


### FIXED CODE ###

ans=0
n=int(input())
for i in range(1,n+1):
	ans+=i
	
print(ans)
from functools import lru_cache

import sys
sys.setrecursionlimit(10**9)

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

# N = 5, K = 3
# i = 1 3 (青, 青, 青, 赤, 赤), (赤, 青, 青, 青, 赤), (赤, 赤, 青, 青, 青)
# (0, 2), (1, 1), (2, 0) 3c2 = 3 * 2 / 2 * 1
# i = 1, B = 3, R = 2
# i = 2 6 (青, 青, 赤, 青, 赤), (青, 青, 赤, 赤, 青), (赤, 青, 青, 赤, 青), (赤, 青, 赤, 青, 青), (青, 赤, 青, 青, 赤), (青, 赤, 赤, 青, 青)
# (0, 1, 0, 1), (0, 1, 1, 0), (1, 0, 1, 0), () 4c2 = 4 * 3 / 2 * 1 = 6
# i = 2, B = 3, R = 2
# i = 3 1 (青, 赤, 青, 赤, 青)
# (1, 1) 2c1 = 1
# i = 3, B = 3, R = 2

# i = 1, N = 5, B = 3, R = 2, ans = 3
# i = 2, N = 5, B = 3, R = 2, ans = 6
# i = 3, N = 5, B = 3, R = 2, ans = 1

# N = 6, K = 3
# i = 1 4: (BBBRRR), (RBBBRR), (RRBBBR), (RRRBBB)
# (0, 3), (1, 2), (2, 1), (3, 0)
# i = 1, B = 3, R = 3
# i = 2 : (BBRBRR), (BRBBRR), (BRRBBR) * 2

# B = 3, i = 1: B / i = 1
# B = 3, i = 2: B / i = 3
# B = 3, i = 3: B / i = 1

# B = 1: 1 * x = 3
# B = 2: 2 * x = 6
# B = 3: 1 * x = 1


@lru_cache(maxsize=10*9)
def combinations(n, r):
    if n == 0 or r == 0: return 1
    return int(combinations(n, r-1) * (n-r+1) / r )

def f(i):
    return (combinations(N - K + 1, i)  % (10 ** 9 + 7)) * (combinations(K - 1, i - 1)  % (10 ** 9 + 7))

for i in range(1, K + 1):
    print(f(i) % (10 ** 9 + 7))


### FIXED CODE ###

from functools import lru_cache

import sys
sys.setrecursionlimit(10**9)

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

M = 10 ** 9 + 7

@lru_cache(maxsize=10**9)
def combinations(n, r):
    if n == 0 or r == 0: return 1
    return int((combinations(n, r-1) * (n-r+1)) // r)

def f(i):
    return (combinations(N - K + 1, i) % M) * (combinations(K - 1, i - 1) % M)

for i in range(1, K + 1):
    print(f(i) % M)
x = int(input())
 if x >0:   
    num = x / 500
    w = x-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
 else:
     sum = 0 

### FIXED CODE ###

X = int(input())
if X >0:   
    num = X / 500
    w = X-(int(num)*500)
    p = w / 5   
    sum = (int(num)*1000)+(int(p)*5)
else:
     sum = 0   
print(sum)
N,K = map(int, input().split())
p = list(map(int, input().split())

print(sum(sorted(p)[:N]))

### FIXED CODE ###

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

print(sum(sorted(p)[:k]))
N,C = map(int,input().split())
XV = [0,0] + [[int(i) for i in input().split()] for _ in range(N)] + [C,0]

Sum_left = [0] * (N+1)
Sum_right = [0] * (N+1)
for i in range(N):
    Sum_left[i+1] = Sum_left[i] + XV[i+1][1]
    Sum_right[i+1] = Sum_right[i] + XV[N-i][1]

ans = 0
for i in range(N+1):
    for j in range(N+1-i):
        ans = max(ans, Sum_left[i] + Sum_right[j] - XV[i][0] - 2 * (C - XV[N+1-j][0]), Sum
_left[i] + Sum_right[j] - 2 * XV[i][0] - (C - XV[N+1-j][0]))

print(ans)


### FIXED CODE ###

N,C = map(int,input().split())
XV = [[0,0]] + [[int(i) for i in input().split()] for _ in range(N)] + [[C,0]]

Sum_left = [0] * (N+1)
Sum_right = [0] * (N+1)
for i in range(N):
    Sum_left[i+1] = Sum_left[i] + XV[i+1][1]
    Sum_right[i+1] = Sum_right[i] + XV[N-i][1]

Sum_right_maxA = [0] * (N+1)
Sum_right_maxB = [0] * (N+1)
for i in range(1,N+1):
    Sum_right_maxA[i] = max(Sum_right_maxA[i-1], Sum_right[i] - 2 * (C - XV[N+1-i][0]))
    Sum_right_maxB[i] = max(Sum_right_maxB[i-1], Sum_right[i] - (C - XV[N+1-i][0]))

ans = 0
for i in range(N+1):
    ans = max(ans, Sum_left[i] + Sum_right_maxA[N-i] - XV[i][0], Sum_left[i] + Sum_right_maxB[N-i] - 2*XV[i][0])
print(ans)
n = int(input())
a = list(map(float, input().split()))
c = 1
for i in range(n):
    c = c * a[i]
print(float(c) / sum(a))

### FIXED CODE ###

a = int(input())
s = input()
if a >= 3200:
    print(s)
else:
    print('red')
MOD = 998244353

def zeta_gcd(a,primes):
    n = len(a)-1
    for p in primes:
        for i in range(n//p,0,-1):
            a[i] += a[p*i]
            a[i] %= MOD
def mobius_gcd(a,primes):
    n = len(a)
    for p in primes:
        for i in range(1,n):
            if i*p >= n: break
            a[i] -= a[p*i] 
            a[i] %= MOD
def get_primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

NNN = 10**6
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )

N, = map(int, input().split())
X = list(map(int, input().split()))
primes = get_primes(NNN)
fs = [0]*NNN
for x in X:
    fs[x] += x
#print(fs)
zeta_gcd(fs, primes)
#print(fs)
for i, x in enumerate(fs):
    fs[i] = x**2
#print(fs)
mobius_gcd(fs, primes)
#print(fs)
r = 0
for i, f in enumerate(fs[1:]):
    i += 1
    r = (r + f*inverse[i]) % MOD
for x in X:
    r = (r - x) % MOD

print((r*inverse[2])%MOD)


### FIXED CODE ###

MOD = 998244353

def zeta_gcd(a,primes):
    n = len(a)-1
    for p in primes:
        for i in range(n//p,0,-1):
            a[i] += a[p*i]
            a[i] %= MOD
def mobius_gcd(a,primes):
    n = len(a)
    for p in primes:
        for i in range(1,n):
            if i*p >= n: break
            a[i] -= a[p*i] 
            a[i] %= MOD
def get_primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

NNN = 10**6 + 1
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )

N, = map(int, input().split())
X = list(map(int, input().split()))
primes = get_primes(NNN)
fs = [0]*NNN
for x in X:
    fs[x] += x
#print(fs)
zeta_gcd(fs, primes)
#print(fs)
for i, x in enumerate(fs):
    fs[i] = x**2
#print(fs)
mobius_gcd(fs, primes)
#print(fs)
r = 0
for i, f in enumerate(fs[1:]):
    i += 1
    r = (r + f*inverse[i]) % MOD
for x in X:
    r = (r - x) % MOD

print((r*inverse[2])%MOD)
from logging import root
from tokenize import group
import numpy
from pandas.core.resample import f
from regex.regex import U

class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)

        if i == j:
            return

        if i > j:
            i, j = j, i

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

N, M = map(int, input().split())
p = [int(i) - 1 for i in input().split()]

forest = UnionFind(N)

for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    forest.unite(x, y)

ans = 0
for i in range(N):
    if forest.same(i, p[i]):
        ans += 1

print(ans)


### FIXED CODE ###

class UnionFind:
    def __init__(self, N):
        self.N = N

        # the parent of all node is itself
        # self.parent = list(range(N))
        self.parent = [-1] * N

    def root(self, i):
        if self.parent[i] < 0:
            return i

        r = self.root(self.parent[i])
        self.parent[i] = r
        return r

    def unite(self, i, j):
        i = self.root(i)
        j = self.root(j)

        if i == j:
            return

        if i > j:
            i, j = j, i

        self.parent[i] += self.parent[j]
        self.parent[j] = i
        # print(self.parent)

    def same(self, i, j):
        return self.root(i) == self.root(j)

    def size(self, i):
        return -self.parent[self.root(i)]

N, M = map(int, input().split())
p = [int(i) - 1 for i in input().split()]

forest = UnionFind(N)

for _ in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    forest.unite(x, y)

ans = 0
for i in range(N):
    if forest.same(i, p[i]):
        ans += 1

print(ans)
a = int(input().rstrip())
if a >= 3200:
  print(input())
 else:
  print("red")

### FIXED CODE ###

a = input()
a = int(a)
if a >= 3200:
  s = input()
  print(s)
else:
  print('red')
A, B, K = map(int, input().split())
num = max(A, B)
a = [1]
cnt = 1
for i in range(1,num):
  if A % i == 0 and B % i == 0:
    cnt += 1
    a.append(i)
a.sort(reverse=True)
print(a[K])



### FIXED CODE ###

A, B, C = map(int,input().split())

print(min(B//A, C))
def solve():
    maxCards, gates = map(int, input().split())
    gateRanges = [tuple(map(int, input().split())) for i in range(gates)]

    for i, permitRange in enumerate(gateRanges):
        if i == 0:
            activeBegin, activeEnd = permitRange
            continue
        begin, end = permitRange
        if not (begin <= activeEnd and end >= activeBegin):
            print(0)
            break
        else:
            activeBegin, activeEnd = max(activeBegin, begin), min(activeEnd, end)
    else:
        if (maxCards < activeBegin):
            return print(0)
        ans = min(activeEnd, maxCards) - activeBegin + 1
    print(ans)
solve()

### FIXED CODE ###

def solve():
    maxCards, gates = map(int, input().split())
    gateRanges = [tuple(map(int, input().split())) for i in range(gates)]

    for i, permitRange in enumerate(gateRanges):
        if i == 0:
            activeBegin, activeEnd = permitRange
            continue
        begin, end = permitRange
        if not (begin <= activeEnd and end >= activeBegin):
            return print(0)
        else:
            activeBegin, activeEnd = max(activeBegin, begin), min(activeEnd, end)
    else:
        if (maxCards < activeBegin):
            return print(0)
        ans = min(activeEnd, maxCards) - activeBegin + 1
    print(ans)
solve()
n = int(input())
A,B = map(int,input().split())
for _ in range(n-1):
  a,b = map(int,input().split())
  m = max(math.ceil(A/a), math.ceil(B/b))
  A,B = A * m, B * m
print(A+B)

### FIXED CODE ###

n = int(input())
A,B = map(int,input().split())
for _ in range(n-1):
    a,b = map(int,input().split())
    aa = 0
    bb = 0
    if A % a == 0:
        aa = A // a
    else:
        aa = A // a + 1
    if B % b == 0:
        bb = B // b
    else:
        bb = B // b + 1
    m = max(aa, bb)
    A,B = a * m, b * m
print(A+B)
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
adj = [set() for _ in range(N)]
colors = dict()
ed = []
for i in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    adj[a].add(b)
    adj[b].add(a)
    ed.append([a, b])

col = max(len(v) for v in adj)

s = -1
for i, a in enumerate(adj):
    if len(a) == col:
        s = i
        break

Q = [[s, -1, -1]]
while Q:
    cur, prev, NG = Q.pop()
    c = 1
    for nex in enumerate(adj[cur]):
        if nex == prev:
            continue
        else:
            c += 1
        if c == NG:
            c += 1
        colors[min(cur, nex)*N + max(cur, nex)] = c
        Q.append([nex, cur, c])
print(col)
for a, b in ed:
    print(colors[a*N + b])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
adj = [set() for _ in range(N)]
colors = dict()
ed = []
for i in range(N-1):
    a, b = map(lambda x: int(x)-1, input().split())
    adj[a].add(b)
    adj[b].add(a)
    ed.append([a, b])

col = max(len(v) for v in adj)

s = -1
for i, a in enumerate(adj):
    if len(a) == col:
        s = i
        break

Q = [[s, -1, -1]]
while Q:
    cur, prev, NG = Q.pop()
    c = 0
    for nex in adj[cur]:
        if nex == prev:
            continue
        else:
            c += 1
        if c == NG:
            c += 1
        colors[min(cur, nex)*N + max(cur, nex)] = c
        Q.append([nex, cur, c])
print(col)
for a, b in ed:
    print(colors[a*N + b])
n=int(input())
ans=0
for i in range(n):
  x, u=map(int, str, input().split())
  if u=="BTC":
    x=x*380000
  ans=ans+x
print(ans)

### FIXED CODE ###

n=int(input())
ans=0
for i in range(n):
  x,u=input().split()
  x=float(x)
  if u=="BTC":
    x=x*380000
  ans=ans+x
print(ans)
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
p = [i-1 for i in p]
q = [i - 1 for i in q]
permutations_lis = itertools.permutations(range(n))# 全ての場合のリストを生成
dis_list = []
for i,case in enumerate(permutations_lis):
    if list(case) == p :
        a = i 
    elif list(case) == q :
        b = i
print(abs(a-b))

    

### FIXED CODE ###

import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
permutations_lis = itertools.permutations(range(1,n+1))# 全ての場合のリストを生成
dis_list = []
for i,case in enumerate(permutations_lis):
    if list(case) == p :
        a = i 
    if list(case) == q :
        b = i
print(abs(a-b))
N = input()

match_flg = 0
for nn in N:
  if( nn== "7" ):
    print( Yes )
    match_flg = 1
    break
if( match_flg == 0 ):
	print("No")


### FIXED CODE ###

N = input()
match_flg = 0
for nn in N:
  if( nn== "7" ):
    print( "Yes" )
    match_flg = 1
    break
if( match_flg == 0 ):
	print("No")
import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
tmp=(n+1)//2*(n-2)
# print(tmp)
if n%2==0:
    print(N*(N-2)//2)
else:
    print(((N-1)*(N-3))//2+N-1)
for i in range(n):
    for j in range(i+1,n):
        if (i+1)+(j+1)!=n+(n+1)%2:
            print(i+1,j+1)

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")
n=int(input())
tmp=(n+1)//2*(n-2)
# print(tmp)
if n%2==0:
    print(n*(n-2)//2)
else:
    print(((n-1)*(n-3))//2+n-1)
for i in range(n):
    for j in range(i+1,n):
        if (i+1)+(j+1)!=n+(n+1)%2:
            print(i+1,j+1)
n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
for i in range(1:n+1):
    if i =< k:
        ans += x
    else:
        ans += y
print(ans)

### FIXED CODE ###

n = int(input())
k = int(input())
x = int(input())
y = int(input())
ans = 0
for i in range(1,n+1):
    if i <= k:
        ans += x
    else:
        ans += y
print(ans)
import sys
input = sys.stdin.readline
s = input()
n = len(s)
slist = [int(i)for i in s]
q = True
ans = 0
while q:
  q = False
  kesu = 0
  for i in range(1,len(slist)):
    if slist[i] != slist[i-1]:
      kesu = i
      ans += 2
      q = True
      break
  if kesu != 0:
    del slist[kesu-1:kesu+1]
print(ans)


### FIXED CODE ###

s = input()
cnt1 = s.count('1')
cnt0 = s.count('0')
print(len(s)-abs(cnt1-cnt0))
from collections import defaultdict
N,M = list(map(int,input().split()))
price_howmany = {}
price_list = []
for _ in range(N):
    tmp = list(map(int,input().split()))
    price_list.append(tmp[0])
    if tmp[0] in price_howmany:
        price_howmany[tmp[0]] += tmp[1]
    else:
        price_howmany[tmp[0]] = tmp[1]
price_list.sort()

price = 0
many = 0
for low_price in price_list:
    many = min(M,price_howmany.pop(low_price))
    price += many * low_price
    M -= many
    if M == 0: break
print(price)

### FIXED CODE ###

# from collections import defaultdict
# N,M = list(map(int,input().split()))
# price_howmany = defaultdict(int)
import sys

stdin = sys.stdin

read_int = lambda : list(map(int,stdin.readline().split()))

N,M = read_int()
price_howmany = {}
# price_list = []

price_set = set()
for _ in range(N):
    tmp = read_int()
    # if tmp[0] not in price_set:
        # price_list.append(tmp[0])
    price_set.add(tmp[0])
    if tmp[0] in price_howmany:
        price_howmany[tmp[0]] += tmp[1]
    else:
        price_howmany[tmp[0]] = tmp[1]
# price_list.sort(reverse=True)
price_list = sorted(list(price_set))

# price_howmany = dict(price_howmany)

def solve():
    price = 0
    global M
    # while M > 0:
        # low_price = min(price_howmany.keys())
        # low_price = price_list.pop()
        # many = min(M,price_howmany.pop(low_price))
        # price += many * low_price
        # M -= many
    for low_price in price_list:
        many = min(M,price_howmany.pop(low_price))
        price += many * low_price
        M -= many
        if M == 0: break
    print(price)

if __name__ == "__main__":
    solve()
n = int(input())
a = list(map(int,input().split()))
s1 = []
s2 = []
for i in range(n):
  if i % 2 == 0:
    s1.append(a[i])
  else:
    s2.append(a[i])

if n % 2 == 0:
  for x in reversed(s2) + s1:
    print(x, end=' ')
else:
  for x in reversed(s1) + s2:
    print(x, end=' ')
print()

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
s1 = []
s2 = []
for i in range(n):
  if i % 2 == 0:
    s1.append(a[i])
  else:
    s2.append(a[i])

if n % 2 == 0:
  for x in list(reversed(s2)) + s1:
    print(x, end=' ')
else:
  for x in list(reversed(s1)) + s2:
    print(x, end=' ')
print()
c=input()
if c == a :
    print("b")
elif c == b :
    print("c")
elif c == c :
    print("d")
elif c == d :
    print("e")
elif c == e :
    print ("f")
elif c == f :
    print("g")
elif c == g :
    print("h")
elif c == h :
    print("i")
elif c == i :
    print("j")
elif c == j :
    print("k")
elif c == k :
    print("l")
elif c == l :
    print("m")
elif c == m :
    print("n")
elif c == n :
    print("o")
elif c == o :
    print("p")
elif c == p :
    print("q")
elif c == q :
    print("r")
elif c== r :
    print("s")
elif c == s :
    print("t")
elif c == t :
    print("u")
elif c == u :
    print("v")
elif c == v :
    print("w")
elif c == w :
    print("x")
elif c == x :
    print("y")
elif c == y :
    print("z")

### FIXED CODE ###

c=str(input())
if c == 'a' :
    print("b")
elif c == 'b' :
    print("c")
elif c == 'c' :
    print("d")
elif c == 'd' :
    print("e")
elif c == 'e' :
    print ("f")
elif c == 'f' :
    print("g")
elif c == 'g' :
    print("h")
elif c == 'h' :
    print("i")
elif c == 'i' :
    print("j")
elif c == 'j' :
    print("k")
elif c == 'k' :
    print("l")
elif c == 'l' :
    print("m")
elif c == 'm' :
    print("n")
elif c == 'n' :
    print("o")
elif c == 'o' :
    print("p")
elif c == 'p' :
    print("q")
elif c == 'q' :
    print("r")
elif c == 'r' :
    print("s")
elif c == 's' :
    print("t")
elif c == 't' :
    print("u")
elif c == 'u' :
    print("v")
elif c == 'v' :
    print("w")
elif c == 'w' :
    print("x")
elif c == 'x' :
    print("y")
elif c == 'y' :
    print("z")