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

A, B, C, K = list(map(int, input().split()))

ans = 0
while K:
  K -= 1
  if A:
    ans += 1
    A -= 1
  elif B:
    B -= 1
  else:
    ans -= 1

print(str(ans))

### FIXED CODE ###

A, B, C, K = list(map(int, input().split()))

ans = 0
if A > K:
  print(K)
elif A == K:
  print(A)
elif A + B >= K:
  print(A)
else:
  print(A - (K - A - B))
### BUGGY CODE ###

a,b,k=map(int,input().split());r=range(a,b+1)
for i in sorted(set(r)-set(r[k:-k])):
  print(i)

### FIXED CODE ###

a,b,k=map(int,input().split())
s=list((range(a,b+1)[:k]))
t=list(range(a,b+1)[-k:])
for r in sorted(set([s,s+t][b>k])):print(r)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

from heapq import heappop,heappush
import math

xs,ys,xt,yt = map(int,input().split())
n = int(input())

v = [[xs,ys,0]]
for _ in range(n):
    x,y,r = map(int,input().split())
    v.append([x,y,r])
v.append([xt,yt,0])

def dd(a,b):
    return max(0,math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2) - a[2] - b[2])

edges=[[] for i in range(n+2)]
for i in range(n+2):
    for j in range(n+2):
        if i != j:
            edges[i].append((dd(v[i],v[j]),j))
            edges[j].append((dd(v[i],v[j]),i))

def dijkstra(s,n,edges):
    #edges[source] = [(cost_1,target_1),(cost_2,target_2),...]
    #import 'heap'
    d = [float('inf')] * n
    d[s] = 0
    q = [[d[s],s]]
    while q:
        dist_u, u = heappop(q)
        for c, v in edges[u]:
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q,[d[v],v])
    return d

ans = dijkstra(0,n+2,edges)
print(ans[n+1])

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
from heapq import heappop,heappush
import math
 
xs,ys,xt,yt = map(int,input().split())
n = int(input())
 
v = [[xs,ys,0]]
for _ in range(n):
    x,y,r = map(int,input().split())
    v.append([x,y,r])
v.append([xt,yt,0])
 
def dd(a,b):
    return max(0,math.sqrt((a[0]-b[0])**2 + (a[1]-b[1])**2) - a[2] - b[2])

edges=[[0]*(n+2) for _ in range(n+2)]
for i in range(n+2):
    for j in range(i+1,n+2):
        edges[i][j] = dd(v[i],v[j])
        edges[j][i] = dd(v[i],v[j])

def dijkstra(s,n,edges):
    #edges[i][j] : the cost of i→j
    #import 'heap'
    d = [float('inf') for _ in range(n)]
    d[s] = 0
    q = [(0, s)]
    while q:
        dist_u, u = heappop(q)
        if d[u] < dist_u:
            continue
        for v, c in enumerate(edges[u]):
            if d[v] > dist_u + c:
                d[v] = dist_u + c
                heappush(q, (d[v], v))
    return d

ans = dijkstra(0,n+2,edges)
print(ans[n+1])
### BUGGY CODE ###

# Problem C - Marks
# input
N, K = map(int, input().split())
a_nums = list(map(int, input().split()))

# initialization
cumulative_sum = 1
for i in range(K):
    cumulative_sum *= a_nums[i]
cumulative_list = [0] * N
cumulative_list[K-1] = cumulative_sum

# cumulative sum calc
for i in range(K, N):
    cumulative_sum = cumulative_sum // a_nums[i-K]
    cumulative_sum = cumulative_sum * a_nums[i]
    cumulative_list[i] = cumulative_sum

# check
for i in range(K, N):
    if cumulative_list[i]>cumulative_list[i-1]:
        print("Yes")
    else:
        print("No")


### FIXED CODE ###

# Problem C - Marks
# input
N, K = map(int, input().split())
a_nums = list(map(int, input().split()))

# initialization
cumulative_sum = 1
for i in range(K):
    cumulative_sum += a_nums[i]
cumulative_list = [0] * N
cumulative_list[K-1] = cumulative_sum

# cumulative sum calc
for i in range(K, N):
    cumulative_sum = cumulative_sum - a_nums[i-K]
    cumulative_sum = cumulative_sum + a_nums[i]
    cumulative_list[i] = cumulative_sum
    if cumulative_list[i]>cumulative_list[i-1]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

from collections import Counter
import itertools
N = int(input())
A = list(map(int, input().split()))

def choose2(n):
    return len(list(itertools.combinations(range(n), 2)))

counts = Counter(A)
total = 0
combi_count = [-1] * (N + 1)
for n, count in counts.items(): 
    #初めに、同じ数同士から2つ選んだ時の組み合わせの総和を求める
    combi = choose2(count)
    total += combi 
    combi_count[n] = combi

for i in A:
    #上で求めた組み合わせの総和から、消える数字について1つ減らしたときの組み合わせを減らす
    temp = total - combi_count[i]
    temp += choose2(counts[i] - 1) 
    print(temp)

### FIXED CODE ###

from collections import Counter
N = int(input())
A = list(map(int, input().split()))

def choose2(n):
    return n * (n - 1) // 2

counts = Counter(A)
total = 0
for n, count in counts.items(): 
    #初めに、同じ数同士から2つ選んだ時の組み合わせの総和を求める
    combi = choose2(count)
    total += combi 

for i in A:
    #上で求めた組み合わせの総和から、消える数字について1つ減らしたときの組み合わせを減らす
    temp = total - choose2(counts[i])
    temp += choose2(counts[i] - 1) 
    print(temp)
### BUGGY CODE ###

#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
#読書時間A,B
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
#Aを増やしたときA+Bがkより小さくなるようなi,jを決めて最大値を決めてる
for i in range(n + 1):
    j = m
    if A[i] > k:
        break
    #K<=A[i]+B[j]となるまでjを引く>>k-A<=B
    while B[j] > k - A[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

### FIXED CODE ###

#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
#読書時間A,B
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
j = m
#Aを増やしたときA+Bがkより小さくなるようなi,jを決めて最大値を決めてる
for i in range(n + 1):
    if A[i] > k:
        break
    #K<=A[i]+B[j]となるまでjを引く>>k-A<=B
    while A[i] + B[j] > k:
        j -= 1
    ans = max(ans, i + j)
print(ans)
### BUGGY CODE ###


S = input()

MOD = 10 ** 9 + 7
count = 0
S_len = len(S)

dp = [[0 for i in range(13)] for j in range(100006)]
c = -1
if S[0] != '?':
    c = int(S[0])
for j in range(10):
    if c == -1:
        dp[1][j] = 1
    else:
        dp[1][c] = 1

for i in range(2, S_len + 1):
    c = -1
    if S[i - 1] != '?':
        c = int(S[i - 1])

    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i][(k * 10 + j) % 13] += dp[i - 1][k]

    for j in range(10):
        dp[i][j] %= MOD

print(dp[S_len][5])




### FIXED CODE ###


S = input()

MOD = 10 ** 9 + 7
count = 0
S_len = len(S)

dp = [[0 for i in range(13)] for j in range(100006)]
c = -1
if S[0] != '?':
    c = int(S[0])
for j in range(10):
    if c == -1:
        dp[1][j] = 1
    else:
        dp[1][c] = 1

for i in range(2, S_len + 1):
    c = -1
    if S[i - 1] != '?':
        c = ord(S[i - 1]) - ord('0')

    for j in range(10):
        if c != -1 and c != j:
            continue
        for k in range(13):
            dp[i][(k * 10 + j) % 13] += dp[i - 1][k] % MOD


print(dp[S_len][5] % MOD)
### BUGGY CODE ###

N=int(input())
listA=list(map(int,input().split()))
ans=0
for i in range(N-1):
  if listA[i]<N-i:
    for k in range(i+2,N):
      if k-i==listA[i]+listA[k]:
        ans+=1
print(ans)        

### FIXED CODE ###

N=int(input())
listA=list(map(int,input().split()))
ans=0
L=[]
R=[]
L1=[0]*N
R1=[0]*N
for i in range(N):
  L+=[i+listA[i]]
  R+=[i-listA[i]]
  try:
    L1[i+1+listA[i]]+=1
  except:
    pass
  try:
    if i-listA[i]>0:
      R1[i+1-listA[i]]+=1
  except:
    pass
for i in range(N):
  ans+=L1[i]*R1[i]
print(ans)
### BUGGY CODE ###

n = int(input())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.reverse()
B.reverse()

cnt = 0
dif = 0
for a, b in zip(A, B):
    a += dif
    while a % b != 0:
        a += 1
        dif += 1
        cnt += 1
print(cnt)

### FIXED CODE ###

import math

n = int(input())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.reverse()
B.reverse()

cnt = 0
for a, b in zip(A, B):
    a += cnt
    cnt += math.ceil(a/b) * b - a
print(cnt)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
C_h, C_w = map(int, input().split())
D_h, D_w = map(int, input().split())

S = [input() for _ in range(H)]
dist = [[float("inf") for i in range(W)] for j in range(H)]
dist[C_h-1][C_w-1] = 0

d = deque([[C_h-1, C_w-1, 0]])

def check_movable(h, w):
    if h < 0 or h >= H or w < 0 or w >= W:
        return False
    if S[h][w] == "#":
        return False
    else:
        return True

def check_appnendable(h, w, cost):
    if not check_movable(h,w):
        return False
    if dist[h][w] > cost:
        return True
    else:
        return False

dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
while d:
    h, w, cost = d.pop()
    for dh, dw in zip(dx, dy):
        if check_appnendable(h+dh, w+dw, cost):
            d.append([h+dh, w+dw, cost])
            dist[h+dh][w+dw] = cost
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if check_appnendable(h+dh, w+dw, cost+1):
                d.appendleft([h+dh, w+dw, cost+1])
                dist[h+dh][w+dw] =cost+1

if dist[D_h-1][D_w-1] < float("inf"):
    print(dist[D_h-1][D_w-1])
else:
    print(-1)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
C_h, C_w = map(int, input().split())
D_h, D_w = map(int, input().split())

S = [input() for _ in range(H)]
dist = [[float("inf") for i in range(W)] for j in range(H)]
dist[C_h-1][C_w-1] = 0

d = deque([[C_h-1, C_w-1, 0]])

def check_movable(h, w):
    if h < 0 or h >= H or w < 0 or w >= W:
        return False
    if S[h][w] == "#":
        return False
    else:
        return True

def check_appnendable(h, w, cost):
    if not check_movable(h,w):
        return False
    if dist[h][w] > cost:
        return True
    else:
        return False

dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
while d:
    h, w, cost = d.pop()
    for dh, dw in zip(dx, dy):
        if check_appnendable(h+dh, w+dw, cost):
            d.append([h+dh, w+dw, cost])
            dist[h+dh][w+dw] = cost
    for dh in range(-2, 3):
        for dw in range(-2, 3):
            if check_appnendable(h+dh, w+dw, cost+1):
                d.appendleft([h+dh, w+dw, cost+1])
                dist[h+dh][w+dw] =cost+1

if dist[D_h-1][D_w-1] < float("inf"):
    print(dist[D_h-1][D_w-1])
else:
    print(-1)
### BUGGY CODE ###

N, M = map(int, input().split())
lst_a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7

dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in lst_a else 1
for i in range(2, N+1):
    dp[i] = 0 if i in lst_a else dp[i-1] + dp[i-2]
ans = dp[N] % MOD

print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
set_a = set([int(input()) for _ in range(M)])
MOD = 10**9 + 7

dp = [0] * (N + 1)
dp[0] = 1
dp[1] = 0 if 1 in set_a else 1
for i in range(2, N+1):
    dp[i] = 0 if i in set_a else dp[i-1] + dp[i-2]
ans = dp[N] % MOD

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

n= int(input())
a = list(map(int, input().split()))
g = [[0]*20 for i in range(n)]
for i in range(n):
  e = a[i]
  for j in range(20):
    g[i][j]+=e%2
    e//=2
ans=n
for i in range(n-1):
  c = g[i]
  for j in range(i+1,n):
    f=False
    for k in range(20):
      c[k]+=g[j][k]
      if c[k]>=2:
        f =True
        break
    if f:
      break
    else:
      ans+=1
print(ans)

### FIXED CODE ###

n= int(input())
a = list(map(int, input().split()))
g = [[0]*20 for i in range(n)]
for i in range(n):
  e = a[i]
  for j in range(20):
    g[i][j]+=e%2
    e//=2
ans=0
b =0
c =0
d= [0]*20
s=1
while(1):
  e =0
  if s ==1:
    for i in range(20):
      d[i]+=g[c][i]
      if d[i]>=2:
        e+=1
  else:
    for i in range(20):
      d[i]-=g[b-1][i]
      if d[i]>=2:
        e+=1
  if e==0 and c!=n-1:
    s=1
    c+=1
  elif e!=0:
    ans+=c-b
    s=0
    b+=1
  else:
    ans+=c-b+1
    s=0
    b+=1
    if b==n:
      break
print(ans)
### BUGGY CODE ###

import collections
N = int(input())
S = []
for n in range(N):
    S.append(input())
    
cnt = collections.Counter(S)
ans = []
for k, v in cnt.items():
    if v == cnt.most_common()[0][1]:
        ans.append(k)
        
ans = sorted(ans)
for a in ans:
    print(a)

### FIXED CODE ###

import collections
N = int(input())
S = [input() for n in range(N)]

cnt = collections.Counter(S)
m = max(cnt.values())

ans = []
for k, v in cnt.items():
    if v == m:
        ans.append(k)
        
ans.sort()
for a in ans:
    print(a)
### BUGGY CODE ###

import itertools

mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(len(str(bin(max(a)))) - 2)]
a = [bin(i)[2:] for i in a]

for i in a:
    for j, k in enumerate(i[::-1]):
        if k == "1":
            l[j] += 1
ans = 0
for i, j in enumerate(l):
    ans = (ans + (j * (n - j)) * (2 ** i)) % mod
print(ans)

### FIXED CODE ###

mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(len(str(bin(max(a)))) - 2)]
a = [bin(i)[2:] for i in a]

for i in a:
    for j, k in enumerate(i[::-1]):
        if k == "1":
            l[j] += 1
ans = 0
for i, j in enumerate(l):
    ans = (ans + (j * (n - j)) * (2 ** i)) % mod
print(ans)
### BUGGY CODE ###

import copy
import numpy as np
import collections

n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  ans = 0
  b = copy.copy(a)
  b.pop(i)
  c = np.array(list(collections.Counter(b).values()))
  d = int(sum(c*(c-np.ones(len(c)))//2))
  print(d)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
k = [0]*n
for i in a:
  k[i-1]+=1
g = 0
for i in range(n):
  g+=((k[i]*(k[i]-1))//2)
for i in a:
  print(g+1-k[i-1])
### BUGGY CODE ###

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    c=[0]*m
    for i in range(m):
        a[i],b[i]=map(int,readline().split())
        li=list(map(int,readline().split()))
        for j in range(len(li)):
            c[i]|=1<<(li[j]-1)

    inf=10**9
    dp=[[inf]*(1<<n) for _ in range(m+1)]
    dp[0][0]=0
    for i in range(1,m+1):
        for j in range(1<<n):
            #i番目の鍵を使わない
            dp[i][j]=min(dp[i-1][j],dp[i][j])

            #i番目の鍵を使う
            dp[i][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1])

    ans=dp[m][(1<<n)-1]
    print(ans if ans<inf else -1)

if __name__=="__main__":
    main()

### FIXED CODE ###

from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    a=[0]*m
    b=[0]*m
    c=[0]*m
    for i in range(m):
        a[i],b[i]=map(int,readline().split())
        li=list(map(int,readline().split()))
        for j in range(len(li)):
            c[i]|=1<<(li[j]-1)

    inf=10**9
    dp=[[inf]*(1<<n) for _ in range(m+1)]
    dp[0][0]=0
    for i in range(1,m+1):
        for j in range(1<<n):
            #i番目の鍵を使わない
            dp[i][j]=min(dp[i-1][j],dp[i][j])

            #i番目の鍵を使う
            dp[i][j|c[i-1]]=min(dp[i][j|c[i-1]],dp[i-1][j]+a[i-1])

    ans=dp[m][(1<<n)-1]
    print(ans if ans<inf else -1)

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

N = int(input())
g = [[] for _ in range(0,N+1)]
for i in range(0,N-1):
    a,b,c = map(int,input().split())
    g[a].append((b,c))
    g[b].append((a,c))
Q,K = map(int,input().split())
xy = []
for i in range(0,Q):
    x,y = map(int,input().split())
    xy.append((x,y))

#dijkstra
d = [float("inf") for _ in range(0,N+1)]
d[K] = 0
queue = []
queue.append((K,g[K]))
while queue:
    start,edge = queue.pop(0)
    for to,cost in edge:
        if d[to] > d[start] + cost:
            d[to] = d[start] + cost
            queue.append((to,g[to]))

for x,y in xy:
    print(d[x] + d[y])


### FIXED CODE ###

from collections import deque

N = int(input())
g = [[] for _ in range(0,N+1)]
for i in range(0,N-1):
    a,b,c = map(int,input().split())
    g[a].append((b,c))
    g[b].append((a,c))
Q,K = map(int,input().split())
xy = []
for i in range(0,Q):
    x,y = map(int,input().split())
    xy.append((x,y))

d = [-1 for _ in range(0,N+1)]
d[K] = 0
queue = deque([[K,g[K]]])
while queue:
    start,edge = queue.popleft()
    for to,cost in edge:
        if d[to] != -1:
            continue
        d[to] = d[start] + cost
        queue.append((to,g[to]))

for x,y in xy:
    print(d[x] + d[y])
### BUGGY CODE ###

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

ans = 0
for x in range(k + 1):
    for y in range(min(k + 1, s - x + 1)):
        for z in range(min(k + 1, s - x - y + 1)):
            if x + y + z == s:
                ans += 1

print(ans)


### FIXED CODE ###

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

ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        if 0 <= s - x - y <= k:
            ans += 1

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

N,K,Q = map(int,input().split())
a = [K]*N

for i in range(Q):
    a=list(map(lambda x: x-1, a))
    a[int(input())-1]+=1
for i in range(N):
    if a[i]>0:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N,K,Q = map(int,input().split())
a = [K]*N

for i in range(Q):
    a[int(input())-1]+=1
a=list(map(lambda x: x-Q, a))
for i in range(N):
    if a[i]>0:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

from heapq import heappush, heappop
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

X.sort()
pq = []
ans = 0
for i in range(1, M + 1):
    while (len(X) > 0) and (X[0][0] <= i):
        heappush(pq, (-X[0][1]))
        X = X[1:]
    
    if pq:
        ans -= heappop(pq)
    
print(ans)




### FIXED CODE ###

from heapq import heappush, heappop
from collections import defaultdict
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

cand = defaultdict(list)
for a, b in X:
    cand[a].append(b)

pq = []
ans = 0
for i in range(1, M + 1):
    for c in cand[i]:
        heappush(pq, -c)
    if pq:
        ans -= heappop(pq)
    
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

#+++++
		
def main():
	k, s = map(int, input().split())
	c=0
	for x in range(k+1):
		for y in range(k+1):
			for z in range(k+1):
				c+=1 if x+y+z==s else 0
	
	print(c)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)

### FIXED CODE ###

import sys
input = sys.stdin.readline

#+++++
		
def main():
	k, s = map(int, input().split())
	c=0
	for x in range(k+1):
		for y in range(k+1):
			ccc=s-(x+y)
			c+=1 if ccc <= k and 0<= ccc else 0
	
	print(c)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)
### BUGGY CODE ###

n, k = [int(w) for w in input().split()]
la = [int(w) for w in input().split()]

mul = 1
for i in range(k):
    mul *= la[i]

bef = mul

for i in range(k, n):
    mul /= la[i-k]
    mul *= la[i]

    cond = mul > bef
    print("Yes" if cond else "No")

    bef = mul


### FIXED CODE ###

n, k = [int(w) for w in input().split()]
la = [int(w) for w in input().split()]


for i in range(k, n):
    cond = la[i] > la[i-k]
    print("Yes" if cond else "No")
### BUGGY CODE ###

import itertools

N = int(input())

def g(x, y, z):
    g_xyz = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    return g_xyz


list_g_xyz = []
list_f_n = []
N2 = int(N ** (1 /2) / 2) + 1

for x in range(1, N2 + 1):
    break_flg = False
    for y in range(x, N2 + 1):
        for z in range(y, N2 + 1):
            g_xyz = g(x, y, z)
            f_n = len(set(["".join(map(str, v)) for v in itertools.permutations([x, y, z])]))
            list_g_xyz.append(g_xyz)
            list_f_n.append(f_n)
            # print(f'x, y, z = {x}, {y}, {z},  g(x, y, z) = {g_xyz},  f(n) = {f_n}')

            if g_xyz > N:
                break_flg = True
            if break_flg:
                break
        if break_flg:
            break
            
            
list_ans = []
for target in range(1, N + 1):
    list_index = [i for i, x in enumerate(list_g_xyz) if x == target]
    ans = sum([list_f_n[i] for i in list_index])
    print(ans)
    

### FIXED CODE ###

def g(x, y, z):
    g_xyz = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    return g_xyz


N = int(input())
ans_list = [0 for _ in range(60000)]
for x in range(1, 100):
  for y in range(1, 100):
      for z in range(1, 100):
          ans_list[g(x=x, y=y, z=z) - 1] += 1
           
for i in range(N):
    print(ans_list[i])
### BUGGY CODE ###

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

tyouten = [list(map(int,input().split())) for _ in range(n-1)]
tree = [list(map(int,input().split())) for _ in range(q)]
ans = [0] * n
temp = [] * n
for i in range(n):
    temp.append([i+1])
temp[0] = [x for x in range(1,n+1)]    

tyouten.sort()

for i in range(n-1):
    if i == 0:
        continue
    temp[tyouten[i][0]-1].append(tyouten[i][1])


for i in range(q):
    s = tree[i][0] - 1
    t = tree[i][1]
    if s == 0:
        for i in range(n):
            ans[i] += t
    else:
        for i in temp[s]:
            ans[i-1] += t

print(*ans)

### FIXED CODE ###

n, q = map(int, input().split())
li_nq = [list(map(int, input().split())) for _ in range(n-1)]
li_px = [list(map(int, input().split())) for _ in range((q))]

graph = [[] for _ in range(n+1)]
for i, j in li_nq:
    graph[i].append(j)
    graph[j].append(i)

ans = [0 for _ in range(n+1)]
for i, j in li_px:
    ans[i] += j

check_list = [None] * (n+1)
stack = [1]

while stack:
    num = stack.pop()
    for i in graph[num]:
        if check_list[num] == i:
            continue
        stack.append(i)
        ans[i] += ans[num]
        check_list[i] = num

print(*ans[1:])
### BUGGY CODE ###

def get_prime_list(n):
    data = [i for i in range(2, n+100)]
    for d in data:
        data = [x for x in data if (x == d or x % d != 0)]
    return data


X = int(input())

data2 = get_prime_list(X)
for y in data2:
    if y >= X:
        print(y)
        break


### FIXED CODE ###

import random


def is_prime3(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q-1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q-1 and t & 1 == 0:
            return False
    return True


X = int(input())

while not is_prime3(X):
    X += 1

print(X)
### BUGGY CODE ###

from operator import mul
from functools import reduce
R=10**9+7
K=int(input())
S=input()
N=len(S)

A=0
TF=[1]
TS=[1]
C=[]
for i in range(K+1):
    TF.append(TF[i]*25 %R)
    TS.append(TS[i]*26 %R)
    r = min(i, N-1)
    numer = reduce(mul, range(i+N-1, i+N-1-r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    C.append(numer // denom %R)
for i in range(K+1): # Sに含まれる文字を加えるときは、必ず後ろであると考え、S[N-1]の(Sの文字を除いた)位置をiとする
    A=(A+TF[i]*TS[K-i]*C[i]) %R
print(A)

### FIXED CODE ###

K=int(input())
S=input()
N=len(S)
p=10**9+7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N+K ):
    fact.append((fact[-1] * i) % p) # [-1]は後ろから?
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return (fact[n] * factinv[r] * factinv[n-r]) % p
A=0
TF=[1]
TS=[1]
for i in range(K+1):
    TF.append(TF[i]*25 %p)
    TS.append(TS[i]*26 %p)
for i in range(K+1): # Sに含まれる文字を加えるときは、必ず後ろであると考え、S[N-1]の(Sの文字を除いた)位置をiとする
    A=(A+TF[i]*TS[K-i]*cmb(i+N-1,i,p)) %p
print(A)
### BUGGY CODE ###

n = int(input())
s = input()
cnt = 0
for i in range(1000):
  num = '{:03}'.format(i)
  t=0
  for j in range(n):
    if s[j] == num[t]:
      t += 1
      if t > 2:
        cnt += 1
        break
print(cnt)

### FIXED CODE ###

n = int(input())
s = input()
cnt = 0
for i in range(1000):
  num = '{:03}'.format(i)
  t=0
  for j in range(n):
    if s[j] == num[t]:
      t += 1
      if t > 2:
        cnt += 1
        break
print(cnt)