Harryxun/stf_run huggingface dataset:
a=10**9+7
n,k=map(int,input().split())
from math import factorial 
"def c(t, r):
"  return factorial(t)//factorial(t-r)//factorial(r)
def f(x):
  return factorial(x)


for _ in range(1,k+1):
  a1=f(n-k+1)%a
  a2=f(n-k+1-_)
  a3=f(_)
  a4=f(k-1)%a
  a5=f(k-1-_+1)
  a6=f(_-1)
  ans=a1*a4//(a2*a3*a5*a6)%a
  print(ans)

"  print((c(n-k+1,_)%a*c(k-1,_-1)%a))

### FIXED CODE ###

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

from scipy.misc import comb

for i in range(1,k+1):
  print(comb(n-k+1,i,exact=True)*comb(k-1,i-1,exact=True)%mod)
def get_pattern(n, y):
    X = 10
    Y = 5
    Z = 1

    y //= 1000
    for nx in range(n+1):
        m = n - nx
        for ny in range(m+1):
            nz = m - ny
            sum = nx * X + ny * Y + nz * Z
            if y == sum:
                return f'{nx} {ny} {nz}'
    return '-1 -1 -1'


n, y = [int(x) for x in input().split()]
print(get_pattern(n, y))


### FIXED CODE ###

def get_pattern(n, y):
    X = 10
    Y = 5
    Z = 1

    y //= 1000
    for nx in range(n+1):
        m = n - nx
        for ny in range(m+1):
            nz = m - ny
            sum = nx * X + ny * Y + nz * Z
            if y == sum:
                return (nx, ny, nz)
    return (-1, -1, -1)


n, y = [int(x) for x in input().split()]
a, b, c = get_pattern(n, y)
print(a, b, c)
a=input()
print(int(a**0.5)*int(a**0.5))

### FIXED CODE ###

a=input()
print(int(int(a)**0.5)*int(int(a)**0.5))
import sys
from io import StringIO
import unittest

def resolve():
    N, M, K = [int(x) for x in input().split()]
    global list, block, seen, osusume
    list = [[] for _ in range(N)]
    block = [[] for _ in range(N)]
    seen = [[False] * N for _ in range(N)]
    osusume = [[] for _ in range(N)]

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

    for _ in range(K):
        C, D = [int(x)-1 for x in input().split()]
        block[C].append(D)
        block[D].append(C)

    for i in range(N):
        dfs(i, i)
        print(len(osusume[i]), end=" ")

def dfs(v, origin):
    stacka = list[v]
    seen[origin][v] = True

    if not v in list[origin] and not v in block[origin] and v != origin:
        osusume[origin].append(v)

    for i in stacka:
        if(seen[origin][v] == True):
            dfs(i, origin)
resolve()

### FIXED CODE ###

class UnionFind:
    def __init__(self, N, l):
        self.roots = list(range(N+1))
        self.counter = [1]*(N+1)
        for a, b in l:
            self.union(a, b)
 
    def get_root(self, n):
        if self.roots[n] != n:
            self.roots[n] = self.get_root(self.roots[n])
        return self.roots[n]
 
    def union(self, a, b):
        a, b = sorted([self.get_root(a), self.get_root(b)])
        if a != b:
            self.roots[b] = a
            self.counter[a] += self.counter[b]
            self.counter[b] = 0
 
    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)
 
    def count(self, x):
        return(self.counter[self.get_root(x)])
 
 
N, M, K = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(M)]
cd = [[int(i) for i in input().split()] for _ in range(K)]
friend = [[] for _ in range(N+1)]
uf = UnionFind(N, ab)
 
for a, b in ab:
    friend[a].append(b)
    friend[b].append(a)
 
ans = [uf.count(i)-1-len(friend[i]) for i in range(N+1)]
 
for c, d in cd:
    if uf.find(c, d):
        ans[c] -= 1
        ans[d] -= 1
 
print(*ans[1:])
abcd = input()
bin_pattern_digit = len(abcd) - 1

for i in range(1 << bin_pattern_digit):
    # 初期値:一番左の桁の値。
    result = int(abcd[0:1])
    for j in range(bin_pattern_digit):
        # +を入れた場合
        # 例：1234のパターン1「+」2の場合：i=0の時に+2(abcd[1:2])する必要がある。
        #                 3「-」4の場合：i=2の時に-4(abcd[3:4])する必要がある。
        if i & 1 << j:
            result += int(abcd[j + 1:j + 2])
        # -を入れた場合
        else:
            result -= int(abcd[j + 1:j + 2])

    # 合計が7なら終了
    if result == 7:
        break

# 注意：
# bit変数(i)の結果を確認する場合、文字列とスライスの併用(str(bit(i[0:1])))は使えない。
# 数値と同じで、先頭0は消される = 桁数が可変であるため。
# i & 1 << 0  # 1桁目が真か確認。
# i & 1 << 1  # 2桁目が真か確認。
# -dev-
print(abcd[0:1] + conv_bin(i, 2) + abcd[1:2] + conv_bin(i, 1) + abcd[2:3] + conv_bin(i, 0) + abcd[3:4] + "=7")


def conv_bin(i, digit):
    if i & 1 << digit:
        return "+"
    else:
        return "-"


### FIXED CODE ###


def conv_bin(i, digit):
    if i & 1 << digit:
        return "+"
    else:
        return "-"


if __name__ == "__main__":
    abcd = input()
    bin_pattern_digit = len(abcd) - 1

    for i in range(1 << bin_pattern_digit):
        # 初期値:一番左の桁の値。
        result = int(abcd[0:1])
        for j in range(bin_pattern_digit):
            # +を入れた場合
            # 例：1234のパターン1「+」2の場合：i=0の時に+2(abcd[1:2])する必要がある。
            #                 3「-」4の場合：i=2の時に-4(abcd[3:4])する必要がある。
            if i & 1 << (bin_pattern_digit - j -1 ):
                # result += int(abcd[j + 1:j + 2])
                result += int(abcd[j + 1])
            # -を入れた場合
            else:
                # result -= int(abcd[j + 1:j + 2])
                result -= int(abcd[j + 1])

        # 合計が7なら終了
        if result == 7:
            break

    # 注意：
    # bit変数(i)の結果を確認する場合、文字列とスライスの併用(str(bit(i[0:1])))は使えない。
    # 数値と同じで、先頭0は消される = 桁数が可変であるため。
    # i & 1 << 0  # 1桁目が真か確認。
    # i & 1 << 1  # 2桁目が真か確認。
    # -dev-
    print(abcd[0:1] + conv_bin(i, 2) + abcd[1:2] + conv_bin(i, 1) + abcd[2:3] + conv_bin(i, 0) + abcd[3:4] + "=7")
N, K = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
S = []
a = 1
number = 0
numbers=[-1 for _ in range(N)]
for _ in range(N + 1):
    b = A[a - 1]
    if numbers[b-1] != -1:
      c=numbers[b-1]
      break
    numbers[b-1]=number
    number += 1
    S.append(b)
    a = b
T = S[c:number]
if K <= N:
    print(S[K - 1])
else:
    z = K - c - 1
    y = z % (number - c)
    print(T[y])


### FIXED CODE ###

N, K = map(int, input().split())
A = input().split()
A = [int(a) for a in A]
S = [1]
a = 1
number = 0
numbers=[-1 for _ in range(N)]
for _ in range(N + 1):
    b = A[a - 1]
    if numbers[b-1] != -1:
      c=numbers[b-1]
      break
    numbers[b-1]=number
    number += 1
    S.append(b)
    a = b
T = S[c+1:number+1]
if K <= number:
  print(S[K ])
else:
  z = K - c-1
  y = z % (number - c)
  print(T[y])
N=int(input())

for i in range(N):
  ans*=int(input())
  if ans>10**18:
    break
    print(-1)

print(ans)


### FIXED CODE ###

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

if 0 in a:
  print(0)

else:
  ans = 1
  for i in range(n):
    ans *= a[i]
    if ans > 10 ** 18:
      print(-1)
      exit()
  print(ans)
h,w,k = map(int, input().split())
sx,sy,gx,gy = map(lambda x: int(x)-1, input().split())
board = [list(map(lambda x: int(x=="."), input())) for i in range(h)]

DP = [[float("inf") for j in range(w)] for i in range(h)]
DP[sx][sy] = 0

from collections import deque
que = deque([(sx,sy)])

dxdy = [(0,1),(1,0),(0,-1),(-1,0)]
while que:
    x,y = que.popleft()
    for dx,dy in dxdy:
        nx,ny = x,y
        for i in range(1,k+1):
            nx += dx
            ny += dy
            if not(0<=nx<h and 0<=ny<w and board[nx][ny] and DP[nx][ny] > DP[x][y]+1):
                break
            DP[nx][ny] = DP[x][y]+1
            que.append((nx,ny))

ans = DP[gx][gy]
if ans == inf:
    ans = -1
print(ans)

### FIXED CODE ###

h,w,k = map(int, input().split())
sx,sy,gx,gy = map(lambda x: int(x)-1, input().split())
board = [list(map(lambda x: int(x=="."), input())) for i in range(h)]
inf = 1<<30
DP = [[inf for j in range(w)] for i in range(h)]
DP[sx][sy] = 0

from collections import deque
que = deque([(sx,sy)])

dxdy = [(0,1),(1,0),(0,-1),(-1,0)]
while que:
    x,y = que.popleft()
    for dx,dy in dxdy:
        nx,ny = x,y
        for i in range(k):
            nx += dx
            ny += dy
            if not(0<=nx<h and 0<=ny<w and board[nx][ny] and DP[nx][ny] >= DP[x][y]+1):
                break
            # コストが変わらない場合は無視か...
            if DP[nx][ny] == DP[x][y]+1:
                continue
            DP[nx][ny] = DP[x][y]+1
            que.append((nx,ny))
ans = DP[gx][gy]
if ans == inf:
    ans = -1
print(ans)
S, T = input()
txt = S + T
print(txt)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,T = read().decode('utf-8').split()
 
answer = T + S
print(answer)
r = int(input)

print(r**2)

### FIXED CODE ###

r = int(input())

print(int(r**2))
age,cost=list(map(int, input().split()))
age=x[0]
cost=x[1]
if age<=5:
  print('0')
elif age>=6 and age<=12:
  print(a/2)
else:
  print(a)


### FIXED CODE ###

n,k=tuple(map(int,input().split()))
if n >= 13:
  print(k)
elif 6 <= n <= 12:
  print(k//2)
elif n <= 5:
  print(0)
a, b, c = sorted(map(int, input().split()))
print(c - b + (b-a)//2 + (b-a)%2*2)

### FIXED CODE ###

print("YNeos"[len(set(input()))!=3::2])
n=int(input())
if n == 1:
  print(1)
elif n%2 == 0:
  print(0.5):
else:
  print(0.6)

### FIXED CODE ###

a=0
n=int(input())
a+=n//2
if n%2 == 1:
    a+=1
print(a/n)
n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]
like = [i for i in range(10)]
pay = []
    
for i in str(n):
    while int(i)%10 in a:
            i = int(i) + 1
    pay.append(str(i%10))

total = ''
for i in pay:
    total += i

if n > int(total):
    total += str(like[0])
print(int(total))

### FIXED CODE ###

n, k = (int(_) for _ in input().split())
a = [int(_) for _ in input().split()]

found = False
bad = False
while not found:
    for i in str(n):
        if int(i) in a:
            bad = True
    if not bad:
        found = True
    bad = False
    n += 1

print(n - 1)
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    Ps = list(map(int, input().split()))

    count = 0

    ans = []

    for i in range(len(Ps) - 1):
        if Ps[i] >= Ps[i+1]:
            count += 1
        else:
            ans.append(count)
            count = 0

        if i == len(Ps) - 2:
            ans.append(count)

    print(max(ans))


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    Ps = list(map(int, input().split()))

    count = 0

    ans = [0]

    for i in range(len(Ps) - 1):
        if Ps[i] >= Ps[i+1]:
            count += 1
        else:
            ans.append(count)
            count = 0

        if i == len(Ps) - 2:
            ans.append(count)

    print(max(ans))


if __name__ == '__main__':
    main()
N, A = map(int, input().split())
x = list(map(int, input().split()))

total = sum(x)

# dp[i][j][k] := i枚目までからj枚取って、合計をkにする通り数
dp = [[[0] * (total+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1


for i in range(N+1):
    for j in range(N+1):
        for k in range(total+1):
            if i >= 1 and x[i-1] > k:
                dp[i][j][k] = dp[i-1][j][k]
            elif i >= 1 and j >= 1 and x[i-1] <= k:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - x[i-1]]

ans = 0
for j in range(1, N+1):
     # N枚(カード総数)の中から1枚以上取った時の、j枚取って合計がj*Aの所 の合計
    ans += dp[N][j][j*A]
print(ans)

### FIXED CODE ###

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

max_of_a = N * A

# dp[i][j][k] := i枚目までからj枚取って、合計をkにする通り数
dp = [[[0] * (max_of_a + 1) for _ in range(N+1)]for _ in range(N+1)]
dp[0][0][0] = 1


for i in range(N+1):
    for j in range(N+1):
        for k in range(max_of_a + 1):
            if i >= 1 and x[i-1] > k:
                dp[i][j][k] = dp[i-1][j][k]
            elif i >= 1 and j >= 1 and x[i-1] <= k:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k - x[i-1]]

ans = 0
for j in range(1, N+1):
    # N枚(カード総数)の中から1枚以上取った時の、j枚取って合計がj*Aの所 の合計
    ans += dp[N][j][j*A]
print(ans)
#!/usr/bin/env python3
#abc126 e

N,M = map(int,input().split())
XYZ = [list(map(int,input().split())) for _ in range(M)]

G = [[] for _ in range(N)]
for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])

check = [False for _ in range(N)]#各頂点を訪問したかどうか
def DFS(G,start):
    check[start-1] = True
    for j in G[start-1]:
        if not check[j-1]:
            DFS(G,j)
    return
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
#abc126 e

import sys
sys.setrecursionlimit(1000000)
N,M = list(map(int,input().split()))
XYZ = [list(map(int,input().split())) for _ in range(M)]

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

for i in XYZ:
    G[i[0]-1].append(i[1])
    G[i[1]-1].append(i[0])

check = [False for _ in range(N)]#各頂点を訪問したかどうか

def DFS(G,s):
    check[s-1] = True
    for i in G[s-1]:
        if not check[i-1]:
            DFS(G,i)
ans = 0
for i in range(N):
    if not check[i]:
        DFS(G,i+1)
        ans += 1
print(ans)
import numpy as np

def main():
    H,N = [int(x) for x in input().split()]
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)

    dp = np.full((N+1,H+1),10 ** 18)
    dp[0][0] = 0
    for i in range(N):
        for j in range(H+1):
            # print(i,j)
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            dp[i+1][min(j+A[i],H)] = min(dp[i+1][j]+B[i], dp[i+1][min(j+A[i],H)])
            # print(dp)
    print(int(dp[N][H]))


if __name__ == '__main__':
    main()


### FIXED CODE ###

# import numpy as np

def main():
    H,N = [int(x) for x in input().split()]
    A,B = [],[]
    for _ in range(N):
        a,b = [int(x) for x in input().split()]
        A.append(a)
        B.append(b)

    # dp = np.full((N+1,H+1),10 ** 18)
    # dp[0][0] = 0
    dp = [float('inf')]*(H+1)
    dp[0] = 0
    for i in range(N):
        for j in range(H+1):
            # print(i,j,dp[j],A[i],B[i])
            dp[min(j+A[i],H)] = min(dp[min(j+A[i],H)], dp[j]+B[i])
            # dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            # dp[i+1][min(j+A[i],H)] = min(dp[i+1][j]+B[i], dp[i+1][min(j+A[i],H)])
            # print(dp)
    print(int(dp[H]))


if __name__ == '__main__':
    main()
s1 , s2, s3 = map(int, input().split())
print(s1 + s2 + s3)

### FIXED CODE ###

print(input().count('1'))
import sys
from itertools import accumulate


def input():
    return sys.stdin.readline().strip()


MOD = 10 ** 9 + 7


def main():
    S = input()
    answer = 0
    for i in range(len(S)):
        func = lambda x, y: (int(x) * 10 + int(y)) % 2019
        A = list(accumulate(S[i:], func, initial=0))
        answer += A.count(0) - 1
    print(answer)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


def main():
    S = list(input())
    N = len(S)
    check = [0] * 2019
    ten = 1
    mod = 1
    check[mod] += 1
    for i in range(N):
        mod = (mod + int(S[N - i - 1]) * ten) % 2019
        ten = (ten * 10) % 2019
        check[mod] += 1
    answer = 0
    for i in range(2019):
        answer += ((check[i] - 1) * check[i]) // 2
    print(answer)


if __name__ == "__main__":
    main()
from collections import deque
#累積和を木に拡張する
N, Q = map(int, input().split())

graph = [[] for i in range(N)]
score = [0 for _ in range(N)]

def dfs(now, prev):

    for adj in graph[now]:
        if adj == prev:
            continue
        score[adj] += score[now]
        dfs(adj, now)

    return

for i in range(1, N):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

query = [0] * N
for i in range(Q):
    p, x = map(int, input().split())

    score[p-1] += x

dfs(0, -1)

for p in score:
    print(p)


### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**7)
#累積和を木に拡張する
N, Q = map(int, input().split())

graph = [[] for i in range(N)]
score = [0 for _ in range(N)]

def dfs(now, prev):

    for adj in graph[now]:
        if adj == prev:
            continue
        score[adj] += score[now]
        dfs(adj, now)

    return

for i in range(1, N):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

query = [0] * N
for i in range(Q):
    p, x = map(int, input().split())

    score[p-1] += x

dfs(0, -1)

for p in score:
    print(p)
N = int(input())
number=[]
for i in range(N):
    number.append(input())
print(len(Counter(number)))

### FIXED CODE ###

import collections
N = int(input())
item = []
for i in range(N):
    item.append(input())
item_count=collections.Counter(item)
print(len(item_count))
N, K  = map(int,input().split())
L =list(map(int,input().split()))
Lzero = list(filter(lambda x:x==0,L))
Lright = list(filter(lambda x:x>0,L))
Lleft = list(map(lambda x:abs(x),filter(lambda x:x<0,L)))[::-1]
K -= len(Lzero)
if K <= 0:
    print(0)
    quit()

dis = []
if len(Lright) == 0:
    print(Lleft[K-1])
    quit()
if len(Lleft) == 0:
    print(Lright[K-1])
    quit()



#turn at right
for i in range(len(Lright)):
    remain = K
    if i+1 >K:
        break
    elif i+1 == K:
        dis.append(Lright[i])
        break
    d = 2*Lright[i]
    remain -= (i+1)
    d += Lleft[remain-1]
    dis.append(d)
for i in range(len(Lleft)):
    remain = K
    if i+1 >K:
        break
    elif i+1 == K:
        dis.append(Lleft[i])
        break
    d = 2*Lleft[i]
    remain -= (i+1)
    d += Lright[remain-1]
    dis.append(d)
print(min(dis))


### FIXED CODE ###

N, K  = map(int,input().split())
L =list(map(int,input().split()))
Lzero = list(filter(lambda x:x==0,L))
Lright = list(filter(lambda x:x>0,L))
Lleft = list(map(lambda x:abs(x),filter(lambda x:x<0,L)))[::-1]
K -= len(Lzero)
if K <= 0:
    print(0)
    quit()

dis = []
if len(Lright) == 0:
    print(Lleft[K-1])
    quit()
if len(Lleft) == 0:
    print(Lright[K-1])
    quit()
try :
    dis.append(Lright[K-1])
    dis.append(Lleft[K-1])
except:
    pass


for i in range(len(Lright)):
    remain = K
    if i+1 >K:
        break
    elif i+1 == K:
        dis.append(Lright[i])
        break
    d = 2*Lright[i]
    remain -= (i+1)
    try :
        d += Lleft[remain-1]
        dis.append(d)
    except:
        pass
for i in range(len(Lleft)):
    remain = K
    if i+1 >K:
        break
    elif i+1 == K:
        dis.append(Lleft[i])
        break
    d = 2*Lleft[i]
    remain -= (i+1)
    try:
        d += Lright[remain-1]
        dis.append(d)
    except:
        pass
print(min(dis))
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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


ans = INF
for a in A:
    cnt = 0
    while True:
        q, mod = divmod(a, 2)
        if mod != 0:
            break
        cnt += 1
        a = q
    ans = min(ans, cnt)
print(ants)


### FIXED CODE ###

import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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


ans = INF
for a in A:
    cnt = 0
    while True:
        q, mod = divmod(a, 2)
        if mod != 0:
            break
        cnt += 1
        a = q
    ans = min(ans, cnt)
print(ans)
import copy
import math
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
s_list = [input() for i in range(N)]


def split(word):
    return [char for char in word]


normalized_s_list = sorted([''.join(sorted(split(s))) for s in s_list])

uniqued_s_list = list(set(normalized_s_list))

j = 0
counter = 0
result = 0
for s in normalized_s_list:
    if s == uniqued_s_list[j]:
        counter += 1
    else:
        result += (1 / 2) * counter * (counter - 1)
        j += 1
        counter = 1  # このとき s と uniqued_s_list[j] は同じはずなので

result += (1 / 2) * counter * (counter - 1)
print(int(result))


### FIXED CODE ###

import copy
import math
import sys

sys.setrecursionlimit(10 ** 7)

N = int(input())
s_list = [input() for i in range(N)]


def split(word):
    return [char for char in word]


normalized_s_list = sorted([''.join(sorted(split(s))) for s in s_list])

uniqued_s_list = sorted(list(set(normalized_s_list)))

j = 0
counter = 0
result = 0
for s in normalized_s_list:
    if s == uniqued_s_list[j]:
        counter += 1
    else:
        result += (1 / 2) * counter * (counter - 1)
        j += 1
        counter = 1  # このとき s と uniqued_s_list[j] は同じはずなので

result += (1 / 2) * counter * (counter - 1)
print(int(result))
from collections import defaultdict
from collections import OrderedDict
n = int(input())
answer = dict()
for _ in range(n):
    z = str(input())
    if z in answer:
        ans[z]+=1
    else:
        answer.update({z:1})
groupedByValue = defaultdict(list)
for key, value in sorted(answer.items()):
    groupedByValue[value].append(key)
M = groupedByValue[max(groupedByValue)]
for i in M:
    print(i)

### FIXED CODE ###

from collections import defaultdict
from collections import OrderedDict
n = int(input())
answer = dict()
for _ in range(n):
    z = str(input())
    if z in answer:
        answer[z]+=1
    else:
        answer.update({z:1})
groupedByValue = defaultdict(list)
for key, value in sorted(answer.items()):
    groupedByValue[value].append(key)
M = groupedByValue[max(groupedByValue)]
for i in M:
    print(i)
t=input()
n=len(t)
a=[0]*n
for i in range(n):
    a[i]=t[i]

for i in range(n):
    if a[i]=="?":
        if i==0:
            a[i]="D"
        elif a[i-1]=="P":
            if a[i+1]=="?":
                a[i]="D"
            elif a[i+1]=="P":
                a[i]="D"
            elif a[i+1]=="D":
                a[i]="D"
        elif a[i-1]=="D":
            if a[i+1]=="?":
                a[i]="D"
            elif a[i+1]=="P":
                a[i]="D"
            elif a[i+1]=="D":
                a[i]="P"
s=''.join(a)
print(s)


### FIXED CODE ###

t=input()
n=len(t)
a=[0]*n
for i in range(n):
    a[i]=t[i]

for i in range(n):
    if a[i]=="?":
        if i!=n-1:
            if a[i-1]=="D" and a[i+1]=="?":
                a[i]="P"
            elif a[i-1]=="P" and a[i+1]=="?":
                a[i]="D"
            elif a[i-1]=="D" and a[i+1]=="D":
                a[i]="P"
            else:
                a[i]="D"
        else:
            a[i]="D"
    #print(a)

s=''.join(a)
print(s)
from collections import Counter
N = int(input())
S = list(map(str,input().split()))
count = 0
for i in range(N):
  for j in range(i+1, N):
    if Counter(S[i]) == Counter(S[j]):
      count += 1
    else:
      break
print(count)

### FIXED CODE ###

from collections import Counter
N = int(input())
S = [str(sorted(input())) for _ in range(N)]
count = 0
for i in Counter(S).values():
  count += i*(i-1)//2
print(count)
def judge(x):
  if x==4 or x==6 or x==9 or x==11:
    y = a
  elif x==12:
    y = b
  else:
    y = c
  return y

a,b = map(int,input().split())
if judge(a) == judge(b) :
  print('Yes')
else:
  print('No')

### FIXED CODE ###

def judge(x):
  if x==4 or x==6 or x==9 or x==11:
    y = 'a'
  elif x==2:
    y = 'b'
  else:
    y = 'c'
  return y
 
a,b = map(int,input().split())
if judge(a) == judge(b) :
  print('Yes')
else:
  print('No')
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n

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

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**9]*n

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