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

L=list()
s=input()
K=int(input())
for i in range(len(s)):
  for j in range(i+1,len(s)+1):
    L.append(str(s[i:j]))
L=sorted(list(set(L)))
print(L[K-1])

### FIXED CODE ###

L=list()
s=input()
K=int(input())
if len(s)<10:
  for i in range(len(s)):
    for j in range(i+1,len(s)+1):
      L.append(str(s[i:j]))
  L=sorted(list(set(L)))
  print(L[K-1])
else:
  A=sorted(list(s))
  B=[A[0],A[1],A[2],A[3],A[4]]
  for i in range(len(s)):
    if s[i] in B:
      for j in range(i+1,min(i+6,len(s)+1)):
        L.append(str(s[i:j]))
      L=sorted(list(set(L)))
      if len(L)>K:
        L=list(L[:K])
  print(L[K-1])
### BUGGY CODE ###

X = 998244353

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

def calc_inverse(n, law):
	if n == 1:
		return 1
	
	pre_r = law
	pre_x = 0
	pre_y = 1
	cur_r = n
	cur_x = 1
	cur_y = 0
	
	while True:
		d = pre_r // cur_r
		r = pre_r % cur_r
		
		nxt_r = r
		nxt_x = pre_x - d * cur_x
		nxt_y = pre_y - d * cur_y
		
		if nxt_r == 1:
			ret = nxt_x
			while ret < 0:
				ret += law;
			return ret;
		elif nxt_r == 0:
			return None
		
		pre_r = cur_r;
		pre_x = cur_x;
		pre_y = cur_y;
		cur_r = nxt_r;
		cur_x = nxt_x;
		cur_y = nxt_y;

inv_cache = [1]
for i in range(1, K + 1):
	inv_cache.append(calc_inverse(i, X))

inv_f_cache = [1]
d = 1
for i in range(1, K + 1):
	d = (d * inv_cache[i]) % X
	inv_f_cache.append(d)

f_cache = {}
#c = 1
#for i in range(N - M, N):
#	c = (c * i) % X
#	f_cache.append(c)

#print(f_cache, inv_f_cache)

def C(n, m):
	if m in f_cache:
		c = f_cache[m]
	else:
		c = 1
		for i in range(n - m + 1, n + 1):
			c = (c * i) % X
		f_cache[m] = c
#	d = 1
#	for i in range(1, m + 1):
#		d = (d * inv_cache[i]) % X
	return (c * inv_f_cache[m]) % X


total = 0
for k in range(K + 1):
	total = (total + M * pow(M - 1, N - 1 - k, X) * C(N - 1, k)) % X
	
#	print(k, M * pow(M - 1, N - 1 - k, X))
	

print(total)


### FIXED CODE ###

X = 998244353

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

def calc_inverse(n, law):
	if n == 1:
		return 1
	
	pre_r = law
	pre_x = 0
	pre_y = 1
	cur_r = n
	cur_x = 1
	cur_y = 0
	
	while True:
		d = pre_r // cur_r
		r = pre_r % cur_r
		
		nxt_r = r
		nxt_x = pre_x - d * cur_x
		nxt_y = pre_y - d * cur_y
		
		if nxt_r == 1:
			ret = nxt_x
			while ret < 0:
				ret += law;
			return ret;
		elif nxt_r == 0:
			return None
		
		pre_r = cur_r;
		pre_x = cur_x;
		pre_y = cur_y;
		cur_r = nxt_r;
		cur_x = nxt_x;
		cur_y = nxt_y;

inv_cache = [1]
for i in range(1, K + 1):
	inv_cache.append(calc_inverse(i, X))

inv_f_cache = [1]
d = 1
for i in range(1, K + 1):
	d = (d * inv_cache[i]) % X
	inv_f_cache.append(d)

f_cache = [1]
c = 1
for i in range(N - 1, N - K - 1, -1):
	c = (c * i) % X
	f_cache.append(c)

#print(f_cache, inv_f_cache)

def C(n, m):
#	if m in f_cache:
#		c = f_cache[m]
#	else:
#		c = 1
#		for i in range(n - m + 1, n + 1):
#			c = (c * i) % X
#		f_cache[m] = c
#	d = 1
#	for i in range(1, m + 1):
#		d = (d * inv_cache[i]) % X
#	print(m)
	return (f_cache[m] * inv_f_cache[m]) % X


total = 0
for k in range(K + 1):
	total = (total + M * pow(M - 1, N - 1 - k, X) * C(N - 1, k)) % X
	
#	print(k, M * pow(M - 1, N - 1 - k, X))
	

print(total)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
for i in range(k):
    now = a[now - 1]
print(now)


### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
now = 1
chk = [0] * n
flg = True
count = 0
if k < 10 ** 7:
    for i in range(k):
        now = a[now - 1]
else:
    while flg:
        count += 1
        now = a[now - 1]
        if chk[now - 1] == 0 and now != 1:
            chk[now - 1] = count
        else:
            flg = False
            if (k - count) != 0 and (count - chk[now - 1]) != 0:
                rem = (k - count) % (count - chk[now - 1])
            else:
                rem = 0
    else:
        for i in range(rem):
            now = a[now - 1]
            count += 1
print(now)
### BUGGY CODE ###

def main():
    n = int(input())
    s = input()
    whole = (n*(n-1)*(n-2))//6
    num = n-2
    cnt = 0
    for i in range(n-3):
        for j in range(i+1,n-1):
            if j == i+1:
                if s[i] == s[j]:
                    cnt += (n-(j+2))
                    continue
                for k in range(j+2,n):
                    if (j-i) == (k-j) or s[j] == s[k] or s[i] == s[k]:
                        cnt += 1
            else:
                if s[i] == s[j]:
                    cnt += (n-(j+1))
                    continue
                for k in range(j+1,n):
                    if (j-i) == (k-j) or s[j] == s[k] or s[i] == s[k]:
                        cnt += 1
    print(whole-num-cnt)

if __name__ == "__main__":
    main()

### FIXED CODE ###

n = int(input())
S = input()
k = 0
num = 0
r, g, b = 0, 0, 0
for s in S:
    if s == "R": r += 1
    elif s == "G": g += 1
    else: b += 1
whole = r * g * b
for i in range(n-2):
    for j in range(i+1,n-1):
        k = 2 * j - i
        if k >= n:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            num += 1
print(whole - num)
### BUGGY CODE ###


import math

M=[]
for i in range(1001):
   m=(i+1)/2
   M.append(m) 

N,K=map(int,input().split())
P=list(map(int,input().split()))
Q=[]
q=0

for i in range(N-K+1):
   for j in range(K):
       a=P[i+j]
       q=q+M[a]
   Q.append(q)
   q=0

print(max(Q))

       

### FIXED CODE ###

M=[]
for i in range(1001):
   m=(i+1)/2
   M.append(m) 

N,K=map(int,input().split())
P=list(map(int,input().split()))
S=[]
s=0
for i in range(N):
    a=P[i]
    s=s+M[a]
    S.append(s)
Q=[]
Q.append(S[K-1])
q=0
for i in range(N-K):
    q=S[i+K]-S[i] 
    Q.append(q)
    q=0
print(max(Q))
### BUGGY CODE ###

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

DP=[[0]*(W+1) for i in range(N+1)]

for i in range(N):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j-w>=0:
            DP[i+1][j]=max(DP[i][j],DP[i][j-w]+v)
        DP[i+1][j]=max(DP[i+1][j],DP[i][j])
print(max(DP[N]))



### FIXED CODE ###

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

DP=[[0]*(W+1) for i in range(N+1)]

for i in range(N):
    w,v=map(int,input().split())
    for j in range(1,W+1):
        if j-w>=0:
            DP[i+1][j]=max(DP[i][j],DP[i][j-w]+v)
        DP[i+1][j]=max(DP[i+1][j],DP[i][j])
print(max(DP[N]))
### BUGGY CODE ###

X, K, D = map(int, input().split())
X=abs(X)
if D>=X and K%2==0:
    ans=X
elif D>=X and K%2==1:
    ans=D-X
elif D<X and K*D<X:
    ans=X-K*D
else:
    ans=X
    for i in range(0,K):
        ans=ans-D
        if ans<0 and (K-i)%2==0:
            ans=ans+D
            break
        elif ans<0 and (K-i)%2==1:
            ans=-ans
            break
print(ans)

### FIXED CODE ###

X, K, D = map(int, input().split())
X=abs(X)
if D>=X and K%2==0:
    ans=X
elif D>=X and K%2==1:
    ans=D-X
elif D<X and K*D<X:
    ans=X-K*D
else:
    ans=X%D
    if (X-ans)%2!=K%2:
        ans=D-ans
print(ans)
### BUGGY CODE ###

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

for num in range(x):
    print(A.count(num+1))

### FIXED CODE ###

import numpy as np

x = int(input())
l = [0] * x
A = list(map(int, input().split()))

for num in range(x-1):
    l[A[num]-1] += 1

for i in range(x):
    print(l[i])
### BUGGY CODE ###

N = int(input())
a = input().split(' ')
for i in range(1,N+1):
    if int(a.count(str(i))) > 0:
        print(a.count(str(i)))
    else:
        print(0)

### FIXED CODE ###

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

ans = [0]*N

for i in A:
    ans[i - 1] += 1
print('\n'.join(map(str,ans)))
### BUGGY CODE ###

s = input()
MOD = 10**9 + 7
memo = [0]*13
memo[0] = 1

c = 1
for d in reversed(s):
    if d == '?':
        nmemo = [0]*13
        for i in range(10):
            r = (i*c)%13
            for j in range(13):
                nmemo[(j+r)%13] += memo[j]
        for i in range(13):
            nmemo[i] %= MOD
        memo = nmemo
    else:
        d = (-int(d)*c)%13
        memo = memo[d:] + memo[:d]

    c *= 10
    c %= 13
print(memo[5])

### FIXED CODE ###

s = input()
MOD = 10**9 + 7
memo = [0]*13
memo[0] = 1

c = 1
for d in reversed(s):
    if d == '?':
        nmemo = [0]*13
        for i in range(10):
            r = (i*c)%13
            for j in range(13):
                nmemo[(j+r)%13] += memo[j]
        for i in range(13):
            nmemo[i] %= MOD
        memo = nmemo
    else:
        d = (-int(d)*c)%13
        memo = memo[d:] + memo[:d]

    c *= 10
    c %= 13
print(memo[5])
### BUGGY CODE ###

import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

(X,N) = getVar()
p = getArray()

if (len(p) == 0):
  print(X)
else:
  subp = p - X
  i = 0
  while (True):
    if (not i in subp):
      break
  print(X - i)

### FIXED CODE ###

import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

(X,N) = getVar()
p = getArray()

if (len(p) == 0):
  print(X)
else:
  subp = p - X
  i = 0
  while (True):
    if (not -i in subp):
      print(X - i)
      break
    if (not i in subp):
      print(X + i)
      break
    i += 1
### BUGGY CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
from collections import Counter
a = list(map(int, input().split()))
c = Counter(a)
s = set()
for k,v in c.items():
    if v>=2:
        s.add(k)
        
a.sort()
tmp = [a[0]]
for i in range(1, n):
    num = a[i]
    for item in tmp:
        if num%item==0:
            break
    else:
        tmp.append(num)
tmp = set(tmp) - s
print(len(tmp))

### FIXED CODE ###

import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
from collections import Counter
a = list(map(int, input().split()))
c = Counter(a)
s = set()
for k,v in c.items():
    if v>=2:
        s.add(k)
        
a.sort()
ok = set()
p = set(list(range(1, 10**6+1)))
ck = list(c.keys())
ck.sort()
for num in ck:
    if num in p:
        ok.add(num)
    i = 2
    while num*i<=10**6:
        if num*i in p:
            p.remove(num*i)
        i += 1
tmp = ok
tmp = set(tmp) - s
print(len(tmp))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 5)
S = input()
Ls = [1, 10, 9, 12, 3, 4]  # 10^n % 13, n % 6でループ
C = 10 ** 9 + 7

L = len(S) - 1
mem = [[-1 for _ in range(13)] for _ in range(len(S))]


def calc(i, m):  # i桁目以下で余りがmとなるようにする
    if mem[i][m] >= 0:
        return mem[i][m]
    t = S[L - i]
    if t == '?':
        if i == 0:
            if m < 10:
                mem[i][m] = 1
                return 1
            else:
                mem[i][m] = 0
                return 0
        else:
            s = 0
            for j in range(10):
                tm = m - ((Ls[i % 6] * j) % 13)
                if tm < 0:
                    tm += 13
                s += calc(i - 1, tm)
            s %= C
            mem[i][m] = s
            return s
    else:
        tn = int(t)
        if i == 0:
            if m == tn:
                mem[i][m] = 1
                return 1
            else:
                mem[i][m] = 0
                return 0
        else:
            tm = m - ((Ls[i % 6] * tn) % 13)
            if tm < 0:
                tm += 13
            k = calc(i - 1, tm) % C
            mem[i][m] = k
            return k


print(calc(len(S) - 1, 5))

### FIXED CODE ###

S = input()
Ls = [1, 10, 9, 12, 3, 4]  # 10^n % 13, n % 6でループ
C = 10 ** 9 + 7

L = len(S) - 1
mem = [[0 for _ in range(13)] for _ in range(len(S))]
if S[L] == '?':
    for m in range(10):
        mem[0][m] = 1
else:
    mem[0][int(S[L])] = 1

for i in range(1, len(S)):
    t = S[L - i]
    for m in range(13):
        if t == '?':
            s = 0
            for j in range(10):
                tm = m - ((Ls[i % 6] * j) % 13)
                if tm < 0:
                    tm += 13
                s += mem[i - 1][tm]
            mem[i][m] = s % C
        else:
            tm = m - ((Ls[i % 6] * int(t)) % 13)
            if tm < 0:
                tm += 13
            mem[i][m] = mem[i - 1][tm] % C
print(mem[len(S) - 1][5])
### BUGGY CODE ###

#B

A,B,C,K=map(int,input().split())
cnt=0
Sum=0
while True:
    if cnt==K:
        print(Sum)
        break
        
    if A!=0:
        A+=-1
        Sum+=1
        cnt+=1
        continue
        
    elif B!=0:
        B+=-1
        cnt+=1
        continue
        
    elif C!=0:
        C+=-1
        Sum+=-1
        cnt+=1
        continue

### FIXED CODE ###

#B

A,B,C,K=map(int,input().split())

if K<=A:
    Sum=K
elif K<=A+B:
    Sum=A
else:
    Sum=A-(K-A-B)
    
print(Sum)
### BUGGY CODE ###

w = []
v = []
n, W = map(int, input().split())
#dp = [[0 for i in range(n)] for j in range(W)]
dp = [[None for i in range(W+1)] for j in range(n+1)]

for i in range(n):
    v1, v2 = map(int, input().split())
    w.append(v1)
    v.append(v2)

# i: Index (Tracing all items)
# j: Remaining weight
# Return the sum of value
def knap(i, j):
    # print("\n# i: " + str(i))
    # print("# j: " + str(j))
    if dp[i][j] is not None:
        return dp[i][j]

    res = 0

    if i == n:
#        dp[i][j] = 0
        res = 0
    elif j < w[i]:
        res = knap(i+1, j)
    else:
        # if dp[i][j] is None:
        #     dp[i][j] = dp[i-1][j] + v[i]
        res = max(knap(i+1, j), knap(i+1, j-w[i]) + v[i])

    dp[i][j] = res
    return dp[i][j]
#    return res

print(knap(0, W))


### FIXED CODE ###

n, W = map(int, input().split())
w = [0]*(n+1)
v = [0]*(n+1)

#dp = [[None for i in range(W+1)] for j in range(n+1)]
dp = [[0 for i in range(W+1)] for j in range(n+1)]

for i in range(n):
    w[i], v[i] = map(int, input().split())

def knap(i, j):
    if dp[i][j] is not None:
        return dp[i][j]

    res = 0

    if i == n:
       	res = 0
    elif j < w[i]:
        res = knap(i+1, j)
    else:
        res = max(knap(i+1, j), knap(i+1, j-w[i]) + v[i])

    dp[i][j] = res
    return dp[i][j]

for i in reversed(range(n)):
    for j in range(W+1):
#        res = 0
        # if i == n-1:
        #     res = 0
        if j < w[i]:
            dp[i][j] = dp[i+1][j]
        else:
            dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]] + v[i])

#print(knap(0, W))
print(dp[0][W])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
box = np.zeros(N+1, np.int32)
ans = []
for i in reversed(range(1, N+1)):
    # iの倍数の箱の合計
    if sum(box[i::i]) % 2 != A[i-1]:
        box[i] = 1
        ans.append(i)
    # sum(box[i::i]) % 2 == A[i]
print(len(ans))
print(*ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


mod = 10 ** 9 + 7
N = int(input())
A = list(map(int, input().split()))
box = [0] * (N+1)
ans = []
for i in reversed(range(1, N+1)):
    # iの倍数の箱の合計
    if sum(box[i::i]) % 2 != A[i-1]:
        # sum_ = sum([box[i*j] for j in range(1, N//i+1)])
        box[i] = 1
        ans.append(i)
print(len(ans))
print(*ans)
### BUGGY CODE ###

from collections import Counter

n=int(input())
ss=[input() for _ in range(n)]
ans=0
for i in range(n-1):
    for j in range(i+1,n):
        if Counter(ss[i])==Counter(ss[j]):
            ans+=1
print(ans)

### FIXED CODE ###

from collections import defaultdict

n = int(input())
cnt = defaultdict(int)
for _ in range(n):
    s = list(input())
    s.sort()
    s = tuple(s)
    cnt[s] += 1
print(sum(v * (v - 1) // 2 for v in cnt.values() if v > 1))
### BUGGY CODE ###

def main():
    x = int(input())
    n = int(x ** (1 / 5))
    a = n
    b = n
    while True:
        if a**5 - b**5 == x:
            print(a,b)
            break
        b -= 1

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    x = int(input())
    for i in range(150, 0, -1):
        for j in range(i, -150, -1):
            cal = i ** 5 - j ** 5
            if cal == x:
                print(i, j)
                exit()


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

def edu_dp_a_frog2():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf')] * n
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(2, n):
        for j in range(1, k+1):
            if i >= j:
                dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
            else:
                break
    print(dp[n-1])

edu_dp_a_frog2()

### FIXED CODE ###

def edu_dp_a_frog2():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(2, n):
        dp[i] = min([dp[i-j]+abs(h[i]-h[i-j]) for j in range(1, min(i+1, k+1))])
        # for j in range(1, min(i+1, k+1)):
        #     dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]))
    print(dp[n-1])

edu_dp_a_frog2()
### BUGGY CODE ###

#import heapq
import itertools
#import math
#import numpy as np
#import sys

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
#print(L)
C = itertools.combinations(list(range(0,N-1)), 2)
ans = 0
i = 1
for c in C :
    #print(c)
    while True :
        #print(L[c[1] + i])
        if L[c[0]] + L[c[1]] > L[c[1] + i] :
            ans += 1
            i += 1
        else :
            i = 1
            break

        if c[1] + i > N - 1:
            i = 1
            break
print(ans)


#a = [(x, y, z) for (x, y, z) in itertools.combinations(L, 3) if ((x+y) > z) and ((x+z) > y) and ((y+z) > x)]
#print(len(a))

### FIXED CODE ###

from bisect import bisect_left

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

L.sort()
result = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        result += bisect_left(L, L[i] + L[j]) - j - 1
print(result)
### BUGGY CODE ###

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

### FIXED CODE ###

N,K = map(int, input().split())
H = list(map(int, input().split()))
L = [0]*N
for i in range (1,N):
  L[i] = min(L[i-j] + abs(H[i] - H[i-j]) for j in range(1, min(i,K)+1))
print(L[N-1])
### BUGGY CODE ###

#coding utf-8
N,M=map(int,input().split())
a =[int(input()) for i in range(M)]
ans=1
mod =10**9+7
dp = [1]
for i in range(1,N+1):
  if i in a:
    dp.append(0)
  else:
    if i ==1:
      dp.append(dp[i-1])
    else:
      dp.append((dp[i-1]+dp[i-2])%mod)

print(dp[N]%mod)

### FIXED CODE ###

#coding utf-8
N,M=map(int,input().split())
a =[int(input()) for i in range(M)]
a.append(0)
mod =10**9+7
dp = [1]
j = 0
for i in range(1,N+1):
  if i != a[j]:
    if i ==1:
      dp.append(dp[-1])
    else:
      dp.append((dp[-1]+dp[-2])%mod)
  else:
    dp.append(0)
    j +=1 

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

import sys
sys.setrecursionlimit(10**9)

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

def score(i,j,k,l):#A[i:j)が残っているときのscore,1:Xの手番,-1:Yの手番

    if i==j:
        return k

    if l==1:
        return max(score(i+1,j,k+A[i],-l),score(i,j-1,k+A[j-1],-l))
    if l==-1:
        return min(score(i+1,j,k-A[i],-l),score(i,j-1,k-A[j-1],-l))


print(score(0,N,0,1))

### FIXED CODE ###

import sys
input = sys.stdin.readline

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

SCORE=[[None for i in range(N+1)] for j in range(N+1)]

def score(i,j,k,l):#A[i:j)が残っているときのscore,1:Xの手番,-1:Yの手番
    #print(i,j,k,l)
    
    if SCORE[i][j]!=None:
        return SCORE[i][j]+k
    if i==j:
        SCORE[i][j]=0
        return k

        

    if l==1:
        SCORE[i][j]=max(score(i+1,j,k+A[i],-l),score(i,j-1,k+A[j-1],-l))-k
        return SCORE[i][j]+k
    if l==-1:
        SCORE[i][j]=min(score(i+1,j,k-A[i],-l),score(i,j-1,k-A[j-1],-l))-k
        return SCORE[i][j]+k



hand=N%2
for i in range(N+1):
    for j in range(N-i+1):
        score(j,j+i,0,(-1)**(j+j+i+hand))

print(SCORE[0][N])
### BUGGY CODE ###

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N=int(input())
A=list(map(int,input().split()))
MOD=(10**9)+7
S=list(set(A))
LCM=lcm_list(S)
ans=0

for i in range(N):
    ans+=(LCM//A[i])
    ans=ans%MOD

print(ans)


### FIXED CODE ###

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N=int(input())
A=list(map(int,input().split()))
MOD=(10**9)+7
S=list(set(A))
LCM=lcm_list(S)
ans=0

for i in range(N):
    ans+=(LCM//A[i])


print(ans%MOD)
### BUGGY CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
for a in A:
    for b in B:
        if a >= b:
            continue
        for c in C:
            if b >= c:
                continue
            else:
                ans += 1
print(ans)

### FIXED CODE ###

N = int(input())

A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = i = j = 0

import bisect

for b in B:
    i = bisect.bisect_left(A,b)
    j = N - bisect.bisect_right(C,b)
    ans += i * j
print(ans)
### BUGGY CODE ###

import math
ans = 0
N = int(input())
for i in range(N):
    for j in range(N):
        for k in range(N):
            ans += math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
print(ans)

### FIXED CODE ###

import math
ans = 0
N = int(input())
if N <= 5:
  for i in range(N):
    for j in range(N):
        for k in range(N):
            ans += math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
else:
    for i in range(N):
        ans += i+1
    for i in range(N-1):
        for j in range(i+1,N):
            ans += 6*math.gcd(i+1,j+1)
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
                ans += 6*math.gcd(math.gcd(i+1,j+1),math.gcd(j+1,k+1))
print(ans)
### BUGGY CODE ###

import numpy as np
S = input()

MOD = 10 ** 9 + 7
mod_change_table = [(i * 10) % 13 for i in range(13)]
dp = np.array([[0] * 13] * (len(S)))
if S[0] == '?':
    dp[0][:10] = 1
else:
    dp[0][int(S[0])] = 1

for i in range(1, len(S)):
    for j in range(13):
        if S[i] == '?':
            for k in range(10):
                dp[i][(mod_change_table[j] + k) % 13] += dp[i - 1][j]
        else:
            dp[i][(mod_change_table[j] + int(S[i])) % 13] += dp[i - 1][j]
    dp[i] %= MOD
print(dp[len(S) - 1][5])

### FIXED CODE ###

r = [[(j - k) * 9 % 13 for j in range(10)] for k in range(13)]
d = [1] + [0] * 12
M = 10 ** 9 + 7
for c in input():
    if c == '?':
        d = [sum(d[j] for j in k) % M for k in r]
    else:
        d = [d[(int(c) - k) * 9 % 13] for k in range(13)]
    #print(d)
print(d[5])
### BUGGY CODE ###

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

rsl = []
for i in range(1,n+1):
    rsl.append(a.count(i))

for _ in rsl:
    print(_)

### FIXED CODE ###

import numpy as np
n = int(input())
a = list(map(int,input().split()))

rsl = np.zeros(n)

for i in a:
    rsl[i-1] += 1

for i in range(n):
    print(int(rsl[i]))
### BUGGY CODE ###

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

dp = [0 for _ in range(N)]


import numpy as np
for i in range(N): #0 <= i < N
    if i == 0:
        continue
    else:
        obj = [dp[i-k] + abs(H[i]-H[i-k]) for k in range(1, min(i, K)+1)]
        dp[i] = min(obj)

print(dp[-1])

### FIXED CODE ###

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

dp = [0 for _ in range(N)]

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

print(dp[-1])