Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

K = input().split()
N = int(K[0])
K = int(K[1])

count = 0
for b in range(K+1, N+1):
    for l in range(K, b):
        count += int((N-l)/b)


if K != 0:
    for a in range(K, N+1):
        count += N-a
if K == 0:
        for a in range(1, N+1):
            count += N-a

print(count)

### FIXED CODE ###

K = input().split()
N = int(K[0])
K = int(K[1])

count = 0
for b in range(K+1, N+1):
    siki1 = int((N-K)/b)
    siki2 = int((N-b+1)/b)
    if siki1 <= siki2:
        count += (b-K)*siki1
    elif siki1 > siki2:
        count += (b-K)*siki1
        count -= (b-N-1)*(siki1 - siki2)
        count -= b*(int((siki1*(siki1+1))/2) - int((siki2*(siki2+1))/2))

if K != 0:
    for a in range(K, N+1):
        count += N-a
if K == 0:
        for a in range(1, N+1):
            count += N-a

print(count)
### BUGGY CODE ###

def gcd(x,y,z):
  p=[x,y,z]
  p.sort()
  for hh in range(p[0],0,-1):
    if x%hh==0 and y%hh==0 and z%hh==0:
      return(hh)
      break
n=int(input())
s=0
f={}
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      u=[i,j,k]
      u.sort()
      if 1 in u:
        s+=1
      else:
        o=''
        o+=str(u[0])
        o+=str(u[1])
        o+=str(u[2])
        if o in f:
          s+=f[o]
        else:
          f[o]=gcd(u[0],u[1],u[2])
          s+=f[o]
print(s)


### FIXED CODE ###

from math import gcd
n=int(input())
s=0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      s+=gcd(gcd(i,j),k)
print(s)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A = sorted([(a, p) for p, a in enumerate(A)], reverse=True)
dp = [[0]*(i+1) for i in range(N+1)]
for z in range(N):
    for y in range(z+1):
        dp[z+1][y] = max(A[z][0]*(A[z][1]-(z-y))+dp[z][y],dp[z+1][y])
        dp[z+1][y+1]= A[z][0]*((N-y-1)-A[z][1])+dp[z][y]
print(max(dp[-1]))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A = sorted([(a, p) for p, a in enumerate(A)], reverse=True)
dp = [[0]*(i+1) for i in range(N+1)]
for z in range(N):
    for y in range(z+1):
        dp[z+1][y] = max(A[z][0]*(A[z][1]-(z-y))+dp[z][y],dp[z+1][y])
        dp[z+1][y+1]= A[z][0]*((N-y-1)-A[z][1])+dp[z][y]
print(max(dp[-1]))
### BUGGY CODE ###

beforex=[]
beforey=[]
sum=0
for i in range(int(input())):
  xy=list(map(int,input().split()))
  beforex.append(xy[0])
  beforey.append(xy[1])

for i in range(len(beforex)-1):
  for j in range(i+1,len(beforex)):
    sum=max(sum,abs(beforex[i]-beforex[j])+abs(beforey[i]-beforey[j]))

print(sum)

### FIXED CODE ###

beforex_plus_y=[]
beforex_minus_y=[]
for i in range(int(input())):
  xy=list(map(int,input().split()))
  beforex_plus_y.append(xy[0]+xy[1])
  beforex_minus_y.append(xy[0]-xy[1])

print(max(max(beforex_plus_y)-min(beforex_plus_y),max(beforex_minus_y)-min(beforex_minus_y)))
### BUGGY CODE ###

from collections import Counter
n = int(input())
l = []
check = []
count = 0
for i in range(n):
    a = list(input())
    a.sort()
    
    if a in l:
        index = l.index(a)
        count += check[index]
        check[index] += 1
    else:
        l.append(a)
        check.append(1)


print(count)

### FIXED CODE ###

n = int(input())
dic = {}
for i in range(n):
    s = "".join(sorted(input()))
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
ans = 0
for i in dic.values():
    if i > 1:
        ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

def abc(n:int,lst:list):
    l=list(map(lambda x:x[2],lst))
    if min(l)==0 and max(l)<201:
        for x in range(101):
            for y in range(101):
                for h in range(201):
                    for i in range(n):
                        if max(0,h-abs(lst[i][0]-x)-abs(lst[i][1]-y)) ==lst[i][2]:
                            if i ==n-1:
                                return x,y,h
                        else:
                            break
    else:
        x0 =lst[0][0]
        y0=lst[0][1]
        h0 =lst[0][2]
        for x in range(101):
            for y in range(101):
                for i in range(1,n):
                    if abs(x0-x)+abs(y0-y)-abs(lst[i][0]-x)-abs(lst[i][1]-y) ==lst[i][2]-h0:
                        if i ==n-1:
                            return x,y,h0+abs(x0-x)+abs(y0-y)
                    else:
                        break
n = int(input())
lst = [list(map(int,input().split())) for i in range(n)]
x,y,h =abc(n,lst)
print(x,y,h)

### FIXED CODE ###

def abc(n:int,lst:list):
    l0=list(filter(lambda x:x[2]==0,lst))
    l=list(filter(lambda x:x[2]!=0,lst))
    if len(l0):
        x0 =l[0][0]
        y0=l[0][1]
        h0 =l[0][2]
        ans=[]
        for x in range(101):
            for y in range(101):
                for i in range(len(l)):
                    if abs(x0-x)+abs(y0-y)-abs(l[i][0]-x)-abs(l[i][1]-y) == l[i][2]-h0:
                        if i ==len(l)-1:
                            ans.append([x,y,h0+abs(x0-x)+abs(y0-y)])
                    else:
                        break
        for xyh in ans:
            for i in range(len(l0)):
                if abs(l0[i][0]-xyh[0])+abs(l0[i][1]-xyh[1])>=xyh[2]:
                    if i == len(l0)-1:
                        return xyh
                else:
                    break
    else:
        x0 =lst[0][0]
        y0=lst[0][1]
        h0 =lst[0][2]
        for x in range(101):
            for y in range(101):
                for i in range(1,n):
                    if abs(x0-x)+abs(y0-y)-abs(lst[i][0]-x)-abs(lst[i][1]-y) ==lst[i][2]-h0:
                        if i ==n-1:
                            return x,y,h0+abs(x0-x)+abs(y0-y)
                    else:
                        break
n = int(input())
lst = [list(map(int,input().split())) for i in range(n)]
x,y,h =abc(n,lst)
print(x,y,h)
### BUGGY CODE ###

n= int(input())
s_list= list(input())
r_list=[]
g_list=[]
b_list=[]
count=0
for i in range(0,n):
    if s_list[i]=="R":
        r_list.append(i)
    elif s_list[i]=="G":
        g_list.append(i)
    else:
        b_list.append(i)

for pp in r_list:
    for qq in g_list:
        for rr in b_list:
            if rr-pp != -1*(qq-pp) and rr-pp !=2*(qq-pp) and qq-pp !=2*(rr-pp) :
                count=count+1
print(count)

### FIXED CODE ###

n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        if s_list[p] == s_list[q]:
            continue
        elif 2*q-p<n and s_list[2*q-p]!=s_list[p] and s_list[2*q-p]!=s_list[q]:
            count= count+1
print(sum-count)
### BUGGY CODE ###

import sys
H,W,M=map(int, input().split())
h=[]
w=[]
Hcount=[0 for _ in range(H)]
Wcount=[0 for _ in range(W)]
B=set()

for i in range(M):
    hi,wi=map(int, input().split())
    #h.append(hi)
    #w.append(wi)
    B.add((hi,wi))
    Hcount[hi-1]+=1
    Wcount[wi-1]+=1
h_max=[i for i, v in enumerate(Hcount) if v == max(Hcount)]
w_max=[i for i, v in enumerate(Wcount) if v == max(Wcount)]
#print(h_max,w_max)
for ii in range(len(h_max)):
    for jj in range(len(w_max)):
        if (h_max[ii]+1,w_max[jj]+1) not in B:
            print(max(Hcount)+max(Wcount))
            sys.exit()
print(max(Hcount)+max(Wcount)-1)

### FIXED CODE ###

import sys
 
input = sys.stdin.readline
 
 
def main():
    H, W, M = map(int, input().split())
    row = [0] * (H)
    col = [0] * (W)
    bomb = set()
    for _ in range(M):
        h, w = map(int, input().split())
        bomb.add((h, w))
        row[h-1] += 1
        col[w-1] += 1
    row_max = max(row)
    row_index_list = [i for i, v in enumerate(row) if v == row_max]
    col_max = max(col)
    col_index_list = [i for i, v in enumerate(col) if v == col_max]
    ans = row_max + col_max - 1
    c = False
    for x in row_index_list:
        for y in col_index_list:
            if not (x + 1, y + 1) in bomb:
                c = True
                break
        if c:
            break
    if c:
        ans += 1
    print(ans)
 
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
ans = 0
while A:
    a = A.pop(-1)
    if not A or a != A[-1]:
        ans += 1
    A = [i for i in A if i%a != 0]
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
A.sort()
B = [True]*(A[-1]+1)
i = 0
for i in range(N):
  if i < N-1 and A[i] == A[i+1]:
    B[A[i]] = False
  if A[-1] < 2*A[i]:
    continue
  M = A[-1]//A[i]+1
  for j in range(2,M):
    B[j*A[i]] = False

ans = 0
for a in A:
  if B[a]:
    ans += 1
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
solved = []
wa_history = {}

for i in range(m):
    t1, t2 = input().split()
    if t1 in solved:
        pass
    elif t2 == 'WA':
        if t1 in wa_history:
            wa_history[t1] += 1
        else:
            wa_history[t1] = 1
    else: # t2 == AC
        solved.append(t1)

wa = 0
for key in wa_history.keys():
    if key in solved:
        wa += wa_history[key]

print(len(solved), wa)

### FIXED CODE ###

n, m = map(int, input().split())
ss = []

for i in range(m):
    t1, t2 = input().split()
    ss.append([t1, t2])

ss.sort(key=lambda x:x[0])

t = ''
ac = 0
wa = 0
awa = 0
cIsSolved = False
for s in ss:
    if s[0] != t:
        t = s[0]
        cIsSolved = False
        wa = 0
    if s[1] == 'AC' and not cIsSolved:
        cIsSolved = True
        ac += 1
        awa += wa
    if s[1] == 'WA' and not cIsSolved:
        wa += 1
print(ac, awa)
### BUGGY CODE ###

s = list(map(int,list(input())))
c = 0
while s :
    t = len(s)
    for i in range(t-1):
        if (s[i] == 0 and s[i+1] == 1) or (s[i] == 1 and s[i+1] == 0):
            s.remove(s[i])
            s.remove(s[i])
            c += 2
            break
    else:
        print(c)
        exit()

print(c)
    

### FIXED CODE ###

s = input()
print(min(s.count("1"),s.count("0"))*2)
### BUGGY CODE ###

sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx,sy,0)]
for i in range(n):
    data.append(tuple(map(int,input().split())))
data.append((gx,gy,0))
for i in range(n+2):
    for j in range(i+1,n+2):
        tmp=((data[i][0]-data[j][0])**2+(data[i][1]-data[j][1])**2)**0.5-data[i][2]-data[j][2]
        if tmp<0:
            tmp=0
        g[i].append((tmp,j))
        g[j].append((tmp,i))

def dijkstra(g,st,ed):
    from heapq import heappush, heappop, heapify
    dist=[2828427127 for i in range(len(g))]
    dist[st]=0
    que=[]
    heappush(que,(0,st))
    while que:
        c,v=heappop(que)
        if dist[v]<c:
            continue
        for i in range(len(g[v])):
            tmp=g[v][i][0]+c
            if tmp<dist[g[v][i][1]]:
                dist[g[v][i][1]]=tmp
                heappush(que,(tmp,g[v][i][1]))
    return dist[ed]

print(dijkstra(g,0,n+1))

### FIXED CODE ###

from heapq import heappush, heappop
sx,sy,gx,gy=map(int,input().split())
n=int(input())
g = [[] for i in range(n+2)]
data=[(sx+sy*1j,0)]
for i in range(n):
    a,b,c=map(int,input().split())
    data.append((a+b*1j,c))
data.append((gx+gy*1j,0))

for i in range(n+2):
    for j in range(i+1,n+2):
        tmp=abs(data[i][0]-data[j][0])-data[i][1]-data[j][1]
        g[i].append((tmp,j))
        g[j].append((tmp,i))

dist=[2828427127 for i in range(n+2)]
visited=[False for i in range(n+2)]
dist[0]=0
que=[]
heappush(que,(0,0))

while que:
    c,v=heappop(que)
    if visited[v]:
        continue
    visited[v]=True
    for x in g[v]:
        if visited[x[1]]:
            continue
        tmp=x[0]+c if not x[0]<0 else c
        if tmp<dist[x[1]]:
            dist[x[1]]=tmp
            heappush(que,(tmp,x[1]))
print(dist[n+1])
### BUGGY CODE ###

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

tmp=0
for i in range(n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            a,b,c = l[i],l[j],l[k]
            if((a+b>c) & (b+c>a) & (c+a>b)):
                tmp+=1
print(tmp)


### FIXED CODE ###

n=int(input())
L=list(map(int, input().split()))
L.sort()

ans=0
for c in range(n-1,1,-1):
    a=0
    b=c-1
    while(a<b):
        #cが一番長い
        if(L[a]+L[b]>L[c]):
            ans+=b-a
            b-=1
        else:
            a+=1
            
print(ans)
### BUGGY CODE ###

def BinSearch(A, hi, lo):
    b = (hi + lo) // 2
    tmp0 = FindAns(A, b - 1)
    tmp1 = FindAns(A, b)
    if hi == lo:
        tmp2 = FindAns(A, b + 1)
        return min(tmp0, tmp1, tmp2)
    if tmp0 < tmp1:
        return BinSearch(A, b - 1, lo)
    else:
        return BinSearch(A, hi, lo + 1)
    
def FindAns(A, b):
    ans = 0
    for a in A:
        ans += abs(a - b)
    return ans

n = int(input())
A = list(map(int, input().split()))
for i in range(n):
    A[i] -= i + 1
    
hi = max(A)
lo = min(A)

print(BinSearch(A, hi, lo))

### FIXED CODE ###

def BinSearch(A, hi, lo):
    b = (hi + lo) // 2
    tmp0 = FindAns(A, b - 1)
    tmp1 = FindAns(A, b)
    if hi == lo:
        tmp2 = FindAns(A, b + 1)
        return min(tmp0, tmp1, tmp2)
    if tmp0 < tmp1:
        return BinSearch(A, b - 1, lo)
    else:
        return BinSearch(A, hi, b + 1)
    
def FindAns(A, b):
    ans = 0
    for a in A:
        ans += abs(a - b)
    return ans

n = int(input())
A = list(map(int, input().split()))
for i in range(n):
    A[i] -= i + 1
    
hi = max(A)
lo = min(A)

print(BinSearch(A, hi, lo))
### BUGGY CODE ###

N = int(input())
print(sum(v for v in range(N)))


### FIXED CODE ###

N = int(input())
print((N - 1) * N // 2)
### BUGGY CODE ###

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

for i in range(N-1):
    for j in range(N-i-1):
        value += A[i]*A[i+j+1]  
        value = value % (1*10**9 + 7)


print(value)

### FIXED CODE ###

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

A_sum = sum(A)

value = 0
ans = 0

for i in range(N-1):
    A_sum -= A[i]
    value += A[i]*A_sum

ans = value % (1*10**9+7)

print(ans)
### BUGGY CODE ###

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

count = 0

for i in range(1,6):
	for j in range(1,n-1):
		if (9*i+9+63*j)%11 == k:
			count += 1
print(count)

### FIXED CODE ###

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

a = 4;b = 2;c = 0;d = 9;e = 7
f = [a,b,c,d,e]
ans = 0
for i in range((n-2)%11):
	if k in (a,b,c,d,e):
		ans += 1
	a = (a+8)%11
	b = (b+8)%11
	c = (c+8)%11
	d = (d+8)%11
	e = (e+8)%11

print(ans+((n-2)//11)*5)
### BUGGY CODE ###

import numpy as np

n,k=map(int,input().split())
heights=[int(i) for i in input().split()]

dp=np.array([0]*n)
dp[1]=abs(heights[1]-heights[0])

for i in range(2,n):
  dp[i]=min([dp[i-j]+abs(heights[i]-heights[i-j]) for j in range(1,min(k+1,i+1))])
print(dp[n-1])

### FIXED CODE ###

n,k=map(int,input().split())
heights=[int(i) for i in input().split()]

dp=[0]*n
dp[1]=abs(heights[1]-heights[0])

for i in range(2,n):
  step=[]
  for j in range(1,min(k+1,i+1)):
      step.append(dp[i-j]+abs(heights[i]-heights[i-j]))
    
  dp[i]=min(step)
print(dp[n-1])
### BUGGY CODE ###

#単一始点最短経路問題
#負の辺があっても動作する

#最短経路を求める
#計算量O(N * M)

INF = 10 ** 15
#入力
# N = int(input()) #頂点の数
# M = int(input()) #辺の数
N, M, P = map(int, input().split())

# 入力は1-index
# 内部で0-indexにして処理
G = []
for _ in range(M): #M個の辺の情報を受け取る
    l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
    G += [[l-1, r-1, -(s-P)]] #有向グラフのときはここだけ
    # G += [[r-1, l-1, s]] #無向グラフのときはこの行も必要


#メイン文
d = [0] * N #最短距離を記録しておくリスト
# prev = [-1] * N
def shortest_path(s): #S番目の頂点から各頂点への最短距離を求める
    s -= 1
    for i in range(N):
        d[i] = INF
    d[s] = 0
    count = 0
    while True:
        count += 1
        update = False
        for i in range(M): #無向グラフのときは辺は実質的には2倍
            e = G[i]
            if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                update = True
                # prev[e[1]] = e[0]
        if not update: #更新が終わったとき
            return True
        if count == N - 1: #永遠に更新が起きているとき
            tmp = d[N -1]
        if count == 2 * N:
            if d[N - 1] == tmp:
                return True #N-1の値が更新されていないとき
            else:
                return False #N + 2回目でもN - 1の値が小さくなっている-->得点が無限に大きくなる

#呼び出しスタート地点を入れる
if not shortest_path(1):
    print (-1)
    # print (d)
    exit()
# print (d)

print (max(0, -d[N - 1]))


### FIXED CODE ###

#単一始点最短経路問題
#負の辺があっても動作する

#最短経路を求める
#計算量O(N * M)

INF = 10 ** 15
#入力
# N = int(input()) #頂点の数
# M = int(input()) #辺の数
N, M, P = map(int, input().split())

# 入力は1-index
# 内部で0-indexにして処理
G = []
for _ in range(M): #M個の辺の情報を受け取る
    l, r, s = map(int, input().split()) #lからrへ重みsの辺が存在
    G += [[l-1, r-1, -(s-P)]] #有向グラフのときはここだけ
    # G += [[r-1, l-1, s]] #無向グラフのときはこの行も必要


#メイン文
d = [0] * N #最短距離を記録しておくリスト
# prev = [-1] * N
def shortest_path(s): #S番目の頂点から各頂点への最短距離を求める
    s -= 1
    for i in range(N):
        d[i] = INF
    d[s] = 0
    count = 0
    while True:
        count += 1
        update = False
        for i in range(M): #無向グラフのときは辺は実質的には2倍
            e = G[i]
            if d[e[0]] != INF and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                update = True
                # prev[e[1]] = e[0]
        if not update: #更新が終わったとき
            return True
        if count == N - 1: #永遠に更新が起きているとき
            tmp = d[N -1]
        if count == 2 * N:
            if d[N - 1] == tmp:
                return True #N-1の値が更新されていないとき
            else:
                return False #N + 2回目でもN - 1の値が小さくなっている-->得点が無限に大きくなる

#呼び出しスタート地点を入れる
if not shortest_path(1):
    print (-1)
    # print (d)
    exit()
# print (d)

print (max(0, -d[N - 1]))
### BUGGY CODE ###

k, s = map(int, input().split())
ans = 0

for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if s == x + y + z:
                ans += 1
            else:
                pass

print(ans)

### FIXED CODE ###

k, s = map(int, input().split())
ans = 0

for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z >=0 and z <= k:
            ans += 1
        else:
            pass
        

print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
x, y, z, k = map(int, input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)            

abc=[]

for i in range(x):
    for j in range(y):
        for l in range(z):
                if((i+1)*(j+1)*(l+1)<=k):
                        abc.append(a[i]+b[j]+c[l])

abc.sort(reverse=True)
for i in abc[:k]:
    print(i)

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ab = sorted(x+y for x in a for y in b)[:-k-1:-1]
abc = sorted(x+y for x in ab[:k] for y in c)[:-k-1:-1]
print(*abc, sep='\n')
### BUGGY CODE ###

n = int(input())
s = input()
result = 0
for i in range(1000):
    x = format(i, "03")
    p = 0
    for j in range(n):
        if s[j]==x[p]:
            p += 1
            if p==3:
                result += 1
                break
print(result)

### FIXED CODE ###

n = int(input())
s = list(input())[::-1]
result = 0
for i in range(1000):
    x = format(i, "03")
    j = 0
    p = 0
    while p < n:
        if s[p]==x[j]:
            j += 1
            if j == 3:
                result += 1
                break
        p += 1

print(result)
### BUGGY CODE ###

N = int(input())
X = []; Y = []; P = []
INF = float("inf")
for i in range(N):
  x,y,p = list(map(int,input().split()))
  X.append(x);Y.append(y);P.append(p)
ans = [INF for _ in range(N+1)] #0本置いた時からN本置いた時までN+1個
def calc(A):
  n = len(A) #Aにはいくつ入っているか。つまり、xoryで選ばれたものはいくつあるか。
  A.sort()
  res = [INF for _ in range(n+1)] #道が0本からn本
  for s in range(1<<n): #選ばれたものを全探索
    p = [] #最初の大通り
    for i in range(n):
      if (s>>i)&1 == 1: #bitが立っている位置は道があるので追加
        p.append(A[i][0])
    #p.sort()
    now = 0 #現在の移動距離
    pi = 0 #i個目の町の位置よりも小さい位置
    for i in range(n): #i個目の町に注目
      #m = INF
      x = A[i][0] #xoryとして選ばれた町のi番目の位置。
      while pi+1 < len(p) and p[pi+1] < x:
        pi += 1
      m = abs(x)
      if pi < len(p):
        m = min(m,abs(x-p[pi]))
      if pi+1 < len(p):
        m = min(m,abs(x-p[pi+1]))
      #for j in range(len(p)): #すべての道に対して愚直に最短距離を求める。
      #  m = min(m,abs(p[j]-A[i][0]))
      now += m*A[i][1] #最短距離×人数
    b = len(p) #道を何本追加したか。1を引くのは最初の大通り。
    res[b] = min(res[b],now)
  return res
    

for s in range(1<<N): #x軸にするかをbitで全探索
  AX = [];AY = [] #Aは選ばれた村を追加していく。2**N回これは更新される。
  for i in range(N):
    if (s>>i)&1 == 1: #x軸で見る
      AX.append((X[i],P[i]))
    else:
      AY.append((Y[i],P[i]))
    
  dx = calc(AX)
  dy = calc(AY)
  for i in range(len(dx)):
    for j in range(len(dy)):
      ans[i+j] = min(ans[i+j],dx[i]+dy[j])
for t in ans:
  print(t)

### FIXED CODE ###

N = int(input())
X = []; Y = []; P = []
INF = float("inf")
for i in range(N):
  x,y,p = list(map(int,input().split()))
  X.append(x);Y.append(y);P.append(p)
ans = [INF for _ in range(N+1)] #0本置いた時からN本置いた時までN+1個

def calc(A):
  n = len(A) #Aにはいくつ入っているか。つまり、xoryで選ばれたものはいくつあるか。
  A.sort()
  dp = [[INF]*(n+1) for _ in range(n+1)] #i個目までカバーしてj個目まで道を置いた。
  dp[0][0] = 0
  for l in range(n):
    for r in range(l+1,n+1):
      now = INF
      for k in range(l,r):
        s = 0
        for i in range(l,r):
          s += abs(A[i][0]-A[k][0])*A[i][1]
        now = min(now,s)
      for j in range(n):
        dp[r][j+1] = min(dp[r][j+1], dp[l][j]+now)
      now = 0
      for i in range(l,r):
        now += abs(A[i][0])*A[i][1]
      for j in range(n+1):
        dp[r][j] = min(dp[r][j], dp[l][j]+now)

  
  res = [INF for _ in range(n+1)] #道が0本からn本
  for j in range(n+1):
    res[j] = dp[n][j]

  return res
    

for s in range(1<<N): #x軸にするかをbitで全探索
  AX = [];AY = [] #Aは選ばれた村を追加していく。2**N回これは更新される。
  for i in range(N):
    if (s>>i)&1 == 1: #x軸で見る
      AX.append((X[i],P[i]))
    else:
      AY.append((Y[i],P[i]))
    
  dx = calc(AX)
  dy = calc(AY)
  for i in range(len(dx)):
    for j in range(len(dy)):
      ans[i+j] = min(ans[i+j],dx[i]+dy[j])
for t in ans:
  print(t)
### BUGGY CODE ###

from collections import Counter
from operator import mul
from functools import reduce


def combinations_count(n, r):
    if n > 1:
        r = min(r, n - r)
        numer = reduce(mul, range(n, n - r, -1), 1)
        denom = reduce(mul, range(1, r + 1), 1)
        return numer // denom
    else:
        return 0


n = int(input())
a = list(map(int, input().split()))
d = Counter(a)
c = [0 for _ in range(max(a))]
for k, v in d.items():
    c[k - 1] = combinations_count(v, 2)

for i in range(n):
    ans = sum(c)
    p = a[i]
    res = c[p - 1] * (d[p] - 2) / d[p]
    ans -= c[p - 1] - res
    print(int(ans))


### FIXED CODE ###

from collections import Counter

n = int(input())
a = list(map(int, input().split()))
d = Counter(a)
c = [0 for _ in range(max(a))]
for k, v in d.items():
    c[k - 1] = v * (v - 1) / 2

ans = sum(c)
for i in range(n):
    p = a[i]
    res = c[p - 1] * (d[p] - 2) / d[p]
    ans -= c[p - 1] - res
    print(int(ans))
    ans += c[p - 1] - res
### BUGGY CODE ###

n=int(input())
d=sorted([int(i) for i in input().split()])
dif=[0]*d[-1]
for i in d:
    dif[i-1]+=1
SUM=sum(dif)
ans=0
for i in range(n-1):
    S=sum(dif[:d[i]])
    if S==SUM-S:
        ans+=d[i+1]-d[i]
print(ans)

### FIXED CODE ###

n=int(input())
d=sorted([int(i) for i in input().split()])
dif=[0]*d[-1]
ruiseki=[0]*d[-1]
for i in d:
    dif[i-1]+=1
for i in range(d[-1]):
    ruiseki[i]=ruiseki[i-1]+dif[i]
SUM=sum(dif)
ans=0
for i in range(n-1):
    S=ruiseki[d[i]-1]
    if S==SUM-S:
        ans+=d[i+1]-d[i]
print(ans)
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
ans = 0
for i in range(N // R + 1):
    for j in range(N-i+1):
        if (N - i*R - j*G) / B >= 0 and (N - i*R - j*G) % B == 0:
            ans += 1
            
print(ans)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
ans = 0
for i in range(N // R + 1):
    for j in range((N - R*i) // G + 1):
        if (N - i*R - j*G) % B == 0:
            ans += 1
            
print(ans)