peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys

x, y = map(int, sys.stdin.readline().rstrip().split())
count = 0
if abs(x) < abs(y):
    if x < 0:
        count += 1
        x = -x
    if y < 0:
        count += 1
        y = -y
    count += abs(y - x)
    print(count)
else:
    if x > 0:
        count += 1
        x = -x
    if y > 0:
        count += 1
        y = -y
    count += abs(y - x)
    print(count)
# Judge status: Accepted
N = int(input())

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

ans = 0
for i in range(N):
    if (i + 1) % 2 == 1 and a[i] % 2 == 1:
        ans += 1
print(ans)
# Judge status: Wrong Answer
n, m =map(int,input().split())
s = list(map(int,input().split()))
a = []*m
b = []*m
ans = 0
for __ in range(m):
  _= list(map(int, input().split()))
  a.append(_)
  if s[_[0]-1] > s[_[1]-1]:
    b.append(_[0])
  elif s[_[0]-1] < s[_[1]-1]:
    b.append(_[1])
  else:
    b.append(0)
for i in range(n):
  count = 0
  for j in range(m):
    if i+1 in a[j]:
      count += 1
  if b.count(i+1) == count:
      ans += 1
      print(str(i+1) +" is good")
print(ans)
# Judge status: Accepted
S = list(input())
t = 0
for i in range(len(S)):
  if S[i] == S[-1-i]:
    continue
  elif S[i] != S[-1-i]:
    S[-1-i] = S[i]
    t += 1
print(t)
# Judge status: Accepted
a,b=map(int, input().split())
print("Possible" if a%3==0 or b%3==0 or (a+b)%3==0 else "Impossible")
# Judge status: Accepted
n=int(input())
a=[list(map(int,input().split())) for i in range(n)] 

dp=[]
for i in range(n+1):
    dp.append([0,0,0])

for i in range(0,n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i+1][k]=max(dp[i+1][k],dp[i][j]+a[i][k])

print(max(dp[n]))
# Judge status: Accepted
n, k = map(int, input().split())
if n%k==0:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
S = str(input(""))
S.lower()
if S.endswith(('o', 'ch', 's', 'sh', 'x', 'z')):
    print(S+"es")
else:
    print(S+"s")
# Judge status: Accepted
#曜日を表す関数Sを使う
#input()という命令を使い、入力待機状態にする
#つまり、曜日ｓを入力したら、答えを出してくれるようプログラムする

s = input()
if s =='SUN':
    print('7')
elif s == 'MON':
    print('6')
elif s == ('TUE'):
    print('5')
elif s == 'WED':
    print('4')
elif s == 'THU':
    print('3')
elif s == 'FRI':
    print('2')
elif s == 'SAT':
    print('1')
# Judge status: Accepted
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = list(map(int,input().split()))

Ans = 10**8
for x in range(-100,100+1):
    ans = 0
    for i in range(N):
        ans += (A[i] - x)**2
    Ans = min(Ans,ans)

print(Ans)
# Judge status: Accepted
N = int(input())
L = list(map(int, input().split()))
if len(set(L)) == len(L):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for i in range(n)]
mincost = 10**111

for i in range(2**n):
  li = [0]*m
  cost = 0
  count = 0
  for j in range(n):
    if (i >> j) & 1:
      cost += ca[j][0]
      for k in range(m):
        li[k] += ca[j][1+k]
  for l in range(m):
    if li[l] >= x:
      count += 1
  if count == m:
    mincost = min(cost,mincost)
    
if mincost == 10**111:
  print(-1)
else:
  print(mincost)
# Judge status: Wrong Answer
from math import floor
a,b = map(int, input().split())
print("{}".format(floor((a+b)/2)))
# Judge status: Accepted
N,K=list(map(int,input().split()))
R,S,P= list(map(int,input().split()))
T= list(input())
lock_list=[""] * K
ans=0
dic={"r":"p","p":"s","s":"r"}
for i,j in enumerate(T):
   if lock_list[i%K] != dic[j]:
      lock_list[i%K] = dic[j]
      if j == "r":
         ans+=P
      elif j == "s":
         ans+=R
      else:
         ans+=S
   else:
      try:
         lock_list[i%K] = ""
      except IndexError:
         pass
print(ans)
# Judge status: Accepted
n = int(input())
s = [int(input()) for i in range(n)]

ans = 0
sub = sum(s)
if sub % 10 != 0:
    print(sub)
else:
    l = []
    for i in range(n):
        if s[i] % 10 != 0:
            l.append(s[i])
    l.sort()
    for j in l:
        sub -= j
        if sub % 10 != 0:
            break
    
    if sub % 10 == 0:
        print("0")
    else:
        print(sub)
# Judge status: Wrong Answer
import numpy as np

A_init = 500
B_init = 100
C_init = 50

A_list = [A_init * i for i in range(1,int(input())+1)]
B_list = [B_init * i for i in range(1,int(input())+1)]
C_list = [C_init * i for i in range(1,int(input())+1)]

X = int(input())

All_list = np.concatenate([A_list, B_list, C_list], 0)
np.count_nonzero([k+[i for i in All_list] == X for k in All_list])
# Judge status: Accepted
N, K = map(int, input().split())
HL = sorted(list(map(int, input().split())), reverse=1)

print(sum(HL[K:]))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort()

x=0
y=0
i=0

while(i<n):
    if x==0 and a[n-1-i]==a[n-2-i]:
        x=a[n-1-i]
        i+=2
        continue
    if x>0 and y==0 and a[n-1-i]==a[n-2-i]:
        y=a[n-1-i]
        break
    i+=1
print(x*y)
# Judge status: Wrong Answer
#B - 754
S = list(map(int,input()))
print(S)
minimam = 987
for i in range(len(S)-2):
    X = 100*S[i] + 10*S[(i+1)] + S[(i+2)]
    if abs(X - 753)<minimam:
        minimam = abs(X - 753)
print(minimam)
# Judge status: Accepted
n, t = map(int, input().split())
sen = -1
gos = -1
man = -1
for i in range(n+1):
    for j in range(n-i+1):
        if i * 1000 + j*5000 + (n-i-j)*10000 == t:
            sen = i
            gos = j
            man = n-i-j
print(man, gos, sen)
# Judge status: Wrong Answer
import sys
x,y = map(int,input().split())
for i in range(1,10**18,1):
    if i%x == 0 and i%y != 0:
        print(i)
    else:
        print(-1)
        sys.exit()
# Judge status: Accepted
h = int(input())
w = int(input())
n = int(input())

cnt = 0
if w >= h:
    cnt = -(-n // w)
else:
    cnt = -(-n // h)

print(cnt)
# Judge status: Accepted
a, b, c = map(int, input().split())
print(c - min(c, a - b))
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
i1, i2, i3, p = 0, 0, 0, 0
while i1 <= a:
  while i2 <= b:
    while i3 <= c:
      m = 500 * i1 + 100 * i2 + 50 * i3
      if m == x:
        p += 1
      i3 += 1
    i3 = 0
    i2 += 1
  i2 = 0
  i1 += 1
print(p)
# Judge status: Accepted
i = input("").split(" ")
ii = [int(a) for a in i]
if ii[0]%ii[1] == 0:
  n = (ii[0]//ii[1])
else:
  n = (ii[0]//ii[1])+1
print(str(n*ii[2]))
# Judge status: Accepted
n,c,k = map(int,input().split())
t = list(int(input()) for i in range(n))
t.sort()
ans = 0
i = 0
while i < n:
    a = t[i]
    j = i + 1
    z = 1
    for j in range(i+1,min(i+c,n)):
        if a+k >= t[j]:
            z += 1
        else:
            break
    i += z
    ans += 1
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = 0

for i in range(n-1):
    if a[i] > a[i + 1]:
        ans += (a[i] - a[i + 1])
        a[i + 1] = a[i]

print(ans)
# Judge status: Wrong Answer
n = int(input())
s = input()
ch = []
for i in range(0, n):
    x = s[:i+1]
    y = s[i:len(s)]
    a = set(x)
    b = set(y)
    c = a.intersection(b)
    ch.append(len(c))
print(max(ch))
# Judge status: Wrong Answer
N,A,B,C,D=map(int,input().split())
S=input()
if ("##" in S[A:]) or ("..." not in S[B:D] and C>D):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
#coding:utf-8

S = str(input())

if S[-1] == "s":
    print("{}".format(S+"es"))
else:
    print("{}".format(S+"s"))
# Judge status: Accepted
n = int(input())
ans = 0
for i in range(n+1):
    if i % 3 == 0 or i%5 == 0:
        ans += 0
    else:
        ans+=i
print(ans)
# Judge status: Accepted
x = int(input())
a = x // 11
if (x % 11 == 0):
    print(2*a)
elif (x % 11 <= 6):
    print(2*a+1)
else:
    print(2*a+2)
# Judge status: Accepted
q,h,s,d=map(int,input().split())
n=int(input())
num1=n%2
num2=n//2
num10=min(q*4,h*2,s)
num20=min(q*8,h*4,s*2,d)
ans=0
if num1==1:
    ans+=num10
ans+=num2*num20
print(ans)
# Judge status: Wrong Answer
N,M = map(int,input().split())
for i in range(1,M+1):
    print(i,M+i+i)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(input() for _ in range(N))
B = list(input() for _ in range(M))
b = len(B[0])

ans = "No"
for i in range(N-(M-1)):
  n = -1
  c = 0
  for j in range(M):
    if B[j] in A[i+j]:
      if n < 0:
        n = A[i + j].index(B[j])
        c += 1
      else:
        if B[j] in A[i + j][n: n + b + 1]:
          c += 1
  if c == M:
    ans = "Yes"
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
a=[]
b=[]
for i in range():
    A, B = map(int, input().split())
    a.append(A)
    b.append(B)'''

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

c=a//x
cc=b//x
if a%x==0:
    cc+=1
print(cc-c)
# Judge status: Accepted
x,a,b = map(int,input().split())
if b <= a:
  print('delicious')
elif b<= a+x:
  print('safe')
else:
  print('dangerous')
# Judge status: Wrong Answer
n = int(input())
arr = [0] * 5
min_p = 10 ** 12
mi = -1
for i in range(5):
    arr[i] = int(input())
    if arr[i] < min_p:
        min_p = arr[i]
        mi = i

import math
print(4 + math.ceil(n / min_p))
# Judge status: Accepted
S = input()
count = 0
if S[0] == "R" and S[1] == "R":
    if S[2] == "R":
        count = 3
    else:
        count = 2
if S[0] == "R" and S[1] == "S":
    count = 1
if S[0] == "S" and S[1] == "R":
    if S[2] == "R":
        count = 2
    else:
        count = 1
if S[0] == "S" and S[1] == "S":
    if S[2] == "R":
        count = 1
    else:
        count = 0
print(count)
# Judge status: Accepted
from collections import deque

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

order = n%2
ans = deque([])
for i in range(n):
    if i%2 == order:
        ans.append(a[i])
    else:
        ans.appendleft(a[i])
for el in ans:
    print(el, end=' ')
# Judge status: Accepted
s=input()

ans=0
num=0
for i in range(len(s)):

    if s[i] == 'R':

        num+=1

    else:
        num=0

    if num>ans:
        ans=num

print(ans)
# Judge status: Accepted
import sys

def input():
    return sys.stdin.readline()[:-1]

l, r, d = map(int, input().split())
s = int(r//d-(l-1)//d)
print(s)
# Judge status: Wrong Answer
a,b= map(int, input().split())

if  0<a<17 and 0<b<17 and a+b<17:
    print('Yeh')
else:
    print(':(')
# Judge status: Wrong Answer
mod=10**9+7

x,y=map(int,input().split())
if (x+y)%3!=0:
  print(0)
  exit()
  
z=(x+y)//3

x-=z
y-=z

n=x+y
r=x


lst=[0]+[1]
for i in range(2,2*10**6+10):
  lst.append((lst[-1]*i)%mod)


xxx=lst[n]
xxx*=pow(lst[n-r],10**9+5,mod)
xxx%=mod
xxx*=pow(lst[r],10**9+5,mod)
xxx%=mod

print(xxx)
# Judge status: Accepted
a, b, c = map(int, input().split())

if (b - a) == (c - b):
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
n=int(input())

def func(n):
  a=[]
  f=2
  while f*f<=n:
    if n%f==0:
      a.append(f)
      n//=f
    f+=1
  if n!=1 and f-1!=n:
    a.append(n)
  return a

print(len(func(n)))
# Judge status: Accepted
line = input()
a, b, c = [int(n) for n in line.split()]
if a>b:
    maior=a
    menor=b
else:
    maior=b
    menor=a
v = []
for i in range(1, menor+1, 1):
    if menor%i==0 and maior%i==0:
        v.append(i)
print(v[-c])
# Judge status: Wrong Answer
a, b = map(int, input().split())
s =  input()
num = ["0","1","2","3","4","5","6","7","8","9"]
check = True
for i in range(a):
    if not s[i] in num:
        check = False
        break
if s[a+1] != "-":
    check = False

for j in range(b):
    if not s[j+a+1] in num:
        check = False
        break

if check == True:
    print("Yes")
if check == False:
    print("No")
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")

n = int(input())
a = list(map(int, input().split()))
nmax = [None]*(n+1)
nmax[-1] = 0
for i in range(n-1, -1, -1):
    nmax[i] = nmax[i+1] + a[i+1]
    
k = 1
ans = 0
for i,(num, M) in enumerate(zip(a, nmax)):
    if k<num:
        ans = -1
        break
    k -= num
    k = min(M, k)
    ans += (k+num)
    k *= 2
print(ans)
# Judge status: Accepted
import sys

input = sys.stdin.readline

N = int(input().rstrip())
S = []
for s in range(N):
    S.append(sorted(input().rstrip()))
S = sorted(S)
ans = 0
ren = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        ans += ren
        ren += 1
    else:
        ren = 1

print(ans)
# Judge status: Wrong Answer
N,X = list(map(int,input().split()))
A = list(map(int,input().split()))
A.sort()
count = 0
for i in A:
    if X >= i:
        X = X - i
        count += 1
        print(X)
    else:
        break
if X > 0:
    count -= 1
print(max(count,0))
# Judge status: Wrong Answer
s = input()

sc = ["dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"]
for i in sc:
    s = s.replace(i, '')

if len(s) == 0:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N=int(input())
    A=list(map(int,input().split()))
    AS =sorted(A)
    right = AS[N//2]
    left = AS[N//2 -1]
    for a in A:
        if a<=left:
            print(right)
        else:
            print(left)




if __name__ == "__main__":
    main()
# Judge status: Accepted
n,m=list(map(int,input().split()))
N=[list(input()) for _ in range(n)]
M=[list(input()) for _ in range(m)]

for i in range(n-m+1):
  for j in range(n-m+1):
    count = 0
    for k in range(m):
      if N[i+k][j:j+m] == M[k][:]:
        count += 1
    if count == m:
      print("Yes")
      exit()
    
print("No")
# Judge status: Accepted
x , y = map(int,input().split())
ans = 0
if abs(x) < abs(y):
    if x < 0:
        ans += 1
    ans += abs(y) - abs(x)
    if y < 0:
        ans += 1
    
elif abs(x) > abs(y):
    if x > 0:
        ans += 1
    ans += abs(x) - abs(y)
    if y > 0:
        ans += 1
elif abs(x) == abs(y):
    ans = 1

print(ans)
# Judge status: Accepted
import numpy as np

c = np.array([list(map(int, input().split())) for i in range(3)])

x = [0] * 3
y = [0] * 3

for i in range(3):
    y[i] = c[0][i] - x[0]
for i in range(3):
    x[i] = c[i][0] - y[0]
flag = True

for i in range(3):
    for j in range(3):
        if x[i] + y[j] != c[i][j]:
            flag = False

print("Yes" if flag else "No")
# Judge status: Accepted
from math import sqrt

N, M = [int(_) for _ in input().split()]
m = M

a = 0
flg = False
for i in range(1, int(sqrt(M)) + 1):
    if M % i==0:
        if i <= M / N:
            a = max(a, i)
        b = M // i
        if b <= M / N:
            a = max(a, b)

print(a)
# Judge status: Accepted
N = int(input())
X = input()
L, R = 0, 0
for x in X:
  if x == "(":
    R += 1
  else:
    if R == 0:
      L += 1
    else:
      R -= 1
print(L*"("+X+R*")")
# Judge status: Accepted
from collections import Counter
S = list(input())
S.reverse()
MOD = 2019

t = [0]
r = 1
for i in range(len(S)):
    q = (t[-1] + (int(S[i]) * r)) % MOD
    t.append(q)
    r *= 10
    r %= MOD

cnt = Counter(t)
cnt_mc = cnt.most_common()

ans = 0
for _, j in cnt_mc:
    if j >= 2:
        ans += j * (j - 1) // 2
        
print(ans)
# Judge status: Accepted
a, b, n = map(int, input().split())
if n >= b:
    ans = a * (b-1) // b
else:
    ans = a * n // b
print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())
K = int(input())

m = max(A, B, C)
m *= 2**K

ans = A + B + C - max(A, B, C)
ans += m
print(ans)
# Judge status: Accepted
X = int(input())
for i in range(1, 361):
  if X*i % 360 == 0:
    print(i)
    exit()
# Judge status: Accepted
s = input()
n = int(s)
l = len(s)
isall9 = True
for i in range(1, l):
    if s[i] != "9":
        isall9 = False
if isall9:
    print( int(s[0])  + 9 * (l - 1) )
else:
    res = int(int(s[0]) - 1) + 9 * (l - 1)
    print( res)
# Judge status: Accepted
a = int(input())
for _ in range(3):
    input()
e = int(input())
k = int(input())
if e-a > k:
    print(':(')
else:
    print('Yay!')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
cnt = 0
need = len(a)//2
ans = 'No'
for i in a:
  if i%4 != 0:
    cnt += 1
if (len(a) - cnt) >= need+1:
  ans = 'Yes'
print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
h.sort()
ans=pow(10,9)
for i in range(n-k+1):
  ans=min(ans,h[i+k-1]-h[i])
print(ans)
# Judge status: Accepted
import math
x,y = map(int,input().split())
 
m = (x+y)/2
 
print(math.ceil(m))
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)

n = int(input())

d = {}

for i in range(n):
    t = input()
    t = ''.join(sorted(t))
    d[t] = d.get(t,0) + 1
        
ans = 0

for v in d.values():
    ans += v*(v-1)//2
    
print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import Counter
def main():
    n=int(input())
    D=[int(_) for _ in input().split()]
    dc=Counter(D)
    mod,ans=998244353,1
    if D[0]!=0 or dc[0]!=1:
        print(0)
        sys.exit()
    for i,_ in enumerate(list(dc.items())):
        if i>1:
            ans*=dc[i-1]**dc[i]%mod
    print(ans%mod)

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


if a-k<0:
    a=0
    fusai=a-k
    b=max(b+fusai,0)
    print(a,b)
else:
    print(a-k,b)
# Judge status: Wrong Answer
n,m = map(int,input().split())
if n == 2 or m == 2:
	print(0)
elif n == 1 or m == 1:
	print(max(n-2,m-2))
else:
	print((n-2)*(m-2))
# Judge status: Wrong Answer
n = int(input())
t, a = map(int, input().split())
temp = 10 ** 6
ans = 0
height = list(map(int, input().split()))
for i, h in enumerate(height):
    diff = abs(a - (t - h * 0.006))
    print(diff)
    if temp > diff:
        temp = diff
        ans = i + 1
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 9)
if __name__ == '__main__':
    def solve(s, a):
        if len(s) == n:
            print(s)
        else:
            for c in range(ord("a"), a + 1):
                if c == a:
                    solve(s + chr(c), a + 1)
                else:
                    solve(s + chr(c), a)
    n = int(input())
    solve("", ord("a"))
# Judge status: Accepted
S = input()


def solve(S):
    n = len(S)
    ans = 1000
    for i in range(n-2):
        ans = min(ans,abs(int(S[i:i+3])-753))
    return ans
print(solve(S))
# Judge status: Accepted
import sys,math
sys.setrecursionlimit(10**9)
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())


n=int(input())
print(n//500*1000+n%500//5*5)
# Judge status: Wrong Answer
s = str(input())
l = list(s)

count = 0

if int(l[0]) == 0:
    for i in range(1, len(l), 2):
        if int(l[i]) != 0 or int(l[i-1]) != 1 :
            count = count + 1

if int(l[0]) == 1:
    for j in range(1, len(l), 2):
        if int(l[j]) != 1 or int(l[j-1]) != 0 :
            count = count +1

print(count)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
abs_A = [abs(i) for i in A]

minus = 0
for i in range(N):
    minus += A[i] < 0

if minus % 2 == 0:
    print(sum(abs_A))
else:
    mini = float('inf')
    for i in range(N):
        mini = min(mini, abs_A[i])
    print(sum(abs_A) - 2*mini)
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))
for i in range(k):
    b=[0]
    b*=n
    for j in range(n):
        b[j]+=1
        for l in range(1,a[j]+1):
            if j-l>=0:
                b[j-l]+=1    
            if j+l<=n-1:
                b[j+l]+=1
    for j in range(n):
        a[j]=b[j]
    
print(a)
# Judge status: Accepted
N, M = map(int, input().split())
n_student = [list(map(int, input().split())) for i in range(N)]
m_point = [list(map(int, input().split())) for i in range(M)]

for x in range(N):
    min_y = 0
    min_value = 10**12
    for y in range(M):
        distance = abs(n_student[x][0] - m_point[y][0]) + \
            abs(n_student[x][1] - m_point[y][1])
        if distance < min_value:
            min_value = distance
            min_y = y + 1
    print(min_y)
# Judge status: Wrong Answer
S = input()
T = input()
# print(list(S))
# print(list(T))
# result = list(set(list(S)) - set(list(T)))
# print(result)
result = list(filter(lambda x: x not in list(S), list(T)))
# print(result)
print(len(result))
# Judge status: Accepted
n=int(input())
abc=[]
for i in range(n):
    x=tuple(map(int,input().split()))
    abc.append(x)
dp=[[0]*n for _ in range(3)]
for i in range(3):
    dp[i][0]=abc[0][i]

for i in range(1,n):
    x=abc[i]
    for j in range(3):
        dp[j][i]=max(dp[j][i],dp[(j+1)%3][i-1]+x[j],dp[(j+2)%3][i-1]+x[j])

ans=0
for i in range(3):
    ans=max(ans,dp[i][-1])
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sa = sum(A)
sb = sum(B)
if sa>sb:
    print("No")
else:
    d1 = 0
    d2 = 0
    for i in range(N):
        if A[i]>B[i]:
            d1 += A[i]-B[i]
        elif B[i]>A[i]:
            d2 += (B[i]-A[i])//2
    if d2>=d1:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def main():
    d, t, s = _ia()
    return "Yes" if t * s >= d else "No"


if __name__ == "__main__":
    print(main())
# Judge status: Accepted
N=int(input())
for i in reversed(range(1,10001)):
	if N<=(i*(i-1)//2) and N>(i-1)*(i-2)//2:
		print(i-1)
		N-=(i-1)
	else:continue
# Judge status: Accepted
x, y = map(int, input().split())
group = [[1, 3, 5, 7, 8, 10, 12], [4, 6, 9, 11], [2]]
for i in group:
    if x in i and y in i:
        print("Yes")
        exit()
print("No")
# Judge status: Accepted
N,M = map(int,input().split())
print(abs((N-2)*(M-2)))
# Judge status: Wrong Answer
A=list(map(int,input().split()))

print(A[0])
if A[0]+A[1]+A[2]<=21 :
    print("win")
else:
    print("bust")
# Judge status: Accepted
def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    diff = 10 ** 10

    partA = 0
    partB = sum(A)

    for i in range(N):
        diff = min(diff, abs(partA-partB))
        partA += A[i]
        partB -= A[i]
    print(diff)
    return
resolve()
# Judge status: Accepted
N = int(input())
S = list(input())

rightWhite = []
leftBlack = []

cntB = 0
cntW = 0

for i in range(N):
    rightWhite.append(cntW)
    leftBlack.append(cntB)
    if (S[i] == "#"):
        cntB += 1

    if (S[-i-1] == "."):
        cntW += 1

rightWhite = list(reversed(rightWhite))

ans = N

for i in range(N):
    ans = min(rightWhite[i] + leftBlack[i], ans)

print(ans)
# Judge status: Wrong Answer
n=int(input()) 
l = list(map(int,input().split())) 
if n<=2:
  print(0)
  exit()
  
cnt = 0
for i in range(n):
  for j in range(n):
    for k in range(n):
      if l[i]<l[j]+l[k] and l[j]<l[i]+l[k] and l[k]<l[i]+l[j]:
        cnt+= 1
print(cnt)
# Judge status: Wrong Answer
from fractions import gcd
from functools import reduce


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


def solve(string):
    n, m, *a = map(int, string.split())
    l = reduce(lcm, a)
    ma = max(a)
    s = l
    while s < ma:
        s += l
    return str((m - s // 2) // l + 1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
# Judge status: Accepted
a, b = map(int, input().split())

if a > 0:
    print("Positive")
elif a <= 0 and b >= 0:
    print("Zero")
else:
    if (b - a) % 2 == 0:
        print("Negative")
    elif (b - a) % 2 == 1:
        print("Positive")
# Judge status: Accepted
import math
a,b = map(int,input().split())
print(math.ceil((b-1)/(a-1)))
# Judge status: Accepted
from collections import Counter

n=int(input())
s=[ input() for i in range(n)]
dick=Counter(s)
dick=dick.most_common()
#print(dick)
#print(dick.values())
p=dick[0][1]

s=[]
for k,i in dick:
  if i==p:
    s.append(k)
  else:
    break
ss=sorted(s)
for i in ss:
  print(i)
# Judge status: Accepted
import math
a,b,x = map(int,input().split())
ans_taiseki = a**2*b - x
ans_hen2 = ans_taiseki/(a*a)*2

ans_hen = x/(a*b)*2
if ans_hen < a:
    ans = math.degrees(math.atan(b/ans_hen))
else:
    ans = math.degrees(math.atan(ans_hen2/a))

print(ans)