peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())

if a < 0 and b < 0 :
    print(b*c)
elif a < 0 and b >=0:
    if c < 0 and d < 0:
        print(a*c)
    elif c < 0 and d >=0:
        if a * c < b * d :
            print(b*d)
        else :
            print(a*c)
    else :
        print(b*d)
elif a>=0 and b >=0:
    if c < 0 and d < 0:
        print(a*d)
    else :
        print(b*d)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

arr=[a[i]-i-1 for i in range(n)]

if len(arr)%2==0:
  tmp=[arr[len(arr)//2-1],arr[len(arr)//2]]
else:
  tmp=[arr[len(arr)//2]]

ans=10**20
for b in tmp:
  ans=min(ans,sum([abs(a[i]-b-i-1) for i in range(n)]))
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
n, a, b, c, d = map(int, input().split())
s = input()
if c < d:
    print("YNeos"[any(s[i:i + 2] == "##" for i in range(a, d - 1))::2])
else:
    if any(s[i:i + 3] == "..." for i in range(b - 2, d - 1)):
        if all(s[i:+2] != "##" for i in range(a, c - 1)):
            print("Yes")
            exit()
    print("No")
# Judge status: Accepted

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

t = 1
for x in a:
    if x == t:
        t += 1
t -= 1

if t == 0:
    print(-1)
else:
    print(N-t)
# Judge status: Accepted
import sys

N = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

tmp = {v: k+1 for k, v in enumerate(A)}
ans = []
for v, k in sorted(tmp.items(), key=lambda x: x[0]):
    ans.append(k)

print(*ans)
# Judge status: Accepted
N = int(input())
ans=N%10
if ans == 3:
    print('bon')
elif ans in [0, 1, 6, 8]:
    print('pon')
else:
    print('hon')
# Judge status: Accepted
import sys
import itertools
import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    x, y, a, b, c = map(int, readline().split())
    p = sorted(map(int, readline().split()), reverse=True)
    q = sorted(map(int, readline().split()), reverse=True)
    r = sorted(map(int, readline().split()), reverse=True)

    z = sorted(p[:x] + q[:y] + r, reverse=True)
    ans = sum(z[:x+y])
    print(ans)

if __name__ == "__main__":
    main()
    pass
# Judge status: Wrong Answer
def main():
    n,m=map(int,input().split())
    x = n*m
    if n < 2 or m < 2: # 4隅
        x -= 2
    else:
        x -= (2*m + 2*n)-4
    print(x)

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a, b, x = map(int, input().split())

if a+b>=x:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
s = list(input())
white = 0
black = 0
for i in range(n):
    if s[i] == '.':
        white+=1

ans = white
for i in range(n):
    if s[i] == '.':
        white -= 1
    else:
        black += 1
    ans = min(ans, white + black)
print(ans)
# Judge status: Wrong Answer
A,B,K=map(int,input().split())

if A>=K:
  A=A-K
else:
  B=A+B-K
  A=0

print('{} {}'.format(A,B))
# Judge status: Accepted
N=int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
n = N-2
i = 1
ans = a[0]
while n > 0:
    if n > 1:
        ans += a[i]*2
        i += 1
        n -= 2
    elif n == 1:
        ans += a[i]
        i += 1
        n -= 1
    else:
        pass
print(ans)
# Judge status: Wrong Answer
N, K, S = map(int, input().split())
ans = [S] * N

if S < 10e9:
    for i in range(K):
        ans[i] = S+1
else:
    for i in range(K):
        ans[i] = 1

print(" ".join([str(x) for x in ans]))
# Judge status: Accepted
from fractions import gcd
def GCD(a):
    x = a[0]
    for i in range(1, len(a)):
        x = gcd(x, a[i])
    return x
n = int(input())
a = list(map(int, input().split()))
print(GCD(a))
# Judge status: Wrong Answer
import math
a,b,x=map(int, input().split())
A=math.ceil(a/x)
B=math.floor(b/x)
if A>B:
  print(0)
else:
  print(B-A+1)
# Judge status: Accepted
w,h,n=map(int,input().split())
b=c=0
for _ in range(n):
    x,y,a=map(int,input().split())
    if a==1:b=max(b,x)
    if a==2:w=min(w,x)
    if a==3:c=max(c,y)
    if a==4:h=min(h,y)
print(max(0,(w-b))*max(0,(h-c)))
# Judge status: Accepted
S= input()

f=int(S[0]+S[1])
r=int(S[2]+S[3])

if f>=1 and f<=12 and r>=1 and r<=12:
  print('AMBIGUOUS')
elif (r>=1 and r<=12):
  print('YYMM')
elif (f>=1 and f<=12):
  print('MMYY')
else:
  print('NA')
# Judge status: Accepted
s,a=input().split()
ss=int(s)
aa=int(a)
c=0 
while ss>0:
    c=c+1
    ss=ss-aa
print(c)
# Judge status: Wrong Answer
d,n=map(int,input().split())
print(100**d*n)
# Judge status: Accepted
n,m=map(int,input().split())
a=list(map(int,input().split()))

sumv=sum(a)
cnt=0
for i in a:
  if i>=sumv/(4*m):
    cnt+=1
print('Yes' if cnt>=m else 'No')
# Judge status: Accepted
f=lambda:map(int,input().split())
n,m=f()
g=[[] for _ in range(n)]
for _ in range(m):
  a,b=f()
  g[a-1]+=[b-1]
  g[b-1]+=[a-1]
p=[0]*n
from collections import*
q=deque([0])
while q:
  v=q.popleft()
  for c in g[v]:
    if p[c]<1: p[c]=v+1; q.append(c)
if 0 in p: print('No')
else: print('Yes',*p[1:],sep='\n')
# Judge status: Accepted
o=input()
e=input()
ans=[]
for i in range(len(o)):
    ans.append(o[i])
    if i < len(e):
        ans.append(e[i])
print(''.join(ans))
# Judge status: Wrong Answer
N, K = map(int, input().split())
A_list = list(map(int, input().split()))

for i in range(K, N):
  if A_list[i - K] <= A_list[i]:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
S=list(input().split())
ans=''
for s in S:
    ans+=s[0:1]
print(ans)
# Judge status: Accepted
l = float(input())
print((l/3)**3)
# Judge status: Accepted
h=int(input())
w=int(input())
n=int(input())
if w>=h:
    re=int(n/w)
    if n%w>0:
        re+=1
else:
    re=int(n/h)
    if n%h>0:
        re+=1
print(re)
# Judge status: Accepted
x = int(input())

for i in range(8, 0, -1):
    j = 8 - i
    num = 400 + 200 * j
    if num <= x < num + 200:
        print(i)
        exit()
# Judge status: Accepted
S = input()
T = input()

ok = True

RS = {}
RT = {}

for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s in RS:
        if RS[s] != t:
            ok = False
    if t in RT:
        if RT[t] != s:
            ok = False
    RS[s] = t
    RT[t] = s
if ok:
    print('Yes')
else:
    print("No")
# Judge status: Wrong Answer
INF = 10**6

N = int(input())
h = [int(i) for i in input().split()] + [0, 0]

dp = [INF] * 100010
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))

print(dp[N-1])
# Judge status: Accepted
num=int(input())
ans=num+num**2+num**3
print(ans)
# Judge status: Accepted
from collections import*
_, *a = map(int, open(0).read().split())
print(sum(v - i if i < v else v if i > v else 0 for i, v in Counter(a).items()))
# Judge status: Wrong Answer
n,x=map(int,input().split())
Y = list(map(int,input().split()))
Z = [0]*n
a = 0
for i in range(n):
  a +=Y[i]
  Z[i]=a
import bisect
print(1+bisect.bisect_left(Z,x))
# Judge status: Wrong Answer
n=int(input())
if(3<=n<=7 and n%2==1):print("Yes")
else: print("No")
# Judge status: Accepted
import queue
k=int(input())
q=queue.Queue()
for i in range(1,10):
    q.put(i)
for i in range(k):
    x=q.get()
    if x%10!=0:
        q.put(10*x+(x%10)-1)
    q.put(10*x+(x%10))
    if x%10 !=9:
        q.put(10*x+(x%10)+1)
print(x)
# Judge status: Wrong Answer
#!/usr/bin/env python
"""AtCoder nomura 2020: B - Postdocs - 
https://atcoder.jp/contests/nomura2020/tasks/nomura2020_b
"""

__author__ = 'bugttle <bugttle@gmail.com>'

def calc(t):
    return t.count('D') + t.count('PD')

def main():
    T = input()

    t = T.replace('??', 'DD').replace('?D', 'DD').replace('D?', 'DD').replace('P?', 'PD').replace('?P', 'DP')
    print(t)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
#coding:utf-8
x, y = map(int, input().split())

mod = 10**9 + 7
f = [1]
for i in range(10**6):
    f.append(f[-1] * (i+1) % mod)
    
def nCr(n, r):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod

def main():
    if (x + y) % 3 != 0 or (x + y) // 3 < abs(x - y):
        print(0)
        return

    n = (x + y) // 3
    r = n // 2 + abs(x - y) // 2
    print(nCr(n, r))
    return
    
main()
# Judge status: Accepted
N = int(input())
import collections
import math
cnt = 0
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
c = collections.Counter(prime_factorize(N))
v = c.values()
for i in v:
	cnt += math.floor((math.sqrt(8*i+1)-1)/2)
print(cnt)
# 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)]
a.sort()
bc.sort(key=lambda x:x[1], reverse=True)
i = 0
j = 0
while i < n and j < m:
    if a[i] < bc[j][1]:
        a[i] = bc[j][1]
        i += 1
        bc[j][0] -= 1
        if  bc[j][0] == 0:
            j += 1
    else:
        break
print(sum(a))
# Judge status: Accepted
N,M = map(int,input().split())

m = 1
ds = set()
while m*m <= M:
    if M%m==0:
        ds.add(m)
        ds.add(M//m)
    m += 1

ans = 1
for d in ds:
    if d*N > M: continue
    ans = max(ans,d)
print(ans)
# Judge status: Wrong Answer
N = int(input())
Word = []
tail = ""
for i in range(N):
    W = list(input())
    tail = W[-1]
    if i != 0:
        if tail != W[0] or (W in Word):
            print("No")
            exit()
    Word.append(W)
print("Yes")
# Judge status: Accepted
n,d=map(int,input().split())
p=0
while n>0:
  n-=(d*2+1)
  p+=1
print(str(p))
# Judge status: Wrong Answer
def main():
    a, b, c = map(int, input().split())
    k = int(input())
    for i in range(1, k+2):
        if a < b and b < c:
            print("Yes")
            return 0
        
        elif i == k+1:
            print("No")
            return 0

        elif c < a or c < b:
            c = c * 2

        elif b < a:
            b = b * 2

main()
# Judge status: Accepted
s = int(input())

lst = [s]

i = 1
while True:
    if s % 2 == 0:
        s = s // 2
    else:
        s = 3 * s + 1
    i += 1
    if s in lst:
        print(i)
        break
    else:
        lst.append(s)
# Judge status: Accepted
#!/usr/bin/env python3
import sys
import collections
input = sys.stdin.readline

a,b= map(int,input().split())
if b %2 ==0 :
    B=b//2
    if a<=B and B<=2*a:
        print('Yes')
        sys.exit()
    else:
        print('No')
        sys.exit()
else:
    print("No")
    sys.exit()
# Judge status: Wrong Answer
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]
ma = 0
mi = float('inf')
for x,y in xy:
  ma = max(ma,abs(x-y))
  mi = min(mi,abs(x-y))
ans = ma - mi

ma = 0
mi = float('inf')
for x,y in xy:
  ma = max(ma,x+y)
  mi = min(mi,x+y)
  
ans = max(ans, ma - mi)
print(ans)
# Judge status: Wrong Answer
A, B = map(int,input().split())
if (A+B)%3==0: print('Possible')
else: print('Impossible')
# Judge status: Accepted
import sys
A = [int(input()) for _ in range(5)]
k = int(input())
for i in range(5):
    for j in range(i,5):
        if A[j]-A[i]>k:
            print(":(")
            sys.exit()
else:
    print("Yay!")
# Judge status: Wrong Answer
import math
a,b = map(float, input().split()) 

sum=a*b
result=math.floor(sum)
print(int(result))
# Judge status: Accepted
# solution

data = {p: input() for p in 'abc'}

card = 'a'

while data[card]:
    new_card, data[card] = data[card][0], data[card][1:]
    card = new_card
print(card.upper())
# Judge status: Accepted
N = int(input())
As = list(map(int,input().split()))
mi=0
ma=0
r = []
for i in range(N):
 rate = As[i]//400
 if rate < 8:
     if not rate in r:
         r.append(rate)
         mi += 1
         ma += 1
 else:
     ma+=1
if mi == 0:
    mi =1
print(mi,ma)
# Judge status: Wrong Answer
n,k = map(int,input().split())
s = input()
edge,inside,cnt,on = 0,0,0,0
if s[0]=='L':
  edge = 1
else:
  on = 1
if s[-1]=='L':
  edge = 1
temp = ''
for i in range(n):
  if temp=='L' and s[i]=='R':
    if on:
      inside += 1
    else:
      on = 1
  elif temp==s[i]:
    cnt += 1
  temp = s[i]
if inside>=k:
  print(min(k*2+cnt,n-1))
else:
  print(min(inside*2+edge+cnt,n-1))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
if n==0:
    if a[0]==1:
        print(1)
    else:
        print(-1)
    exit()
ma = [None]*n
ma[0] = 1
for i in range(n-1):
    ma[i+1] = (ma[i]-a[i])*2
node = a[-1]
ans = node
for i in range(n-1, -1, -1):
    mi = (node+1)//2
    if ma[i]-a[i]<mi:
        print(-1)
        exit()
    node = min(ma[i]-a[i], node) + a[i]
    ans += node
print(ans)
# Judge status: Accepted
N = int(input()) 
a = sorted(list(map(int, input().split())))[::-1]
f = int(0)
Ali = int(0)
Bob = int(0)

for i in range(N):
  if f == 0:
    Ali = Ali + a[0]
    del a[0]
    f = 1
  else:
    Bob = Bob + a[0]
    del a[0]
    f = 0
print(Ali-Bob)
# Judge status: Accepted
s = input()
a = set(s)
if len(a) != 2:
  print('No')
  exit()
  
import collections
c = collections.Counter(s)
if c.most_common()[0][1] == 2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
s=input()
s_r=s[::-1]

f=s.index("A")
l=s_r.index("Z")
l_r=len(s)-1-l


print(l_r-f+1)
# Judge status: Accepted
S = input()
if S == "AAA" or S == "BBB":
    print("No")
else:
    print("Yes")
# Judge status: Accepted
def calc(n, a, d):
    return (n * (2 * a + (n - 1) * d)) // 2


n = int(input())
ans = 0
for i in range(1, n + 1):
    n_ = (n // i)
    d, a = i, i
    sm = calc(n_, a, d)
    ans += sm
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())
print(a - (a > b))
# Judge status: Accepted
n = int(input())
def count():
    count = 0
    result = ''
    for i in range(n):
        d1, d2 = map(int, input().split())
        if result == 'Yes':
            continue
        if d1 == d2:
            count += 1
            if count == 3:
                result = 'Yes'
        else:
            count = 0
            result = 'No'
    return result

print(count())
# Judge status: Accepted
n,m=map(int,input().split())
a_s=[]
b_s=[]
for i in range(m):
  a,b=map(int,input().split())
  a_s.append(a)
  b_s.append(b)

for i in range(1,n+1):
  print(a_s.count(i)+b_s.count(i))
# Judge status: Wrong Answer
def yomikata(N):
    N_firstdigit=N%10
    if N_firstdigit==3:
        print("bon")
    elif N_firstdigit==0 or 1 or 6 or 8:
        print("pon")
    else:
        print("hon")

N = int(input())
yomikata(N)
# Judge status: Accepted
A,B = list(map(int,input().split()))

if A >=13:
  print(B)
elif A >= 6 and A <=12:
  print(int(B/2))
else:
  print(0)
# Judge status: Wrong Answer
s=[input()]
q=int(input())
for i in range(q):
  aa=list(map(str,input().split()))
  if len(aa)==1:
    s.reverse()
  else:
    if aa[1]=="1":
      s.insert(0,aa[2])
    else:
      s.append(aa[2])
print(*s,sep='')
# Judge status: Accepted
(n, k) = map(int, raw_input().split())

snakes = [[] for i in xrange(n + 1)]

for i in xrange(k):
    s = int(raw_input())
    ns = map(int, raw_input().split())

    for num in ns:
        snakes[num].append(s)

tot = 0
for i in xrange(1, n + 1):
    if not snakes[i]:
        tot += 1
print tot
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
m=min(a)

c=0
for i in range(1,m):
    cnt=0
    for j in range(n):
        if a[j]%i==0:
            cnt+=1
    if cnt>=n-1:
        c=i
print(c)
# Judge status: Accepted
n = int(input())
ans = []
a = 0
for i in range(1,n+1):
    a += i
    ans.append(i)
    if a >= n:
        break
a -= n
for x in ans:
    if x != a:
        print(x)
# Judge status: Accepted
n,k=map(int,input().split())
A=list(map(int,input().split()))
V=[0]*n
V[0]=0
a=0
c=0
for i in range(k):
  a=A[a]-1
  if V[a]!=0:
    break
  V[a]=i+1
if i==k-1:
  print(a+1)
  exit()
else:
  k=(k-V[a])%(i+1-V[a])
  for i in range(k):
    a=A[a]-1
  if k==0:
    print(a+1)
  else:
    print(a+1)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a=len(list(set(a)))
if n==a:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
def solve():
    N, M = map(int, input().split())
    l = [i for i in range(M-(N-1), M+(N-1)+1)]
    print(*l)

# print(solve())

# def solve()が@return voidのとき
solve()
# Judge status: Accepted
line = input()
numbers = [int(n) for n in line.split()]
if numbers[0] <= 5:
    predicted_value = 0
elif numbers[0] <= 12:
    predicted_value = numbers[1]//2
else:
    predicted_value = numbers[1]
print(predicted_value)
# Judge status: Accepted
N,K = map(int,input().split())
lh = list(map(int,input().split()))
dp = [float("inf")]*N
dp[0] = 0
for i in range(N):
    for k in range(i+1,min((i+K+1),N)):
        dp[k] = min(dp[k],(dp[i]+abs(lh[i]-lh[k])))
print(dp[-1])
# Judge status: Accepted
import math
n, d = map(int, input().split())
xs = [list(map(int, input().split()))for _ in range(n)]
c = 0
check = []
for i in range(n):
  check.append(i)
  for j in range(n):
    if i == j or j in check:
      continue
    else:
      a = xs[i][:]
      b = xs[j][:]
      length = math.sqrt(sum([(n-m)**2 for n,m in zip(a,b)]))
      if length%1 == 0:
        c += 1
print(c)
# Judge status: Accepted
memo = dict()

def dp(n):
  if n == 0: return 1
  if n in memo: return memo[n]
  ans = 0
  mod = pow(10, 9) + 7
  for i in range(n-2):
    ans = (ans + dp(i)) % mod
  memo[n] = ans
  return ans

s = int(input())
ans = dp(s)
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
A = list()
B = list()
for i in range(N):
  A.append(input())
for i in range(M):
  B.append(input())
def check(posx, posy):
  for y in range(M):
    for x in range(M):
      if not B[y][x] == A[y + posy][x + posx]:
        return False
  return True
for y in range(N - M + 1):
  for x in range(N - M + 1):
    if check(x,y):
      print("Yes")
      exit()
print("No")
# Judge status: Accepted
s=input()
n=len(s)
list=[]
for i in range(n-2):
  list.append(''.join(s[i:i+3]))
ans=[]
for l in list:
  ans.append(abs(int(l)-753))
print(min(ans))
# Judge status: Wrong Answer
n=int(input())
ans=0
for i in range(1,n+1,2):
  count=0
  for j in range(1,i+1):
    if n%j==0:
      count=count+1
  if count==8:
    ans=ans+1
else:
  print(ans)
# Judge status: Accepted
from sys import stdin
#input = stdin.readlines
import math

def main():
    N = int(input())
    p = [list(map(int, input().split())) for _ in range(N)]
    s = 0.0
    for i in range(N - 1):
        for j in range(i + 1, N):
            s += math.sqrt((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)
    print(s*2/N)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N, K, S = map(int, input().split())

ans = [0]*N
T = 10**9
if T == S:
    T = 10**9 - 1
for i in range(N):
    if i < K:
        ans[i] = S
    else:
        ans[i] = T
print(" ".join(map(str, ans)))
# Judge status: Accepted
from math import factorial
 
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
c = 1
for i in range(b):
  c = c * (n - i) % M
  if i + 1 == a:
    r -= c * pow(factorial(a), M - 2, M)
    a = b
print(r % M)
# Judge status: Accepted
a = list(map(int,input().split()))

f = 0
for i in a:
    if i % 2 == 0:
        f = 1

if f:
    ans = 0
else:
    tmp = []
    for i in range(2):
        for j in range(i+1,3):
            tmp.append(a[i] * a[j])
    #print(tmp)
    ans = min(tmp)

print(ans)
# Judge status: Accepted
n,a,b,c,d=map(int,input().split())
s=input()
if d>c:
    if "##" in s[b-1:d] or "##" in s[a-1:c]:
        print("No")
    else:
        print("Yes")
elif c>d:
    if ("##" not in s[a-1:c]) and ("..." in s[b-2:d+1]):
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
d, t, s = map(int, input().split())

if d <= t*s:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr(), dtype=np.int32)
A -= np.arange(1, N+1)
answer = np.abs(A - int(np.median(A))).sum()
print(answer)
# Judge status: Wrong Answer
list1 = [1, 3, 5, 7, 8, 10, 12]
list2 = [4, 6, 9, 11]
list3 = [2]

num = map(int, input().split())

if num in list1 or num in list2 or num in list3:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
arr = [[int(i) for i in list(input().split())] for j in range(n)]
for i in range(1,n):
	arr[i][0] += max(arr[i-1][1], arr[i-1][2])
	arr[i][2] += max(arr[i-1][1], arr[i-1][0])
	arr[i][1] += max(arr[i-1][0], arr[i-1][2])
print(max(arr[n-1]))
# Judge status: Accepted
# ABC-140-D
N, K = map(int, input().split())
S = input()
ans = 0

#初期値を確認する。
for i in range(0, len(S)-1):
    if S[i] == S[i+1]:
        ans += 1

ans = min(N-1, ans + 2 * K)
print(ans)
# Judge status: Accepted
N = int(input())

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

print(num2alpha(N).lower())
# Judge status: Accepted
n = int(input())
*a, = map(int, input().split())

*b, = filter(lambda x: x%4 != 0, a)
mul_4 = n-len(b)

*c, = filter(lambda x: x%2 != 0, b)
mul_2 = (len(b)-len(c))

k = n-(mul_4+mul_2)

if mul_2 == 0 and k <= mul_4+1:
    print("Yes")
elif k <= mul_4:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
K = int(input())
l = [x for x in range(1,11)]
if K <= 10:
  print(K)
for i in range(1,K-9):
  num = 10+ 9 *((i) // 3) + i - (i//3)
  if l[i+9-1] % 10 == 0:
    l.append(l[i+9-1]+1)
  else:
    l.append(num)
    
print(l[K-1])
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
dp=[-1]*n
dp[0]=0
dp[1]=abs(a[1]-a[0])
for i in range(2,len(a)):
    dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]))
print(dp)
print(dp[-1])
# Judge status: Accepted
a,b=map(int,input().split())
l=[2,3,4,5,6,7,8,9,10,11,12,13,1]
if l.index(a) < l.index(b):
    print('Bob')
elif l.index(a) > l.index(b):
    print('Alice')
else:
    print('Draw')
# Judge status: Accepted
S = input()

w = ""

if S == "Sunny":
    w = "Cloudy"
if S == "Cloudy":
    w = "Rainy"
if S == "Rainy":
    w = "Sunny"
print(w)
# Judge status: Accepted
n,k=map(int,input().split())
a=[]
for i in range(k):
    d=int(input())
    a+=list(map(int,input().split()))
a=set(a)
print(n-len(a))
# Judge status: Accepted
s = input()

if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
X,Y,Z=map(int,input().split())
p=1;t=Y+2*Z
while t<X:
  t=t+Y+Z
  if t>X:
    break
  #print(t)
  p=p+1
 
print(p)
# Judge status: Wrong Answer
S = input()
ACGT = ['A','C','G','T']
anss = []
for i in range(len(S)):
    tmp_s = ""
    if S[i] in ACGT:
        tmp_s += S[i]
        for j in range(i+1,len(S)-i):
            if S[j] in ACGT:
                tmp_s += S[j]
            else:
                break
    anss.append([len(tmp_s),tmp_s])
anss.sort()
print(anss[-1][0])
# Judge status: Wrong Answer
a, b = map(int, input().split())
print(a+b if a+b<=24 else a+b-24)
# Judge status: Accepted
a,b,x=map(int,input().split())
print('YES' if a<=x and a+b>=x else 'NO')
# Judge status: Accepted
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
p = [0]*(n+1)
p[0] = 1
if 1 not in a:
  p[1] = 1

t = 1000000007

for i in range(2, n+1):
  if i in a:
    continue
  s = p[i-1] + p[i-2]
  s = s%t
  p[i] = s
  
print(p[n])
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(1, n + 1):
    if i % 2 == 1:
        cnt = 0
        for j in range(1, i + 1):
            if i % j == 0:
                cnt += 1
        if cnt == 8:
            ans += 1
print(ans)
# Judge status: Accepted
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

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

print(gcd(xn))
# Judge status: Accepted
n,m = map(int,input().split())
if n*2 >= m:
    print(m//2)
else:
    print(n + (m-n*2)//4)
# Judge status: Accepted
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]
A.sort(key=lambda x:x[1])
ans=0
for i in range(N):
  if ans+A[i][0]>A[i][1]:
    print('No')
    exit()
  ans+=A[i][0]
print('Yes')