Harryxun/stf_run huggingface dataset:
import sympy
N=int(input())
out=0
for i in range(1,N+1):
    out+=len(sympy.divisors(i))*i
print(out)

### FIXED CODE ###

N=int(input())
out=0
for X in range(1,N+1):
    Y=N//X
    out+=Y*(Y+1)*X/2
print(int(out))
sys.setrecursionlimit(10000)

class Graph:
    def __init__(self,n,side):
        self.side = side
        self.neighbor = [set() for i in range(n+1)]
        self.visited = [False]*(n+1)
        self.group =[0]*n
        self.product()
    def product(self):
        for a,b in self.side:
            self.neighbor[a].add(b)
            self.neighbor[b].add(a)
    def dfs(self,x,a):
        self.group[a] += 1
        self.visited[x] = True
        for i in self.neighbor[x]:
            if self.visited[i]:continue
            self.dfs(i,a)
    def all_dfs(self):
        a = 0
        for i in range(1,n+1):
            if not self.visited[i]:
                self.dfs(i,a)
                a += 1

n,m = map(int,input().split())
side = list(tuple(map(int,input().split()))for i in range(m))
graph1 = Graph(n,side)
graph1.all_dfs()
print((graph1.group))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)

class Graph:
    def __init__(self,n,side):
        self.side = side
        self.neighbor = [set() for i in range(n+1)]
        self.visited = [False]*(n+1)
        self.group =[0]*n
        self.product()
    def product(self):
        for a,b in self.side:
            self.neighbor[a].add(b)
            self.neighbor[b].add(a)
    def dfs(self,x,a):
        self.group[a] += 1
        self.visited[x] = True
        for i in self.neighbor[x]:
            if self.visited[i]:continue
            self.dfs(i,a)
    def all_dfs(self):
        a = 0
        for i in range(1,n+1):
            if not self.visited[i]:
                self.dfs(i,a)
                a += 1

n,m = map(int,input().split())
side = list(tuple(map(int,input().split()))for i in range(m))
graph1 = Graph(n,side)
graph1.all_dfs()
print(max(graph1.group))
print('YES' if len(set(input())==2 else 'NO')

### FIXED CODE ###

print("Yes" if len(set(input()))==2 else "No")
n=int(input())
*l,=map(int,input().split())
m=[0]*n
a=n*(n+1)//2
b=sum(l)

if b%a:
  print("NO")
else:
  k=b//a
  for i in range(n):
    m[i]=(l[(i+1)%n]-l[i]-k)

*o,=filter(lambda x:x<0 and x%n==0,m)
if len(o)==k:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

n=int(input())
*l,=map(int,input().split())
m=[0]*n
a=n*(n+1)//2
b=sum(l)

if b%a:
  print("NO")
else:
  k=b//a
  m=[l[(i+1)%n]-l[i]-k for i in range(n)]
  for i in range(n):
    if m[i]>0 or m[i]%n!=0:
      print("NO")
      break
  else:
    print("YES")
n = int(input())
ac,wa,tle,re = 0,0,0,0
for i in range(n):
    inp = input()
    if inp == 'AC':
        ac += 1
    elif inp == 'WA':
        wa += 1
    elif inp == 'TLE':
        tle += 1
    else :
        RE += 1



print('AC x {}\nWA x {}\nTLE x {}\nRE x {}'.format(ac,wa,tle,re))

### FIXED CODE ###

n = int(input())
ac,wa,tle,re = 0,0,0,0
for i in range(n):
    inp = input()
    if inp == 'AC':
        ac += 1
    elif inp == 'WA':
        wa += 1
    elif inp == 'TLE':
        tle += 1
    else:
        re += 1



print('AC x {}\nWA x {}\nTLE x {}\nRE x {}'.format(ac,wa,tle,re))
A, B, X = list(map(int,input().split()))
if A > X:
  print(A-X, B)
elif A <= x and B > X - A:
  print(0, B-(X-A))
elif A == 0 and B == 0:
  print(0,0)
else:
  print(0,0)

### FIXED CODE ###

A, B, X = list(map(int,input().split()))
if A > X:
  print(A-X, B)
elif A <= X and B > X - A:
  print(0, B-(X-A))
elif A == 0 and B == 0:
  print(0,0)
else:
  print(0,0)
# coding: utf-8

judge = input().split()

if int(judge[0] * judge[1]) % 2 == 1:
    print("Odd")
else:
    print("Even")

### FIXED CODE ###

# coding: utf-8

judge = input().split()

if (int(judge[0]) * int(judge[1])) % 2 == 1:
    print("Odd")
else:
    print("Even")
N = int(input())
l = list(map(int, input().split()))

cnt = 0
for i in range(1, N+1, 2):
  if l[i-1] % 2 != 0:
    cnt += 1

print(cnt)

### FIXED CODE ###

L, R, d = map(int, input().split())
  
cnt = 0
for i in range(L, R+1, 1):
  if i % d == 0:
    cnt += 1

print(cnt)
# ABC044
N, A = map(int, input().split())
X = list(map(int, input().split()))

# 2 ** 50 -> 全探索は厳しい -> DP
# dp[i][k][wa] = i枚まで見て、k枚選んだ時の合計値がwaとなるときの選び方の合計
# max wa = max(X) * N
max_wa = max(X) * N
if max_wa < A:
    print(0)
    exit()
dp = [[[0] * (max_wa+50) for _ in range(N+1)] for __ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for k in range(i+1):
        for wa in range(max_wa):
            # 選ぶとき
            dp[i+1][k+1][wa+X[i]] += dp[i][k][wa]
            # 選ばないとき
            dp[i+1][k][wa] += dp[i][k][wa]

ans = 0
for k in range(1, N+1):
    ans += dp[-1][k][k*A]

print(ans)

### FIXED CODE ###

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

# 2 ** 50 -> 全探索は厳しい -> DP
# dp[i][k][wa] = i枚まで見て、k枚選んだ時の合計値がwaとなるときの選び方の合計
# max wa = max(X) * N
max_wa = max(X) * N
dp = [[[0] * (max(X) * (N+1)) for _ in range(N+1)] for __ in range(N+1)]
dp[0][0][0] = 1
for i in range(N):
    for k in range(i+1):
        for wa in range(max_wa):
            # 選ぶとき
            dp[i+1][k+1][wa+X[i]] += dp[i][k][wa]
            # 選ばないとき
            dp[i+1][k][wa] += dp[i][k][wa]

ans = 0
for k in range(1, N+1):
    if k * A > max_wa:
        break
    ans += dp[-1][k][k*A]

print(ans)
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, S = iim()
    A = list(iim())
    mod = 998244353
    S1 = S + 1

    dp = [0] * (S+1)
    dp1 = dp[:]
    dp[0] = 1
    for ai in A:
        sa = S - ai
        for i in range(sa):
            dp1[i] = 2 * dp[i]
        for i in range(sa, S1):
            dp1[i] = 2 * dp[i] + dp[i-ai]
        dp, dp1 = dp1, dp

    print(dp[-1])


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N, S = iim()
    A = list(iim())
    mod = 998244353
    S1 = S + 1

    dp = [0] * (S+1)

    dp[0] = pow(2, N, mod)
    inv = pow(2, mod-2, mod)

    for ai in A:
        for i in range(S, ai-1, -1):
            dp[i] = (dp[i] + dp[i-ai]*inv) % mod

    print(dp[-1])


if __name__ == "__main__":
    resolve()
l = [input() for _ in range(2)]
S = l[1]
N = int(l[0])
count = 0

indexR = []
indexG = []
indexB = []

i = 0
j = 0
k = 0

for a in range(N):
    character = S[a:a+1]

    if character == 'R':
        indexR.append(a+1)
    elif character == 'G':
        indexG.append(a+1)
    elif character == 'B':
        indexB.append(a+1)

for r in indexR:
    for g in indexG:
        for b in indexB:
            mean = (max[r, g, b] + min[r, g, b])/2
            if mean != r and mean != g and mean != b:
                count = count + 1
print(count)

### FIXED CODE ###

from collections import Counter

N = int(input())
S = input()
cnt = Counter(S)

ans = cnt['R']*cnt['G']*cnt['B']
#まずansに要請１を満たす(i, j, k)の組の数を入れておき，ここから，要請２を満たさないものを除いていく。

for i in range(N-2):
    for j in range(i+1, N-1):
        k = j + (j - i)
        #kは　j - i = k - j を満たす。ただし，（i, j, k）が要請１を満たしているとは限らない。
        if k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1

print(ans)
s=input()
k=int(input())
p=0

if s[0]==s[-1]:
  p+=1

l=[1]
for i in range(len(s)-1):
  if s[i]!=s[i+1]:
    l.append(1)
  else:
    l[-1]+=1
x=[i//2 for i in l]
y=sum(x)
if s[-1]==s[-2]:
  print((y-1)*k+p*k)
else:
  print(y*k+p*(k-1))



### FIXED CODE ###

s=input()
k=int(input())
p=0
if s[0]==s[-1]:
  p+=1

if len(s)==1:
  print(k//2)
else:
  l=[1]
  for i in range(len(s)-1):
    if s[i]!=s[i+1]:
      l.append(1)
    else:
      l[-1]+=1
  x=[i//2 for i in l]
  y=sum(x)
  if len(l)>1:
    if s[0]==s[-1]:
      if (l[0]+l[-1])%2==1:
        print(y*k)
      else:
        print(y*k+p*(k-1))
    else:
      print(y*k+p*(k-1))
  else:
    print((len(s)*k)//2)
A,B = map(int,input().split())

if A == B:
    print("EQUAL")
elif A < B:
    print("LESS")
else:
    print("GREATER")

### FIXED CODE ###

A = int(input())
B = int(input())

if A == B:
    print("EQUAL")
elif A < B:
    print("LESS")
else:
    print("GREATER")
import numpy as np
import math
H,N = (int(x) for x in input().split())
A = np.array([0]*N)
B = np.array([0]*N)
C = np.array([0.]*N)
for i in range(N):
    A[i],B[i] = (int(x) for x in input().split())
    C[i] = float(A[i]) / float(B[i])

indexs = np.argsort(-C)
A=A[indexs]
B=B[indexs]
C=C[indexs]

V=[[0]*(H+1) for i in range(N+1)]
for h in range(H+1):
    V[0][h] = B[0]*math.ceil(h/A[0])

for i  in range(N):
    for h in range(H+1):
        if h < A[i]:
            V[i+1][h] = V[i][h]
        elif V[i][h] > (V[i][h-A[i]]+B[i]):
            V[i+1][h] = (V[i][h-A[i]]+B[i])
        else:
            V[i+1][h] = V[i][h]

print(V[N][H])

### FIXED CODE ###

import math

H,A = (float(x) for x in input().split())
print(math.ceil(H/A))
n = int(input())
a_list = list(map(int, input().split()))

co = a_list.copy()
if 0 in co:
    co.remove(0)
co.sort()


if not len(co) % 2 == 0:
    print(0)
    quit()

for index in range(len(a_list))[:-1:2]:
    if not co[index] == co[index + 1]:
        print(0)
        quit()




print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))

### FIXED CODE ###

from math import factorial, floor
n = int(input())
a_list = list(map(int, input().split()))

co = a_list.copy()
if 0 in co:
    co.remove(0)
co.sort()


if not len(co) % 2 == 0:
    print(0)
    quit()

for index in range(len(a_list))[:-1:2]:
    if not co[index] == co[index + 1]:
        print(0)
        quit()


print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7))
s=input()
a=s**3
print(a)


### FIXED CODE ###

s=input()
a=s**3
print(a)
words = input()
ans = 'NO'

for word in words:
  if words.count(word) %2 != 0:
    breake
  else:
    ans = ('YES')
    
print(ans)

### FIXED CODE ###

words = input()
ans = 'No'
for word in words:
  if words.count(word) %2 != 0:
    break
else:
  ans ='Yes'  
print(ans)
H,N = map(int,input().split())

AB = []

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

dp = [1e9]*(H+3)

for i in range(H+1):
    dp[i] = min(dp[i-a]+b for a,b in AB)
    
print(min(dp[H-1:]))

### FIXED CODE ###

H,N = map(int,input().split())
AB = [list(map(int, input().split())) for i in range(N)]

M = max(a for a,b in AB)

dp = [0]*(H+M)

for i in range(1,H+M):
    dp[i] = min(dp[i-a]+b for a,b in AB)
    
print(min(dp[H:]))
S = int(input().split('/'))

print("2018/"+S[1]+'/'+S[2])


### FIXED CODE ###

S = (input().split('/'))

print("2018/"+S[1]+'/'+S[2])
import re
s=input()
m=0
for i in range(len(s)/2):
  dst = re.sub(r'01|10', "", s)
  if dst == s:
    break
  m += len(s) - len(dst)
  s=dst
print(m)

### FIXED CODE ###

s=input();print(min(s.count("0"), s.count("1"))*2)
T = int(input())
a = []
for i in range(T):
    a.append(list(map(int, input().split())))
for r in a:
    s, b, c, d = r[0], r[1], r[2], r[3]
    mod_list = []
    if (s < b) or (b>d):
        print('No')
        break
    if (c>b):
        print('Yes')
        break
    while True:
        s = s%b
        if s > c:
            print('No')
            break
        s += d
        if s in mod_list:
            print('Yes')
            break
        mod_list.append(s)

### FIXED CODE ###

N = map(int, input())
a = list(map(int, input().split()))
all_set = set(range(1, 10000))

use_set = list(set(all_set - set(a)))

count = 0
for i in range(len(a)-1):
    if a[i] == a[i+1]:
        a[i+1] = use_set[0]
        use_set = use_set[1:]
        count += 1
    
print(count)
N = int(input())
A = list(map(int, input().split()))
B = 0
i = 1
while i <= N:
    if A[i] > A[i-1]:
        B += A[i] - A[i-1]
        A[i] = A[i-1]
print(B)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = 0
i = 1
while i < N:
    if A[i] - A[i-1] < 0:
        B += A[i-1] - A[i]
        A[i] = A[i-1]
    i += 1
print(B)
if __name__ == "__main__":
    N,K = input().split()
    D = input().split()
    num = set([str(i) for i in range(10)])
    
    diff = num^set(D)
    print(diff)
    ans = N
    while True:
        strN = set(list(ans))
        if strN - diff:
            ans += 1
        else:
            break
    print(ans)

### FIXED CODE ###


def main():
    N, K = input().split(" ")

    D = list(input().split(" "))
    use_num = list(set([str(i) for i in range(10)]) - set(D))

    N = int(N)
    i = N
    while True:

        if not set(str(i)) <= set(use_num) and i >= N:
            i += 1
        else:
            print(i)
            break

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

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def solve(positions, s, t):
    # print('{}, s = {}, t = {}'.format(positions, s, t))
    if len(t) == 0:
        return 0

    if len(positions[t[0]]) == 0:
        return -1

    i = 0
    j = 0
    while i < len(s) and j < len(t):
        candidates = positions[t[j]]
        if len(candidates) == 0:
            break
        pos = bisect.bisect_left(candidates, i)
        if pos == len(candidates):
            break

        i = candidates[pos] + 1
        j += 1

    if j == len(t):
        return i
    else:
        rest = solve(positions, s, t[j:])
        return len(s) + rest if rest != -1 else -1


def main():
    s = input()
    t = input()

    positions = defaultdict(list)
    for i in range(len(s)):
        positions[s[i]].append(i)

    print(solve(positions, s, t))


if __name__ == '__main__':
    main()


### FIXED CODE ###

#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def solve(positions, s, t):

    if not set(t) <= set(s):
        return -1

    loop = 0
    prev = -1

    for tchar in t:
        candidates = positions[tchar]
        pos = bisect.bisect_right(candidates, prev)

        if pos == len(candidates):
            loop += 1
            pos = 0
        prev = candidates[pos]

    return loop * len(s) + prev + 1


def main():
    s = input()
    t = input()

    positions = defaultdict(list)
    for i in range(len(s)):
        positions[s[i]].append(i)

    print(solve(positions, s, t))


if __name__ == '__main__':
    main()
import math
from functools import reduce

N, M = map(int, input().split())
alist = list(map(lambda k: int(k) // 2, input().split()))

numdic = {}

def lcm(x, y):
    return (x * y) // math.gcd(x,y)

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

lcmnum = lcm_list(alist)

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)


### FIXED CODE ###

from fractions import gcd
from functools import reduce
import sys

N, M = map(int, input().split())
alist = list(map(lambda k: int(k) // 2, input().split()))

numdic = {}

def lcm(x, y):
    return (x * y) // gcd(x,y)

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

lcmnum = lcm_list(alist)

for i in alist:
    if (lcmnum//i)%2==0:
        print(0)
        sys.exit()

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)
#-*- coding:utf-8 -*-
x,a,b= int(input())

print((x-a)-b*((x-a)//b))

### FIXED CODE ###

#-*- coding:utf-8 -*-
x = int(input())
a = int(input())
b = int(input())

print((x-a)-b*((x-a)//b))
a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
d=0
for i in range(a):
  while d<b:
    d=d+b[i]
  print(d)
  break

### FIXED CODE ###

a,b=input().split()
a=int(a)
b=int(b)
c=list(map(int,input().split()))
d=0
e=0
for i in range(a):
  if d+c[i]<=b:
    d=d+c[i]
    e=e+1
  else:
    break
print(e+1)
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m = map(int, input().split())
d = factor(m)

def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr
M = 10**9+7 # 出力の制限
N = max(d.values())+10+n # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M

ans = 1
for v in d.values():
    ans *= cmb(v+n-1, n-1, M)
    ans %= M
print(ans)

### 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,m = map(int, input().split())

def factor(n, m=None):
    # mを与えると、高々その素因数まで見て、残りは分解せずにそのまま出力する
    arr = {}
    temp = n
    M = int(-(-n**0.5//1))+1
    if m is not None:
        M = min(m+1, M)
    for i in range(2, M):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr

d = factor(m)

M = 10**9+7 # 出力の制限
N = max(d.values())+10+n # 必要なテーブルサイズ

g1 = [None] * (N+1) # 元テーブル
g2 = [None] * (N+1) #逆元テーブル
inverse = [None] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M

if m!=1:
    ans = 1
    for v in d.values():
        ans *= cmb(v+n-1, n-1, M)
        ans %= M
else:
    ans = 1
print(ans%M)
str1 = raw_input() print "".join(reversed(str1))

### FIXED CODE ###

str1 = raw_input() 
print "".join(reversed(str1))
def sigma(c):
    if c == 1:
        return 1
    elif c == 0:
        return 0
    else:
        return c + sigma(c-1)
      
      
      
n = int(input())
sn = {}
sn_list = []
for i in range(n):
    s = "".join(sorted(input()))
    sn_list.append(s)
for s in sn_list:
    if not(s in sn):
        sn[s] = 0
    else:
        sn[s] += 1
        
        
count = 0
for v in sn.values():
    count += sigma(v)
print(count)

### FIXED CODE ###

def main():
    n = int(input())
    array_s = []
    array = []
    for i in range(n):
        array_s.append(input())
 
    for s in array_s:
        array.append(''.join(sorted(s)))
    array = sorted(array)
    ans = 0
    count = 1
    for i in range(n-1):
        if array[i] == array[i+1]:
            count += 1
            if i != n-2:
                continue
        ans += int(count*(count-1)/2)
        count = 1
    print(ans)
 
 
if __name__ == '__main__':
    main()
import sys

def main(argv):
 #L = int(argv.pop())
 #tree = [int(s) for s in argv]
 n = argv[1]
 if n%2 == 0:
    print(n/2)
 else:
    print(n/2+1)

if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

s = input().strip()
s = int(s)

if s%2 == 0:
    print(int(s/2))
else:
    print(int(s/2)+1)
def cub():
    x = raw_input("Input number >")
   return x ** 3

### FIXED CODE ###


def cub():
   x = input()
   print x **3

cub()
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
a,b  = ma()
x = lma()
ans = 10 **18
for i in range(a-b+1):
    a0 = x[i]
    ab = x[i+b-1]
    if ab< 0 :
        ans = min(ans,ab)
    elif a0 <=0 and 0 <= ab:
        ans = min(ans, ab-2*a0, 2*ab-a0)
    else:
        ans = min(ans,ab)
print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
if k%2==1:print((n//k)**3)
elif k%2==0:print((n//k)**3 + (n//(k//2) - n//k)**3 )
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]

d_1 = []
for i in range(1, n+2):
  d_1.append(abs(a[i]-a[i-1]))
d_2 = []
for i in range(1, n+1):
  d_2.append(abs(a[i+1]-a[i-1]))

s_d = sum(d_1)
for i in range(1, n+1):
  print(s_d - d_1[i] - d_1[i+1] + d_2[i])

### FIXED CODE ###

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

d_1 = []
for i in range(1, n+2):
  d_1.append(abs(a[i]-a[i-1]))
d_2 = []
for i in range(1, n+1):
  d_2.append(abs(a[i+1]-a[i-1]))

s_d = sum(d_1)
for i in range(1, n+1):
  print(s_d - d_1[i-1] - d_1[i] + d_2[i-1])
a = input()
b = input()
c = input()
d = input()

ab = a - b
bc = b - c
ac = a - c

if a <= b <= c <= or  c < b < a:
  if ab <= d and bc <= d or ac <= d:
      print("Yes")
  else:
      print("No")
else:
  if ac <= d:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

a, b, c, d = map(int, input().split())

if abs(a-b) <= d and abs(b-c) <= d or abs(a-c) <= d:
    print('Yes')
else:
    print('No')
a,b = map(int,input().split())
for i in range (1,1000):
  n = i(i+1)//2
  if b - a == i:
    print(n-a)
  

### FIXED CODE ###

a,b = map(int,input().split())
n = b-a
tower = ((n+1)*n)/2
print(int(tower-b))
from itertools import product
 
def gcb(a, b):
    if b == 0:
        gcb_table[a][b] = a
    else:
        if gcb_table[a][b] == -1:
            gcb_table[a][b] = gcb(b, a%b)
    return gcb_table[a][b]

def gcb_3(a, b, c):
    return gcb(gcb(a, b), gcb(b, c))
  
k = int(input())
gcb_table = [[-1 for _ in range(k+1)] for _ in range(k+1)]

for i in range(1, k+1):
    for j in range(1, k+1):
        temp = gcb(i, j)
        gcb_table[i][j] = temp
        gcb_table[j][i] = temp
        
res = 0
l_k = range(1, k+1)
for part in itertools.product(l_k, l_k, l_k):
    gcb_first = gcb_table[part[0]][part[1]]
    res += gcb_table[gcb_first][part[2]]
print(res)

### FIXED CODE ###

def gcb(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        gcb_table[a][b] = a
    else:
        if gcb_table[a][b] == -1:
            gcb_table[a][b] = gcb(b, a%b)
    return gcb_table[a][b]

k = int(input())
gcb_table = [[-1 for _ in range(k+1)] for _ in range(k+1)]

for i in range(1, k+1):
    for j in range(1, k+1):
        temp = gcb(i, j)
        gcb_table[i][j] = temp
        gcb_table[j][i] = temp
        
res = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        gcb_first = gcb_table[a][b]
        for c in range(1, k+1):
            res += gcb_table[gcb_first][c]
print(res)
def base_N(N,n,n_N):#N進数に変換
    if n==0:
        return int(n_N[::-1])
    else:
        n_N+=str(n%N)
        n=n//N
        return base_N(N,n,n_N)
"""
def base_N_10(N,n):#N進数を10進数に変換
    n_10=0
    for i in range(len(str(n))):
        n_10+=int(str(n)[i])*N**(len(str(n))-i-1)
    return n_10
"""


n,k=map(int,input().split())
dislike=list(map(int,input().split()))

usable=[i for i in range(10)]
for number in dislike:
    usable.remove(number)

N=len(usable)
M=0
bit=''
num_s=''    
num_i=0



while 1:
    M+=1
    bit=str(base_N(N,M,''))
    for i in range(len(bit)):
        num_s+=str(usable[int(bit[i])])
    num_i=int(num_s)
    if num_i>=n:
        print(num_i)
        exit()
    else:
        num_s=''
        bit=0
        num_i=0

### FIXED CODE ###

n,k=map(int,input().split())
dislike=list(map(int,input().split()))


while 1:
    for i in range(len(str(n))):
        if int(str(n)[i]) in dislike:
            break
        if i==len(str(n))-1:
            print(n)
            exit()
    n+=1