CodeEff/ECCO huggingface dataset:
# Original solution
l=list(map(int,input().split()))
c=0
if 1 in l:c+=1
if 9 in l:c+=1
if 7 in l:c+=1
if 4 in l:c+=1
if c==4:print('YES')
else:print('NO')

# Optimized solution
l=list(map(int,input().split()))
if 1 in l and 9 in l and 7 in l and 4 in l:print('YES')
else:print('NO')
# Original solution
def resolve():
   l=list(map(int, input().split()))
   a=l.count(1)
   b=l.count(9)
   c=l.count(7)
   d=l.count(4)
   if a==b==c==d==1:
       print('YES')
   else:
       print('NO')
resolve()

# Optimized solution
def resolve():
   l=list(map(int, input().split()))
   l.sort()
   if l==[1,4,7,9]:
       print('YES')
   else:
       print('NO')
resolve()
# Original solution
l = set([int(e) for e in input().split()])
set_1974 = set([1,9,7,4])

if l == set_1974:
  print("YES")
else:
  print("NO")

# Optimized solution
l = {int(e) for e in input().split()}
set_1974 = {1,9,7,4}

if l == set_1974:
  print("YES")
else:
  print("NO")
# Original solution
N = [int(_) for _ in input().split()]

if 1 in N and 9 in N and 7 in N and 4 in N:
    print("YES")
else:
    print("NO")

# Optimized solution
N = [int(_) for _ in input().split()]

N.sort()
if N == [1, 4, 7, 9]:
    print("YES")
else:
    print("NO")
# Original solution
def slove():
    import sys
    input = sys.stdin.readline
    a = list(map(str, str(input().rstrip('\n')).split()))
    a.sort()
    print(("YES" if "".join(a) == "1479" else "NO"))


if __name__ == '__main__':
    slove()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = sorted(list(map(str, readline().rstrip().decode('utf-8').split())))
    print(("YES" if n == sorted("1974") else "NO"))


if __name__ == '__main__':
    solve()
# Original solution
n = list(map(int,input().split()))
n.sort()
if(n[0]==1 and n[1]==4 and n[2]==7 and n[3]==9):
  print("YES")
else:
  print("NO")

# Optimized solution
li = list(map(int,input().split()))
if 1 in li and 4 in li and 7 in li and 9 in li:
    print("YES")
else:
    print("NO")
# Original solution
n = list(map(int,input().split()))
n.sort()
if n == [1,4,7,9]:
  print("YES")
else:
  print("NO")

# Optimized solution
print(("YES" if sorted(map(int,input().split())) == [1,4,7,9] else "NO"))
# Original solution
#!/usr/bin/python

import sys

def solve(s):
    count = 0
    len_s = len(s)
    l = len_s // 2
    for i in range(l):
        if s[i] != s[len_s -1 -i]:
            count += 1

    print(count)

if __name__ == '__main__':
    s = sys.stdin.readline().strip()
    solve(s)

# Optimized solution
import sys

S = sys.stdin.readline().strip()
ls = len(S)

ans = 0
h = ls // 2
for i in range(h):
    if S[i] != S[ls - 1 - i]:
        ans += 1

print(ans)
# Original solution

import sys
import math
def resolve():
    S=list(input().rstrip())
    c=0
    for i in range(math.floor(len(S)/2)):
        if(S[i]!=S[len(S)-i-1]):
            c+=1
    print(c)

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """redcoder"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """vvvvvv"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """abcdabc"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

# Optimized solution

import sys
import math
def resolve():
    S=input().rstrip()
    c=0
    for i in range((len(S)//2)):
        if(S[i]!=S[-i-1]):
            c+=1
    print(c)

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """redcoder"""
        output = """1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """vvvvvv"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """abcdabc"""
        output = """2"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()
# Original solution
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str):
    sl = list(S)
    rs = sl[::-1]
    
    from math import ceil
    print((ceil([sl[i] != rs[i] for i in range(len(S))].count(True)/2)))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(S: str):
    print(([S[i] != S[::-1][i] for i in range(len(S))].count(True)//2))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
# Original solution
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    r = len(s)
    res = 0
    for i in range(r//2):
        if s[i] != s[-(i+1)]:
            res += 1
    print(res)



if __name__ == '__main__':
    main()

# Optimized solution
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    res = 0
    ss = s[::-1]
    for i in range(len(s)):
        if s[i] != ss[i]:
            res += 1
    print((res//2))

if __name__ == '__main__':
    main()
# Original solution
#参考
#https://atcoder.jp/contests/aising2019/submissions/3995168

import bisect

N,Q=list(map(int,input().split()))

A=list(map(int,input().split()))
Asum=[0]*N
Asum2=[0]*N
total=0

for i in range(N):
  total+=A[i]
  Asum[i]=total
  if i>1:
    Asum2[i]=A[i]+Asum2[i-2]
  else:
    Asum2[i]=A[i]

X=[] 
for i in range(Q):
  X.append((int(eval(input())),i))
X.sort(key=lambda x :x[0])
  

#yで高橋くんと青木くんの取りたいカードが初めて衝突すると考える。
#このようなyは半分より小さい所にはないので初期値を半分のところとする。
#yがNまで来た時は最初から交互に取る
#Xを小さい順から計算することで、yの値が単調増加になる
y=N//2-1
ans=[0]*Q
for x,i in X:
  while y<=N-1 and x>A[y]:
    y+=1
  while y<=N-1:
    takahashi=N-y
    aoki=y+1-bisect.bisect_left(A,x-(A[y]-x))
    if takahashi>aoki:
      y+=1
    else:
      break
  #右端からA[y]までは全て高橋くんが取る
  ans[i]+=Asum[N-1]-Asum[y-1]
  #青木くんはyからN-y個取っているので、その下のところから交互に取る
  if y-(N-y)-1<0:
    continue
  ans[i]+=Asum2[y-(N-y)-1]

for i in range(Q):
  print((ans[i]))

# Optimized solution
#参考
#https://atcoder.jp/contests/aising2019/submissions/3995168
 
import bisect
 
N,Q=list(map(int,input().split()))
 
A=list(map(int,input().split()))
Asum=[0]*N
Asum2=[0]*N
total=0
 
for i in range(N):
  total+=A[i]
  Asum[i]=total
  if i>1:
    Asum2[i]=A[i]+Asum2[i-2]
  else:
    Asum2[i]=A[i]
 
X=[] 
for i in range(Q):
  X.append((int(eval(input())),i))
X.sort(key=lambda x :x[0])
  
 
#yで高橋くんと青木くんの取りたいカードが初めて衝突すると考える。
#このようなyは半分より小さい所にはないので初期値を半分のところとする。
#yがNまで来た時は最初から交互に取る
#Xを小さい順から計算することで、yの値が単調増加になる
y=N//2-1
ans=[0]*Q
for x,i in X:
  #条件式はy<=N-1を最初に持ってこないとA[y]の参照でエラーの可能性
  while y<=N-1 and x>A[y]:
    y+=1
  while y<=N-1:
    takahashi=N-y
    aoki=y+1-bisect.bisect_left(A,x-(A[y]-x))
    if takahashi>aoki:
      y+=1
    else:
      break
  #右端からA[y]までは全て高橋くんが取る
  ans[i]+=Asum[N-1]-Asum[y-1]
  #青木くんはyからN-y個取っているので、その下のところから交互に取る
  if y-(N-y)-1<0:
    continue
  ans[i]+=Asum2[y-(N-y)-1]
 
for i in range(Q):
  print((ans[i]))
# Original solution
import sys
input = sys.stdin.readline
from collections import *
from bisect import *

def judge(x):
    tak = N-x
    aoki = x-bisect_left(A, 2*X-A[x])+1
    
    return tak<=aoki

def binary_search():
    l, r = mark, N-1
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            r = m-1
        else:
            l = m+1
    
    return l

N, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
acc = [0]
acc_e = [0]

for i in range(N):
    acc.append(acc[-1]+A[i])
    acc_e.append(acc_e[-1]+(A[i] if i%2==0 else 0))

for _ in range(Q):
    X = int(eval(input()))
    mark = bisect_left(A, X)
    border = binary_search()
    ans = acc[-1]-acc[border]
    c = N-border
    
    if 2*c>=N:
        print(ans)
        continue
    
    if (N-2*c-1)%2==0:
        ans += acc_e[N-2*c]
    else:
        ans += acc[N-2*c]-acc_e[N-2*c]
    
    print(ans)

# Optimized solution
import sys
input = sys.stdin.readline
from collections import *
from bisect import *

def judge(x):
    aoki = N-x-bisect_left(A, 2*X-A[N-x])+1
    return x<=aoki
    
def binary_search():
    l, r = 1, N-bisect_left(A, X)
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            l = m+1
        else:
            r = m-1
    
    return r

N, Q = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
acc = [0]
acco = [0]

for i in range(N):
    acc.append(acc[-1]+A[i])
    
    if i%2==1:
        acco.append(acco[-1]+A[i])
    else:
        acco.append(acco[-1])

for _ in range(Q):
    X = int(eval(input()))
    x = binary_search()
    ans = acc[N]-acc[N-x]
    
    if N-2*x>0:
        if (N-2*x)%2==0:
            ans += acco[N-2*x]
        else:
            ans += acc[N-2*x]-acco[N-2*x]
        
    print(ans)
# Original solution
import bisect
INF = 10**12
n, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

# Calc cumrative sum
sum_even = [0] * (n + 1)
sum_odd = [0] * (n + 1)
sum_all = [0] * (n + 1)
for i, item in enumerate(a):
    if i % 2 == 0:
        sum_odd[i+1] = sum_odd[i] + a[i]
        sum_even[i+1] = sum_even[i]
    else:
        sum_even[i+1] = sum_even[i] + a[i]
        sum_odd[i+1] = sum_odd[i]
    sum_all[i+1] = sum_all[i] + a[i]

# Iterate in query
a.append(INF)
for i in range(q):
    # Get div of aoki - takahashi
    x = int(eval(input()))
    big = bisect.bisect_left(a, x)
    small = big - 1
    if (x - a[small]) ** 2 <= (x - a[big]) ** 2:
        l = small
    else:
        l = big
    r = n - 1
    while r - l > 1:
        m = (r + l) // 2
        rng = abs(x - a[m])
        taka = n - m
        aoki = n - taka - (bisect.bisect_left(a, x - rng))
        if taka <= aoki + 1:
            r = m
        else:
            l = m
    rng = abs(x - a[r])
    taka = n - r
    aoki = n - taka - (bisect.bisect_left(a, x - rng))
    taka_sum = sum_all[n] - sum_all[n - taka]
    aoki_sum = sum_all[r] - sum_all[r - taka]
    rest = n - taka * 2
    if rest > 0:
        if rest % 2 == 0:
            taka_sum += sum_even[rest]
            aoki_sum += sum_odd[rest]
        else:
            taka_sum += sum_odd[rest]
            aoki_sum += sum_even[rest]

    print(taka_sum)

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

INF = 10**12
n, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

# Calc cumrative sum
sum_even = [0] * (n + 1)
sum_odd = [0] * (n + 1)
sum_all = [0] * (n + 1)
for i, item in enumerate(a):
    if i % 2 == 0:
        sum_odd[i+1] = sum_odd[i] + a[i]
        sum_even[i+1] = sum_even[i]
    else:
        sum_even[i+1] = sum_even[i] + a[i]
        sum_odd[i+1] = sum_odd[i]
    sum_all[i+1] = sum_all[i] + a[i]

# Iterate in query
a.append(INF)
ans = []
for i in range(q):
    # Get div of aoki - takahashi
    x = int(eval(input()))
    big = bisect.bisect_left(a, x)
    small = big - 1
    if (x - a[small]) ** 2 <= (x - a[big]) ** 2:
        l = small
    else:
        l = big
    r = n - 1
    while r - l > 1:
        m = (r + l) // 2
        rng = abs(x - a[m])
        taka = n - m
        aoki = n - taka - (bisect.bisect_left(a, x - rng))
        if taka <= aoki + 1:
            r = m
        else:
            l = m
    rng = abs(x - a[r])
    taka = n - r
    aoki = n - taka - (bisect.bisect_left(a, x - rng))
    taka_sum = sum_all[n] - sum_all[n - taka]
    aoki_sum = sum_all[r] - sum_all[r - taka]
    rest = n - taka * 2
    if rest > 0:
        if rest % 2 == 0:
            taka_sum += sum_even[rest]
            aoki_sum += sum_odd[rest]
        else:
            taka_sum += sum_odd[rest]
            aoki_sum += sum_even[rest]

    ans.append(taka_sum)
print(("\n".join([str(item) for item in ans])))
# Original solution
import bisect
import sys
input = sys.stdin.readline

INF = 10**12
n, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

# Calc cumrative sum
sum_even = [0] * (n + 1)
sum_odd = [0] * (n + 1)
sum_all = [0] * (n + 1)
for i, item in enumerate(a):
    if i % 2 == 0:
        sum_odd[i+1] = sum_odd[i] + a[i]
        sum_even[i+1] = sum_even[i]
    else:
        sum_even[i+1] = sum_even[i] + a[i]
        sum_odd[i+1] = sum_odd[i]
    sum_all[i+1] = sum_all[i] + a[i]

# Iterate in query
a.append(INF)
ans = []
for i in range(q):
    # Get div of aoki - takahashi
    x = int(eval(input()))
    big = bisect.bisect_left(a, x)
    small = big - 1
    if (x - a[small]) ** 2 <= (x - a[big]) ** 2:
        l = small
    else:
        l = big
    r = n - 1
    while r - l > 1:
        m = (r + l) // 2
        rng = abs(x - a[m])
        taka = n - m
        aoki = n - taka - (bisect.bisect_left(a, x - rng))
        if taka <= aoki + 1:
            r = m
        else:
            l = m
    rng = abs(x - a[r])
    taka = n - r
    aoki = n - taka - (bisect.bisect_left(a, x - rng))
    taka_sum = sum_all[n] - sum_all[n - taka]
    aoki_sum = sum_all[r] - sum_all[r - taka]
    rest = n - taka * 2
    if rest > 0:
        if rest % 2 == 0:
            taka_sum += sum_even[rest]
            aoki_sum += sum_odd[rest]
        else:
            taka_sum += sum_odd[rest]
            aoki_sum += sum_even[rest]

    ans.append(taka_sum)
print(("\n".join([str(item) for item in ans])))

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

INF = 10**12
n, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

# Calc cumrative sum
sum_even = [0] * (n + 1)
sum_odd = [0] * (n + 1)
sum_all = [0] * (n + 1)
for i, item in enumerate(a):
    if i % 2 == 0:
        sum_odd[i+1] = sum_odd[i] + a[i]
        sum_even[i+1] = sum_even[i]
    else:
        sum_even[i+1] = sum_even[i] + a[i]
        sum_odd[i+1] = sum_odd[i]
    sum_all[i+1] = sum_all[i] + a[i]

# Iterate in query
a.append(INF)
ans = []
for i in range(q):
    # Get div of aoki - takahashi
    x = int(eval(input()))
    l = 0
    r = n - 1
    # l: aoki takes, r: takahashi takes
    while r - l > 1:
        m = (r + l) // 2
        rng = abs(x - a[m])
        t_num = n - m
        a_num = n - t_num - (bisect.bisect_left(a, x - rng))
        if t_num <= a_num + 1:
            r = m
        else:
            l = m
    rng = abs(x - a[r])
    t_num = n - r
    rest = n - 2 * t_num
    t_sum = sum_all[n] - sum_all[n - t_num]
    a_sum = sum_all[r] - sum_all[r - t_num]

    # Add stripe area
    if n - t_num * 2 > 0:
        if rest % 2 == 0:
            t_sum += sum_even[rest]
            a_sum += sum_odd[rest]
        else:
            t_sum += sum_odd[rest]
            a_sum += sum_even[rest]
    ans.append(t_sum)

print(("\n".join([str(item) for item in ans])))
# Original solution
import bisect
import sys
input = sys.stdin.readline

INF = 10**12
n, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

# Calc cumrative sum
sum_even = [0] * (n + 1)
sum_odd = [0] * (n + 1)
sum_all = [0] * (n + 1)
for i, item in enumerate(a):
    if i % 2 == 0:
        sum_odd[i+1] = sum_odd[i] + a[i]
        sum_even[i+1] = sum_even[i]
    else:
        sum_even[i+1] = sum_even[i] + a[i]
        sum_odd[i+1] = sum_odd[i]
    sum_all[i+1] = sum_all[i] + a[i]

# Iterate in query
a.append(INF)
ans = []
for i in range(q):
    # Get div of aoki - takahashi
    x = int(eval(input()))
    l = 0
    r = n - 1
    # l: aoki takes, r: takahashi takes
    while r - l > 1:
        m = (r + l) // 2
        rng = abs(x - a[m])
        t_num = n - m
        a_num = n - t_num - (bisect.bisect_left(a, x - rng))
        if t_num <= a_num + 1:
            r = m
        else:
            l = m
    rng = abs(x - a[r])
    t_num = n - r
    rest = n - 2 * t_num
    t_sum = sum_all[n] - sum_all[n - t_num]
    a_sum = sum_all[r] - sum_all[r - t_num]

    # Add stripe area
    if n - t_num * 2 > 0:
        if rest % 2 == 0:
            t_sum += sum_even[rest]
            a_sum += sum_odd[rest]
        else:
            t_sum += sum_odd[rest]
            a_sum += sum_even[rest]
    ans.append(t_sum)

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

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

INF = 10**12
n, q = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

# Calc cumrative sum
sum_even = [0] * (n + 1)
sum_odd = [0] * (n + 1)
sum_all = [0] * (n + 1)
for i, item in enumerate(a):
    if i % 2 == 0:
        sum_odd[i+1] = sum_odd[i] + a[i]
        sum_even[i+1] = sum_even[i]
    else:
        sum_even[i+1] = sum_even[i] + a[i]
        sum_odd[i+1] = sum_odd[i]
    sum_all[i+1] = sum_all[i] + a[i]

# Iterate in query
a.append(INF)
ans = []
for i in range(q):
    x = int(eval(input()))
    # Get div of aoki - takahashi
    # l: aoki takes, r: takahashi takes
    l = 0; r = n - 1
    while r - l > 1:
        m = (r + l) // 2
        rng = abs(x - a[m])
        t_num = n - m
        a_num = n - t_num - (bisect.bisect_left(a, x - rng))
        if t_num <= a_num + 1:
            r = m
        else:
            l = m
    rng = abs(x - a[r])
    t_num = n - r
    rest = n - 2 * t_num
    t_sum = sum_all[n] - sum_all[n - t_num]
    a_sum = sum_all[r] - sum_all[r - t_num]

    # Add stripe area
    if n - t_num * 2 > 0:
        if rest % 2 == 0:
            t_sum += sum_even[rest]
            a_sum += sum_odd[rest]
        else:
            t_sum += sum_odd[rest]
            a_sum += sum_even[rest]
    ans.append(t_sum)

print(("\n".join([str(item) for item in ans])))
# Original solution
from bisect import *
n,q = list(map(int,input().split()))
A = list(map(int,input().split()))
every2 = [[0]*(n//2 + 2) for _ in range(2)]
right = [0]*(n+1)

for i in range(n):
    odd = i&1
    every2[odd][i//2 + 1] = every2[odd][i//2] + A[i]
    right[i+1] = right[i] + A[-i-1]
# ans = [0]*q

def ok(y,x):
    M = A[-y]
    if M <= x:return False
    d = M - x
    m = x - d
    return bisect_left(A,m)+2*y-1 <= n

for i in range(q):
    X = int(eval(input()))
    W = bisect_right(A,X)
    top = n - W + 1
    bottom = 1
    while top - bottom > 1:
        mid = (top + bottom)//2
        if ok(mid,X):
            bottom = mid
        else:
            top = mid
    ans = right[bottom] + every2[1 - (n&1)][(n-1)//2 + 1 - bottom]
    print(ans)
# print('\n'.join(ans))


# Optimized solution
from bisect import *
import sys
input = sys.stdin.readline
n,q = list(map(int,input().split()))
A = list(map(int,input().split()))
every2 = [[0]*(n//2 + 2) for _ in range(2)]
right = [0]*(n+1)

for i in range(n):
    odd = i&1
    every2[odd][i//2 + 1] = every2[odd][i//2] + A[i]
    right[i+1] = right[i] + A[-i-1]
# ans = [0]*q

def ok(y,x):
    M = A[-y]
    if M <= x:return False
    d = M - x
    m = x - d
    return bisect_left(A,m)+2*y-1 <= n

for i in range(q):
    X = int(eval(input()))
    W = bisect_right(A,X)
    top = n - W + 1
    bottom = 1
    while top - bottom > 1:
        mid = (top + bottom)//2
        if ok(mid,X):
            bottom = mid
        else:
            top = mid
    ans = right[bottom] + every2[1 - (n&1)][(n-1)//2 + 1 - bottom]
    print(ans)
# print('\n'.join(ans))
# Original solution
from itertools import accumulate,zip_longest
from functools import reduce
import bisect
import sys
input = sys.stdin.readline

N,Q = list(map(int,input().split()))
A = list(map(int,input().split()))
X = [int(eval(input())) for i in range(Q)]

B = [2*a+1 for a in A] # right
A = [2*a for a in A] # left
X = [2*x for x in X]

S = list(accumulate(A))
T0 = accumulate(A[::2])
T1 = accumulate(A[1::2])
T = list(reduce(lambda x,y : x+y, zip_longest(T0,T1)))
if T[-1] is None:
    T.pop()

maxhigh = 10**16
for x in X:
    if x > (A[-1]+A[-2])//2:
        print((T[-1]//2))
        continue
    NG = maxhigh
    OK = 0
    R = OK
    ans = 0
    while True:
        l = x - R
        r = x + R
        li = bisect.bisect_left(A,l)
        ri = bisect.bisect_right(B,r)
        #print(l,r,li,ri)
        M = ri-li
        if ri == N-M:
            if li > 0:
                ans += T[li-1]
            break
        if ri == N-M-1:
            #print("HER",li,ri)
            li -= 1
            if li > 0:
                ans += T[li-1]
            break
        if ri < N-M:
            OK = R
            R = (R + NG)//2
        if N-M < ri:
            NG = R
            R = (R + OK)//2
        #print(l,x,r,li,ri,OK,"R",R,NG)
    #print(l,x,r,li,ri,OK,R,NG)
    if ri > 0:
        ans += S[N-1] - S[ri-1]
    else:
        ans += S[N-1]
    print((ans//2))



# Optimized solution
from itertools import accumulate,zip_longest
from functools import reduce
import bisect
import sys
input = sys.stdin.readline

N,Q = list(map(int,input().split()))
A = list(map(int,input().split()))
X = [int(eval(input())) for i in range(Q)]

B = [2*a+1 for a in A] # right
A = [2*a for a in A] # left
X = [2*x for x in X]

S = list(accumulate(A))
T0 = accumulate(A[::2])
T1 = accumulate(A[1::2])
T = []
for s,t in zip_longest(T0,T1):
    T.append(s)
    T.append(t)
if T[-1] is None:
    T.pop()

maxhigh = 10**16
for x in X:
    if x > (A[-1]+A[-2])//2:
        print((T[-1]//2))
        continue
    NG = maxhigh
    OK = 0
    R = OK
    ans = 0
    while True:
        l = x - R
        r = x + R
        li = bisect.bisect_left(A,l)
        ri = bisect.bisect_right(B,r)
        M = ri-li
        if ri == N-M:
            if li > 0:
                ans += T[li-1]
            break
        if ri == N-M-1:
            li -= 1
            if li > 0:
                ans += T[li-1]
            break
        if ri < N-M:
            OK = R
            R = (R + NG)//2
        if N-M < ri:
            NG = R
            R = (R + OK)//2
    if ri > 0:
        ans += S[N-1] - S[ri-1]
    else:
        ans += S[N-1]
    print((ans//2))