Harryxun/stf_run huggingface dataset:
n, k = input().split()
n = int(n)
k = int(k)
divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    return pTri[n][m]

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
    print(comb(k - 1, i - 1) * comb(n - k + 1, i)%divnum)

### FIXED CODE ###

n, k = input().split()
n = int(n)
k = int(k)
divnum = 10**9+7

pTri =[[1]]
rowNum = 2000

def comb(n,m):
    return pTri[n][m]

for i in range(1,rowNum):
    ls = [1]
    for j in range(1,i):
        ls.append(pTri[i-1][j-1] + pTri[i-1][j])
    ls.append(1)
    pTri.append(ls)

for i in range(1,k+1):
    if (n-k+1 >= i):
        print(comb(k-1, i-1) % divnum * comb(n-k+1, i) % divnum)
    else:
        print(0)
N,K = map(int,input().split(" "))
H = list(map(int,input().split(" ")))
#DPテーブル作成
dp = [10**10]*(len(H)+100)

dp[0]=0

for i in range(N):
    for j in range(K):
        dp[i+j]=min(dp[i+j],dp[i]+abs(H[i]-H[i+j]))

print(dp[N])

### FIXED CODE ###

N,K = map(int,input().split(" "))
H = list(map(int,input().split(" ")))
#DPテーブル作成
dp = [10**10]*(N)

dp[0]=0

for i,hi in enumerate(H):
    if i ==0:
        continue
    s = i-K if i-K>=0 else 0
    dp[i] = min([dpk+abs(hi-hk) for dpk,hk in zip(dp[s:i],H[s:i])])
print(dp[-1])
#print(dp)
n = int(input())
if n / 2 % == 1:
  print("No")
  exit()
s = input()
if s[:n/2] == s[n/2:]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
s = input()
if s[:n//2] == s[n//2:]:
  print("Yes")
else:
  print("No")
n = int(input())
a = list(map(int, input().split(" ")))

for a_i in set(a):
	a.remove(a_i)
max_2 = sorted(a, reverse=True)[:2]
print(max_2[0]*max_2[1])

### FIXED CODE ###

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

a.sort()
maxs = []
for i in range(2):
	max_1 = a.pop()
	while True:
		max_2 = a.pop()
		if max_1 == max_2:
			maxs.append(max_1)	
			break
		max_1 = max_2
		if len(a) == 0:
			print(0)
			exit()
print(maxs[0]*maxs[1])
n,m=map(int,input().split())
a=list(map(int,input().split()))
if n-sum(a)<=0:
  print(-1)
else print(n-sum(a))

### FIXED CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
if n-sum(a)<0:
    print(-1)
else:
    print(n-sum(a))
import sys
from io import StringIO
import unittest

    lines = sys.stdin.readlines()
    lines = list(map(lambda x: int(x.rstrip()), lines))
    n = lines[0]
    i = 1
    for c in range(1, n+1):
        i = lines[i]
        if i == 2:
            print(c)
            return
    print(-1)

### FIXED CODE ###

import sys
from io import StringIO
import unittest

def resolve():
    lines = sys.stdin.readlines()
    lines = list(map(lambda x: int(x.rstrip()), lines))
    n = lines[0]
    i = 1
    for c in range(1, n+1):
        i = lines[i]
        if i == 2:
            print(c)
            return
    print(-1)
    
resolve()
import sys

size = int(input())
a = map(int, input().split())
cnt = 0

while true:
  for i in range(size):
    if(a[i]%2 == 1):
      print(cnt)
      sys.exit()
    
  a = map(lambda x:x/2, a)
  cnt +=1
  

### FIXED CODE ###

a = input()
cnt = 0
for i in a:
  if i == '1':
    cnt+=1
    
print(cnt)
from collections import defaultdict


def main():
    flag_imp = 0
    n, m = map(int, input().split())
    conds = list(set([input() for i in range(m)]))
    conds_dict = defaultdict(list)
    for c in conds:

        conds_dict[int(c.split()[0])].append(c.split()[1])
 
    if max(list(map(len, conds_dict.values()))) > 1:
        flag_imp += 1
    else:
        try:
            first_digit = conds_dict[1][0]
        except IndexError:
            if n == 1:
                first_digit = "0"
            else:
                flag_imp += 1
        try:
            seond_digit = conds_dict[2][0]
        except IndexError:
            seond_digit = "0"

        try:
            third_digit = conds_dict[3][0]
        except IndexError:
            third_digit = "0"
           
    if flag_imp:
        print(-1)
    elif n > 1 and first_digit == "0":
        print(-1)
    else:
        if n == 1:
            print(first_digit)
        elif n == 2:
            print(first_digit + seond_digit)
        else:
            print(first_digit + seond_digit + third_digit)


if __name__ == "__main__":
    main()


### FIXED CODE ###

n, *D  = [list(map(int, s.split())) for s in open(0)]
imp = 0
dic = dict()
D = sorted(D)
cond = []
for d in D:
    if n[0] != 1 and d[0] == 1 and d[1] == 0:
        imp += 1
    if d not in cond:
        cond.append(d)
        if d[0] in dic:
            imp += 1
        else:
            dic[d[0]] = d[1]

s = ""
if imp:
    print(-1)
else:
    for i in range(n[0]):
        if i + 1 in dic:
            s += str(dic[i+1])
        else:
            if i == 0 and n[0] > 1:
                s += str(1)
            else:
                s += str(0)
    print(s)
n,m = list(map(int, input().split()))
s = [0 for i in range(n+1)]
t = [-1 for i in range(n+1)]
for i in range(m):
    x = int(input())
    s[x] = 1

def dx(r):
    global t
    if t[r]>=0:
        return t[r]
    x=0
    y=0
    #print(i)
    if r==n-2:
        return 2
    if r==n-1:
        return 1
    if r==n:
        return 0
    if s[r+1] == 0:
        x=dx(r+1)
    if s[r+2] == 0:
        y=dx(r+2)
    #print([i,x,y])
    t[r]=(x+y)%1000000007
    return (x+y)%1000000007

ans=dx(0)

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
n,m = list(map(int, input().split()))
s = [0 for i in range(n+1)]
t = [-1 for i in range(n+1)]
for i in range(m):
    x = int(input())
    s[x] = 1

def dx(r):
    global t
    if t[r]>=0:
        return t[r]
    x=0
    y=0
    #print(i)
    if s[r+1]==0 and r==n-2:
        return 2
    if s[r+1]==1 and r==n-2:
        return 1
    if r==n-1:
        return 1
    if r==n:
        return 0
    if s[r+1] == 0:
        x=dx(r+1)
    if s[r+2] == 0:
        y=dx(r+2)
    #print([i,x,y])
    t[r]=(x+y)%1000000007
    return (x+y)%1000000007

ans=dx(0)

print(ans)
n = int(input())

for x in range(1, 10**6):
    if x**2 >= n:
        y = x
        break

i, j = y, y
for x in range(10**6):
    if i*j == n:
        ans = i + j - 2
        break
    elif i*j > n:
        i -= 1
    elif i*j < n:
        j += 1

print(ans)

### FIXED CODE ###

import math

n = int(input())

ans  = 10 ** 12 
for i in range(1, math.floor(math.sqrt(n)) + 1):
    if n%i != 0:
        continue
    j = int(n/i)
    ans = min(ans, i+j-2)

print(ans)
N,M=map(int,input().split())
from heapq import heappop,heappush 

graph=[[] for _ in range(M)]
for _ in range(M):
    A,B=map(int,input().split())
    A,B=A-1,B-1
    graph[A].append(B)
    graph[B].append(A)

mark=[-1]*(N-1)

inf=float("inf")

di=[inf]*N
di[0]=0
hq=[(0,0)]

while hq:
    t,r=heappop(hq) #time room
    if t>di[r]:
        continue
    for x in graph[r]:
        t_new=t+1
        r_new=x
        if t_new<di[r_new]:
            di[r_new]=t_new
            heappush(hq,(t_new,r_new))
            if mark[r_new-1]==-1:
                mark[r_new-1]=r
            else:
                print("No")
                exit()
    
print("Yes")
for i in mark:
    print(i+1)

### FIXED CODE ###

N,M=map(int,input().split())
from heapq import heappop,heappush 

graph=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    A,B=A-1,B-1
    graph[A].append(B)
    graph[B].append(A)

mark=[-1]*(N-1)

inf=float("inf")

di=[inf]*N
di[0]=0
hq=[(0,0)]

while hq:
    t,r=heappop(hq) #time room
    if t>di[r]:
        continue
    for x in graph[r]:
        t_new=t+1
        r_new=x
        if t_new<di[r_new]:
            di[r_new]=t_new
            heappush(hq,(t_new,r_new))
            if mark[r_new-1]==-1:
                mark[r_new-1]=r
            else:
                print("No")
                exit()
    
print("Yes")
for i in mark:
    print(i+1)
import math


def sieve_of_eratosthenes(N):
    sqrt_N = math.sqrt(N)
    prime_list = [True for _ in range(N + 1)]
    prime_list[0] = False
    prime_list[1] = False
    for p in range(2, int(sqrt_N) + 1):
        if prime_list[p]:
            for i in range(2 * p, N + 1, p):
                prime_list[i] = False

    return prime_list


Q = int(input())
Max_ = 10**5
prime_list = sieve_of_eratosthenes(Max_)
prime_check_list = [0]*(Max_ + 1)
for i in range(1, Max_ + 1, 2):
    if prime_list[i] and prime_list[(i + 1) // 2]:
        a_list[i] = 1
for _ in range(Q):
    l, r = map(int, input().split())
    print(sum(a_list[l:r+1]))

### FIXED CODE ###

def sieve_of_eratosthenes(N):
    prime_list = [True for _ in range(N + 1)]
    prime_list[0] = False
    prime_list[1] = False
    for p in range(2, int(N ** 0.5) + 1):
        if prime_list[p]:
            for i in range(2 * p, N + 1, p):
                prime_list[i] = False

    return prime_list


Q = int(input())
Max_ = 10**5
prime_list = sieve_of_eratosthenes(Max_)
count_list = [0]*(Max_+1)
count = 0
for i in range(Max_+1):
    if prime_list[i] and prime_list[(i + 1) // 2]:
        count += 1
    count_list[i] = count
for _ in range(Q):
    l, r = map(int, input().split())
    print(count_list[r] - count_list[l-1])
n,k = map(int,input().split())
a = list(map(int,input().split()))
ans = a[0] + k - a[-1]
for i in range(n-1):
  ans = max(ans, a[i+1]-a[i])
print(k-ans)

### FIXED CODE ###

k,n = map(int,input().split())
a = list(map(int,input().split()))
ans = a[0] + k - a[-1]
for i in range(n-1):
  ans = max(ans, a[i+1]-a[i])
print(k-ans)
class Node(object):
    def __init__(self, N):
        self.p = [-1 for i in range(N)]
        self.l = [-1 for i in range(N)]
        self.r = [-1 for i in range(N)]
        self.D = [-1 for i in range(N)]

    def set_depth(self, u, p):
        self.D[u] = p
        if self.r[u] is not -1:
            self.set_depth(self.r[u], p)
        if self.l[u] is not -1:
            self.set_depth(self.l[u], p+1)

    def print_children(self, u):
        children = []
        flag = self.l[u]
        while flag is not -1:
            children.append(flag)
            flag = self.r[flag]
            
        return children

N = int(input())
T = Node(N)

for j in range(N):
    A = [int(i) for i in input().readline().split()]
    
    # left????±????
    if len(A) > 2:
        T.l[j] = A[2]
    else:
        T.l[j] = -1

    # parent???right????±????
    for index, i in enumerate(A[2:]):
        if(A[-1] == i):
            T.p[i], T.r[i] = A[0], -1
        else:
            T.p[i], T.r[i] = A[0], A[index+3]

T.set_depth(0, 0)

for i in range(N):
    if T.p[i] is -1:
        node = "root"
    elif T.l[i] is -1:
        node = "leaf"
    else:
        node = "internal node"
        
    print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(i, T.p[i], T.D[i], node, T.print_children(i)))

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(100000)
class Node(object):
    # left????????¨??????????????????(leaf), right???s?????¨??????????????????????????????
    # ???????????????????????????????????¨???????????´??????parent???-1?????????
    def __init__(self, N):
        self.p = [-1 for i in range(N)]
        self.l = [-1 for i in range(N)]
        self.r = [-1 for i in range(N)]
        self.D = [0 for i in range(N)]

    def set_depth_rec(self, u, p):
        self.D[u] = p
        if self.r[u] is not -1:
            self.set_depth(self.r[u], p)
        if self.l[u] is not -1:
            self.set_depth(self.l[u], p+1)

    def set_depth(self, u):
        d = 0
        pre_u = u
        while self.p[u] is not -1:
            u = self.p[u]
            d += 1
        self.D[pre_u] = d

    def print_children(self, u):
        children = []
        flag = self.l[u]
        while flag is not -1:
            children.append(flag)
            flag = self.r[flag]
            
        return children
        

N = int(input())
T = Node(N)

for j in range(N):
    A = [int(i) for i in input().split()]
    
    # left????±????
    if len(A) > 2:
        T.l[A[0]] = A[2]
    else:
        T.l[A[0]] = -1

    # parent???right????±????
    for index, i in enumerate(A[2:]):
        if(A[-1] == i):
            T.p[i], T.r[i] = A[0], -1
        else:
            T.p[i], T.r[i] = A[0], A[index+3]
    
#T.set_depth_rec(T.p.index(-1), 0)
for i in range(N):
    T.set_depth(i)

for i in range(N):
    if T.p[i] is -1:
        node = "root"
    elif T.l[i] is -1:
        node = "leaf"
    else:
        node = "internal node"
        
    print("node {0}: parent = {1}, depth = {2}, {3}, {4}".format(i, T.p[i], T.D[i], node, T.print_children(i)))
S = input('天気が雨である日が連続していた最大の日数を出力せよ。')
[n1,n2,n3] = S.split() 
if n1 == S
	if n2 == S
  		if n3 == S
    		print(3)
      	else 
        	print(2)
	else     
    	if n3 == S
      		print(1)
        else
        	print(2)
else
	if n2 == S
  		if n2 == S
    		print(2)
      	else
        	print(1)
	else
    	if n2 == S
      		print(2)
        else
        	print(3)


### FIXED CODE ###

S = input()
if S == 'SSS':
  print(0)
elif S == 'SRR':
  print(2)
elif S == 'RRS':
  print(2)
elif S == 'RRR':
  print(3)
else:
  print(1)
n,m,c = map(int,input().split())
input_b = map(int,input().split())
list_a=[list(map(int,input().split()))]
for i in range(n):
  answer = c
  count = 0
  lista_item = list_a[i]
  for j in range(m):
    answer += input_b[m] * lista_item[m]
  if answer > 0
    count+=1
print count

### FIXED CODE ###

n,m,c = map(int,input().split())
input_b = list(map(int,input().split()))
a_list=[input() for i in range(n)]
count = 0
for i in range(n):
  answer = c
  aitems = list(map(int,a_list[i].split()))
  for j in range(m):
    answer += input_b[j] * aitems[j]
  if answer > 0:
    count+=1
print(count)
# seishin.py
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

M = 28
MSK = [(1 << i) - 1 for i in range(1, M+2)]
MOD = [(1 << i) for i in range(1, M+2)]

def make(B, v):
    S = [set() for i in range(M)]

    for i, s in enumerate(S):
        m = MSK[i]
        for b in B:
            s[b & m] = s.get(b & m, 0) ^ 1
    T = [sorted(v for v in s if s[v]) for s in S]
    if v:
        for i in range(1, M):
            m = MOD[i]
            T[i] += list(map(lambda x: x+m, T[i]))
    return T
S = make(A, 0)
T = make(B, 1)

ans = 0
V0 = [1 in T[0], 0 in T[0]]
if 0 in S[0]:
    ans ^= 1 in T[0]
if 1 in S[1]:
    ans ^= 0 in T[0]

for i in range(1, M):
    s = S[i]; ls = len(S)
    t = T[i]; lt = len(t)
    m = MOD[i]; p = MOD[i-1]
    P = p+m; Q = 2*m

    if lt:
        c = 0
        f = lt
        while P < t[f-1]:
            f -= 1

        u = f; v = lt
        for a in s:
            while u > 0 and P <= a + t[u-1]:
                u -= 1
            while v > 0 and Q <= a + t[v-1]:
                v -= 1
            c += (v - u)
        if c & 1:
            ans ^= 1 << i
print(ans)

### FIXED CODE ###

# seishin.py
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

M = 32
MOD = [(2 << i) for i in range(M+1)]

from bisect import bisect
def make(B, mode):
    S = [None]*M
    s = {}; get = s.get
    for b in B:
        s[b] = get(b, 0) ^ 1
    S[M-1] = sorted(b for b in s if s[b])

    for i in range(M-2, -1, -1):
        t = S[i+1]; l = len(t)
        m = MOD[i]
        mid = q = bisect(t, m-1)
        p = 0
        if q < l:
            if p < mid:
                def gen(p, q):
                    u = t[p]; v = t[q]
                    while p < mid and q < l:
                        if u+m == v:
                            p += 1; u = t[p] if p < mid else None
                            q += 1; v = t[q] if q < l else None
                        elif u+m < v:
                            yield u
                            p += 1; u = t[p] if p < mid else None
                        else:
                            yield v-m
                            q += 1; v = t[q] if q < l else None
                    while p < mid:
                        yield t[p]; p += 1
                    while q < l:
                        yield t[q]-m; q += 1
                *S[i], = gen(p, q)
            else:
                *S[i], = (u-m for u in t)
        else:
            *S[i], = t
    if mode:
        for i in range(M):
            m = MOD[i]
            S[i] += list(map(lambda x: x+m, S[i]))
    return S
S = make(A, 0)
T = make(B, 1)

ans = 0
if 0 in S[0]:
    ans ^= 1 in T[0]
if 1 in S[0]:
    ans ^= 0 in T[0]

for i in range(1, M):
    s = S[i]; ls = len(S)
    t = T[i]; lt = len(t)
    m = MOD[i]; p = MOD[i-1]
    P = p+m; Q = 2*m

    if lt:
        c = 0
        f = lt
        while P <= t[f-1]:
            f -= 1

        u = f; v = lt
        for a in s:
            while u > 0 and P <= a + t[u-1]:
                u -= 1
            while v > 0 and Q <= a + t[v-1]:
                v -= 1
            c += (v - u)
        if c & 1:
            ans ^= 1 << i
print(ans)
def mi(): return map(int,input().split())
def lmi(): return list(map(int,input().split()))
def ii(): return int(input())
def isp(): return input().split()

n=ii()
a=lmi()
suma=sum(a)
Counter=[0]*(10**5)
for i in a:
  Counter[i]+=1
#print(Counter)
q=ii()

for i in range(q):
  b,c=mi()
  suma+=(c-b)*Counter[b]
  
  Counter[c]+=Counter[b]
  Counter[b]=0
  #print(Counter)
  print(suma)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
suma=sum(a)
q=int(input())
b=[]
c=[]
for i in range(q):
  b_,c_=map(int,input().split())
  b.append(b_)
  c.append(c_)

counter=[0]*(10**5+1)
for i in a:
  counter[i]+=1
new_sum=suma
for i in range(q):
  new_sum=new_sum-b[i]*counter[b[i]]+c[i]*counter[b[i]]
  
  counter[c[i]]+=counter[b[i]]
  counter[b[i]]=0
  print(new_sum)
be=list(map(str,input().split()))
af=list(map(str,input().split()))
ans=0
for i in range (0,2):
  	if be[i]==af[i]:
    	ans+=1
print(ans)

### FIXED CODE ###

be=input()
af=input()
ans=0
for i in range (3):
    if be[i]==af[i]:
        ans+=1
print(ans)
from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = []
for i in range(N):
    l.append(stdin.readline().rstrip().split())
k = l[0]
for i in range(N):
    k = k&l[i]
print(len(k))

### FIXED CODE ###

from sys import stdin
N, M = [int(x) for x in stdin.readline().rstrip().split()]
l = []
m = []
for i in range(N):
    l.append(stdin.readline().rstrip().split())
    l[i].pop(0)
k = l[N-1]
for i in range(N-1):
    k = set(k)&set(l[i])
print(len(k))
str1, str2 = [s for s in input().split()]
a = str(str1)*str2
b = str(str2)*str2
if a > b:
    print(a)
elif a < b:
    print(b)
else:
    print(a)

### FIXED CODE ###

str1, str2 = [s for s in input().split()]
if str1 == str2:
    print('Yes')
else:
    print('No')
import sys
Row=int(input())
 

X = map(int, input().strip())
 
res = float('inf')
for i in range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(res)


### FIXED CODE ###

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

res=0
for i in Xs:
    res = res + (i-round(sum(Xs)/N))**2

print(res)
def f(k):
  if k==0:return 0
  if k<0: return 100000
  if dp[k]!=-1:return dp[k]
  f1=f(k-1)+abs(h[k]-h[k-1])
  f2=f(k-2)+abs(h[k]-h[k-2])
  dp[k]=min(f1,f2)
  return dp[k]
n=int(input())
h=list(map(int,input().split()))
dp=[-1]*n
print(f(n-1))


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def f(k):
  if k==0:return 0
  if k<0: return 100000
  if dp[k]!=-1:return dp[k]
  f1=f(k-1)+abs(h[k]-h[k-1])
  f2=f(k-2)+abs(h[k]-h[k-2])
  dp[k]=min(f1,f2)
  return dp[k]
n=int(input())
h=list(map(int,input().split()))
dp=[-1]*n
print(f(n-1))
#-*-coding:utf-8-*-

import math

def calculate_length(A,B,theta):
    radian=math.radians(theta)
    length=(A**2)+(B**2)-(2*A*B*math.cos(radian))
    return  math.sqrt(length)

def main():
    A,B,H,M = map(int,input().split())
    thetaA=H*30+M*0.5
    thetaB=M*6
    if thetaA > thetaB:
        theta=thetaA-thetaB
    elif thetaA < thetaB:
        theta = thetaB-thetaA
    else:
        print("0")
    length=calculate_length(A,B,theta)
    print(length)

if __name__=="__main__":
    main()

### FIXED CODE ###

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

import math

def calculate_length(A,B,rad):
    length=(A**2)+(B**2)-(2*A*B*math.cos(math.pi*rad/180))
    return  math.sqrt(length)

def main():
    A,B,H,M = map(int,input().split())
    rad = abs((H*60+M)*0.5-M*6)
    length=calculate_length(A,B,rad)
    print(length)

if __name__=="__main__":
    main()
a, b, c = gets.split(" ")
a, b, c = a.to_i, b.to_i, c.to_i
if a < b && b < c
    puts "YES"
else
    puts "NO"
end

### FIXED CODE ###

a,b,c = map(int,raw_input().split())

if (a < b and b < c):
    print 'Yes'
else:
    print 'No'
def f():
  n=int(input())
  l=(tuple(map(int,input().split())) for i in range(n-1))
  for i in range(n):
    now=0
    for a,s,d in l[i:]:
      now=a+s-(-max(0,now-s)//d)*d
    print(now)
if __name__=="__main__":
  f()

### FIXED CODE ###

n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]+[[0,0,1]]
al=[]
mati=0
for i in range(n):
  now=l[i][1]+l[i][0]
  for j in range(i+1,n):
    now=l[j][0]+l[j][1]-(-max(0,now-l[j][1])//l[j][2])*l[j][2]
  al.append(now)
print(*al,sep="\n")
s =input()
a =s.split('')
print(a)

### FIXED CODE ###

s =input().replace(","," ")
print(s)
n,m =map(int,input().split())
lis = [list(map(int,input().split())) for i in range(m)]
for i in range(n):
    lis[i].append(i)
lis.sort()
cnt = 1
ans = []
ans.append([lis[0][-1],format(lis[0][0]).zfill(6)+format(1).zfill(6)])
for i in range(m-1):
    if lis[i][0] == lis[i+1][0]:
        cnt += 1
        ans.append([lis[i+1][-1],format(lis[i+1][0]).zfill(6)+format(cnt).zfill(6)])
    else:
        cnt = 1
        ans.append([lis[i+1][-1],format(lis[i+1][0]).zfill(6)+format(cnt).zfill(6)])
ans.sort(key = lambda x:x[0])
for i,x in ans:
    print(x)

### FIXED CODE ###

from operator import itemgetter
n,m = map(int,input().split())
lis = []
ans = [0 for i in range(m)]
num = [0 for i in range(n)]
for i in range(m):
  a,b = map(int,input().split())
  lis.append([i,a,b])
lis.sort(key=itemgetter(2))
for i in range(m):
  num[lis[i][1]-1] += 1
  cou = max(0,5-(lis[i][1] // 10))
  co = max(0,5-(num[lis[i][1]-1] // 10))
  ans[lis[i][0]] = format(lis[i][1],'06d') + format(num[lis[i][1]-1],'06d')
for i in range(m):print(ans[i])
N = int(input())
K = int(input())
if N * 500 >= K:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N, K = map(int,input().split())
if N * 500 >= K:
  print("Yes")
else:
  print("No")
n, k = map(int, input().split())
p = list(map(int, input().split()))
p = [0] + p
c = list(map(int, input().split()))
c = [0] + c
score = [[0] * (n + 1) for _ in range(n + 1)]
# score[i][j]: iからstartしてj回移動した時のスコア
l_cycle = [0] * (n + 1)
for i in range(1, n + 1):
    start = i
    move_cnt = 0
    nxt = i
    while move_cnt < n:
        nxt = p[nxt]
        score[i][move_cnt + 1] += score[i][move_cnt] + c[nxt]
        move_cnt += 1
        if nxt == start:
            l_cycle[start] = move_cnt
            break
# for i in range(1, n + 1):
#     print(score[i])
# print('l_cycle', l_cycle)
ans = -float('inf')
for s in range(1, n + 1):
    if k <= l_cycle[s]:
        # サイクルを回らないので
        temp = max(score[s][1:k + 1])
        ans = max(ans, temp)
        continue
    # 以降は一周以上出来る時

    # 一周以下でやめる場合を探索
    temp = max(score[s][1:l_cycle[s] + 1])
    ans = max(ans, temp)
    if score[s][l_cycle[s]] <= 0:
        # 周回する意味がない
        continue
    sk = k // l_cycle[s]  # 何周出来るか
    remk = k % l_cycle[s]
    temp = sk * score[s][l_cycle[s]]  # 周回によるスコア
    temp += max(score[s][1:remk + 1])
    ans = max(ans, temp)

print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in range(n):
    p[i] -= 1
ans = -float('inf')
for st in range(n):
    x = st
    score = []
    tot = 0
    while True:
        x = p[x]
        score.append(c[x])
        tot += c[x]
        if x == st:
            break
    l = len(score)
    now = 0
    t = 0
    for i in range(l):
        t += score[i]
        if i + 1 > k:
            break
        now = t
        if tot > 0:
            cycle_num = (k - (i + 1)) // l
            now += tot * cycle_num
        ans = max(ans, now)
print(ans)