peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N=int(input())
x=0
y=0
t=0
for i in range(N):
    tt,xx,yy=map(int,input().split())
    if abs(xx-x)+abs(yy-y)<=tt-t:
        if (abs(xx-x)+abs(yy-y))%2!=(tt-t)%2:
            print("No")
            exit()
    else:
        print("No")
        exit()
    t,x,y=tt,xx,yy
print("Yes")
# Judge status: Accepted
x, y = map(int, input().split())
list2 = [4, 6, 9, 11]

if x == 2 or y == 2:
    print('No')
else:
    if x in list2 and y in list2:
        print('Yes')
    else:
        if x not in list2 and y not in list2:
            print('Yes')
        else:
            print('No')
# Judge status: Accepted
n,m = map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for _ in range(m)]
bc.sort(key=lambda x:x[1], reverse=True)

for b,c in bc:
  a.extend([c]*b)
  if len(a) > n*2:
    break

a.sort(reverse=True)
print(sum(a[:n]))
# Judge status: Accepted
n,m=map(int,input().split())
edge=[[] for _ in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    edge[x-1].append(y-1)
    edge[y-1].append(x-1)
for i in edge[0]:
    if n-1 in edge[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
# Judge status: Wrong Answer
s = input()

def dfs( i, sums, s1 ):
    if i == 3:
        if sums == 7:
            print(s1)
            return s1
    else:
        dfs( i + 1, sums + int( s[i+1] ), "{}+{}".format( s1, s[ i  + 1 ] ))
        dfs( i + 1, sums  - int( s[i+1] ), "{} -{}".format( s1, s[ i  + 1 ] ))

dfs(0, int( s[0]), s[0])
# Judge status: Accepted
n = int(input())
s = [int(input()) for _ in range(n)]
score = sum(s)
ans = float('inf')
if score % 10 == 0:
  for i in s:
    if i%10 != 0:
      ans = min(ans, i)
  if ans == float('inf'):
    ans = 0
    score = 0
  score -= ans
print(score)
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, M, Q = mapint()
abcd = [list(mapint()) for _ in range(Q)]

from itertools import combinations_with_replacement

lis = range(1, 11)
ans = 0
for l in combinations_with_replacement(lis, N):
    tmp = 0
    for a, b, c, d in abcd:
        if l[b-1]-l[a-1]==c:
            tmp += d
    ans = max(ans, tmp)

print(ans)
# Judge status: Wrong Answer
import math
N=int(input())
ans=0
for i in range(1,N):
  Y=math.ceil(N/i)
  ans+=(Y*(Y+1)*i)//2
print(ans)
# Judge status: Accepted
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = input()
    y = input()

    if x == y[::-1]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()
# Judge status: Accepted
N, M = map(int, input().split())
H = list(map(int, input().split()))
g = [[] for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  g[a-1].append(b-1); g[b-1].append(a-1)

ans = 0
for i in range(N):
  neighbors = g[i]
  h = H[i]
  res = True
  for node in neighbors:
    res *= h > H[node]
  ans += res

print(ans)
# Judge status: Accepted
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
import math
# mod = 10**9 + 7
#
# n = int(input())
# a = list(map(int, input().split()))
a,b,x = map(float, input().split())

if x >= a * a * b / 2:
    ans = math.atan(2*(b/a - x/(a**3)))

else:
    ans = math.atan(a /2 /x *(b**2))

print(ans*180/math.pi)
# Judge status: Accepted
n,m = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
x = sorted(x)

cost = 0
for i in range(n):
    cost += x[i][0] * min(m, x[i][1])
    m -= x[i][1]
    if m < 1: break

print(cost)
# Judge status: Wrong Answer
n=int(input())
l=[int(x) for x in input().split()]
sum=0
n=len(l)
for i in range(0,n):
    if(i==0):
        sum=sum+(l[i]*2)
    elif(i==n-1):
        sum=sum+l[i]
    else:
        if(l[i]<=l[i+1]):
            sum=sum+l[i]
        else:
            sum=sum+l[i+1]
print(sum)
# Judge status: Accepted
input_num = int(input())

# 取得した Nから必要なキャンディーの個数を算出し出力する
i = 1
result = 0;

while i <= input_num:
    result = result + i
    i = i + 1

print(result)
# Judge status: Accepted
n = int(input())
s = input()
e_count = [0]*(n+1)
w_count = [0]*(n+1)
for i in range(n):
    if s[i] == "E":
        e_count[i+1] = e_count[i] + 1
        w_count[i+1] = w_count[i]
    else:
        w_count[i+1] = w_count[i] + 1
        e_count[i+1] = e_count[i]
#print(w_count)
#print(e_count)
ans = n+1
for i in range(1, n+1):
    res = 0
    res += w_count[i-1]
    res += e_count[n] - e_count[i]
    ans = min(ans, res)
print(ans)
# Judge status: Accepted
n = int(input())
ais = input().split()
ais_int = [int(a) for a in ais]
ais_sort = ais_int.sort()
alice = 0
bob = 0
if n % 2 == 0:
  for i in range(n):
    if i % 2 == 1:
      alice += int(ais_int[i])
    else:
      bob += int(ais_int[i])
else:
  for j in range(n):
    if j % 2 == 0:
      alice += int(ais_int[j])
    else:
      bob += int(ais_int[j])
print(alice - bob)
# Judge status: Wrong Answer
from collections import deque
n,m = map(int,input().split())
hq = []
for _ in range(n):
    a,b = map(int,input().split())
    hq.append((-b,a))
hq.sort(key = lambda x:(x[0],-x[1]))
q = deque(hq)
day = 0
cnt = 0
while day <=m and q:
    b,a = q.popleft()
    b = -b
    if a+day<=m:
        cnt += b
        day += 1
print(cnt)
# Judge status: Wrong Answer
N = int(input())
S = list(input())

r , g, b = S.count("R"), S.count("G"), S.count("B")
ans = r * g * b

for i in range(N-2):
    for j in range(i+1, N-1):
        k = 2*(j+1) - (i+1)
        if k >= N: break
        if S[i] != S[j] and S[j] != S[k-1] and S[k-1] != S[i]:
            ans -= 1
print(ans)
# Judge status: Accepted
import bisect
from collections import defaultdict
n, m = map(int, input().split())
dic = defaultdict(lambda : [])
cities = []
for _ in range(m):
    p, y = map(int, input().split())
    cities.append((p, y))
    dic[p].append(y)
for key, vals in dic.items():
    dic[key] = sorted(vals)
for p, y in cities:
    pos = bisect.bisect_right(dic[p], y)
    print('{:06}{:06}'.format(p, pos))
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

ab = a
cd = c
ab_flag = 0
cd_flag = 0

if abs(a) < abs(b):
    ab = b
    ab_flag = 1

if abs(c) < abs(d):
    cd = d
    cd_flag = 1

ans = ab * cd

if ans < 0:
    if a > 0:
        ans = a * d
    elif c > 0:
        ans = b * c

print(str(ans))
# Judge status: Wrong Answer
N = int(input()) #文字列にするとlen()関数が使用可能
ans = 0
for i in range(1, N+1):
    if len(str(N))%2 == 1:
        ans += 1
print(ans)
# Judge status: Accepted
N, M, X = map(int, input().split())

INF = 30
ans = 1 << INF

data = []
for i in range(N):
    c = list(map(int, input().split()))
    data.append(c)

for i in range(1, 2**N):
    tmp = 0
    skill = [0] * M
    for j in range(N):
        if i >> j & 1:
            tmp += data[j][0]
            for k in range(M):
                skill[k] += data[j][k + 1]
    if min(skill) >= X and tmp < ans:
        ans = tmp

if ans == 1 << INF:
    print('-1')
else:
    print(ans)
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))

ans = 2*10**9
allsum = sum(a)
snukesum = 0

for n in range(1,N):
  snukesum += a[n-1]
  ans_candidate = abs(2*snukesum- allsum)
  if ans > ans_candidate:
    ans = ans_candidate
    
print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a>=13:
    print(b)
elif 6<=a<=12:
    print(b/2)
else:
    print(0)
# Judge status: Accepted
import math
 
R = int(input())
Ans = 2 * R * math.pi
 
print(Ans)
# Judge status: Accepted
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
i=0
count=1
frag=-1
for j in range(n):
  if a[i]==2:
    frag=count
    break
  else:
    i=a[i]-1
    count+=1
print(frag)
# Judge status: Accepted
S = input()
ans = 9999
for i in range(len(S) - 2):
    v = int(S[i:i + 3])
    ans = min(ans, abs(753 - v))
print(ans)
# Judge status: Wrong Answer
a,b,c,x,y=map(int,input().split())
ans=0
if a+b<=c*2:
    print(a*x+b*y)
    exit()
elif x>=y:
    ans+=c*y*2
    x-=y
    if a>=c*2:
        ans+=c*2*x
    else:
        ans+=a*x
elif y>x:
    ans+=c*x*2
    y-=x
    if b>=c*2:
        ans+=c*2*y
    else:
        ans+=b*x
print(ans)
# Judge status: Wrong Answer
# 166 B

n, k = map(int, input().split())
l = []
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    l.append(a)

print(n - (len(set(a))))
# Judge status: Accepted
import math
n = int(input())
coo = [list(map(int,input().split())) for i in range(n)]
sum = 0
for i in range(n):
    for j in range(i,n):
        sum += math.sqrt((coo[i][0]-coo[j][0])**2 + (coo[i][1]-coo[j][1])**2)

ans = 2 * sum / float(n)
print(ans)
# Judge status: Accepted
A, B, C, K = map(int, input().split())

if K % 2 == 0:
    if abs(A-B) > 10**18:
        print("Unfair")
    else:
        print(A-B)
        
else:
    if abs(B-A) > 10**18:
        print("Unfair")
    else:
        print(B-A)
# Judge status: Accepted
#C
a,b,c = map(int,input().split())

if (c-a-b)**2 > 4*a*b and (c-a-b) > 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s = input()
for i in range(len(s)):
    if i % 2 == 1:
        if s[i] not in ['R','U','D']:
            print('No')
            exit()
    else:
        if s[i] not in ['L','U','D']:
            print('No')
            exit()        
print('Yes')
# Judge status: Accepted
import itertools

n,m,x = (int(i) for i in input().split())
A = []
for i in range(n):
    A.append([int(i) for i in input().split()])

ans = float('inf')

for p in itertools.product(range(2), repeat=n):
    knowledges = [0 for _ in range(m)]
    tmp = 0

    for i,a in zip(p,A):
        if i == 0: continue
        tmp += a[0]
        for j,anm in enumerate(a[1:]): knowledges[j] += anm
    
    if all([a >= x for a in knowledges]):
        ans = min(ans, tmp)

if ans == float('inf'):
    print(-1)
else:
    print(ans)
# Judge status: Wrong Answer
L, R = map(int, input().split())
  
if R - L >= 2018:
  print(0)
  exit()
  
lst = []
for i in range(L,R+1):
  lst.append(i%2019)
  
lst.sort()

print(lst[0]*lst[1]%2019)
# Judge status: Accepted
N = int(input())

print(N*(N-1)//2)
# Judge status: Wrong Answer
from collections import deque
S=deque([input()])
q=int(input())
rev=False
for i in range(q):
   s=input()
   if s=="1":
      rev= not rev
   else:
      t,f,c=s.split()
      if (rev==False and f=="1") or (rev==True and f=="2"):
         S.appendleft(c)
      else:
         S.append(c)
if rev==False:
   print("".join(S))
else:
   print("".join(reversed(S)))
# Judge status: Accepted
x, k = map(int, input().split())
if x*500 >= k:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
a = [int(i) for i in input().split()]
K=int(input())
ans = 0
for i in range(K):
  a[-1] = a[-1]**2
print(sum(a))
# Judge status: Accepted
#!/usr/bin/env python3




def main():
    # Failed to predict input format
    n = int(input())
    a = list(map(int, input().split()))

    if all([i%3 == 0 or i%5 == 0 for i in a if i%2 == 0]):
        print('APPROVED')
    else:
        print('DENIED')
    

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
s=input();print('YNeos'[s[:2]!=s[-2:]::2])
# Judge status: Wrong Answer
n = int(input())
T,A = map(int,input().split())
h = list(map(int,input().split()))
#print(h)
l =[]
for i in range(n):
  a = T - h[i]*0.006
 # print(a)
  b = int(abs(a-A))
  l.append(b)
  #print(l)
c = h.index(h[l.index(min(l))])
print(c+1)
# Judge status: Wrong Answer
N,P=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    A[i]%=2

odds=sum(A)
evens=N-odds 
if odds>0:
    ans=2**evens 
    ans+=2**(odds-1)
    print(ans)
else:
    if P==0:
        print(2**evens)
    else:
        print(0)
# Judge status: Wrong Answer
import numpy as np
N,K=map(int,input().split())
listH=list(map(int,input().split()))
cost=np.array([10**5]*N)
cost[0]=0
for i in range(1,N):
  for k in range(1,min(i+1,K+1)):
    cost[i]=min(abs(listH[i-k]-listH[i])+ cost[i-k],cost[i])
ans=cost[-1]      
print(ans)
# Judge status: Accepted
from collections import Counter
input()
angles = sorted(((key, value) for key, value in Counter(map(int, input().split())).items() if value > 1), key=lambda t: t[0])
try:
    square = angles[-1][0] ** 2 if angles[-1][1] > 3 else angles[-1][0] * angles[-2][0]
except:
    square = 0
print(square)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

L = set()
cnt = 0
for a in A:
    c = a//400
    if c >= 8:
        cnt += 1
    else:
        L.add(a//400)

print(len(L),len(L)+cnt)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
print(sum(B)+sum(C[A[i]-1] for i in range(N-1) if A[i]==(A[i+1]-1)))
# Judge status: Wrong Answer
import sys
import collections

n = int(input())
a = collections.Counter(list(map(int, sys.stdin.readline().split())))

q = [0, 0]
for i in a:
    if a[i] >= 4:
        q = [i, i]
    elif a[i] >= 2:
        q[0] = i
        q.sort()

print(q[-1]*q[-2])
# Judge status: Wrong Answer
def factorial(n):
    if n == 1:
        return 1
    else:
        return n * factorial(n-1)

a = int(input())
print(factorial(a))
# Judge status: Accepted
n,m=map(int,input().split())
ans=list(map(int,input().split()))
ans=set(ans[1:])
for i in range(n-1):
    t=list(map(int,input().split()))
    t=set(t[1:])
    ans=ans&t
print(len(ans))
# Judge status: Wrong Answer
def primelist(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]]
  
x = int(input())

list = primelist(x*2)
print(min([i for i in list if i>x]))
# Judge status: Accepted
n = int(input())
l0 = 2
l1 = 1
cnt = 2
l2 = l0 + l1
while cnt < n:
    l2, l1, l0 = l2 + l1, l2, l1
    cnt += 1
if n == 1:
    print(1)
else:
    print(l2)
# Judge status: Accepted
k,s = map(int, input().split())

ans = 0
for right in range(max(s-k, 0), min(s+1, 2*k+1)):
  lower = max(0, right-k)
  upper = min(k, right)
  if right % 2 != 0:
    ans += upper - lower + 1
  else:
    ans += upper - lower + 1
print(ans)
# Judge status: Wrong Answer
import math
def colon(a, b, h, m):
  hour = 0.5 * (h * 60 + m) 
  minute = 6 * m
  angle = abs(hour - minute)
  angle = min(360 - angle, angle)
  rad = angle*0.0174533
  #print(angle, rad)
  ans = math.sqrt(a**2+b**2-(2*a*b*(math.cos(rad))))
  return ans
  

a, b, h, m = map(int, input().split())
print(colon(a,b,h, m))
# Judge status: Accepted
print("Yes" if len(set(input())) == 2 else "No")
# Judge status: Wrong Answer
a = int(input())
b = a % 28

c = b % 7
d = b % 4
if c % 4 ==0:
  print('Yes')
  exit()
elif d % 7 ==0:
  print('Yes')
  exit()
print('No')
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
K=int(input())
i=0
while B<A:
    for i in range(K):
        B*=2
while C<B:
    for j in range(K-i):
        C*=2
if A<B and B<C:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
l , r = map(int,input().split())
lt = l % 2019
rt = r % 2019

if rt - lt <= 0:
    print(0)
else:
    print(min(lt*(lt+1),(2019-rt)*(2020-rt)))
# Judge status: Wrong Answer

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

for i in range(n-1):
    if a[i]+a[i+1]>x:
        a[i+1]=x-a[i]
        
asum=asum-sum(a)
print(asum)
# Judge status: Accepted
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
A = [input() for _ in range(N)]
M = int(input())
B = [input() for _ in range(M)]

cnt_a = Counter(A)
cnt_b = Counter(B)

ans = 0
for k, v in cnt_a.items():
    val = v - cnt_b[k]
    ans = max(ans, val)
print(ans)
# Judge status: Wrong Answer
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
ans = 0
for a in range(n):
    for b in range(a + 1, n):
        if l[a] == l[b]:
            continue
        for c in range(b + 1, n):
            if l[b] == l[c]:
                continue
            if l[a] < l[b] + l[c]:
                ans += 1
print(ans)
# Judge status: Accepted
import numpy as np
N = int(input())
point_arr = np.array(list(map(int, input().split())))

mean = point_arr.mean()
int_mean = int(mean)

print(min(sum((point_arr-int_mean)**2), sum((point_arr-(int_mean+1))**2)))
# Judge status: Accepted
n = str(input())

for i in range(3):
    if n[i] == "7":
        print("Yes")
        break
    elif i == 2:
        print("No")
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
a1 = 0
a2 = 0

c1 = int(sum(l)/n)
c2 = c1 + 1

for i in range(len(l)):
    a1 = a1 + (c1-l[i])**2
    a2 = a2 + (c2-l[i])**2
ans = min(a1,a2)
print(ans)
# Judge status: Accepted
s = input()
ans = ''
for i in s:
  if i == 'B':
    ans = ans[:-1]
  else:
    ans = ans + i
print(ans)
# Judge status: Accepted
from collections import Counter

def solve(n, s):
    c = Counter(s)
    ret, tmp = 0, 0
    d = set()
    for l in s:
        c[l] -= 1
        if c[l] == 0:
            tmp -= 1

        if l not in d:
            tmp += 1
        d.add(l)

        if ret < tmp:
            ret = tmp
    return ret

_n = int(input())
_s = input()
print(solve(_n, _s))
# Judge status: Accepted
Day=["SUN","MON","TUE","WED","THU","FRI","SAT"]
n=input()
for i in range(7):
  if n==Day[i]:
    print(7-i)
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if abs(b-a)==abs(b-c):
    print('YES')
else:
    print('NO')
# Judge status: Accepted
a,b,c=map(int,input().split())
k=int(input())
M=max(a,b,c)
print(a+b+c-M+M*(2**k))
# Judge status: Accepted
a, b, c, x, y = map(int, input().split())
i = a*x+b*y
j = c*min(x, y)*2+a*(x-min(x, y))+b*(y-min(x, y))
k = c*max(x, y)*2
print(min(i, j, k))
# Judge status: Wrong Answer
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

n=int(input())
d=lnii()

mod=998244353

c=Counter(d)
max_key=max(d)

if c[0]!=1:
  print(0)
  exit()

ans=1
patterns=1
for i in range(max_key+1):
  p_num=c[i]
  ans=ans*(patterns**p_num)
  ans%=mod
  patterns=p_num

print(ans)
# Judge status: Wrong Answer
N,Q = map(int,input().split())
S = input()
c = [0]
count = 0
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        count += 1
    c.append(count)
print(c)
for i in range(Q):
    l,r = map(int,input().split())
    print(c[r-1]-c[l-1])
# Judge status: Wrong Answer
x = int(input())

year = 0
money = 100

while money < x:
    year += 1
    money = int(money * 1.01)

print(year)
# Judge status: Accepted
n,m=map(int,input().split())

s=[0]*n
left=[]
right=[]
for i in range(m):
    l,r=map(int,input().split())
    left.append(l)
    right.append(r)
    
if min(right)<max(left):
    print(0)
else:
    print(min(right)-max(left)+1)
# Judge status: Accepted
X , Y = map(int,input().split())

F = False

for i in range(0,X+1):
  J = X - i
  C = 4 * i + 2 * J
  if C == Y:
    F = True
if F: 
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a,b = [int(x) for x in input().split()]
import fractions
g = fractions.gcd(a,b)
ans = 1
mama = int(g ** (1/2))
flag = 0
for i in range(2,mama+2):
    while True:
        if g%i != 0:
            break
        else:
            g = g/i
            flag = 1
    if flag == 1:
        ans += 1
    flag = 0
if g != 1:
    ans += 1
print(ans)
# Judge status: Accepted
#103_B
S=input()
T=input()
flg=False
for i in range(len(S)):
    S=S[-1]+S[:-1]
    if S==T:
        flg=True
print('Yes' if flg else 'No')
# Judge status: Wrong Answer
n = int(input())
l_list = list(map(int, input().split()))
d = [l_list[i+1]-l_list[i] for i in range(n-1)]

flag = False

for i in d:
    if i < -1:
        print("No")
        break
    if i == -1 and flag == True:
        print("No")
        break
    elif i == -1 and flag == False:
        flag = True
else:
    print("Yes")
# Judge status: Accepted
n = int(input())
count=0
for i in range(1,n+1):
  if len(str(i)) % 2 == 1:
    count += 1
print(count)
# Judge status: Accepted
a, b = map(int, input().split())

X = a*b
if X%2 ==1:
    print('Odd')
else:
    print('Even')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

cnt = len([a for a in A if a < 0])
if cnt % 2 == 0:
    print(sum([abs(a) for a in A]))
else:
    ans = sum([abs(a) for a in A])
    M = float('inf')
    for a in A:
        if abs(a) < M:
            M = abs(a)
    print(ans - 2 * M)
# Judge status: Accepted
x, n = map(int, input().split())
p = list(map(int, input().split()))
y = None
if x in p:
    for i in range(102):
        if i in p:
            continue
        if y is None or abs(x - i) < y:
            y = abs(x - i)
            ans = i
else:
    ans = x
print(ans)
# Judge status: Accepted

k,x=map(int,input().split())
s=[str(a)for a in range(x-k+1,x+k)]
s=" ".join(s)
print(s)
# Judge status: Accepted
1.
S = input()

if len(S)==3 and S.count('A')==2 or S.count('B')==2:
    print('Yes')

else:
    print('No')
# Judge status: Wrong Answer
a = int(input())
s = input()

if a >= 3200:
  print(s)
else:
  print("Red")
# Judge status: Accepted
n,k = [int(i) for i in input().split(" ")]
p = [int(i) for i in input().split(" ")]

p.sort()
    
print(sum(p[:k]))
# Judge status: Wrong Answer
N = int(input())
A = map(int, input().split())
limit = 10**18+1

mul = 1
for i in A:
    mul *= i
    if mul >= limit:
        print("-1")
        break

if mul < limit:
    print(mul)
# Judge status: Wrong Answer
A = [list(map(int,input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
for i in range(N):
    for h in range(3):
        for w in range(3):
            if b[i] == A[h][w]:
                A[h][w] = 0
if [0,0,0] in A:
    print('Yes')
else:
    ans = 'No'
    for i in zip(*A):
        if i == (0,0,0):
            ans = 'Yes'
            break
    print(ans)
# Judge status: Accepted
def main():
    n,m = map(int, input().split())
    lim = 10 ** n
    val = [list(map(int, input().split())) for _ in range(m)]
    for i in range(10**(n-1) if n >= 2 else 0, lim):
        for j, k in val:
            j = j - 1
            l = str(i)
            if l[j] != str(k):
                break
        else:
             print(i)
             exit()
    print(-1)

if __name__ == '__main__':
    main()
# Judge status: Accepted
week = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
week.reverse()
print(week.index(input())+1)
# Judge status: Wrong Answer
l,r=map(int,input().split())

mod=2019
sa=r-l
ans=float('inf')
if 2019<=sa:
  print(0)
else:
  for i in range(l,r+1):
    for j in range(l,r+1):
      if i<j:
        ans=min((i%mod)*(j%mod),ans)
  print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
if a==b==5 and c==7 :
    print('YES')
elif   a==c==5 and b== 7:
    print('YES')
elif   b==c==5 and a==7:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
import heapq as hq
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
a.sort()
for i in range(n):
    a[i][1]*=-1
b=[]
hq.heapify(b)
ans,i=0,0
for k in range(m-1,-1,-1):
    while i<n and a[i][0]+k<=m:
        hq.heappush(b,a[i][1])
        i+=1
    if b:
        ans-=hq.heappop(b)
print(ans)
# Judge status: Wrong Answer
k, s = map(int,input().split(' '))
count = 0
for x in range(k+1):
    for y in range(k+1):
        if (s - (x+y)) <= k:
            count += 1

print(count)
# Judge status: Accepted
s = int(input())

l = [s]
N = s
count = 1

while 1:
  count += 1
  if N % 2 == 0:
    N = N // 2
  else:
    N = 3 * N + 1
    
  if N in l:
    print(count)
    break
  else:
    l.append(N)
# Judge status: Accepted
N = input()
if N[1] == N[2]:
    if N[0] == N[1] or N[2] == N[3]:
        print("Yes")
    else:
        print("No")
else:
    print("No")