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

import itertools

n = int(input())
s = input()
nm = [i for i in range(n)]
sl = itertools.combinations(nm, 3)
ans = []

for v in sl:
    a, b, c = v[0], v[1], v[2]
    p = str(s[a]) + str(s[b]) + str(s[c])
    ans.append(p)
    ans_s = set(ans)
    
print(len(ans_s))

### FIXED CODE ###

n = int(input())
s = input()
ans = 0
for i in range(1000):
    tg = str(i + 1000)[1:]
    if tg[0] not in s:
        continue
    else:
        x2 = s[s.index(tg[0]) + 1:]
        if tg[1] not in x2:
            continue
        else:
            x3 = x2[x2.index(tg[1]) + 1:]
            if tg[2] not in x3:
                continue
            else:
                ans += 1
print(ans)
### BUGGY CODE ###

from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans_hash = {}
    num_hash = {}
    for n in A:
        if n in ans_hash:
            print(ans_hash[n])
        else:
            ans = 0
            a = A[:]
            i = a.index(n)
            del a[i]
            val = Counter(a).values()
            for num in val:
                if num in num_hash:
                    ans += num_hash[num]
                else:
                    num_hash[num] = num * (num - 1) // 2
                    ans += num_hash[num]
            ans_hash[n] = ans
            print(ans_hash[n])


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import Counter

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


def main():
    N = int(input())
    A = list(map(int, input().split()))
    C = Counter(A)
    cnt = 0
    for c in C.values():
        cnt += choose(c)

    for a in A:
        ans = cnt
        ans -= choose(C[a])
        ans += choose(C[a] - 1)
        print(ans)


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

# -*- coding: utf-8 -*-

def main():
    def _create_trio(_list):
        ret = []
        ret.append(_list.pop())
        ret.append(_list.pop())
        ret.append(_list.pop(0))
        return ret

    n = int(raw_input())
    a = map(int,raw_input().split())

    a.sort()
    trio_sum = 0

    for i in range(n):
        trio_sum += _create_trio(a)[1]
    
    return trio_sum

print main()


### FIXED CODE ###

# -*- coding: utf-8 -*-

def main():

    n = int(raw_input())
    a = map(int,raw_input().split())

    if n <= 0 or n > 10 ** 5:
        return
    for i in a:
        if i <= 0 or i > 10 ** 9:
            return

    a.sort(reverse=True)
    trio_sum = 0

    for i in range(n):
        index = (i * 2) + 1
        trio_sum += a[index]

    return trio_sum

print main()
### BUGGY CODE ###

#!/usr/bin/env python3
def main():
    import sys
    input = sys.stdin.readline
    h, w, m = map(int, input().split())
    cnt_h = [0] * h
    cnt_w = [0] * w
    bomb = [[False] * w for _ in range(h)]
    for _ in range(m):
        y, x = map(lambda x:int(x) - 1, input().split())
        cnt_h[y] += 1
        cnt_w[x] += 1
        bomb[y][x] = 1
        
    kouho_h = []
    kouho_w = []
    max_h = max(cnt_h)
    max_w = max(cnt_w)
    for i in range(h):
        if cnt_h[i] == max_h:
            kouho_h.append(i)
    for i in range(w):
        if cnt_w[i] == max_w:
            kouho_w.append(i)
    
    for i in kouho_h:
        for j in kouho_w:
            if bomb[i][j] == False:
                print(max_h + max_w)
                exit()
    print(max_h + max_w - 1)



if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python3
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline
    h, w, m = map(int, input().split())
    cnt_h = [0] * h
    cnt_w = [0] * w
    bomb = defaultdict(lambda : 0)
    for _ in range(m):
        y, x = map(lambda x:int(x) - 1, input().split())
        cnt_h[y] += 1
        cnt_w[x] += 1
        bomb[(y, x)] = 1
        
    kouho_h = []
    kouho_w = []
    max_h = max(cnt_h)
    max_w = max(cnt_w)
    for i in range(h):
        if cnt_h[i] == max_h:
            kouho_h.append(i)
    for i in range(w):
        if cnt_w[i] == max_w:
            kouho_w.append(i)
    
    for i in kouho_h:
        for j in kouho_w:
            if bomb[(i, j)] == False:
                print(max_h + max_w)
                exit()
    print(max_h + max_w - 1)



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

S = input()
for _ in range(int(input())):
    l = input().split()
    if len(l) == 1:
        S = S[::-1]
    else:
        if l[1] == "1":
            S = l[2] + S
        else:
            S = S + l[2]
print(S)

### FIXED CODE ###

S = input()
l1 = []
l2 = []
rev = False
for _ in range(int(input())):
    l = [s for s in input().split()]
    if l[0] == "1":
        rev = not rev
    elif l[1] == "1":
        if rev:
            l2.append(l[2])
        else:
            l1.append(l[2])
    else:
        if rev:
            l1.append(l[2])
        else:
            l2.append(l[2])

if rev:
    ret = "".join(l2)[::-1] + S[::-1] + "".join(l1)
else:
    ret = "".join(l1)[::-1] + S + "".join(l2)

print(ret)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *


N, X, Y = MAP()

graph = [[] for _ in range(N)]

for i in range(N-1):
	graph[i].append(i+1)
	graph[i+1].append(i)

graph[X-1].append(Y-1)
graph[Y-1].append(X-1)

dic = defaultdict(int)
for i in range(N):
	q = deque([i])
	dist = [-1]*N
	dist[i] = 0

	while q:
		n = q.popleft()
		for node in graph[n]:
			if dist[node] == -1:
				dist[node] = dist[n] + 1
				q.append(node)

	for i in range(N):
		dic[dist[i]] += 1

for k in range(1, N):
	print(dic[k]//2)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np
#from decimal import *

def dijkstra(E, start): #最短経路のみ
	N_d = len(E)
	dist = [INF] * N_d
	dist[start] = 0
	q = [(0, start)]
	while q:
		dist_v, v = heappop(q)
		if dist[v] != dist_v:
			continue
		for u, dist_vu in E[v]:
			dist_u  = dist_v + dist_vu
			if dist[u] > dist_u:
				dist[u] = dist_u
				heappush(q, (dist_u, u))
	return dist	

N, X, Y = MAP()

graph = [[[1, 1]]] + [[[i-1, 1], [i+1, 1]] for i in range(1, N-1)] + [[[N-2, 1]]]
graph[X-1].append([Y-1, 1])
graph[Y-1].append([X-1, 1]) 

dic = defaultdict(int)

ans = 0
for i in range(N):
	ans = dijkstra(graph, i)
	for key in ans:
		dic[key] += 1

for i in range(1, N):
	print(dic[i]//2)
### BUGGY CODE ###

def resolve():
    n = int(input())
    woker = list(map(int, input().split()))
    for i in range(n):
        print(woker.count(i + 1))


resolve()

### FIXED CODE ###

import collections


def resolve():
    n = int(input())
    woker = list(map(int, input().split()))
    woker_count = collections.Counter(woker)
    for i in range(n):
        print(woker_count[i + 1])


resolve()
### BUGGY CODE ###

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

cnt = 0
for i in range(len(A)+1):
    for j in range(len(B)+1):
        if sum(A[:i])+sum(B[:j]) <= K:
            if i+j > cnt:
                cnt = i+j
print(cnt)

### FIXED CODE ###

N, M, K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
SUM_A=[0 for _ in range(N+1)]
for i in range(N):
    SUM_A[i+1] = A[i] + SUM_A[i]
    if SUM_A[i+1] > K:
        N=i
        break

SUM_B=[0 for _ in range(M+1)]
for i in range(M):
    SUM_B[i+1] = B[i] + SUM_B[i]
    if SUM_B[i+1] > K:
        M=i
        break

cnt = N
for i in range(N+1)[::-1]:
    V=K-SUM_A[i]
    j = cnt-i
    while j < M+1 and SUM_B[j] <= V:
        j += 1
    j-=1
    if i+j > cnt:
        cnt = i+j
print(cnt)
### BUGGY CODE ###

s = input()

cnt_max = 0
for i, s_item in enumerate(s):
  if s_item == 'A':
    cnt = 1
    for ss_item in s[i+1:]:
      cnt += 1
      if ss_item == 'Z':
        if cnt > cnt_max:
          cnt_max = cnt

print(cnt_max)


### FIXED CODE ###

s = input()
print(s.rindex('Z') - s.index('A') + 1)
### BUGGY CODE ###

import numpy as np
in1=list(map(int,input().split(" ")))
#print(in1)
#arr=np.zeros((in1[0],in1[1]))
d={}
for i in range(in1[0]):
    #arr[i]=input().split(" ")
    for n,k in enumerate(input().split(" ")):
        d[int(k)]=[i,n]
#print(arr)
Q=int(input())
test=[]
out=[]
for k in range(Q):
    ans=0
    start,end=list(map(int,input().split(" ")))
    #place=np.where(arr==start)
    place=d[start]
    #print(start,end)
    while start != end:
        #print("ans",ans)
        #nextplace=np.where(arr==start+in1[2])#[1][0]
        nextplace=d[start+in1[2]]
        ans+=abs(nextplace[0]-place[0])
        ans+=abs(nextplace[1]-place[1])
        start+=in1[2]
        place=nextplace

    print(ans)
    #out.append(ans)
#for i in out:
    #print(i)


### FIXED CODE ###

import numpy as np
H, W, D=list(map(int,input().split(" ")))
#print(in1)
#arr=np.zeros((in1[0],in1[1]))
d={}
for i in range(H):
    #arr[i]=input().split(" ")
    for n,k in enumerate(input().split(" ")):
        d[int(k)]=[i,n]
#print(arr)
Q=int(input())
out=[]

cost={}

for i in range(1,D+1):
    now = i + D
    cost[i]=0
    #cost[i]=abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
    while now <= H * W:
        cost[now] = cost[now - D] + abs(d[now][0] - d[now - D][0]) + abs(d[now][1] - d[now - D][1])
        now += D


out=[]
for k in range(Q):
    start,end=list(map(int,input().split(" ")))
    out.append(cost[end]-cost[start])

for i in out:
    print(int(i))
### BUGGY 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()))

ab = []

for s in a:
    for t in b:
       ab.append(s + t)

ab.sort(reverse=True)
c.sort(reverse=True)

ans = []

for i in range(min(k, len(ab))):
    for u in c:
        ans.append(ab[i] + u)

ans.sort(reverse=True)

for i in range(k):
    print(ans[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()))

ab = []

for s in a:
    for t in b:
       ab.append(s + t)

ab.sort(reverse=True)
c.sort(reverse=True)

ans = []

for i in range(min(k, len(ab))):
    for u in c:
        ans.append(ab[i] + u)

ans.sort(reverse=True)

for i in range(k):
    print(ans[i])
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
A=list(map(int,input().split()))
queue=deque(A)
for i in range(M):
    queue.extend([max(queue)//2])
    queue.remove(max(queue))
print(sum(queue))

### FIXED CODE ###

from heapq import heappop,heappush,heapify
n,m=map(int,input().split())
A=list(map(int,input().split()))
A_m=list(map(lambda x: -x,A))
heapify(A_m)
pop=lambda: -heappop(A_m)
push=lambda x: heappush(A_m,-x)
for _ in range(m):
    x=pop()
    push(x//2)
print(-sum(A_m))
### BUGGY CODE ###

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

mod=998244353


def do():
    
    def cmb(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod
    
    n,m,k=INTM()
    
    ans=0
    
    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]
    for i in range( 2, n  ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
    
    for i in range(k+1):
        temp=m
        for _ in range(n-1-i):
            temp=(temp*(m-1))%mod
            #print(_,m-1)
        temp=temp*cmb(n-1,i,mod)%mod
        #print(cmb(n-1,i,mod))
        ans+=temp
        ans=ans%mod
    print(ans)
    
if __name__ == '__main__':
    do()

### FIXED CODE ###

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))

mod=998244353


def do():
    
    def power_func(a,n,p):
        bi=str(format(n,"b"))
        res=1
        for i in range(len(bi)):
            res=(res*res) %p
            if bi[i]=="1":
                res=(res*a) %p
        return res
    
    def cmb(n, r, mod):
        if ( r<0 or r>n ):
            return 0
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod
    
    n,m,k=INTM()
    
    ans=0
    
    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]
    for i in range( 2, n  ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
    
    for i in range(k+1):
        temp=m
        temp=m*power_func(m-1,n-1-i,mod)%mod
        temp=temp*cmb(n-1,i,mod)%mod
        #print(cmb(n-1,i,mod))
        ans+=temp
        ans=ans%mod
    print(ans)
    
if __name__ == '__main__':
    do()
### BUGGY CODE ###

import sys
N,K=map(int, input().split())
a=list(map(int, input().split()))
sum=0
for i in range(0,N):
  sum+=a[i]
if sum<K:#全部不必要
  print(N)
  sys.exit()
if sum==K:#全部必要
  print(0)
  sys.exit()
a.sort()
a.reverse()

#K未満の最大の数字のラベルはどこ？
l=N
for i in range(N-1,-1,-1):
  if a[i]<K:
    l=i
  else:
    break

if l==N:
  print(0)
  sys.exit()

count=N
#lまでの要素が必要か不要かチェック
for i in range(0,l):
  sum=0
  for j in range(l,N):
    if sum+a[j]<K:
      sum+=a[j]
  if sum+a[i]>=K:#必要ってことだ
    count-=1
#lからの要素は自分のことを抜かないといけないことに注意
for i in range(l,N):
  sum=0
  b=a[:]
  C=b.pop(i)
  for j in range(l-1,N-1):
    if sum+b[j]<K:
      sum+=b[j]
  if sum+C>=K:#必要ってことだ
    count-=1
print(count)

### FIXED CODE ###

import sys
N,K=map(int, input().split())
a=list(map(int, input().split()))
sum=0
for i in range(0,N):
  sum+=a[i]
if sum<K:#全部不必要
  print(N)
  sys.exit()
if sum==K:#全部必要
  print(0)
  sys.exit()
a.sort()
a.reverse()
 
#K未満の最大の数字のラベルはどこ？
l=N
for i in range(N-1,-1,-1):
  if a[i]<K:
    l=i
  else:
    break
 
if l==N:
  print(0)
  sys.exit()
 
count=N
#lまでの要素が必要か不要かチェック(使いまわし可能)
sum=0
l_list=[]
for j in range(l,N):
  if sum+a[j]<K:
    sum+=a[j]
    l_list.append(a[j])
for i in range(0,l):  
  if sum+a[i]>=K:#必要ってことだ
    count-=1
#lからの要素は自分のことを抜かないといけないことに注意
for i in range(l,N):
  if a[i] in l_list:
    sum=0
    b=a[:]
    C=b.pop(i)
    for j in range(l-1,N-1):
      if sum+b[j]<K:
        sum+=b[j]
    if sum+C>=K:#必要ってことだ
      count-=1
  else:
    count-=1
print(count)
### BUGGY CODE ###

s=list(input())

c=0
for i in range(len(s)):
    if s[i:i+3]==["A","B","C"]:
        j=1
        ci=1
        while s[i-j]=="A":
            ci+=1
            j+=1
            if i-j<0:
                break
        s[i-j+1]="B"
        s[i-j+2]="C"
        s[i-j+3:i+3]=["A" for i in range(j)]
        c+=ci        

print(c)

### FIXED CODE ###

s=input()

s=s.replace("BC","D")

count=0

c=0
while c<len(s):
    if s[c]=="A" or s[c]=="D":
        d=c
        while s[d]=="A" or s[d]=="D":
            d+=1
            if d==len(s):
                break
        an=0
        for i in range(c,d):
            if s[i]=="A":
                an+=1
            else:
                count+=an
        c=d
    else:
        c+=1

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

import re
S = input()
N1 = re.subn('A','0',S)
N2 = re.subn('BC','1',N1[0])
S_li = N2[0].split('B')

count = 0
for bigstr in S_li:
    if len(bigstr):
        li = bigstr.split('C')
        for l in li:
            if len(l):
                while True:
                    a = l.find('0')
                    bc = l.rfind('1')
                    if a<0 or bc<0:
                        break
                    if a < bc:
                        l = l[a+1:bc]
                        count += (bc-a)
                    else:
                        break

print(str(count))

### FIXED CODE ###

import re
S = input()
N1 = S.replace('A','0').replace('BC','1')
S_li = re.split('B|C',N1)
 
count = 0
for l in S_li:
    a = sum([i for i,x in enumerate(l) if '1' in x])
    su=sum([x for x in range(l.count('1'))])
    count += (a-su)
print(str(count))
### BUGGY CODE ###

import numpy as np
import networkx as nx

INF = float('inf')

def main():
    N, M, L = map(int, input().split())

    G = nx.Graph()
    G.add_nodes_from([i for i in range(1, N+1)])

    edges = []

    for i in range(M):
        a, b, c = map(int, input().split())
        edges.append((a, b, c))
    G.add_weighted_edges_from(edges)
    Q = int(input())
    Queries = []
    for i in range(Q):
        s, t = map(int, input().split())
        Queries.append((s, t))

    
    # ワーシャルフロイド法で、全点間の距離を求める
    cost = nx.floyd_warshall(G)
    # print(cost)
    # 全点間の距離のうち、移動距離がL以内でおさまる頂点同士は、給油せずにすむ
    # そこで、全点間の距離のうち、移動距離がL以内でおさまる頂点同士を距離1で結んだグラフを作成し、
    # そのグラフに対してワーシャルフロイド法で最短距離を計算することで、
    # refuel[x][y] =「xからyへ移動するときの給油回数+1」というグラフを作成できる
    no_refuel_edges = []
    for i in range(1, N+1):
        for j in range(i, N+1):
            if cost[i][j] <= L:
                no_refuel_edges.append((i, j, 1))
    no_refuel = nx.Graph()
    no_refuel.add_nodes_from([i for i in range(1, N+1)])
    no_refuel.add_weighted_edges_from(no_refuel_edges)
    refuel_count = nx.floyd_warshall(no_refuel)
    # print(refuel_count)
    ans = []
    for s, t in Queries:
        d = refuel_count[s][t]
        ans.append(int(d-1) if d != INF else -1)
    
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

### FIXED CODE ###

INF = float('inf')

def warshall_floyd(G):
    # ワーシャルフロイド法で移動距離を求める
    # G[x][y]: xからyへ直接移動するときの距離。直接移動できない場合はINF
    # 
    cost = [g[:] for g in G]
    N = len(G)
    # cost[i][j]: 頂点v_iから頂点v_jへ到達するための辺コストの和
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if cost[i][k] != INF and cost[k][j] != INF:
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
    return cost

def main():
    N, M, L = map(int, input().split())

    # G[x][y]: xからyへ直接移動するときのコスト。移動できない場合はINF
    G = [[INF] * (N+1) for n in range(N+1)]

    for i in range(M):
        a, b, c = map(int, input().split())
        G[a][b] = c
        G[b][a] = c

    Q = int(input())
    Queries = []
    for i in range(Q):
        s, t = map(int, input().split())
        Queries.append((s, t))

    # ワーシャルフロイド法で、全点間の距離を求める
    cost = warshall_floyd(G)

    # 全点間の距離のうち、移動距離がL以内でおさまる頂点同士は、給油せずにすむ
    # そこで、全点間の距離のうち、移動距離がL以内でおさまる頂点同士を距離1で結んだグラフを作成し、
    # そのグラフに対してワーシャルフロイド法で最短距離を計算することで、
    # refuel[x][y] =「xからyへ移動するときの給油回数+1」というグラフを作成できる
    no_refuel = [[1 if x <= L else INF for x in c] for c in cost]

    refuel_count = warshall_floyd(no_refuel)

    ans = []
    for s, t in Queries:
        d = refuel_count[s][t]
        ans.append(d-1 if d != INF else -1)
    
    print(*ans, sep='\n')

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

N = int(input())

def f(n):
    flag = False
    #total = 0
    ans = 0
    i = 134
    for x in range(1,i):
        for y in range(1,i-x):
            for z in range(1,i-(x+y)):
                if (x + y + z)**2 - (x*y + y*z + x*z) == n:
                    #total += 1
                    flag = True
                    break
            if flag:
                break
        if flag:
            break
    if x == i-1:
        ans = 0
    elif x == y and  y== z:
        ans = 1
    elif x == y or y == z or x == z:
        ans = 3
    else:
        ans = 6
    return ans

for i in range(1,N+1):
    print(f(i))

### FIXED CODE ###

N = int(input())


ans = [0]*(N+1)
i = 102
for x in range(1,i):
    for y in range(1,i):
        for z in range(1,i):
            total = (x + y + z)**2 - (x*y + y*z + x*z)
            if total <= N:
                ans[total] += 1

for i in range(1,N+1):
    print(ans[i])
### BUGGY CODE ###

N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))

been = [False]*N
n_been=0
loops = []

while True:
    #スタート地点を選ぶ
    for i in range(N):
        if not been[i]:
            now=i
            break
    else:
        break
    cand=[]       
    for _ in range(N):
        if been[now]:
            break
        else:
            cand.append(C[now])
            been[now]=True

        now = P[now]-1
    loops.append(cand)

ans=-10**20
for l in loops:
    m=len(l)
    sum_l = sum(l)
    if sum_l>0:
        k_gene = range(max(0,K-m), K+1)
    else:
        k_gene = range(1,min(m,K)+1)
    for k in k_gene:
        for i in range(m):
            if m-i>=K:
                cand = sum(l[i:i+k]) 
            else:
                cand = sum(l[i:]) +sum_l* ((k-m+i)//m) + sum(l[:(k-m+i)%m] ) 
            ans=max(ans,cand)
            

print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))

been = [False]*N
n_been=0
loops = []

while True:
    #スタート地点を選ぶ
    for i in range(N):
        if not been[i]:
            now=i
            break
    else:
        break
    cand=[]       
    for _ in range(N):
        if been[now]:
            break
        else:
            cand.append(C[now])
            been[now]=True

        now = P[now]-1
    loops.append(cand)

ans=-10**20
for l in loops:
    m=len(l)
    sum_l = sum(l)
    
    rui =[None]*(m+1)
    rui[0]=0
    for i in range(m):
        rui[i+1] = rui[i]+l[i]

    if sum_l>0:
        k_gene = range(max(0,K-m), K+1)
    else:
        k_gene = range(1,min(m,K)+1)
    for k in k_gene:
        for i in range(m):
            if m-i>=k:
#                cand = sum(l[i:i+k]) 
                cand =rui[i+k]-rui[i]
            else:
#                cand = sum(l[i:])     +sum_l* ((k-m+i)//m) + sum(l[:(k-m+i)%m] ) 
                cand = rui[-1]-rui[i] +sum_l* ((k-m+i)//m) + rui[(k-m+i)%m] 
            ans=max(ans,cand)
            

print(ans)