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

S = str(input())
N = len(S)
mod = 10 ** 9 + 7

dp = [[0 for _ in range(13)] for _ in range(N)]
if S[0] == '?':
    for j in range(10):
        dp[0][j] = 1
else:
    dp[0][int(S[0])] = 1
for i in range(1, N):
    if S[i] == '?':
        for s in range(0, 10):
            for j in range(0, 13):
                for k in range(0, 13):
                    if (10 * k + s) % 13 == j:
                        dp[i][j] += dp[i - 1][k]
    else:
        s = int(S[i])
        for j in range(0, 13):
            for k in range(0, 13):
                if (10 * k + s) % 13 == j:
                    dp[i][j] += dp[i-1][k]

    for j in range(13):
        dp[i][j] %= mod

print(dp[N-1][5])

### FIXED CODE ###

from collections import defaultdict
S = str(input())
N = len(S)
mod = 10 ** 9 + 7

dp = [[0 for _ in range(13)] for _ in range(N)]
if S[0] == '?':
    for j in range(10):
        dp[0][j] = 1
else:
    dp[0][int(S[0])] = 1

residualDict = defaultdict(list)
for s in range(0, 10):
    for j in range(0, 13):
        for k in range(0, 13):
            if (10 * k + s) % 13 == j:
                residualDict[s].append([j, k])

for i in range(1, N):
    if S[i] == '?':
        for s in range(0, 10):
            tmpList = residualDict[s]
            for j, k in tmpList:
                dp[i][j] += dp[i - 1][k]
    else:
        s = int(S[i])
        tmpList = residualDict[s]
        for j, k in tmpList:
            dp[i][j] += dp[i-1][k]

    for j in range(13):
        dp[i][j] %= mod

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

s = input()
Q = int(input())
query = list(list(input().split()) for _ in range(Q))
mode = 1
for q in query:
    if len(q)==1:
        mode *= -1
    else:
        f,c = q[1], q[2]
        if (mode>0 and f=='1') or (mode<0 and f=='2'):
            s = '{}{}'.format(c,s)
        else:
            s = '{}{}'.format(s,c)
print(s if mode>0 else s[::-1])

### FIXED CODE ###

from collections import deque
s = input()
Q = int(input())
s = deque([s])
rev = 1
for i in range(Q):
    tmp = list(input().split())
    if len(tmp)==1:
        rev *= -1
    else:
        f,c = tmp[1], tmp[2]
        if rev > 0:
            if f=='1':
                s.appendleft(c)
            else:
                s.append(c)
        else:
            if f=='1':
                s.append(c)
            else:
                s.appendleft(c)
s = ''.join(list(s))
print(s if rev > 0 else s[::-1])
### BUGGY CODE ###

H = int(input())
m = 1
at = 0
while True:
    at += m
    H //= 2
    m *= 2
    if H == 1:
        at += m
        print(at)
        exit()


### FIXED CODE ###

H = int(input())
m = 1
at = 0
for i in range(H):
    if H == 1:
        at += m
        print(at)
        exit()
    at += m
    H //= 2
    m *= 2
### BUGGY CODE ###

import numpy as np
N,W=list(map(int,input().split()))
DP=np.arange((N+1)*(W+1)).reshape(N+1,W+1)
DP=np.zeros_like(DP,dtype=float)
sumv=float(0)
for i in range(1,N+1):
    w,v=list(map(int,input().split()))
    sumv+=v
    for j in range(W+1):
        if j-w>=0:
            DP[i][j]=max(DP[i-1][j],DP[i-1][j-w]+v)
            if DP[i][j]==sumv:
                DP[i][j:]=DP[i][j]
                break
        else:
            DP[i][j]=max(DP[i-1][j],DP[i][j-1])
print(int(DP[-1][-1]))
# for i in DP:
#     print(i)


### FIXED CODE ###

import numpy as np
N,W=list(map(int,input().split()))
DP=np.zeros(W+1)

for i in range(N):
    w,v=list(map(int,input().split()))
    a=DP[:-w]+v
    b=DP[w:]
    c=np.maximum(a,b)
    DP[w:]=c



print(int(DP[-1]))
# for i in DP:
#     print(i)
### BUGGY CODE ###

N, M = map(int,input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]
li = []
cnt = 0
for b, c in sorted(BC, key=lambda x:x[1], reverse=True):
  cnt += b
  for _ in range(b):
    li.append(c)
for i in range(min(N,cnt)):
  if A[i] < li[i]:
    A[i] = li[i]
print(sum(A))

### FIXED CODE ###

N, M = map(int,input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]
li = []
cnt = 0
for b, c in sorted(BC, key=lambda x:x[1], reverse=True):
  cnt += b
  for _ in range(b):
    li.append(c)
  if cnt >= N:
    break
for i in range(min(N,cnt)):
  if A[i] < li[i]:
    A[i] = li[i]
print(sum(A))
### BUGGY CODE ###

import bisect

A, B, Q = map(int,input().split())
INF = float("inf")
s = [-1*INF]
t = [-1*INF]
for _ in range(A):
    s.append(int(input()))
s.append(INF)
for _ in range(B):
    t.append(int(input()))
t.append(INF)
for _ in range(Q):
    x = int(input())
    s_index = bisect.bisect_left(s,x)
    t_index = bisect.bisect_left(t,x)
    s_l = x - s[s_index-1]
    s_r = s[s_index] - x
    t_l = x - t[t_index-1]
    t_r = t[t_index] - x
    print(min(max(s_l,t_l), s_l + t_r*2, s_r + t_l*2, s_l*2 + t_r, s_r*2 + t_l, max(s_r,t_r)))

### FIXED CODE ###

from bisect import bisect_left
A, B, Q = map(int,input().split())
INF = 2 * 10 ** 10
S = [-INF]
T = [-INF]
for _ in range(A):
    S.append(int(input()))
S.append(INF)
for _ in range(B):
    T.append(int(input()))
T.append(INF)
for _ in range(Q):
    x = int(input())
    s = bisect_left(S, x)
    t = bisect_left(T, x)
    ans = min(max(S[s], T[t]) - x, x - min(S[s-1], T[t-1]), 2 * S[s] - T[t-1] - x, 2 * T[t] - S[s-1] - x, T[t] + x - 2 * S[s-1], S[s] + x - 2 * T[t-1])
    print(ans)
### BUGGY CODE ###

import sys

MAX = 1000000


def digit_sum(n, b):
    if n == 0:
        return 0
    else:
        return digit_sum(n // b, b) + n % b


if __name__ == '__main__':
    n = int(input())
    s = int(input())

    if n < s:
        print(-1)
        sys.exit()

    ans = -1

    for b in range(2, max(n + 1, MAX) + 1):
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    if not ans == -1:
        print(ans)
        sys.exit()

    if n + 1 <= MAX:
        print(-1)
        sys.exit()

    for p in reversed(range(MAX)):
        if (n - s) % p != 0:
            continue
        b = (n - s) / p + 1
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    print(ans)


### FIXED CODE ###

import sys

MAX = 1000000


def digit_sum(n, b):
    if n == 0:
        return 0
    else:
        return digit_sum(n // b, b) + n % b


def main():
    n = int(input())
    s = int(input())

    if n < s:
        print(-1)
        sys.exit()

    ans = -1

    for b in range(2, min(n + 1, MAX) + 1):
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    if ans != -1:
        print(ans)
        sys.exit()

    if n + 1 <= MAX:
        print(-1)
        sys.exit()

    for p in reversed(range(1, MAX)):
        if (n - s) % p != 0:
            continue
        b = (n - s) // p + 1
        if b < 2:
            continue
        sm = digit_sum(n, b)
        if sm == s:
            ans = b
            break

    if ans != -1:
        print(ans)
        sys.exit()

    if n == s:
        print(n+1)
        sys.exit()

    print(-1)


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

S=input()
K=int(input())
K-=1
D={}
for s in range(len(S)):
    for e in range(s,len(S)):
        D[S[s:e+1]]=1
        #print(S[s:e+1])
D=list(D)
D.sort()
print(D[K])

### FIXED CODE ###

s = input()
K =input()

list1=[]
for i in range(len(s)):
    if s[0:i].count(s[i])==0:
        list1.append(s[i])
        i +=1
    else:
        i+=1

i=0
for i in range(len(s)):
    if s[i:i+2] not in list1:
        list1.append(s[i:i+2])
    else:
        i+=1
i=0
for i in range(len(s)):
    if s[i:i+3] not in list1:
        list1.append(s[i:i+3])
    else:
        i+=1
i=0
for i in range(len(s)):
    if s[i:i+4] not in list1:
        list1.append(s[i:i+4])
    else:
        i+=1
i=0
for i in range(len(s)):
    if s[i:i+5] not in list1:
        list1.append(s[i:i+5])
    else:
        i+=1

list1=sorted(list1)
print(list1[int(K)-1])
### BUGGY CODE ###

import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)

for i in range(M):
    B, C = map(int, input().split())
    for b in range(B):
        tmp = heapq.heappop(A)
        if tmp < C:
            heapq.heappush(A, C)
        else:
            heapq.heappush(A, tmp)
            continue

print(sum(A))

### FIXED CODE ###

from collections import Counter
n, m = map(int, input().split())
a = Counter(list(map(int, input().split())))

for i in range(m):
    b, c = map(int, input().split())
    a[c] += b

num = sorted(a.items(), key=lambda x: x[0], reverse=True)
ans = 0

for key, val in num:
    if n > val:
        ans += key * val
        n -= val
    else:
        ans += key * n
        break

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

import sys
input = sys.stdin.readline
a,b = map(int, input().split())

cnt = 1
while True:
  if b<= 1:
    cnt = 0
  elif b <= (a-1)*cnt+1:
    break
  cnt += 1
  
print(cnt)

### FIXED CODE ###

import sys
input = sys.stdin.readline
a,b = map(int, input().split())

cnt = 1
while True:
  if b<= 1:
    cnt = 0
    break
  elif b <= (a-1)*cnt+1:
    break
  cnt += 1
  
print(cnt)
### BUGGY CODE ###

import collections
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N-1+M)]

G = [set() for i in range(N)]
count = [0]*N
for a, b in(AB):
    a -= 1
    b -= 1
    G[a].add(b)
    count[b] += 1
root = 0
for i in range(N):
    if count[i] == 0:
        root = i
        break
level = [-1]*N
parent = [0]*(N)

q = collections.deque()
q.append((root, 0))
while(q):
    x, l = q.popleft()
    for y in G[x]:
        if level[y] < level[x]+1:
            level[y] = l+1
            parent[y] = x+1
            q.append((y, l+1))


for i in range(N):
    print(parent[i])


### FIXED CODE ###

def main():
    import networkx as nx
    import sys
    input = sys.stdin.buffer.readline
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for i in range(N-1+M)]
    DG = nx.DiGraph(AB)

    G = [set() for i in range(N)]
    for a, b in AB:
        a -= 1
        b -= 1
        G[a].add(b)

    DG = list(nx.topological_sort(DG))

    parent = [0]*N
    for i, x in enumerate(DG):
        x -= 1
        if i == 0:
            parent[x] = 0
        for y in G[x]:
            parent[y] = x+1
    print(*parent, sep='\n')


main()
### BUGGY CODE ###

import numpy as np
n=int(input())
a=list(map(int,input().split()))
a1=[]
a2=[]
for i in range(n):
  a1.append(i-a[i])
for i in range(n):
  a2.append(i+a[i])
count=0
p=0
q=1
for k in range(int(n*(n-1)/2)):
  if a1[q]==a2[p]:
    count+=1
  p+=1
  if p==q:
    p=0
    q+=1
print(count)

### FIXED CODE ###

from collections import Counter
n=int(input())
alist=list(map(int,input().split()))
a1=[]
a2=[]
for i,a in enumerate(alist):
  a2.append(i-a)
  a1.append(i+a)
aa=Counter(a2)
count=0
for k in a1:
  count+=aa.get(k,0)
print(count)
### BUGGY CODE ###

import re
s=input()
s=s.replace('01','10')
cnt=0
while re.subn('10','',s)[1]!=0:
  t=re.subn('10','',s)
  s=t[0].replace('01','10')
  cnt+=t[1]
print(int(cnt*2))

### FIXED CODE ###

s = input()
print(int(2*min(s.count('0'),s.count('1'))))
### BUGGY CODE ###

h, w, k = map(int, input().split())
SS = [list(input()) for _ in range(h)]
num = 1
ans = [[0] * w for _ in range(h)]

for i in range(h):
    S = SS[i]

    if S != ['.'] * w:
        for j in range(w):
            s = S[j]
            if s == '#':
                ans[i][j] = num
                if j != w - 1:
                    if '#' in S[j + 1:]:
                        num += 1
            else:
                ans[i][j] = num
        num += 1
    else:
        if i != h - 1:
            for j in range(w):
                ans[i][j] = ans[i + 1][j]
        else:
            for j in range(w):
                ans[i][j] = ans[i - 1][j]
        continue
flag = False
while True:
    if flag is True:
        break
    alll = []
    for i in range(h):
        alll += ans[i]
    if 0 not in alll:
        flag = True
    for i in range(h):
        S = SS[i]
        if S == ['.'] * w:
            if i != h - 1:
                for j in range(w):
                    ans[i][j] = ans[i + 1][j]
            else:
                for j in range(w):
                    ans[i][j] = ans[i - 1][j]


for a in ans:
    a = list(map(str, a))
    print(' '.join(a))


### FIXED CODE ###

h, w, k = map(int, input().split())
SS = [list(input()) for _ in range(h)]
num = 1
ans = [[0] * w for _ in range(h)]

for i in range(h):
    S = SS[i]

    if S != ['.'] * w:
        for j in range(w):
            s = S[j]
            if s == '#':
                ans[i][j] = num
                if j != w - 1:
                    if '#' in S[j + 1:]:
                        num += 1
            else:
                ans[i][j] = num
        num += 1

cnt = 1

for num, a in enumerate(ans):
    if a == [0] * w:
        cnt += 1
        continue
    else:
        for i in range(cnt):
            a = list(map(str, a))
            print(' '.join(a))
        cnt = 1

cnt1 = 0
if cnt != 1:
    p = []
    ans = ans[::-1]
    for i in range(h):
        b = ans[i]
        if b == [0] * w:
            cnt1 += 1
        else:
            for j in range(cnt1):
                b = list(map(str, b))
                print(' '.join(b))
            exit()
### BUGGY CODE ###

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

B = [i+1 for i in range(N)]
d = dict(zip(A, B))
s = ''
for i in range(N):
    s = s + str(d[i+1]) + ' '
print(s)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = [0]*N
for i in range(N):
    B[A[i]-1] = i+1
print(' '.join(map(str, B)))
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
b = 0
import math
for i in range(N):
  if A[i] > 0 and ans >0:
    if math.log10(A[i])+math.log10(ans)>18:
    
      ans = -1
      b = 1
    else:
      ans *= A[i]
  else:
    ans *= A[i]

if ans == 0:
  print(ans)
elif b == 1:
  print(-1)
elif ans>10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
n0 = A.count(0)
n1 = A.count(1)
import math
ans = 1
if N-n0-n1>60:
  ans = -1
for i in range(N):
  if A[i] == 0 or ans == 0:
    ans = 0
    break
  elif ans <0:
    ans = -1
  elif math.log10(A[i])+math.log10(ans)>18:
    ans = -1
    b = 1
  else:
    ans *= A[i]

if ans == 0:
  print(0)
elif ans < 0:
  print(-1)
elif ans>10**18:
  print(-1)
else:
  print(ans)
### BUGGY CODE ###

import collections as c

n = int(input())

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

q = int(input())

s = sum(a)

cnt = c.Counter(a)

for i in range(100000):
    cnt[i] = a.count(i+1)

for i in range(q):
    b,c = map(int,input().split())
    s += (c-b)*cnt[b-1]
    cnt[c-1] += cnt[b-1]
    cnt[b-1] = 0
    print(s)

### FIXED CODE ###

import collections as c

n = int(input())

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

q = int(input())

s = sum(a)

cnt = c.Counter(a)

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

import sys
n = int(input())

for i in range(1, 3501):
    for j in range(1, 3501):
        x = 4*i*j-n*i-n*j
        if x > 0:
            if (n*i*j)%x == 0:
                print(i, j, n*i*j//x)
                sys.exit()

### FIXED CODE ###

import sys
n = int(input())

for i in range(1, 3501):
    for j in range(1, 3501):
        if 4*i*j-n*i-n*j > 0:
            if (n*i*j)%(4*i*j-n*i-n*j) == 0:
                print(i, j, n*i*j//(4*i*j-n*i-n*j))
                sys.exit()
### BUGGY CODE ###

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

dp = [0] * N
dp [0] = 0

for j in range (1, N):
    dp_cost = dp[j-1] + abs(h[j]-h[j-1])
    for k in range (2, K+1- max(0,K-j)):
        dp_cost = min(dp_cost, dp[j-k] + abs(h[j]-h[j-k]))
    dp[j] = dp_cost
print(dp[N-1])

### FIXED CODE ###

import numpy as np
N, K= map(int,input().split())
h = list(map(int,input().split()))
 
dp = [0] * N
h = np.array(h)
 
dp = np.array([0]*N, dtype=np.int64)
 
for i in range (1, N):
    x = max(0, i - K)
    dp[i] = np.min(dp[x:i] + np.abs(h[i]-h[x:i]))
print(dp[N-1])
### BUGGY CODE ###

N = int(input())
s = [input() for i in range(N)]
L = list(set(s))
S = [s.count(j) for j in L]
M = max(S)
l = len(S)
A = [L[k] for k in range(l) if S[k] == M]
A.sort()
[print(m) for m in A]

### FIXED CODE ###

import collections
N = int(input())
l = [input() for i in range(N)]
L = collections.Counter(l)
a = L.most_common()
M = a[0][1]
A = [j[0] for j in a if j[1] == M]
[print(k) for k in sorted(A)]
### BUGGY CODE ###

l = list(map(int,input().split()))
n, k = l[0], l[1]
a = list(map(int,input().split()))

for i in range(k, n):
    bef, cur = 1, 1
    for ii in range(1, k+1):
        bef *= a[i-ii]

    for ii in range(k):
        cur *= a[i-ii]

    if cur > bef:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

l = list(map(int,input().split()))
n, k = l[0], l[1]
a = list(map(int,input().split()))

for i in range(k, n):
    if a[i] > a[i-k]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

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

for i in range(N-1):
    if H[i] - min(H[i+1:]) > 1:
        print("No")
        exit()

print("Yes")

### FIXED CODE ###

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

for i in range(N-1):
    if r_H[i+1] - r_H[i] > 1:
        print("No")
        exit()
    if r_H[i+1] - r_H[i] == 1:
        r_H[i+1] = r_H[i+1] - 1
print("Yes")
### BUGGY CODE ###

N,M = map(int,input().split())
import numpy as np
A = sorted(np.array(list(map(int,input().split()))),reverse=True)
bi = [0]*(A[0]+1)
for a in A:
  bi[a]+=1
  
cum = [0]*(A[0]+1)
for i in range(1,A[0]+1):
  cum[i]=cum[i-1]+bi[i]

cum_max=cum[-1]
left = 0
right = A[0]*2
while right-1!=left:
  x = (right+left)//2
  num = 0
  for a in A:
    b = max(x-a,1)
    if b<=A[0]:
      num += cum_max-cum[b-1]
    
  if num>M:
    left=x
  else:
    right=x
ans = 0
for a in A:
  b = max(left-a,1)
  c = cum_max-cum[b-1]
  M-=c
  ans+=(a*c)+(sum(A[:c]))
  if M<=0:
    break
  
ans+=(M*left)
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=True)
bi = [0]*(A[0]+1)
for a in A:
  bi[a]+=1
  
cum = [0]*(A[0]+1)
for i in range(1,A[0]+1):
  cum[i]=cum[i-1]+bi[i]

cum_max=cum[-1]
left = 0
right = A[0]*2+1
while right-1!=left:
  x = (right+left)//2
  num = 0
  for a in A:
    b = max(x-a,1)
    if b<=A[0]:
      num += cum_max-cum[b-1]
    
  if num>=M:
    left=x
  else:
    right=x

ans = 0
cum_A = [0]*(N+1)
for i in range(1,N+1):
  cum_A[i]=cum_A[i-1]+A[i-1]
for a in A:
  b = max(right-a,1)
  if b>A[0]:
    break
  c = cum_max-cum[b-1]
  M-=c
  ans+=(a*c)+cum_A[c]
  

ans+=M*left
print(ans)
### BUGGY CODE ###

import numpy as np

D,G = map(int, input().split())
P = []
C = []

for i in range(D):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

cnt = [0 for _ in range(D)]

ans = sum(P)
cnt_tar = 0

for i in range(D):
    tar = i

    ind_list = list(range(D))
    ind_list.remove(tar)
    ind_list = np.array(ind_list)

    P_part = np.array(P[:tar] + P[tar+1:])
    C_part = np.array(C[:tar] + C[tar+1:])

    cnt_part = np.zeros(D-1,dtype=int)#[0 for _ in range(D-1)]
    point_part = np.zeros(D-1,dtype=int)#[0 for _ in range(D-1)]

    bit_list = np.ones(D-1,dtype=int)
    point_part_max = np.sum(((ind_list+1) * 100 * P_part + C_part)*bit_list)

    for cnt_tar in range(P[tar]+1):
        point_base = cnt_tar*(tar+1)*100

        num_base   = cnt_tar + C[tar]*max(0,cnt_tar-P[tar] + 1)

        if point_base >= G or num_base >= ans:
            num = num_base
            ans = min(ans,num)
            break
        elif point_base + point_part_max >= G:

            for bit_seed in range(2**(D-1)):

                s_bit = (format(bit_seed, '#011b'))[::-1]
                bit_list = np.array(list(s_bit[:D-1]),dtype=int)

                cnt_part = P_part*bit_list
                point_part = cnt_part * (ind_list+1) * 100 + C_part*bit_list

                num = num_base + np.sum(cnt_part)
                point = point_base + np.sum(point_part)

                if point >= G:
                    ans = min(ans,num)

print(ans)


### FIXED CODE ###

import numpy as np

D,G = map(int, input().split())
P = []
C = []

for i in range(D):
    p,c = map(int,input().split())
    P.append(p)
    C.append(c)

cnt = np.zeros(D,dtype=int)
P = np.array(P)
C = np.array(C)

ans = sum(P)
cnt_tar = 0

ind_list = np.arange(D)

for bit_seed in range(2**D):

    s_bit = (format(bit_seed, '#016b'))[::-1]
    bit_list = np.array(list(s_bit[:D]),dtype=int)

    cnt = P*bit_list
    num_base = np.sum(cnt)

    point_base_array = (P * (ind_list+1) * 100 + C) * bit_list
    point_base = np.sum(point_base_array)
#    print(point_base_array)

    if point_base >= G:
        num = num_base
        ans = min(ans,num)
    elif num_base > ans:
        continue
    else:
        for i,bit in enumerate(bit_list):
            if bit == 0:
                tar = i

        point_max = point_base + P[tar]*(tar+1)*100 + C[tar]
        if point_max >= G:

            tar_min = (G-point_base) // ((tar+1)*100)
            point = point_base + P[tar]*(tar+1)*100*tar_min

            if point < G:
                tar_min += 1

            if tar_min < P[tar]:
                num = num_base + tar_min
            else:
                num = num_base + P[tar]
            ans = min(ans,num)

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

import sys
sys.setrecursionlimit(50000)
N,M=map(int,input().split())
L=[int(input()) for _ in range(M)]
ans=0

def dfs(i):
	global ans
	if i==N:
		ans+=1
		return True
	if i>N:return False
	if i in L:return True
	if dfs(i+1)==False:return True
	if dfs(i+2)==False:return True

dfs(0)
print(ans%1000000007) 

### FIXED CODE ###

N,M=map(int,input().split())
A=set([int(input()) for _ in range(M)])
dp=[0]*(N+1)
dp[0]=1
for i in range(1,N+1):
	dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
	if i in A:
		dp[i]=0
print(dp[N])
### BUGGY CODE ###

n = int(input())
d = list(int(i) for i in input().split())
m = int(input())
t = list(int(i) for i in input().split())
for i in t:
  if not i in d:
    print('NO')
    exit()
  d.remove(i)
print('YES')

### FIXED CODE ###

import collections
n = int(input())
d =list(int(i) for i in input().split())
m = int(input())
t =list(int(i) for i in input().split())
a = collections.deque(sorted(d))
b = collections.deque(sorted(t))


for i in range(n):
  if a[0] == b[0]:
    b.popleft()
  a.popleft()
  if len(b) == 0:
    print('YES')
    exit()
  elif len(a) == 0:
    break
print('NO')
### BUGGY CODE ###

def gcd(a,b,c):
    #1
    seq  = [a,b,c]
    seq.sort()
    while b > 0:
        r = c%b
        c = b
        b = r
    #2
    seq_2 = [a,c]
    seq_2.sort()
    while a > 0:
        r = c%a
        c = a
        a = r
    return c
    
from itertools import product

k = int(input())
ans=[]

i = range(1,k+1)
j = range(1,k+1)
k = range(1,k+1)

for a,b,c in product(i,j,k):
    p = gcd(a,b,c)
    ans.append(p)

print(sum(ans))

### FIXED CODE ###

def gcd(a,b,c):
    #1
    seq  = [a,b,c]
    seq.sort()
    while b > 0:
        r = c%b
        c = b
        b = r
    #2
    seq_2 = [a,c]
    seq_2.sort()
    while a > 0:
        r = c%a
        c = a
        a = r
    return c

from functools import reduce

k = int(input())
ans = 0

for i in range(1,k+1):
    for j in range(i,k+1):
        for k in range(j,k+1):
            t = len(set([i,j,k]))
            
            if t == 1:
                ans += gcd(i,j,k)
                
            elif t == 2:
                ans += gcd(i,j,k)*3
            
            elif t == 3:
                ans += gcd(i,j,k)*6
    

print(ans)