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

import math

N ,M, K = map(int,input().split())
MOD = 998244353
SUM = 0

def getInvs(n, MOD):
    invs = [1] * (n+1)
    for x in range(2, n+1):
        invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
    return invs
invs = getInvs(K+3, MOD)

POW = [1]
for i in range(1,N):
    a = (POW[-1] * (M-1))%MOD
    POW.append(a)

mole = 1
deno = 1
for i in range(K+1):
    SUM += M * POW[N-1-i]%MOD * mole % MOD * deno % MOD
    SUM %= MOD
    mole *= (N-1-i)
    mole %= MOD
    deno *= invs[i+1]

print(SUM)

### FIXED CODE ###

import math

N ,M, K = map(int,input().split())
MOD = 998244353

def getInvs(n, MOD):
    invs = [1] * (n+1)
    for x in range(2, n+1):
        invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
    return invs
invs = getInvs(N+3, MOD)

num = M
nums = []
for i in reversed(range(1,N)):
    nums.append(num)
    num *= i*(M-1)
    num *= invs[N-i]
    num %= MOD
nums.append(num)
nums.reverse()

ans = sum(nums[:K+1])
ans %= MOD
print(ans)
### BUGGY CODE ###

n = int(input())
list = []
for i in range(n):
  s = input()
  list.append(s)
  set_list = set(list)

print(len(set_list))

### FIXED CODE ###

n = int(input())
list = []
for i in range(n):
  s = input()
  list.append(s)

set_list = set(list)
print(len(set_list))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
check=0
sum=0
col=[-1 for i in range(n)]
for i in range(n):
    for j in range(i+1,n):
        if a[i]%a[j]==0:
            col[i]=1
        if a[j]%a[i]==0:
            col[j]=1
    if col[i]==-1:
        sum+=1


print(sum)

### FIXED CODE ###

def main():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    max=a[-1]
    check=[0 for i in range(max+10)]
    sum=0
    #print(a)
    if len(a)==1:
        print(1)
        exit()
    if a[0]==1:
        if a[1]==1:
            print(0)
        else:
            print(1)
        exit()
    for i in range(n):
        if check[a[i]]==0:
            sum+=1
            j=1
            x=a[i]*j
            while x<max+1:
                check[x]=1
                j+=1
                x=a[i]*j
            if i<n-1 and a[i+1]==a[i]:
                sum-=1
        else:
            continue
    print(sum)
        
    
    
if __name__=="__main__":
    main()
### BUGGY CODE ###

n,m=map(int,input().split())
H=list(map(int,input().split()))
L=[[]]*(n)
for i in range(m):
	a,b=map(int,input().split())
	L[a-1] = L[a-1]+[H[b-1]]
	L[b-1] = L[b-1]+[H[a-1]]
	
#print(L)

count=0
for i in range(n):
	if L[i]!=[]:
		if H[i]>max(L[i]):
			count+=1
	else:
		count+=1
		
print(count)

### FIXED CODE ###

from sys import stdin,stdout
n,m=map(int,stdin.readline().split())
H=list(map(int,stdin.readline().split()))
L=[0]*n
for i in range(m):
	a,b=map(int,stdin.readline().split())
	L[a-1]=max(L[a-1],H[b-1])
	L[b-1]=max(L[b-1],H[a-1])
ans=0
for i in range(n):
	if H[i]>L[i]:
		ans+=1
		
stdout.write(str(ans))
### BUGGY CODE ###

#!/usr/bin/env python
from fractions import gcd
def main():
    N = int(input())
    ans = len(str(N))
    for i in range(1, N // 2 + 2):
        if N % i == 0:
            tmp = max(len(str(i)),  len(str(N // i)))
        if ans > tmp:
            ans = tmp
    print(ans)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python
from fractions import gcd
def main():
    N = int(input())
    ans = len(str(N))
    for i in range(len(str(N)) // 2 + 1):
            for j in reversed(range(10**i, 10**(i+1))):
                if N % j == 0:
                    tmp = max(len(str(j)), len(str(N // j)))
                    if ans > tmp:
                        ans = tmp
                    break
    print(ans)

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    print(sum([i for i in range(1, int(readline()))]))
if __name__ == '__main__':
    main()


### FIXED CODE ###

#python3
n=int(input())
n-=1
print(n*(n+1)//2)
### BUGGY CODE ###

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

SL = []
TL = []
for i in range(len(S)):
    SL.append(S[i])
    TL.append(S[i])

A = []

for i in range(len(SL)):
    for j in range(len(SL)):
        if j < i:
            TL[j] = "E"
        elif j > i:
            TL[j] = "W"
    count = 0
    for k in range(len(S)):
        if TL[k] != SL[k]:
            count += 1
    A.append(count)

print(min(A))

### FIXED CODE ###

N = int(input())
S = input()
W_count = 0
W_cumulative = []
for i in range(N):
    if S[i] == "W":
        W_count += 1
    W_cumulative.append(W_count)

ans = N
W_cumulative.insert(0,0)
for i in range(1,N+1):
    count = W_cumulative[i-1]
    count += N - W_cumulative[-1] - i + W_cumulative[i]
    ans = min(ans,count)

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

import sys

if __name__ == '__main__':
    n, m = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    h = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    matrix = [[0 for i in range(n)] for j in range(n)]

    for i in range(m):
        a, b = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
        a, b = a-1, b-1
        matrix[a][b] = 1
        matrix[b][a] = 1

    good = 0
    # 展望台iが良い展望台か
    for i in range(n):
        for j in range(n):
            if matrix[i][j] == 1 and h[i] <= h[j]:
                break
        else:
            good += 1
    print(good)

### FIXED CODE ###

import sys

if __name__ == '__main__':
    n, m = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    h = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
    # matrix = {}
    # matrix = [[0 for i in range(n)] for j in range(n)]
    matrix = [[] for j in range(n)]

    for i in range(m):
        a, b = list(map(lambda x: int(x), sys.stdin.readline().split(' ')))
        a, b = a-1, b-1
        # matrix[a] = matrix.get(a, []) + [b]
        # matrix[b] = matrix.get(b, []) + [a]
        # matrix[a][b] = 1
        # matrix[b][a] = 1
        matrix[a].append(b)
        matrix[b].append(a)

    bads = {}
    good = 0
    # 展望台iが良い展望台か
    for i in range(n):
        if bads.get(i, 0) == 1:
            continue
        # for t in matrix.get(i, []):
        for t in matrix[i]:
            if h[i] <= h[t]:
                break
            else:
                # 展望台tはもはや良い展望台でない
                if t > i:
                    bads[t] = 1
        else:
            good += 1
    print(good)

# matrixを疎行列にする
# 判定順をソートする
### BUGGY CODE ###

N = int(input())
S = [input() for i in range(N)]
dic = {}

for i in range (N):
  if S[i] in dic:
    dic[S[i]] += 1
  else:
    dic[S[i]] = 1


x = [ i[0] for i in dic.items() if i[1] == max(dic.values())]
x.sort()
for i in range(len(x)):
  print(x[i])

### FIXED CODE ###

N = int(input())
dic = {}

for i in range (N):
  s = input()
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1

sai = max(dic.values())

for j in sorted(k for k in dic if dic[k] == sai):
  print(j)
### BUGGY CODE ###

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

for i in range(n):
    ls = x[:(i)] + x[(i+1):]
    ls.sort()
    print(ls[int(n/2-1)])

### FIXED CODE ###

n = int(input())
x = list(map(int,input().split()))
ls = sorted(x)
a = ls[int(n/2-1)]
b = ls[int(n/2)]


for i in range(n):
    if x[i] >=b:
        print(a)
        
    else:
        print(b)
### BUGGY CODE ###

# coding: utf-8
import sys
input = sys.stdin.readline

def f(n, wlimit):
    dp = [0] * (wlimit + 1)
    wv = [list(map(int, input().rstrip().split())) for _ in range(n)]
    for wi, vi in wv:
        dp_ = list(dp)
        for w in range(wlimit + 1):
            v_ = dp[w] if w - wi < 0 else dp[w - wi] + vi
            dp_[w] = max(dp[w], v_)
        dp = dp_
    return(dp[-1])

n, w = map(int, input().rstrip().split()) # 1 <= n <= 100, 1 <= w <= 10^5

print(f(n, w))


### FIXED CODE ###

# coding: utf-8
import sys
input = sys.stdin.readline

def f(n, wlimit):
    dp = [-1] * (wlimit + 1)
    dp[0] = 0
    for i in range(1, n + 1):
        wi, vi = map(int, input().rstrip().split())
        dp_ = list(dp)
        for w in range(wlimit + 1):
            if dp[w] >= 0:
                w_ = w + wi
                v_ = dp[w] + vi
                if w_ <= wlimit and dp[w_] < v_:
                    dp_[w_] = v_
        dp = dp_
    return(max(dp))

n, w = map(int, input().rstrip().split()) # 1 <= n <= 100, 1 <= w <= 10^5

print(f(n, w))
### BUGGY CODE ###

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

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    check=[0]*n
    for i in l:
        check[i-1]+=1
    for j in l:
        cnt=0
        check[j-1]-=1
        for k in check:
            if k>=2:
                cnt+=k*(k-1)//2
        print(cnt)
        check[j-1]+=1
resolve()

### FIXED CODE ###

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

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    from collections import Counter
    c=Counter(l)# ()にカウンターの対象のリストの変数名
    cnt=0
    for i in c.values():
        if i>=2:
            cnt+=i*(i-1)//2
    for j in l:
        x=(c[j]-1)*(c[j]-2)//2-c[j]*(c[j]-1)//2
        print(cnt+x)
resolve()
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for i in range(Q)]

for i in range(Q):
  before_a = False
  ans = 0
  for j in range(LR[i][0]-1, LR[i][1]):
    if before_a and S[j] == 'C':
      ans += 1
      before_a = False
    elif S[j] == 'A':
      before_a = True
    else:
      before_a = False
  print(ans)
    


### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
LR = [list(map(int, input().split())) for i in range(Q)]

P = [0] * (N)
before_a = False
cnt = 0
for i in range(N):
  if before_a and S[i] == 'C':
    cnt += 1
    before_a = False
  elif S[i] == 'A':
    before_a = True
  else:
    before_a = False
  P[i] = cnt
for i in range(Q):
  print(P[LR[i][1]-1] - P[LR[i][0]-1])
### BUGGY CODE ###

def main():
    import numpy as np
    n, m, q = map(int, input().split())
    ten = np.zeros((n+1, m+1), dtype=np.int32)
    ten[1:, 1:] = np.array([list(map(lambda x:int(x), list(input())))
                            for _ in [0]*n], dtype=np.int32)

    hen1 = np.zeros((n+1, m), dtype=np.int32)
    hen1[1:, 1:] = ten[1:, 1:m] & ten[1:, 2:]
    hen1 = np.cumsum(hen1, axis=0)
    hen1 = np.cumsum(hen1, axis=1)
    hen2 = np.zeros((n, m+1), dtype=np.int32)
    hen2[1:, 1:] = ten[1:n, 1:] & ten[2:, 1:]
    hen2 = np.cumsum(hen2, axis=0)
    hen2 = np.cumsum(hen2, axis=1)
    ten = np.cumsum(ten, axis=0)
    ten = np.cumsum(ten, axis=1)

    for i in range(q):
        x1, y1, x2, y2 = map(int, input().split())
        temp = -hen1[x2][y2-1]-hen1[x1-1][y1-1]+hen1[x2][y1-1]+hen1[x1-1][y2-1]
        temp -= hen2[x2-1][y2]+hen2[x1-1][y1-1]-hen2[x2-1][y1-1]-hen2[x1-1][y2]
        print(temp+ten[x2][y2]+ten[x1-1][y1-1]-ten[x2][y1-1]-ten[x1-1][y2])


main()

### FIXED CODE ###

def main():
    from itertools import accumulate as ac
    n, m, q = map(int, input().split())
    ten = [list(map(lambda x:x == "1", list(input()))) for _ in [0]*n]
    xy = [list(map(int, input().split())) for _ in [0]*q]
    ans = [0]*q

    hen = [[0]*m]+[None]*n
    for i in range(n):
        temp = [0]
        for j in range(m-1):
            temp.append(ten[i][j] & ten[i][j+1])
        hen[i+1] = list(ac(temp))
    for i in range(n):
        for j in range(1, m):
            hen[i+1][j] += hen[i][j]

    for i, (x1, y1, x2, y2) in enumerate(xy):
        ans[i] = -hen[x2][y2-1]-hen[x1-1][y1-1] + \
            hen[x2][y1-1]+hen[x1-1][y2-1]

    hen = [[0]*(m+1)]+[None]*(n-1)
    for i in range(n-1):
        temp = [0]
        for j in range(m):
            temp.append(ten[i][j] & ten[i+1][j])
        hen[i+1] = list(ac(temp))
    for i in range(n-1):
        for j in range(1, m+1):
            hen[i+1][j] += hen[i][j]

    for i, (x1, y1, x2, y2) in enumerate(xy):
        ans[i] -= hen[x2-1][y2]+hen[x1-1][y1-1] - \
            hen[x2-1][y1-1]-hen[x1-1][y2]

    del hen

    ten = [[0]*(m+1)]+ten
    for i in range(1, n+1):
        ten[i] = [0]+list(ac(ten[i]))
    for i in range(n):
        for j in range(1, m+1):
            ten[i+1][j] += ten[i][j]

    for i, (x1, y1, x2, y2) in enumerate(xy):
        print(ans[i]+ten[x2][y2]+ten[x1-1][y1-1]-ten[x2][y1-1]-ten[x1-1][y2])


main()
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline
    import numpy as np
    from math import ceil
    N,D,A = map(int,input().split())
    XH = [list(map(int,input().split())) for _ in range(N)]
    XH.sort(key = lambda x:x[0])
    XH = np.array(XH)
    X = XH[:,0]
    H = XH[:,1]
    ans = 0
    for i in range(N):
        if H[i] > 0:
            tmp = np.searchsorted(X,X[i]+2*D,side = "right")
            num = ceil(H[i]/A)
            H[i:tmp] -= A*num
            ans += num
    print(ans)
if __name__ == '__main__':
    main()

### FIXED CODE ###

#https://atcoder.jp/contests/abc153/submissions/9750027

import sys
input = sys.stdin.readline
from math import ceil
from collections import deque
N,D,A = map(int, input().split())
XH = [list(map(int,input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0])
#X,H = map(list, zip(*XH))
q = deque()
d = 0
ans = 0

for x,h in XH:
    while q and q[0][0] < x:    #今見ている座標が既にそれまでの爆弾範囲から外れていたら
        d -= q.popleft()[1]
    h -= d
    if h > 0:
        num = ceil(h/A)
        ans += num
        q.append((x+2*D, num*A))    #(末端, そこまででの爆弾の威力)
        d += num*A
print(ans)
### BUGGY CODE ###

from collections import deque
from collections import defaultdict
N=int(input())
G=defaultdict(list)
Edges=defaultdict(int)
edges=[]
for i in range(N-1):
  a,b=map(int,input().split())
  G[a].append(b)
  Edges[(a,b)]=0
  edges.append([a,b])
def dfs(G,s):
  stack=deque()
  seen=[]
  stack.append(s)
  seen.append(s)
  prev=defaultdict(int)
  prev[s]=s
  k=1
  while len(stack)!=0:
    u=stack.pop()
    if u!=s:
      k=max(k,len(G[u])+1)
    else:
      k=max(k,len(G[u]))
    lst=[i for i in range(1,k+1)]
    if u!=s:
      lst.remove(Edges[(prev[u],u)]) 
    else:
      pass
    for v in G[u]:
      if v not in seen:
        num=lst.pop(0)
        Edges[(u,v)]=num
        seen.append(v)
        stack.append(v)
        prev[v]=u
  return k

K=dfs(G,1)
print(K)
for e in edges:
  a,b=e[0],e[1]
  print(Edges[(a,b)])

### FIXED CODE ###

from collections import deque
from collections import defaultdict
n=int(input())
E=[[] for _ in range(n)]
col=defaultdict(list)
l=[]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  E[a].append(b)
  E[b].append(a)
  col[(a,b)]=-1
  col[(b,a)]=-1
  l.append((a,b))
s=-1
k=-1
for i in range(n):
  if len(E[i])>k:
    k=len(E[i])
    s=i
par=[-1]*n
stack=deque([s])
seen=[-1]*n
seen[s]=1
while stack:
  u=stack.pop()
  if u==s:
    cnt=1
  else:
    cnt=col[(par[u],u)]+1
  for v in E[u]:
    if seen[v]!=1:
      par[v]=u
      seen[v]=1
      if cnt<=k:
        col[(u,v)]=cnt
        cnt+=1
      else:
        col[(u,v)]=1
        cnt=2
      stack.append(v)
print(k)
for a,b in l:
  if col[(a,b)]==-1:
    print(col[(b,a)])
  else:
    print(col[(a,b)])
### BUGGY CODE ###

from collections import Counter

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

if len(set(V)) == 1:
    print(len(V)//2)
    exit()

V_odd = [i for i in V[::2]]
V_even = [i for i in V[1::2]]
V_odd_counter = Counter(V_odd)
V_even_counter = Counter(V_even)
while True:
    if V_odd_counter.most_common()[0][0] != V_even_counter.most_common()[0][0]:
        print(len(V) - V_odd_counter.most_common()[0][1] - V_even_counter.most_common()[0][1])
        exit()
    else:
        if V_odd_counter.most_common()[0][1] >= V_even_counter.most_common()[0][1]:
            V_even = [i for i in V_even if i != V_even_counter.most_common()[0][0] ]
            V_even_counter = Counter(V_even)
        else:
            V_odd = [i for i in V_odd if i != V_odd_counter.most_common()[0][0] ]
            V_odd_counter = Counter(V_odd)


### FIXED CODE ###

from collections import Counter

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

if len(set(V)) == 1:
    print(len(V)//2)
    exit()

V_odd = [i for i in V[::2]]
V_even = [i for i in V[1::2]]
V_odd_counter = Counter(V_odd)
V_even_counter = Counter(V_even)

vodd = V_odd_counter.most_common()
veven = V_even_counter.most_common()
vlen = len(V)
while True:
    if vodd[0][0] != veven[0][0]:
        print(vlen - vodd[0][1] - veven[0][1])
        exit()
    else:
        print(min(vlen - vodd[1][1] - veven[0][1],
                    vlen - vodd[0][1] - veven[1][1]))
        exit()
### BUGGY CODE ###



N = int(input())
S = []
Sset = set()
for i in range(N):
    s = input()
    Sset.add(s)
    S.append(s)



names = [0]*len(Sset)

for i, name in enumerate(Sset):
    cnt = 0
    for s in S:
        if(name==s):
            cnt += 1
            names[i] = (name, cnt)
max = 0
for n in names:
    if max<n[1]:
        max = n[1]
ans = []
for n in names:
    if n[1]==max:
        ans.append(n[0])

ans.sort()
for a in ans:
    print(a)




### FIXED CODE ###

from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import product, combinations,permutations
from copy import deepcopy
import sys
sys.setrecursionlimit(4100000)



if __name__ == '__main__':
    N = int(input())
    S_list = []

    s_hash = dict()

    for i in range(N):
        S_list.append(input())

    for s in S_list:
        if s not in s_hash:
            s_hash[s] = 1
        else:
            s_hash[s] += 1
    max_p = 0
    max_p_name = []
    for k, v in s_hash.items():
        if max_p < v:
            max_p_name = []
            max_p = v
        if max_p == v:
            max_p_name.append(k)
    
    for p in sorted(max_p_name):
        print(p)
### BUGGY CODE ###

s = input()
q = int(input())

up = 0

for _ in range(q):
    query = list(input().split())

    if query[0] == "1":
        if up:
            up = 0
        else:
            up = 1

    elif query[0] == "2":
        if query[1] == "1":
            if up:
                s = s + query[2]
            else:
                s = query[2] + s
        elif query[1] == "2":
            if up:
                s = query[2] + s
            else:
                s = s + query[2]

if up:
    s = s[::-1]
print(s)

### FIXED CODE ###

s = input()
q = int(input())

up = 0

head = []
tail = []

for _ in range(q):
    query = list(input().split())

    if query[0] == "1":
        if up:
            up = 0
        else:
            up = 1

    elif query[0] == "2":
        if query[1] == "1":
            if up:
                tail.append(query[2])
            else:
                head.append(query[2])
        elif query[1] == "2":
            if up:
                head.append(query[2])
            else:
                tail.append(query[2])

head=''.join(map(str,head))
tail=''.join(map(str,tail))

ans = head[::-1] + s + tail

if up:
    ans = ans[::-1]
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import numpy as np

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

dp = np.zeros([N+1,W+1],dtype=int)

for i in range(N):
    weight,value = map(int, input().split())
    for sum_w in range(W+1):
        if sum_w - weight >=  0:
            dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - weight] + value)
        else:
            dp[i+1][sum_w] = dp[i][sum_w]

print(dp[N][W])


### FIXED CODE ###

import sys
input = sys.stdin.readline
import numpy as np

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

dp = np.zeros([N+1,W+1],dtype=int)

# 重かったので却下
# for i in range(N):
#     weight,value = map(int, input().split())
#     for sum_w in range(W+1):
#         if sum_w - weight >=  0:
#             dp[i+1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - weight] + value)
#         dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

for i in range(N):
    weight, value = map(int, input().split())
    dp[i+1] = dp[i]
    dp[i+1, weight:] = np.maximum(dp[i+1, weight:], dp[i, :W-weight+1] + value)

print(dp[N][W])
### BUGGY CODE ###

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

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
answer = [0] * n

for i in range(n - 1):
  answer[a[i] - 1] += 1
    
for i in range(n):
  print(answer[i])
### BUGGY CODE ###

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N = int(input())
ans = 0
for i in range(1, N):
    le = prime_factorize(N - i)
    if len(le) == len(set(le)):
        ans += pow(2, len(le))
    else:
        w = []
        p = 1
        for x in set(le):
            if le.count(x) > 1:
                w.append(x)
                p *= le.count(x) + 1
        ans += pow(2, len(set(le)) - len(w))*p
print(ans)

### FIXED CODE ###

import math
N = int(input())
ans = 0
ve = math.floor(math.sqrt(N))
for st in range(ve):
    tmp = math.floor(N/(st+1)-0.000001)
    score = 2*(tmp - st)
    if score > 0:
        score -= 1
    ans += score
print(ans)
### BUGGY CODE ###

K = int(input())

L = 9*K
ans = 0

if (L % 2 == 0) or (L % 5 == 0):
    ans = -1
else:
    a = 0
    for i in range(1,L):
        a = 7*(10**i -1)
        if a % L == 0:
            ans = i
            break
print(ans)

### FIXED CODE ###

K = int(input())
ref = 0
ans = 0

for i in range(K):
    ref = (10*ref + 7) % K
    if ref == 0:
        ans = i + 1
        break
    elif i == K - 1:
        ans = -1
        break

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

N = int(input())
a = list(map(int, input().split()))
n = 1
p = 0
for i in range(max(a)):
  if not n in a[p:]:
    break
  else:
    p = a[p:].index(n) + 1
    n += 1
if n == 1:
  print(-1)
else:
  print(N - n + 1)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
K = 0
p = 0
bricks = [[] for i in range(N)] #iと書かれたレンガがどこにあるか

for i in range(N):
  bricks[a[i] - 1].append(i)

for i in range(N):
  if len(bricks[i]) == 0:
    break
  elif bricks[i][-1] < p:
    break
  else:
    for j in bricks[i]:
      if j >= p:
        p = j
        K += 1
        break
if K == 0:
  print(-1)
else:
  print(N - K)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(65536)

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

path=[[] for _ in range(N+1)]

for _ in range(M):
	l,r,d=map(int, input().split())
	path[l].append((r,+d))
	path[r].append((l,-d))

cost=[None for _ in range(N+1)]

def dfs(i, c):
	if cost[i] is None:
		cost[i] = c
		for j,d in path[i]:
			if not dfs(j, c+d):
				return False
	return cost[i] == c

ans = "Yes"

for i in range(1, N+1):
	if cost[i] is None and not dfs(i, 0):
		ans = "No"
		break

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(1145141919)

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

path=[[] for _ in range(N+1)]

for _ in range(M):
	l,r,d=map(int, input().split())
	path[l].append((r,+d))
	path[r].append((l,-d))

cost=[None for _ in range(N+1)]

def walk(i, c):
	if cost[i] is None:
		cost[i] = c
		for j,d in path[i]:
			if not walk(j, c+d):
				return False
	return cost[i] == c

ans = "Yes"

for i in range(1, N+1):
	if cost[i] is None and not walk(i, 0):
		ans = "No"
		break

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

a,b,n=map(int,input().split())
m=0
d=1
if n>=10**5:
    d=2
for i in range(1,n+1,d):
    c=a*i//b-a*(i//b)
    if c>=m:
        m=c
    # print((a*i)//b,a*(i//b),a*i//b-a*(i//b))
print(m) 

### FIXED CODE ###

a,b,n=map(int,input().split())
if b-1<=n:
    i=b-1
else:
    i=n
print(a*i//b-a*(i//b))
### BUGGY CODE ###

import math
N, K = map(int, input().split())
h = list(map(int, input().split()))

S = [0] * N
S[0] = 0

for i in range(1, N):
    value = math.inf
    for k in range(1, K + 1):
        # print("i, k:", i, k)
        if i - k < 0:
            break
        value = min(value, S[i - k] + abs(h[i] - h[i - k]))
        #print("value", value)
    S[i] = value
    # print(S)
# print(S)
print(S[N - 1])


### FIXED CODE ###

N,K=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*(N)
dp[1]=abs(h[0]-h[1])
for i in range(2,N):
    dp[i]=min(dp[j]+abs(h[j]-h[i]) for j in range(max(0,i-K),i))
print(dp[N-1])