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

def compute(n, k, h):
    inf = 1e9
    if n == 1:
        return 0
    dp = [inf] * n
    dp[0] = 0
    for i in range(1, n):
        cnt = 1
        while cnt <= k and i - cnt > -1:
            dp[i] = min(dp[i], dp[i - cnt] + abs(h[i] - h[i - cnt]))
            cnt += 1
    return dp[-1]


if __name__ == '__main__':
    N, K = [int(_) for _ in input().split()]
    h = [int(_) for _ in input().split()]
    print(compute(N, K, h))


### FIXED CODE ###

n, k = [int(_) for _ in input().split()]
h = [int(_) for _ in input().split()]
inf = 1e9
dp = [inf] * n
dp[0] = 0
for i in range(1, n):
    cnt = 1
    while cnt <= k and i - cnt > -1:
        dp[i] = min(dp[i], dp[i - cnt] + abs(h[i] - h[i - cnt]))
        cnt += 1
print(dp[-1])
### BUGGY CODE ###

import math
import sys
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*(2*10**5)
for a in range(1,N+1):
    kosuu=A.count(a)
    if kosuu<=1:
        pass
    else:
        numbers.insert(a-1,kosuu)
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
answers=[0]*(2*10**5)
for a in range(1,N+1):
    if numbers[a-1]>=2:
        b=combinations_count(numbers[a-1],2)
        answers[a-1]+=b
kotae=sum(answers)
for a in range(N):
    z=A[a]
    if kotae==0:
        print(0)
    else:
        answer=kotae-numbers[z-1]+1
        print(answer)


### FIXED CODE ###

import math
import sys
from collections import Counter
N=int(input())
a=sys.stdin.readline().split()
A=[int(b) for b in a]
numbers=[0]*N
count=Counter(A)
kotae=0
for a in range(N+1):
    b=count[a]
    kotae+=b*(b-1)//2
for a in A:
    print(kotae+1-count[a])
### BUGGY CODE ###

import numpy as np
N = int(input())
L = np.array(sorted(list(map(int, input().split()))))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        limit_c = a + b
        idx = np.searchsorted(L, limit_c)
        ans += idx - 1 - j
print(ans)


### FIXED CODE ###

from bisect import bisect_left

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        a = L[i]
        b = L[j]
        idx = bisect_left(L, a + b)
        ans += idx - 1 - j
print(ans)
### BUGGY CODE ###

N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=list(set([abs(inputcities[i]-X) for i in range(N)]))
N=len(cities)
count=0
flag=0
minimum=min(cities)
for j in range(minimum+1)[::-1]:
  for i in range(N):
    if sum(cities)%j==0:
      if cities[i]%j==0:
        count+=1
      else:
        count=0
        break
      if count==N:
        print(j)
        flag=1
        break
    else:
      break
  if flag==1:
    break

### FIXED CODE ###

def gcd(a,b):
    if a < b:
        a,b = b,a
    if a % b == 0:
        return b
    else:
        return gcd(b,(a % b))
 
N,X=map(int,input().split())
inputcities=list(map(int, input().split()))
cities=[abs(inputcities[i]-X) for i in range(N)]
cities.sort()
D=cities[0]
for i in range(N):
  D=gcd(D,cities[i])
print(D)
### BUGGY CODE ###

from scipy.sparse.csgraph import shortest_path
import numpy as np
n, x, y = map(int, input().split())
ans = [0] * (n - 1)
table = []
for i in range(n):
    l = [0] * n
    if i + 1 < n:
        l[i + 1] = 1
    if i - 1 > -1:
        l[i - 1] = 1
    if i == x - 1:
        l[y - 1] = 1
    if i == y - 1:
        l[x - 1] = 1
    table.append(l)
a = shortest_path(np.array(table))
a = a.flatten().tolist()
for i in range(1, n):
    print(a.count(i) // 2)


### FIXED CODE ###

n, x, y = map(int, input().split())
ans = [0] * n
for i in range(1, n + 1):
  for j in range(i + 1, n + 1):
    d = min(j - i, abs(i - x) + abs(j - y) + 1)
    ans[d] += 1
    
for i in range(1, n):
    print(ans[i])
### BUGGY CODE ###

# encoding: "utf-8"

class Stdin:
    @staticmethod
    def read_line(converter=str):
        return [converter(x) for x in input().split()]
    
    @staticmethod
    def read_lines(n, converter=str):
        result = list()
        for _ in range(n):
            result.append(Stdin.read_line(converter))
        return result
    
    @staticmethod
    def convert(data, converter):
        assert(len(data) == len(converter))
        return tuple(map(lambda x, f: f(x), data, converter))

    @staticmethod
    def convert_lines(datas, n, converter):
        return [converter(data, n, converter) for data in datas]


def first_count_and_pop(xs):
    cnt = 0
    fst = xs[0]
    for x in xs:
        if x != fst:
            break
        cnt += 1
    return (cnt, xs[cnt:])
        
    

def main():
    _ = input()
    xs = Stdin.read_line(converter=int)
    xs.sort()
    ys = dict()
    while xs:
        key = xs[0]
        cnt, xs = first_count_and_pop(xs)
        ys[key] = cnt
    m = 0
    for x in ys.keys():
        temp = ys.get(x-1, 0) + ys.get(x, 0) + ys.get(x+1, 0)
        if m < temp:
            m = temp
    print(m)

if __name__ == "__main__":
    main()

### FIXED CODE ###

input()
a_list = [int(s) for s in input().split()]

count = [0]*100002

for a in a_list:
    count[a] += 1
    count[a+1] += 1
    count[a+2] += 1
    
print(max(count))
### BUGGY CODE ###

from collections import deque

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

parent = [[] for _ in range(N)]
child = [[] for _ in range(N)]

for _ in range(N - 1 + M):
    pr, ch = map(int, input().split())
    pr -= 1
    ch -= 1
    parent[ch].append(pr)
    child[pr].append(ch)

root = parent.index([])
depth = [-1] * N

st = deque([(root, root)])
while st:
    now, pr = st.popleft()
    if depth[now] >= depth[pr] + 1:
        continue
    depth[now] = depth[pr] + 1
    for ch in child[now]:
        if depth[ch] >= depth[now] + 1:
            continue
        st.append((ch, now))

ans = []
for i in range(N):
    if i == root:
        ans.append(0)
    else:
        for pr in parent[i]:
            if depth[i] == depth[pr] + 1:
                ans.append(pr + 1)
                break

print(*ans, sep='\n')

### FIXED CODE ###

from functools import lru_cache
import sys
sys.setrecursionlimit(10 ** 7)

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

parent = [[] for _ in range(N)]
child = [[] for _ in range(N)]

for _ in range(N - 1 + M):
    pr, ch = map(int, input().split())
    pr -= 1
    ch -= 1
    parent[ch].append(pr)
    child[pr].append(ch)

root = parent.index([])
ans = [-1] * N

# 葉からの検索を行う
@lru_cache(maxsize=None)
def search(now):
    if now == root:
        ans[now] = 0
        return 0
    ret = -1
    for pr in parent[now]:
        depth = search(pr)
        if depth > ret:
            ans[now] = pr + 1
            ret = depth
    return ret + 1

for i in range(N):
    search(i)

print(*ans, sep='\n')
### BUGGY CODE ###

n = int(input())
P = list(map(int, input().split()))
ans = 0

for i in range(n):
  if min(P[:i+1]) == P[i]:
    ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
P = list(map(int, input().split()))
ans = 0
min = n+1

for i in range(n):
  if P[i] < min:
    min = P[i]
    ans += 1
print(ans)
### BUGGY CODE ###

from collections import Counter
n=int(input())
cnt=0  
lst=[[i for i in input()] for j in range(n)]
dic=[[] for i in range(n)]
for i in range(n):
  dic[i]=Counter(lst[i])
for left in range(n-1):
  l=sorted(dic[left].items(),key=lambda x:x[0])
  for right in range(left++1,n):
    r=sorted(dic[right].items(),key=lambda x:x[0])
    flg=True
    for ll,rr in zip(l,r):
      if ll!=rr:
        flg=False
        break
    if flg:
      cnt+=1
print(cnt)      

### FIXED CODE ###

from scipy.misc import comb
n=int(input())
d={}
cnt=0
for i in range(n):
  a=[i for i in input()]
  a.sort()
  b="".join(a)
  d[b]= d[b]+1 if b in d else 1
for k,v in d.items():
  cnt+=comb(v,2,exact=True)
print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

S = input().rstrip()
Q = int(input())
head = ''
tail = ''
rev = False

for _ in range(Q):
    query = list(input().split())
    if query[0] == '1':
        if rev:
            rev = False
        else:
            rev = True
    elif query[0] == '2':
        f = query[1]
        c = query[2].rstrip()
        if f == '1':
            if rev:
                tail = tail + c
            else:
                head = c + head
        else:
            if rev:
                head = c + head
            else:
                tail = tail + c
if rev:
    tmp = head + S + tail
    print(tmp[::-1])
else:
    print(head + S + tail)


### FIXED CODE ###

import sys
input = sys.stdin.readline

S = input().rstrip()
Q = int(input())
head = ''
tail = ''
rev = False

for _ in range(Q):
    query = list(input().split())
    if query[0] == '1':
        if rev:
            rev = False
        else:
            rev = True
    elif query[0] == '2':
        f = query[1]
        c = query[2].rstrip()
        if f == '1':
            if rev:
                tail = tail + c
            else:
                head = c + head
        else:
            if rev:
                head = c + head
            else:
                tail = tail + c
if rev:
    tmp = head + S + tail
    print(tmp[::-1])
else:
    print(head + S + tail)
### BUGGY CODE ###

from operator import itemgetter


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

INF = 10**18
dp = [[INF] * (1 << n) for i in range(n)]
for i in range(n):
    dp[i][1 << i] = i

for bit_state in range(1 << n):
    for i in range(n):
        if not(bit_state & (1 << i)):
            continue
        for j in range(n):
            if bit_state & (1 << j):
                continue
            cnt1 = bin(bit_state).count("1")
            num_i = a[i] if (cnt1 - 1) % 2 == i % 2 else b[i]
            num_j = a[j] if (cnt1) % 2 == j % 2 else b[j]
            if num_i > num_j:
                continue
            cnt0 = bin((bit_state & ((1 << j) - 1)) | (1 << j)).count("0") - 1
            dp[j][bit_state | (1 << j)] = min(dp[j][bit_state | (1 << j)], dp[i][bit_state] + cnt0)

ans = 10**18
for i in range(n):
    ans = min(ans, dp[i][-1]) 
if ans == 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

# Binary Indexed Tree (Fenwick Tree)
class BIT():
    """一点加算、区間取得クエリをそれぞれO(logN)で答える
    add: i番目にvalを加える
    get_sum: 区間[l, r)の和を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = 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, val):
        """i番目にvalを加える"""
        i = i + 1
        while i <= self.n:
            self.bit[i] += val
            i += i & -i

    def get_sum(self, l, r):
        """区間[l, r)の和を求める"""
        return self._sum(r) - self._sum(l)


from operator import itemgetter
from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 10**18


for bit_state in range(1 << n):
    pattern = [[] for i in range(2)]
    for i in range(n):
        if bit_state & (1 << i) and i % 2 == 0:
            pattern[0].append(a[i]*100 + i)
        elif bit_state & (1 << i) and i % 2 == 1:
            pattern[1].append(a[i]*100 + i)
        elif i % 2 == 0:
            pattern[1].append(b[i]*100 + i)
        else:
            pattern[0].append(b[i]*100 + i)

    if len(pattern[0]) == len(pattern[1]) or len(pattern[0]) - 1 == len(pattern[1]):
        for i in range(2):
            pattern[i] = sorted(pattern[i])
        bit = BIT(n)
        ans_tmp = 0
        prev_num = 10**8
        for i in range(n)[::-1]:
            pal = i % 2
            num = pattern[pal].pop()
            ind = num % 100
            num = num // 100
            if prev_num < num:
                break
            prev_num = num
            bit.add(ind, 1)
            ans_tmp += bit.get_sum(0, ind)
        else:
            ans = min(ans, ans_tmp)

if ans == 10**18:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

#C問題
N,K,Q=map(int,input().split())
lists=[]
emptylists=[]

for i in range(Q):
    s=int(input())
    lists.append(s)

for i ,j in enumerate(lists):
    emptylists.append([i,j])


Uselist=[K for i in range(N)]

for nums in range(Q):
    for numbers in range(N):
        if numbers==emptylists[nums][1]-1:
            Uselist[numbers]=Uselist[numbers]
        else:
            Uselist[numbers]=Uselist[numbers]-1

for num in range(N):
    if Uselist[num]>0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

n,k,q=map(int,input().split())
lists=[0]*n
for i in range(q):
    a=int(input())
    lists[a-1]+=1
for i in range(n):
    check=k-(q-lists[i])
    if check>0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

def main():
    from collections import Counter
    from math import factorial as f
    s = input()
    l = len(s)
    n = 2019
    t = [int(s[-i:]) % n for i in range(1, l + 1)]
    c = Counter(t)
    ans = 0
    for k, v in c.items():
        if v > 1:
            c = f(v) // f(v - 2) // 2
            ans += c
        if k == 0:
            ans += v
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from collections import Counter
    s = input()

    n = 2019
    l = [0]
    t = 1
    for i, x in enumerate(s[::-1]):
        t = t * 10 % n
        y = (l[-1] + int(x) * t) % n
        l.append(y)

    c = Counter(l)
    ans = sum([v * (v - 1) // 2 for v in c.values()])
    print(ans)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
value = sum(a)
used = []
import math
for i in range(m):
  if used != []:
    if a != []:
      if max(used) < a[-1]:
        value -= math.ceil(a[-1]/2)
        used.append(math.floor(a[-1]/2))
        a = a[:-1]
      else:
        use = max(used)
        value -= math.ceil(use/2)
        used[used.index(use)] //= 2
    else:
      use = max(used)
      value -= math.ceil(use/2)
      used[used.index(use)] //= 2
  else:
    value -= math.ceil(a[-1]/2)
    used.append(math.floor(a[-1]/2))
    a = a[:-1]
print(value)

### FIXED CODE ###

n, m = map(int, input().split())
a = list(map(lambda x: -int(x), input().split()))
import heapq
import math
value = -sum(a)
heapq.heapify(a)

for i in range(m):
  use = heapq.heappop(a)
  value += math.floor(use/2)
  heapq.heappush(a, math.ceil(use/2))
  
print(value)
### BUGGY CODE ###

n = int(input())
stw = []
x_list = []
y_list = []
for i in range(n):
  x, y = map(int, input().split())
  x_list += [[x, i]]
  y_list += [[y, i]]
x_list.sort()
y_list.sort()
for i in range(n-1):
  xs = x_list[i][1]
  xt = x_list[i+1][1]
  ys = y_list[i][1]
  yt = y_list[i+1][1]
  dis_x = abs(x_list[i][0]-x_list[i+1][0])
  dis_y = abs(y_list[i][0]-y_list[i+1][0])
  stw += [[xs, xt, dis_x]]
  stw += [[xt, xs, dis_x]]
  stw += [[ys, yt, dis_y]]
  stw += [[yt, ys, dis_y]]
  
stw = sorted(stw, key=lambda x:x[2])

class UnionFind():
  def __init__(self, n):
    self.n = n
    self.root = [-1]*(n+1)
    self.rnk = [0]*(n+1)
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]
  def Unite(self, x, y):
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    if(x == y):
      return 
    if self.root[x] > self.root[y]:
      x, y = y, x
    self.root[x] += self.root[y]
    self.root[y] = x 
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)
  def Count(self, x): # xが属するグループのサイズを返す
    return -self.root[self.Find_Root(x)]
  def Members(self, x): # xが属するグループに属する要素をリストで返す
    return [i for i in range(self.n) if self.Find_Root(i)==self.Find_Root(x)]
  def Roots(self): # 全ての根の要素をリストで返す
    return [i for i, x in enumerate(self.root) if x < 0]
  def Group_Count(self): # グループの数を返す
    return len(self.Roots())


def kruskal():
  # stw = [[s0, t0, w0], [s1, t1, w1], ..., [sn, tn, wn]]
  # stw: s: 始点, t: 終点, w: st間の重み
  # stwはwを小さい順にソートされたものとする
  res = 0
  uf = UnionFind(n)
  for i in range(len(stw)):
    s, t, w = stw[i]
    if not uf.isSameGroup(s, t):
      uf.Unite(s, t)
      res += w
  return res

print(kruskal())

### FIXED CODE ###

import itertools
import heapq
from heapq import heappush, heappop
global G, inp_x, inp_y

def input_graph(N):
  global G, inp_x, inp_y
  inp_x = []
  inp_y = []
  for i in range(N):
    x, y = map(int, input().split())
    inp_x.append((x, i))
    inp_y.append((y, i))
  inp_x.sort()
  inp_y.sort()
  for i in range(N-1):
    xa = inp_x[i][1]
    xb = inp_x[i+1][1]
    ya = inp_y[i][1]
    yb = inp_y[i+1][1]
    cost_x = abs(inp_x[i][0]-inp_x[i+1][0])
    cost_y = abs(inp_y[i][0]-inp_y[i+1][0])
    G[xa] += [(cost_x, xb)]
    G[xb] += [(cost_x, xa)]
    G[ya] += [(cost_y, yb)]
    G[yb] += [(cost_y, ya)]

  
def prim(V):
  global G, used
  edgelist = []
  for e in G[0]:
    heappush(edgelist, e)
  used[0] = True
  res = 0
  while edgelist:
    minedge = heappop(edgelist)
    if used[minedge[1]]:
      continue 
    v = minedge[1]
    used[v] = True 
    for e in G[v]:
      if not used[e[1]]:
        heappush(edgelist, e)
    res += minedge[0]
  return res

def main():
  global G, used
  N = int(input())
  G = [[] for _ in range(N)]
  used = [False for _ in range(N)]
  input_graph(N)
  print(prim(N))

if __name__ == "__main__":
  main()
### BUGGY CODE ###

N = int(input())
A = input().split(' ')

intAList = [int(i) for i in A]
sortA = sorted(intAList)

for i in range(1,N+1):
  print(sortA.count(i))

### FIXED CODE ###

N = int(input())
A = input().split(' ')

intAList = [int(i) for i in A]

backet = list([0]*N)
#print(backet)

for i in intAList:
  backet[i-1] += 1

for i in backet:
  print(i)
### BUGGY CODE ###

from collections import Counter
n,x,y = map(int, input().split())
x -= 1
y -= 1
ans = [0]*n
dp = [[0]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
         ans[min(abs(i-j),(abs(i-x)+abs(j-y)+1),(abs(i-y)+abs(j-x)+1))]+=1
for k in range(1,n):
    print(ans[k]//2)

### FIXED CODE ###

from collections import Counter
n,x,y = map(int, input().split())
x -= 1
y -= 1
ans = [0]*n
dp = [[0]*n for _ in range(n)]
for i in range(n):
    for j in range(i,n):
         ans[min(abs(i-j),(abs(i-x)+abs(j-y)+1),(abs(i-y)+abs(j-x)+1))]+=1
for k in range(1,n):
    print(ans[k])
### BUGGY CODE ###

import sys
import math
s = input()
count = 0
num = 1
for _ in range(math.factorial(len(s))):
  num = s.count('BW')
  if num == 0:
    break
  s = s.replace('BW','WB')
  count += num
  
print(count)

### FIXED CODE ###

S = list(input())
W_i = [i for i,j in enumerate(S) if j == 'W']
W_n = S.count('W')
cur = 0
ans = 0
for i in W_i:
  ans += i-cur
  cur += 1
print(ans)
### BUGGY CODE ###

hwd = list(map(int, input().split()))
a = []
for i in range(hwd[0]):
    a.append(list(map(int, input().split())))
q = int(input())
lr = []
for i in range(q):
    lr.append(list(map(int, input().split())))

for i in range(q):
    power = 0
    pre_number = lr[i][0]
    next_number = lr[i][0] + hwd[2]
    while pre_number != lr[i][1]:
        for j in range(hwd[0]):
            for k in range(hwd[1]):
                if a[j][k] == pre_number:
                    pre_xy = [j, k]
                if a[j][k] == next_number:
                    next_xy = [j, k]
        power = power + abs(pre_xy[0] - next_xy[0]) + abs(pre_xy[1] - next_xy[1])
        pre_number = next_number
        next_number = next_number + hwd[2]
    print(power)

### FIXED CODE ###

hwd = list(map(int, input().split()))
a = []
for i in range(hwd[0]):
    a.append(list(map(int, input().split())))
q = int(input())
lr = []
for i in range(q):
    lr.append(list(map(int, input().split())))

xy = [None] * hwd[0] * hwd[1]
for i in range(hwd[0]):
    for j in range(hwd[1]):
        xy[a[i][j] - 1] = [i, j]
        
power_accumulation = []
for i in range(hwd[2]):
    power = [0]
    number = 0
    place = i
    while place < hwd[0] * hwd[1] - hwd[2]:
        power.append(power[number] + abs(xy[place + hwd[2]][0] - xy[place][0]) + abs(xy[place + hwd[2]][1] - xy[place][1]))
        number = number + 1
        place = place + hwd[2]
    power_accumulation.append(power)

for i in range(q):
    test_power = power_accumulation[(lr[i][1] - 1) % hwd[2]][(lr[i][1] - 1) // hwd[2]] - power_accumulation[(lr[i][0]- 1) % hwd[2]][(lr[i][0] - 1) // hwd[2]]
    print(test_power)
### BUGGY CODE ###

N,X,Y=map(int,input().split())
A=[]
for i in range(N-1):
    A.append([-1]*(N-1-i))

Ndmin=[0]*(N-1)
for i in range(N-1):
    for j in range(i+1,N):
        Ndmin[min(j-i,abs(X-i-1)+1+abs(Y-j-1),abs(X-j-1)+1+abs(Y-i-1))-1]+=1

for k in range(N-1):
    print(Ndmin[k])

### FIXED CODE ###

N,X,Y=map(int,input().split())
A=[]
for i in range(N-1):
    A.append([-1]*(N-1-i))

Ndmin=[0]*(N-1)
for i in range(N-1):
    for j in range(i+1,N):
        Ndmin[min(j-i,abs(X-i-1)+1+abs(Y-j-1),abs(X-j-1)+1+abs(Y-i-1))-1]+=1

for k in range(N-1):
    print(Ndmin[k])
### BUGGY CODE ###

N,Y=map(int,input().split())
x,y,z=0,0,0
n=0
for i in range(0,N+1):
    a=Y-10000*i
    if a==0 and i==N:
        x,y,z=i,0,0
    else:
        for j in range(0,N-i+1):
            b=a-5000*j
            if b==0 and i+j==N:
                x,y,z=i,j,0
            else:
                for k in range(0,N-i-j+1):
                    c=b-1000*k
                    if c==0 and i+j+k==N:
                        x,y,z=i,j,k                      
if x==0 and y==0 and z==0:
    print(-1,-1,-1,sep=" ")
else:
    print(x,y,z,sep=" ")


### FIXED CODE ###

import sys
N,Y=map(int,input().split())
n=0
for i in range(0,N+1):
    for j in range(0,N-i+1):
        k=N-i-j
        S=10000*i+5000*j+1000*k
        if (S==Y) and (k>=0):
            print(i,j,k,sep=" ")
            sys.exit()
        else:
            n=n+1
if n==(N+1)*(N+2)/2:
    print(-1,-1,-1,sep=" ")
### BUGGY CODE ###


N = int(input())
S = list(input())

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            val = [i,j,k]
            idx = 0
            for s in S:
                if int(s)==val[idx]:idx+=1
                if idx>2:
                    ans += 1
                    break
print(ans)
            


### FIXED CODE ###

N = int(input())
Ss = list(input())
S = [int(i) for i in Ss]

ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            val = [i,j,k]
            idx = 0
            for s in S:
                if s==val[idx]:idx+=1
                if idx>2:
                    ans += 1
                    break
print(ans)
### BUGGY CODE ###

def factorize2(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    >>> factorize(20)
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b * b <= n:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


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

cnt = 0
for a in A:
    res = factorize2(a)
    if len(res) > 0:
        fct, num = res[0]
        if fct == 2:
            cnt += num
print(cnt)

### FIXED CODE ###

def factorize2(n):
    """
    nの値を素因数分解し、素因数とその指数をtupleにまとめたリストを返す
    e.g.
    >>> factorize(20)
    [(2, 2), (5, 1)]
    """
    b = 2
    fct = []
    while b == 2:
        cnt = 0
        while n % b == 0:
            cnt += 1
            n //= b
        if cnt > 0:
            fct.append((b, cnt))
        b += 1
    if n > 1:
        fct.append((n, 1))
    return fct


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

cnt = 0
for a in A:
    res = factorize2(a)
    if len(res) > 0:
        fct, num = res[0]
        if fct == 2:
            cnt += num
print(cnt)