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

check=dict()
N,b,d=0,[],0
#ttfは235、chaはabc
inf=10**15
def dfs_sub(n,ttf,cha):
    global check,d
    check[0]=min(check[n]+n*d,check.get(0,inf))
    if n//ttf==0:
        check[n//ttf]=min(check.get(n//ttf,inf),check[n]+(n%ttf)*d)
    else:
        if n//ttf in check:
            if check[n//ttf]>check[n]+(n%ttf)*d+cha:
                check[n//ttf]=check[n]+(n%ttf)*d+cha
                dfs(n//ttf)
        else:
            check[n//ttf]=check[n]+(n%ttf)*d+cha
            dfs(n//ttf)
    if 1+n//ttf in check:
        if check[1+n//ttf]>check[n]+(ttf-n%ttf)*d+cha:
            check[1+n//ttf]=check[n]+(ttf-n%ttf)*d+cha
            dfs(1+n//ttf)
    else:
        check[1+n//ttf]=check[n]+(ttf-n%ttf)*d+cha
        dfs(1+n//ttf)


def dfs(n):
    global b,check,d
    for i,j in zip([2,3,5],b):
        dfs_sub(n,i,j)

t=int(input())
for i in range(t):
    N,*b,d=map(int,input().split())
    check={N:0}
    dfs(N)
    print(check[0])

### FIXED CODE ###

import sys
check=dict()
N,a,b,c,d=0,0,0,0,0
#ttfは235、chaはabc
def dfs_sub(n,ttf,cha):
    global check,d
    if 0 in check:
        check[0]=min(check[n]+n*d,check[0])
    else:
        check[0]=check[n]+n*d
    if n//ttf==0:
        if n//ttf in check:
            if check[n//ttf]>check[n]+(n%ttf)*d:
                check[n//ttf]=check[n]+(n%ttf)*d
        else:
            check[n//ttf]=check[n]+(n%ttf)*d
    else:
        if n//ttf in check:
            if check[n//ttf]>check[n]+(n%ttf)*d+cha:
                check[n//ttf]=check[n]+(n%ttf)*d+cha
                dfs(n//ttf)
        else:
            check[n//ttf]=check[n]+(n%ttf)*d+cha
            dfs(n//ttf)
    if 1+n//ttf in check:
        if check[1+n//ttf]>check[n]+(ttf-n%ttf)*d+cha:
            check[1+n//ttf]=check[n]+(ttf-n%ttf)*d+cha
            dfs(1+n//ttf)
    else:
        check[1+n//ttf]=check[n]+(ttf-n%ttf)*d+cha
        dfs(1+n//ttf)


def dfs(n):
    global check,a,b,c,d
    dfs_sub(n,2,a)
    dfs_sub(n,3,b)
    dfs_sub(n,5,c)

t=int(input())
ans=[0]*t
for i in range(t):
    N,a,b,c,d=map(int,input().split())
    check={N:0}
    dfs(N)
    ans[i]=check[0]
for i in range(t):
    print(ans[i])
### BUGGY CODE ###

N = int(input())
A = []
K = 0
edges = [[0]*N for _ in range(N)]
cnt_edges = [0]*N
for i in range(N-1):
    a,b = [int(x) for x in input().split()]
    edges[a-1][b-1] = -1
    edges[b-1][a-1] = -1

    cnt_edges[a-1]+=1
    cnt_edges[b-1]+=1
    A.append((a-1,b-1))

K = max(cnt_edges)

stk = [(0,0)]
while(stk):
    n,used = stk.pop()
    available_color = [i for i in range(1, K+1)]
    if(used!=0):
        available_color.remove(used)
    for ind,i in enumerate(edges[n]):
        if(i==-1):
            col = available_color.pop()
            edges[n][ind] = col
            edges[ind][n] = col
            stk.append((ind, col))
print(K)
for a,b in A:
    print(edges[a][b])


### FIXED CODE ###

N = int(input())
edges = [[] for _ in range(N)]
cnt_edges = [0]*N
colors = [0]*(N-1)
di = {}
A = []
K = 0
for i in range(N-1):
    a,b = [int(x) for x in input().split()]
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

    K=max(K,len(edges[a-1]),len(edges[b-1]))
    di[(a-1,b-1)] = i
    di[(b-1,a-1)] = i
    A.append((a-1,b-1))
#%%
#K = max(cnt_edges)

stk = [(0,0)]
seen = set()
while(stk):
    n,used_color = stk.pop()
    available_color = 1
    next_stk = []
    for next in edges[n]:
        if(next in seen):
            continue
        if(available_color == used_color):
            available_color += 1
        next_stk.append((next,available_color))
        i = di[(next,n)]
        colors[i] = available_color
        available_color += 1
    stk += next_stk
    seen.add(n)

print(K)
for col in colors:
    print(col)
### BUGGY CODE ###

def modpow(a, b, mod=1):
    ret = 1
    while b > 0:
        if b % 2 == 1:
            ret = ret * a % mod
        a = a * a % mod
        b //= 2
    return ret


MOD = 10 ** 9 + 7
X, Y = map(int, input().split())

if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
    print(0)
elif (2 * X - Y) // 3 < 0 or (2 * Y - X) // 3 < 0:
    print(0)
else:
    A, B = (2 * X - Y) // 3, (2 * Y - X) // 3
    ans = 1
    for n in range(A + B, A, -1):
        ans = ans * n % MOD
    for n in range(1, B + 1):
        ans = ans * modpow(n, MOD - 2, MOD) % MOD
    print(ans % MOD)


### FIXED CODE ###

MOD = 10 ** 9 + 7


def modpow(a, b, mod):
    ret = 1
    while b > 0:
        if b % 2 == 1:
            ret = ret * a % mod
        a = a * a % mod
        b //= 2
    return ret


X, Y = map(int, input().split())
if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
    print(0)
elif (2 * X - Y) // 3 < 0 or (2 * Y - X) // 3 < 0:
    print(0)
else:
    A, B = (2 * X - Y) // 3, (2 * Y - X) // 3
    ans = 1
    for n in range(A + B, A, -1):
        ans = ans * n % MOD
    for n in range(1, B + 1):
        ans = ans * modpow(n, MOD - 2, MOD) % MOD
    print(ans % MOD)
### BUGGY CODE ###


def lcmm(l,m):
    low,high = 1,1
    
    if(l==m):return l
    elif(l>m):
        if(l % m ==0):return l
        high = l
        low = m
        
    else:
        if(m % l ==0):return m
        high = m
        low = l
    lcm = high
    while(lcm%low != 0):
        lcm += high

    return lcm
n = int(input().strip())
last = 1
lcm = 1
for i in range(n):
    num = int(input().strip())
    lcm = lcmm(lcm,num)
    #print(lcm)

print(lcm)
    


### FIXED CODE ###

def gcd(a,b):
    if(a == 0):
        return b
    else:
        return gcd(b % a, a)
    
def lcmm(l,m):

    prod = l * m

    gcD = gcd(l,m)

    return (prod // gcD)

n = int(input().strip())

lcm = 1
for i in range(n):
    num = int(input().strip())
    lcm = lcmm(lcm,num)
    #print(lcm)

print(lcm)
### BUGGY CODE ###

class RollingHash:
    def __init__(self, s):
        B = 10**5+7
        self.MOD = 10**9+7

        size = len(s)
        self.hashtable = [0] * (size+1)
        self.power = [0] * (size+1)
        self.power[0] = 1

        for i in range(1, size+1):
            self.hashtable[i] = (self.hashtable[i-1] * B + ord(s[i-1]))%self.MOD
        for i in range(1, size+1):
            self.power[i] = (B * self.power[i-1])%self.MOD

    def get_hash(self, l, length):
        r = length+l-1
        l -= 1
        return (self.hashtable[r]-self.hashtable[l]*self.power[r-l])%self.MOD


N = int(input())
S = input()
size = len(S)
hash_table = RollingHash(S)

ans = 0
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if S[i-1]!=S[j-1]:continue

        left = 1
        right = min(j-i, size-j+1)+1

        while right-left>1:
            m = (left+right)//2
            if hash_table.get_hash(i, m)==hash_table.get_hash(j, m):
                left = m
            else:
                right = m
        ans = max(ans, left)

print(ans)


### FIXED CODE ###

N = int(input())
S = input()
dp = [[0]*(N+1) for _ in range(N+1)]

for l in range(N)[::-1]:
    for r in range(l+1, N)[::-1]:
        dp[l][r] = dp[l+1][r+1]+1 if S[l]==S[r] else 0

ans = 0 
for l in range(N)[::-1]:
    for r in range(l+1, N)[::-1]:
        ans = max(ans, min(r-l, dp[l][r]))
print(ans)
### BUGGY CODE ###

s=list(input())
t=list(input())
n=len(s)
def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for i in range(n):
        ans[s[i]].append(i)
    return ans


def get_index2alpha(s):
    ans={}
    for i in range(n):
        ans[i]=s[i]
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0
for i in range(len(s)):
    if not s_count[s_index[i]]==t_count[t_index[i]]:
        ans+=1

if ans==0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s=list(input())
t=list(input())
n=len(s)
def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for i in range(n):
        ans[s[i]].append(i)
    return ans


def get_index2alpha(s):
    ans={}
    for i in range(n):
        ans[i]=s[i]
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0

s_set=set(s)


for i in range(n):
    s_alpha=s_index[i]
    t_alpha = t_index[i]
    if s_alpha in s_set:
        s_set.remove(s_alpha)
        if not s_count[s_alpha]==t_count[t_alpha]:
            ans+=1

if ans==0:
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import collections

class BellmanFord():
    def __init__(self):
        self.edges = []

    def add(self, u, v, d, directed=False):
        """
        u = from, v = to, d = cost
        directed = Trueのとき、有向グラフである。
        """
        if directed is False:
            self.edges.append([u, v, d])
            self.edges.append([v, u, d])
        else:
            self.edges.append([u, v, d])

    def BellmanFord_search(self, s):
        """
        次のBellmanFord_negative_boolまで考慮した時には、0-indexedであることに注意
        s =  始点
        return: d[i] 始点sから各点iまでの最短経路
        """
        d = collections.defaultdict(lambda: float('inf'))
        d[s] = 0
        numEdges = len(self.edges)
        while True:
            update = False
            for i in range(numEdges):
                e = self.edges[i]
                # e: 辺iについて [from,to,cost]
                if d[e[0]] != float("inf") and d[e[1]] > d[e[0]] + e[2]:
                    d[e[1]] = d[e[0]] + e[2]
                    update = True
            if not update:
                break
        return d

    def BellmanFord_negative_bool(self, numNodes, zero_indexed=False):
        # 負の閉路の検出, Trueなら負の閉路が存在する
        d = collections.defaultdict(lambda: float('inf'))
        d[0] = 0
        numEdges = len(self.edges)
        for i in range(numNodes):
            for j in range(numEdges):
                e = self.edges[j]
                if d[e[1]] > d[e[0]] + e[2]:
                    d[e[1]] = d[e[0]] + e[2]
                    if i == numNodes-1 and e[1] == numNodes-1:
                        return True
        return False

n,m = na()
g = BellmanFord()

for i in range(m):
    a,b,c = na()
    a,b,c = a-1,b-1,-c
    g.add(a, b, c, directed=True)

if g.BellmanFord_negative_bool(n):
    print('inf')

d = g.BellmanFord_search(0)

print(-d[n-1])

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
abc = [tuple(na()) for i in range(m)]

dp = [float('inf')]*n
dp[0] = 0

for i in range(n):
    for a,b,c in abc:
        a,b,c = a-1,b-1,-c
        if dp[a] != float('inf') and dp[b] > dp[a] + c:
            dp[b] = dp[a] + c
            if i == n-1 and b == n-1:
                print('inf')
                exit()

print(-dp[-1])
### BUGGY CODE ###

N,X,Y=map(int,input().split())

def count(k):
    ans=0
    for i in range(1,N):
        for j in range(i+1,N+1):
            if min(abs(j-i),abs(X-i)+abs(Y-j)+1)==k:
                ans+=1
    return ans

for k in range(1,N):
    print(count(k))


### FIXED CODE ###

N,X,Y=map(int,input().split())

ans=[0]*N

for i in range(1,N):
    for j in range(i+1,N+1):
        ans[min(abs(j-i),abs(X-i)+abs(Y-j)+1)]+=1

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

N=int(input())
A=list(map(int,input().split()))
for i in range(1,max(A)+1):
  print(A.count(i))
for j in range(max(A)+1,N+1):
  print(0)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
import collections
c=collections.Counter(A)
for i in range(1,N+1):
  print(c[i])
### BUGGY CODE ###

n = int(input())
mv = [int(input()) for i in range(5)]
st = [n,0,0,0,0,0]
time = 0

while st[5] != n:
    stcpy = st[:]
    for i in range(5):
        if stcpy[i]-mv[i] >= 0:
            st[i] -= mv[i]
            st[i+1] += mv[i]
        else:
            st[i] -= stcpy[i]
            st[i+1] += stcpy[i]
    time += 1
else:
    ans = time

print(ans)


### FIXED CODE ###

n = int(input())
t = [int(input()) for _ in range(5)]
m = min(t)
print((n+m-1)//m+4)
### BUGGY CODE ###

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]

H.sort()
res = 10000000000
for i in range(N-K+1):
    res = min(res, max(H[i:i+K]) - min(H[i:i+K]))
print(res)

### FIXED CODE ###

N, K = map(int, input().split())
H = [int(input()) for _ in range(N)]

H.sort()
res = 10000000000
for i in range(0, N-K+1):
    res = min(res, H[i+K-1] - H[i])
print(res)
### BUGGY CODE ###

def make_divisors(n):
	divisors = []
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n//i)

	divisors.sort()
	return divisors

x = int(input())

l = make_divisors(x)

for i in range(max(len(l)//2,1)):
	a = -10**4+l[i]
	b = -10**4
	#print(a,b)
	while True:
		num = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
		if num == l[-i-1]:
			print(a,b)
			#print('Yes!')
			break
		if a == 10**5:
			break
		#print(l[-i-1],num)
		a += 1
		b += 1



### FIXED CODE ###

def make_divisors(n):
	divisors = []
	for i in range(1, int(n**0.5)+1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n//i)

	divisors.sort()
	return divisors

x = int(input())

l = make_divisors(x)

for i in range(max(len(l)//2,1)):
	a = -10**3+l[i]
	b = -10**3
	#print(a,b)
	while True:
		num = a**4 + (a**3)*b + (a**2)*(b**2) + a*(b**3) + b**4
		if num == l[-i-1]:
			print(a,b)
			#print('Yes!')
			break
		if b == 10**3:
			break
		#print(l[-i-1],num)
		a += 1
		b += 1
### BUGGY CODE ###

import numpy as np
N, K = map(int,input().split())
H = np.array([int(input()) for _ in range(0, N)])
H = np.sort(H)
H_diff = abs(H[1:]-H[:-1])
best = 10**9
for i in range(0, len(H_diff)-K+2):
    s = np.sum(H_diff[i:i+K-1])
    if s < best:
        best = s
print(best)

### FIXED CODE ###

import numpy as np
N, K = map(int,input().split())
H = np.array([int(input()) for _ in range(0, N)])
H = np.sort(H)
H_diff = np.diff(H)
best = int(np.min(np.convolve((H_diff), np.ones(K-1), mode='valid')))
print(best)
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import itertools
import math
N = int(input())
An = list(map(int,input().split()))
#組み合わせ nC2
numList = list(itertools.combinations(range(1,N+1), 2))
count = 0
for pair in numList:
    #　数字のdiff (絶対値) float型
    numDiff = int(math.fabs(pair[1] - pair[0]))
    # 身長の和
    sumHeight = An[pair[0]-1] + An[pair[1]-1]
    if numDiff == sumHeight:
        count = count + 1
print(count)

### FIXED CODE ###

N = int(input())
An = list(map(int,input().split()))
countN = 0
sum = [0]*N
for i, name in enumerate(An):
    if i + name < N:
        sum[i+name] = sum[i+name] + 1
    if i - name >= 0:
        countN = countN + sum[i-name]
print(countN)
### BUGGY CODE ###

N=int(input())
S=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            count=0
            for s in S:
                if count==0:
                    if s==str(i):
                        count+=1
                elif count==1:
                    if s==str(j):
                        count+=1
                elif count==2:
                    if s==str(k):
                        count+=1
                if count==3:
                    ans+=1
                    break
print(ans)

### FIXED CODE ###

N=int(input())
S=input()
ans=0
for i in range(10):
    for j in range(10):
        for k in range(10):
            count=0
            for s in S:
                if count==0:
                    if s==str(i):
                        count+=1
                elif count==1:
                    if s==str(j):
                        count+=1
                elif count==2:
                    if s==str(k):
                        count+=1
                if count==3:
                    ans+=1
                    break
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

dp = [[[0, 0, 0] for _ in range(s+1)] for _ in range(n+1)]
for i in range(n):
    dp[0][0][0] = 1
    for j in range(s+1):
        dp[i+1][j][0] += dp[i][j][0]
        dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]
        dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]
        if j + a[i] <= s:
            dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]
            dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]

print(dp[n][s][2] % p)

### FIXED CODE ###

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

dp = [0] * (S+1)
ans = 0
for i in range(N):
    ndp = dp[:]
    if A[i] <= S:
        ndp[A[i]] = (ndp[A[i]] + i+1) % mod
    for j in range(S):
        if j+A[i] <= S:
            ndp[j+A[i]] = (ndp[j+A[i]] + dp[j]) % mod
    ans = (ans + ndp[S]) % mod
    dp = ndp[:]
print (ans)
### BUGGY CODE ###

import itertools

N = int(input())
L = list(map(int, input().split(' ')))

L = sorted(L)

count = 0

for i in range(N - 1):
    for j in range(i + 1, N - 1):
        x, y = L[i], L[j]
        top = N
        bottom = j + 1
        tmp = (top + bottom) // 2
        
        while(top - bottom > 1):
            if L[tmp] >= x + y:
                top = tmp
                tmp = (top + bottom) // 2
            elif L[tmp] < x + y:
                bottom = tmp
                tmp = (top + bottom) // 2
        if bottom - j == 1:
            if L[bottom] < x + y:
                count += 1
        else:
            count += (bottom - j)

print(count)

### FIXED CODE ###

import itertools
import bisect

N = int(input())
L = list(map(int, input().split(' ')))

L = sorted(L)

count = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        x, y = L[i], L[j]
        limit = x + y
        index = bisect.bisect_left(L, limit)
        count += max(0, index - j - 1)

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

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
total = 0
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

mod = 10**9+7
N = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N + 1):
    g1.append(( g1[-1] * i ) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

mem = {}

def cmb(n, r, mod):
    if (n,r) not in mem:
        mem[(n,r)] = _cmb(n, r, mod)
    return mem[(n,r)]

for i in range(n-k+1):
    for j in range(i+k-1,n):
        total += cmb(j-i-1,k-2,mod)*(a[j]-a[i])
        total %= mod
print(total)

### FIXED CODE ###

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
total = 0
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

mod = 10**9+7
N = 10**5
g1 = [1,1]
g2 = [1,1]
inverse = [0,1]

for i in range(2, N + 1):
    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(n-k+1):
    total += cmb(n-i-1,k-1,mod)*(a[n-i-1]-a[i])
    total %= mod
print(total)
### BUGGY CODE ###

def solve(i, m):
    if m == 0:
        return True
    if i == n or m < 0:
        return False

    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    return res

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

q = int(raw_input())
M = map(int, raw_input().split())

for i in M:
    print "yes" if solve(0, i) else "no"

### FIXED CODE ###

def solve(i, m):
    if m == 0: return True

    if i < n and min(A[i:]) <= m <= sum(A[i:]):
        r1 = solve(i + 1, m-A[i])
        if r1: return r1
        r2 = solve(i + 1, m)
        if r2: return r2


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

q = int(raw_input())
M = map(int, raw_input().split())

for i in M:
    print "yes" if solve(0, i) else "no"
### BUGGY CODE ###

n = int(input())
s = list(input())

num_wes = s.count('W')
num_eas = s.count('E')


res = []
for i in range(n):
    a = s[:i].count("W")
    res += [2*a + num_eas - i]
    
print(min(res))


### FIXED CODE ###

n = int(input())
s = list(input())

num_eas = s.count('E')


res = []
res += [num_eas - s[0].count("E")]

for i in range(1,n):
    res += [res[i-1] + s[i-1].count("W") - s[i].count("E")]
    
print(min(res))
### BUGGY CODE ###

import numpy as np

def main():

    N, K, Q = map(int, input().split())
    player = np.array([K] * N)
    sub = np.array([-1] * N)
    A = [int(input()) for i in range(Q)]
    for i in range(Q):
        player[A[i] - 1] += 1
        player += sub
    for k in range(N):
        if player[k] <= 0:
            print("No")
        else:
            print("Yes")

if __name__ == "__main__":
    main()

### FIXED CODE ###

import numpy as np

def main():

    N, K, Q = map(int, input().split())
    player = np.array([K - Q] * N)
    sub = np.array([-1] * N)
    A = [int(input()) for i in range(Q)]
    for i in range(Q):
        player[A[i] - 1] += 1
    for k in range(N):
        if player[k] <= 0:
            print("No")
        else:
            print("Yes")

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

# coding: utf-8
#Problem Name: Prime Number
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

while True:
    try:
        n = int(raw_input())
        List = []
        for i in range(1,n+1):
            List2 = []
            for j in range(2,int(i**.5)+1):
                List2.append(i % j != 0)
            if i != 1 and all(List2):
                List.append(i)
        print len(List)
    except:
        break

### FIXED CODE ###

# coding: utf-8
#Problem Name: Prime Number
#ID: tabris
#Mail: t123037@kaiyodai.ac.jp

__max = 999999
List = [False,True]*(__max/2+1)
List[1] = False
List[2] = True
for i in xrange(3,int(__max**.5)+1,2):
    List[i**2::i] = [False]*len(List[i**2::i])

List = [i for i in xrange(2,__max) if List[i]]

while True:
    try:
        n = int(raw_input())
        print __import__('bisect',fromlist=['bisect_right']).bisect_right(List,n)
    except:
        break
### BUGGY CODE ###

n = int(input())
#a,b = map(int,input().split())
li = list(map(int,input().split()))
li.sort()
#print(li)
num = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if li[i]+li[j]>li[k] and li[i]<li[j]+li[k] and li[i]+li[k]>li[j]:
                num += 1
                #print(li[i],li[j],li[k])
print(num)


### FIXED CODE ###

n = int(input())
li = list(map(int,input().split()))
li.sort()

num = 0
import bisect
for i in range(n):
    for j in range(i+1,n):
        num += bisect.bisect_left(li,li[i]+li[j])-(j+1)
print(num)
### BUGGY CODE ###

import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split()])
q = int(input())
hako = np.array([0]*(10**6))
ind = np.array(list(range(10**6)))
s = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
#     S += (ind[c] - ind[b])*hako[b]
    hako[c] += hako[b]
    hako[b] = 0
    S = np.sum(hako*ind)
    s.append(S)
for i in range(q):
    print(s[i])

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
hako = [0]*(10**6)
ind = list(range(10**6))
S = sum(a)
s = []

for i in a:
    hako[i] += 1

for i in range(q):
    b, c = [int(i) for i in input().split()]
    S += (ind[c] - ind[b])*hako[b]
    s.append(S)
    hako[c] += hako[b]
    hako[b] = 0
for i in range(q):
    print(s[i])
### BUGGY CODE ###

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

INF = 10 ** 10
dp = [INF] * N

dp[0] = 0

for i in range(1, N):
    for j in range(min(K, i) + 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()))

INF = 10 ** 10
dp = [INF] * N

dp[0] = 0

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

print(dp[N-1])