Harryxun/stf_run huggingface dataset:
# -*- coding:utf-8 -*-


if __name__ == "__main__":
    # input
    a = raw_input()
    b = raw_input()
    c = raw_input()

    a_index = 0
    b_index = 0
    c_index = 0

    next_user = a[a_index]
    a_index += 1

    while(True):
        if next_user == 'a':
            next_user = a[a_index]
            a_index = a_index + 1
            if len(a) == a_index:
                print 'A'
                break
        elif next_user == 'b':
            next_user = b[b_index]
            b_index = b_index + 1
            if len(b) == b_index:
                print 'B'
                break

        else:
            next_user = c[c_index]
            c_index = c_index + 1
            if len(c) == c_index:
                print 'C'
                break


### FIXED CODE ###

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


# input
a = list(raw_input())
b = list(raw_input())
c = list(raw_input())

user = 'a'
while(True):
    if user == 'a':
        if len(a) == 0:
            print 'A'
            break
        user = a.pop(0)

    if user == 'b':
        if len(b) == 0:
            print 'B'
            break
        user = b.pop(0)

    if user == 'c':
        if len(c) == 0:
            print 'C'
            break
        user = c.pop(0)
import sys 
import numpy as np

N = int(sys.stdin.readline())
P = np.array([int(x) for x in sys.stdin.readline().split()])

SUM = np.sum([np.sum([min(P[l:r+1]) for r in range(l, N)]) for l in range(N)])

print(SUM)  

### FIXED CODE ###

line = input()

ori = len(line)

count = 0 

T = 0 
S = 0 

for i in line:
    if i is "S":
        S += 1
    else:
        if S is not 0:
            S -= 1
            count += 1

print(ori - count * 2)
N, M= (int(i) for i in input().split())
lst = [[int(i) for i in input().split()] for i in range(n)]

### FIXED CODE ###

N, M= (int(i) for i in input().split())
lst = [[int(i) for i in input().split()] for i in range(N)]
import numpy as np
food = np.zeros((N,M))
for i in range(N):
    for j in range(lst[i][0]):
        #print(lst[i][j+1])
        food[i][lst[i][j+1]-1] = 1
#print(food)
s = np.sum(food, axis=0)
print(len(s[s==N]))
n = int(input())
a = int(input())

ans = 'No'
for i in range(a+1):
    if (n-i)%500 == 0:
        ans = 'Yes'
        break
print(ans)


### FIXED CODE ###

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

p_a = sum(sorted(a, reverse = True)[::2])
p_b = sum(a) - p_a
print(p_a - p_b)
a, b = map(int, input().split())
l = []
c = a +b
d = a -b
e = a *b
l.append(c)
l.append(d)
l.append(e)
print(max(l[c, d, e]))

### FIXED CODE ###

a, b = map(int, input().split())
l = []
c = a +b
d = a -b
e = a *b
l.append(c)
l.append(d)
l.append(e)
print(max(l))
a,b = map(int,input().split())

p = [["."]*50 for _ in range(20)]
q = [["#"]*50 for _ in range(21)]

for t in range(b-1):
  p[t//25*2][t%25*2] = "#"
for t in range(a-1):
  q[t//25*2+1][t%25*2] = "."
for l in p:
  print(" ".join(l))

### FIXED CODE ###

a,b = map(int,input().split())

p = [["."]*100 for _ in range(20)]
q = [["#"]*100 for _ in range(21)]

for t in range(b-1):
  p[t//50*2][t%50*2] = "#"
for t in range(a-1):
  q[t//50*2+1][t%50*2] = "."
  
print(41, 100)
for l in p+q:
  print("".join(l))
'''
Problem Link - https://atcoder.jp/contests/abc176/tasks/abc176_c
'''
from sys import stdin,stdout
from math import *
from collections import *

mod = 1000000007

def gcd(a,b):
	while b:
		a,b = b,a%b
	return a

def lcm(a,b): return (a*b) // gcd(a,b)

def set_bits(X):
	c = 0
	while X:
		X &= (X-1);c += 1
	return c

def compute_MOD(N,M): return (N%M + M) % M

def get_array(): return list(map(int, stdin.readline().split()))
 
def get_ints(): return map(int, stdin.readline().split())

def get_int(): return int(stdin.readline())

def get_input(): return stdin.readline().strip()

def main():
    tc = get_int()
    # while(tc):
	arr = get_array()
	ans = 0
	Max = arr[0]
	for i in arr[1:]:
		Max = max(Max,i)
		ans += Max-i
	stdout.write(str(ans)+'\n')
    	# tc-=1

if __name__ == "__main__":
    main()

### FIXED CODE ###

'''
Problem Link - https://atcoder.jp/contests/abc176/tasks/abc176_c
'''
from sys import stdin,stdout
from math import *
from collections import *

mod = 1000000007

def gcd(a,b):
	while b:
		a,b = b,a%b
	return a

def lcm(a,b): return (a*b) // gcd(a,b)

def set_bits(X):
	c = 0
	while X:
		X &= (X-1);c += 1
	return c

def compute_MOD(N,M): return (N%M + M) % M

def get_array(): return list(map(int, stdin.readline().split()))
 
def get_ints(): return map(int, stdin.readline().split())

def get_int(): return int(stdin.readline())

def get_input(): return stdin.readline().strip()

def main():
    tc = get_int()
    arr = get_array()
    ans = 0
    Max = arr[0]
    for i in arr[1:]:
    	Max = max(Max,i)
    	ans += Max-i
    stdout.write(str(ans)+'\n')
if __name__ == "__main__":
    main()
from collections import deque
k = int(input())

digsum = lambda x: sum(list(map(int, list(str(x)))))

que = deque([])
MAX = 800000
min_v = MAX
for i in range(MAX-1, 0, -1):
    v = i/digsum(i)
    if v <= min_v:
        que.append(i)
        # print(i, v)
        min_v = v
        
while k > 0:
    print(que.pop())
    k -= 1


### FIXED CODE ###

# almost the copy of answer #2730510 

def S(n):
    return sum(list(map(int, str(n))))

def norm(n):
    return n/S(n)

k = int(input())
j = 1
order = 1
for i in range(k):
    print(j)
    if norm(j+10**(order-1)) > norm(j+10**(order)):
        order += 1
    j += 10**(order-1)
While True:
    array = input().split(" ")
    a = int(array[0])
    op = array[1]
    b = int(input())

    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/"
        print(a / /b)
    

### FIXED CODE ###

while True:
    a, op, b = input().split(" ")
    if op == "?":
        break
    elif op == "+":
        print( int(a) + int(b) )
    elif op == "-":
        print( int(a) - int(b) )
    elif op == "*":
        print( int(a) * int(b) )
    elif op == "/":
        print( int(a) // int(b) )
lis = [input() for _ in range(3)]
len = [len(lis[i]) for i in range(3)]
idx = [0,0,0]
name = ['a','b','c']

turn = 0
while 1:
  if len[turn] <= idx[turn]:
    print(name(turn))
    exit()
  else:
    tmp = ord(lis[turn][idx[turn]])-ord('a')
    idx[turn] += 1
    turn = tmp


### FIXED CODE ###

lis = [input() for _ in range(3)]
len = [len(lis[i]) for i in range(3)]
idx = [0,0,0]
name = ['A','B','C']

turn = 0
while 1:
  if len[turn] <= idx[turn]:
    print(name[turn])
    exit()
  else:
    tmp = ord(lis[turn][idx[turn]])-ord('a')
    idx[turn] += 1
    turn = tmp
a,b,c = map(int,input().split())
L = a**2*b
l = L/2
# print(L,l)
# if l:
#     print(0)
#     exit()
if L  == c:
    print(0)
    exit()
if c <= l:
    t = 2*c/(a*b)
    T = t/b
    # print(t,T)
    atan1 = math.degrees(math.atan(T))
    print(90-atan1)
else:
    x = 2*c/a**2 - b
    t = a/(b-x)
    atan1 = math.degrees(math.atan(t))
    print(90-atan1)

### FIXED CODE ###

import math
a,b,c = map(int,input().split())
L = a**2*b
l = L/2
# print(L,l)
# if l:
#     print(0)
#     exit()
if c <= l:
    t = 2*c/(a*b)
    T = t/b
    # print(t,T)
    atan1 = math.degrees(math.atan(T))
    print(90-atan1)
elif L == c:
    print(0)
else:
    x = 2*c/a**2 - b
    t = a/(b-x)
    atan1 = math.degrees(math.atan(t))
    print(90-atan1)
from math import ceil
a, b = map(float, input().split(' '))
return ceil(a + b / 2)

### FIXED CODE ###

from math import ceil

a, b = map(float, input().split())
print(ceil((a + b) / 2))
if N%1000==0:
  print(0)
else:
  N=math.ceil(N/1000)*1000-N
  print(N)
  

### FIXED CODE ###

n = int(input())

if n % 1000 == 0:
  print(0)
else:
  print(1000-(n%1000))
n = int(input())
a = [int(i) for i in input().split()]
print(" ".join(a))

for i in range(len(a)-1):
    v = a[i]
    j = i 

    while j >= 0 and a[j]>v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v
    print(" ".join(a))

### FIXED CODE ###

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

for i in range(len(a)):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j]>v:
        a[j+1] = a[j]
        j-=1
    a[j+1]=v
    print(" ".join([str(i) for i in a]))
import statistics

def Medi(Arra, Haba):
    re = []
    for i_M in range(len(Arra) - Haba + 1):
        re.append(statistics.median_high(Arra[i_M: i_M+Haba]))
    return re

N = int(input())
A = list(map(int, input().split()))
print(A)
ans = []

if N == 1:
    ans.append(A[0])
else:
    kuri = max(N//2, 10)
    for i in range(1, N+1):
        ans += Medi(A, i)
        so = ans
        so.sort()
        print(so)


print(statistics.median_high(ans))

### FIXED CODE ###

# S = input()
# N = int(input())
N, K = map(int, input().split())
X = list(map(int, input().split()))
# LR = [list(map(int, input().split())) for _ in range(M)]

ans = 10000000000

if K == 1:
    for i in range(N):
        if ans > abs(X[i]):
            ans = abs(X[i])
else:
    for i in range(N - K+1):
        left = X[i]
        right = X[i + K - 1]
        sum = 0

        if abs(left) <= abs(right):
            sum += abs(left)
        else:
            sum += abs(right)

        sum += abs(left - right)

        if ans > sum:
            ans = sum

print(ans)
# -*- coding: utf-8 -*-
def solve():
    N, M = map(int, input().split())
    if M%2:
        return '-1'
    E = [set() for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, input().split())
        E[a].add(b)
        E[b].add(a)
    q = [(0,1,1)]
    v = set()
    T = [set() for _ in range(N+1)]
    L = []
    V = []
    while q:
        n_, n, d = q.pop()
        if n not in v:
            T[n].add(n_)
            T[n_].add(n)
            v.add(n)
            V.append((d,n))
            if E[n]-v:
                q.extend([(n,u, d+1) for u in E[n]-v])
            else:
                L.append(n)

    A = [0 for _ in range(N+1)]
    res = []
    c = set()
    for d, n in sorted(V, reverse=1):
        c.add(n)
        if (A[n]+len(E[n]))%2:
            res.extend([(u,n) for u in E[n]-c])
            for u in E[n]-c:
                A[u] += 1
                E[u] -= {n}
        else:
            res.extend([(n,u) for u in E[n]-c])
            for u in E[n]-c:
                A[n] += 1
                E[u] -= {n}
    if any(a%2 for a in A):
        return '-1'
    else:
        return '\n'.join(['{} {}'.format(*e,) for e in res])


if __name__ == '__main__':
    print(solve())

### FIXED CODE ###

# -*- coding: utf-8 -*-
def solve():
    N, M = map(int, input().split())
    if M%2:
        return '-1'
    E = [set() for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, input().split())
        E[a].add(b)
        E[b].add(a)
    q = [(0,1,1)]
    v = set()
    T = []
    while q:
        n_, n, d = q.pop()
        if n not in v:
            T.append((d,n_,n))
            E[n].discard(n_)
            E[n_].discard(n)
            v.add(n)
            if E[n]-v:
                q.extend([(n,u, d+1) for u in E[n]-v])

    A = [0 for _ in range(N+1)]
    res = []
    c = set()
    for d,a,b in sorted(T, reverse=1)[:-1]:
        F = E[b]-c
        if A[b]%2 == 0 or len(E[b])%2:
            res.extend([(u,b) for u in F])
            for u in F:
                A[u] += 1
                E[u] -= {b}
        else:
            res.extend([(b,u) for u in F])
            for u in F:
                A[b] += 1
                E[u] -= {b}

        E[a] -= {b}
        if A[b]%2:
            A[b] += 1
            res.extend([(b,a)]) 
        else:
            A[a] += 1
            res.extend([(a,b)])

    return '\n'.join(['{} {}'.format(*e) for e in res])


if __name__ == '__main__':
    print(solve())
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

m = {}
m[1] = 2
m[2] = 5
m[3] = 5
m[4] = 4
m[5] = 5
m[6] = 6
m[7] = 3
m[8] = 7
m[9] = 6


N, M = map(int, input().split())
t = list(map(int, input().split()))
if 3 in t and 2 in t:
    t.remove(2)
if 3 in t and 5 in t:
    t.remove(3)
if 2 in t and 5 in t:
    t.remove(2)
if 6 in t and 9 in t:
    t.remove(6)
A = sorted(t, reverse=True)

matches = [m[v] for v in A]
matches = sorted(matches)
mi = 100
mi_num = 0
for a in A:
    if m[a] < mi:
        mi = m[a]
        mi_num = a
matches.remove(mi)
A.remove(mi_num)

nums = N//mi
r = N - nums*mi

Q = []
Q.append(['', r])
while Q:
    add, r = Q.pop(0)
    #print("add->", add, r)
    if r < 0:
        continue
    elif r == 0:
        cand = []
        for c in add:
            cand.append(int(c))
        cand.append(mi_num)
        cand = sorted(cand, reverse=True)
        l = len(cand)-1
        ans = ''
        for c in cand:
            if c == mi_num:
                ans += str(mi_num)*(nums-l)
            else:
                ans += str(c)
        print(ans)
        exit()
    else:
        r += mi
        for a in A:
            Q.append([add+str(a), r-m[a]])
print(1/0)


### FIXED CODE ###

# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)

nums = {}
nums[1] = 2
nums[2] = 5
nums[3] = 5
nums[4] = 4
nums[5] = 5
nums[6] = 6
nums[7] = 3
nums[8] = 7
nums[9] = 6

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

for i in range(N+1):
    for a in A:
        if i-nums[a] >= 0:
            dp[i] = max(dp[i], dp[i-nums[a]]+1)

ans = ""
i = N
while i > 0:
    for a in A:
        if i >= nums[a] and dp[i]-1 == dp[i-nums[a]]:
            ans += str(a)
            i = i-nums[a]
            break
print(ans)
N, K = map(int, input().split())
A = list(map(int, input().split()))

K = min(K, 100)
for i in range(K):
    B = [0 for _ in range(A)]
    for i in range(N):
        l = max(0, i - A[i])
        r = min(N - 1, i + A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
    
    for i in range(1, N):
        B[i] += B[i-1]
    
    A = B.copy()

print(" ".join(map(str, A)))

### FIXED CODE ###

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

for _ in range(K):
    B = [0] * N
    for i, d in enumerate(A):
        l = max(0, i-d)
        r = min(N-1, i+d)
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
    
    for i in range(1, N):
        B[i] += B[i-1]
    
    A = B.copy()
    if min(A) == N:
        break

print(" ".join(map(str, A)))
a = map(int, input().split()
flag5=0
flag7=0

for i in range(len(a)):
    if a[i] = 5:
        flag5 += 1
    elif a[i] = 7:
        flag7 += 1
    else:
        flag5 = 0
        break
if flag5=2 and flag7=1:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

a = list(map(int, input().split()))
#a = [5,7,5]
a.sort()
if a==[5,5,7]:
        print('YES')
else:
    print('NO')
def linked_merge_sort(l): #マージソート
    if len(l) == 1:
        return
    q, r = divmod(len(l), 2)
    left = [l.pop() for _ in range(q)]
    right = [l.pop() for _ in range(q + r)]
    
    linked_merge_sort(left)
    linked_merge_sort(right)
    
    left.reverse()
    right.reverse()
    while left and right:
        if left[-1] <= right[-1]:
            l.append(left.pop())
        else:
            l.append(right.pop())
    while left:
        l.append(left.pop())
    while right:
        l.append(right.pop())
    return

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

for i in range(n):
    p[i]=p[i]-x
if n>1:
    linked_merge_sort(p)
    j=n-1
    for i in range(n):
        if p[i]>=0:
            j=i
            break
    for i in range(50):
        if j-i>=0:
            if p[j-i]!=-i:
                ans = x-i
                break
        elif j-i<0:
            ans=x+p[0]-1
            break
        if j+i<n:
            if p[j+i]!=i:
                ans = x+i
                break
        else:
            ans=x+p[n-1]+1
            break
elif n==1:
    if p[0]==0:
        ans=x-1
    else:
        ans=x
elif n==0:
    ans=x
print(ans)


### FIXED CODE ###

def linked_merge_sort(l): #マージソート
    if len(l) == 1:
        return
    q, r = divmod(len(l), 2)
    left = [l.pop() for _ in range(q)]
    right = [l.pop() for _ in range(q + r)]
    
    linked_merge_sort(left)
    linked_merge_sort(right)
    
    left.reverse()
    right.reverse()
    while left and right:
        if left[-1] <= right[-1]:
            l.append(left.pop())
        else:
            l.append(right.pop())
    while left:
        l.append(left.pop())
    while right:
        l.append(right.pop())
    return

x,n=map(int,input().split())
p=list(map(int,input().split()))
if x>50:
    ans = 101
else:
    ans = 0
for i in range(n):
    p[i]=p[i]-x
if n>1:
    linked_merge_sort(p)
    j=n-1
    for i in range(n):
        if p[i]>=0:
            j=i
            break
    for i in range(n):
        if j-i>=0:
            if p[j-i]!=-i:
                ans = x-i
                break
        elif j-i<0:
            ans=x+p[0]-1
            break
        if j+i<n:
            if p[j+i]!=i:
                ans = x+i
                break
        else:
            ans=x+p[n-1]+1
            break
elif n==1:
    if p[0]==0:
        ans=x-1
    else:
        ans=x
elif n==0:
    ans=x
print(ans)
N = int(input())
scores = []
cnt = 0
for i in range(N):
    scores.append(int(input()))

scores.sort()
gokei = sum(scores)

while True:
    if gokei % 10 == 0:
        gokei -= scores[cnt]
        cnt += 1
        if cnt < len(scores):
            print(0)
            break
    else:
        print(gokei)
        break

### FIXED CODE ###

import sys

N = int(input())
scores = []
box = []
cnt = 0
for i in range(N):
    scores.append(int(input()))

scores.sort()
gokei = sum(scores)

if gokei % 10 == 0:
    for i in range(N):
        aaa = gokei - scores[i]
        if aaa % 10 != 0:
            box.append(aaa)

else:
    print(gokei)
    sys.exit()
    
if box != []:
    print(max(box))
else:
    print(0)
n,a, b = map(int, input().split())
l = []
for i in range(10 ^100):
    l.extend([1]*a)
    l.extend([0]*b)

print(sum(l[:n]))

### FIXED CODE ###

S = input()

if S == "AAA" or S == "BBB":
    print("No")
else:
    print("Yes")
N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))


def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

list1=[0]
L=0
for a in A:
    L=gcd(L,a)
    list1.append(L)

list2=[0]
R=0
for a in reversed(A):
    R=gcd(R,a)
    list2.append(R)

list2.reverse()

ans=[]

for i in range(N+1):
    ans.append(gcd(list1[i],list2[i+1]))

print(max(ans))





### FIXED CODE ###

N = int(input())
# スペース区切りの整数の入力
A = list(map(int, input().split()))


def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

list1=[0]
L=0
for a in A:
    L=gcd(L,a)
    list1.append(L)

list2=[0]
R=0
for a in reversed(A):
    R=gcd(R,a)
    list2.append(R)

list2.reverse()

ans=[]

for i in range(N):
    ans.append(gcd(list1[i],list2[i+1]))

print(max(ans))
from collections import Counter
N, K = map(int, input().split())
A = list(map(int ,input().split()))

d = Counter(A)
d.most_common()
n =len(d_)
ans = 0
if n <= K:
    print(0)
    exit()
else:
    for i in range(K,n):
        ans += d[i][1]
print(ans)

### FIXED CODE ###

from collections import defaultdict
N, K = map(int, input().split())
A = list(map(int ,input().split()))

d = defaultdict(int)
for i in A:
    d[i] += 1

d_ = sorted(d.items(), key=lambda x:x[1], reverse=True)
n =len(d_)
ans = 0
if n <= K:
    print(0)
    exit()
else:
    for i in range(K,n):
        ans += d_[i][1]
print(ans)
n=int(input())
x,y=[int(input()) for _ in range(int(input()))],[int(input()) for _ in range(int(input()))]
d=0
for i,j in zip(x,y):
  for k,l in zip(x,y):
    m=(i-k)**2+(j-l)**2
    d+=m**0.5
print(d/n)

### FIXED CODE ###

n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int, input().split())
d=0
for i,j in zip(x,y):
  for k,l in zip(x,y):
    m1,m2=i-k,j-l
    o=m1**2+m2**2
    d+=o**0.5
print(d/n)
n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
for i in range(n):
    start=i
    cycle=[0]
    for _ in range(n):
        i=p[i]
        cycle+=[cycle[-1]+c[i]]
        if i==start:break
    S,L=cycle[-1],len(cycle)-1
    if S<=0:ans=max(ans,max(cycle[1:k+1]))
    else:
        if k>L:ans=max(ans,(k//L-1)*S+max(max(cycle),max(cycle[:k%L+1])+S)) 
        else:ans=max(ans,cycle[:min(k+1,L)])
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
p=[int(i)-1for i in input().split()]
c=list(map(int,input().split()))
ans=-10**9
for i in range(n):
    start=i
    cycle=[0]
    for _ in range(n):
        i=p[i]
        cycle+=[cycle[-1]+c[i]]
        if i==start:break
    S,L=cycle[-1],len(cycle)-1
    if S<=0:ans=max(ans,max(cycle[1:k+1]))
    else:
        if k>L:ans=max(ans,(k//L-1)*S+max(max(cycle),max(cycle[:k%L+1])+S)) 
        else:ans=max(ans,max(cycle[:k+1]))
print(ans)
a=input()
b=input()
s=""
for i in range(min(len(b))):
	s+=a[i]+b[i]
if len(a)!=len(b):
	s+=a[-1]
print(s)

### FIXED CODE ###

a=input()
b=input()
s=""
for i in range(len(b)):
	s+=a[i]+b[i]
if len(a)!=len(b):
	s+=a[-1]
print(s)
a, b = map(int, input().split())
pos = 0
length = 0
tree=[]

def position(b,i,pos,posA, posB):
    print(posA, posB)
    if(posA == posB):
        for j in range(b-1-i):
            neia, neib = (tree[j+1]-tree[j], tree[b-i-1-j]-tree[b-i-2-j])
            print(neia, neib)
            if(neia > neib):
                posB = 0
                break
            elif(neib > neia):
                posA = 0
                break
    target = max(posA, posB)
    print(posA, posB)
    if(posA == target):
        pos = tree[0]
        del tree[0]
    else:
        pos = tree[b-i-1]
        del tree[b-i-1]
    return (pos, target)

for i in range(b):
    tree.append(int(input()))
for i in range(b):
    print(tree)
    if(pos > tree[b-i-1]):
        pos, target = position(b,i,pos,abs(tree[0]+a-pos),abs(tree[b-i-1]-pos))
    else:
        pos, target = position(b,i,pos,abs(tree[0]-pos),a-abs(tree[b-i-1]-pos))
    length += target
    print(i+1, "----", pos, target, length) 
print(length)

### FIXED CODE ###

L, N = map(int, input().split())
X=[0]
sumL=[0]
sumR=[0]
for i in range(N):
    X.append(int(input()))
    sumL.append(sumL[-1]+X[-1])
for i in range(N):
    sumR.append(sumR[-1]+L-X[N-i])
sumR.append(0)
sumR.reverse()
#print(X)
#print("sumL",sumL)
#print("sumR",sumR)
ans = 0
for b in range(N+1):
    z = sumL[b] + sumR[b+1]
    if(b > 0):
        if(b <= N-b):
            ans = max(ans, z+sumL[b-1]+sumR[b+1]-2*sumR[N+1-(N-b-b)])
            #print("A", b, z+sumL[b-1]+sumR[b+1]-2*sumR[N+1-(N-b-b)])
        else:
            ans = max(ans, z+sumL[b-1]+sumR[b+1]-2*sumL[b-(N-b)-1])
            #print("B", b, z+sumL[b-1]+sumR[b+1]-2*sumL[b-(N-b)-1])
    if(b < N):
        if(b >= N-b):
            ans = max(ans, z+sumL[b]+sumR[b+2]-2*sumL[b-(N-b)])
            #print("C", b, z+sumL[b]+sumR[b+2]-2*sumL[b-(N-b)])
            #print(b, z, sumR[b+1], sumL[b], sumR[b+2], sumL[b-(N-b)])
        else:
            ans = max(ans, z+sumL[b]+sumR[b+2]-2*sumR[N+1-(N-b-b)+1])
            #print("D", b, z+sumL[b]+sumR[b+2]-2*sumR[N+1-(N-b-b)+1])
    #print("------------------------")
print(ans)
import math

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

if a*a*b < 2*x:
    print(90-math.degrees(math.atan(a**3/(2*(a*a*b-x)))))
else:
    print(90-math.degrees(math.atan(2*x/(a*b*b))))



### FIXED CODE ###

import math
a,b,x=map(int,input().split())
if a*a*b<=2*x:
    c=(b-x/(a**2))*2/a
    ans=math.degrees(math.atan(c))
else:
    c=a*b*b/(2*x)
    ans=math.degrees(math.atan(c))
print(ans)
x,y = map(int,input().split())
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]
print('Yes') if (x and y) in g1 or (x and y) in g2 or (x and y) in g3 print('No')

### FIXED CODE ###

x,y = map(int,input().split())
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]
print('Yes') if (x in g1 and y in g1) or (x in g2 and y in g2) or (x in g3 and y in g3) else print('No')