Problem:


Score : 300 points

Problem Statement

Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.

She is shopping, and now paying at the cashier.
Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).

However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.

Find the amount of money that she will hand to the cashier.

Constraints

 1 ≦ N < 10000

 1 ≦ K < 10

 0 ≦ D_1 < D_2 < … < D_K≦9

\{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}

Input

The input is given from Standard Input in the following format:

N K
D_1 D_2 … D_K

Output

Print the amount of money that Iroha will hand to the cashier.

Sample Input 1

1000 8
1 3 4 5 6 7 8 9

Sample Output 1

2000

She dislikes all digits except 0 and 2.

The smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.

Sample Input 2

9999 1
0

Sample Output 2

9999



Sample input:
1000 8
1 3 4 5 6 7 8 9


Sample output:
2000

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
memo = list(map(int,input().split()))

d = []
for i in range(10):
    if not(i in memo):
        d.append(i)

n_st = list(str(n))
n_st = list(map(int,n_st))

ans = []
flug = False
for i in range(len(n_st)-1,-1,-1):
    for j in range(len(d)+1):
        if j < len(d):
            if n_st[i] <= d[j]:
                ans.append(d[j])
                break
        elif j == len(d):
            ans.append(d[0])
            if i+1 <= len(n_st)-1:
                n_st[i+1] += 1
            else:
                flug = True

if (flug):
    ans.append(d[0])

ttl = 0
for i in range(len(ans)):
    ttl += ans[i]*(10**i)

print(ttl)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
price, count = list(map(int, input().split()))
hate_numbers = list(map(int, input().split()))

def is_ok(hates, price):
  for h in hates:
    if str(h) in list(str(price)):
      return False
  return True

for p in range(1, 10000):
  if is_ok(hate_numbers, p) is False:
    continue
  if p >= price:
    print(p)
    exit(0)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
D = input().split()
for i in range(N, 10001):
    tmp = list(str(i))
    for j in tmp:
        if j in D:
            break
        print("".join(tmp))
        exit(0)

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
D = list(input().split())

for i in range(n,10001):
    for s in str(i):
        if s in D:
            break
    else:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
n,k = map(int,input().split())
D = list(map(int,input().split()))

for i in range(n,10001):
    for s in str(i):
        if s in D:
            break
    else:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N,k = input().split()
D = list(input().split())
nums = ["0","1","2","3","4","5","6","7","8","9"]

for d in D:
    nums.remove(d)

flag = 1
for n in N:
    if n not in nums:
        flag = 0
        break

if flag:
    print(int(N))
else:
    cur = int(N)
    min_n = int(min(nums))
    if nums[0] == "0":
        min_n = int(nums[1])
    # print(min_n)
    while 1:
        flag = 1
        cur += min_n
        for n in str(cur):
            if n not in nums:
                flag = 0
                break
        # print(cur)
        if flag:
            break
    print(cur)

Submission status: Wrong Answer

Solution code:
N,k = input().split()
D = list(input().split())
nums = ["0","1","2","3","4","5","6","7","8","9"]

for d in D:
    nums.remove(d)

while 1:
    flag = True
    for n in N:
        if n not in nums:
            N = str(int(N)*2)
            flag = False
            break
    if flag:
        print(int(N))
        break

Submission status: Wrong Answer

Solution code:
N,k = input().split()
D = list(input().split())
nums = ["0","1","2","3","4","5","6","7","8","9"]

for d in D:
    nums.remove(d)

while 1:
    for n in N:
        if n not in nums:
            N = str(int(N)*2)
            break
    print(int(N))
    break

Submission status: Wrong Answer

Solution code:
N,k = input().split()
D = list(input().split())
nums = ["0","1","2","3","4","5","6","7","8","9"]

for d in D:
    nums.remove(d)

while 1:
    for n in N:
        if n not in nums:
            N = str(int(N)*2)
            continue
    print(int(N))
    break

Submission status: Wrong Answer

Solution code:
N,k = input().split()
D = list(input().split())
nums = ["0","1","2","3","4","5","6","7","8","9"]

for d in D:
    nums.remove(d)

while 1:
    for n in N:
        if n not in nums:
            N = str(int(N)*2)
    print(int(N))
    break

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split(' '))
    str_n = str(n)
    d = list(map(int, input().split(' ')))

    s = {0,1,2,3,4,5,6,7,8,9}
    set_d = set(d)
    set_num = s - set_d
    list_num = list(set_num)
    list_num.sort()
    result = []
    checker = 0
    for i in range(1, len(str_n)+1):
        if all(x < int(str_n[-i]) for x in list_num):
            checker = 1
            result.append(min(list_num))
        else:
            checker = 0
            counter = 1        
            j = list_num[0]
            while j < int(str_n[-i]):
                j = list_num[counter]
                counter += 1
            result.append(j)
    if checker:
        if list_num[0] == 0:
            result.append(list_num[1])
        else:
            result.append(list_num[0])
    print(''.join(map(str, result[::-1])))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n, k = map(int, input().split(' '))
    str_n = str(n)
    d = list(map(int, input().split(' ')))

    s = {0,1,2,3,4,5,6,7,8,9}
    set_d = set(d)
    set_num = s - set_d
    list_num = list(set_num)
    list_num.sort()
    result = []
    checker = 0
    for i in range(1, len(str_n)+1):
        if all(x < int(str_n[-i]) for x in list_num):
            checker = 1
            result.append(min(list_num))
        else:
            counter = 1        
            j = list_num[0]
            while j < int(str_n[-i]):
                j = list_num[counter]
                counter += 1
            result.append(j)
    if checker:
        if list_num[0] == 0:
            result.append(list_num[1])
        else:
            result.append(list_num[0])
    print(''.join(map(str, result[::-1])))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n, k = map(int, input().split())
d = set(map(int, input().split()))

nl = len(str(n))
li = [int(i) for i in list(str(n))]

km = 10 - k
res = []

dset = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
dl = list(dset.difference(d))

for i in range(nl):
    res.append(dl[0])

#print(dl)
#print(li)
#print(res)


def func(x, l, f):
    if l < nl:
        for i in range(km):
            if x[l] == dl[i]:
                res[l] = dl[i]
                f = 1
                #print(res)
                func(x, l + 1, f)
                break
            elif x[l] < dl[i]:
                res[l] = dl[i]
                f = 2
                break
            else:
                f = 0
        if f > 0:
            #print(f)
            return res
        elif l > 0:
            try:
                res[l - 1] = dl[dl.index(res[l - 1]) + 1]
                #print(f)
                return res
            except IndexError:
                pass
        else:
            pass
        for i in range(nl):
            res[i] = dl[0]
        if dl[0] == 0:
            res.insert(0, dl[1])
        else:
            res.insert(0, dl[0])
        #print(f)
        return res
    else:
        #print(f)
        return res


r = [str(i) for i in func(li, 0, 0)]
result = ''.join(r)
print(result)

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
li=list(map(int,input().split()))

N_keta=list(map(int,str(N)))

for n in range(10005):
  count=0
  for k in range(len(N_keta)):
    if N_keta[k] in li:
      count=1
      break
    
  if count==0:
    print(N)
    break
  else:
    N+=1
    N_keta=list(map(int,str(N)))

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
li=list(map(int,input().split()))

N_keta=list(map(int,str(N)))

for n in range(10000):
  count=0
  for k in range(len(N_keta)):
    if N_keta[k] in li:
      count=1
      break
    
  if count==0:
    print(N)
    break
  else:
    N+=1
    N_keta=list(map(int,str(N)))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())

l = set(input().split())

for i in range(N, 10000):
  if(len(l & set(str(i))) == 0):
    print(i)
    break

Submission status: Wrong Answer

Solution code:
n,k=map(int,input().split())
d = list((input().split()))

for i in range(n, 10000):
  r = [x for x in list(str(i))]
  if list(set(r)&set(d))==[]:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
import sys
n,k=map(int,input().split())
d = list((input().split()))

for i in range(n, 10000):
  r = [x for x in list(str(i))]
  if list(set(r)&set(d))==[]:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
# ABC042 C Iroha's Obsession
N,K = map(int,input().split())
D = tuple(map(str,input().split()))

is_iroha = True
for i in range(N,10000):
    S = str(i)
    is_iroha = True
    for s in S:
        if s in D:
            is_iroha = False
            break
    if is_iroha:
        print(S)
        exit()

print(0)

Submission status: Wrong Answer

Solution code:
# ABC042 C Iroha's Obsession
N,K = map(int,input().split())
D = tuple(map(str,input().split()))

is_iroha = True
for i in range(N,10000):
    S = str(i)
    is_iroha = True
    for s in S:
        if s in D:
            is_iroha = False
            break
    
    if is_iroha:
        print(S)
        exit()

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
l = input().split()
temp = str(n)
ans = 0
for i in range(len(temp)):
  if temp[i] in l:
    z = int(temp[i])
    while str(z) in l:
      z += 1
      z = z%10
    ans  += z * 10**(len(temp)-i-1)  
    
  else:
  	ans  += int(temp[i]) * 10**(len(temp)-i-1)#;print("Hey",ans)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
l = input().split()
temp = str(n)
ans = 0
for i in range(len(temp)):
  if temp[i] in l:
    z = int(temp[i])
    while str(z) in l:
      z += 1
      ans  += z * 10**(len(temp)-i-1)
     # print(z,ans)
  else:
  	ans  += int(temp[i]) * 10**(len(temp)-i-1)#;print("Hey",ans)
print(ans)

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
D = list(map(int, input().split()))

ans = list(str(N))

for i in range(len(ans)):
    for j in range(int(ans[i]), 10):
        if int(ans[i]) in D:
            ans[i] = str(j)
            continue
        break
print(''.join(ans))

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
D = list(map(int, input().split()))

ans = list(str(N))

for i in range(len(ans)):
    for j in range(1, 10):
        if int(ans[i]) in D:
            ans[i] = str(j)
            continue
        break
print(''.join(ans))

Submission status: Wrong Answer

Solution code:
import collections

n, k = map(int, input().split())
counter = collections.Counter(list(map(int, input().split())))
for i in range(n, 10000):
    ok = True
    x = i
    while x > 0:
        ok = counter[x % 10] == 0
        x //= 10
        if not ok:
            break
    if ok:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    n, k = map(int, input().split())
    d = list(map(int, input().split()))

    for i in range(n, 10000):
        for x in d:
            if str(x) in str(i):
                break
        else:
            print(i)
            exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, D: "List[int]"):
    ln = list(map(int, list(str(N))))
    c = 0

    for i in range(len(ln)):
        while(ln[i]%10 in D):
            ln[i] += 1
        # print(ln[i])
        if(i == 0):
            continue
        c = ln[i] // 10
        if(c > 0):
            c += ln[i-1]
            c = 0
            j = 0
            while(j in D):
                j += 1
            ln[i] = j
        else:    
            ln[i] = ln[i] % 10

    print(''.join(map(str, ln)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, D: "List[int]"):
    ln = list(map(int, list(str(N))))
    c = 0

    for i in range(len(ln)):
        while(ln[i]%10 in D):
            ln[i] += 1
        # print(ln[i])
        c = ln[i] // 10
        if(i > 0):
            c += ln[i-1]
            c = 0
        ln[i] = ln[i] % 10

    # if(c == 1):
    #     while(c%10 in D):
    #         c += 1
    #     ln = [c] + ln

    print(''.join(map(str, ln)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, D: "List[int]"):
    ln = list(map(int, list(str(N))))
    c = 0

    for i in reversed(range(len(ln))):
        ln[i] += c
        while(ln[i]%10 in D):
            ln[i] += 1
        c = ln[i] // 10
        ln[i] = ln[i] % 10

    if(c == 1):
        while(c%10 in D):
            c += 1
        ln = [c] + ln

    print(''.join(map(str, ln)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, D: "List[int]"):
    ln = list(map(int, list(str(N))))
    c = 0

    for i in reversed(range(len(ln))):
        ln[i] += c
        while(ln[i]%10 in D):
            ln[i] += 1
        c = ln[i] // 10
        ln[i] = ln[i] % 10

    if(c == 1):
        while(c in D):
            c += 1
        ln = [c] + ln

    print(''.join(map(str, ln)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, D: "List[int]"):
    ln = list(map(int, list(str(N))))
    c = 0

    for i in reversed(range(len(ln))):
        ln[i] += c
        while(ln[i] in D):
            ln[i] += 1
        c = ln[i] // 10
        ln[i] = ln[i] % 10

    if(c == 1):
        while(c in D):
            c += 1
        ln = [c] + ln

    print(''.join(map(str, ln)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, D: "List[int]"):
    ln = list(map(int, list(str(N))))
    c = 0

    for i in reversed(range(len(ln))):
        ln[i] += c
        while(ln[i] in D):
            ln[i] += 1
        c = ln[i] // 10
        ln[i] = ln[i] % 10

    if(c == 1):
        ln = [c] + ln

    print(''.join(map(str, ln)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, D: "List[int]"):
    ln = list(map(int, list(str(N))))
    c = 0

    for i in range(len(ln)-1,-1,-1):
        ln[i] += c
        while(ln[i] in D):
            ln[i] += 1
        c = ln[i] // 10
        ln[i] = ln[i] % 10

    if(c == 1):
        ln = [c] + ln

    print(''.join(map(str, ln)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, D: "List[int]"):
    ln = list(map(int, list(str(N))))
    c = 0

    for i in range(len(ln)-1,-1,-1):
        ln[i] += c
        while(ln[i] in D):
            ln[i] += 1
        c = ln[i] // 10
        ln[i] = ln[i] % 10

    if(c > 0):
        ln = [c] + ln

    print(''.join(map(str, ln)))

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    D = [int(next(tokens)) for _ in range(K)]  # type: "List[int]"
    solve(N, K, D)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
D = set(input().split())

for i in range(N,10000):
    if set(str(i)) & D == set():
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
D = list(input().split())

for i in range(N,10000):
    cnt = 0
    for j in list(str(i)):
        if j in D:
            cnt += 1
            break
    if cnt == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
D = list(input().split())

for i in range(10000):
    cnt = 0
    for j in list(str(i)):
        if j in D:
            cnt += 1
    if cnt == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
D = list(input().split())

for i in range(N, 10000):
    cnt = 0
    for j in list(str(i)):
        if j in D:
            cnt += 1
    if cnt == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
D = list(input().split())

for i in range(N, 10001):
    cnt = 0
    for j in list(str(i)):
        if j in D:
            cnt += 1
    if cnt == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
D = {str(i) for i in range(0,10)} - set(input().split())
for i in range(N, 10000):
  num = set(str(i))
  if num <= D:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
N, K = map(int, input().split())
NotD = {str(i) for i in range(0,10)} - set(input().split())
for i in range(N, 10000):
  num = set(str(i))
  if num <= NotD:
    print(i)
    break

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
N, K = map(int, input().split())
hate_list = [s for s in input().rstrip().split()]

for i in range(N, 10000):
    str_list = set(list(str(i))) 
    l1_l2_and = set(str_list) & set(hate_list)
    if len(l1_l2_and) == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
N, K = map(int, input().split())
hate_list = [s for s in input().rstrip().split()]

for i in range(N, 10001):
    str_list = set(list(str(i))) 
    l1_l2_and = set(str_list) & set(hate_list)
    if len(l1_l2_and) == 0:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
import sys

payment = []
input = sys.stdin.readline
N, K = map(int, input().split())
hate_list = [s for s in input().rstrip().split()]

price_list = list(str(N))
reverse_price_list = price_list[::-1]

def hate_num(i):
    if i not in hate_list:
        payment.append(i)
    else:
        int_i = int(i) + 1
        if int_i >= 10:
            int_i = 0
        i = str(int_i)
        hate_num(i)

for i in reverse_price_list:
    hate_num(i)
reverse_payment = payment[::-1]
ans = ''.join(reverse_payment)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
N, K = map(int, input().split())

hate_list = [s for s in input().rstrip().split()]

price_list = list(str(N))
reverse_price_list = price_list[::-1]

payment = []

def hate_num(i, kuriagari=False):
    if kuriagari == True:
        int_i = int(i) + 1
        i = str(int_i)

    kuriagari = False

    if i not in hate_list:
        payment.append(i)
    else:
        int_i = int(i) + 1
        if int_i >= 10:
            int_i = 0
            kuriagari = True
        i = str(int_i)
        hate_num(i, kuriagari)

for i in reverse_price_list:
    hate_num(i)
reverse_payment = payment[::-1]
ans = ''.join(reverse_payment)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
N, K = map(int, input().split())

hate_list = [input().rstrip() for s in range(K)]

price_list = list(str(N))
reverse_price_list = price_list[::-1]

payment = []

def hate_num(i, kuriagari=False):
    if kuriagari == True:
        int_i = int(i) + 1
        i = str(int_i)

    kuriagari = False

    if i not in hate_list:
        payment.append(i)
    else:
        int_i = int(i) + 1
        if int_i >= 10:
            int_i = 0
            kuriagari = True
        i = str(int_i)
        hate_num(i, kuriagari)

for i in reverse_price_list:
    hate_num(i)
reverse_payment = payment[::-1]
ans = ''.join(reverse_payment)
print(ans)

Submission status: Wrong Answer

Solution code:
def check_digit(v, d):
    if v in d:
        return check_digit(str(int(v) + 1), d)
    else:
        return v

n, k = input().split()
d = input().split()

ans = []
for v in n:
    ans.append(check_digit(v, d))

print(''.join(ans))

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
D = list(map(int,input().split()))
ans = N
while ans <= 10**5:
  flg = True
  for i in range(len(str(N))):
    if int(str(ans)[i]) in D:
      flg = False
  if flg == True:
    print(ans)
    exit()
  else:
    ans += 1

Submission status: Wrong Answer

Solution code:
N,K = map(int,input().split())
D = list(map(int,input().split()))
X = []
for i in range(10):
  if i not in D:
    X.append(i)
#print(X)
ans = ""
L = str(N)
for i in range(len(L)):
  S = L[i]
  for j in X:
    if i == len(L) - 1 and L[:len(L)] == ans:
      if j > S:
        ans += str(j)
        break
    else:
      if str(j) >= S:
        ans += str(j) 
        break
print(ans)

Submission status: Wrong Answer

Solution code:
input_a = input().split()
kazu = int(input_a[0])
suuji_kosuu = int(input_a[1])

input_b = input().split()

for i in range(kazu,10000):
    t = 0
    for j in range(suuji_kosuu):
        if input_b[j] in str(i):
            break
        else:
            t = t+1
            continue
    if t == suuji_kosuu:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
input_a = input().split()
kazu = int(input_a[0]) + 1
suuji_kosuu = int(input_a[1])

input_b = input().split()

for i in range(kazu,10000):
    t = 0
    for j in range(suuji_kosuu):
        if input_b[j] in str(i):
            break
        else:
            t = t+1
            continue
    if t == suuji_kosuu:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
input_a = input().split()
kazu = int(input_a[0]) + 1
suuji_kosuu = int(input_a[1])

input_b = input().split()

for i in range(kazu,10000):
    for j in range(suuji_kosuu):
        if input_b[j] in str(i):
            break
        else:
            continue
    if j == suuji_kosuu-1:
        print(i)
        break

Submission status: Wrong Answer

Solution code:
def resolve():
	n,k=map(int,input().split())
	d=list(map(int,input().split()))
	t=1
	while True:
		chk=set(list(str(n*t)))
		for i in chk:
			if int(i) in d:
				t+=1
				break
		else:
			print(n*t)
			break
resolve()

Submission status: Wrong Answer

Solution code:
N,K=map(int,input().split())
D=list(map(int,input().split()))
C=[]

for i in range(0,10):
  if i not in D:
    C.append(i)
#print(C)

for i in range(N,10**10):
  cnt=0
  for j in list(map(int,list(str(i)))):
    cnt+=1
  if len(str(i))==cnt:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 1
while i != a + 1:
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i] = 0
    i += 1
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a + 1:
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i] = 0
    i += 1
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a:
    i += 1
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i] = 0
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 0
while i != a:
    i += 1
    if np.any(d == x[0]) and x[0] != 0:
        i = 0
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 1
while 1:
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
        i = 0
    i += 1
    if np.any(d == x[0]):
        i = 0
    if i == a - 1:
        break
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

i = 1
while 1:
    while np.any(d == x[i]):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
    i += 1
    if np.any(d == x[0]):
        i = 0
    if i == a - 1:
        break
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = list(map(int, input().split()))
d = np.array(list(map(int, input().split())))
a = len(str(n[0]))
x = np.zeros(a + 1)

for i in range(a + 1):
    x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i)

for i in range(1, a + 1):
    while np.any(x[i] == 1):
        x[i] += 1
        x[i + (i != a):] = 0
    if x[i] == 10:
        x[i - 1] += 1
        x[i:] = 0
        
ans = 0
for i in range(a + 1):
    ans += x[i] * np.power(10, a - i)

print(int(ans))