CodeEff/ECCO huggingface dataset:
# Original solution
from itertools import product
n,m = list(map(int, input().split()))

# dp[i][j] i個取った時の{+,-}*3 タイプの最大値
dp = [[0]*8 for i in range(m+1)]
op = [i for i in product([-1,1], repeat=3)]
#print(op)

for i in range(n):
    x,y,z = list(map(int, input().split()))
    nxt = [[0]*8 for i in range(m+1)]
    for j in range(m):
        for k in range(8):
            nxt[j+1][k] = max(dp[j+1][k], dp[j][k] + op[k][0]*x+op[k][1]*y+op[k][2]*z)
    dp = nxt
print((max(dp[-1])))

# Optimized solution
from itertools import product
n,m  = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i, j, k in product([-1,1], repeat=3):
    ans = max(ans, sum(sorted(i*x+j*y+k*z for x,y,z in a)[::-1][:m]))
print(ans)
# Original solution
n,m=list(map(int,input().split()))
xyz=[list(map(int,input().split())) for i in range(n)]
lst=[]
for i in range(8):
    if i&1==1:
        a=1
    else:
        a=-1
    if (i>>1)&1==1:
        b=1
    else:
        b=-1
    if (i>>2)&1==1:
        c=1
    else:
        c=-1
    h=[0]
    for u in xyz:
        x,y,z=u
        h.append(a*x+b*y+c*z)
    lst.append(h)
ans=0
for u in lst:
    dp=[[0]*(m+1) for i in range(n+1)]
    for i in range(1,n+1):
        d=u[i]
        for j in range(1,m+1):
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-1]+d)
    ans=max(ans,dp[n][m])
print(ans)

# Optimized solution
n,m=list(map(int,input().split()))
xyz=[list(map(int,input().split())) for i in range(n)]
lst=[]
for i in range(8):
    if i&1==1:
        a=1
    else:
        a=-1
    if (i>>1)&1==1:
        b=1
    else:
        b=-1
    if (i>>2)&1==1:
        c=1
    else:
        c=-1
    h=[]
    for u in xyz:
        x,y,z=u
        h.append(a*x+b*y+c*z)
    lst.append(h)
ans=0
for u in lst:
    u.sort(reverse=True)
    e=0
    for i in range(m):
        e+=u[i]
    ans=max(ans,e)
print(ans)
# Original solution

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

xyz = []

for i in range(N):

    x,y,z = list(map(int,input().split()))
    xyz.append([x,y,z])

ans = -1 * float("inf")

for bpm in range(2):

    for dpm in range(2):

        for fpm in range(2):


            if bpm == 0:
                bpm = -1
            if dpm == 0:
                dpm = -1
            if fpm == 0:
                fpm = -1

            lis = [0] * (M+1)
            nlis = [0] * (M+1)


            for i in range(N):

                now = xyz[i][0] * bpm + xyz[i][1] * dpm + xyz[i][2] * fpm


                for j in range(M):

                    if j == 0 or lis[j] != 0:

                        nlis[j+1] = max(nlis[j+1],lis[j] + now)

                lis = nlis.copy()

            ans = max(ans,lis[M])

print (ans)

# Optimized solution

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

xyz = []

for i in range(N):

    x,y,z = list(map(int,input().split()))
    xyz.append([x,y,z])

ans = -1 * float("inf")

for bpm in range(2):

    for dpm in range(2):

        for fpm in range(2):


            if bpm == 0:
                bpm = -1
            if dpm == 0:
                dpm = -1
            if fpm == 0:
                fpm = -1

            lis = []

            for i in xyz:

                lis.append(i[0] * bpm + i[1] * dpm + i[2] * fpm)

            lis.sort()
            lis.reverse()

            now = 0
            for j in range(M):
                now += lis[j]

            ans = max(ans,now)

print (ans)
# Original solution
N, M = list(map(int,input().split()))
max = -float('inf')
x = []
y = []
z = []
for i in range(N):
	xx,yy,zz = list(map(int,input().split()))
	x.append(xx)
	y.append(yy)
	z.append(zz)
for i in range(-1,2,2):
	for j in range(-1,2,2):
		for k in range(-1,2,2):
			s = []
			for m in range(N):
				s.append(i*x[m]+j*y[m]+k*z[m])
			s = sorted(s)
			tmp = sum(s[-1*M:])
			if tmp > max:
				max = tmp
if M==0:
	print((0))
else:
	print(max)

# Optimized solution
n,m = list(map(int,input().split()))
xyz = [list(map(int,input().split())) for _ in range(n)]
res = 0
for a in (1,-1):
    for b in (1,-1):
        for c in (1,-1):
            l = []
            for (x,y,z) in xyz:
                l.append(x*a+y*b+z*c)
            l = sorted(l,reverse=True)
            res = max(res, sum(l[:m]))
print(res)
# Original solution
# D Patisserie
N,M=list(map(int,input().split()))
check=M+10 if M+10<=N else N
xyz_list,x_list,y_list,z_list=[],[],[],[]
for i in range(N):
    xyz_list.append(input().split())
for i in range(N):
    x_list.append([int(xyz_list[i][0]),i+1])
    y_list.append([int(xyz_list[i][1]),i+1])
    z_list.append([int(xyz_list[i][2]),i+1])
x_listn=x_list[:]
y_listn=y_list[:]
z_listn=z_list[:]
import itertools as itl
conb=[]
for i in range(check):
    conb.append(i)
conb=[x for x in itl.combinations(conb,M)]
sum_max=0

x_list.sort()
for l in range(2):
    for j in range(len(conb)):
        sum_x,sum_y,sum_z=0,0,0
        for k in conb[j]:
            num_comb=x_list[k][1]-1
            sum_x+=x_listn[num_comb][0]
            sum_y+=y_listn[num_comb][0]
            sum_z+=z_listn[num_comb][0]
        sum_xyz=abs(sum_x)+abs(sum_y)+abs(sum_z)
        if sum_xyz>sum_max:sum_max=sum_xyz
    x_list=x_list[::-1]
    
y_list.sort()
for l in range(2):
    for j in range(len(conb)):
        sum_x,sum_y,sum_z=0,0,0
        for k in conb[j]:
            num_comb=y_list[k][1]-1
            sum_x+=x_listn[num_comb][0]
            sum_y+=y_listn[num_comb][0]
            sum_z+=z_listn[num_comb][0]
        sum_xyz=abs(sum_x)+abs(sum_y)+abs(sum_z)
        if sum_xyz>sum_max:sum_max=sum_xyz
    y_list=y_list[::-1]
    
z_list.sort()
for l in range(2):
    for j in range(len(conb)):
        sum_x,sum_y,sum_z=0,0,0
        for k in conb[j]:
            num_comb=z_list[k][1]-1
            sum_x+=x_listn[num_comb][0]
            sum_y+=y_listn[num_comb][0]
            sum_z+=z_listn[num_comb][0]
        sum_xyz=abs(sum_x)+abs(sum_y)+abs(sum_z)
        if sum_xyz>sum_max:sum_max=sum_xyz
    z_list=z_list[::-1]
print(sum_max)

# Optimized solution
# D Patisserie
import itertools as itl
#入力を取得
N,M=list(map(int,input().split()))
check=M+10 if M+10<=N else N
xyz_list,x_list,y_list,z_list=[],[],[],[]
for i in range(N):
    xyz_list.append(input().split())
    
var_list=[x for x in itl.product([-1,1],repeat=3)]
sum_list=[]
for i in var_list:
    sort_list=[0,]*N
    for j in range(N):
        sort_list[j]=int(xyz_list[j][0])*i[0]+ int(xyz_list[j][1])*i[1]+ int(xyz_list[j][2])*i[2]
    sort_list.sort(reverse=True)
    sum_=0
    for j in range(M):
        sum_+=sort_list[j]
    sum_list.append(sum_)
    
sum_list.sort(reverse=True)
print((sum_list[0]))
# Original solution
import itertools
N, M = list(map(int, input().split()))
xyz = list()
for n in range(N):
    xyz.append([int(x) for x in input().split()])
ans = 0
for x in itertools.combinations(list(range(N)), M):
    tmp = [0,0,0]
    for m in x:
        for y in range(3):
            tmp[y] += xyz[m][y]
    ans = max(ans, sum([abs(x) for x in tmp]))
print(ans)


# Optimized solution
import itertools
N, M = list(map(int, input().split()))
xyz = list()
for n in range(N):
    xyz.append([int(x) for x in input().split()])
ans = 0
for a,b,c in itertools.product([-1,1], repeat=3):
    tmp = []
    for x, y, z in xyz:
        tmp.append(a*x+b*y+c*z)
    tmp.sort(reverse=True)
    ans = max(ans, sum(tmp[:M]))
print(ans)
# Original solution
import itertools

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

a = []
for i in range(n):
    a.append(list(map(int,input().split())))
ans = 0
b = []
for i in itertools.combinations(a,m):
    i0 = 0
    i1 = 0
    i2 = 0
    for j in i:
        i0 += j[0]
        i1 += j[1]
        i2 += j[2]
    ans = max(ans,abs(i0)+abs(i1)+abs(i2))
print(ans)

# Optimized solution
n,m = list(map(int,input().split()))

a = []
b = []
c = []
d = []
e = []
f = []
g = []
h = []
for i in range(n):
    j = list(map(int,input().split()))
    a.append(j[0]+j[1]+j[2])
    b.append(-j[0]+j[1]+j[2])
    c.append(j[0]-j[1]+j[2])
    d.append(j[0]+j[1]-j[2])
    e.append(-j[0]-j[1]+j[2])
    f.append(-j[0]+j[1]-j[2])
    g.append(j[0]-j[1]-j[2])
    h.append(-j[0]-j[1]-j[2])
a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()
d.sort()
d.reverse()
e.sort()
e.reverse()
f.sort()
f.reverse()
g.sort()
g.reverse()
h.sort()
h.reverse()

print((max(sum(a[:m]),sum(b[:m]),sum(c[:m]),sum(d[:m]),sum(e[:m]),sum(f[:m]),sum(g[:m]),sum(h[:m]))))
# Original solution
import itertools


def main():
    N, M = list(map(int, input().split(' ')))
    cakes = [list(map(int, input().split(' '))) for _ in range(N)]
    ans = 0
    for sign in itertools.product([-1, 1], repeat=3):
        dp = [[0 for _ in range(M + 1)] for _ in range(N + 1)]
        for n in range(N):
            cake_score = sum([s * c for s, c in zip(sign, cakes[n])])
            for m in range(M + 1):
                if m - 1 >= 0:
                    dp[n + 1][m] = max([dp[n][m], dp[n][m - 1] + cake_score])
                else:
                    dp[n + 1][m] = dp[n][m]
        ans = max([ans, dp[N][M]])
    print(ans)


if __name__ == '__main__':
    main()

# Optimized solution
import itertools


def main():
    N, M = list(map(int, input().split(' ')))
    cakes = [list(map(int, input().split(' '))) for _ in range(N)]
    ans = 0
    for sign in itertools.product([-1, 1], repeat=3):
        scores = [sum([s * c for s, c in zip(sign, cake)]) for cake in cakes]
        scores.sort(reverse=True)
        ans = max([ans, sum(scores[:M])])
    print(ans)


if __name__ == '__main__':
    main()
# Original solution
n,m=list(map(int,input().split()))
box=list(list(map(int,input().split())) for i in range(n))
ans = 0
for i in (1,-1):
    for j in (1,-1):
        for k in (1,-1):
            cost=list(i*x+j*y+z*k for x,y,z in box)
            cost.sort(reverse=True)
            ans=max(ans,sum(cost[:m]))
print(ans)

# Optimized solution
n,m=list(map(int,input().split()))
XYZ=[list(map(int,input().split())) for _ in range(n)]

ans=0
for i in (-1,1):
    for j in (-1,1):
        for k in (-1,1):
            cost=list(i*x+j*y+z*k for x,y,z in XYZ)
            cost.sort(reverse=True)
            ans=max(ans,sum(cost[:m]))
print(ans)
# Original solution
import itertools

N,M=[int(i) for i in input().split(" ")]
cake=[]
for i in range(N):
    x,y,z=[int(j) for j in input().split(" ")]
    cake.append([x,y,z])

_num=[i for i in range(N)]
num=list(itertools.combinations(_num,M))

result=0
for i in num:
    delicious=0
    beautiful=0
    popular=0
    for j in i:
        delicious+=cake[j][0]
        beautiful+=cake[j][1]
        popular+=cake[j][2]

    result=max(abs(delicious)+abs(beautiful)+abs(popular),result)

print(result)


# Optimized solution
N,M=[int(i) for i in input().split(" ")]
cake1=[]
cake2=[]
cake3=[]
cake4=[]
cake5=[]
cake6=[]
cake7=[]
cake8=[]
for i in range(N):
    x,y,z=[int(j) for j in input().split(" ")]
    cake1.append(x+y+z)
    cake2.append(-x+y+z)
    cake3.append(x-y+z)
    cake4.append(x+y-z)
    cake5.append(-x-y+z)
    cake6.append(-x+y-z)
    cake7.append(x-y-z)
    cake8.append(-x-y-z)

cake1=sorted(cake1)[::-1]
cake2=sorted(cake2)[::-1]
cake3=sorted(cake3)[::-1]
cake4=sorted(cake4)[::-1]
cake5=sorted(cake5)[::-1]
cake6=sorted(cake6)[::-1]
cake7=sorted(cake7)[::-1]
cake8=sorted(cake8)[::-1]
print((max(sum(cake1[:M:]),sum(cake2[:M:]),sum(cake3[:M:]),sum(cake4[:M:]),sum(cake5[:M:]),sum(cake6[:M:]),sum(cake7[:M:]),sum(cake8[:M:]))))
# Original solution
n, m = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for i in range(n)]
B = []

def pm(n):
    if n % 2 == 0:
        return 1
    else:
        return -1
    
for i in range(8):
    temp = sorted([pm(i//4) * x + pm(i//2) * y + pm(i) * z for x, y, z in A], reverse=True)
    B.append(sum(temp[:m]))
    
print((max(B)))

# Optimized solution
n, m = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for i in range(n)]
B = []

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1
    
for i in range(8):
    temp = sorted([f(i // 4) * x + f(i // 2) * y + f(i) * z for x, y, z in A], reverse=True)
    B.append(sum(temp[:m]))
    
print((max(B)))
# Original solution
N, M = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for i in range(N)]

ans = 0
for i in range(1 << 3):
    x = bin(i)[2:]
    while len(x) < 3:
        x = '0' + x
    op = ''
    for j in x:
        if j == '1':
            op += '+'
        else:
            op += '-'
    B = []
    for j in range(N):
        B.append(eval(op[0] + str(A[j][0]) + op[1] + str(A[j][1]) + op[2] + str(A[j][2])))
    B.sort(reverse = True)
    ans = max(ans, sum(B[:M]))
    
print(ans)

# Optimized solution
N, M = list(map(int, input().split()))
A = [[int(i) for i in input().split()] for i in range(N)]

def f(x):
    if x == 1:
        return 1
    else:
        return -1

ans = 0
for i in range(1 << 3):
    B = []
    for x, y, z in A:
        B.append(f((i >> 2) & 1) * x + f((i >> 1) & 1) * y + f(i & 1) * z)
    B.sort(reverse = True)
    ans = max(ans, sum(B[:M]))
    
print(ans)
# Original solution
import itertools
N,M = list(map(int,input().split()))
info = [list(map(int,input().split())) for i in range(N)]
note = []
for x,y,z in info:
    X = [x,-x]; Y = [y,-y]; Z = [z,-z]
    tmp = []
    for c in itertools.product(X,Y,Z):
        tmp.append(sum(c))
    note.append(tmp)

ans = -float('inf')
for j in range(8):
    res = []
    for i in range(N):
        res.append(note[i][j])
    res = sorted(res,reverse=True)
    value = sum(res[:M])
    if value > ans:
        ans = value
print(ans)

# Optimized solution
import itertools
N,M = list(map(int,input().split()))
info = [list(map(int,input().split())) for i in range(N)]
ans = -float('inf')
for i,j,k in itertools.product([1,-1],repeat=3):
    tmp = []
    for x,y,z in info:
        value = x*i + y*j + z*k
        tmp.append(value)
    tmp.sort(reverse=True)
    res = sum(tmp[:M])
    if res > ans:
        ans = res
print(ans)
# Original solution
import itertools
import heapq
n,m = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
ans = 0
c = [0,1]
for l,j,k in itertools.product(c,repeat=3):
    ans = max(ans,sum(heapq.nlargest(m,([a[i][0]*(-1)**l+a[i][1]*(-1)**j+a[i][2]*(-1)**k for i in range(n)]))))
print(ans)

# Optimized solution
from itertools import product as p
n,m = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(n)]
c = [1,-1]
ans = 0
for l,j,k in p(c,repeat=3):
    ans = max(ans,sum(sorted([a[i][0]*l+a[i][1]*j+a[i][2]*k for i in range(n)])[n-m:])) 
print(ans)
# Original solution
# https://abc100.contest.atcoder.jp/tasks/abc100_d
# D - Patisserie ABC

# D_Patisserie_ABC.py

import collections

N, M = list(map(int, input().strip().split(" ")))
A = [[] for i in range(8)]
for n in range(N):
    # 「綺麗さ」「おいしさ」「人気度」
    x, y, z = list(map(int, input().strip().split(" ")))

    A[0].append(x+y+z)
    A[1].append(-x+y+z)
    A[2].append(x-y+z)
    A[3].append(x+y-z)
    A[4].append(x-y-z)
    A[5].append(-x+y-z)
    A[6].append(-x-y+z)
    A[7].append(-x-y-z)


T = []
for i in range(8):
    A[i].sort()
    total = 0
    for _ in range(M):
        total += A[i].pop()
    T.append(total)

T.sort()
print((T[-1]))


# Optimized solution
# https://abc100.contest.atcoder.jp/tasks/abc100_d
# D - Patisserie ABC

# D_Patisserie_ABC.py

#import collections

N, M = list(map(int, input().strip().split(" ")))
A = [[] for i in range(8)]
for n in range(N):
    # 「綺麗さ」「おいしさ」「人気度」
    x, y, z = list(map(int, input().strip().split(" ")))

    A[0].append(x+y+z)
    A[1].append(-x+y+z)
    A[2].append(x-y+z)
    A[3].append(x+y-z)
    A[4].append(x-y-z)
    A[5].append(-x+y-z)
    A[6].append(-x-y+z)
    A[7].append(-x-y-z)


T = []
for i in range(8):
    A[i].sort()
    total = 0
    for _ in range(M):
        total += A[i].pop()
    T.append(total)

T.sort()
print((T[-1]))
# Original solution
import re
for i in range(int(eval(input()))):
 s=input().replace(" ","")
 print((''.join(re.sub(r'0\w','',''.join([i+j for(i,j)in zip(str(10000+eval('+'.join([i[0]+{'m':'*1000','c':'*100','x':'*10','i':''}[i[1]]for i in ['1'+i for i in''.join(re.split(r'\d\w',s))]+re.findall(r'\d\w',s)])))[1:],list('mcxi'))])).split('1'))))

# Optimized solution
import re
for i in range(int(eval(input()))):
 s=input().replace(" ","")
 print((re.sub(r'0.','',''.join([i+j for(i,j)in zip(str(10000+eval('+'.join([i[0]+{'m':'*1000','c':'*100','x':'*10','i':''}[i[1]]for i in ['1'+i for i in''.join(re.split(r'\d\w',s))]+re.findall(r'\d\w',s)])))[1:],list('mcxi'))]).replace('1',''))))
# Original solution
import math

r = float(eval(input()))

s = r*r*math.pi
v = 2*math.pi*r

print(("{:f} {:f}".format(s, v)))

# Optimized solution
import math

r = float(eval(input()))

s = r**2*math.pi
v = 2*math.pi*r

print(("{:f} {:f}".format(s, v)))
# Original solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

s = LS2()

print((s[0]+str(len(s)-2)+s[-1]))

# Optimized solution
import sys
def LS2(): 
    return list(sys.stdin.readline().rstrip())  #空白なし

s = LS2()

print((s[0]+str(len(s)-2)+s[-1]))
# Original solution
from sys import stdin
s = stdin.readline().rstrip()
print((''.join([s[0], str(len(s) - 2), s[-1]])))

# Optimized solution
import sys

s = sys.stdin.readline().rstrip()
l = len(s)

def main():
    return s[0] + str(l-2) + s[-1]

if __name__ == '__main__':
    ans = main()
    print(ans)
# Original solution
from itertools import accumulate
import sys
sys.setrecursionlimit(10**8)
class BIT():
    def __init__(self,number):
        self.n=number
        self.list=[0]*(number+1)
        
    def add(self,i,x):#ith added x  1indexed
        while i<=self.n:
            self.list[i]+=x
            i+=i&-i
            
    def search(self,i):#1-i sum
        s=0
        while i>0:
            s+=self.list[i]
            i-=i&-i
        return s
    
    def suma(self,i,j):#i,i+1,..j sum
        return self.search(j)-self.search(i-1)

N,K=list(map(int,input().split()))
A=[int(eval(input())) for i in range(N)]
B=list(accumulate([0]+A))
for i in range(N+1):
    B[i]-=K*i
C=sorted((B[i],i) for i in range(N+1))
D=[-1]*(N+1)
D[C[0][1]]=0
s=C[0][0]
t=0
for i in range(1,N+1):
    if s<C[i][0]:
        s=C[i][0]
        t+=1
        D[C[i][1]]=t
    else:
        D[C[i][1]]=t
tree=BIT(t+1)
ans=0
for i in range(N+1):
    ans+=tree.search(D[i]+1)
    tree.add(D[i]+1,1)
print(ans)

# Optimized solution
from itertools import accumulate
import sys
sys.setrecursionlimit(10**8)
class BIT():
    def __init__(self,number):
        self.n=number
        self.list=[0]*(number+1)
        
    def add(self,i,x):#ith added x  1indexed
        while i<=self.n:
            self.list[i]+=x
            i+=i&-i
            
    def search(self,i):#1-i sum
        s=0
        while i>0:
            s+=self.list[i]
            i-=i&-i
        return s
    
    def suma(self,i,j):#i,i+1,..j sum
        return self.search(j)-self.search(i-1)

N,K=list(map(int,input().split()))
A=[int(eval(input())) for i in range(N)]
B=list(accumulate([0]+A))
for i in range(N+1):
    B[i]-=K*i
C=sorted(set(B))
t=len(C)
D={ C[i]:i for i in range(t)}
tree=BIT(t)
ans=0
for i in range(N+1):
    ans+=tree.search(D[B[i]]+1)
    tree.add(D[B[i]]+1,1)
print(ans)
# Original solution
from itertools import accumulate
from bisect import bisect_right

N, K = list(map(int, input().split()))
A = [0] + [int(eval(input())) for i in range(N)]

diff = [a - K for a in A]
diff = list(accumulate(diff))


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(N + 1)

temp = sorted(diff)
order = [bisect_right(temp, d) for d in diff]
ans = 0

for x in order:
    ans += BIT.sum(x)
    BIT.add(x, 1)

print(ans)


# Optimized solution
from itertools import accumulate
from bisect import bisect_right

N, K = list(map(int, input().split()))
A = [3] + [int(eval(input())) for i in range(N)]

diff = [a - K for a in A]
diff = list(accumulate(diff))


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(N + 1)

temp = sorted(diff)
order = [bisect_right(temp, d) for d in diff]
ans = 0

for x in order:
    ans += BIT.sum(x)
    BIT.add(x, 1)

print(ans)
# Original solution
from itertools import accumulate
from bisect import bisect_right

N, K = list(map(int, input().split()))
A = [3] + [int(eval(input())) for i in range(N)]

diff = [a - K for a in A]
diff = list(accumulate(diff))


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(N + 1)

temp = sorted(diff)
order = [bisect_right(temp, d) for d in diff]
ans = 0

for x in order:
    ans += BIT.sum(x)
    BIT.add(x, 1)

print(ans)


# Optimized solution
from itertools import accumulate
from bisect import bisect_right

N, K = list(map(int, input().split()))
A = [-19] + [int(eval(input())) for i in range(N)]

diff = [a - K for a in A]
diff = list(accumulate(diff))


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(N + 1)

temp = sorted(diff)
order = [bisect_right(temp, d) for d in diff]
ans = 0

for x in order:
    ans += BIT.sum(x)
    BIT.add(x, 1)

print(ans)
# Original solution
N, K = list(map(int, input().split()))
A = [int(eval(input())) for _ in range(N)]

B = [0] * (N + 1)
B[1] = A[0] - K
for i in range(1, N):
    A[i] += A[i - 1]
    B[i + 1] = A[i] - K * (i + 1)

tmp = sorted(B)

dic = dict()
for index, x in enumerate(tmp):
    dic[x] = index


N = len(B)
bit = [0] * (N + 1)
def total(i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i & -i
    return s

def add(i, x):
    while i <= N:
        bit[i] += x
        i += i & -i
    return

ans = 0
for b in B:
    # print (b)
    n = dic[b]
    ans += total(n + 1)
    # print (b, ans)
    # print ()
    add(n + 1, 1)

print (ans)
# print (B)
# print (dic)
# print (bit)

# Optimized solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N, K = list(map(int, input().split()))
A = [0] + [int(eval(input())) - K for _ in range(N)]

# print (A)
for i in range(N):
    A[i + 1] += A[i]

B = sorted(A)
dic = dict()
for i, b in enumerate(B):
    dic[b] = i + 1

N += 1
bit = [0] * (N + 1)
def total(i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i & -i
    return s

def add(i, x):
    while i <= N:
        bit[i] += x
        i += i & -i
    return

ans = 0
for a in A:
    b = dic[a]
    ans += total(b)
    # print ('tmp')
    add(b, 1)

print (ans)
# print (A)
# print (dic)