CodeEff/ECCO huggingface dataset:
# Original solution
def canbuy(n):
    for i in range(int(100/7)):
        tmp = n-7*i
        if tmp==0 or (tmp>3 and tmp%4==0):
            return 'Yes'
    return 'No'

n=int(eval(input()))
print((canbuy(n)))

# Optimized solution
def canbuy(n):
    if n%7==0 or n%4==0:
        return 'Yes'
    else:
        if n<4:
            return 'No'
        else:
            if canbuy(n-7)=='Yes':
                return 'Yes'
            else:
                if canbuy(n-4)=='Yes':
                    return 'Yes'
                else:
                    return 'No'

n=int(eval(input()))
print((canbuy(n)))
# Original solution
N = int(eval(input()))

for a in range(100 // 4 + 1):
    for b in range(100 // 7 + 1):
        if 4 * a + 7 * b == N:
          print("Yes")
          exit()
print("No")

# Optimized solution
N = int(eval(input()))

for c in range(N // 4 + 1):
    for d in range(N // 7 + 1):
        if 4 * c + 7 * d == N:
            print("Yes")
            exit()
print("No")
# Original solution
N=int(eval(input()))
if N in [1,2,3,5,6,9,10,13,17]:
  print("No")
else:
  print("Yes")

# Optimized solution
N=int(eval(input()))
for i in range(0,4):
  if N-7*i>=0 and (N-7*i)%4==0:
    print("Yes")
    break
else:
  print("No")
# Original solution
list47=set([0,4,7,8,11,12,14,15,16,18,19,20,21,22,23,24,25,26,27])
n=int(eval(input()))
print(('Yes' if (n%28) in list47 else 'No'))

# Optimized solution
n = int(eval(input())) 
list47 = set([1,2,3,5,6,9,10,13,17])
print(('No' if n in list47 else 'Yes'))
# Original solution
N=int(eval(input()))
L = []
for j in range(25):
    for i in range(15):
        l = 4*j+7*i
        L.append(l)
if N in L :
    print("Yes")
else :
    print("No")
    
    

# Optimized solution
N = int(eval(input()))
L = []
counter = 0
for i in range(26) :
    for j in range(16) :
        l = 4*i + 7*j
        L.append(l)
if N in L :
    print("Yes")
else :
    print("No")
# Original solution
N = int(eval(input()))

ans = "No"
for i in range(26):
  for j in range(16):
    if(4*i+7*j == N):
      ans = "Yes"
print(ans)

# Optimized solution
N = int(eval(input()))
ans = "No"
for i in range(26):
  for j in range(16):
    if(i*4+j*7 == N):
      ans = "Yes"
print(ans)
# Original solution
n=int(eval(input()))
flag=False
for i in range(n//4+1):
    for j in range(n//7+1):
        sum=4*i+7*j
        if sum==n:
            flag=True
print(('Yes' if flag else'No'))
    

# Optimized solution
import sys
n=int(eval(input()))
ans=False
if n%7==0 or n%4==0:
        ans=True
        print(('Yes' if ans else 'No'))
        sys.exit()

for i in range(n//4+1):
    total=0
    for j in range(n//7+1):
       total=4*i+7*j
       if total==n:
           ans=True
           break
print(('Yes' if ans else 'No'))
# Original solution
from sys import stdin

N = int(stdin.readline().rstrip())

if N in [1, 2, 3, 5, 6, 9, 10, 13, 17]:
    print('No')
else:
    print('Yes')


# Optimized solution
N = int(eval(input()))

if N in [1, 2, 3, 5, 6, 9, 10, 13, 17]:
    print('No')
else:
    print('Yes')
# Original solution
from collections import deque
import sys
readline = sys.stdin.readline

N, M = list(map(int, readline().split()))
G = [[] for i in range(N)]
for i in range(M):
    a, b = list(map(int, readline().split()))
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)
def check(s, t):
    u = [0]*N
    u[s] = u[t] = 1
    for v in G[s]:
        if v == t:
            continue
        u[v] = 1
        que = deque([v])
        ok = 0
        while que:
            x = que.popleft()
            for y in G[x]:
                if y == s and x != v:
                    return 1
                if u[y]:
                    continue
                u[y] = 1
                que.append(y)
    return 0
C = [0]*4
ok = 1
for i in range(N):
    if len(G[i]) % 2 == 1:
        ok = 0
    C[min(3, len(G[i])//2)] += 1
if C[1] == N or (C[1] == N-1 and C[2] == 1):
    ok = 0
elif C[1] == N-2 and C[2] == 2:
    VV = []
    for i in range(N):
        if len(G[i]) == 4:
            VV.append(i)
    if not check(*VV):
        ok = 0
print(("Yes" if ok else "No"))

# Optimized solution
from collections import deque
import sys
readline = sys.stdin.readline

N, M = list(map(int, readline().split()))
G = [[] for i in range(N)]
for i in range(M):
    a, b = list(map(int, readline().split()))
    a -= 1; b -= 1
    G[a].append(b)
    G[b].append(a)

def check(s, t):
    u = [0]*N
    u[s] = u[t] = 1
    que = deque()
    for v in G[s]:
        if v == t:
            continue
        u[v] = 1
        que.append(v)
        ok = 0
        while que:
            x = que.popleft()
            for y in G[x]:
                if y == s and x != v:
                    return 1
                if not u[y]:
                    u[y] = 1
                    que.append(y)
    return 0
C = [0]*4
ok = 1
for i in range(N):
    if len(G[i]) % 2 == 1:
        ok = 0
    C[min(3, len(G[i])//2)] += 1
if C[1] == N or (C[1] == N-1 and C[2] == 1):
    ok = 0
elif C[1] == N-2 and C[2] == 2:
    VV = []
    for i in range(N):
        if len(G[i]) == 4:
            VV.append(i)
    if not check(*VV):
        ok = 0
print(("Yes" if ok else "No"))
# Original solution
import sys


def solve(n, m, links):
    v4 = set()
    v6 = 0
    for v, link in enumerate(links):
        l = len(link)
        if l % 2 == 1:
            return False
        if l == 4:
            v4.add(v)
        elif l >= 6:
            v6 += 1
    if v6 > 0:
        return True
    if len(v4) > 2:
        return True
    if len(v4) < 2:
        return False
    s = v4.pop()
    t = v4.pop()
    visited = set()
    q = [s]
    while q:
        v = q.pop()
        if v == t:
            continue
        if v == s:
            if s in visited:
                return True
        elif v in visited:
            continue
        visited.add(s)
        q.extend(u for u in links[v] if u not in visited)
    return False


n, m = list(map(int, input().split()))
links = [set() for _ in [0] * n]
for line in sys.stdin:
    a, b = list(map(int, line.split()))
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
print(('Yes' if solve(n, m, links) else 'No'))


# Optimized solution
import sys


def solve(n, m, links):
    v4 = set()
    v6 = 0
    for v, link in enumerate(links):
        l = len(link)
        if l % 2 == 1:
            return False
        if l == 4:
            v4.add(v)
        elif l >= 6:
            v6 += 1
    if v6 > 0:
        return True
    if len(v4) > 2:
        return True
    if len(v4) < 2:
        return False
    s = v4.pop()
    t = v4.pop()
    for c in links[s]:
        visited = {s, t}
        q = [c]
        while q:
            v = q.pop()
            if v in visited:
                continue
            visited.add(v)
            for u in links[v]:
                if v != c and u == s:
                    return True
                if u not in visited:
                    q.append(u)
    return False


n, m = list(map(int, input().split()))
links = [set() for _ in [0] * n]
for line in sys.stdin:
    a, b = list(map(int, line.split()))
    a -= 1
    b -= 1
    links[a].add(b)
    links[b].add(a)
print(('Yes' if solve(n, m, links) else 'No'))
# Original solution
# -*- coding: utf-8 -*-
from collections import defaultdict

def solve():
    N, M = list(map(int, input().split()))
    F = defaultdict(list)
    D = defaultdict(int)
    for _ in range(M):
        a, b = list(map(int, input().split()))
        D[a] += 1
        D[b] += 1
        F[a] += F[a] + [b]
        F[b] += F[b] + [a]

    E = defaultdict(int)
    X = list()
    for a,d in list(D.items()):
        if d%2==0:
            if d >= 6:
                E[6] += 1
            elif d == 4:
                E[4] += 1
                X.append(a)
            else:
                E[d] += 1
        else:
            E[1] += 1

    if E[1]==0 and (E[6]>=1 or E[4]>=3):
        res = 'Yes'
    elif E[4]==2:
        x, y = X
        q = set((y,))
        R = set((x,))
        while q:
            z = q.pop()
            R.add(z)
            q |= set(F[z])-R
        if set(F[x])&R == set(F[x]):
            res = 'No'
        else:
            res = 'Yes'
    else:
        res = 'No'
    return str(res)
if __name__ == '__main__':
    print((solve()))


# Optimized solution
# -*- coding: utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))
    F = [list() for _ in range(N+1)]
    D = [int() for _ in range(N+1)]
    for _ in range(M):
        a, b = list(map(int, input().split()))
        D[a] += 1
        D[b] += 1
        F[a].append(b)
        F[b].append(a)

    E = [0 for _ in range(7)]
    X = list()
    for a,d in enumerate(D[1:], start=1):
        if d%2==0:
            if d >= 6:
                E[6] += 1
            elif d == 4:
                E[4] += 1
                X.append(a)
            else:
                E[d] += 1
        else:
            return 'No'
            E[1] += 1

    if E[6]>0 or E[4]>2:
        return 'Yes'

    elif E[4]<2:
        return 'No'

    else:
        x, y = X
        q = set((y,))
        R = set((x,))
        while q:
            z = q.pop()
            R.add(z)
            q |= set(F[z])-R
        if set(F[x])&R == set(F[x]):
            return 'No'
        else:
            return 'Yes'

if __name__ == '__main__':
    print((solve()))
# Original solution
while 1:
    a, b, c = list(map(int, input().split()))
    if not a:
        break
    n = eval(input())

    I = []; J = []; K = []
    res = [2]*(a+b+c)
    for p in range(n):
        i, j, k, r = list(map(int, input().split()))
        i -= 1; j -= 1; k -= 1
        if r:
            res[i] = res[j] = res[k] = 1
        else:
            I.append(i); J.append(j); K.append(k)
    for p in range(len(I)):
        i, j, k = I[p], J[p], K[p]
        if res[i]==res[j]==res[k]==1:
            continue
        if res[i]==res[j]==1:
            res[k] = 0
        elif res[j]==res[k]==1:
            res[i] = 0
        elif res[k]==res[i]==1:
            res[j] = 0
    for i in range(a+b+c):
        print(res[i])

# Optimized solution
while 1:
    a, b, c = list(map(int, input().split()))
    if not a:
        break
    I = []
    res = [2]*(a+b+c)
    for p in range(int(input())):
        i, j, k, r = list(map(int, input().split()))
        i -= 1; j -= 1; k -= 1
        if r:
            res[i] = res[j] = res[k] = 1
        else:
            I.append((i, j, k))
    for e in I:
        i, j, k = e
        if res[i]+res[j]+res[k]!=4:
            continue
        if res[i]==2:
            res[i] = -1
        elif res[j]==2:
            res[j] = -1
        else:
            res[k] = -1
    for i in range(a+b+c):
        print(res[i] if res[i]>=0 else 0)
# Original solution
INT_MAX = (1<<31) - 1
_N,query_num = list(map(int, input().split()))
queries = [list(map(int, input().split())) for i in range(query_num)]
N = 1<<17

arr_size = 2*N - 1
A = [INT_MAX]*(arr_size)
lazy_A = [None]*(arr_size)

def tree_propagate(k):
    if(lazy_A[k] is None):
        return
    if(k < N // 2):
        A[k*2+1] = A[k*2+2] = lazy_A[k*2+1] = lazy_A[k*2+2] = lazy_A[k]
        lazy_A[k] = None
        return
    if(k < N-1):
        A[k*2+1] = A[k*2+2] = lazy_A[k]
        lazy_A[k] = None

def update(s,t,x,k,l,r):
    if (r <= s or t <= l):
        return
    if (s <= l and r <= t):
        A[k] = x
        if(k < N-1):
            lazy_A[k] = x
        return

    tree_propagate(k)
    center = (l+r)//2
    update(s, t, x, k*2 + 1, l, center)
    update(s, t, x, k*2 + 2, center, r)
    A[k] = min(A[k*2+1], A[k*2+2])

def find(s,t,k,l,r):
    if (r <= s or t <= l):
        return INT_MAX
    if(s <= l and r <= t):
        return A[k]

    tree_propagate(k)
    center = (l+r)//2
    v_left = find(s, t, k*2 + 1, l, center)
    v_right = find(s, t, k*2 + 2, center, r)
    return min(v_left,v_right)

answers = []
for query in queries:
    if(query[0]==0):
        update(query[1],query[2]+1,query[3],0,0,N)
    else:
        answers.append(find(query[1],query[2]+1,0,0,N))

print(("\n".join([str(ans) for ans in answers])))



# Optimized solution
INT_MAX = (1<<31) - 1
_N,query_num = list(map(int, input().split()))
queries = [list(map(int, input().split())) for i in range(query_num)]
N = 1<<17
N1 = N - 1
N2 = N1 // 2
arr_size = 2*N - 1
A = [INT_MAX]*(arr_size)
lazy_A = [-1]*(arr_size)

def tree_propagate(k):

    if(lazy_A[k] == -1):
        return

    if(k < N2):
        A[k*2+1] = A[k*2+2] = lazy_A[k*2+1] = lazy_A[k*2+2] = lazy_A[k]
        lazy_A[k] = -1
        return
    if(k < N1):
        A[k*2+1] = A[k*2+2] = lazy_A[k]
        lazy_A[k] = -1

def update(s,t,x,k,l,r):

    if (r <= s or t <= l):
        return
    if (s <= l and r <= t):
        A[k] = x
        if(k < N1):
            lazy_A[k] = x
        return

    tree_propagate(k)
    center = (l+r)//2
    update(s, t, x, k*2 + 1, l, center)
    update(s, t, x, k*2 + 2, center, r)

    A[k] = min(A[k*2+1], A[k*2+2])

def find(s,t,k,l,r):

    if (r <= s or t <= l):
        return INT_MAX

    if(s <= l and r <= t):
        return A[k]

    tree_propagate(k)
    center = (l+r)//2
    v_left = find(s, t, k*2 + 1, l, center)
    v_right = find(s, t, k*2 + 2, center, r)
    return min(v_left,v_right)

answers = []
for query in queries:
    if(query[0]==0):
        update(query[1],query[2]+1,query[3],0,0,N)
    else:
        answers.append(find(query[1],query[2]+1,0,0,N))

print(("\n".join([str(ans) for ans in answers])))
# Original solution
n, c = list(map(int, input().split()))
sushi = []
for i in range(n):
    x, v = list(map(int, input().split()))
    sushi.append((x, v))
sushi.sort()
sushi_reversed = list(reversed([(c - x, v) for x, v in sushi]))


# def solve(s, sr):
#     d = 0
#     v = 0
#     v_d_max = (0, 0)
#     v_2d_max = (0, 0)
#     conds = []

#     for x_i, v_i in s:
#         v = v + v_i - (x_i - d)
#         d = x_i
#         v_d_max = max(v_d_max, (v, d))
#         if v - d > v_2d_max[0]:
#             v_2d_max = (v - d, d)
#             conds.append((v - d, d))
#     return v_d_max, v_2d_max, conds

def solve(s, sr):
    d = 0
    v = 0
    v_2d_max = 0
    v_max = 0
    n = len(s)
    for i in range(n):
        x_i, v_i = s[i]
        v = v + v_i - (x_i - d)
        d = x_i
        v_max = max(v_max, v)
        if v - d > v_2d_max:
            v_2d_max = v - d
            v_sub = sub_solve(sr[:n - 1 - i])
            v_max = max(v_max, v_2d_max + v_sub)
    return v_max


def sub_solve(s):
    d = 0
    v = 0
    v_max = 0

    for x_i, v_i in s:
        v = v + v_i - (x_i - d)
        d = x_i
        v_max = max(v_max, v)
    return v_max

# l_v_d_max, l_v_2d_max, l_conds = solve(sushi, sushi_reversed)
# r_v_d_max, r_v_2d_max, r_conds = solve(sushi_reversed, sushi)
# print(l_v_d_max, l_v_2d_max, l_conds, r_v_d_max, r_v_2d_max, r_conds)

# max_v = max(l_v_d_max[0], r_v_d_max[0])
# if l_v_d_max[1] + r_v_2d_max[1] < c:
#     max_v = max(max_v, l_v_d_max[0] + r_v_2d_max[0])
# else:
#     for v, d in r_conds:
#         if l_v_d_max[1] + d < c:
#             max_v = max(max_v, l_v_d_max[0] + v)

# if l_v_2d_max[1] + r_v_d_max[1] < c:
#     max_v = max(max_v, l_v_2d_max[0] + r_v_d_max[0])
# else:
#     for v, d in l_conds:
#         if d + r_v_d_max[1] < c:
#             max_v = max(max_v, v + r_v_d_max[0])

# print(max_v)

# l_v_d_max, l_v_2d_max, l_conds = solve(sushi, sushi_reversed)
# r_v_d_max, r_v_2d_max, r_conds = solve(sushi_reversed, sushi)
# print(max_v)


l = solve(sushi, sushi_reversed)
r = solve(sushi_reversed, sushi)
print((max(solve(sushi, sushi_reversed), solve(sushi_reversed, sushi))))


# Optimized solution
n, c = list(map(int, input().split()))
sushi = []
for i in range(n):
    x, v = list(map(int, input().split()))
    sushi.append((x, v))
sushi.sort()
sushi_reversed = list(reversed([(c - x, v) for x, v in sushi]))


def accum_max(s):
    v = 0
    res = [(0, 0)]
    for x_i, v_i in s:
        v += v_i
        res.append(max(res[-1], (v-x_i, x_i)))
    return res[1:]


max_sushi = accum_max(sushi)
max_sushi_reversed = accum_max(sushi_reversed)


def solve(s, msr):
    v_max = 0
    v_2d_max = 0
    v = 0
    n = len(s)
    for i in range(n-1):
        x_i, v_i = s[i]
        v += v_i
        if v - x_i*2 > v_2d_max:
            v_2d_max = v - x_i*2
            v_sub = msr[n - 2 - i][0]
            v_max = max(v_max, v_2d_max + v_sub)
    return v_max


l = solve(sushi, max_sushi_reversed)
r = solve(sushi_reversed, max_sushi)
print((max(l, r, max_sushi[-1][0], max_sushi_reversed[-1][0])))
# Original solution
import sys
N,C = list(map(int,input().split()))
table=[]
for i in range(N):
    x,v=list(map(int,input().split()))
    table.append([x,v])
ans=0
if N==1:
    ans=max(0,table[0][1]-table[0][0],table[0][1]+table[0][0]-C)
    print(ans)
    sys.exit()
V=[0]*N
clo=[0]*N
V[0]=table[0][1]
clo[0]=V[0]-table[0][0]
for i in range(1,N):
    V[i]=V[i-1]+table[i][1]
    clo[i]=max(clo[i-1],V[i]-table[i][0])
    ans = max(clo[i],ans)
rclo=[0]*N
rclo[N-1]=V[N-1]-V[N-2]-C+table[N-1][0]
for i in range(N-1,1,-1):
    rclo[i-1]=max(rclo[i],V[N-1]-V[i-2]-C+table[i-1][0])
    ans = max(clo[i],ans)
rclo[0]=max(rclo[1],V[N-1]-C+table[0][0])
ans = max(rclo[0],ans)

for i in range(N-1):
    t = V[i]+rclo[i+1]-2*table[i][0]
    ans=max(t,ans)
for i in range(N-1,0,-1):
    t = V[N-1]-V[i-1] + clo[i-1]-2*C+2*table[i][0]
    ans=max(t,ans)

print(ans)




# Optimized solution
N,C = list(map(int,input().split()))
X=[]
V=[]
for i in range(N):
    x,v=list(map(int,input().split()))
    X.append(x)
    V.append(v)
#時計回りで見る
R=[0]*(N+1)#0番目は１に格納する
Rans=[0]*(N+1)
for i in range(N):
    R[i+1]=R[i]+V[i]
    Rans[i+1]=max(Rans[i],R[i+1]-X[i])
L=[0]*(N+1)
Lans=[0]*(N+1)
for i in range(N,0,-1):
    L[i-1]=L[i]+V[i-1]#N-1にN-1を格納
    Lans[i-1]=max(Lans[i],L[i-1]-C+X[i-1])
ans_1=max(Rans[N],Lans[0])
ans_2=max(Lans[i+1]+R[i+1]-2*X[i] for i in range(N))
ans_3=max(Rans[i-1]+L[i-1]-2*C+2*X[i-1] for i in range(N,0,-1))
print((max(ans_1,ans_2,ans_3)))
# Original solution
import sys
input=sys.stdin.readline

def main():
    N,C = list(map(int, input().split()))
    X = []
    for _ in range(N):
        X.append(list(map(int, input().split())))
    
    cw = [0] # 時計回りに数えて i 番目までを食べた時に摂取できるカロリー
    ccw = [0] # 反時計回り
    for i in range(N):
        cw.append(cw[i] + X[i][1])
        ccw.append(ccw[i] + X[N-1-i][1])
    for i in range(N):
        cw[i+1] -= X[i][0]
        ccw[i+1] -= C - X[N-1-i][0]
    ans = 0
    # i 番目で向きを変えて、j 番目まで食べる場合を全探索
    # O(n^2) なのでアカンか…？
    for i in range(N+1):
        cwccw = cw[i]
        ccwcw = ccw[i]
        if i > 0:
            cwccw -= X[i-1][0] # 原点に戻るコスト
            ccwcw -= C - X[N-i][0]
        for j in range(N+1-i):
            ans = max(ans, cwccw + ccw[j])
            ans = max(ans, ccwcw + cw[j])

    print(ans)

if __name__ == '__main__':
    main()


# Optimized solution
import sys
input=sys.stdin.readline

def main():
    N,C = list(map(int, input().split()))
    X = []
    for _ in range(N):
        X.append(list(map(int, input().split())))
    
    cw = [0] # 時計回りに数えて i 番目までを食べた時に摂取できるカロリー
    ccw = [0] # 反時計回り
    for i in range(N):
        cw.append(cw[i] + X[i][1])
        ccw.append(ccw[i] + X[N-1-i][1])
    for i in range(N):
        cw[i+1] -= X[i][0]
        ccw[i+1] -= C - X[N-1-i][0]

    ma = 0
    ga = []
    for i in range(0, N+1):
        ma = max(ma, cw[i])
        ga.append(ma)
    ma = 0
    gb = []
    for i in range(0, N+1):
        ma = max(ma, ccw[i])
        gb.append(ma)

    ans = 0
    for bi in range(N+1):
        tmp = ccw[bi] + ga[N-bi]
        if bi > 0:
            tmp -= C - X[N-bi][0]
        ans = max(ans, tmp)

    for ai in range(N+1):
        tmp = cw[ai] + gb[N-ai]
        if ai > 0:
            tmp -= X[ai-1][0]
        ans = max(ans, tmp)

    print(ans)

if __name__ == '__main__':
    main()
# Original solution
N, C = list(map(int, input().split()))
xs = []
vs = []
for i in range(N):
    x, v = list(map(int, input().split()))
    xs += [x]
    vs += [v]

sumVtos = [vs[0]]
for i in range(1, N):
    sumVtos += [sumVtos[-1] + vs[i]]

sumV = sumVtos[-1]
sumVfrs = [sumV]
for i in range(1, N):
    sumVfrs += [sumVfrs[-1] - vs[i - 1]]

# 初手：時計回り
ans = 0
for i in range(N):
    ans1 = sumVtos[i] - xs[i]

    # 2手目：反時計回り
    ans2 = 0
    for j in range(i + 1, N):
        ans2 = max(ans2, sumVfrs[j] - (xs[i] + C - xs[j]))

    ans = max(ans, ans1 + ans2)

# 初手：反時計回り
for i in range(N):
    ans1 = sumVfrs[i] - (C - xs[i])

    # 2手目：時計回り
    ans2 = 0
    for j in range(i):
        ans2 = max(ans2, sumVtos[j] - (C - xs[i] + xs[j]))

    ans = max(ans, ans1 + ans2)

print(ans)


# Optimized solution
N, C = list(map(int, input().split()))
xs = []
vs = []
for i in range(N):
    x, v = list(map(int, input().split()))
    xs += [x]
    vs += [v]


fAs = [0] * N
fAs[0] = vs[0]
for A in range(1, N):
    fAs[A] = fAs[A - 1] + vs[A]
for A in range(N):
    fAs[A] -= xs[A]

gAs = [0] * N
gAs[0] = 0
for A in range(1, N):
    gAs[A] = max(gAs[A - 1], fAs[A - 1])


fBs = [0] * N
fBs[N - 1] = vs[N - 1]
for B in range(0, N - 1)[::-1]:
    fBs[B] = fBs[B + 1] + vs[B]

for B in range(N):
    fBs[B] -= C - xs[B]

gBs = [0] * N
gBs[N - 1] = 0
for B in range(0, N - 1)[::-1]:
    gBs[B] = max(gBs[B + 1], fBs[B + 1])


ans = 0

# 初手：時計回り
for A in range(N):
    ans1 = fAs[A]

    # 2手目：反時計回り
    ans2 = max(0, gBs[A] - xs[A])

    ans = max(ans, ans1 + ans2)


# 初手：反時計回り
for B in range(N):
    ans1 = fBs[B]

    # 2手目：時計回り
    ans2 = max(0, gAs[B] - (C - xs[B]))

    ans = max(ans, ans1 + ans2)

print(ans)