peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import sys
input = sys.stdin.readline
from collections import *

N, P = map(int, input().split())
A = list(map(int, input().split()))
dp = [[0]*2 for _ in range(N+1)]
dp[0][0] = 1

for i in range(N):
    if A[i]%2==0:
        dp[i+1][0] = 2*dp[i][0]
        dp[i+1][1] = 2*dp[i][1]
    else:
        dp[i+1][0] = dp[i][0]+dp[i][1]
        dp[i+1][1] = dp[i][0]+dp[i][1]

print(dp[N][P])
# Judge status: Wrong Answer
H,N=map(int,input().split())
ab=[list(map(int,input().split()))for _ in range(N)]
ab.sort()

ans=[10**9]*(H+1)
ans[0]=0
i=0
while i<=H:
    pc=0
    for a,b in ab:
        if a+i>H:
            a=H-i
            pc+=1
        if ans[i+a]>ans[i]+b:
            ans[i+a]=ans[i]+b
        for _ in range(pc):
            ab.pop()
    i+=1

print(ans[H])
# Judge status: Accepted
a = int(input())
S = input()
b = 0
c = 0 
for i in range(a):
  if S[i]=='I':
    b += 1
  else:
    b -= 1
  c = max(c,b)
print(c)
# Judge status: Wrong Answer
s = input()
len_s = len(s)
cnt = 0
for i in range(1,200000//2019 + 1):
    a = str(2019*i)
    len_a = len(a)
    for j in range(len_s - len_a + 1):
        cnt += s.count(a, j, j+len_a)
print(cnt)
# Judge status: Accepted
import bisect,collections,copy,heapq,itertools,math,string
import sys
def li(): return map(int,sys.stdin.readline().rstrip().split())
def lf(): return map(float,sys.stdin.readline().rstrip().split())
def ls(): return sys.stdin.readline().rstrip().split()

n, k = li()
a = list(li())
print(math.ceil((n-1)/(k-1)))
# Judge status: Wrong Answer
l, r, d = map(int, input().split())
a = l // d
b = r // d
print(b-a)
# Judge status: Wrong Answer
x = input()
if x == 1:
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
n = int(input())
people = [int(input()) for _ in range(5)]
print(5 + n // min(people))
# Judge status: Accepted
n,p=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=a[i]%2
one=sum(a)
zero=n-one
if p==1 and one==0:
    print(0)
    exit()
if p==0 and one==0:
    print(2**n)
    exit()
print(2**(n-1))
# Judge status: Accepted
n,a,b = map(int,input().split())
ans = n // (a+b) * a
if n % (a+b) <= a:
    ans +=  n % (a+b)
else:
    ans += a
print(ans)
# Judge status: Wrong Answer
import sys
from bisect import bisect_left, bisect_right

n = int(sys.stdin.buffer.readline())
a = list(map(int, sys.stdin.buffer.readline().split()))
b = list(map(int, sys.stdin.buffer.readline().split()))
c = list(map(int, sys.stdin.buffer.readline().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for j in b:
    ans += (n - bisect_right(c, j))*bisect_right(a, j)
print(ans)
# Judge status: Accepted
a = list(input())
b = list(input())
f = False
x = []
if len(a)> len(b):
    b.append(0)
    f = True
for i in range(len(a)):
    x.append(a[i])
    x.append(b[i])
if f:
    x.pop()
print("".join(x))
# Judge status: Accepted
a,v,b,w,t=map(int,open(0).read().split())
print('YNEOS'[abs(b-a)>(v-w)*t::2])
# Judge status: Accepted
# -*- coding: utf-8 -*-
s = input()
t = input()
id = s + t[-1:]

if t == id:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
from itertools import combinations_with_replacement as cwd

N, M, Q = map(int, input().split())
A = list(cwd(range(1, M + 1), N))
ABCD = []

for i in range(Q):
    a, b, c, d = map(int, input().split())
    a, b = a - 1, b - 1
    ABCD.append([a, b, c, d])

res = 0
for i in A:
    tmp = 0
    for j in ABCD:
        if i[j[1]] - i[j[0]] == j[2]:
            tmp += j[3]
    res = max(res, tmp)

print(A)
# Judge status: Accepted
S = input()
if S[0] == 'R' and S[1] == 'R' and S[2] == 'R':
    print(3)
elif (S[0] == 'R' and S[1] == 'R') or (S[1] == 'R' and S[2] == 'R'):
    print(2)
elif S[0] == 'R' or S[1] == 'R' or S[2] == 'R' or (S[0] == 'R'
                                                   and S[2] == 'R'):
    print(1)
else:
    print(0)
# Judge status: Accepted
if __name__ == "__main__":
    s = input()
    n = len(s)//2
    sf = s[0:n]
    sb = s[n+1:n]
    if s == s[::-1] and sf == sf[::-1] and sb == sb[::-1]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
A, B = map(int, input().split())
S = input()

if(S[A] == "-"):
    S = S[:A] + S[A+1:]
    if(S.isdecimal()):
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
N=int(input())
a=list(map(int,input().split()))
ad=dict()
ans=0
for i in range(len(a)):
	if a[i] in ad:
		ad[a[i]]+=1
	else:
		ad[a[i]]=1
for i in range(min(ad),max(ad)+1):
	tmp=0
	if i in ad:
		tmp+=ad[i]
	if i-1 in ad:
		tmp+=ad[i-1]
	if i+1 in ad:
		tmp+=ad[i+1]
	if tmp>ans:
		ans=tmp
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
print(min(M // 2, (2 * N + M) // 4))
# Judge status: Accepted
l = int(input())
print((l / 3) ** 3)
# Judge status: Wrong Answer
from collections import *
from operator import mul

n = int(input())
A = list(map(int, input().split()))
q = int(input())


A_dic = Counter(A)
A_sum = sum(A)

for _ in range(q):
    b, c = map(int, input().split())
    tmp = A_dic[b]
    A_dic[c] += tmp
    A_dic[b] = 0
    A_sum += c*A_dic[c] - b*tmp
    print(A_sum)
# Judge status: Accepted
N,X=map(int,input().split())
a=list(map(int,input().split()))
total=sum(a)
if a[0]>X:
    a[0]=X
for i in range(N-1):
    if a[i]+a[i+1]>X:
        a[i+1]=X-a[i]
print(total-sum(a))
# Judge status: Wrong Answer
from math import floor
n=int(input())
b=input().split()
a=[0 for i in range(n+1)]
for i in range(1,n+1):
  a[i]=int(b[i-1])

a[0]=10000000000

m=floor((n-2)/2)

a=sorted(a,reverse=True)

comfort=a[1]
if(n==2):
  print(comfort)
else:
  if(n%2 ==0):
    for i in range(2,m+2):
      comfort+=(2*a[i])
  else:
    for i in range(2,m+2):
      comfort+=(2*a[i])

    comfort+=a[m+2]

print(comfort)
# Judge status: Accepted
N, M = map(int,input().split())

A = list(map(int,input().split()))
A.pop(0)

for _ in range(N-1):
    K = set(list(map(int,input().split()))[1:])
    A = set(A) & K

print(len(A))
# Judge status: Accepted
def resolve():

    X,Y=map(int,input().split())
    cnt=0
    while X<=Y:
        X=X*2
        cnt+=1
    print(cnt)


resolve()
# Judge status: Accepted
n = int(input())
s = list(map(int,input().split()))

s.sort()
flg = True
for i in range(n-1):
    if s[i] == s[i+1]:
        flg = False
        break

if flg:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
import numpy as np
n = int(input())
a = []
b = []
for _ in range(n):
    i = list(map(int, input().split()))
    a.append(i[0])
    b.append(i[1])
a.sort()
b.sort()
a = np.cumsum(np.array(a))
for i in range(n):
    if a[i] > b[i]:
        print("No")
        break
else:
    print("Yes")
# Judge status: Wrong Answer
a,b,x = list(map(int,input().split()))

ans=0
if a!=b:
    A = (a-1)//x
    B = b//x

    ans = B - A
elif a==0 and b==0:
    ans=1

print(ans)
# Judge status: Accepted
n = int(input())
print(n*800-(n//15)*200)
# Judge status: Wrong Answer
import heapq

n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(a[min(n, m):])
a = a[:min(n, m)]
a = [x*(-1) for x in a]
heapq.heapify(a)

for i in range(m):
    c = (heapq.heappop(a)*(-1)//2)*(-1)
    heapq.heappush(a, c)
print(ans-sum(a))
# Judge status: Wrong Answer
import math

input = str(input()).split(" ")
for index in range(len(input)):
    input[index] = int(input[index])
x = input[0]
y = input[1]

def test(x, y):
    for index in range(math.floor(y/x), abs(y)):
        if (x * index % y != 0 and abs(x * index) <= 10**(18)):
            return x * index
    return -1
print(test(x,y))
# Judge status: Accepted
import math
a,b=map(int,input().split())
gou=((a+b)/2)
print(math.ceil(gou))
# Judge status: Accepted
N=int(input())
X=[[0,0]]*N
for i in range(N):
    X[i]=list(map(int,input().split()))
X.sort()
right=X[0][0]+X[0][1]
count=0
for i in range(1,N):
    if right>X[i][0]-X[i][1]:
        count+=1
        right=min(X[i][0]+X[i][1],right)
    else:
        right=X[i][0]+X[i][1]
print(N-count)
# Judge status: Wrong Answer
import numpy as np
N,X,Y = map(int, input().split())
cnt = np.zeros(N+1)
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if abs(X-i)+abs(j-Y)+1 < j-i:
            cnt[abs(X-i)+abs(j-Y)+1] += 1
        else:
            cnt[j-i] += 1
for i in range(1,N+1):
    print(int(cnt[i]))
# Judge status: Wrong Answer
S = list(input())
N = len(S)

count = 0
for i in range(N-2):
  if S[i] == S[i+1]:
    if S[i] == "0":
      S[i+1] = '1'
    if S[i] == "1":
      S[i+1] = '0'
    count += 1
      
print(count)
# Judge status: Accepted
n, m = map(int, input().split())

MOD = 10**9 + 7

if abs(n - m) >= 2:
    print(0)
else:    
    f1 = 1
    for i in range(n):
        f1 = f1*(n-i)%MOD
    f2 = 1
    for i in range(m):
        f2 = f2*(m-i)%MOD
        
    if abs(n - m) == 1:
        print(f1*f2%MOD)
        
    elif n == m:
        print(f1*f2*2%MOD)
# Judge status: Accepted
n, m = map(int, input().split())

l, r = [], []
for i in range(m):
    tmpa, tmpb = map(int, input().split())
    l.append(tmpa)
    r.append(tmpb)

print(min(r) - max(l) + 1 if min(r) >= max(l) else 0)
# Judge status: Accepted
n, k = map(int, input().split())
prob_sum = 0
for i in range(1, n+1):
    prob = 1/n
    while i < k:
        i *= 2
        prob *= 1/2
    prob_sum += prob
print(prob_sum)
# Judge status: Accepted
a,b,n=map(int,input().split())
x = min(b-1,n)
print(int(a*x/b)-a*int(x/b))
# Judge status: Accepted
a, b, c = map(int,input().split())
k = int(input())
M = max(a, b, c)
m = a + b + c -M 
print(m + M*(2**k))
# Judge status: Wrong Answer
# ABC 051: C – Back and Forth
sx, sy, tx, ty = [int(i) for i in input().split()]

dx = tx - sx
dy = ty - sy

# r1
r1 = 'U' * (dy + 1) + 'R' * (dx + 1)

# r2
r2 = 'D' * (dy + 1) + 'L' * (dx + 1)

# r3
r3 = 'L' + 'U' * (dy + 2) + 'R' * (dx + 2) + 'D'

# r4
r4 = 'R' + 'D' * (dy + 2) + 'L' * (dx + 2) + 'U'

print(r1 + r2 + r3 + r4)
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    print((N + K - 3) // ~-K)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
S = [0] * N
for i in range(N):
    S[i] = sum(A[:i+1]) + sum(B[i:])
# print(S)
print(max(S))
# Judge status: Accepted
a=list(input())
b=list(input())
c=list(input())
x='a'

while True:
  if x=='a':
    if len(a)==0:
      print('A')
      exit()
    x=a[0]
    a.remove(x)

  elif x=='b':
    if len(b)==0:
      print('B')
      exit()
    x=b[0]
    b.remove(x)

  elif x=='c':
    if len(c)==0:
      print('C')
      exit()
    x=c[0]
    c.remove(x)
# Judge status: Wrong Answer
N,M=map(int,input().split(' '))
if N==1 or M==1:
    print(max(N,M)-2)
else:
    print(N*M-2*(N+M-2))
# Judge status: Wrong Answer
n = int(input())

d = {}
for _ in range(n):
  s = input()
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1

r = {}
for k, v in d.items():
  if v in r.keys():
    r[v].append(k)
  else:
    r[v] = [k]  # make list
    
t = list(r.keys())[-1]
for s in r[t]:
  print(s)
# Judge status: Accepted
N = int(input())
#print(N)
max_cnt = 0
max_num = 1
for n in range(1, N+1, 1):
  #print("n", n)
  orig_n = n
  cnt = 0
  while True: 
    if n % 2 == 0:
      #print(n)
      n /= 2
      cnt += 1
    else:
      if cnt > max_cnt:
        max_cnt = cnt
        max_num = orig_n
        #print("max_num", max_num)
      break

print(max_num)
# Judge status: Accepted
s = list(input())
al = [0]*(len(s)+1)

for i in range(len(s)):
    if s[i] == '<':
        al[i+1] = max(al[i]+1, al[i+1])

for i in range(len(s)-1, -1, -1):
    if s[i] == '>':
        al[i] = max(al[i+1]+1, al[i])

print(sum(al))
# Judge status: Wrong Answer
m = input()
if m == "A":
    print("A")
if m == "a":
    print("a")
# Judge status: Accepted
import math
N = int(input())
 
a = math.sqrt(N)
a = int(a)
 
print(a*a)
# Judge status: Wrong Answer
from math import sqrt,ceil
x = int(input())

for t in range(ceil(sqrt(x))+10):
    if t*(t+1)//2>=x:
        print(t)
        exit()
# Judge status: Accepted
n,k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

abb = sorted(ab)
temp =0

for i in range(n+1):
    if temp < k:
        temp += abb[i][1]
    else:
        print(abb[i-1][0])
        exit()
# Judge status: Wrong Answer
N = int(input())
A = []
while N!=0:
    if N%2==1:
        A.append("1")
        N -= 1
    else:
        A.append("0")
    N = N//(-2)
A = A[::-1]
print("".join(A))
# Judge status: Accepted
from math import sqrt, cos
a, b, h, m = map(int, input().split())

pi = 3.141592653589793238
tmp = abs(m*6-(h*30+m/2))
arg = min(tmp, 360-tmp)

print(sqrt(a**2+b**2-2*a*b*cos(arg*pi/180)))
# Judge status: Accepted
N = int(input())
s = input()
t = input()

n = 0

for i in range(min(len(s), len(t)) + 1):
    if s[-i:] == t[:i]:
        n = i

print(len(s) + len(t) - n)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
ruiseki = [0]*(N+1)
total = 0
now = 10**9+7
sa = 0
now_2 = 0
for i in range(N):
  total += A[i]
  ruiseki[i+1] = total
for i in range(1,len(ruiseki)-1):
  snuke = ruiseki[i]-ruiseki[0]
  arai = ruiseki[N]-ruiseki[i]
  now_2 = abs(snuke-arai)
  now = min(now,now_2)
print(now)
# Judge status: Accepted
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))
ans = 0
for i in range(1, N+1):
    ans += B[A[i]]
    if i > 1:
        if A[i] == A[i-1]+1:
            ans += C[A[i-1]]
print(ans)
# Judge status: Accepted
H, N = map(int, input().split())
a = list(map(int, input().split()))
sum = sum(a)
if sum >= H:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
l,r,d = map(int, input().split())

ans = 0
for i in range(l, r + 1):
  if i % d == 0:
    ans += 1

print(ans)
# Judge status: Accepted
from collections import Counter
n=int(input())
L=Counter(list(map(int,input().split())))
ans=0
for i in L:
    if i!=L[i]:
        if L[i]-i>0:
            ans=ans+L[i]-i
        else:ans+=L[i]
print(ans)
# Judge status: Accepted
K = int(input()) - 1
nums = [str(i) for i in range(1,10)]
while True:
    # print(nums)
    if K < len(nums):
        print(nums[K])
        break
    else:
        K -= len(nums)

    que = []
    for n in nums:
        if n[-1] > "0":
            que.append(n + str(int(n[-1]) - 1))
        if n[-1] < "9":
            que.append(n + str(int(n[-1]) + 1))
        que.append(n + n[-1])
    que.sort()
    nums = que
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = 1000
stock = 0
for i, num in enumerate(a):
  if i == n-1:
    ans += stock*num
  else:  
    if num > a[i+1]:
      ans += stock*num
      stock = 0
    elif num < a[i+1]:
      stock = ans//num
      ans %= num
print(ans)
# Judge status: Wrong Answer
S = input().rstrip()

if S[2]==S[3] and S[4]==S[5]:
    print("YES")

print("NO")
# Judge status: Accepted
abc = list(map(int, input().split()))
abc.sort()
print('Yes' if abc[-1] == abc[0] + abc[1] else 'No')
# Judge status: Wrong Answer
K = int(input())

def lunlun(x):
    x = str(x)
    if all((abs(int(x[i])-int(x[i+1]))<=1) for i in range(len(x)-1)):
        return True
    else:
        return False

counter = 0
for i in range(1,10**5+1):
    if lunlun(i):
        counter += 1
        if counter == K:
            print(i)
            break
    else:
        continue
# Judge status: Accepted
s = input()
cnt = 0
for i in range(len(s) // 2):
    if s[i] != s[len(s) - i - 1]:
        cnt += 1
print(cnt)
# Judge status: Accepted
s = input()
if s.isupper():
    print("A")
else:
    print("a")
# Judge status: Accepted
n,k,q=map(int,input().split())
cnt=[0]*(n+1)
for _ in range(q):
  cnt[int(input())]+=1
for i in range(1,n+1):
  if k-(q-cnt[i])>0:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
n = int(input())
flag = False
for i in range(9):
  for j in range(9):
    if (i + 1) * (j + 1) == n:
      flag = True
if flag == True:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N, x = map(int, input().split())
a = list(map(int, input().split()))

r = 0
flow = 0

for i in range(1, N):
    t = (a[i] + a[i - 1]) - x
    if flow != 0:
        r += flow
        t -= flow
        flow = 0

    if t > 0:
        if t > a[i]:
            r += t - a[i]
            t -= a[i]

        flow = max(0, t)

r += flow

print(r)
# Judge status: Accepted
from collections import Counter

n = int(input())
s = str(input())
d = Counter(s)
S = list(set(s))
ans = 1
for t in S:
    ans *= d[t] + 1
print((ans - 1) % (10** 9 + 7))
# Judge status: Accepted
N=int(input())
def f(n):
  n=str(n)
  if n[0]==n[1]==n[2]:
    return True
  else:
    return False

for i in range(N,1000):
  if f(i):
    print(i)
    exit(0)
# Judge status: Accepted
N,M = map(int,input().split())

n = min(N,M)
m = max(N,M)

if n == 1 and m == 1:
  print(1)
  exit()
if n == 1:
  print(m-2)
  exit()
print((n-2)*(m-2))
# Judge status: Accepted
n = int(input())
c = input()

# それぞれの色の数をカウント
w = c.count("W")
r = c.count("R")

ans = 0
for i in range(r): #　赤の数分文字列を確認する
  if c[i] == "W": ans += 1 # カウント
print(ans)
# Judge status: Wrong Answer
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    trans = [I(), I(), I(), I(), I()]
    ans = n//min(trans) + 5
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
n = int(input())
s = input()
t = input()

for i in range(n):
    if s[i:] == t[:n-i]:
        print(n + i)
        sys.exit()

print(n * 2)
# Judge status: Accepted
a, b = map(int, input().split())
ans = 0
for i in range(a, b+1):
    s = str(i)
    if s == s[::-1]:
        ans += 1
print(ans)
# Judge status: Wrong Answer
n,a,b=map(int,input().split())
ma=b*(n-1)+a
mi=a*(n-1)+b
print(ma-mi+1)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
# result_list = [0]*n
result = 1
com_val = p[0]

for i in range(1, n):
    if com_val < p[i]:
        continue
    else:
        result += 1
        com_val = p[i]

print(result)
# Judge status: Wrong Answer
N=input()
if len(N)==len(set(N)):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x, y = map(int, input().split())

count = 0
if y % 2 == 0:
	count = x * (y // 2)
elif y == 1:
	count = 1
else:
	count = x * ((y + 1) // 2) - (x // 2)

print(count)
# Judge status: Wrong Answer
a= input()

if a[2] == a[3] and a[4] == a[5]:
  print("yes")

else: print("no")
# Judge status: Accepted
  
# 整数 a と、英小文字からなる文字列s が入力されます。
# a が3200 以上ならs と出力し、a が3200 未満なら red と出力するプログラムを書いてください。


a = int(input())
s = input()

if a >= 3200:
    print(s)
else:
    print("red")
# Judge status: Accepted
w, a, b = map(int, input().split())
if a <= b:
    print(max(0, b - (a + w)))
else:
     print(max(0, a - (b + w)))
# Judge status: Wrong Answer
A,B,C,D=map(int,input().split())
#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)

lcm_=lcm(C,D)
answer=B-A+1-(B//C-A//C)-(B//D-A//D)+(B//lcm_-A//lcm_)
if A%C==0:
    answer-=1
if A%D==0:
    answer-=1
if answer<=-1:
    print(0)
else:
    print(answer)
# Judge status: Wrong Answer
input()
a = list(map(int, input().split()))
print(max(a) - min(a))
# Judge status: Accepted
N = int(input())
A = tuple(map(int,input().split()))

box = [0] * N

for i in range(N-1, -1, -1):
    cnt = 0
    tmp = i + 1
    while tmp <= N:
        cnt += box[tmp - 1]
        tmp += (i + 1)
    
    if cnt  % 2 != A[i]:
        box[i] = 1

ans = [idx+1 for idx in range(N) if box[idx] == 1]

print(len(ans))

if ans:
    print(*ans)
# Judge status: Accepted
n = input()
s=0
for i in n:
    s+=int(i)
if s%9==0:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import bisect
 
N = int(input())
Ls = list(map(int, input().split(" ")))
Ls.sort()
 
ans = 0
 
for i in range(0,N-2):
  for j in range(i+1,N-1):
    k = bisect.bisect_left(Ls,Ls[i]+Ls[j])
    ans += k - (j + 1)
       
print(ans)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, k, *h = map(int, read().split())

h.sort()
ans = 10 ** 9
for i in range(n - k + 1):
    ans = min(ans, h[i + k - 1] - h[i])
print(ans)
# Judge status: Accepted
N = input()
print('Yes' if N.find('9') != -1 else 'No')
# Judge status: Wrong Answer
def main():
    n = int(input())
    blis = list(map(int, input().split()))

    alis = [blis[0], blis[0]]
    if n > 2:
        for i in range(3, n):
            alis.append(min(blis[i-2], blis[i-1]))
    if n > 2:
        alis.append(blis[n-2])
    print(sum(alis))


    


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n = int(input())
if n%2 != 0:
    print(0)
else:
    dum = n//10
    ans = dum
    keta = 1
    while dum != 0:
        dum = dum//10
        ans -= (keta * dum)
        keta += 1
        ans += (keta * dum)
    print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
h = list(map(int, input().split()))

INF = float('inf')
dp = [INF] * n
dp[0] = 0

for i in range(n - 1):
    for j in range(1, k + 1):
        if i + j >= n:
            break
        else:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))

print(dp[-1])
# Judge status: Accepted
import sys
def input():
    return sys.stdin.readline()[:-1]
s,t=input().split()
print(t+s)
# Judge status: Wrong Answer
d,n = map(int, raw_input().split())
print n * (100 ** d)
# Judge status: Accepted
k = int(input())

r = set()
x = 7
i = 1
while True:
    rr = x % k
    if rr == 0:
        print(i)
        break
    if rr in r:
        print(-1)
        break
    x = (x * 10 + 7) % k
    i += 1
    r.add(rr)
# Judge status: Accepted
N=int(input())
N0=N%10

set1={2,4,5,7,9}
set2={0,1,6,8}
set3={3}

if N0 in set1:
  print("hon")
elif N0 in set2:
  print("pon")
else:
  print("bon")
# Judge status: Accepted
n=int(input())
print(((1+n)*n)//2)
# Judge status: Wrong Answer
i=input()
S=input()
if S[:len(S)//2] != S[len(S)//2] or len(S)%2 !=0:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
n = int(input())
ans = n

for i in range(n+1):
    j = n-i

    a = j
    p = 0
    while a>0:
        p += a%6
        a = a//6

    b = i
    q = 0
    while b>0:
        q += b%9
        b = b//9

    ans = min(ans, p+q)

print(ans)
# Judge status: Accepted
s = input().split()[0]
n = len(s)
l = s[:n//2]
r = s[n//2+1:]
cnt = 0
for i in range(n//2):
    if l[i] == l[n//2 - 1 - i]:
        cnt += 1
    if r[i] == r[n//2 - 1 - i]:
        cnt += 1
if l == r and cnt == n - 1:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
K, X = [int(i) for i in input().split()]
total = 500 * K
if total > X:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

for i in range(K):
    if A>=1:
        A=A-1
    else:
        if B>=1:
            B=B-1
        else:
            exit()
print(A, B)
# Judge status: Accepted
q= int(input())
ac,wa,tle,re = 0,0,0,0
for _ in range(q):
    q = input()
    if q == "AC": ac+=1
    elif q == "WA": wa+=1
    elif q == "TLE": tle+=1
    else : re+=1
print("AC x",ac)
print("WA x",wa)
print("TLE x",tle)
print("RE x",re)
# Judge status: Wrong Answer
N = int(input())
T,A = map(int,input().split())
Hls = list(map(int,input().split()))
mabs = 10**5+1
for i in range(N):
    if abs(T-Hls[i]) <= mabs:
        mabs = abs(T-Hls[i])
        ans = i
    else:
        pass
print(ans+1)
# Judge status: Accepted
n = int(input())
pt,px,py = 0, 0, 0

for _ in range(n):
  ct,cx,cy = map(int,input().split())
  t = ct - pt
  d = abs(cx-px) + abs(cy-py)
  if t < d or (t%2) != (d%2):
    print('No')
    break
  pt,px,py = ct,cx,cy
else:
  print('Yes')
# Judge status: Accepted
a = int(input())
b = a + a ** 2 + a ** 3
print (b)
# Judge status: Accepted
import sys

input = sys.stdin.readline
MOD = 1000000007

S = input()[:-1]

S = list(S)

if S[0] == 'A':
    if 'C' in S[2:-1] and  S.count('C') == 1:
        x = []
        for i in range(1,len(S)):
            if S[i] == 'C':
                continue
            x.append(S[i])
        
        #print(x)
        if str(x).islower():
            print("AC")
            exit()

print("WA")